]> granicus.if.org Git - php/commitdiff
ported ext/session
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 12:18:24 +0000 (14:18 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 12:18:24 +0000 (14:18 +0200)
ext/session/mod_files.c
ext/session/mod_user_class.c
ext/session/php_session.h
ext/session/session.c

index 33669852793a2d96793e3a9f3303669d4373fd5c..6ea33a71aa729de20b886d6b4bc6cda95b007d9f 100644 (file)
@@ -187,7 +187,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
        DIR *dir;
        char dentry[sizeof(struct dirent) + MAXPATHLEN];
        struct dirent *entry = (struct dirent *) &dentry;
-       struct stat sbuf;
+       php_stat_t sbuf;
        char buf[MAXPATHLEN];
        time_t now;
        int nrdels = 0;
@@ -238,7 +238,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
 static int ps_files_key_exists(ps_files *data, const char *key TSRMLS_DC)
 {
        char buf[MAXPATHLEN];
-       struct stat sbuf;
+       php_stat_t sbuf;
 
        if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) {
                return FAILURE;
@@ -283,7 +283,7 @@ PS_OPEN_FUNC(files)
 
        if (argc > 1) {
                errno = 0;
-               dirdepth = (size_t) strtol(argv[0], NULL, 10);
+               dirdepth = (size_t) ZEND_STRTOI(argv[0], NULL, 10);
                if (errno == ERANGE) {
                        php_error(E_WARNING, "The first parameter in session.save_path is invalid");
                        return FAILURE;
@@ -292,7 +292,7 @@ PS_OPEN_FUNC(files)
 
        if (argc > 2) {
                errno = 0;
-               filemode = strtol(argv[1], NULL, 8);
+               filemode = ZEND_STRTOI(argv[1], NULL, 8);
                if (errno == ERANGE || filemode < 0 || filemode > 07777) {
                        php_error(E_WARNING, "The second parameter in session.save_path is invalid");
                        return FAILURE;
@@ -335,7 +335,7 @@ PS_CLOSE_FUNC(files)
 
 PS_READ_FUNC(files)
 {
-       long n;
+       php_int_t n;
        struct stat sbuf;
        PS_FILES_DATA;
 
@@ -398,7 +398,7 @@ PS_READ_FUNC(files)
 
 PS_WRITE_FUNC(files)
 {
-       long n;
+       php_int_t n;
        PS_FILES_DATA;
 
        ps_files_open(data, key->val TSRMLS_CC);
index 78b90f49fa543649dad22b1db4be61f1acc23911..326f6f21f11b95305ef91e6193af4aa27fd78885 100644 (file)
@@ -125,12 +125,12 @@ PHP_METHOD(SessionHandler, destroy)
    Wraps the old gc handler */
 PHP_METHOD(SessionHandler, gc)
 {
-       long maxlifetime;
+       php_int_t maxlifetime;
        int nrdels;
 
        PS_SANITY_CHECK_IS_OPEN;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &maxlifetime) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &maxlifetime) == FAILURE) {
                return;
        }
        
index 403d9e00861c6317d351afcc173630b98696d07c..0e2eca918860140695e9a0e6c255901f5fe6287d 100644 (file)
@@ -104,8 +104,8 @@ typedef struct _php_session_rfc1867_progress {
        zval      sid;
        smart_str key;
 
-       long      update_step;
-       long      next_update;
+       php_int_t      update_step;
+       php_int_t      next_update;
        double    next_update_time;
        zend_bool cancel_upload;
        zend_bool apply_trans_sid;
@@ -125,8 +125,8 @@ typedef struct _php_ps_globals {
        char *extern_referer_chk;
        char *entropy_file;
        char *cache_limiter;
-       long entropy_length;
-       long cookie_lifetime;
+       php_int_t entropy_length;
+       php_int_t cookie_lifetime;
        char *cookie_path;
        char *cookie_domain;
        zend_bool  cookie_secure;
@@ -135,11 +135,11 @@ typedef struct _php_ps_globals {
        ps_module *default_mod;
        void *mod_data;
        php_session_status session_status;
-       long gc_probability;
-       long gc_divisor;
-       long gc_maxlifetime;
+       php_int_t gc_probability;
+       php_int_t gc_divisor;
+       php_int_t gc_maxlifetime;
        int module_number;
-       long cache_expire;
+       php_int_t cache_expire;
        union {
                zval names[7];
                struct {
@@ -162,11 +162,11 @@ typedef struct _php_ps_globals {
        zend_bool use_trans_sid;        /* contains the INI value of whether to use trans-sid */
        zend_bool apply_trans_sid;      /* whether or not to enable trans-sid for the current request */
 
-       long hash_func;
+       php_int_t hash_func;
 #if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
        php_hash_ops *hash_ops;
 #endif
-       long hash_bits_per_character;
+       php_int_t hash_bits_per_character;
        int send_cookie;
        int define_sid;
        zend_bool invalid_session_id;   /* allows the driver to report about an invalid session id and request id regeneration */
@@ -176,7 +176,7 @@ typedef struct _php_ps_globals {
        zend_bool rfc1867_cleanup; /* session.upload_progress.cleanup */
        char *rfc1867_prefix;  /* session.upload_progress.prefix */
        char *rfc1867_name;    /* session.upload_progress.name */
-       long rfc1867_freq;         /* session.upload_progress.freq */
+       php_int_t rfc1867_freq;         /* session.upload_progress.freq */
        double rfc1867_min_freq;   /* session.upload_progress.min_freq */
 
        zend_bool use_strict_mode; /* whether or not PHP accepts unknown session ids */
@@ -254,7 +254,7 @@ PHPAPI void php_session_reset_id(TSRMLS_D);
 
 #define PS_ENCODE_VARS                                                                                                 \
        zend_string *key;                                                                                               \
-       ulong num_key;                                                                                                  \
+       php_uint_t num_key;                                                                                                     \
        zval *struc;
 
 #define PS_ENCODE_LOOP(code) do {                                                                      \
index 6482073881f50c139f0fb9c34ce515b593e26b35..a7b79c230008f51437c36beb18d8a3da61d169aa 100644 (file)
@@ -305,7 +305,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
        }
 
        /* maximum 15+19+19+10 bytes */
-       spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (long int)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10);
+       spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (php_int_t)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10);
 
        switch (PS(hash_func)) {
                case PS_HASH_FUNC_MD5:
@@ -705,14 +705,14 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
 
 static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */
 {
-       long val;
+       php_int_t val;
        char *endptr = NULL;
 
 #if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
        PS(hash_ops) = NULL;
 #endif
 
-       val = strtol(new_value, &endptr, 10);
+       val = ZEND_STRTOI(new_value, &endptr, 10);
        if (endptr && (*endptr == '\0')) {
                /* Numeric value */
                PS(hash_func) = val ? 1 : 0;
@@ -1148,7 +1148,7 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */
 static inline void last_modified(TSRMLS_D) /* {{{ */
 {
        const char *path;
-       struct stat sb;
+       php_stat_t sb;
        char buf[MAX_STR + 1];
 
        path = SG(request_info).path_translated;
@@ -1778,7 +1778,7 @@ static PHP_FUNCTION(session_set_save_handler)
                zend_string *func_name;
                HashPosition pos;
                zend_function *default_mptr, *current_mptr;
-               ulong func_index;
+               php_uint_t func_index;
                php_shutdown_function_entry shutdown_function_entry;
                zend_bool register_shutdown = 1;
 
@@ -2719,7 +2719,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
                                array_init(&progress->data);
                                array_init(&progress->files);
 
-                               add_assoc_int_ex(&progress->data, "start_time", sizeof("start_time") - 1, (long)sapi_get_request_time(TSRMLS_C));
+                               add_assoc_int_ex(&progress->data, "start_time", sizeof("start_time") - 1, (php_int_t)sapi_get_request_time(TSRMLS_C));
                                add_assoc_int_ex(&progress->data, "content_length",  sizeof("content_length") - 1, progress->content_length);
                                add_assoc_int_ex(&progress->data, "bytes_processed", sizeof("bytes_processed") - 1, data->post_bytes_processed);
                                add_assoc_bool_ex(&progress->data, "done", sizeof("done") - 1, 0);
@@ -2742,7 +2742,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
                        add_assoc_int_ex(&progress->current_file, "error", sizeof("error") - 1, 0);
 
                        add_assoc_bool_ex(&progress->current_file, "done", sizeof("done") - 1, 0);
-                       add_assoc_int_ex(&progress->current_file, "start_time", sizeof("start_time") - 1, (long)time(NULL));
+                       add_assoc_int_ex(&progress->current_file, "start_time", sizeof("start_time") - 1, (php_int_t)time(NULL));
                        add_assoc_int_ex(&progress->current_file, "bytes_processed", sizeof("bytes_processed") - 1, 0);
 
                        add_next_index_zval(&progress->files, &progress->current_file);