cvs: /php3/functions pdf.c

From: Date: Thu, 22 Jul 1999 04:01:09 +0000
Subject: cvs: /php3/functions pdf.c
Groups: php.dev 
Request: Send a blank email to php-dev+get-8942@lists.php.net to get a copy of this message
cschneid Thu Jul 22 00:01:09 1999 EDT Modified files: /php3/functions pdf.c Log: Made pdf_add_outline for PDFLIB2 backward compatible with pdflib 0.6: proto int pdf_add_outline(int pdfdoc, string text [, int parent=0, int open=0]) Index: php3/functions/pdf.c diff -u php3/functions/pdf.c:1.42 php3/functions/pdf.c:1.43 --- php3/functions/pdf.c:1.42 Wed Jul 21 22:41:25 1999 +++ php3/functions/pdf.c Thu Jul 22 00:01:08 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdf.c,v 1.42 1999/07/22 02:41:25 cschneid Exp $ */ +/* $Id: pdf.c,v 1.43 1999/07/22 04:01:08 cschneid Exp $ */ /* pdflib 0.6 is subject to the ALADDIN FREE PUBLIC LICENSE. Copyright (C) 1997 Thomas Merz. */ @@ -1953,17 +1953,33 @@ } /* }}} */ -/* {{{ proto void pdf_add_outline(int pdfdoc, string text, int parent, int open); +/* {{{ proto int pdf_add_outline(int pdfdoc, string text [, int parent, int open]); Add bookmark for current page */ PHP_FUNCTION(pdf_add_outline) { pval *arg1, *arg2, *arg3, *arg4; int id, type; - int *outline, *parent; + int *outline, *parent, parentid, open; PDF *pdf; PDF_TLS_VARS; #if HAVE_PDFLIB2 - if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + switch (ARG_COUNT(ht)) { + case 2: + if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 3: + if (getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 4: + if (getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + default: WRONG_PARAM_COUNT; } #else @@ -1971,13 +1987,9 @@ WRONG_PARAM_COUNT; } #endif - convert_to_long(arg1); convert_to_string(arg2); -#if HAVE_PDFLIB2 - convert_to_long(arg3); - convert_to_long(arg4); -#endif + id=arg1->value.lval; pdf = php3_list_find(id,&type); if(!pdf || type!=PDF_GLOBAL(le_pdf)) { @@ -1986,15 +1998,35 @@ } #if HAVE_PDFLIB2 - id=arg3->value.lval; - parent = php3_list_find(id,&type); - if(!parent || type!=PDF_GLOBAL(le_outline)) { - php3_error(E_WARNING,"Unable to find identifier %d",id); - RETURN_FALSE; + if (ARG_COUNT(ht) > 2) { + convert_to_long(arg3); + id = arg3->value.lval; + + if (id > 0) { + parent = php3_list_find(id, &type); + if (!parent || (type != PDF_GLOBAL(le_outline))) { + php3_error(E_WARNING,"Unable to find identifier %d",id); + RETURN_FALSE; + } else { + parentid = *parent; + } + } else { + parentid = 0; + } + + if (ARG_COUNT(ht) > 3) { + convert_to_long(arg4); + open = arg4->value.lval; + } else { + open = 0; + } + } else { + parentid = 0; + open = 0; } outline=emalloc(sizeof(int)); - *outline = PDF_add_bookmark(pdf, estrdup(arg2->value.str.val), *parent, arg4->value.lval); + *outline = PDF_add_bookmark(pdf, estrdup(arg2->value.str.val), parentid, open); id = php3_list_insert(outline,PDF_GLOBAL(le_outline)); RETURN_LONG(id); #else

« previous php.dev (#8942) next »