Revision 1.2 |
Revision 1.3 |
Line 4 |
Line 4 |
* This file is still quite primitive as you can see. */  
|
* This file is still quite primitive as you can see. */  
|
# include <stdlib.h>
# include <string.h>
# include "mime.h"
# include "utl.h"
|
#include <stdlib.h>
#include <string.h>
#include "cow_config.h"
#include "mime.h"
|
|
#include "utl.h"
|
Mime mime[256]; int mime_idx; // char* mime_tab[3];
|
Mime mime[256]; int mime_idx; // char* mime_tab[3];
|
char default_type[16];
|
|
void add_mime_type(FILE * fp, char *media_type) {
|
void add_mime_type(FILE * fp, char *media_type) {
|
Line 57 |
Line 57 |
int h; char mt_buf[128];
|
int h; char mt_buf[128];
|
default_type[0] = '\0';
strcat(default_type, "text/html");
|
/*
* If a global mime type was set in the config file, we'll just use that
|
|
* and we don't need to read the list.
*/
if (global_mime)
return 0;
|
mime_idx = 0; for (;;) {
|
mime_idx = 0; for (;;) {
|
Line 97 |
Line 101 |
char *suffix; int i = 0;
|
char *suffix; int i = 0;
|
|
/* If there's a global mime type defined, return that */
if (global_mime)
return global_mime;
|
suffix = strrchr(filename, '.');
|
suffix = strrchr(filename, '.');
|
|
|
if (!suffix || '\0' == *suffix)
|
if (!suffix || '\0' == *suffix)
|
return default_type;
|
return default_mime ? default_mime : "text/plain";
|
suffix++; // don't want '.'
|
suffix++; // don't want '.'
|
Line 109 |
Line 116 |
return mime[i].types; }
|
return mime[i].types; }
|
return default_type;
|
/*
|
|
* Suffix not found in list. If a default was set in the config file,
* return that. If not, just return text/plain.
*/
return default_mime ? default_mime : "text/plain";
|
}
|
}
|