Added a separate keymap for escaped scancodes. This makes the code
[minix.git] / commands / httpd0995 / process.c
blob665fc70a82a19eba9ac5f8b9382ae94477d23510
1 /* process.c
3 * This file is part of httpd.
5 * 02/17/1996 Michael Temari <Michael@TemWare.Com>
6 * 07/07/1996 Initial Relase Michael Temari <Michael@TemWare.Com>
7 * 12/29/2002 Michael Temari <Michael@TemWare.Com>
8 * 05/14/2006 Michael Temari <Michael@TemWare.Com>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <ctype.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <time.h>
18 #include <fcntl.h>
19 #include <unistd.h>
20 #include <errno.h>
22 #include "config.h"
23 #include "http.h"
24 #include "utility.h"
26 int processrequest(rq, rp)
27 struct http_request *rq;
28 struct http_reply *rp;
30 /* clear out http_reply */
31 memset(rp, 0, sizeof(*rp));
32 rp->status = HTTP_STATUS_OK;
33 strcpy(rp->statusmsg, "OK");
34 rp->modtime = (time_t) -1;
35 rp->urlaccess = -1;
36 rp->size = 0;
37 rp->fd = -1;
38 rp->ofd = -1;
39 rp->pid = 0;
41 if(Redirect != NULL) {
42 rp->status = HTTP_STATUS_MOVED_PERM;
43 strcpy(rp->realurl, Redirect);
44 strcat(rp->realurl, rq->uri);
45 strcpy(rq->url, rp->realurl);
46 return(0);
49 /* Simple requests can only be a GET */
50 if(rq->type == HTTP_REQUEST_TYPE_SIMPLE && rq->method != HTTP_METHOD_GET) {
51 rp->status = HTTP_STATUS_BAD_REQUEST;
52 strcpy(rp->statusmsg, "Bad request");
53 return(0);
56 /* I don't know this method */
57 if(rq->method == HTTP_METHOD_UNKNOWN) {
58 rp->status = HTTP_STATUS_NOT_IMPLEMENTED;
59 strcpy(rp->statusmsg, "Method not implemented");
60 return(0);
63 /* Check for access and real location of url */
64 if(police(rq, rp))
65 return(-1);
67 /* We're done if there was an error accessing the url */
68 if(rp->status != HTTP_STATUS_OK)
69 return(0);
71 /* Check to see if we have a newer version for them */
72 if(rq->method == HTTP_METHOD_GET)
73 if(rq->ifmodsince != (time_t) -1)
74 if(rq->ifmodsince < time((time_t *)NULL))
75 if(rp->modtime != (time_t) -1 && rp->modtime <= rq->ifmodsince) {
76 rp->status = HTTP_STATUS_NOT_MODIFIED;
77 strcpy(rp->statusmsg, "Not modified");
78 close(rp->fd);
79 rp->fd = -1;
80 return(0);
83 rp->status = HTTP_STATUS_OK;
84 strcpy(rp->statusmsg, "OK");
86 if(rp->size != 0)
87 rp->keepopen = rq->keepopen;
89 return(0);