good example of unserialization fundamentals?

From: Date: Wed, 30 Sep 2015 20:39:26 +0000
Subject: good example of unserialization fundamentals?
Groups: php.internals 
Request: Send a blank email to internals+get-88584@lists.php.net to get a copy of this message
I have completed a first draft of serialization functionality which is intended to be an updated to amfext. It's on github[0] if anyone is interested. I would now like to write all the unserialization routines and would like some suggestions from experienced php devs. I've been reading Sara Golemon's book, but am still a little unsure. In particular, I want my userland function, amf_decode to accept as a parameter a string (and possibly other args). This is not so difficult but I must call upon another function, php_amf_decode, which needs to be able to handle recursive calls. Something like this: // userland function static PHP_FUNCTION(amf_decode) { char *buf; // char buffer, contains serialize data string int buf_len, buf_cursor=0; // the length of the buffer long flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &buf, &buf_len, &flags) == FAILURE) { return; } if (!buf_len) { RETURN_NULL(); } php_amf_decode(return_value, buf, buf_len, &buf_cursor, flags TSRMLS_CC); } // proposed recursive decoding function PHP_AMF_API void php_amf_decode(zval *return_value, char *buf, int buf_len, int *buf_cursor, long flags TSRMLS_DC) { // is it safe to use these macros in this recursive function? RETVAL_BOOL(1); // or this RETURN_LONG(42); } [0] https://github.com/sneakyimp/amfext

« previous php.internals (#88584) next »