--- sablot.c.old Sat May 11 12:10:49 2002 +++ sablot.c Sat May 11 12:58:18 2002 @@ -52,15 +52,15 @@ static int scheme_close(void *, SablotHandle, int); /* Sax handler functions */ -static SAX_RETURN sax_startdoc(void *); -static SAX_RETURN sax_startelement(void *, const char *, const char **); -static SAX_RETURN sax_endelement(void *, const char *); -static SAX_RETURN sax_startnamespace(void *, const char *, const char *); -static SAX_RETURN sax_endnamespace(void *, const char *); -static SAX_RETURN sax_comment(void *, const char *); -static SAX_RETURN sax_pi(void *, const char *, const char *); -static SAX_RETURN sax_characters(void *, const char *, int); -static SAX_RETURN sax_enddoc(void *); +static SAX_RETURN sax_startdoc(void *, SablotHandle); +static SAX_RETURN sax_startelement(void *, SablotHandle, const char *, const char **); +static SAX_RETURN sax_endelement(void *, SablotHandle, const char *); +static SAX_RETURN sax_startnamespace(void *, SablotHandle, const char *, const char *); +static SAX_RETURN sax_endnamespace(void *, SablotHandle, const char *); +static SAX_RETURN sax_comment(void *, SablotHandle, const char *); +static SAX_RETURN sax_pi(void *, SablotHandle, const char *, const char *); +static SAX_RETURN sax_characters(void *, SablotHandle, const char *, int); +static SAX_RETURN sax_enddoc(void *, SablotHandle); /* Error handlers */ static MH_ERROR error_makecode(void *, SablotHandle, int, unsigned short, unsigned short); @@ -723,12 +723,14 @@ xslt_call_function("scheme get all", XSLT_SCHEME(handle).get_all, 3, argv, &retval); - /* Save the return value in the buffer (copying it) */ - *buffer = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); - *byte_count = Z_STRLEN_P(retval); + if(retval) { + /* Save the return value in the buffer (copying it) */ + *buffer = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + *byte_count = Z_STRLEN_P(retval); - /* Free return value */ - zval_ptr_dtor(&retval); + /* Free return value */ + zval_ptr_dtor(&retval); + } return 0; } @@ -801,11 +803,13 @@ xslt_call_function("scheme open", XSLT_SCHEME(handle).open, 3, argv, &retval); - /* Return value is a resource pointer to an open file */ - *fd = Z_LVAL_P(retval); + if(retval) { + /* Return value is a resource pointer to an open file */ + *fd = Z_LVAL_P(retval); - /* Free it all up */ - zval_ptr_dtor(&retval); + /* Free it all up */ + zval_ptr_dtor(&retval); + } /* return success */ return 0; @@ -845,11 +849,13 @@ xslt_call_function("scheme get", XSLT_SCHEME(handle).get, 3, argv, &retval); - /* Returns the number of bytes read */ - *byte_count = Z_LVAL_P(retval); + if(retval) { + /* Returns the number of bytes read */ + *byte_count = Z_LVAL_P(retval); - /* Free things up */ - zval_ptr_dtor(&retval); + /* Free things up */ + zval_ptr_dtor(&retval); + } /* return success */ return 0; @@ -889,11 +895,13 @@ xslt_call_function("scheme put", XSLT_SCHEME(handle).put, 3, argv, &retval); - /* The return value is the number of bytes written */ - *byte_count = Z_LVAL_P(retval); + if(retval) { + /* The return value is the number of bytes written */ + *byte_count = Z_LVAL_P(retval); - /* Free everything up */ - zval_ptr_dtor(&retval); + /* Free everything up */ + zval_ptr_dtor(&retval); + } /* Return success */ return 0; @@ -931,7 +939,8 @@ 2, argv, &retval); /* Free everything up */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); /* Return success */ return 0; @@ -940,7 +949,7 @@ /* {{{ sax_startdoc() Called when the document starts to be processed */ -static SAX_RETURN sax_startdoc(void *ctx) +static SAX_RETURN sax_startdoc(void *ctx, SablotHandle proc) { zval *argv[1]; /* Arguments to the sax start doc function */ zval *retval; /* Return value from sax start doc function */ @@ -964,13 +973,15 @@ 1, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_startelement() Called when an element is begun to be processed */ static SAX_RETURN sax_startelement(void *ctx, + SablotHandle proc, const char *name, const char **attr) { @@ -1012,13 +1023,14 @@ 3, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ xslt_sax_endelement() Called when an ending XML element is encountered */ -static SAX_RETURN sax_endelement(void *ctx, const char *name) +static SAX_RETURN sax_endelement(void *ctx, SablotHandle proc, const char *name) { zval *argv[2]; /* Arguments to the sax end element function */ zval *retval; /* Return value from the sax end element function */ @@ -1046,13 +1058,15 @@ 2, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_startnamespace() Called at the beginning of the parsing of a new namespace */ -static SAX_RETURN sax_startnamespace(void *ctx, +static SAX_RETURN sax_startnamespace(void *ctx, + SablotHandle proc, const char *prefix, const char *uri) { @@ -1085,13 +1099,14 @@ 3, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_endnamespace() Called when a new namespace is finished being parsed */ -static SAX_RETURN sax_endnamespace(void *ctx, const char *prefix) +static SAX_RETURN sax_endnamespace(void *ctx, SablotHandle proc, const char *prefix) { zval *argv[2]; /* Arguments to the sax end namespace function */ zval *retval; /* Return value from the sax end namespace function */ @@ -1119,13 +1134,14 @@ 2, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_comment() Called when a comment is found */ -static SAX_RETURN sax_comment(void *ctx, const char *contents) +static SAX_RETURN sax_comment(void *ctx, SablotHandle proc, const char *contents) { zval *argv[2]; /* Arguments to the sax comment function */ zval *retval; /* Return value from the sax comment function */ @@ -1153,13 +1169,15 @@ 2, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_pi() Called when processing instructions are found */ static SAX_RETURN sax_pi(void *ctx, + SablotHandle proc, const char *target, const char *contents) { @@ -1192,13 +1210,15 @@ 3, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_characters() Called when characters are come upon */ static SAX_RETURN sax_characters(void *ctx, + SablotHandle proc, const char *contents, int length) { @@ -1228,13 +1248,14 @@ 2, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ /* {{{ sax_enddoc() Called when the document is finished being parsed */ -static SAX_RETURN sax_enddoc(void *ctx) +static SAX_RETURN sax_enddoc(void *ctx, SablotHandle proc) { zval *argv[1]; /* Arguments to the end document function */ zval *retval; /* Return value from the end document function */ @@ -1259,7 +1280,8 @@ 1, argv, &retval); /* Cleanup */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } /* }}} */ @@ -1478,7 +1500,8 @@ 4, argv, &retval); /* Free up */ - zval_ptr_dtor(&retval); + if(retval) + zval_ptr_dtor(&retval); } else { char *errmsg = NULL; /* Error message */