summaryrefslogtreecommitdiff
path: root/ext/soap/php_encoding.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-08-19 08:07:31 +0200
committerAnatol Belski <ab@php.net>2014-08-19 08:07:31 +0200
commit63d3f0b844b3a5f1c94be3c97bca29235dc2b3fc (patch)
treee561a58d6e084c5e4cbdde1f84aed16cf4724383 /ext/soap/php_encoding.c
parent1e8273964fbd517a2eb9e560f9cdb4afffa0c034 (diff)
downloadphp-git-63d3f0b844b3a5f1c94be3c97bca29235dc2b3fc.tar.gz
basic macro replacements, all at once
Diffstat (limited to 'ext/soap/php_encoding.c')
-rw-r--r--ext/soap/php_encoding.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 8aeab65a1b..28ffc618b9 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -145,7 +145,7 @@ encode defaultEncoding[] = {
{{IS_NULL, "nil", XSI_NAMESPACE, NULL}, to_zval_null, to_xml_null},
{{IS_STRING, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string},
- {{IS_LONG, XSD_INT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
+ {{IS_INT, XSD_INT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{IS_DOUBLE, XSD_FLOAT_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_double},
{{IS_FALSE, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool},
{{IS_TRUE, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool},
@@ -317,7 +317,7 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node TSRMLS_DC) {
} else {
SOAP_GLOBAL(cur_uniq_ref)++;
smart_str_appendl(&prefix, "#ref", 4);
- smart_str_append_long(&prefix, SOAP_GLOBAL(cur_uniq_ref));
+ smart_str_append_int(&prefix, SOAP_GLOBAL(cur_uniq_ref));
smart_str_0(&prefix);
id = prefix.s->val;
xmlSetProp(node_ptr, BAD_CAST("id"), BAD_CAST(id+1));
@@ -334,7 +334,7 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node TSRMLS_DC) {
} else {
SOAP_GLOBAL(cur_uniq_ref)++;
smart_str_appendl(&prefix, "#ref", 4);
- smart_str_append_long(&prefix, SOAP_GLOBAL(cur_uniq_ref));
+ smart_str_append_int(&prefix, SOAP_GLOBAL(cur_uniq_ref));
smart_str_0(&prefix);
id = prefix.s->val;
set_ns_prop(node_ptr, SOAP_1_2_ENC_NAMESPACE, "id", id+1);
@@ -397,23 +397,23 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_P(zns), Z_STRVAL_P(zstype));
} else {
zns = NULL;
- enc = get_encoder_ex(SOAP_GLOBAL(sdl), Z_STRVAL_P(zstype), Z_STRLEN_P(zstype));
+ enc = get_encoder_ex(SOAP_GLOBAL(sdl), Z_STRVAL_P(zstype), Z_STRSIZE_P(zstype));
}
if (enc == NULL && SOAP_GLOBAL(typemap)) {
smart_str nscat = {0};
if (zns != NULL) {
- smart_str_appendl(&nscat, Z_STRVAL_P(zns), Z_STRLEN_P(zns));
+ smart_str_appendl(&nscat, Z_STRVAL_P(zns), Z_STRSIZE_P(zns));
smart_str_appendc(&nscat, ':');
}
- smart_str_appendl(&nscat, Z_STRVAL_P(zstype), Z_STRLEN_P(zstype));
+ smart_str_appendl(&nscat, Z_STRVAL_P(zstype), Z_STRSIZE_P(zstype));
smart_str_0(&nscat);
enc = zend_hash_find_ptr(SOAP_GLOBAL(typemap), nscat.s);
smart_str_free(&nscat);
}
}
if (enc == NULL) {
- enc = get_conversion(Z_LVAL_P(ztype));
+ enc = get_conversion(Z_IVAL_P(ztype));
}
if (enc == NULL) {
enc = encode;
@@ -449,7 +449,7 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
ZEND_HASH_FOREACH_STR_KEY_VAL(SOAP_GLOBAL(class_map), type_name, tmp) {
if (Z_TYPE_P(tmp) == IS_STRING &&
- ce->name->len == Z_STRLEN_P(tmp) &&
+ ce->name->len == Z_STRSIZE_P(tmp) &&
zend_binary_strncasecmp(ce->name->val, ce->name->len, Z_STRVAL_P(tmp), ce->name->len, ce->name->len) == 0 &&
type_name) {
@@ -600,7 +600,7 @@ xmlNodePtr to_xml_user(encodeTypePtr type, zval *data, int style, xmlNodePtr par
soap_error0(E_ERROR, "Encoding: Error calling to_xml callback");
}
if (Z_TYPE(return_value) == IS_STRING) {
- xmlDocPtr doc = soap_xmlParseMemory(Z_STRVAL(return_value), Z_STRLEN(return_value));
+ xmlDocPtr doc = soap_xmlParseMemory(Z_STRVAL(return_value), Z_STRSIZE(return_value));
if (doc && doc->children) {
ret = xmlDocCopyNode(doc->children, parent->doc, 1);
}
@@ -831,15 +831,15 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
FIND_ZVAL_NULL(data, ret, style);
if (Z_TYPE_P(data) == IS_STRING) {
- str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
- new_len = Z_STRLEN_P(data);
+ str = estrndup(Z_STRVAL_P(data), Z_STRSIZE_P(data));
+ new_len = Z_STRSIZE_P(data);
} else {
zval tmp = *data;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
- str = estrndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
- new_len = Z_STRLEN(tmp);
+ str = estrndup(Z_STRVAL(tmp), Z_STRSIZE(tmp));
+ new_len = Z_STRSIZE(tmp);
zval_dtor(&tmp);
}
@@ -918,7 +918,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
FIND_ZVAL_NULL(data, ret, style);
if (Z_TYPE_P(data) == IS_STRING) {
- str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data));
+ str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRSIZE_P(data));
text = xmlNewTextLen(BAD_CAST(str->val), str->len);
xmlAddChild(ret, text);
STR_RELEASE(str);
@@ -927,7 +927,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
ZVAL_DUP(&tmp, data);
convert_to_string(&tmp);
- str = php_base64_encode((unsigned char*)Z_STRVAL(tmp), Z_STRLEN(tmp));
+ str = php_base64_encode((unsigned char*)Z_STRVAL(tmp), Z_STRSIZE(tmp));
text = xmlNewTextLen(BAD_CAST(str->val), str->len);
xmlAddChild(ret, text);
STR_RELEASE(str);
@@ -958,15 +958,15 @@ static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNo
convert_to_string(&tmp);
data = &tmp;
}
- str = (unsigned char *) safe_emalloc(Z_STRLEN_P(data) * 2, sizeof(char), 1);
+ str = (unsigned char *) safe_emalloc(Z_STRSIZE_P(data) * 2, sizeof(char), 1);
- for (i = j = 0; i < Z_STRLEN_P(data); i++) {
+ for (i = j = 0; i < Z_STRSIZE_P(data); i++) {
str[j++] = hexconvtab[((unsigned char)Z_STRVAL_P(data)[i]) >> 4];
str[j++] = hexconvtab[((unsigned char)Z_STRVAL_P(data)[i]) & 15];
}
str[j] = '\0';
- text = xmlNewTextLen(str, Z_STRLEN_P(data) * 2 * sizeof(char));
+ text = xmlNewTextLen(str, Z_STRSIZE_P(data) * 2 * sizeof(char));
xmlAddChild(ret, text);
efree(str);
if (data == &tmp) {
@@ -991,7 +991,7 @@ static zval *to_zval_double(zval *ret, encodeTypePtr type, xmlNodePtr data TSRML
whiteSpace_collapse(data->children->content);
switch (is_numeric_string((char*)data->children->content, strlen((char*)data->children->content), &lval, &dval, 0)) {
- case IS_LONG:
+ case IS_INT:
ZVAL_DOUBLE(ret, lval);
break;
case IS_DOUBLE:
@@ -1031,8 +1031,8 @@ static zval *to_zval_long(zval *ret, encodeTypePtr type, xmlNodePtr data TSRMLS_
errno = 0;
switch (is_numeric_string((char*)data->children->content, strlen((char*)data->children->content), &lval, &dval, 0)) {
- case IS_LONG:
- ZVAL_LONG(ret, lval);
+ case IS_INT:
+ ZVAL_INT(ret, lval);
break;
case IS_DOUBLE:
ZVAL_DOUBLE(ret, dval);
@@ -1066,11 +1066,11 @@ static xmlNodePtr to_xml_long(encodeTypePtr type, zval *data, int style, xmlNode
zval tmp = *data;
zval_copy_ctor(&tmp);
- if (Z_TYPE(tmp) != IS_LONG) {
- convert_to_long(&tmp);
+ if (Z_TYPE(tmp) != IS_INT) {
+ convert_to_int(&tmp);
}
convert_to_string(&tmp);
- xmlNodeSetContentLen(ret, BAD_CAST(Z_STRVAL(tmp)), Z_STRLEN(tmp));
+ xmlNodeSetContentLen(ret, BAD_CAST(Z_STRVAL(tmp)), Z_STRSIZE(tmp));
zval_dtor(&tmp);
}
@@ -2347,10 +2347,10 @@ iterator_done:
}
}
- smart_str_append_long(&array_size, dims[0]);
+ smart_str_append_int(&array_size, dims[0]);
for (i=1; i<dimension; i++) {
smart_str_appendc(&array_size, ',');
- smart_str_append_long(&array_size, dims[i]);
+ smart_str_append_int(&array_size, dims[i]);
}
efree(value);
@@ -2375,15 +2375,15 @@ iterator_done:
dims = get_position_12(dimension, ext->val);
if (dims[0] == 0) {dims[0] = i;}
- smart_str_append_long(&array_size, dims[0]);
+ smart_str_append_int(&array_size, dims[0]);
for (i=1; i<dimension; i++) {
smart_str_appendc(&array_size, ',');
- smart_str_append_long(&array_size, dims[i]);
+ smart_str_append_int(&array_size, dims[i]);
}
} else {
dims = emalloc(sizeof(int));
*dims = 0;
- smart_str_append_long(&array_size, i);
+ smart_str_append_int(&array_size, i);
}
} else if (sdl_type &&
sdl_type->attributes &&
@@ -2395,10 +2395,10 @@ iterator_done:
dims = get_position_12(dimension, ext->val);
if (dims[0] == 0) {dims[0] = i;}
- smart_str_append_long(&array_size, dims[0]);
+ smart_str_append_int(&array_size, dims[0]);
for (i=1; i<dimension; i++) {
smart_str_appendc(&array_size, ',');
- smart_str_append_long(&array_size, dims[i]);
+ smart_str_append_int(&array_size, dims[i]);
}
if (sdl_type && sdl_type->elements &&
@@ -2422,14 +2422,14 @@ iterator_done:
enc = elementType->encode;
get_type_str(xmlParam, elementType->encode->details.ns, elementType->encode->details.type_str, &array_type);
- smart_str_append_long(&array_size, i);
+ smart_str_append_int(&array_size, i);
dims = safe_emalloc(sizeof(int), dimension, 0);
dims[0] = i;
} else {
enc = get_array_type(xmlParam, data, &array_type TSRMLS_CC);
- smart_str_append_long(&array_size, i);
+ smart_str_append_int(&array_size, i);
dims = safe_emalloc(sizeof(int), dimension, 0);
dims[0] = i;
}
@@ -2712,7 +2712,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP
xmlNodeSetContent(key, BAD_CAST(key_val->val));
} else {
smart_str tmp = {0};
- smart_str_append_long(&tmp, int_val);
+ smart_str_append_int(&tmp, int_val);
smart_str_0(&tmp);
if (style == SOAP_ENCODED) {
@@ -2765,8 +2765,8 @@ static zval *to_zval_map(zval *ret, encodeTypePtr type, xmlNodePtr data TSRMLS_D
if (Z_TYPE(key) == IS_STRING) {
zend_symtable_update(Z_ARRVAL_P(ret), Z_STR(key), &value);
- } else if (Z_TYPE(key) == IS_LONG) {
- zend_hash_index_update(Z_ARRVAL_P(ret), Z_LVAL(key), &value);
+ } else if (Z_TYPE(key) == IS_INT) {
+ zend_hash_index_update(Z_ARRVAL_P(ret), Z_IVAL(key), &value);
} else {
soap_error0(E_ERROR, "Encoding: Can't decode apache map, only Strings or Longs are allowd as keys");
}
@@ -2863,7 +2863,7 @@ static zval *guess_zval_convert(zval *ret, encodeTypePtr type, xmlNodePtr data T
xmlNsPtr nsptr;
object_init_ex(&soapvar, soap_var_class_entry);
- add_property_long(&soapvar, "enc_type", enc->details.type);
+ add_property_int(&soapvar, "enc_type", enc->details.type);
Z_DELREF_P(ret);
add_property_zval(&soapvar, "enc_value", ret);
parse_namespace(type_name, &cptype, &ns);
@@ -2896,12 +2896,12 @@ static xmlNodePtr to_xml_datetime_ex(encodeTypePtr type, zval *data, char *forma
xmlAddChild(parent, xmlParam);
FIND_ZVAL_NULL(data, xmlParam, style);
- if (Z_TYPE_P(data) == IS_LONG) {
- timestamp = Z_LVAL_P(data);
+ if (Z_TYPE_P(data) == IS_INT) {
+ timestamp = Z_IVAL_P(data);
ta = php_localtime_r(&timestamp, &tmbuf);
/*ta = php_gmtime_r(&timestamp, &tmbuf);*/
if (!ta) {
- soap_error1(E_ERROR, "Encoding: Invalid timestamp %ld", Z_LVAL_P(data));
+ soap_error1(E_ERROR, "Encoding: Invalid timestamp %ld", Z_IVAL_P(data));
}
buf = (char *) emalloc(buf_len);
@@ -2935,7 +2935,7 @@ static xmlNodePtr to_xml_datetime_ex(encodeTypePtr type, zval *data, char *forma
xmlNodeSetContent(xmlParam, BAD_CAST(buf));
efree(buf);
} else if (Z_TYPE_P(data) == IS_STRING) {
- xmlNodeSetContentLen(xmlParam, BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data));
+ xmlNodeSetContentLen(xmlParam, BAD_CAST(Z_STRVAL_P(data)), Z_STRSIZE_P(data));
}
if (style == SOAP_ENCODED) {
@@ -3043,7 +3043,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
convert_to_string(&tmp);
data = &tmp;
}
- str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
+ str = estrndup(Z_STRVAL_P(data), Z_STRSIZE_P(data));
whiteSpace_collapse(BAD_CAST(str));
start = str;
while (start != NULL && *start != '\0') {
@@ -3144,13 +3144,13 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
return ret;
}
if (Z_TYPE_P(data) == IS_STRING) {
- ret = xmlNewTextLen(BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data));
+ ret = xmlNewTextLen(BAD_CAST(Z_STRVAL_P(data)), Z_STRSIZE_P(data));
} else {
zval tmp = *data;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
- ret = xmlNewTextLen(BAD_CAST(Z_STRVAL(tmp)), Z_STRLEN(tmp));
+ ret = xmlNewTextLen(BAD_CAST(Z_STRVAL(tmp)), Z_STRSIZE(tmp));
zval_dtor(&tmp);
}
@@ -3251,20 +3251,20 @@ xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style, xmlNo
if (type) {
if (type->restrictions && Z_TYPE_P(data) == IS_STRING) {
if (type->restrictions->enumeration) {
- if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) {
+ if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRSIZE_P(data)+1)) {
soap_error1(E_WARNING, "Encoding: Restriction: invalid enumeration value \"%s\".", Z_STRVAL_P(data));
}
}
if (type->restrictions->minLength &&
- Z_STRLEN_P(data) < type->restrictions->minLength->value) {
+ Z_STRSIZE_P(data) < type->restrictions->minLength->value) {
soap_error0(E_WARNING, "Encoding: Restriction: length less than 'minLength'");
}
if (type->restrictions->maxLength &&
- Z_STRLEN_P(data) > type->restrictions->maxLength->value) {
+ Z_STRSIZE_P(data) > type->restrictions->maxLength->value) {
soap_error0(E_WARNING, "Encoding: Restriction: length greater than 'maxLength'");
}
if (type->restrictions->length &&
- Z_STRLEN_P(data) != type->restrictions->length->value) {
+ Z_STRSIZE_P(data) != type->restrictions->length->value) {
soap_error0(E_WARNING, "Encoding: Restriction: length is not equal to 'length'");
}
}
@@ -3426,7 +3426,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
while (1) {
smart_str_appendl(&prefix, "ns", 2);
- smart_str_append_long(&prefix, num);
+ smart_str_append_int(&prefix, num);
smart_str_0(&prefix);
if (xmlSearchNs(node->doc, node, BAD_CAST(prefix.s->val)) == NULL) {
break;
@@ -3536,7 +3536,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
if ((ztype = zend_hash_str_find(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
- cur_type = Z_LVAL_P(ztype);
+ cur_type = Z_IVAL_P(ztype);
if ((ztype = zend_hash_str_find(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL) {
cur_stype = Z_STRVAL_P(ztype);