summaryrefslogtreecommitdiff
path: root/httpd/httpd-fs.c
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2016-12-14 09:14:39 -0500
committerJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2016-12-14 09:14:39 -0500
commitdc65ef038279df55d5e49052eabac4eae2617ee1 (patch)
tree84c7ffc081482c18c2bc0a6ddb1a4d6dd260f925 /httpd/httpd-fs.c
parent84de937689bcb35ea3ddae55d9c74dc23463f79c (diff)
downloaduIP-FOSSIL-dc65ef038279df55d5e49052eabac4eae2617ee1.tar.gz
uIP-FOSSIL-dc65ef038279df55d5e49052eabac4eae2617ee1.zip
Now compiles with Turbo C 2.0 using included makefile. Added better logging (to screen). Added supprot for opening and sending gzip'ed files if available on disk.
Diffstat (limited to 'httpd/httpd-fs.c')
-rw-r--r--httpd/httpd-fs.c67
1 files changed, 58 insertions, 9 deletions
diff --git a/httpd/httpd-fs.c b/httpd/httpd-fs.c
index 18d5729..a694fbc 100644
--- a/httpd/httpd-fs.c
+++ b/httpd/httpd-fs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009 Jeffrey Armstrong
+ * Copyright (c) 2009, 2016 Jeffrey Armstrong
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,17 +36,11 @@
#include <stdlib.h>
#include <string.h>
#include <dos.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "httpd-fs.h"
-void change_to_backslash(char *name)
-{
-int counter;
- for(counter=0;counter<strlen(name);counter++) {
- if(name[counter]=='/') name[counter] = '\\';
- }
-}
-
void safe_name(char *name)
{
#ifdef WATCOM
@@ -59,6 +53,61 @@ char *newtext;
#endif
}
+void change_to_backslash(char *name)
+{
+int counter;
+ for(counter=0;counter<strlen(name);counter++) {
+ if(name[counter]=='/') name[counter] = '\\';
+ }
+}
+
+int compressed_name(char *str)
+{
+char *ext;
+
+ if(str == NULL)
+ return -1;
+
+ ext = strrchr(str, '.');
+ if(ext == NULL || strlen(ext) < 4)
+ return -1;
+
+ ext[2] = 'g';
+ ext[3] = 'z';
+ return 1;
+}
+
+int compressed_available(const char *name)
+{
+char *cname;
+char *noslash;
+int ret;
+struct stat st;
+
+ if(name == NULL) return -1;
+
+ noslash = name;
+ while(noslash[0] == '/') noslash++;
+ if(noslash[0] == '\0') noslash = "index.htm";
+
+ cname = (char *)malloc((strlen(noslash)+1)*sizeof(char));
+ if(cname == NULL) return -1;
+
+ strcpy(cname, noslash);
+ ret = compressed_name(cname);
+
+ if(ret == 1) {
+ change_to_backslash(cname);
+ safe_name(cname);
+
+ if(stat(cname,&st) < 0)
+ ret = -1;
+ }
+
+ free(cname);
+ return ret;
+}
+
int httpd_fs_open(char *name, struct httpd_fs_file *file)
{
FILE *fp;