Skip to content

Commit 9dbf879

Browse files
committed
Merge pull request #1 from weltling/merge-fastcgi
Missing symbols to get it worky on Windows
2 parents f20118a + 0512b38 commit 9dbf879

File tree

3 files changed

+66
-55
lines changed

3 files changed

+66
-55
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-
void fcgi_set_in_shutdown(int new_value)
350+
FCGI_API void fcgi_set_in_shutdown(int new_value)
351351
{
352352
in_shutdown = new_value;
353353
}
354354

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

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

365365
#ifndef HAVE_ATTRIBUTE_WEAK
366-
void fcgi_set_logger(fcgi_logger lg) {
366+
FCGI_API 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-
int fcgi_init(void)
379+
FCGI_API int fcgi_init(void)
380380
{
381381
if (!is_initialized) {
382382
#ifndef _WIN32
@@ -442,7 +442,7 @@ int fcgi_init(void)
442442
}
443443

444444

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

454-
void fcgi_shutdown(void)
454+
FCGI_API 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-
int fcgi_listen(const char *path, int backlog)
546+
FCGI_API int fcgi_listen(const char *path, int backlog)
547547
{
548548
char *s;
549549
int tcp = 0;
@@ -723,7 +723,7 @@ int fcgi_listen(const char *path, int backlog)
723723
return listen_socket;
724724
}
725725

726-
void fcgi_set_allowed_clients(char *ip)
726+
FCGI_API void fcgi_set_allowed_clients(char *ip)
727727
{
728728
char *cur, *end;
729729
int n;
@@ -768,7 +768,7 @@ void fcgi_set_allowed_clients(char *ip)
768768
}
769769
}
770770

771-
fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
771+
FCGI_API fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
772772
{
773773
memset(req, 0, sizeof(fcgi_request));
774774
req->listen_socket = listen_socket;
@@ -799,7 +799,7 @@ fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket)
799799
return req;
800800
}
801801

802-
void fcgi_destroy_request(fcgi_request *req) {
802+
FCGI_API void fcgi_destroy_request(fcgi_request *req) {
803803
if (req->env.buckets) {
804804
fcgi_hash_destroy(&req->env);
805805
}
@@ -1093,7 +1093,7 @@ static int fcgi_read_request(fcgi_request *req)
10931093
return 1;
10941094
}
10951095

1096-
int fcgi_read(fcgi_request *req, char *str, int len)
1096+
FCGI_API int fcgi_read(fcgi_request *req, char *str, int len)
10971097
{
10981098
int ret, n, rest;
10991099
fcgi_header hdr;
@@ -1146,7 +1146,7 @@ int fcgi_read(fcgi_request *req, char *str, int len)
11461146
return n;
11471147
}
11481148

1149-
void fcgi_close(fcgi_request *req, int force, int destroy)
1149+
FCGI_API void fcgi_close(fcgi_request *req, int force, int destroy)
11501150
{
11511151
if (destroy && req->has_env) {
11521152
fcgi_hash_clean(&req->env);
@@ -1199,7 +1199,7 @@ void fcgi_close(fcgi_request *req, int force, int destroy)
11991199
}
12001200
}
12011201

1202-
int fcgi_is_closed(fcgi_request *req)
1202+
FCGI_API int fcgi_is_closed(fcgi_request *req)
12031203
{
12041204
return (req->fd < 0);
12051205
}
@@ -1243,7 +1243,7 @@ static int fcgi_is_allowed() {
12431243
return 0;
12441244
}
12451245

1246-
int fcgi_accept_request(fcgi_request *req)
1246+
FCGI_API int fcgi_accept_request(fcgi_request *req)
12471247
{
12481248
#ifdef _WIN32
12491249
HANDLE pipe;
@@ -1399,7 +1399,7 @@ static inline void close_packet(fcgi_request *req)
13991399
}
14001400
}
14011401

1402-
int fcgi_flush(fcgi_request *req, int close)
1402+
FCGI_API int fcgi_flush(fcgi_request *req, int close)
14031403
{
14041404
int len;
14051405

@@ -1429,7 +1429,7 @@ int fcgi_flush(fcgi_request *req, int close)
14291429
return 1;
14301430
}
14311431

1432-
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len)
1432+
FCGI_API int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len)
14331433
{
14341434
int limit, rest;
14351435

@@ -1541,7 +1541,7 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
15411541
return len;
15421542
}
15431543

1544-
int fcgi_finish_request(fcgi_request *req, int force_close)
1544+
FCGI_API int fcgi_finish_request(fcgi_request *req, int force_close)
15451545
{
15461546
int ret = 1;
15471547

@@ -1555,7 +1555,7 @@ int fcgi_finish_request(fcgi_request *req, int force_close)
15551555
return ret;
15561556
}
15571557

1558-
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
1558+
FCGI_API char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
15591559
{
15601560
unsigned int val_len;
15611561

@@ -1564,14 +1564,14 @@ char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
15641564
return fcgi_hash_get(&req->env, FCGI_HASH_FUNC(var, var_len), (char*)var, var_len, &val_len);
15651565
}
15661566

1567-
char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value)
1567+
FCGI_API char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value)
15681568
{
15691569
unsigned int val_len;
15701570

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

1574-
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
1574+
FCGI_API char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
15751575
{
15761576
if (!req) return NULL;
15771577
if (val == NULL) {
@@ -1582,7 +1582,7 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
15821582
}
15831583
}
15841584

1585-
char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val)
1585+
FCGI_API char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val)
15861586
{
15871587
if (val == NULL) {
15881588
fcgi_hash_del(&req->env, hash_value, var, var_len);
@@ -1592,13 +1592,13 @@ char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int
15921592
}
15931593
}
15941594

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

16001600
#ifdef _WIN32
1601-
void fcgi_impersonate(void)
1601+
FCGI_API void fcgi_impersonate(void)
16021602
{
16031603
char *os_name;
16041604

@@ -1609,19 +1609,19 @@ void fcgi_impersonate(void)
16091609
}
16101610
#endif
16111611

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

1619-
void fcgi_free_mgmt_var_cb(zval *zv)
1619+
FCGI_API void fcgi_free_mgmt_var_cb(zval *zv)
16201620
{
16211621
pefree(Z_STR_P(zv), 1);
16221622
}
16231623

1624-
const char *fcgi_get_last_client_ip()
1624+
FCGI_API const char *fcgi_get_last_client_ip()
16251625
{
16261626
static char str[INET6_ADDRSTRLEN];
16271627

main/fastcgi.h

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
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+
4656
typedef enum _fcgi_role {
4757
FCGI_RESPONDER = 1,
4858
FCGI_AUTHORIZER = 2,
@@ -186,44 +196,44 @@ struct _fcgi_request {
186196
fcgi_hash env;
187197
};
188198

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);
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);
204214

205215
#ifndef HAVE_ATTRIBUTE_WEAK
206216
typedef void (*fcgi_logger)(int type, const char *fmt, ...);
207-
void fcgi_set_logger(fcgi_logger lg);
217+
FCGI_API void fcgi_set_logger(fcgi_logger lg);
208218
#endif
209219

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);
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);
215225

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

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);
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);
220230

221231
#ifdef PHP_WIN32
222-
void fcgi_impersonate(void);
232+
FCGI_API void fcgi_impersonate(void);
223233
#endif
224234

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);
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);
227237

228238
/*
229239
* Local variables:

win32/build/confutils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,8 @@ 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);
2602+
/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER
2603+
+ " /D FCGI_EXPORTS");
26032604

26042605
DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
26052606
1

0 commit comments

Comments
 (0)