tinywebd

changeset 9:0244b08cc9d3

fixed the mime-type bug
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 18 Apr 2015 21:36:07 +0300
parents 121b991ccc1d
children 0dd50a23f3dd
files src/main.c src/mime.c
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/src/main.c	Fri Apr 17 12:02:59 2015 +0300
     1.2 +++ b/src/main.c	Sat Apr 18 21:36:07 2015 +0300
     1.3 @@ -21,7 +21,9 @@
     1.4  	signal(SIGTERM, sighandler);
     1.5  	signal(SIGQUIT, sighandler);
     1.6  
     1.7 -	tw_start();
     1.8 +	if(tw_start() == -1) {
     1.9 +		return 1;
    1.10 +	}
    1.11  
    1.12  	for(;;) {
    1.13  		int i;
     2.1 --- a/src/mime.c	Fri Apr 17 12:02:59 2015 +0300
     2.2 +++ b/src/mime.c	Sat Apr 18 21:36:07 2015 +0300
     2.3 @@ -17,8 +17,7 @@
     2.4  	{"jpeg", "image/jpeg"},
     2.5  	{"gif", "image/gif"},
     2.6  	{"bmp", "image/bmp"},
     2.7 -	{"cgi", 0}
     2.8 -,
     2.9 +	{"cgi", 0},
    2.10  	{0, 0}
    2.11  };
    2.12  
    2.13 @@ -33,7 +32,7 @@
    2.14  
    2.15  	if(types) return 0;
    2.16  
    2.17 -	if((types = rb_create(RB_KEY_STRING))) {
    2.18 +	if(!(types = rb_create(RB_KEY_STRING))) {
    2.19  		return -1;
    2.20  	}
    2.21  	rb_set_delete_func(types, del_func, 0);
    2.22 @@ -54,7 +53,7 @@
    2.23  {
    2.24  	init_types();
    2.25  
    2.26 -	return rb_insert(types, strdup(suffix), strdup(type));
    2.27 +	return rb_insert(types, strdup(suffix), type ? strdup(type) : 0);
    2.28  }
    2.29  
    2.30  const char *mime_type(const char *path)