3 * This file is part of httpd
5 * 02/17/1996 Michael Temari <Michael@TemWare.Com>
6 * 07/07/1996 Initial Release Michael Temari <Michael@TemWare.Com>
7 * 12/29/2002 Initial Release Michael Temari <Michael@TemWare.Com>
10 #include <sys/types.h>
20 const char *days
[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
21 const char *months
[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
22 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
29 static char datebuffer
[80];
31 if(t
== (time_t *)NULL
)
32 (void) time(&worktime
);
36 tm
= localtime(&worktime
);
38 sprintf(datebuffer
, "%4d%02d%02d%02d%02d%02d",
42 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
52 static char datebuffer
[80];
54 if(t
== (time_t *)NULL
)
55 (void) time(&worktime
);
59 tm
= gmtime(&worktime
);
61 sprintf(datebuffer
, "%s, %02d %s %4d %02d:%02d:%02d GMT",
63 tm
->tm_mday
, months
[tm
->tm_mon
], 1900+tm
->tm_year
,
64 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
72 time_t worktime
, gtime
, ltime
;
77 worktime
= (time_t) -1;
83 for(i
= 0; i
< 7; i
++)
84 if(!strncmp(p
, days
[i
], 3)) break;
89 while(*p
&& *p
!= ' ') p
++;
90 if(!*p
) return(worktime
);
91 while(*p
&& *p
== ' ') p
++;
92 if(!*p
) return(worktime
);
94 if(*p
>= '0' && *p
<= '9') {
96 if(*(p
+1) >= '0' && *(p
+1) <= '9')
97 tm
.tm_mday
= 10 * (*p
- '0') + (*(p
+1) - '0');
102 for(i
= 0; i
< 12; i
++)
103 if(!strncmp(p
, months
[i
], 3)) break;
109 if(!*p
++) return(worktime
);
111 tm
.tm_year
= atoi(p
);
112 while(*p
&& *p
!= ' ') p
++;
116 tm
.tm_mday
= atoi(p
);
117 while(*p
&& *p
!= ' ') p
++;
118 while(*p
&& *p
== ' ') p
++;
119 if(!*p
) return(worktime
);
123 if(*p
< '0' || *p
> '9' || *(p
+1) < '0' || *(p
+1) > '9' || *(p
+2) != ':') return(worktime
);
124 tm
.tm_hour
= 10 * (*p
- '0') + (*(p
+1) - '0');
128 if(*p
< '0' || *p
> '9' || *(p
+1) < '0' || *(p
+1) > '9' || *(p
+2) != ':') return(worktime
);
129 tm
.tm_min
= 10 * (*p
- '0') + (*(p
+1) - '0');
133 if(*p
< '0' || *p
> '9' || *(p
+1) < '0' || *(p
+1) > '9' || *(p
+2) != ' ') return(worktime
);
134 tm
.tm_sec
= 10 * (*p
- '0') + (*(p
+1) - '0');
136 while(*p
&& *p
== ' ') p
++;
137 if(!*p
) return(worktime
);
139 if(*p
>= '0' && *p
<= '9')
140 tm
.tm_year
= atoi(p
);
142 if(*p
++ != 'G' || *p
++ != 'M' || *p
++ != 'T')
148 if(tm
.tm_year
> 1900)
151 worktime
= mktime(&tm
);
153 gtime
= mktime(gmtime(&worktime
));
154 tm2
= localtime(&worktime
);
158 worktime
= worktime
- (gtime
- ltime
);
177 for(ps
= msufx
; ps
!= NULL
; ps
= ps
->snext
)
178 if(!strcmp(ps
->suffix
, "") && dmt
== (char *) NULL
)
179 dmt
= ps
->mtype
->mimetype
;
181 if(!strcmp(p
, ps
->suffix
))
182 return(ps
->mtype
->mimetype
);
186 if(dmt
== (char *) NULL
)
187 dmt
= "application/octet-stream";
195 static char decode
[80];
204 if(*p
>= 'A' && *p
<= 'Z') c
[i
++] = *p
++ - 'A'; else
205 if(*p
>= 'a' && *p
<= 'z') c
[i
++] = *p
++ - 'a' + 26; else
206 if(*p
>= '0' && *p
<= '9') c
[i
++] = *p
++ - '0' + 52; else
207 if(*p
== '+') c
[i
++] = *p
++ - '+' + 62; else
208 if(*p
== '/') c
[i
++] = *p
++ - '/' + 63; else
209 if(*p
== '=') c
[i
++] = *p
++ - '='; else
212 decode
[d
++] = ((c
[0] << 2) | (c
[1] >> 4));
213 decode
[d
++] = ((c
[1] << 4) | (c
[2] >> 2));
214 decode
[d
++] = ((c
[2] << 6) | c
[3]);
222 int getparms(p
, parms
, maxparms
)
232 while(*p
&& LWS(*p
)) p
++;
234 parms
[np
++] = (char *)NULL
;
238 while(np
< maxparms
&& *p
) {
240 while(*p
&& !LWS(*p
)) p
++;
242 while(*p
&& LWS(*p
)) p
++;
256 if(toupper(*p
) == 'R') ua
|= URLA_READ
; else
257 if(toupper(*p
) == 'W') ua
|= URLA_WRITE
; else
258 if(toupper(*p
) == 'X') ua
|= URLA_EXEC
; else
259 if(toupper(*p
) == 'H') ua
|= URLA_HEADERS
; else