xref: /plan9/sys/src/libhttpd/checkcontent.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include <u.h>
2 #include <libc.h>
3 #include <bin.h>
4 #include <httpd.h>
5 
6 int
hcheckcontent(HContent * me,HContent * oks,char * list,int size)7 hcheckcontent(HContent *me, HContent *oks, char *list, int size)
8 {
9 	HContent *ok;
10 
11 	if(oks == nil || me == nil)
12 		return 1;
13 	for(ok = oks; ok != nil; ok = ok->next){
14 		if((cistrcmp(ok->generic, me->generic) == 0 || strcmp(ok->generic, "*") == 0)
15 		&& (me->specific == nil || cistrcmp(ok->specific, me->specific) == 0 || strcmp(ok->specific, "*") == 0)){
16 			if(ok->mxb > 0 && size > ok->mxb)
17 				return 0;
18 			return 1;
19 		}
20 	}
21 
22 	USED(list);
23 	if(0){
24 		fprint(2, "list: %s/%s not found\n", me->generic, me->specific);
25 		for(; oks != nil; oks = oks->next){
26 			if(oks->specific)
27 				fprint(2, "\t%s/%s\n", oks->generic, oks->specific);
28 			else
29 				fprint(2, "\t%s\n", oks->generic);
30 		}
31 	}
32 	return 0;
33 }
34