Skip to content

Commit f972e21

Browse files
committed
Merge pull request #2 from weltling/merge-fastcgi
Simplify the windows side
2 parents 49b10ee + 6d582c6 commit f972e21

File tree

5 files changed

+57
-67
lines changed

5 files changed

+57
-67
lines changed

main/fastcgi.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,23 @@ static void fcgi_setup_signals(void)
347347
}
348348
#endif
349349

350-
FCGI_API void fcgi_set_in_shutdown(int new_value)
350+
void fcgi_set_in_shutdown(int new_value)
351351
{
352352
in_shutdown = new_value;
353353
}
354354

355-
FCGI_API int fcgi_in_shutdown(void)
355+
int fcgi_in_shutdown(void)
356356
{
357357
return in_shutdown;
358358
}
359359

360-
FCGI_API void fcgi_terminate(void)
360+
void fcgi_terminate(void)
361361
{
362362
in_shutdown = 1;
363363
}
364364

365365
#ifndef HAVE_ATTRIBUTE_WEAK
366-
FCGI_API void fcgi_set_logger(fcgi_logger lg) {
366+
void fcgi_set_logger(fcgi_logger lg) {
367367
fcgi_log = lg;
368368
}
369369
#else
@@ -376,7 +376,7 @@ void __attribute__((weak)) fcgi_log(int type, const char *format, ...) {
376376
}
377377
#endif
378378

379-
FCGI_API int fcgi_init(void)
379+
int fcgi_init(void)
380380
{
381381
if (!is_initialized) {
382382
#ifndef _WIN32
@@ -442,7 +442,7 @@ FCGI_API int fcgi_init(void)
442442
}
443443

444444

445-
FCGI_API int fcgi_is_fastcgi(void)
445+
int fcgi_is_fastcgi(void)
446446
{
447447
if (!is_initialized) {
448448
return fcgi_init();
@@ -451,7 +451,7 @@ FCGI_API int fcgi_is_fastcgi(void)
451451
}
452452
}
453453

454-
FCGI_API void fcgi_shutdown(void)
454+
void fcgi_shutdown(void)
455455
{
456456
if (is_initialized) {
457457
zend_hash_destroy(&fcgi_mgmt_vars);
@@ -543,7 +543,7 @@ static int is_port_number(const char *bindpath)
543543
return 1;
544544
}
545545

546-
FCGI_API int fcgi_listen(const char *path, int backlog)
546+
int fcgi_listen(const char *path, int backlog)
547547
{
548548
char *s;
549549
int tcp = 0;
@@ -723,7 +723,7 @@ FCGI_API int fcgi_listen(const char *path, int backlog)
723723
return listen_socket;
724724
}
725725

726-
FCGI_API void fcgi_set_allowed_clients(char *ip)
726+
void fcgi_set_allowed_clients(char *ip)
727727
{
728728
char *cur, *end;
729729
int n;
@@ -772,7 +772,7 @@ static void fcgi_hook_dummy() {
772772
return;
773773
}
774774

775-
FCGI_API fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
775+
fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
776776
{
777777
memset(req, 0, sizeof(fcgi_request));
778778
req->listen_socket = listen_socket;
@@ -807,7 +807,7 @@ FCGI_API fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
807807
return req;
808808
}
809809

810-
FCGI_API void fcgi_destroy_request(fcgi_request *req) {
810+
void fcgi_destroy_request(fcgi_request *req) {
811811
fcgi_hash_destroy(&req->env);
812812
}
813813

@@ -1099,7 +1099,7 @@ static int fcgi_read_request(fcgi_request *req)
10991099
return 1;
11001100
}
11011101

1102-
FCGI_API int fcgi_read(fcgi_request *req, char *str, int len)
1102+
int fcgi_read(fcgi_request *req, char *str, int len)
11031103
{
11041104
int ret, n, rest;
11051105
fcgi_header hdr;
@@ -1152,7 +1152,7 @@ FCGI_API int fcgi_read(fcgi_request *req, char *str, int len)
11521152
return n;
11531153
}
11541154

1155-
FCGI_API void fcgi_close(fcgi_request *req, int force, int destroy)
1155+
void fcgi_close(fcgi_request *req, int force, int destroy)
11561156
{
11571157
if (destroy && req->has_env) {
11581158
fcgi_hash_clean(&req->env);
@@ -1203,7 +1203,7 @@ FCGI_API void fcgi_close(fcgi_request *req, int force, int destroy)
12031203
}
12041204
}
12051205

1206-
FCGI_API int fcgi_is_closed(fcgi_request *req)
1206+
int fcgi_is_closed(fcgi_request *req)
12071207
{
12081208
return (req->fd < 0);
12091209
}
@@ -1246,7 +1246,7 @@ static int fcgi_is_allowed() {
12461246
return 0;
12471247
}
12481248

1249-
FCGI_API int fcgi_accept_request(fcgi_request *req)
1249+
int fcgi_accept_request(fcgi_request *req)
12501250
{
12511251
#ifdef _WIN32
12521252
HANDLE pipe;
@@ -1397,7 +1397,7 @@ static inline void close_packet(fcgi_request *req)
13971397
}
13981398
}
13991399

1400-
FCGI_API int fcgi_flush(fcgi_request *req, int close)
1400+
int fcgi_flush(fcgi_request *req, int close)
14011401
{
14021402
int len;
14031403

@@ -1427,7 +1427,7 @@ FCGI_API int fcgi_flush(fcgi_request *req, int close)
14271427
return 1;
14281428
}
14291429

1430-
FCGI_API int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len)
1430+
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len)
14311431
{
14321432
int limit, rest;
14331433

@@ -1539,7 +1539,7 @@ FCGI_API int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *s
15391539
return len;
15401540
}
15411541

1542-
FCGI_API int fcgi_finish_request(fcgi_request *req, int force_close)
1542+
int fcgi_finish_request(fcgi_request *req, int force_close)
15431543
{
15441544
int ret = 1;
15451545

@@ -1553,7 +1553,7 @@ FCGI_API int fcgi_finish_request(fcgi_request *req, int force_close)
15531553
return ret;
15541554
}
15551555

1556-
FCGI_API char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
1556+
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
15571557
{
15581558
unsigned int val_len;
15591559

@@ -1562,14 +1562,14 @@ FCGI_API char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
15621562
return fcgi_hash_get(&req->env, FCGI_HASH_FUNC(var, var_len), (char*)var, var_len, &val_len);
15631563
}
15641564

1565-
FCGI_API char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value)
1565+
char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value)
15661566
{
15671567
unsigned int val_len;
15681568

15691569
return fcgi_hash_get(&req->env, hash_value, (char*)var, var_len, &val_len);
15701570
}
15711571

1572-
FCGI_API char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
1572+
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
15731573
{
15741574
if (!req) return NULL;
15751575
if (val == NULL) {
@@ -1580,7 +1580,7 @@ FCGI_API char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
15801580
}
15811581
}
15821582

1583-
FCGI_API char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val)
1583+
char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val)
15841584
{
15851585
if (val == NULL) {
15861586
fcgi_hash_del(&req->env, hash_value, var, var_len);
@@ -1590,13 +1590,13 @@ FCGI_API char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsi
15901590
}
15911591
}
15921592

1593-
FCGI_API void fcgi_loadenv(fcgi_request *req, fcgi_apply_func func, zval *array)
1593+
void fcgi_loadenv(fcgi_request *req, fcgi_apply_func func, zval *array)
15941594
{
15951595
fcgi_hash_apply(&req->env, func, array);
15961596
}
15971597

15981598
#ifdef _WIN32
1599-
FCGI_API void fcgi_impersonate(void)
1599+
void fcgi_impersonate(void)
16001600
{
16011601
char *os_name;
16021602

@@ -1607,19 +1607,19 @@ FCGI_API void fcgi_impersonate(void)
16071607
}
16081608
#endif
16091609

1610-
FCGI_API void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
1610+
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
16111611
{
16121612
zval zvalue;
16131613
ZVAL_NEW_STR(&zvalue, zend_string_init(value, value_len, 1));
16141614
zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
16151615
}
16161616

1617-
FCGI_API void fcgi_free_mgmt_var_cb(zval *zv)
1617+
void fcgi_free_mgmt_var_cb(zval *zv)
16181618
{
16191619
pefree(Z_STR_P(zv), 1);
16201620
}
16211621

1622-
FCGI_API const char *fcgi_get_last_client_ip()
1622+
const char *fcgi_get_last_client_ip()
16231623
{
16241624
static char str[INET6_ADDRSTRLEN];
16251625

main/fastcgi.h

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@
4343
#define FCGI_PUTENV(request, name, value) \
4444
fcgi_quick_putenv(request, name, sizeof(name)-1, FCGI_HASH_FUNC(name, sizeof(name)-1), value)
4545

46-
#ifdef PHP_WIN32
47-
# ifdef FCGI_EXPORTS
48-
# define FCGI_API __declspec(dllexport)
49-
# else
50-
# define FCGI_API __declspec(dllimport)
51-
# endif
52-
#else
53-
# define FCGI_API
54-
#endif
55-
5646
typedef enum _fcgi_role {
5747
FCGI_RESPONDER = 1,
5848
FCGI_AUTHORIZER = 2,
@@ -196,44 +186,44 @@ struct _fcgi_request {
196186
fcgi_hash env;
197187
};
198188

199-
FCGI_API int fcgi_init(void);
200-
FCGI_API void fcgi_shutdown(void);
201-
FCGI_API int fcgi_is_fastcgi(void);
202-
FCGI_API int fcgi_is_closed(fcgi_request *req);
203-
FCGI_API void fcgi_close(fcgi_request *req, int force, int destroy);
204-
FCGI_API int fcgi_in_shutdown(void);
205-
FCGI_API void fcgi_terminate(void);
206-
FCGI_API int fcgi_listen(const char *path, int backlog);
207-
FCGI_API fcgi_request* fcgi_init_request(fcgi_request *request, int listen_socket);
208-
FCGI_API void fcgi_destroy_request(fcgi_request *req);
209-
FCGI_API void fcgi_set_allowed_clients(char *ip);
210-
FCGI_API int fcgi_accept_request(fcgi_request *req);
211-
FCGI_API int fcgi_finish_request(fcgi_request *req, int force_close);
212-
FCGI_API const char *fcgi_get_last_client_ip();
213-
FCGI_API void fcgi_set_in_shutdown(int new_value);
189+
int fcgi_init(void);
190+
void fcgi_shutdown(void);
191+
int fcgi_is_fastcgi(void);
192+
int fcgi_is_closed(fcgi_request *req);
193+
void fcgi_close(fcgi_request *req, int force, int destroy);
194+
int fcgi_in_shutdown(void);
195+
void fcgi_terminate(void);
196+
int fcgi_listen(const char *path, int backlog);
197+
fcgi_request* fcgi_init_request(fcgi_request *request, int listen_socket);
198+
void fcgi_destroy_request(fcgi_request *req);
199+
void fcgi_set_allowed_clients(char *ip);
200+
int fcgi_accept_request(fcgi_request *req);
201+
int fcgi_finish_request(fcgi_request *req, int force_close);
202+
const char *fcgi_get_last_client_ip();
203+
void fcgi_set_in_shutdown(int new_value);
214204

215205
#ifndef HAVE_ATTRIBUTE_WEAK
216206
typedef void (*fcgi_logger)(int type, const char *fmt, ...);
217-
FCGI_API void fcgi_set_logger(fcgi_logger lg);
207+
void fcgi_set_logger(fcgi_logger lg);
218208
#endif
219209

220-
FCGI_API char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
221-
FCGI_API char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
222-
FCGI_API char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value);
223-
FCGI_API char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val);
224-
FCGI_API void fcgi_loadenv(fcgi_request *req, fcgi_apply_func load_func, zval *array);
210+
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
211+
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
212+
char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value);
213+
char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val);
214+
void fcgi_loadenv(fcgi_request *req, fcgi_apply_func load_func, zval *array);
225215

226-
FCGI_API int fcgi_read(fcgi_request *req, char *str, int len);
216+
int fcgi_read(fcgi_request *req, char *str, int len);
227217

228-
FCGI_API int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
229-
FCGI_API int fcgi_flush(fcgi_request *req, int close);
218+
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
219+
int fcgi_flush(fcgi_request *req, int close);
230220

231221
#ifdef PHP_WIN32
232-
FCGI_API void fcgi_impersonate(void);
222+
void fcgi_impersonate(void);
233223
#endif
234224

235-
FCGI_API void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
236-
FCGI_API void fcgi_free_mgmt_var_cb(zval *zv);
225+
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
226+
void fcgi_free_mgmt_var_cb(zval *zv);
237227

238228
/*
239229
* Local variables:

sapi/cgi/config.w32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes');
66
if (PHP_CGI == "yes") {
77
ADD_FLAG("LDFLAGS_CGI", "/stack:67108864");
88
SAPI('cgi', 'cgi_main.c', 'php-cgi.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
9+
ADD_SOURCES('main', 'fastcgi.c', 'cgi');
910
ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib');
1011
}

win32/build/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
149149
ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
150150
php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
151151
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
152-
php_open_temporary_file.c output.c internal_functions.c php_sprintf.c fastcgi.c");
152+
php_open_temporary_file.c output.c internal_functions.c php_sprintf.c");
153153
ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
154154
ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c");
155155

win32/build/confutils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,7 @@ function toolset_setup_common_cflags()
25992599
{
26002600
// CFLAGS for building the PHP dll
26012601
DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \
2602-
/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER
2603-
+ " /D FCGI_EXPORTS");
2602+
/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER);
26042603

26052604
DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
26062605
1

0 commit comments

Comments
 (0)