Re: [PHP4BETA] cvs: /php4/ext/imap php_imap.c

From: Date: Mon, 24 Apr 2000 23:40:47 +0000
Subject: Re: [PHP4BETA] cvs: /php4/ext/imap php_imap.c
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-14030@lists.php.net to get a copy of this message
When you build the UW c-client library, it generates a file named "linkage.c" which contains calls to mail_link() and auth_link() for each of the supported drivers and authenticators. Rather than link them in manually, it may be better to just #include "linkage.c". That way, the PHP module link in the appropriate drivers for all supported platforms the current c-client release, and future c-client releases. I didn't get a chance to investigate whether or not there was a reason for doing the linkage manually, so I left it in there as a suggestion for a possible future change. andy On Tue, Apr 25, 2000 at 01:31:15AM +0300, Andi Gutmans wrote: > Can you elaborate on that suggestion? > > Andi > > At 10:22 PM 4/24/00 +0000, Andrew Skalski wrote: > >askalski Mon Apr 24 15:22:04 2000 EDT > > > > Modified files: > > /php4/ext/imap php_imap.c > > Log: > > * typecast fs_give parameter to void** > > * removed wide-character treatment from imap_utf7_encode > > * suggestion to #include "linkage.c" rather than link in auth/mail drivers > > manually > > > > > >Index: php4/ext/imap/php_imap.c > >diff -u php4/ext/imap/php_imap.c:1.18 php4/ext/imap/php_imap.c:1.19 > >--- php4/ext/imap/php_imap.c:1.18 Sat Apr 22 13:54:07 2000 > >+++ php4/ext/imap/php_imap.c Mon Apr 24 15:21:34 2000 > >@@ -23,7 +23,7 @@ > > | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | > > +----------------------------------------------------------------------+ > > */ > >-/* $Id: php_imap.c,v 1.18 2000/04/22 20:54:07 chagenbu Exp $ */ > >+/* $Id: php_imap.c,v 1.19 2000/04/24 22:21:34 askalski Exp $ */ > > > > #define IMAP41 > > > >@@ -385,6 +385,7 @@ > > ZEND_INIT_MODULE_GLOBALS(imap, php_imap_init_globals, NULL) > > > > > >+#if 1 > > #ifndef PHP_WIN32 > > mail_link(&unixdriver); /* link in the unix driver */ > > #endif > >@@ -405,6 +406,11 @@ > > auth_link(&auth_log); /* link in the log authenticator */ > > #endif > > mail_link(&dummydriver); /* link in the dummy driver */ > >+#else > >+ /* link in the c-client mail and auth drivers */ > >+#include "linkage.c" > >+#endif > >+ > > /* lets allow NIL */ > > > > REGISTER_MAIN_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS); > >@@ -1973,7 +1979,7 @@ > > > > decode = (char *) rfc822_base64((unsigned char *) > > Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength); > > RETVAL_STRINGL(decode, newlength, 1); > >- fs_give(&decode); > >+ fs_give((void**) &decode); > > } > > /* }}} */ > > > >@@ -1995,7 +2001,7 @@ > > > > decode = (char *) rfc822_qprint((unsigned char *) > > Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength); > > RETVAL_STRINGL(decode, newlength, 1); > >- fs_give(&decode); > >+ fs_give((void**) &decode); > > } > > /* }}} */ > > > >@@ -2017,7 +2023,7 @@ > > > > decode = (char *) rfc822_8bit((unsigned char *) > > Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength); > > RETVAL_STRINGL(decode, newlength, 1); > >- fs_give(&decode); > >+ fs_give((void**) &decode); > > } > > /* }}} */ > > > >@@ -2036,7 +2042,7 @@ > > convert_to_string_ex(text); > > decode = rfc822_binary(Z_STRVAL_PP(text), Z_STRLEN_PP(text), &len); > > RETVAL_STRINGL(decode, len, 1); > >- fs_give(&decode); > >+ fs_give((void**) &decode); > > } > > /* }}} */ > > > >@@ -2217,11 +2223,11 @@ > > PHP_FUNCTION(imap_utf7_decode) > > { > > /* author: Andrew Skalski <askalski@chek.com> */ > >- int argc; > >+ int argc; > > zval **arg; > > const unsigned char *in, *inp, *endp; > > unsigned char *out, *outp; > >- int inlen, outlen; > >+ int inlen, outlen; > > enum { > > ST_NORMAL, /* printable text */ > > ST_DECODE0, /* encoded text rotation... */ > >@@ -2229,7 +2235,7 @@ > > ST_DECODE2, > > ST_DECODE3 > > } state; > >- > >+ > > /* collect arguments */ > > argc = ZEND_NUM_ARGS(); > > if (argc != 1 || zend_get_parameters_ex(argc, &arg) == FAILURE) { > >@@ -2372,11 +2378,11 @@ > > PHP_FUNCTION(imap_utf7_encode) > > { > > /* author: Andrew Skalski <askalski@chek.com> */ > >- int argc; > >+ int argc; > > zval **arg; > >- const unsigned char *in, *inp, *endp; > >+ const unsigned char *in, *inp, *endp; > > unsigned char *out, *outp; > >- int inlen, outlen, slen; > >+ int inlen, outlen; > > enum { > > ST_NORMAL, /* printable text */ > > ST_ENCODE0, /* encoded text rotation... */ > >@@ -2389,7 +2395,7 @@ > > if (argc != 1 || zend_get_parameters_ex(argc, &arg) == FAILURE) { > > ZEND_WRONG_PARAM_COUNT(); > > } > >- convert_to_writable_string_ex(arg); /* Is this string > >really modified? */ > >+ convert_to_string_ex(arg); > > in = (const unsigned char *) Z_STRVAL_PP(arg); > > inlen = Z_STRLEN_PP(arg); > > > >@@ -2400,23 +2406,28 @@ > > while (inp < endp) { > > if (state == ST_NORMAL) { > > if (SPECIAL(*inp)) { > >- state = ST_ENCODE1; > >- slen=1; > >- } else if (*inp == '&') { > >+ state = ST_ENCODE0; > > outlen++; > >+ } else if (*inp++ == '&') { > >+ outlen++; > > } > > outlen++; > > } else if (!SPECIAL(*inp)) { > > state = ST_NORMAL; > >- outlen+=2+slen*3-slen/3; > >- slen=0; > > } else { > >- slen++; > >+ /* ST_ENCODE0 -> ST_ENCODE1 - two chars > >+ * ST_ENCODE1 -> ST_ENCODE2 - one char > >+ * ST_ENCODE2 -> ST_ENCODE0 - one char > >+ */ > >+ if (state == ST_ENCODE2) { > >+ state = ST_ENCODE0; > >+ } > >+ else if (state++ == ST_ENCODE0) { > >+ outlen++; > >+ } > >+ outlen++; > >+ inp++; > > } > >- inp++; > >- } > >- if (state!=ST_NORMAL) { > >- outlen+=1+slen*3-slen/3; > > } > > > > /* allocate output buffer */ > >@@ -2450,41 +2461,22 @@ > > /* encode input character */ > > switch (state) { > > case ST_ENCODE0: > >- *outp++ = B64((*inp>>8) >> 2); > >- *outp = (*inp>>8) << 4; > >+ *outp++ = B64(*inp >> 2); > >+ *outp = *inp++ << 4; > > state = ST_ENCODE1; > > break; > > case ST_ENCODE1: > >- *outp++ = B64(*outp | (*inp>>8) >> 4); > >- *outp = (*inp>>8) << 2; > >+ *outp++ = B64(*outp | *inp >> 4); > >+ *outp = *inp++ << 2; > > state = ST_ENCODE2; > > break; > > case ST_ENCODE2: > >- *outp++ = B64(*outp | (*inp>>8) >> 6); > >- *outp++ = B64((*inp>>8)); > >+ *outp++ = B64(*outp | *inp >> 6); > >+ *outp++ = B64(*inp++); > > state = ST_ENCODE0; > > case ST_NORMAL: > > break; > > } > >- switch (state) { > >- case ST_ENCODE0: > >- *outp++ = B64((*inp&0xff) >> 2); > >- *outp = (*inp&0xff) << 4; > >- state = ST_ENCODE1; > >- break; > >- case ST_ENCODE1: > >- *outp++ = B64(*outp | > >(*inp&0xff) >> 4); > >- *outp = (*inp&0xff) << 2; > >- state = ST_ENCODE2; > >- break; > >- case ST_ENCODE2: > >- *outp++ = B64(*outp | > >(*inp&0xff) >> 6); > >- *outp++ = B64((*inp&0xff)); > >- state = ST_ENCODE0; > >- case ST_NORMAL: > >- break; > >- } > >- inp++; > > } > > } > > > >@@ -3487,7 +3479,7 @@ > > > >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(&decode); > >+ fs_give((void**) &decode); > > > > offset+=end_token+2; > > if (string[offset]==' ' > > && string[offset+1]=='=' && string[offset+2]=='?') { > > > > > > > >-- > >PHP 4.0 Beta Mailing List > ><http://www.php.net/version4/> > >To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > >For additional commands, e-mail: php4beta-help@lists.php.net > >To contact the list administrators, e-mail: php4beta-admin@lists.php.net > > --- > Andi Gutmans <andi@zend.com> > http://www.zend.com/

« previous php.version4 (#14030) next »