Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88584 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43933 invoked from network); 30 Sep 2015 20:39:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2015 20:39:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=zardozrocks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zardozrocks@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.178 as permitted sender) X-PHP-List-Original-Sender: zardozrocks@gmail.com X-Host-Fingerprint: 209.85.223.178 mail-io0-f178.google.com Received: from [209.85.223.178] ([209.85.223.178:33458] helo=mail-io0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/70-38941-1884C065 for ; Wed, 30 Sep 2015 16:39:30 -0400 Received: by iofh134 with SMTP id h134so62509441iof.0 for ; Wed, 30 Sep 2015 13:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=XNs+S1YtLOpfG++SjPvUItDVzM28mQZrIkvnGNdrFzc=; b=R2jSXUfKs9bypFXiRSMaFZFIB6J29ZhQGz+sxl6b6zrUjHKUnUYAsdu3eFbWqGOrKf C+G5hBzQdUXLhxPiy6XNthqjbglC8VWagtXryHnu2MmgMbXcIq999EUvaHUd7Gx9tq/6 pM6l1It1v7V4e8XAA/dXJAL/oHhEKt6q7JTzgiZS7IDw5TzUlM5lBsHYJFf74vtSeyUd rFspLnurNAyTVjBpIJrVRrQOoPzBFgi1wuVSE509IaR6jk5/Xur5tHvMUCCGCwtp5/I8 v67+IxyLXrXlprxYHcKB0i4QxedPdw/d9vFn0KP75667EBQUjwCQEJJiNC9exc/BJHBe cvpg== MIME-Version: 1.0 X-Received: by 10.107.8.89 with SMTP id 86mr6724962ioi.125.1443645566583; Wed, 30 Sep 2015 13:39:26 -0700 (PDT) Received: by 10.107.31.148 with HTTP; Wed, 30 Sep 2015 13:39:26 -0700 (PDT) Date: Wed, 30 Sep 2015 13:39:26 -0700 Message-ID: To: internals Content-Type: multipart/alternative; boundary=001a113f3cd42da4ab0520fced0c Subject: good example of unserialization fundamentals? From: zardozrocks@gmail.com (j adams) --001a113f3cd42da4ab0520fced0c Content-Type: text/plain; charset=UTF-8 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 --001a113f3cd42da4ab0520fced0c--