diff options
-rw-r--r-- | ext/imap/php_imap.c | 58 |
1 files changed, 17 insertions, 41 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index a802ce1892..be9accb99f 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -376,28 +376,13 @@ void mail_free_messagelist(MESSAGELIST **msglist, MESSAGELIST **tail) */ void mail_getquota(MAILSTREAM *stream, char *qroot, QUOTALIST *qlist) { - zval *t_map; TSRMLS_FETCH(); /* this should only be run through once */ for (; qlist; qlist = qlist->next) { - MAKE_STD_ZVAL(t_map); - if (array_init(t_map) == FAILURE) { - php_error(E_WARNING, "Unable to allocate t_map memory"); - FREE_ZVAL(t_map); - FREE_ZVAL(IMAPG(quota_return)); - return; - } - if (strncmp(qlist->name, "STORAGE", 7) == 0) - { - add_assoc_long_ex(IMAPG(quota_return), "usage", sizeof("usage"), qlist->usage); - add_assoc_long_ex(IMPAG(quota_return), "limit", sizeof("limit"), qlist->limit); - } - - add_assoc_long_ex(t_map, "usage", sizeof("usage"), qlist->usage); - add_assoc_long_ex(t_map, "limit", sizeof("limit"), qlist->usage); - ass_assoc_zval_ex(IMAPG(quota_return), qlist->name, strlen(qlist->name)+1, t_map); + IMAPG(quota_usage) = qlist->usage; + IMAPG(quota_limit) = qlist->limit; } } /* }}} */ @@ -1059,13 +1044,6 @@ PHP_FUNCTION(imap_get_quota) convert_to_string_ex(qroot); - MAKE_STD_ZVAL(IMAPG(quota_return)); - if (array_init(IMAPG(quota_return)) == FAILURE) { - php_error(E_WARNING, "Unable to allocate array memory"); - FREE_ZVAL(IMAPG(quota_return)); - RETURN_FALSE; - } - /* set the callback for the GET_QUOTA function */ mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota); if(!imap_getquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot))) { @@ -1073,9 +1051,13 @@ PHP_FUNCTION(imap_get_quota) RETURN_FALSE; } - *return_value = *IMAPG(quota_return); - FREE_ZVAL(IMAPG(quota_return)); - + if (array_init(return_value) == FAILURE) { + php_error(E_WARNING, "Unable to allocate array memory"); + RETURN_FALSE; + } + + add_assoc_long(return_value, "usage", IMAPG(quota_usage)); + add_assoc_long(return_value, "limit", IMAPG(quota_limit)); } /* }}} */ @@ -2218,7 +2200,7 @@ PHP_FUNCTION(imap_utf7_decode) /* author: Andrew Skalski <askalski@chek.com> */ zval **arg; const unsigned char *in, *inp, *endp; - unsigned char *out, *outp, c; + unsigned char *out, *outp; int inlen, outlen; enum { ST_NORMAL, /* printable text */ @@ -2320,15 +2302,13 @@ PHP_FUNCTION(imap_utf7_decode) break; case ST_DECODE1: outp[1] = UNB64(*inp); - c = outp[1] >> 4; - *outp++ |= c; + *outp++ |= outp[1] >> 4; *outp <<= 4; state = ST_DECODE2; break; case ST_DECODE2: outp[1] = UNB64(*inp); - c = outp[1] >> 2; - *outp++ |= c; + *outp++ |= outp[1] >> 2; *outp <<= 6; state = ST_DECODE3; break; @@ -2361,7 +2341,7 @@ PHP_FUNCTION(imap_utf7_encode) /* author: Andrew Skalski <askalski@chek.com> */ zval **arg; const unsigned char *in, *inp, *endp; - unsigned char *out, *outp, c; + unsigned char *out, *outp; int inlen, outlen; enum { ST_NORMAL, /* printable text */ @@ -2432,8 +2412,7 @@ PHP_FUNCTION(imap_utf7_encode) } else if (inp == endp || !SPECIAL(*inp)) { /* flush overflow and terminate region */ if (state != ST_ENCODE0) { - c = B64(*outp); - *outp++ = c; + *outp++ = B64(*outp); } *outp++ = '-'; state = ST_NORMAL; @@ -2441,20 +2420,17 @@ PHP_FUNCTION(imap_utf7_encode) /* encode input character */ switch (state) { case ST_ENCODE0: - c = B64(*outp | *inp >> 4); - *outp = c; + *outp++ = B64(*inp >> 2); *outp = *inp++ << 4; state = ST_ENCODE1; break; case ST_ENCODE1: - c = B64(*outp | *inp >> 4); - *outp++ = c; + *outp++ = B64(*outp | *inp >> 4); *outp = *inp++ << 2; state = ST_ENCODE2; break; case ST_ENCODE2: - c = B64(*outp | *inp >> 6); - *outp++ = c; + *outp++ = B64(*outp | *inp >> 6); *outp++ = B64(*inp++); state = ST_ENCODE0; case ST_NORMAL: |