PHP

PHP7源码系列-SAPIs

2019年4月11日
// 每种sapi都是一个 sapi_module_struct
typedef struct _sapi_module_struct sapi_module_struct;

struct _sapi_module_struct {
  // sapi名字
    char *name; 
  // sapi完整名字
    char *pretty_name; 

    // module startup
    int (*startup)(struct _sapi_module_struct *sapi_module); 
  // moduler shutdown
    int (*shutdown)(struct _sapi_module_struct *sapi_module);

  // 
    int (*activate)(void);
    int (*deactivate)(void);

  // unbuffered write
    size_t (*ub_write)(const char *str, size_t str_length);
  // flush
    void (*flush)(void *server_context);
    zend_stat_t *(*get_stat)(void);
    char *(*getenv)(char *name, size_t name_len);

    void (*sapi_error)(int type, const char *error_msg, ...);

    int (*header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers);
    int (*send_headers)(sapi_headers_struct *sapi_headers);
    void (*send_header)(sapi_header_struct *sapi_header, void *server_context);

    // 读取post数据
    size_t (*read_post)(char *buffer, size_t count_bytes);
  // 读取cookies
    char *(*read_cookies)(void);

    void (*register_server_variables)(zval *track_vars_array);
    void (*log_message)(char *message);
    double (*get_request_time)(void);
    void (*terminate_process)(void);

    char *php_ini_path_override;

    void (*block_interruptions)(void);
    void (*unblock_interruptions)(void);

    void (*default_post_reader)(void);
    void (*treat_data)(int arg, char *str, zval *destArray);
    char *executable_location;

    int php_ini_ignore;
    int php_ini_ignore_cwd; /* don't look for php.ini in the current directory */

    int (*get_fd)(int *fd);

    int (*force_http_10)(void);

    int (*get_target_uid)(uid_t *);
    int (*get_target_gid)(gid_t *);

    unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);

    void (*ini_defaults)(HashTable *configuration_hash);
    int phpinfo_as_text;

    char *ini_entries;
    const zend_function_entry *additional_functions;
    unsigned int (*input_filter_init)(void);
};

cli

fpm

cgi

apache2handler

litespeed

embedded(嵌入式)

phpdbg(调试工具)

发表评论

电子邮件地址不会被公开。 必填项已用*标注