src/server/safs/objecttype.c

changeset 77
f1cff81e425a
parent 61
c858850f3d3a
child 87
bdec069d2239
equal deleted inserted replaced
76:5f7660fe1562 77:f1cff81e425a
34 #include "../daemon/config.h" 34 #include "../daemon/config.h"
35 #include "../daemon/session.h" 35 #include "../daemon/session.h"
36 36
37 int object_type_by_extension(pblock *pb, Session *sn, Request *rq) { 37 int object_type_by_extension(pblock *pb, Session *sn, Request *rq) {
38 sstr_t ppath = sstr(pblock_findkeyval(pb_key_ppath, rq->vars)); 38 sstr_t ppath = sstr(pblock_findkeyval(pb_key_ppath, rq->vars));
39
40 //printf("\nobject_type_by_extension: {%s}[%d]\n\n", ppath); 39 //printf("\nobject_type_by_extension: {%s}[%d]\n\n", ppath);
41 40
42 sstr_t ct; 41 sstr_t ct;
43 if(ppath.ptr[ppath.length - 1] == '/') { 42 if(ppath.ptr[ppath.length - 1] == '/') {
44 /* directory */ 43 // directory
45 ct = sstrn("internal/directory", 18); 44 ct = sstrn("internal/directory", 18);
46 } else { 45 } else {
47 sstr_t ext; 46 sstr_t ext;
48 ext.length = 0; 47 ext.length = 0;
49 for(int i=ppath.length - 1;i>=0;i--) { 48 for(int i=ppath.length - 1;i>=0;i--) {
52 ext.length = ppath.length - i - 1; 51 ext.length = ppath.length - i - 1;
53 } 52 }
54 } 53 }
55 54
56 if(ext.length == 0) { 55 if(ext.length == 0) {
57 /* no extension, no type */ 56 // no extension, no type
58 return REQ_NOACTION; 57 return REQ_NOACTION;
59 } 58 }
60 59
61 /* get the mime type for the ext from the server configuration */ 60 // get the mime type for the ext from the server configuration
62 ServerConfiguration *config = session_get_config(sn); 61 ServerConfiguration *config = session_get_config(sn);
63 char *type = ucx_map_sstr_get(config->mimetypes->map, ext); 62 char *type = ucx_map_sstr_get(config->mimetypes->map, ext);
64 63
65 if(!type) { 64 if(!type) {
66 return REQ_NOACTION; 65 return REQ_NOACTION;

mercurial