diff options
author | Chuck Hagenbuch <chagenbu@php.net> | 2000-12-10 19:18:34 +0000 |
---|---|---|
committer | Chuck Hagenbuch <chagenbu@php.net> | 2000-12-10 19:18:34 +0000 |
commit | a9a1553031f3410348daf79d239d18fd0b895fc9 (patch) | |
tree | e817eb96dfdf0d5f48cdf10dc9d2746b64e96793 /ext/imap/php_imap.c | |
parent | 71348b8b9efb54fc06997733d42a89f74432de4e (diff) | |
download | php-git-a9a1553031f3410348daf79d239d18fd0b895fc9.tar.gz |
[whitespace] make this code a bit less dense.
Diffstat (limited to 'ext/imap/php_imap.c')
-rw-r--r-- | ext/imap/php_imap.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 1888960b3f..520aa712b3 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -3566,50 +3566,52 @@ PHP_FUNCTION(imap_mime_header_decode) RETURN_FALSE; } - string=(*str)->value.str.val; - end=(*str)->value.str.len; + string = (*str)->value.str.val; + end = (*str)->value.str.len; - if ((charset=((char *)emalloc((end+1)*2)))) { - text=&charset[end+1]; - while(offset<end) { /* Reached end of the string? */ - if ((charset_token=(long) php_memnstr(&string[offset], "=?", 2, string+end))) { /* Is there anything encoded in the string? */ + if ((charset = ((char *)emalloc((end + 1) * 2)))) { + text = &charset[end + 1]; + while (offset < end) { /* Reached end of the string? */ + if ((charset_token = (long)php_memnstr(&string[offset], "=?", 2, string + end))) { /* Is there anything encoded in the string? */ charset_token -= (long)string; - if (offset!=charset_token) { /* Is there anything before the encoded data? */ + if (offset != charset_token) { /* Is there anything before the encoded data? */ /* Retrieve unencoded data that is found before encoded data */ memcpy(text, &string[offset], charset_token-offset); - text[charset_token-offset]=0x00; + text[charset_token - offset] = 0x00; MAKE_STD_ZVAL(myobject); object_init(myobject); add_property_string(myobject, "charset", "default", 1); add_property_string(myobject, "text", text, 1); - zend_hash_next_index_insert(return_value->value.ht,(void *)&myobject,sizeof(zval *),NULL); + zend_hash_next_index_insert(return_value->value.ht, (void *)&myobject, sizeof(zval *), NULL); } - if ((encoding_token=(long) php_memnstr(&string[charset_token+2], "?", 1, string+end))) { /* Find token for encoding */ - encoding_token -= (long) string; - if ((end_token=(long) php_memnstr(&string[encoding_token+3], "?=", 2, string+end))) { /* Find token for end of encoded data */ - end_token -= (long) string; - memcpy(charset, &string[charset_token+2], encoding_token-(charset_token+2)); /* Extract charset encoding */ - charset[encoding_token-(charset_token+2)]=0x00; - encoding=string[encoding_token+1]; /* Extract encoding from string */ - memcpy(text, &string[encoding_token+3], end_token-(encoding_token+3)); /* Extract text */ - text[end_token-(encoding_token+3)]=0x00; - decode=text; - if (encoding=='q' || encoding=='Q') { /* Decode 'q' encoded data */ - for(i=0;text[i]!=0x00;i++) if (text[i]=='_') text[i]=' '; /* Replace all *_' with space. */ - decode = (char *) rfc822_qprint((unsigned char *) text, strlen(text), &newlength); - } else if (encoding=='b' || encoding=='B') { - decode = (char *) rfc822_base64((unsigned char *) text, strlen(text), &newlength); /* Decode 'B' encoded data */ + if ((encoding_token = (long)php_memnstr(&string[charset_token+2], "?", 1, string+end))) { /* Find token for encoding */ + encoding_token -= (long)string; + if ((end_token = (long)php_memnstr(&string[encoding_token+3], "?=", 2, string+end))) { /* Find token for end of encoded data */ + end_token -= (long)string; + memcpy(charset, &string[charset_token + 2], encoding_token - (charset_token + 2)); /* Extract charset encoding */ + charset[encoding_token-(charset_token + 2)] = 0x00; + encoding=string[encoding_token + 1]; /* Extract encoding from string */ + memcpy(text, &string[encoding_token + 3], end_token - (encoding_token + 3)); /* Extract text */ + text[end_token - (encoding_token + 3)] = 0x00; + decode = text; + if (encoding == 'q' || encoding == 'Q') { /* Decode 'q' encoded data */ + for(i=0; text[i] != 0x00; i++) if (text[i] == '_') text[i] = ' '; /* Replace all *_' with space. */ + decode = (char *)rfc822_qprint((unsigned char *) text, strlen(text), &newlength); + } else if (encoding == 'b' || encoding == 'B') { + decode = (char *)rfc822_base64((unsigned char *) text, strlen(text), &newlength); /* Decode 'B' encoded data */ } MAKE_STD_ZVAL(myobject); object_init(myobject); add_property_string(myobject, "charset", charset, 1); add_property_string(myobject, "text", decode, 1); - zend_hash_next_index_insert(return_value->value.ht,(void *)&myobject,sizeof(zval *),NULL); - fs_give((void**) &decode); + zend_hash_next_index_insert(return_value->value.ht, (void *)&myobject, sizeof(zval *), NULL); + fs_give((void**)&decode); - offset=end_token+2; - for(i=0;(string[offset+i]==' ') || (string[offset+i]==0x0a) || (string[offset+i]==0x0d);i++); - if((string[offset+i]=='=') && (string[offset+i+1]=='?') && (offset+i<end)) offset+=i; + offset = end_token+2; + for (i = 0; (string[offset + i] == ' ') || (string[offset + i] == 0x0a) || (string[offset + i] == 0x0d); i++); + if ((string[offset + i] == '=') && (string[offset + i + 1] == '?') && (offset + i < end)) { + offset += i; + } continue; /*/ Iterate the loop again please. */ } } @@ -3617,19 +3619,19 @@ PHP_FUNCTION(imap_mime_header_decode) /* Just some tweaking to optimize the code, and get the end statements work in a general manner. If we end up here we didn't find a position for "charset_token", so we need to set it to the start of the yet unextracted data. */ - charset_token=offset; + charset_token = offset; } /* Return the rest of the data as unencoded, as it was either unencoded or was missing separators which rendered the the remainder of the string impossible for us to decode. */ - memcpy(text, &string[charset_token], end-charset_token); /* Extract unencoded text from string */ - text[end-charset_token]=0x00; + memcpy(text, &string[charset_token], end - charset_token); /* Extract unencoded text from string */ + text[end - charset_token] = 0x00; MAKE_STD_ZVAL(myobject); object_init(myobject); add_property_string(myobject, "charset", "default", 1); add_property_string(myobject, "text", text, 1); - zend_hash_next_index_insert(return_value->value.ht,(void *)&myobject,sizeof(zval *),NULL); + zend_hash_next_index_insert(return_value->value.ht, (void *)&myobject, sizeof(zval *), NULL); - offset=end; /* We have reached the end of the string. */ + offset = end; /* We have reached the end of the string. */ } efree(charset); } else { |