summaryrefslogtreecommitdiff
path: root/libhashtable/example.c
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-09-07 02:37:46 -0500
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-09-07 02:37:46 -0500
commitf41ec6d42942f994f762486a9ab525ed8c5506e5 (patch)
tree2834f14db4cdac0a8efb9bb810741af2d38e287d /libhashtable/example.c
parent5b723a9da5b94d3a99225f43c7dafcffa1f7676b (diff)
downloadsegfault-f41ec6d42942f994f762486a9ab525ed8c5506e5.tar.gz
segfault-f41ec6d42942f994f762486a9ab525ed8c5506e5.zip
took the hashtable stuff out of segfault and put it into a library. good idea? dunno.
Diffstat (limited to 'libhashtable/example.c')
-rw-r--r--libhashtable/example.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libhashtable/example.c b/libhashtable/example.c
new file mode 100644
index 0000000..614e440
--- /dev/null
+++ b/libhashtable/example.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include "libhashtable.h"
+
+extern char **environ;
+
+int main(int argc,char *argv[]) {
+ struct hashtable ht;
+ int i;
+ char *name;
+ char *value;
+ inittable(&ht);
+ for(i=0;environ[i];i++) {
+ name=strdup(environ[i]);
+ if((value=strchr(name,'=') )){
+ *value=0;
+ value++;
+ }
+ //printf("'%s' = '%s'\n",name,value);
+ ht_setkey(&ht,name,value);
+ free(name);
+ }
+ printf("PATH='%s'\n",ht_getvalue(&ht,"PATH"));
+ return 0;
+}