From f41ec6d42942f994f762486a9ab525ed8c5506e5 Mon Sep 17 00:00:00 2001 From: Epoch Qwert Date: Sun, 7 Sep 2014 02:37:46 -0500 Subject: took the hashtable stuff out of segfault and put it into a library. good idea? dunno. --- libhashtable/example.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 libhashtable/example.c (limited to 'libhashtable/example.c') 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 +#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; +} -- cgit v1.2.3