Skip to content

Commit

Permalink
Replace usage of php_int32 and php_uint32 with int32_t and uint32_t
Browse files Browse the repository at this point in the history
  • Loading branch information
realityking authored and nikic committed Feb 4, 2016
1 parent d998ca6 commit a61029b
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 145 deletions.
30 changes: 15 additions & 15 deletions ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,10 @@ void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */
#endif
#define PHAR_ZIP_16(var) ((php_uint16)((((php_uint16)var[0]) & 0xff) | \
(((php_uint16)var[1]) & 0xff) << 8))
#define PHAR_ZIP_32(var) ((php_uint32)((((php_uint32)var[0]) & 0xff) | \
(((php_uint32)var[1]) & 0xff) << 8 | \
(((php_uint32)var[2]) & 0xff) << 16 | \
(((php_uint32)var[3]) & 0xff) << 24))
#define PHAR_ZIP_32(var) ((uint32_t)((((uint32_t)var[0]) & 0xff) | \
(((uint32_t)var[1]) & 0xff) << 8 | \
(((uint32_t)var[2]) & 0xff) << 16 | \
(((uint32_t)var[3]) & 0xff) << 24))

/**
* Open an already loaded phar
Expand Down Expand Up @@ -604,7 +604,7 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
*
* data is the serialized zval
*/
int phar_parse_metadata(char **buffer, zval *metadata, php_uint32 zip_metadata_len) /* {{{ */
int phar_parse_metadata(char **buffer, zval *metadata, uint32_t zip_metadata_len) /* {{{ */
{
php_unserialize_data_t var_hash;

Expand Down Expand Up @@ -649,14 +649,14 @@ int phar_parse_metadata(char **buffer, zval *metadata, php_uint32 zip_metadata_l
* This is used by phar_open_from_filename to process the manifest, but can be called
* directly.
*/
static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, zend_long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error) /* {{{ */
static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, zend_long halt_offset, phar_archive_data** pphar, uint32_t compression, char **error) /* {{{ */
{
char b32[4], *buffer, *endbuffer, *savebuf;
phar_archive_data *mydata = NULL;
phar_entry_info entry;
php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
uint32_t manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
php_uint16 manifest_ver;
php_uint32 len;
uint32_t len;
zend_long offset;
int sig_len, register_alias = 0, temp_alias = 0;
char *signature = NULL;
Expand Down Expand Up @@ -778,7 +778,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char

switch(sig_flags) {
case PHAR_SIG_OPENSSL: {
php_uint32 signature_len;
uint32_t signature_len;
char *sig;
zend_off_t whence;

Expand Down Expand Up @@ -1565,7 +1565,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
const zend_long tokenlen = sizeof(token) - 1;
zend_long halt_offset;
size_t got;
php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
uint32_t compression = PHAR_FILE_COMPRESSED_NONE;

if (error) {
*error = NULL;
Expand Down Expand Up @@ -2309,9 +2309,9 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{
/**
* Validate the CRC32 of a file opened from within the phar
*/
int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip) /* {{{ */
int phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip) /* {{{ */
{
php_uint32 crc = ~0;
uint32_t crc = ~0;
int len = idata->internal_file->uncompressed_filesize;
php_stream *fp = idata->fp;
phar_entry_info *entry = idata->internal_file;
Expand Down Expand Up @@ -2476,8 +2476,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
zend_off_t manifest_ftell;
zend_long offset;
size_t wrote;
php_uint32 manifest_len, mytime, loc, new_manifest_count;
php_uint32 newcrc32;
uint32_t manifest_len, mytime, loc, new_manifest_count;
uint32_t newcrc32;
php_stream *file, *oldfile, *newfile, *stubfile;
php_stream_filter *filter;
php_serialize_data_t metadata_hash;
Expand Down Expand Up @@ -2809,7 +2809,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
php_stream_flush(entry->cfp);
php_stream_filter_remove(filter, 1);
php_stream_seek(entry->cfp, 0, SEEK_END);
entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp);
entry->compressed_filesize = (uint32_t) php_stream_tell(entry->cfp);
/* generate crc on compressed file */
php_stream_rewind(entry->cfp);
entry->old_flags = entry->flags;
Expand Down
30 changes: 15 additions & 15 deletions ext/phar/phar_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,17 @@ enum phar_fp_type {
/* entry for one file in a phar file */
typedef struct _phar_entry_info {
/* first bytes are exactly as in file */
php_uint32 uncompressed_filesize;
php_uint32 timestamp;
php_uint32 compressed_filesize;
php_uint32 crc32;
php_uint32 flags;
uint32_t uncompressed_filesize;
uint32_t timestamp;
uint32_t compressed_filesize;
uint32_t crc32;
uint32_t flags;
/* remainder */
/* when changing compression, save old flags in case fp is NULL */
php_uint32 old_flags;
uint32_t old_flags;
zval metadata;
int metadata_len; /* only used for cached manifests */
php_uint32 filename_len;
uint32_t filename_len;
char *filename;
enum phar_fp_type fp_type;
/* offset within original phar file of the file contents */
Expand Down Expand Up @@ -295,14 +295,14 @@ struct _phar_archive_data {
HashTable virtual_dirs;
/* hash of mounted directory paths */
HashTable mounted_dirs;
php_uint32 flags;
php_uint32 min_timestamp;
php_uint32 max_timestamp;
uint32_t flags;
uint32_t min_timestamp;
uint32_t max_timestamp;
php_stream *fp;
/* decompressed file contents are stored here */
php_stream *ufp;
int refcount;
php_uint32 sig_flags;
uint32_t sig_flags;
int sig_len;
char *signature;
zval metadata;
Expand Down Expand Up @@ -536,15 +536,15 @@ void phar_object_init(void);
void phar_destroy_phar_data(phar_archive_data *phar);

int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error);
int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip);
int phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip);
int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error);
int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
int phar_open_executed_filename(char *alias, int alias_len, char **error);
int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len);
int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error);
int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error);
int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error);
int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, int *signature_length, char **error);

/* utility functions */
Expand All @@ -558,7 +558,7 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
zend_string *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar);
char *phar_fix_filepath(char *path, int *new_len, int use_cwd);
phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error);
int phar_parse_metadata(char **buffer, zval *metadata, php_uint32 zip_metadata_len);
int phar_parse_metadata(char **buffer, zval *metadata, uint32_t zip_metadata_len);
void destroy_phar_manifest_entry(zval *zv);
int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links);
php_stream *phar_get_efp(phar_entry_info *entry, int follow_links);
Expand All @@ -572,7 +572,7 @@ int phar_copy_on_write(phar_archive_data **pphar);

/* tar functions in tar.c */
int phar_is_tar(char *buf, char *fname);
int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error);
int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, uint32_t compression, char **error);
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error);
int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error);

Expand Down
14 changes: 7 additions & 7 deletions ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext, ze
}
/* }}} */

static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags) /* {{{ */
static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, uint32_t flags) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry, newentry;
Expand Down Expand Up @@ -2288,7 +2288,7 @@ PHP_METHOD(Phar, convertToExecutable)
char *ext = NULL;
int is_data;
size_t ext_len = 0;
php_uint32 flags;
uint32_t flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
zend_long format = 9021976, method = 9021976;
Expand Down Expand Up @@ -2392,7 +2392,7 @@ PHP_METHOD(Phar, convertToData)
char *ext = NULL;
int is_data;
size_t ext_len = 0;
php_uint32 flags;
uint32_t flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
zend_long format = 9021976, method = 9021976;
Expand Down Expand Up @@ -3066,7 +3066,7 @@ PHP_METHOD(Phar, getModified)
static int phar_set_compression(zval *zv, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
php_uint32 compress = *(php_uint32 *)argument;
uint32_t compress = *(uint32_t *)argument;

if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
Expand Down Expand Up @@ -3104,7 +3104,7 @@ static int phar_test_compression(zval *zv, void *argument) /* {{{ */
}
/* }}} */

static void pharobj_set_compression(HashTable *manifest, php_uint32 compress) /* {{{ */
static void pharobj_set_compression(HashTable *manifest, uint32_t compress) /* {{{ */
{
zend_hash_apply_with_argument(manifest, phar_set_compression, &compress);
}
Expand All @@ -3130,7 +3130,7 @@ PHP_METHOD(Phar, compress)
zend_long method;
char *ext = NULL;
size_t ext_len = 0;
php_uint32 flags;
uint32_t flags;
zend_object *ret;
PHAR_ARCHIVE_OBJECT();

Expand Down Expand Up @@ -3239,7 +3239,7 @@ PHP_METHOD(Phar, decompress)
PHP_METHOD(Phar, compressFiles)
{
char *error;
php_uint32 flags;
uint32_t flags;
zend_long method;
PHAR_ARCHIVE_OBJECT();

Expand Down
24 changes: 12 additions & 12 deletions ext/phar/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#include "phar_internal.h"

static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */
static uint32_t phar_tar_number(char *buf, int len) /* {{{ */
{
php_uint32 num = 0;
uint32_t num = 0;
int i = 0;

while (i < len && buf[i] == ' ') {
Expand Down Expand Up @@ -62,7 +62,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
static int phar_tar_octal(char *buf, php_uint32 val, int len) /* {{{ */
static int phar_tar_octal(char *buf, uint32_t val, int len) /* {{{ */
{
char *p = buf;
int s = len;
Expand All @@ -84,9 +84,9 @@ static int phar_tar_octal(char *buf, php_uint32 val, int len) /* {{{ */
}
/* }}} */

static php_uint32 phar_tar_checksum(char *buf, int len) /* {{{ */
static uint32_t phar_tar_checksum(char *buf, int len) /* {{{ */
{
php_uint32 sum = 0;
uint32_t sum = 0;
char *end = buf + len;

while (buf != end) {
Expand All @@ -100,8 +100,8 @@ static php_uint32 phar_tar_checksum(char *buf, int len) /* {{{ */
int phar_is_tar(char *buf, char *fname) /* {{{ */
{
tar_header *header = (tar_header *) buf;
php_uint32 checksum = phar_tar_number(header->checksum, sizeof(header->checksum));
php_uint32 ret;
uint32_t checksum = phar_tar_number(header->checksum, sizeof(header->checksum));
uint32_t ret;
char save[sizeof(header->checksum)], *bname;

/* assume that the first filename in a tar won't begin with <?php */
Expand Down Expand Up @@ -202,13 +202,13 @@ static size_t strnlen(const char *s, size_t maxlen) {
}
#endif

int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error) /* {{{ */
int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, uint32_t compression, char **error) /* {{{ */
{
char buf[512], *actual_alias = NULL, *p;
phar_entry_info entry = {0};
size_t pos = 0, read, totalsize;
tar_header *hdr;
php_uint32 sum1, sum2, size, old;
uint32_t sum1, sum2, size, old;
phar_archive_data *myphar, *actual;
int last_was_longlink = 0;
int linkname_len;
Expand Down Expand Up @@ -299,7 +299,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
| ((((unsigned char*)(buffer))[1]) << 8) \
| (((unsigned char*)(buffer))[0]))
#else
# define PHAR_GET_32(buffer) (php_uint32) *(buffer)
# define PHAR_GET_32(buffer) (uint32_t) *(buffer)
#endif
myphar->sig_flags = PHAR_GET_32(buf);
if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, myphar->sig_flags, buf + 8, size - 8, fname, &myphar->signature, &myphar->sig_len, error)) {
Expand Down Expand Up @@ -1235,12 +1235,12 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
}
#ifdef WORDS_BIGENDIAN
# define PHAR_SET_32(var, buffer) \
*(php_uint32 *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \
*(uint32_t *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \
| ((((unsigned char*)&(buffer))[2]) << 16) \
| ((((unsigned char*)&(buffer))[1]) << 8) \
| (((unsigned char*)&(buffer))[0]))
#else
# define PHAR_SET_32(var, buffer) *(php_uint32 *)(var) = (php_uint32) (buffer)
# define PHAR_SET_32(var, buffer) *(uint32_t *)(var) = (uint32_t) (buffer)
#endif
PHAR_SET_32(sigbuf, phar->sig_flags);
PHAR_SET_32(sigbuf + 4, signature_length);
Expand Down
4 changes: 2 additions & 2 deletions ext/phar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{
*/
char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */
{
php_uint32 flags;
uint32_t flags;

if (entry->is_modified) {
flags = entry->old_flags;
Expand Down Expand Up @@ -1473,7 +1473,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
/* }}} */
#endif /* #ifndef PHAR_HAVE_OPENSSL */

int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error) /* {{{ */
int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error) /* {{{ */
{
int read_size, len;
zend_off_t read_len;
Expand Down
Loading

0 comments on commit a61029b

Please sign in to comment.