summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/WebSTONE/src/nsapi-includes/frame/req.h
blob: e198ce22df81b4f828705cf1a7c687cb9d0ce470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
 * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
 * rights reserved.
 *
 * Use of this software is governed by the terms of the license agreement for
 * the Netscape Communications or Netscape Comemrce Server between the
 * parties.
 */


/* ------------------------------------------------------------------------ */


/*
 * req.h: Request-specific data structures and functions
 *
 * Rob McCool
 */


#ifndef REQ_H
#define REQ_H


#include "netsite.h"
#include "base/pblock.h"
#include "base/session.h"
#include "frame/objset.h"

#include <sys/stat.h>



/* ------------------------------ Constants ------------------------------- */


#define REQ_HASHSIZE 10
#define REQ_MAX_LINE 4096


/*
 * The REQ_ return codes. These codes are used to determine what the server
 * should do after a particular module completes its task.
 *
 * Func type functions return these as do many internal functions.
 */

/* The function performed its task, proceed with the request */
#define REQ_PROCEED 0
/* The entire request should be aborted: An error occurred */
#define REQ_ABORTED -1
/* The function performed no task, but proceed anyway. */
#define REQ_NOACTION -2
/* Tear down the session and exit */
#define REQ_EXIT -3



/* ------------------------------ Structures ------------------------------ */


typedef struct {
    /* Server working variables */
    pblock *vars;

    /* The method, URI, and protocol revision of this request */
    pblock *reqpb;
    /* Protocol specific headers */
    int loadhdrs;
    pblock *headers;

    /* Server's response headers */
    pblock *srvhdrs;

    /* The object set constructed to fulfill this request */
    httpd_objset *os;
    /* Array of objects that were created from .nsconfig files */
    httpd_objset *tmpos;

    /* The stat last returned by request_stat_path */
    char *statpath;
    char *staterr;
    struct stat *finfo;

#ifdef MCC_PROXY
    /* SOCKS request data */
    void *socks_rq;
#endif

} Request;


/* ------------------------------ Prototypes ------------------------------ */


/*
 * request_create creates a new request structure.
 */

Request *request_create(void);

/*
 * request_free destroys a request structure.
 */

void request_free(Request *req);


/*
 * Restarts a request for a given URI internally. If rq is non-NULL, the
 * function will keep the old request's headers and protocol, but with a new
 * URI and method of GET. If the previous method was HEAD, this is preserved.
 * Any other method becomes GET. You may assume that if you give it a request
 * structure that it will use the same structure.
 *
 * Once you have this new Request, you must then do what you want with
 * it (e.g. send the object back, perform uri2path translation, etc.)
 */

Request *request_restart_internal(char *uri, Request *rq);


/*
 * request_translate_uri performs virtual to physical mapping on the given
 * uri and returns either a path string or NULL depending on whether it was
 * successful or not.
 */

char *request_translate_uri(char *uri, Session *sn);


/*
 * request_header finds the named header depending on the requesting
 * protocol. If possible, it will not load headers until the first is
 * requested. You have to watch out because this can return REQ_ABORTED.
 */

int request_header(char *name, char **value, Session *sn, Request *rq);

/*
 * request_loadheaders just makes sure the headers have been loaded.
 */

int request_loadheaders(Session *sn, Request *rq);


/*
 * request_stat_path tries to stat path. If path is NULL, it will look in
 * the vars pblock for "path". If the stat is successful, it returns the stat
 * structure. If not, returns NULL and leaves a message in rq->staterr. If a
 * previous call to this function was successful, and path is the same, the
 * function will simply return the previously found value.
 *
 * User functions should not free this structure.
 */

struct stat *request_stat_path(char *path, Request *rq);


/*
 * Parses the URI parameter in rq->vars and finds out what objects it
 * references (using NameTrans). Builds the request's object set.
 */

int request_uri2path(Session *sn, Request *rq);

/*
 * Performs any path checks needed for this request.
 */

int request_pathchecks(Session *sn, Request *rq);

/*
 * Does all the ObjectType directives for a request
 */

int request_fileinfo(Session *sn, Request *rq);


/*
 * request_handle_processed takes a Request structure with its reqpb
 * block filled in and handles the request.
 */

int request_handle_processed(Session *sn, Request *rq);


/*
 * Complete a request by finding the service function and using it. Returns
 * REQ_NOACTION if no matching function was found.
 */

int request_service(Session *sn, Request *rq);


/*
 * request_handle handles one request from the session's inbuf.
 */

void request_handle(Session *sn);

/*
 * Moved here due to problems with interdependency. See object.h for
 * description.
 */

int object_findnext(Session *sn, Request *rq, httpd_object *obj);
int object_pathcheck(Session *sn, Request *rq, httpd_object *obj);
int object_findinfo(Session *sn, Request *rq, httpd_object *obj);
int object_findservice(Session *sn, Request *rq, httpd_object *obj);
int object_finderror(Session *sn, Request *rq, httpd_object *obj);
int object_findlogs(Session *sn, Request *rq, httpd_object *obj);

#endif