// A list of handlers for mime types struct hand_l { char *t_mime; char *b_mime; int *function; struct hand_l* next; } // This adds a handler for a mime type void addhandler(struct hand_l handlers,char *t_mime,char *b_mime,int *func) { struct hand_l newhandler=NULL; strdup(newhandler->t_mime,t_mime); strdup(newhandler->b_mime, b_mime); newhandler->function = function; newhandler->next=null; while (handlers->next != NULL) { handlers=handlers->next; } handlers->next = newhandler; } // given a mime type, finds a handler function struct *handl_l findhandler( struct hand_l list, char *t_mime, char* b_mime) { int * funcret=NULL; while (handlers->next !=NULL) { if (strcmp(list->t_mime,t_mime) && strcmp(list->b_mime, b_mime)) { funcret = list-> function; break; } } return funcret; } // pull out "text" from "text/html" char * getmajormime(char *fullmime) { char *tempwork; char *retval; char slashloc=NULL; tempwork = strdupa(fullmime); slashloc = strchr(tempwork,'/'); if (slashloc) { *slashloc = NULL; } retval = strdup(tempwork); return(retval); } // pull out "html" from "text/html" char * getminormime(char *fullmime) { char *tempwork; char *retval; char slashloc=NULL; tempwork = strdupa(fullmime); slashloc = strchr(tempwork,'/'); if (slashloc) { tempwork = slashloc; } retval = strdup(tempwork); return(retval); } // finds the mime type for a file char * findmimetype(char *filename) { // Find something to figure it out }