Read http://php.net/streams

Goba [one [EMAIL PROTECTED]]

----- Original Message -----
From: "Mike Wossen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, December 30, 2002 10:00 AM
Subject: [PHP-DOC] Help needed: php_fopen_wrapper in php 4.3.0


> I�m migrating from php 4.2.1 to 4.3.0 (rh 7.2).
>
> I've written my own php template extension.
>
>
>
> Compilation runs normally (with 3 warning messages on lines where
> php_fopen_wrapper function is used).
>
> But when i try starting apache i get error message:
>
> Cannot load /usr/local/apache/libexec/libphp4.so into server:
> /usr/local/apache/libexec/libphp4.so: undefined symbol: php_fopen_wrapper
>
>
> Where can I find documentations about  all changes made to wrappers in php
> 4.3.0.
>
> Should I need to use new functions like php_stream_open_wrapper_as_file
(or
> similar) instead?
>
>
>
> My piece of code:
>
> -----------------------------------------------
>
>
>
> PHP_FUNCTION(temp_load)
> {
>         zval **tempfile=NULL, **cachefile=NULL;
>         int argc;
>         char *filename;
>         FILE *fp;
>         struct stat st;
>         template *tp;
> //      TEMPLATELS_FETCH();
>
>         argc = ZEND_NUM_ARGS();
>         if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc,
&tempfile,
> &cachefile) == FAILURE){
>                 WRONG_PARAM_COUNT;
>         }
>
>         switch (argc) {
>                 case 2:
>                         convert_to_string_ex(cachefile);
>                         /* Fall-through. */
>                 case 1:
>                         convert_to_string_ex(tempfile);
>                         break;
>         }
>
>         tp = emalloc(sizeof(template));
>         tp->bl = emalloc(sizeof(block));
>         tp->bl->cont = emalloc(sizeof(mpchain));
>         tp->bl->cont->next = NULL;
>         tp->bl->lastcont = tp->bl->cont;
>
>         tp->bl->lastcont->mp.ptr = NULL;
>
>         tp->bl->prev = NULL;
>         tp->bl->done = 0;
>
>         tp->cf = NULL;
>         tp->cached = 0;
>
>         if(cachefile)
>                {
>                 filename = Z_STRVAL_PP(cachefile);
>
>
>
>                 /*
>
>                 LINE WITH WARNING
>
>                 */
>                 if((fp = php_fopen_wrapper(filename,"r",
> USE_PATH|ENFORCE_SAFE_MODE|IGNORE_URL, NULL, NULL, NULL)))
>                         {
>                         if(fstat(fileno(fp),&st))
>                                 {
>                                 php_error(E_WARNING,"Can't get stats of
> \"%s\" - %s",filename,strerror(errno));
>                                 RETURN_FALSE;
>                                 }
>
>                         if(st.st_size > 0)
>                                 {
>                                 tp->cached = 1;
>                                 goto notemp;
>                                 }
>                         }
>                 else if (errno == ENOENT)               // cachefile not
> found
>                         {
>
>
>                 /*
>
>                 LINE WITH WARNING
>
>                 */
>                         if(!(tp->cf = php_fopen_wrapper(filename,"w",
> USE_PATH|ENFORCE_SAFE_MODE|IGNORE_URL, NULL, NULL, &tp->cachefile)))
>                                 {
>                                 php_error(E_WARNING,"Can't open
> cachefile(\"%s\") for writing - %s",filename,strerror(errno));
>                                 RETURN_FALSE;
>                                 }
>                         }
>                 else    // some other error
>                         {
>                         php_error(E_WARNING,"Can't open
cachefile(\"%s\") -
> %s",filename,strerror(errno));
>                         RETURN_FALSE;
>                         }
>                 }
>
>         filename = Z_STRVAL_PP(tempfile);
>
>
>
>
>                 /*
>
>                 LINE WITH WARNING
>
>                 */
>         if(!(fp = php_fopen_wrapper(filename,"r",
> USE_PATH|ENFORCE_SAFE_MODE|IGNORE_URL, NULL, NULL, NULL)))
>                 {
>                 php_error(E_WARNING,"Can't open tempfile(\"%s\") -
> %s",filename,strerror(errno));
>                 RETURN_FALSE;
>                 }
>         if(fstat(fileno(fp),&st))
>                 {
>                 php_error(E_WARNING,"Can't get stats of \"%s\" -
> %s",filename,strerror(errno));
>                 RETURN_FALSE;
>                 }
>
> notemp:
>
>         tp->bl->lastcont->mp.ptr = emalloc(tp->bl->lastcont->mp.len =
> st.st_size);
>         if(fread(tp->bl->lastcont->mp.ptr,st.st_size,1,fp)!=1)
>                 {
>                 php_error(E_WARNING,"Can't read file \"%s\" -
> %s",filename,strerror(errno));
>                 RETURN_FALSE;
>                 }
>
>         /*php_stream_close(fp);*/
>         fclose(fp);
>         ZEND_REGISTER_RESOURCE(return_value, tp, le_template);
> }
> /* }}} */
>
>
>
>
> Regards,
> Mike
>
>
>
> --
> PHP Documentation Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to