struct _sapi_module_struct {
char *name;
char *pretty_name;
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*activate)(TSRMLS_D);
int (*deactivate)(TSRMLS_D);
int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC);
void (*flush)(void *server_context);
struct stat *(*get_stat)(TSRMLS_D);
char *(*getenv)(char *name, size_t name_len TSRMLS_DC);
void (*sapi_error)(int type, const char *error_msg, ...);
int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC);
int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC);
int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC);
char *(*read_cookies)(TSRMLS_D);
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
void (*log_message)(char *message);
time_t (*get_request_time)(TSRMLS_D);
char *php_ini_path_override;
void (*block_interruptions)(void);
void (*unblock_interruptions)(void);
void (*default_post_reader)(TSRMLS_D);
void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC);
char *executable_location;
int php_ini_ignore;
int (*get_fd)(int *fd TSRMLS_DC);
int (*force_http_10)(TSRMLS_D);
int (*get_target_uid)(uid_t * TSRMLS_DC);
int (*get_target_gid)(gid_t * TSRMLS_DC);
unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
char *ini_entries;
};
char *name;
char *pretty_name;
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*activate)(TSRMLS_D);
int (*deactivate)(TSRMLS_D);
int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC);
void (*flush)(void *server_context);
struct stat *(*get_stat)(TSRMLS_D);
char *(*getenv)(char *name, size_t name_len TSRMLS_DC);
void (*sapi_error)(int type, const char *error_msg, ...);
int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC);
int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC);
int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC);
char *(*read_cookies)(TSRMLS_D);
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
void (*log_message)(char *message);
time_t (*get_request_time)(TSRMLS_D);
char *php_ini_path_override;
void (*block_interruptions)(void);
void (*unblock_interruptions)(void);
void (*default_post_reader)(TSRMLS_D);
void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC);
char *executable_location;
int php_ini_ignore;
int (*get_fd)(int *fd TSRMLS_DC);
int (*force_http_10)(TSRMLS_D);
int (*get_target_uid)(uid_t * TSRMLS_DC);
int (*get_target_gid)(gid_t * TSRMLS_DC);
unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
char *ini_entries;
};
[startup]
SAPI가 초기화될 때 1회 실행. mod_php5의 경우 child process가 실행되기 전 parent process에서 1회 실행.
[activate]
request 마다 실행. 이전 request의 SAPI 데이터를 전부 다시 초기화 시킴.
[deactivate]
request가 끝날 때 실행. 모든 데이터를 application으로 flush 시킴. 해당 request의 모든 data를 destroy.
[shutdown]
interpreter가 shutdown 될 때 실행. 모든 SAPI structure destroy.
[ub_write]
PHP가 client에 데이터를 내보냄. CLI SAPI라면 stdout에 쓰는 것이고, mod_php5라면 Apache library가 rwrite를 call
[sapi_error]
application으로 error reporting
[flush]
application이 output을 flush. CLI라면 C library의 fflush, mod_php5라면 Apache library의 rflush.
[send_header]
client에 단일 header 전송. Apache의 경우는 header를 다루는 built-in 함수로, PHP CGI는 수동처리 해야하고, CLI의 경우 header 전송 없음.
[send_headers]
모든 header를 client에 전송.
[read_cookies]
SAPI 실행시 read_cookies handler가 정의되면, $_COOKIE autoglobal 생성을 위해 SG(request_info), cookie_data 생성.
[read_post]
SAPI 실행시 request method가 POST이거나, php.ini의 always_populate_raw_post_data가 true이면 $HTTP_RAW_POST_DATA와 $_POST를 생성하기 위해 read_post handler가 호출됨.
'PHP' 카테고리의 다른 글
[PHP] mod_php5 request life cycle (0) | 2010.09.14 |
---|---|
[PHP] PHP Core - PHP interpreter (0) | 2010.09.14 |
[PHP Extension] Call User Function (0) | 2010.09.13 |
[PHP Extension] Super Globals (0) | 2010.09.13 |
[PHP Extension] C++로 제작하기 위한 config.m4 (0) | 2010.09.09 |