Klaus Demo bjoern / 449e381
Merge pull request #63 from patricklucas/fix_warnings Fixed some compiler warnings. Thanks to Patrick Lucas for the patch! Jonas Haag 8 years ago
8 changed file(s) with 20 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
1212 $(wildcard $(SOURCE_DIR)/*.c))
1313
1414 CPPFLAGS += $(PYTHON_INCLUDE) -I . -I $(SOURCE_DIR) -I $(HTTP_PARSER_DIR)
15 CFLAGS += $(FEATURES) -std=c99 -fno-strict-aliasing -Wall -Wextra \
16 -Wno-unused -g -O0 -fPIC
15 CFLAGS += $(FEATURES) -std=c99 -fno-strict-aliasing -fcommon -fPIC -Wall \
16 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g -O0
1717 LDFLAGS += $(PYTHON_LDFLAGS) -l ev -shared -fcommon
1818
1919 ifneq ($(WANT_SENDFILE), no)
8989 {NULL, NULL, 0, NULL}
9090 };
9191
92 PyMODINIT_FUNC initbjoern()
92 PyMODINIT_FUNC initbjoern(void)
9393 {
9494 _init_common();
9595 _init_filewrapper();
2020 enum http_status { HTTP_BAD_REQUEST = 1, HTTP_LENGTH_REQUIRED, HTTP_SERVER_ERROR };
2121
2222 size_t unquote_url_inplace(char* url, size_t len);
23 void (_init_common)();
23 void _init_common(void);
2424
2525 PyObject *_REMOTE_ADDR, *_PATH_INFO, *_QUERY_STRING, *_REQUEST_METHOD, *_GET,
2626 *_HTTP_CONTENT_LENGTH, *_CONTENT_LENGTH, *_HTTP_CONTENT_TYPE, *_CONTENT_TYPE,
4444 (destructor)FileWrapper_dealloc, /* tp_dealloc */
4545 };
4646
47 void _init_filewrapper()
47 void _init_filewrapper(void)
4848 {
4949 FileWrapper_Type.tp_new = FileWrapper_New;
5050 FileWrapper_Type.tp_iter = FileWrapper_Iter;
88 PyObject* file;
99 } FileWrapper;
1010
11 void (_init_filewrapper)();
11 void _init_filewrapper(void);
107107 Py_DECREF(val); \
108108 } while(0)
109109
110 static int on_message_begin(http_parser* parser)
110 static int
111 on_message_begin(http_parser* parser)
111112 {
112113 REQUEST->headers = PyDict_New();
113114 PARSER->field = (string){NULL, 0};
115116 return 0;
116117 }
117118
118 static int on_path(http_parser* parser, char* path, size_t len)
119 {
120 if(!(len = unquote_url_inplace(path, len)))
119 static int
120 on_path(http_parser* parser, const char* path, size_t len)
121 {
122 if(!(len = unquote_url_inplace((char*)path, len)))
121123 return 1;
122124 _set_header_free_value(_PATH_INFO, PyString_FromStringAndSize(path, len));
123125 return 0;
124126 }
125127
126 static int on_query_string(http_parser* parser, const char* query, size_t len)
128 static int
129 on_query_string(http_parser* parser, const char* query, size_t len)
127130 {
128131 _set_header_free_value(_QUERY_STRING, PyString_FromStringAndSize(query, len));
129132 return 0;
130133 }
131134
132 static int on_header_field(http_parser* parser, const char* field, size_t len)
135 static int
136 on_header_field(http_parser* parser, const char* field, size_t len)
133137 {
134138 if(PARSER->value.data) {
135139 /* Store previous header and start a new one */
5959 Py_END_ALLOW_THREADS
6060 }
6161
62 static void cleanup() {
62 static void cleanup(void) {
6363 close(sockinfo.fd);
6464 if(sockinfo.filename)
6565 unlink(sockinfo.filename);
1111 include_dirs = ['http-parser'],
1212 define_macros = [('WANT_SENDFILE', '1'),
1313 ('WANT_SIGINT_HANDLING', '1')],
14 extra_compile_args = ['-std=c99', '-fno-strict-aliasing', '-Wall',
15 '-Wextra', '-Wno-unused', '-g', '-fPIC',
16 '-Wno-missing-field-initializers', '-fcommon']
14 extra_compile_args = ['-std=c99', '-fno-strict-aliasing', '-fcommon',
15 '-fPIC', '-Wall', '-Wextra', '-Wno-unused-parameter',
16 '-Wno-missing-field-initializers', '-g']
1717 )
1818
1919 setup(