nxt_application.h (206:86a529b2ea9b) nxt_application.h (216:07257705cd64)
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_APPLICATION_H_INCLUDED_
9#define _NXT_APPLICATION_H_INCLUDED_
10
11
12typedef enum {
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_APPLICATION_H_INCLUDED_
9#define _NXT_APPLICATION_H_INCLUDED_
10
11
12typedef enum {
13 NXT_APP_UNKNOWN = 0,
14 NXT_APP_PYTHON,
13 NXT_APP_PYTHON,
15 NXT_APP_PYTHON2,
16 NXT_APP_PYTHON3,
17 NXT_APP_PHP,
14 NXT_APP_PHP,
18 NXT_APP_PHP5,
19 NXT_APP_PHP7,
20 NXT_APP_RUBY,
21 NXT_APP_GO,
22
15 NXT_APP_GO,
16
23 NXT_APP_MAX,
17 NXT_APP_UNKNOWN,
24} nxt_app_type_t;
25
26
18} nxt_app_type_t;
19
20
21typedef struct nxt_app_module_s nxt_application_module_t;
22typedef struct nxt_app_module_s nxt_app_module_t;
23
24
25typedef struct {
26 nxt_str_t type;
27 nxt_str_t version;
28 char *file;
29 nxt_application_module_t *module;
30} nxt_app_lang_module_t;
31
32
27typedef struct nxt_common_app_conf_s nxt_common_app_conf_t;
28
29
30typedef struct {
31 nxt_str_t path;
32 nxt_str_t module;
33} nxt_python_app_conf_t;
34

--- 8 unchanged lines hidden (view full) ---

43typedef struct {
44 nxt_str_t executable;
45} nxt_go_app_conf_t;
46
47
48struct nxt_common_app_conf_s {
49 nxt_str_t name;
50 nxt_str_t type;
33typedef struct nxt_common_app_conf_s nxt_common_app_conf_t;
34
35
36typedef struct {
37 nxt_str_t path;
38 nxt_str_t module;
39} nxt_python_app_conf_t;
40

--- 8 unchanged lines hidden (view full) ---

49typedef struct {
50 nxt_str_t executable;
51} nxt_go_app_conf_t;
52
53
54struct nxt_common_app_conf_s {
55 nxt_str_t name;
56 nxt_str_t type;
51 nxt_app_type_t type_id;
52 nxt_str_t user;
53 nxt_str_t group;
54
55 uint32_t workers;
56
57 union {
58 nxt_python_app_conf_t python;
59 nxt_php_app_conf_t php;

--- 83 unchanged lines hidden (view full) ---

143 nxt_buf_t *buf; /* current buffer to read */
144};
145
146
147nxt_inline u_char *
148nxt_app_msg_write_length(u_char *dst, size_t length);
149
150/* TODO asynchronous mmap buffer assignment */
57 nxt_str_t user;
58 nxt_str_t group;
59
60 uint32_t workers;
61
62 union {
63 nxt_python_app_conf_t python;
64 nxt_php_app_conf_t php;

--- 83 unchanged lines hidden (view full) ---

148 nxt_buf_t *buf; /* current buffer to read */
149};
150
151
152nxt_inline u_char *
153nxt_app_msg_write_length(u_char *dst, size_t length);
154
155/* TODO asynchronous mmap buffer assignment */
151u_char *nxt_app_msg_write_get_buf(nxt_task_t *task, nxt_app_wmsg_t *msg,
152 size_t size);
156NXT_EXPORT u_char *nxt_app_msg_write_get_buf(nxt_task_t *task,
157 nxt_app_wmsg_t *msg, size_t size);
153
158
154nxt_int_t nxt_app_msg_write(nxt_task_t *task, nxt_app_wmsg_t *msg,
159NXT_EXPORT nxt_int_t nxt_app_msg_write(nxt_task_t *task, nxt_app_wmsg_t *msg,
155 u_char *c, size_t size);
156
160 u_char *c, size_t size);
161
157nxt_int_t nxt_app_msg_write_prefixed_upcase(nxt_task_t *task,
162NXT_EXPORT nxt_int_t nxt_app_msg_write_prefixed_upcase(nxt_task_t *task,
158 nxt_app_wmsg_t *msg, const nxt_str_t *prefix, const nxt_str_t *v);
159
160nxt_inline nxt_int_t
161nxt_app_msg_write_nvp_(nxt_task_t *task, nxt_app_wmsg_t *msg,
162 u_char *n, size_t nsize, u_char *v, size_t vsize);
163
164
165#define nxt_app_msg_write_const(task, msg, c) \

--- 7 unchanged lines hidden (view full) ---

173
174#define nxt_app_msg_write_nvp(task, msg, n, v) \
175 nxt_app_msg_write_nvp_((task), (msg), (u_char *)(n), sizeof(n) - 1, \
176 (v)->start, (v)->length)
177
178nxt_inline nxt_int_t nxt_app_msg_write_size(nxt_task_t *task,
179 nxt_app_wmsg_t *msg, size_t size);
180
163 nxt_app_wmsg_t *msg, const nxt_str_t *prefix, const nxt_str_t *v);
164
165nxt_inline nxt_int_t
166nxt_app_msg_write_nvp_(nxt_task_t *task, nxt_app_wmsg_t *msg,
167 u_char *n, size_t nsize, u_char *v, size_t vsize);
168
169
170#define nxt_app_msg_write_const(task, msg, c) \

--- 7 unchanged lines hidden (view full) ---

178
179#define nxt_app_msg_write_nvp(task, msg, n, v) \
180 nxt_app_msg_write_nvp_((task), (msg), (u_char *)(n), sizeof(n) - 1, \
181 (v)->start, (v)->length)
182
183nxt_inline nxt_int_t nxt_app_msg_write_size(nxt_task_t *task,
184 nxt_app_wmsg_t *msg, size_t size);
185
181nxt_int_t nxt_app_msg_flush(nxt_task_t *task, nxt_app_wmsg_t *msg,
186NXT_EXPORT nxt_int_t nxt_app_msg_flush(nxt_task_t *task, nxt_app_wmsg_t *msg,
182 nxt_bool_t last);
183
187 nxt_bool_t last);
188
184nxt_int_t nxt_app_msg_write_raw(nxt_task_t *task, nxt_app_wmsg_t *msg,
185 const u_char *c, size_t size);
189NXT_EXPORT nxt_int_t nxt_app_msg_write_raw(nxt_task_t *task,
190 nxt_app_wmsg_t *msg, const u_char *c, size_t size);
186
191
187nxt_int_t nxt_app_msg_read_str(nxt_task_t *task, nxt_app_rmsg_t *msg,
192NXT_EXPORT nxt_int_t nxt_app_msg_read_str(nxt_task_t *task, nxt_app_rmsg_t *msg,
188 nxt_str_t *str);
189
193 nxt_str_t *str);
194
190size_t nxt_app_msg_read_raw(nxt_task_t *task, nxt_app_rmsg_t *msg, void *buf,
191 size_t size);
195NXT_EXPORT size_t nxt_app_msg_read_raw(nxt_task_t *task,
196 nxt_app_rmsg_t *msg, void *buf, size_t size);
192
197
193nxt_int_t nxt_app_msg_read_nvp(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
194 nxt_str_t *n, nxt_str_t *v);
198NXT_EXPORT nxt_int_t nxt_app_msg_read_nvp(nxt_task_t *task,
199 nxt_app_rmsg_t *rmsg, nxt_str_t *n, nxt_str_t *v);
195
200
196nxt_int_t nxt_app_msg_read_size(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
197 size_t *size);
201NXT_EXPORT nxt_int_t nxt_app_msg_read_size(nxt_task_t *task,
202 nxt_app_rmsg_t *rmsg, size_t *size);
198
199
203
204
200typedef struct nxt_app_module_s nxt_application_module_t;
201typedef struct nxt_app_module_s nxt_app_module_t;
202
203struct nxt_app_module_s {
205struct nxt_app_module_s {
206 nxt_str_t type;
207 nxt_str_t version;
208
204 nxt_int_t (*init)(nxt_task_t *task,
205 nxt_common_app_conf_t *conf);
209 nxt_int_t (*init)(nxt_task_t *task,
210 nxt_common_app_conf_t *conf);
206 nxt_int_t (*prepare_msg)(nxt_task_t *task,
207 nxt_app_request_t *r,
208 nxt_app_wmsg_t *wmsg);
209 nxt_int_t (*run)(nxt_task_t *task,
210 nxt_app_rmsg_t *rmsg,
211 nxt_app_wmsg_t *wmsg);
212};
213
214
211 nxt_int_t (*run)(nxt_task_t *task,
212 nxt_app_rmsg_t *rmsg,
213 nxt_app_wmsg_t *wmsg);
214};
215
216
215extern nxt_application_module_t *nxt_app_modules[NXT_APP_MAX];
216
217
218
219nxt_int_t nxt_app_http_read_body(nxt_app_request_t *r, u_char *data,
220 size_t len);
221nxt_int_t nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t len);
222
223nxt_inline u_char *
224nxt_app_msg_write_length(u_char *dst, size_t length)
225{
226 if (length < 128) {

--- 58 unchanged lines hidden (view full) ---

285 src[3];
286 src += 4;
287 }
288
289 return src;
290}
291
292
217nxt_int_t nxt_app_http_read_body(nxt_app_request_t *r, u_char *data,
218 size_t len);
219nxt_int_t nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t len);
220
221nxt_inline u_char *
222nxt_app_msg_write_length(u_char *dst, size_t length)
223{
224 if (length < 128) {

--- 58 unchanged lines hidden (view full) ---

283 src[3];
284 src += 4;
285 }
286
287 return src;
288}
289
290
291nxt_app_lang_module_t *nxt_app_lang_module(nxt_runtime_t *rt, nxt_str_t *name);
293nxt_app_type_t nxt_app_parse_type(nxt_str_t *str);
294
292nxt_app_type_t nxt_app_parse_type(nxt_str_t *str);
293
294
295extern nxt_application_module_t nxt_go_module;
296
297
295#endif /* _NXT_APPLICATION_H_INCLIDED_ */
298#endif /* _NXT_APPLICATION_H_INCLIDED_ */