24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include <ucx/string.h> |
29 #include <cx/string.h> |
30 #include <ucx/map.h> |
30 #include <cx/map.h> |
31 |
31 |
32 #include "objecttype.h" |
32 #include "objecttype.h" |
33 #include "../util/pblock.h" |
33 #include "../util/pblock.h" |
34 |
34 |
35 #include "../daemon/config.h" |
35 #include "../daemon/config.h" |
36 #include "../daemon/session.h" |
36 #include "../daemon/session.h" |
37 |
37 |
38 int object_type_by_extension(pblock *pb, Session *sn, Request *rq) { |
38 int object_type_by_extension(pblock *pb, Session *sn, Request *rq) { |
39 sstr_t path = sstr(pblock_findkeyval(pb_key_path, rq->vars)); |
39 cxstring path = cx_str(pblock_findkeyval(pb_key_path, rq->vars)); |
40 //printf("\nobject_type_by_extension: {%s}[%d]\n\n", path); |
40 //printf("\nobject_type_by_extension: {%s}[%d]\n\n", path); |
41 |
41 |
42 sstr_t ct; |
42 cxstring ct; |
43 if(path.ptr[path.length - 1] == '/') { |
43 if(path.ptr[path.length - 1] == '/') { |
44 // directory |
44 // directory |
45 ct = sstrn("internal/directory", 18); |
45 ct = (cxstring)CX_STR("internal/directory"); |
46 } else { |
46 } else { |
47 sstr_t ext; |
47 cxstring ext; |
48 ext.length = 0; |
48 ext.length = 0; |
49 for(int i=path.length - 1;i>=0;i--) { |
49 for(int i=path.length - 1;i>=0;i--) { |
50 if(path.ptr[i] == '.') { |
50 if(path.ptr[i] == '.') { |
51 ext.ptr = path.ptr + i + 1; |
51 ext.ptr = path.ptr + i + 1; |
52 ext.length = path.length - i - 1; |
52 ext.length = path.length - i - 1; |