"Fossies" - the Fresh Open Source Software Archive

Member "PDFlib-Lite-7.0.5p3/libs/pdflib/pdflib.c" (6 Jun 2012, 102433 Bytes) of package /linux/misc/old/PDFlib-Lite-7.0.5p3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pdflib.c" see the Fossies "Dox" file reference documentation.

    1 /*---------------------------------------------------------------------------*
    2  |              PDFlib - A library for generating PDF on the fly             |
    3  +---------------------------------------------------------------------------+
    4  | Copyright (c) 1997-2006 Thomas Merz and PDFlib GmbH. All rights reserved. |
    5  +---------------------------------------------------------------------------+
    6  |                                                                           |
    7  |    This software is subject to the PDFlib license. It is NOT in the       |
    8  |    public domain. Extended versions and commercial licenses are           |
    9  |    available, please check http://www.pdflib.com.                         |
   10  |                                                                           |
   11  *---------------------------------------------------------------------------*/
   12 
   13 /* $Id: pdflib.c,v 1.128.2.19 2009/03/03 21:12:37 kurt Exp $
   14  *
   15  * PDFlib API functions
   16  *
   17  */
   18 
   19 #define PDFLIB_C
   20 
   21 #include "p_intern.h"
   22 
   23 
   24 #if (defined(WIN32) || defined(__CYGWIN))
   25 #define WIN32_LEAN_AND_MEAN
   26 #include <windows.h>
   27 #include <winbase.h>
   28 #undef WIN32_LEAN_AND_MEAN
   29 #endif /* WIN32 || __CYGWIN */
   30 
   31 #if _MSC_VER >= 1310    /* VS .NET 2003 and later */
   32 /* pdflib.h declares some functions as deprecated, but we don't want to see
   33  * these warnings here */
   34 #pragma warning(disable: 4995)
   35 #endif
   36 
   37 static const PDFlib_api PDFlib = {
   38     /* version numbers for checking the DLL against client code */
   39     sizeof(PDFlib_api),         /* size of this structure */
   40 
   41     PDFLIB_MAJORVERSION,        /* PDFlib major version number */
   42     PDFLIB_MINORVERSION,        /* PDFlib minor version number */
   43     PDFLIB_REVISION,            /* PDFlib revision number */
   44 
   45     0,                          /* reserved */
   46 
   47     PDF_activate_item,
   48     PDF_add_bookmark,
   49     PDF_add_bookmark2,
   50     PDF_add_launchlink,
   51     PDF_add_locallink,
   52     PDF_add_nameddest,
   53     PDF_add_note,
   54     PDF_add_note2,
   55     PDF_add_pdflink,
   56     PDF_add_table_cell,
   57     PDF_add_textflow,
   58     PDF_add_thumbnail,
   59     PDF_add_weblink,
   60     PDF_arc,
   61     PDF_arcn,
   62     PDF_attach_file,
   63     PDF_attach_file2,
   64     PDF_begin_document,
   65     PDF_begin_document_callback,
   66     PDF_begin_font,
   67     PDF_begin_glyph,
   68     PDF_begin_item,
   69     PDF_begin_layer,
   70     PDF_begin_mc,
   71     PDF_begin_page,
   72     PDF_begin_page_ext,
   73     PDF_begin_pattern,
   74     PDF_begin_template,
   75     PDF_begin_template_ext,
   76     PDF_boot,
   77     PDF_check_context,
   78     PDF_circle,
   79     PDF_clip,
   80     PDF_close,
   81     PDF_close_image,
   82     PDF_close_pdi,
   83     PDF_close_pdi_document,
   84     PDF_close_pdi_page,
   85     PDF_closepath,
   86     PDF_closepath_fill_stroke,
   87     PDF_closepath_stroke,
   88     PDF_concat,
   89     PDF_continue_text,
   90     PDF_continue_text2,
   91     PDF_create_3dview,
   92     PDF_create_action,
   93     PDF_create_annotation,
   94     PDF_create_bookmark,
   95     PDF_create_field,
   96     PDF_create_fieldgroup,
   97     PDF_create_gstate,
   98     PDF_create_pvf,
   99     PDF_create_textflow,
  100     PDF_curveto,
  101     PDF_define_layer,
  102     PDF_delete,
  103     PDF_delete_pvf,
  104     PDF_delete_table,
  105     PDF_delete_textflow,
  106     PDF_encoding_set_char,
  107     PDF_end_document,
  108     PDF_end_font,
  109     PDF_end_glyph,
  110     PDF_end_item,
  111     PDF_end_layer,
  112     PDF_end_mc,
  113     PDF_end_page,
  114     PDF_end_page_ext,
  115     PDF_end_pattern,
  116     PDF_end_template,
  117     PDF_endpath,
  118     PDF_fill,
  119     PDF_fill_imageblock,
  120     PDF_fill_pdfblock,
  121     PDF_fill_stroke,
  122     PDF_fill_textblock,
  123     PDF_findfont,
  124     PDF_fit_image,
  125     PDF_fit_pdi_page,
  126     PDF_fit_table,
  127     PDF_fit_textflow,
  128     PDF_fit_textline,
  129     PDF_get_api,
  130     PDF_get_apiname,
  131     PDF_get_buffer,
  132     PDF_get_errmsg,
  133     PDF_get_errnum,
  134     PDF_get_majorversion,
  135     PDF_get_minorversion,
  136     PDF_get_opaque,
  137     PDF_get_parameter,
  138     PDF_get_pdi_parameter,
  139     PDF_get_pdi_value,
  140     PDF_get_value,
  141     PDF_info_font,
  142     PDF_info_matchbox,
  143     PDF_info_table,
  144     PDF_info_textflow,
  145     PDF_info_textline,
  146     PDF_initgraphics,
  147     PDF_lineto,
  148     PDF_load_3ddata,
  149     PDF_load_font,
  150     PDF_load_iccprofile,
  151     PDF_load_image,
  152     PDF_makespotcolor,
  153     PDF_mc_point,
  154     PDF_moveto,
  155     PDF_new,
  156     PDF_new2,
  157     PDF_open_CCITT,
  158     PDF_open_file,
  159     PDF_open_image,
  160     PDF_open_image_file,
  161     PDF_open_mem,
  162     PDF_open_pdi,
  163     PDF_open_pdi_callback,
  164     PDF_open_pdi_document,
  165     PDF_open_pdi_page,
  166     PDF_pcos_get_number,
  167     PDF_pcos_get_string,
  168     PDF_pcos_get_stream,
  169     PDF_place_image,
  170     PDF_place_pdi_page,
  171     PDF_process_pdi,
  172     PDF_rect,
  173     PDF_restore,
  174     PDF_resume_page,
  175     PDF_rotate,
  176     PDF_save,
  177     PDF_scale,
  178     PDF_set_border_color,
  179     PDF_set_border_dash,
  180     PDF_set_border_style,
  181     PDF_set_gstate,
  182     PDF_set_info,
  183     PDF_set_info2,
  184     PDF_set_layer_dependency,
  185     PDF_set_parameter,
  186     PDF_set_text_pos,
  187     PDF_set_value,
  188     PDF_setcolor,
  189     PDF_setdash,
  190     PDF_setdashpattern,
  191     PDF_setflat,
  192     PDF_setfont,
  193     PDF_setgray,
  194     PDF_setgray_fill,
  195     PDF_setgray_stroke,
  196     PDF_setlinecap,
  197     PDF_setlinejoin,
  198     PDF_setlinewidth,
  199     PDF_setmatrix,
  200     PDF_setmiterlimit,
  201     PDF_setpolydash,
  202     PDF_setrgbcolor,
  203     PDF_setrgbcolor_fill,
  204     PDF_setrgbcolor_stroke,
  205     PDF_shading,
  206     PDF_shading_pattern,
  207     PDF_shfill,
  208     PDF_show,
  209     PDF_show2,
  210     PDF_show_boxed,
  211     PDF_show_boxed2,
  212     PDF_show_xy,
  213     PDF_show_xy2,
  214     PDF_shutdown,
  215     PDF_skew,
  216     PDF_stringwidth,
  217     PDF_stringwidth2,
  218     PDF_stroke,
  219     PDF_suspend_page,
  220     PDF_translate,
  221     PDF_utf16_to_utf8,
  222     PDF_utf32_to_utf16,
  223     PDF_utf8_to_utf16,
  224     PDF_xshow,
  225     pdf_catch,
  226     pdf_exit_try,
  227     pdf_jbuf,
  228     pdf_rethrow
  229 };
  230 
  231 static pdc_bool
  232 pdf__check_context(PDF *p)
  233 {
  234     if (p == NULL || p->magic != PDC_MAGIC)
  235     {
  236         fprintf(stderr, "*** PDFlib context pointer %p is invalid ***\n", p);
  237         return pdc_false;
  238     }
  239 
  240     return pdc_true;
  241 }
  242 
  243 static pdc_bool
  244 pdf_enter_api(PDF *p, const char *funame, pdf_state s, const char *fmt, ...)
  245 {
  246     /* check whether the client completely screwed up */
  247     if (pdf__check_context(p))
  248     {
  249         pdc_bool retval;
  250         va_list args;
  251 
  252         va_start(args, fmt);
  253         retval = pdc_enter_api_logg(p->pdc, funame, pdc_true, fmt, args);
  254         va_end(args);
  255 
  256         if (retval)
  257         {
  258             /* check whether we are in a valid scope */
  259             if ((p->state_stack[p->state_sp] & s) != 0)
  260             {
  261                 return pdc_true;
  262             }
  263 
  264             /* check glyphignore scope */
  265             if ((p->state_stack[p->state_sp] & pdf_state_glyphignore) == 0)
  266             {
  267                 /* pdc_error() will NOT throw an exception
  268                 ** (and simply return instead) if the core
  269                 ** is already in error state.
  270                 */
  271                 pdc_error(p->pdc, PDF_E_DOC_SCOPE, pdf_current_scope(p),
  272                           0, 0, 0);
  273             }
  274         }
  275 
  276         pdc_logg_exit_api(p->pdc, pdc_true, "\n");
  277     }
  278 
  279     /* invalid PDFlib context or
  280     ** core is in the error state or
  281     ** glyphignore scope
  282     */
  283     return pdc_false;
  284 }
  285 
  286 static pdc_bool
  287 pdf_enter_api_simple(PDF *p, const char *funame, const char *fmt, ...)
  288 {
  289     /* check whether the client completely screwed up */
  290     if (pdf__check_context(p))
  291     {
  292         pdc_bool retval;
  293         va_list args;
  294 
  295         va_start(args, fmt);
  296         retval = pdc_enter_api_logg(p->pdc, funame, pdc_false, fmt, args);
  297         va_end(args);
  298 
  299         return retval;
  300     }
  301 
  302     return pdc_false;
  303 }
  304 
  305 static int
  306 pdf_exit_boolean_api(PDF *p, int retval)
  307 {
  308     /* check whether the client completely screwed up */
  309     if (pdf__check_context(p))
  310     {
  311         if (p->pdc->hastobepos && retval == -1)
  312             retval += 1;
  313         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
  314     }
  315 
  316     return retval;
  317 }
  318 
  319 static int
  320 pdf_exit_handle_api(PDF *p, int retval)
  321 {
  322     /* check whether the client completely screwed up */
  323     if (pdf__check_context(p))
  324     {
  325         if (p->pdc->hastobepos)
  326             retval += 1;
  327         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
  328     }
  329 
  330     return retval;
  331 }
  332 
  333 static void
  334 pdf_logg_is_deprecated(PDF *p, const char *fn, int version)
  335 {
  336     pdc_logg_cond(p->pdc, 2, trc_api,
  337             "[Function \"%s\" is deprecated since PDFlib %d]\n",
  338             fn, version);
  339 }
  340 
  341 static void
  342 pdf_logg_is_unsupported(PDF *p, const char *fn)
  343 {
  344     pdc_logg_cond(p->pdc, 2, trc_api,
  345             "[Function \"%s\" is unsupported]\n", fn);
  346 }
  347 
  348 
  349 /***************************
  350  *
  351  *  external API functions
  352  *
  353  ***************************/
  354 
  355 PDFLIB_API void PDFLIB_CALL
  356 PDF_boot(void)
  357 {
  358     /* nothing yet */
  359 }
  360 
  361 PDFLIB_API void PDFLIB_CALL
  362 PDF_shutdown(void)
  363 {
  364     /* nothing yet */
  365 }
  366 
  367 PDFLIB_API const PDFlib_api * PDFLIB_CALL
  368 PDF_get_api(void)
  369 {
  370     return &PDFlib;
  371 }
  372 
  373 PDFLIB_API int PDFLIB_CALL
  374 PDF_get_majorversion(void)
  375 {
  376     return PDFLIB_MAJORVERSION;
  377 }
  378 
  379 PDFLIB_API int PDFLIB_CALL
  380 PDF_get_minorversion(void)
  381 {
  382     return PDFLIB_MINORVERSION;
  383 }
  384 
  385 
  386 #if (defined(WIN32) || defined(__CYGWIN)) && defined(PDFLIB_EXPORTS)
  387 
  388 /*
  389  * DLL entry function as required by Visual C++.
  390  * It is currently not necessary on Windows, but will eventually
  391  * be used to boot thread-global resources for PDFlib
  392  * (mainly font-related stuff).
  393  */
  394 BOOL WINAPI
  395 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved);
  396 
  397 BOOL WINAPI
  398 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  399 {
  400     (void) hModule;
  401     (void) lpReserved;
  402 
  403     switch (ul_reason_for_call)
  404     {
  405         case DLL_PROCESS_ATTACH:
  406             PDF_boot();
  407             break;
  408         case DLL_THREAD_ATTACH:
  409             break;
  410         case DLL_THREAD_DETACH:
  411             break;
  412         case DLL_PROCESS_DETACH:
  413             PDF_shutdown();
  414             break;
  415     }
  416 
  417     return TRUE;
  418 }
  419 #endif  /* WIN32 && PDFLIB_EXPORT */
  420 
  421 
  422 /*************************
  423  *
  424  *  general API functions
  425  *
  426  *************************/
  427 
  428 PDFLIB_API int PDFLIB_CALL
  429 PDF_check_context(PDF *p)
  430 {
  431     return pdf__check_context(p);
  432 }
  433 
  434 PDFLIB_API int PDFLIB_CALL
  435 PDF_get_errnum(PDF *p)
  436 {
  437     static const char fn[] = "PDF_get_errnum";
  438     int retval = -1;
  439 
  440     if (pdf_enter_api_simple(p, fn, "(p_%p)\n", (void *) p))
  441     {
  442         retval = pdc_get_errnum(p->pdc);
  443         pdc_logg_exit_api(p->pdc, pdc_false, "[%d]\n", retval);
  444     }
  445 
  446     return retval;
  447 }
  448 
  449 PDFLIB_API const char * PDFLIB_CALL
  450 PDF_get_errmsg(PDF *p)
  451 {
  452     static const char fn[] = "PDF_get_errmsg";
  453     const char *retval = "";
  454 
  455     if (pdf_enter_api_simple(p, fn, "(p_%p)\n", (void *) p))
  456     {
  457         retval = pdc_get_errmsg(p->pdc);
  458         pdc_logg_exit_api(p->pdc, pdc_false, "[\"%T\"]\n", retval, 0);
  459     }
  460 
  461     return retval;
  462 }
  463 
  464 PDFLIB_API const char * PDFLIB_CALL
  465 PDF_get_apiname(PDF *p)
  466 {
  467     static const char fn[] = "PDF_get_apiname";
  468     const char *retval = "";
  469 
  470     if (pdf_enter_api_simple(p, fn, "(p_%p)\n", (void *) p))
  471     {
  472         retval = pdc_get_apiname(p->pdc);
  473         pdc_logg_exit_api(p->pdc, pdc_false, "[\"%T\"]\n", retval, 0);
  474     }
  475 
  476     return retval;
  477 }
  478 
  479 PDFLIB_API void * PDFLIB_CALL
  480 PDF_get_opaque(PDF *p)
  481 {
  482     static const char fn[] = "PDF_get_opaque";
  483     void *retval = NULL;
  484 
  485     if (pdf__check_context(p))
  486     {
  487         pdc_logg_cond(p->pdc, 1, trc_api, "/* ");
  488         pdf_enter_api_simple(p, fn, "(p_%p) */\n", (void *) p);
  489         retval = p->opaque;
  490         pdc_logg_exit_api(p->pdc, pdc_false, "/* [%p] */\n", retval);
  491     }
  492 
  493     return retval;
  494 }
  495 
  496 PDFLIB_API pdf_jmpbuf * PDFLIB_CALL
  497 pdf_jbuf(PDF *p)
  498 {
  499     if (pdf__check_context(p))
  500         return (pdf_jmpbuf *) pdc_jbuf(p->pdc);
  501 
  502     return ((pdf_jmpbuf *) NULL);
  503 }
  504 
  505 PDFLIB_API void PDFLIB_CALL
  506 pdf_exit_try(PDF *p)
  507 {
  508     if (pdf__check_context(p))
  509         pdc_exit_try(p->pdc);
  510 }
  511 
  512 PDFLIB_API int PDFLIB_CALL
  513 pdf_catch(PDF *p)
  514 {
  515     if (pdf__check_context(p))
  516         return pdc_catch_extern(p->pdc);
  517 
  518     return pdc_false;
  519 }
  520 
  521 PDFLIB_API void PDFLIB_CALL
  522 pdf_rethrow(PDF *p)
  523 {
  524     static const char fn[] = "pdf_rethrow";
  525 
  526     if (pdf_enter_api_simple(p, fn, "(p_%p)\n", (void *) p))
  527         pdc_rethrow(p->pdc);
  528 }
  529 
  530 PDFLIB_API void PDFLIB_CALL
  531 pdf_throw(PDF *p, const char *parm1, const char *parm2, const char *parm3)
  532 {
  533     if (pdf__check_context(p))
  534     {
  535         pdc_enter_api(p->pdc, "pdf_throw");
  536         pdc_error(p->pdc, PDF_E_INT_WRAPPER, parm1, parm2, parm3, NULL);
  537     }
  538 }
  539 
  540 
  541 /**********************
  542  *
  543  *  p_3d.c
  544  *
  545  **********************/
  546 
  547 PDFLIB_API int PDFLIB_CALL
  548 PDF_create_3dview(
  549     PDF *p,
  550     const char *username,
  551     int len,
  552     const char *optlist)
  553 {
  554     static const char fn[] = "PDF_create_3dview";
  555     int retval = -1;
  556 
  557     if (pdf_enter_api(p, fn,
  558         (pdf_state) (pdf_state_page | pdf_state_document),
  559         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
  560         (void *) p, username, len, len, optlist, 0))
  561     {
  562         pdc_error(p->pdc, PDF_E_UNSUPP_3DANNOT, 0, 0, 0, 0);
  563     }
  564 
  565     return pdf_exit_handle_api(p, retval);
  566 }
  567 
  568 PDFLIB_API int PDFLIB_CALL
  569 PDF_load_3ddata(
  570     PDF *p,
  571     const char *filename,
  572     int len,
  573     const char *optlist)
  574 {
  575     static const char fn[] = "PDF_load_3ddata";
  576     int retval = -1;
  577 
  578     if (pdf_enter_api(p, fn,
  579         (pdf_state) (pdf_state_page | pdf_state_document),
  580         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
  581         (void *) p, filename, len, len, optlist, 0))
  582     {
  583         pdc_error(p->pdc, PDF_E_UNSUPP_3DANNOT, 0, 0, 0, 0);
  584     }
  585 
  586     return pdf_exit_handle_api(p, retval);
  587 }
  588 
  589 
  590 /**********************
  591  *
  592  *  p_actions.c
  593  *
  594  **********************/
  595 
  596 PDFLIB_API int PDFLIB_CALL
  597 PDF_create_action(
  598     PDF *p,
  599     const char *type,
  600     const char *optlist)
  601 {
  602     static const char fn[] = "PDF_create_action";
  603     int retval = -1;
  604 
  605     if (pdf_enter_api(p, fn,
  606         (pdf_state) (pdf_state_page | pdf_state_document),
  607         "(p_%p, \"%s\", \"%T\")\n",
  608         (void *) p, type, optlist, 0))
  609     {
  610         retval = pdf__create_action(p, type, optlist);
  611     }
  612 
  613     return pdf_exit_handle_api(p, retval);
  614 }
  615 
  616 
  617 /**********************
  618  *
  619  *  p_annots.c
  620  *
  621  **********************/
  622 
  623 PDFLIB_API void PDFLIB_CALL
  624 PDF_attach_file(
  625     PDF *p,
  626     double llx,
  627     double lly,
  628     double urx,
  629     double ury,
  630     const char *filename,
  631     const char *description,
  632     const char *author,
  633     const char *mimetype,
  634     const char *icon)
  635 {
  636     static const char fn[] = "PDF_attach_file";
  637 
  638     if (pdf_enter_api(p, fn, pdf_state_page,
  639         "(p_%p, %f, %f, %f, %f, \"%T\", \"%T\", \"%T\", \"%s\", \"%s\")\n",
  640         (void *) p, llx, lly, urx, ury, filename, 0, description, 0,
  641         author, 0, mimetype, icon))
  642     {
  643         int len_descr = description ? (int) pdc_strlen(description) : 0;
  644         int len_auth = author ? (int) pdc_strlen(author) : 0;
  645 
  646         pdf_logg_is_deprecated(p, fn, 6);
  647 
  648         pdf__attach_file(p, llx, lly, urx, ury, filename, 0,
  649             description, len_descr, author, len_auth, mimetype, icon);
  650 
  651         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  652     }
  653 }
  654 
  655 PDFLIB_API void PDFLIB_CALL
  656 PDF_attach_file2(
  657     PDF *p,
  658     double llx,
  659     double lly,
  660     double urx,
  661     double ury,
  662     const char *filename, int len_filename,
  663     const char *description, int len_descr,
  664     const char *author, int len_auth,
  665     const char *mimetype,
  666     const char *icon)
  667 {
  668     static const char fn[] = "PDF_attach_file2";
  669 
  670     if (pdf_enter_api(p, fn, pdf_state_page,
  671         "(p_%p, %f, %f, %f, %f, \"%T\", /*c*/%d, \"%T\", /*c*/%d, "
  672         "\"%T\", /*c*/%d, \"%s\", \"%s\")\n",
  673         (void *) p, llx, lly, urx, ury,
  674         filename, len_filename, len_filename,
  675         description, len_descr, len_descr,
  676         author, len_auth, len_auth,
  677         mimetype, icon))
  678     {
  679         pdf_logg_is_deprecated(p, fn, 6);
  680 
  681         pdf__attach_file(p, llx, lly, urx, ury, filename, len_filename,
  682             description, len_descr, author, len_auth, mimetype, icon);
  683 
  684         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  685     }
  686 }
  687 
  688 PDFLIB_API void PDFLIB_CALL
  689 PDF_add_note(
  690     PDF *p,
  691     double llx,
  692     double lly,
  693     double urx,
  694     double ury,
  695     const char *contents,
  696     const char *title,
  697     const char *icon,
  698     int open)
  699 {
  700     static const char fn[] = "PDF_add_note";
  701 
  702     if (pdf_enter_api(p, fn, pdf_state_page,
  703         "(p_%p, %f, %f, %f, %f, \"%T\", \"%T\", \"%s\", %d)\n",
  704         (void *) p, llx, lly, urx, ury, contents, 0, title, 0,
  705         icon, open))
  706     {
  707         int len_cont = contents ? (int) pdc_strlen(contents) : 0;
  708         int len_title = title ? (int) pdc_strlen(title) : 0;
  709 
  710         pdf_logg_is_deprecated(p, fn, 6);
  711 
  712         pdf__add_note(p, llx, lly, urx, ury, contents, len_cont,
  713                       title, len_title, icon, open);
  714 
  715         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  716     }
  717 }
  718 
  719 PDFLIB_API void PDFLIB_CALL
  720 PDF_add_note2(
  721     PDF *p,
  722     double llx,
  723     double lly,
  724     double urx,
  725     double ury,
  726     const char *contents, int len_cont,
  727     const char *title, int len_title,
  728     const char *icon,
  729     int open)
  730 {
  731     static const char fn[] = "PDF_add_note2";
  732 
  733     if (pdf_enter_api(p, fn, pdf_state_page,
  734         "(p_%p, %f, %f, %f, %f, \"%T\", /*c*/%d, \"%T\", "
  735         "/*c*/%d, \"%s\", %d)\n",
  736         (void *) p, llx, lly, urx, ury, contents, len_cont, len_cont,
  737         title, len_title, len_title, icon, open))
  738     {
  739         pdf_logg_is_deprecated(p, fn, 6);
  740 
  741         pdf__add_note(p, llx, lly, urx, ury, contents, len_cont,
  742                       title, len_title, icon, open);
  743 
  744         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  745     }
  746 }
  747 
  748 PDFLIB_API void PDFLIB_CALL
  749 PDF_add_launchlink(
  750     PDF *p,
  751     double llx,
  752     double lly,
  753     double urx,
  754     double ury,
  755     const char *filename)
  756 {
  757     static const char fn[] = "PDF_add_launchlink";
  758 
  759     if (pdf_enter_api(p, fn, pdf_state_page,
  760         "(p_%p, %f, %f, %f, %f, \"%s\")\n",
  761         (void *)p, llx, lly, urx, ury, filename))
  762     {
  763         pdf_logg_is_deprecated(p, fn, 6);
  764 
  765         pdf__add_launchlink(p, llx, lly, urx, ury, filename);
  766 
  767         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  768     }
  769 }
  770 
  771 PDFLIB_API void PDFLIB_CALL
  772 PDF_add_locallink(
  773     PDF *p,
  774     double llx,
  775     double lly,
  776     double urx,
  777     double ury,
  778     int page,
  779     const char *optlist)
  780 {
  781     static const char fn[] = "PDF_add_locallink";
  782 
  783     if (pdf_enter_api(p, fn, pdf_state_page,
  784         "(p_%p, %f, %f, %f, %f, %d, \"%T\")\n",
  785         (void *) p, llx, lly, urx, ury, page, optlist, 0))
  786     {
  787         pdf_logg_is_deprecated(p, fn, 6);
  788 
  789         pdf__add_locallink(p, llx, lly, urx, ury, page, optlist);
  790 
  791         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  792     }
  793 }
  794 
  795 PDFLIB_API void PDFLIB_CALL
  796 PDF_add_pdflink(
  797     PDF *p,
  798     double llx,
  799     double lly,
  800     double urx,
  801     double ury,
  802     const char *filename,
  803     int page,
  804     const char *optlist)
  805 {
  806     static const char fn[] = "PDF_add_pdflink";
  807 
  808     if (pdf_enter_api(p, fn, pdf_state_page,
  809         "(p_%p, %f, %f, %f, %f, \"%s\", %d, \"%T\")\n",
  810         (void *) p, llx, lly, urx, ury, filename, page,
  811         optlist, 0))
  812     {
  813         pdf_logg_is_deprecated(p, fn, 6);
  814 
  815         pdf__add_pdflink(p, llx, lly, urx, ury, filename, page, optlist);
  816 
  817         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  818     }
  819 }
  820 
  821 PDFLIB_API void PDFLIB_CALL
  822 PDF_add_weblink(
  823     PDF *p,
  824     double llx,
  825     double lly,
  826     double urx,
  827     double ury,
  828     const char *url)
  829 {
  830     static const char fn[] = "PDF_add_weblink";
  831 
  832     if (pdf_enter_api(p, fn, pdf_state_page,
  833         "(p_%p, %f, %f, %f, %f, \"%s\")\n",
  834         (void *) p, llx, lly, urx, ury, url))
  835     {
  836         pdf_logg_is_deprecated(p, fn, 6);
  837 
  838         pdf__add_weblink(p, llx, lly, urx, ury, url);
  839 
  840         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  841     }
  842 }
  843 
  844 PDFLIB_API void PDFLIB_CALL
  845 PDF_create_annotation(
  846     PDF *p,
  847     double llx,
  848     double lly,
  849     double urx,
  850     double ury,
  851     const char *type,
  852     const char *optlist)
  853 {
  854     static const char fn[] = "PDF_create_annotation";
  855 
  856     if (pdf_enter_api(p, fn, pdf_state_page,
  857         "(p_%p, %f, %f, %f, %f, \"%s\", \"%T\")\n",
  858         (void *) p, llx, lly, urx, ury, type, optlist, 0))
  859     {
  860         pdf__create_annotation(p, llx, lly, urx, ury, type, optlist);
  861 
  862         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  863     }
  864 }
  865 
  866 PDFLIB_API void PDFLIB_CALL
  867 PDF_set_border_color(
  868     PDF *p,
  869     double red,
  870     double green,
  871     double blue)
  872 {
  873     static const char fn[] = "PDF_set_border_color";
  874 
  875     if (pdf_enter_api(p, fn,
  876         (pdf_state) (pdf_state_document | pdf_state_page),
  877         "(p_%p, %f, %f, %f)\n", (void *) p, red, green, blue))
  878     {
  879         pdf_logg_is_deprecated(p, fn, 6);
  880 
  881         pdf__set_border_color(p, red, green, blue);
  882 
  883         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  884     }
  885 }
  886 
  887 PDFLIB_API void PDFLIB_CALL
  888 PDF_set_border_dash(
  889     PDF *p,
  890     double b,
  891     double w)
  892 {
  893     static const char fn[] = "PDF_set_border_dash";
  894 
  895     if (pdf_enter_api(p, fn,
  896         (pdf_state) (pdf_state_document | pdf_state_page),
  897         "(p_%p, %f, %f)\n", (void *) p, b, w))
  898     {
  899         pdf_logg_is_deprecated(p, fn, 6);
  900 
  901         pdf__set_border_dash(p, b, w);
  902 
  903         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  904     }
  905 }
  906 
  907 PDFLIB_API void PDFLIB_CALL
  908 PDF_set_border_style(
  909     PDF *p,
  910     const char *style,
  911     double width)
  912 {
  913     static const char fn[] = "PDF_set_border_style";
  914 
  915     if (pdf_enter_api(p, fn,
  916         (pdf_state) (pdf_state_document | pdf_state_page),
  917         "(p_%p, \"%s\", %f)\n", (void *) p, style, width))
  918     {
  919         pdf_logg_is_deprecated(p, fn, 6);
  920 
  921         pdf__set_border_style(p, style, width);
  922 
  923         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
  924     }
  925 }
  926 
  927 
  928 /**********************
  929  *
  930  *  p_block.c
  931  *
  932  **********************/
  933 
  934 PDFLIB_API int PDFLIB_CALL
  935 PDF_fill_imageblock(
  936     PDF *p,
  937     int page,
  938     const char *blockname,
  939     int image,
  940     const char *optlist)
  941 {
  942     static const char fn[] = "PDF_fill_imageblock";
  943     int retval = -1;
  944 
  945     if (pdf_enter_api(p, fn,
  946         (pdf_state) pdf_state_content,
  947         "(p_%p, %d, \"%T\", %d, \"%T\")\n",
  948         (void *) p, page, blockname, 0, image, optlist, 0))
  949     {
  950         pdc_set_unsupp_error(p->pdc,
  951                 PDF_E_UNSUPP_BLOCK_CONFIG, PDF_E_UNSUPP_BLOCK, pdc_false);
  952     }
  953 
  954     return pdf_exit_boolean_api(p, retval);
  955 }
  956 
  957 PDFLIB_API int PDFLIB_CALL
  958 PDF_fill_pdfblock(
  959     PDF *p,
  960     int page,
  961     const char *blockname,
  962     int contents,
  963     const char *optlist)
  964 {
  965     static const char fn[] = "PDF_fill_pdfblock";
  966     int retval = -1;
  967 
  968     if (pdf_enter_api(p, fn,
  969         (pdf_state) pdf_state_content,
  970         "(p_%p, %d, \"%T\", %d, \"%T\")\n",
  971         (void *) p, page, blockname, 0, contents, optlist, 0))
  972     {
  973         pdc_set_unsupp_error(p->pdc,
  974                 PDF_E_UNSUPP_BLOCK_CONFIG, PDF_E_UNSUPP_BLOCK, pdc_false);
  975     }
  976 
  977     return pdf_exit_boolean_api(p, retval);
  978 }
  979 
  980 PDFLIB_API int PDFLIB_CALL
  981 PDF_fill_textblock(
  982     PDF *p,
  983     int page,
  984     const char *blockname,
  985     const char *text, int len,
  986     const char *optlist)
  987 {
  988     static const char fn[] = "PDF_fill_textblock";
  989     int retval = -1;
  990 
  991     if (pdf_enter_api(p, fn,
  992         (pdf_state) pdf_state_content,
  993         "(p_%p, %d, \"%T\", \"%T\", /*c*/%d, \"%T\")\n",
  994         (void *) p, page, blockname, 0, text, len, len, optlist, 0))
  995     {
  996         pdc_set_unsupp_error(p->pdc,
  997                 PDF_E_UNSUPP_BLOCK_CONFIG, PDF_E_UNSUPP_BLOCK, pdc_false);
  998     }
  999 
 1000     return pdf_exit_boolean_api(p, retval);
 1001 }
 1002 
 1003 
 1004 /**********************
 1005  *
 1006  *  p_color.c
 1007  *
 1008  **********************/
 1009 
 1010 PDFLIB_API int PDFLIB_CALL
 1011 PDF_makespotcolor(PDF *p, const char *spotname, int len)
 1012 {
 1013     static const char fn[] = "PDF_makespotcolor";
 1014     int retval = -1;
 1015 
 1016     if (pdf_enter_api(p, fn,
 1017         (pdf_state) (pdf_state_content | pdf_state_document),
 1018         "(p_%p, \"%T\", /*c*/%d)\n",
 1019         (void *) p, spotname, len, len))
 1020     {
 1021         pdc_error(p->pdc, PDF_E_UNSUPP_SPOTCOLOR, 0, 0, 0, 0);
 1022     }
 1023 
 1024     return pdf_exit_handle_api(p, retval);
 1025 }
 1026 
 1027 PDFLIB_API void PDFLIB_CALL
 1028 PDF_setcolor(
 1029     PDF *p,
 1030     const char *fstype,
 1031     const char *colorspace,
 1032     double c1, double c2, double c3, double c4)
 1033 {
 1034     static const char fn[] = "PDF_setcolor";
 1035     int legal_states;
 1036 
 1037     if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p))
 1038         legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template;
 1039     else
 1040         legal_states = pdf_state_content | pdf_state_document;
 1041 
 1042     if (pdf_enter_api(p, fn, (pdf_state) legal_states,
 1043         "(p_%p, \"%s\", \"%s\", %f, %f, %f, %f)\n",
 1044         (void *) p, fstype, colorspace, c1, c2, c3, c4))
 1045     {
 1046         pdf__setcolor(p, fstype, colorspace, c1, c2, c3, c4);
 1047 
 1048         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1049     }
 1050 }
 1051 
 1052 PDFLIB_API void PDFLIB_CALL
 1053 PDF_setgray(PDF *p, double g)
 1054 {
 1055     static const char fn[] = "PDF_setgray";
 1056 
 1057     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1058         (void *) p, g))
 1059     {
 1060         pdf_logg_is_deprecated(p, fn, 5);
 1061 
 1062         pdf__setcolor(p, "fillstroke", "gray", g, 0, 0, 0);
 1063 
 1064         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1065     }
 1066 }
 1067 
 1068 PDFLIB_API void PDFLIB_CALL
 1069 PDF_setgray_fill(PDF *p, double gray)
 1070 {
 1071     static const char fn[] = "PDF_setgray_fill";
 1072 
 1073     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1074         (void *) p, gray))
 1075     {
 1076         pdf_logg_is_deprecated(p, fn, 5);
 1077 
 1078         pdf__setcolor(p, "fill", "gray", gray, 0, 0, 0);
 1079 
 1080         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1081     }
 1082 }
 1083 
 1084 PDFLIB_API void PDFLIB_CALL
 1085 PDF_setgray_stroke(PDF *p, double gray)
 1086 {
 1087     static const char fn[] = "PDF_setgray_stroke";
 1088 
 1089     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1090         (void *) p, gray))
 1091     {
 1092         pdf_logg_is_deprecated(p, fn, 5);
 1093 
 1094         pdf__setcolor(p, "stroke", "gray", gray, 0, 0, 0);
 1095 
 1096         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1097     }
 1098 }
 1099 
 1100 PDFLIB_API void PDFLIB_CALL
 1101 PDF_setrgbcolor(PDF *p, double r, double g, double b)
 1102 {
 1103     static const char fn[] = "PDF_setrgbcolor";
 1104 
 1105     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n",
 1106         (void *) p, r, g, b))
 1107     {
 1108         pdf_logg_is_deprecated(p, fn, 5);
 1109 
 1110         pdf__setcolor(p, "fillstroke", "rgb", r, g, b, 0);
 1111 
 1112         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1113     }
 1114 }
 1115 
 1116 PDFLIB_API void PDFLIB_CALL
 1117 PDF_setrgbcolor_fill(PDF *p, double r, double g, double b)
 1118 {
 1119     static const char fn[] = "PDF_setrgbcolor_fill";
 1120 
 1121     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n",
 1122         (void *) p, r, g, b))
 1123     {
 1124         pdf_logg_is_deprecated(p, fn, 5);
 1125 
 1126         pdf__setcolor(p, "fill", "rgb", r, g, b, 0);
 1127 
 1128         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1129     }
 1130 }
 1131 
 1132 PDFLIB_API void PDFLIB_CALL
 1133 PDF_setrgbcolor_stroke(PDF *p, double r, double g, double b)
 1134 {
 1135     static const char fn[] = "PDF_setrgbcolor_stroke";
 1136 
 1137     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n",
 1138         (void *) p, r, g, b))
 1139     {
 1140         pdf_logg_is_deprecated(p, fn, 5);
 1141 
 1142         pdf__setcolor(p, "stroke", "rgb", r, g, b, 0);
 1143 
 1144         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1145     }
 1146 }
 1147 
 1148 
 1149 /**********************
 1150  *
 1151  *  p_document.c
 1152  *
 1153  **********************/
 1154 
 1155 PDFLIB_API int PDFLIB_CALL
 1156 PDF_begin_document(
 1157     PDF *p,
 1158     const char *filename, int len,
 1159     const char *optlist)
 1160 {
 1161     static const char fn[] = "\nPDF_begin_document";
 1162     int retval = -1;
 1163 
 1164     if (pdf_enter_api(p, fn, pdf_state_object,
 1165         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 1166         (void *) p, filename, len, len, optlist, 0))
 1167     {
 1168         if (filename && *filename && len < 0)
 1169             pdc_error(p->pdc, PDC_E_ILLARG_INT,
 1170                 "len", pdc_errprintf(p->pdc, "%d", len), 0, 0);
 1171         retval = pdf__begin_document(p, filename, len, optlist);
 1172     }
 1173 
 1174     return pdf_exit_boolean_api(p, retval);
 1175 }
 1176 
 1177 PDFLIB_API void PDFLIB_CALL
 1178 PDF_begin_document_callback(
 1179     PDF *p,
 1180     size_t (*i_writeproc)(PDF *p, void *data, size_t size),
 1181     const char *optlist)
 1182 {
 1183     static const char fn[] = "\nPDF_begin_document_callback";
 1184     size_t (*writeproc)(PDF *, void *, size_t) = i_writeproc;
 1185 
 1186     if (pdf_enter_api(p, fn, pdf_state_object,
 1187         "(p_%p, wp_%p), \"%T\"", (void *) p, (void *) writeproc, optlist, 0))
 1188     {
 1189         pdf__begin_document_callback(p, writeproc, optlist);
 1190 
 1191         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1192     }
 1193 }
 1194 
 1195 PDFLIB_API void PDFLIB_CALL
 1196 PDF_close(PDF *p)
 1197 {
 1198     static const char fn[] = "\nPDF_close";
 1199 
 1200     if (pdf_enter_api(p, fn, pdf_state_document,
 1201         "(p_%p)\n", (void *) p))
 1202     {
 1203         pdf_logg_is_deprecated(p, fn, 6);
 1204 
 1205         pdf__end_document(p, "");
 1206 
 1207         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1208     }
 1209 }
 1210 
 1211 PDFLIB_API void PDFLIB_CALL
 1212 PDF_end_document(PDF *p, const char *optlist)
 1213 {
 1214     static const char fn[] = "\nPDF_end_document";
 1215 
 1216     if (pdf_enter_api(p, fn, pdf_state_document,
 1217         "(p_%p, \"%T\")\n", (void *) p, optlist, 0))
 1218     {
 1219         pdf__end_document(p, optlist);
 1220 
 1221         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1222     }
 1223 }
 1224 
 1225 PDFLIB_API const char * PDFLIB_CALL
 1226 PDF_get_buffer(PDF *p, long *size)
 1227 {
 1228     static const char fn[] = "PDF_get_buffer";
 1229     const char *retval = NULL;
 1230 
 1231     if (!size)
 1232         pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "size", 0, 0, 0);
 1233 
 1234     *size = (long) 0;
 1235 
 1236     if (pdf_enter_api(p, fn,
 1237         (pdf_state) (pdf_state_object | pdf_state_document),
 1238         "(p_%p, &size_%p)\n", (void *) p, (void *) size))
 1239     {
 1240         retval = pdf__get_buffer(p, size);
 1241 
 1242         pdc_logg_exit_api(p->pdc, pdc_false, "[%p, size=%ld]\n",
 1243                            (void *) (retval), *size);
 1244     }
 1245 
 1246     return retval;
 1247 }
 1248 
 1249 PDFLIB_API int PDFLIB_CALL
 1250 PDF_open_file(PDF *p, const char *filename)
 1251 {
 1252     static const char fn[] = "\nPDF_open_file";
 1253     int retval = -1;
 1254 
 1255     if (pdf_enter_api(p, fn, pdf_state_object, "(p_%p, \"%s\")\n",
 1256         (void *) p, filename))
 1257     {
 1258         pdf_logg_is_deprecated(p, fn, 6);
 1259 
 1260         retval = pdf__begin_document(p, filename, 0, "");
 1261     }
 1262 
 1263     return pdf_exit_boolean_api(p, retval);
 1264 }
 1265 
 1266 PDFLIB_API void PDFLIB_CALL
 1267 PDF_open_mem(
 1268     PDF *p,
 1269     size_t (*i_writeproc)(PDF *p, void *data, size_t size))
 1270 {
 1271     static const char fn[] = "\nPDF_open_mem";
 1272     size_t (*writeproc)(PDF *, void *, size_t) = i_writeproc;
 1273 
 1274     if (pdf_enter_api(p, fn, pdf_state_object,
 1275         "(p_%p, wp_%p)\n", (void *) p, (void *) writeproc))
 1276     {
 1277         pdf_logg_is_deprecated(p, fn, 6);
 1278 
 1279         pdf__begin_document_callback(p, writeproc, "");
 1280 
 1281         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1282     }
 1283 }
 1284 
 1285 
 1286 /**********************
 1287  *
 1288  *  p_draw.c
 1289  *
 1290  **********************/
 1291 
 1292 PDFLIB_API void PDFLIB_CALL
 1293 PDF_arc(PDF *p, double x, double y, double r, double alpha, double beta)
 1294 {
 1295     static const char fn[] = "PDF_arc";
 1296 
 1297     if (pdf_enter_api(p, fn,
 1298         (pdf_state) (pdf_state_content | pdf_state_path),
 1299         "(p_%p, %f, %f, %f, %f, %f)\n", (void *) p, x, y, r, alpha, beta))
 1300     {
 1301         pdf__arc(p, x, y, r, alpha, beta);
 1302 
 1303         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1304     }
 1305 }
 1306 
 1307 PDFLIB_API void PDFLIB_CALL
 1308 PDF_arcn(PDF *p, double x, double y, double r, double alpha, double beta)
 1309 {
 1310     static const char fn[] = "PDF_arcn";
 1311 
 1312     if (pdf_enter_api(p, fn,
 1313         (pdf_state) (pdf_state_content | pdf_state_path),
 1314         "(p_%p, %f, %f, %f, %f, %f)\n", (void *) p, x, y, r, alpha, beta))
 1315     {
 1316         pdf__arcn(p, x, y, r, alpha, beta);
 1317 
 1318         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1319     }
 1320 }
 1321 
 1322 PDFLIB_API void PDFLIB_CALL
 1323 PDF_circle(PDF *p, double x, double y, double r)
 1324 {
 1325     static const char fn[] = "PDF_circle";
 1326 
 1327     if (pdf_enter_api(p, fn,
 1328         (pdf_state) (pdf_state_content | pdf_state_path),
 1329         "(p_%p, %f, %f, %f)\n", (void *) p, x, y, r))
 1330     {
 1331         pdf__circle(p, x, y, r);
 1332 
 1333         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1334     }
 1335 }
 1336 
 1337 PDFLIB_API void PDFLIB_CALL
 1338 PDF_clip(PDF *p)
 1339 {
 1340     static const char fn[] = "PDF_clip";
 1341 
 1342     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1343     {
 1344         pdf__clip(p);
 1345 
 1346         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1347     }
 1348 }
 1349 
 1350 PDFLIB_API void PDFLIB_CALL
 1351 PDF_closepath(PDF *p)
 1352 {
 1353     static const char fn[] = "PDF_closepath";
 1354 
 1355     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1356     {
 1357         pdf__closepath(p);
 1358 
 1359         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1360     }
 1361 }
 1362 
 1363 PDFLIB_API void PDFLIB_CALL
 1364 PDF_closepath_fill_stroke(PDF *p)
 1365 {
 1366     static const char fn[] = "PDF_closepath_fill_stroke";
 1367 
 1368     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1369     {
 1370         pdf__closepath_fill_stroke(p);
 1371 
 1372         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1373     }
 1374 }
 1375 
 1376 PDFLIB_API void PDFLIB_CALL
 1377 PDF_closepath_stroke(PDF *p)
 1378 {
 1379     static const char fn[] = "PDF_closepath_stroke";
 1380 
 1381     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1382     {
 1383         pdf__closepath_stroke(p);
 1384     }
 1385 
 1386         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1387 }
 1388 
 1389 PDFLIB_API void PDFLIB_CALL
 1390 PDF_curveto(PDF *p,
 1391     double x_1, double y_1, double x_2, double y_2, double x_3, double y_3)
 1392 {
 1393     static const char fn[] = "PDF_curveto";
 1394 
 1395     if (pdf_enter_api(p, fn, pdf_state_path,
 1396         "(p_%p, %f, %f, %f, %f, %f, %f)\n",
 1397         (void *) p, x_1, y_1, x_2, y_2, x_3, y_3))
 1398     {
 1399         pdf__curveto(p, x_1, y_1, x_2, y_2, x_3, y_3);
 1400 
 1401         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1402     }
 1403 }
 1404 
 1405 PDFLIB_API void PDFLIB_CALL
 1406 PDF_endpath(PDF *p)
 1407 {
 1408     static const char fn[] = "PDF_endpath";
 1409 
 1410     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1411     {
 1412         pdf__endpath(p);
 1413 
 1414         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1415     }
 1416 }
 1417 
 1418 PDFLIB_API void PDFLIB_CALL
 1419 PDF_fill(PDF *p)
 1420 {
 1421     static const char fn[] = "PDF_fill";
 1422 
 1423     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1424     {
 1425         pdf__fill(p);
 1426 
 1427         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1428     }
 1429 }
 1430 
 1431 PDFLIB_API void PDFLIB_CALL
 1432 PDF_fill_stroke(PDF *p)
 1433 {
 1434     static const char fn[] = "PDF_fill_stroke";
 1435 
 1436     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1437     {
 1438         pdf__fill_stroke(p);
 1439 
 1440         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1441     }
 1442 }
 1443 
 1444 PDFLIB_API void PDFLIB_CALL
 1445 PDF_lineto(PDF *p, double x, double y)
 1446 {
 1447     static const char fn[] = "PDF_lineto";
 1448 
 1449     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p, %f, %f)\n",
 1450         (void *) p, x, y))
 1451     {
 1452         pdf__lineto(p, x, y);
 1453 
 1454         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1455     }
 1456 }
 1457 
 1458 PDFLIB_API void PDFLIB_CALL
 1459 PDF_moveto(PDF *p, double x, double y)
 1460 {
 1461     static const char fn[] = "PDF_moveto";
 1462 
 1463     if (pdf_enter_api(p, fn,
 1464         (pdf_state) (pdf_state_content | pdf_state_path),
 1465         "(p_%p, %f, %f)\n", (void *) p, x, y))
 1466     {
 1467         pdf__moveto(p, x, y);
 1468 
 1469         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1470     }
 1471 }
 1472 
 1473 PDFLIB_API void PDFLIB_CALL
 1474 PDF_rcurveto(PDF *p,
 1475     double x_1, double y_1, double x_2, double y_2, double x_3, double y_3)
 1476 {
 1477     static const char fn[] = "PDF_rcurveto";
 1478 
 1479     if (pdf_enter_api(p, fn, pdf_state_path,
 1480         "(p_%p, %f, %f, %f, %f, %f, %f)\n",
 1481         (void *) p, x_1, y_1, x_2, y_2, x_3, y_3))
 1482     {
 1483         pdf_logg_is_unsupported(p, fn);
 1484 
 1485         pdf__rcurveto(p, x_1, y_1, x_2, y_2, x_3, y_3);
 1486 
 1487         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1488     }
 1489 }
 1490 
 1491 PDFLIB_API void PDFLIB_CALL
 1492 PDF_rect(PDF *p, double x, double y, double width, double height)
 1493 {
 1494     static const char fn[] = "PDF_rect";
 1495 
 1496     if (pdf_enter_api(p, fn,
 1497         (pdf_state) (pdf_state_content | pdf_state_path),
 1498         "(p_%p, %f, %f, %f, %f)\n", (void *) p, x, y, width, height))
 1499     {
 1500         pdf__rect(p, x, y, width, height);
 1501 
 1502         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1503     }
 1504 }
 1505 
 1506 PDFLIB_API void PDFLIB_CALL
 1507 PDF_rlineto(PDF *p, double x, double y)
 1508 {
 1509     static const char fn[] = "PDF_rlineto";
 1510 
 1511     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p, %f, %f)\n",
 1512         (void *) p, x, y))
 1513     {
 1514         pdf_logg_is_unsupported(p, fn);
 1515 
 1516         pdf__rlineto(p, x, y);
 1517 
 1518         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1519     }
 1520 }
 1521 
 1522 PDFLIB_API void PDFLIB_CALL
 1523 PDF_rmoveto(PDF *p, double x, double y)
 1524 {
 1525     static const char fn[] = "PDF_rmoveto";
 1526 
 1527     if (pdf_enter_api(p, fn,
 1528         (pdf_state) (pdf_state_content | pdf_state_path),
 1529         "(p_%p, %f, %f)\n", (void *) p, x, y))
 1530     {
 1531         pdf_logg_is_unsupported(p, fn);
 1532 
 1533         pdf__rmoveto(p, x, y);
 1534 
 1535         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1536     }
 1537 }
 1538 
 1539 PDFLIB_API void PDFLIB_CALL
 1540 PDF_stroke(PDF *p)
 1541 {
 1542     static const char fn[] = "PDF_stroke";
 1543 
 1544     if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p)\n", (void *) p))
 1545     {
 1546         pdf__stroke(p);
 1547 
 1548         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1549     }
 1550 }
 1551 
 1552 
 1553 /**********************
 1554  *
 1555  *  p_encoding.c
 1556  *
 1557  **********************/
 1558 
 1559 PDFLIB_API void PDFLIB_CALL
 1560 PDF_encoding_set_char(
 1561     PDF *p,
 1562     const char *encoding,
 1563     int slot,
 1564     const char *glyphname,
 1565     int uv)
 1566 {
 1567     static const char fn[] = "PDF_encoding_set_char";
 1568 
 1569     if (pdf_enter_api(p, fn, pdf_state_all,
 1570         "(p_%p, \"%s\", %d, \"%s\", %d/*0x%04X*/)\n",
 1571         (void *) p, encoding, slot, glyphname, uv, uv))
 1572     {
 1573         pdf__encoding_set_char(p, encoding, slot, glyphname, uv);
 1574 
 1575         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1576     }
 1577 }
 1578 
 1579 
 1580 /**********************
 1581  *
 1582  *  p_fields.c
 1583  *
 1584  **********************/
 1585 
 1586 PDFLIB_API void PDFLIB_CALL
 1587 PDF_create_field(
 1588     PDF *p,
 1589     double llx, double lly, double urx, double ury,
 1590     const char *name, int len,
 1591     const char *type,
 1592     const char *optlist)
 1593 {
 1594     static const char fn[] = "PDF_create_field";
 1595 
 1596     if (pdf_enter_api(p, fn, pdf_state_page,
 1597         "(p_%p, %f, %f, %f, %f, \"%T\", /*c*/%d, \"%s\", \"%T\")\n",
 1598         (void *) p, llx, lly, urx, ury, name, len, len,
 1599         type, optlist, 0))
 1600     {
 1601         pdc_error(p->pdc, PDF_E_UNSUPP_FORMFIELDS, 0, 0, 0, 0);
 1602 
 1603         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1604     }
 1605 }
 1606 
 1607 
 1608 PDFLIB_API void PDFLIB_CALL
 1609 PDF_create_fieldgroup(
 1610     PDF *p,
 1611     const char *name, int len,
 1612     const char *optlist)
 1613 {
 1614     static const char fn[] = "PDF_create_fieldgroup";
 1615 
 1616     if (pdf_enter_api(p, fn, pdf_state_documentall,
 1617         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 1618         (void *) p, name, len, len, optlist, 0))
 1619     {
 1620         pdc_error(p->pdc, PDF_E_UNSUPP_FORMFIELDS, 0, 0, 0, 0);
 1621 
 1622         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1623     }
 1624 }
 1625 
 1626 
 1627 /**********************
 1628  *
 1629  *  p_font.c
 1630  *
 1631  **********************/
 1632 
 1633 PDFLIB_API int PDFLIB_CALL
 1634 PDF_findfont(
 1635     PDF *p,
 1636     const char *fontname,
 1637     const char *encoding,
 1638     int embed)
 1639 {
 1640     static const char fn[] = "PDF_findfont";
 1641     int retval = -1;
 1642 
 1643     if (pdf_enter_api(p, fn,
 1644         (pdf_state) (pdf_state_document | pdf_state_content |
 1645                      pdf_state_path | pdf_state_font),
 1646         "(p_%p, \"%s\", \"%s\", %d)\n",
 1647         (void *) p, fontname, encoding, embed))
 1648     {
 1649         pdf_logg_is_deprecated(p, fn, 6);
 1650 
 1651         if (embed < 0 || embed > 1)
 1652             pdc_error(p->pdc, PDC_E_ILLARG_INT,
 1653                 "embed", pdc_errprintf(p->pdc, "%d", embed), 0, 0);
 1654 
 1655         retval = pdf__load_font(p, fontname, 0, encoding,
 1656                                 (embed > 0) ? "embedding" : "");
 1657     }
 1658 
 1659     return pdf_exit_handle_api(p, retval);
 1660 }
 1661 
 1662 PDFLIB_API double PDFLIB_CALL
 1663 PDF_info_font(PDF *p, int font, const char *keyword, const char *optlist)
 1664 {
 1665     static const char fn[] = "PDF_info_font";
 1666     double retval = 0;
 1667 
 1668     if (pdf_enter_api(p, fn, pdf_state_documentall,
 1669         "(p_%p, %d, \"%s\", \"%s\")\n",
 1670         (void *) p, font, keyword, optlist))
 1671     {
 1672         pdc_error(p->pdc, PDF_E_UNSUPP_FONTINFO, 0, 0, 0, 0);
 1673 
 1674         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 1675     }
 1676 
 1677     return retval;
 1678 }
 1679 
 1680 PDFLIB_API int PDFLIB_CALL
 1681 PDF_load_font(
 1682     PDF *p,
 1683     const char *fontname, int len,
 1684     const char *encoding,
 1685     const char *optlist)
 1686 {
 1687     static const char fn[] = "PDF_load_font";
 1688     int retval = -1;
 1689 
 1690     if (pdf_enter_api(p, fn,
 1691         (pdf_state) (pdf_state_document | pdf_state_content |
 1692                      pdf_state_path | pdf_state_font),
 1693         "(p_%p, \"%T\", /*c*/%d, \"%s\", \"%T\")\n",
 1694         (void *) p, fontname, len, len, encoding, optlist, 0))
 1695     {
 1696         retval = pdf__load_font(p, fontname, len, encoding, optlist);
 1697     }
 1698 
 1699     return pdf_exit_handle_api(p, retval);
 1700 }
 1701 
 1702 
 1703 /**********************
 1704  *
 1705  *  p_gstate.c
 1706  *
 1707  **********************/
 1708 
 1709 PDFLIB_API void PDFLIB_CALL
 1710 PDF_concat(PDF *p, double a, double b, double c, double d, double e, double f)
 1711 {
 1712     static const char fn[] = "PDF_concat";
 1713 
 1714     if (pdf_enter_api(p, fn, pdf_state_content,
 1715         "(p_%p, %f, %f, %f, %f, %f, %f)\n", (void *) p, a, b, c, d, e, f))
 1716     {
 1717         pdf__concat(p, a, b, c, d, e, f);
 1718 
 1719         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1720     }
 1721 }
 1722 
 1723 PDFLIB_API void PDFLIB_CALL
 1724 PDF_initgraphics(PDF *p)
 1725 {
 1726     static const char fn[] = "PDF_initgraphics";
 1727 
 1728     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p)\n", (void *) p))
 1729     {
 1730         pdf__initgraphics(p);
 1731 
 1732         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1733     }
 1734 }
 1735 
 1736 PDFLIB_API void PDFLIB_CALL
 1737 PDF_restore(PDF *p)
 1738 {
 1739     static const char fn[] = "PDF_restore";
 1740 
 1741     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p)\n", (void *) p))
 1742     {
 1743         pdf__restore(p);
 1744 
 1745         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1746     }
 1747 }
 1748 
 1749 PDFLIB_API void PDFLIB_CALL
 1750 PDF_rotate(PDF *p, double phi)
 1751 {
 1752     static const char fn[] = "PDF_rotate";
 1753 
 1754     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1755         (void *) p, phi))
 1756     {
 1757         pdf__rotate(p, phi);
 1758 
 1759         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1760     }
 1761 }
 1762 
 1763 PDFLIB_API void PDFLIB_CALL
 1764 PDF_save(PDF *p)
 1765 {
 1766     static const char fn[] = "PDF_save";
 1767 
 1768     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p)\n", (void *) p))
 1769     {
 1770         pdf__save(p);
 1771 
 1772         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1773     }
 1774 }
 1775 
 1776 PDFLIB_API void PDFLIB_CALL
 1777 PDF_scale(PDF *p, double sx, double sy)
 1778 {
 1779     static const char fn[] = "PDF_scale";
 1780 
 1781     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f)\n",
 1782         (void *) p, sx, sy))
 1783     {
 1784         pdf__scale(p, sx, sy);
 1785 
 1786         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1787     }
 1788 }
 1789 
 1790 PDFLIB_API void PDFLIB_CALL
 1791 PDF_setdash(PDF *p, double b, double w)
 1792 {
 1793     static const char fn[] = "PDF_setdash";
 1794 
 1795     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f)\n",
 1796         (void *) p, b, w))
 1797     {
 1798         pdf__setdash(p, b, w);
 1799 
 1800         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1801     }
 1802 }
 1803 
 1804 PDFLIB_API void PDFLIB_CALL
 1805 PDF_setdashpattern(PDF *p, const char *optlist)
 1806 {
 1807     static const char fn[] = "PDF_setdashpattern";
 1808 
 1809     if (pdf_enter_api(p, fn, pdf_state_content,
 1810         "(p_%p, \"%T\")\n", (void *) p, optlist, 0))
 1811     {
 1812         pdf__setdashpattern(p, optlist);
 1813 
 1814         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1815     }
 1816 }
 1817 
 1818 PDFLIB_API void PDFLIB_CALL
 1819 PDF_setflat(PDF *p, double flat)
 1820 {
 1821     static const char fn[] = "PDF_setflat";
 1822 
 1823     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1824         (void *) p, flat))
 1825     {
 1826         pdf__setflat(p, flat);
 1827 
 1828         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1829     }
 1830 }
 1831 
 1832 PDFLIB_API void PDFLIB_CALL
 1833 PDF_setlinecap(PDF *p, int cap)
 1834 {
 1835     static const char fn[] = "PDF_setlinecap";
 1836 
 1837     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %d)\n",
 1838         (void *) p, cap))
 1839     {
 1840         pdf__setlinecap(p, cap);
 1841 
 1842         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1843     }
 1844 }
 1845 
 1846 PDFLIB_API void PDFLIB_CALL
 1847 PDF_setlinejoin(PDF *p, int join)
 1848 {
 1849     static const char fn[] = "PDF_setlinejoin";
 1850 
 1851     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %d)\n",
 1852         (void *) p, join))
 1853     {
 1854         pdf__setlinejoin(p, join);
 1855 
 1856         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1857     }
 1858 }
 1859 
 1860 PDFLIB_API void PDFLIB_CALL
 1861 PDF_setlinewidth(PDF *p, double width)
 1862 {
 1863     static const char fn[] = "PDF_setlinewidth";
 1864 
 1865     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1866         (void *) p, width))
 1867     {
 1868         pdf__setlinewidth(p, width);
 1869 
 1870         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1871     }
 1872 }
 1873 
 1874 PDFLIB_API void PDFLIB_CALL
 1875 PDF_setmatrix(PDF *p, double a, double b, double c, double d,
 1876               double e, double f)
 1877 {
 1878     static const char fn[] = "PDF_setmatrix";
 1879 
 1880     if (pdf_enter_api(p, fn, pdf_state_content,
 1881         "(p_%p, %f, %f, %f, %f, %f, %f)\n", (void *) p, a, b, c, d, e, f))
 1882     {
 1883         pdf__setmatrix(p, a, b, c, d, e, f);
 1884 
 1885         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1886     }
 1887 }
 1888 
 1889 PDFLIB_API void PDFLIB_CALL
 1890 PDF_setmiterlimit(PDF *p, double miter)
 1891 {
 1892     static const char fn[] = "PDF_setmiterlimit";
 1893 
 1894     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n",
 1895         (void *) p, miter))
 1896     {
 1897         pdf__setmiterlimit(p, miter);
 1898 
 1899         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1900     }
 1901 }
 1902 
 1903 PDFLIB_API void PDFLIB_CALL
 1904 PDF_setpolydash(PDF *p, float *darray, int length)
 1905 {
 1906     static const char fn[] = "PDF_setpolydash";
 1907     int i;
 1908 
 1909     if (!darray)
 1910         pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "darray", 0, 0, 0);
 1911 
 1912     for (i = 0; i < length; i++)
 1913         pdc_logg_cond(p->pdc, 1, trc_api,
 1914                            "/* *(darray+%d) = %f; */\n", i, darray[i]);
 1915 
 1916     if (pdf_enter_api(p, fn, pdf_state_content,
 1917         "(p_%p, darray_%p, /*c*/%d)\n", (void *) p, (void *) darray, length))
 1918     {
 1919         char optlist[PDC_GEN_BUFSIZE], *sopt;
 1920 
 1921         if (length > PDF_MAX_DASHLENGTH)
 1922             pdc_error(p->pdc, PDC_E_ILLARG_TOOMANY, "darray",
 1923                       pdc_errprintf(p->pdc, "%d", PDF_MAX_DASHLENGTH), 0, 0);
 1924 
 1925         sopt = optlist;
 1926         sopt += pdc_sprintf(p->pdc, pdc_false, optlist, "dasharray {");
 1927         for (i = 0; i < length; i++)
 1928         {
 1929             pdc_check_number_limits(p->pdc, "darray", darray[i],
 1930                                     0.0, PDC_FLOAT_MAX);
 1931             sopt += pdc_sprintf(p->pdc, pdc_false, sopt, "%f ", darray[i]);
 1932         }
 1933         pdc_sprintf(p->pdc, pdc_false, sopt, "}");
 1934 
 1935         pdf__setdashpattern(p, optlist);
 1936 
 1937         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 1938     }
 1939 }
 1940 
 1941 PDFLIB_API void PDFLIB_CALL
 1942 PDF_skew(PDF *p, double alpha, double beta)
 1943 {
 1944     static const char fn[] = "PDF_skew";
 1945 
 1946     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f)\n",
 1947         (void *) p, alpha, beta))
 1948     {
 1949         pdf__skew(p, alpha, beta);
 1950 
 1951         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1952     }
 1953 }
 1954 
 1955 PDFLIB_API void PDFLIB_CALL
 1956 PDF_translate(PDF *p, double tx, double ty)
 1957 {
 1958     static const char fn[] = "PDF_translate";
 1959 
 1960     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f)\n",
 1961         (void *) p, tx, ty))
 1962     {
 1963         pdf__translate(p, tx, ty);
 1964 
 1965         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 1966     }
 1967 }
 1968 
 1969 
 1970 /**********************
 1971  *
 1972  *  p_hyper.c
 1973  *
 1974  **********************/
 1975 
 1976 PDFLIB_API int PDFLIB_CALL
 1977 PDF_add_bookmark(
 1978     PDF *p,
 1979     const char *text,
 1980     int parent,
 1981     int open)
 1982 {
 1983     static const char fn[] = "PDF_add_bookmark";
 1984     int retval = -1;
 1985 
 1986     if (pdf_enter_api(p, fn,
 1987         (pdf_state) (pdf_state_page | pdf_state_document),
 1988         "(p_%p, \"%T\", %d, %d)\n", (void *) p, text, 0, parent, open))
 1989     {
 1990         int len = text ? (int) pdc_strlen(text) : 0;
 1991 
 1992         pdf_logg_is_deprecated(p, fn, 6);
 1993 
 1994         retval = pdf__add_bookmark(p, text, len, parent, open);
 1995         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 1996     }
 1997 
 1998     return retval;
 1999 }
 2000 
 2001 PDFLIB_API int PDFLIB_CALL
 2002 PDF_add_bookmark2(
 2003     PDF *p,
 2004     const char *text, int len,
 2005     int parent,
 2006     int open)
 2007 {
 2008     static const char fn[] = "PDF_add_bookmark2";
 2009     int retval = -1;
 2010 
 2011     if (pdf_enter_api(p, fn,
 2012         (pdf_state) (pdf_state_page | pdf_state_document),
 2013         "(p_%p, \"%T\", /*c*/%d, %d, %d)\n",
 2014         (void *) p, text, len, len, parent, open))
 2015     {
 2016         pdf_logg_is_deprecated(p, fn, 6);
 2017 
 2018         retval = pdf__add_bookmark(p, text, len, parent, open);
 2019         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 2020     }
 2021 
 2022     return retval;
 2023 }
 2024 
 2025 PDFLIB_API void PDFLIB_CALL
 2026 PDF_add_nameddest(
 2027     PDF *p,
 2028     const char *name, int len,
 2029     const char *optlist)
 2030 {
 2031     static const char fn[] = "PDF_add_nameddest";
 2032 
 2033     if (pdf_enter_api(p, fn,
 2034         (pdf_state) (pdf_state_page | pdf_state_document),
 2035         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 2036         (void *) p, name, len, len, optlist, 0))
 2037     {
 2038         pdf__add_nameddest(p, name, len, optlist);
 2039 
 2040         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2041     }
 2042 }
 2043 
 2044 PDFLIB_API int PDFLIB_CALL
 2045 PDF_create_bookmark(
 2046     PDF *p,
 2047     const char *text, int len,
 2048     const char *optlist)
 2049 {
 2050     static const char fn[] = "PDF_create_bookmark";
 2051     int retval = -1;
 2052 
 2053     if (pdf_enter_api(p, fn,
 2054         (pdf_state) (pdf_state_page | pdf_state_document),
 2055         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 2056         (void *) p, text, len, len, optlist, 0))
 2057     {
 2058         retval = pdf__create_bookmark(p, text, len, optlist);
 2059 
 2060         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 2061     }
 2062     return retval;
 2063 }
 2064 
 2065 PDFLIB_API void PDFLIB_CALL
 2066 PDF_set_info(PDF *p, const char *key, const char *value)
 2067 {
 2068     static const char fn[] = "PDF_set_info";
 2069 
 2070     if (pdf_enter_api(p, fn,
 2071         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2072         "(p_%p, \"%T\", \"%T\")\n",
 2073         (void *) p, key, 0, value, 0))
 2074     {
 2075         int len = value ? (int) pdc_strlen(value) : 0;
 2076         pdf__set_info(p, key, value, len);
 2077 
 2078         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2079     }
 2080 }
 2081 
 2082 PDFLIB_API void PDFLIB_CALL
 2083 PDF_set_info2(PDF *p, const char *key, const char *value, int len)
 2084 {
 2085     static const char fn[] = "PDF_set_info2";
 2086 
 2087     if (pdf_enter_api(p, fn,
 2088         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2089         "(p_%p, \"%T\", \"%T\", /*c*/%d)\n",
 2090         (void *) p, key, 0, value, len, len))
 2091     {
 2092         pdf__set_info(p, key, value, len);
 2093 
 2094         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2095     }
 2096 }
 2097 
 2098 
 2099 /**********************
 2100  *
 2101  *  p_icc.c
 2102  *
 2103  **********************/
 2104 
 2105 PDFLIB_API int PDFLIB_CALL
 2106 PDF_load_iccprofile(
 2107     PDF *p,
 2108     const char *profilename, int len,
 2109     const char *optlist)
 2110 {
 2111     static const char fn[] = "PDF_load_iccprofile";
 2112     int retval = -1;
 2113 
 2114     if (pdf_enter_api(p, fn,
 2115         (pdf_state) (pdf_state_document | pdf_state_content),
 2116         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 2117         (void *) p, profilename, len, len, optlist, 0))
 2118     {
 2119         pdc_error(p->pdc, PDF_E_UNSUPP_ICC, 0, 0, 0, 0);
 2120     }
 2121 
 2122     return pdf_exit_handle_api(p, retval);
 2123 }
 2124 
 2125 
 2126 /**********************
 2127  *
 2128  *  p_image.c
 2129  *
 2130  **********************/
 2131 
 2132 PDFLIB_API void PDFLIB_CALL
 2133 PDF_add_thumbnail(PDF *p, int image)
 2134 {
 2135     static const char fn[] = "PDF_add_thumbnail";
 2136 
 2137     if (pdf_enter_api(p, fn, pdf_state_page,
 2138         "(p_%p, %d)\n", (void *) p, image))
 2139     {
 2140         if (p->pdc->hastobepos) image -= 1;
 2141         pdf__add_thumbnail(p, image);
 2142 
 2143         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2144     }
 2145 }
 2146 
 2147 PDFLIB_API void PDFLIB_CALL
 2148 PDF_close_image(PDF *p, int image)
 2149 {
 2150     static const char fn[] = "PDF_close_image";
 2151 
 2152     if (pdf_enter_api(p, fn,
 2153         (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font),
 2154         "(p_%p, %d)\n", (void *) p, image))
 2155     {
 2156         if (p->pdc->hastobepos) image -= 1;
 2157         pdf__close_image(p, image);
 2158 
 2159         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2160     }
 2161 }
 2162 
 2163 PDFLIB_API void PDFLIB_CALL
 2164 PDF_fit_image(
 2165     PDF *p,
 2166     int image,
 2167     double x,
 2168     double y,
 2169     const char *optlist)
 2170 {
 2171     static const char fn[] = "PDF_fit_image";
 2172 
 2173     /* scope check dependent on image type in kernel function */
 2174     if (pdf_enter_api(p, fn, pdf_state_firsttest,
 2175         "(p_%p, %d, %f, %f, \"%T\")\n", (void *) p, image, x, y, optlist, 0))
 2176     {
 2177         if (p->pdc->hastobepos) image -= 1;
 2178         pdf__fit_image(p, image, x, y, optlist);
 2179 
 2180         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2181     }
 2182 }
 2183 
 2184 PDFLIB_API int PDFLIB_CALL
 2185 PDF_load_image(
 2186     PDF *p,
 2187     const char *type,
 2188     const char *filename,
 2189     int len,
 2190     const char *optlist)
 2191 {
 2192     static const char fn[] = "PDF_load_image";
 2193     int retval = -1;
 2194 
 2195     /* scope check dependent on image type in kernel function */
 2196     if (pdf_enter_api(p, fn,
 2197         (pdf_state) (pdf_state_document | pdf_state_page |
 2198                      pdf_state_font | pdf_state_content),
 2199         "(p_%p, \"%s\", \"%T\", /*c*/%d, \"%T\")\n",
 2200         (void *) p, type, filename, len, len, optlist, 0))
 2201     {
 2202         filename = pdf_convert_filename(p, filename, len,
 2203                                         "filename", PDC_CONV_WITHBOM);
 2204         retval = pdf__load_image(p, type, filename, optlist);
 2205     }
 2206 
 2207     return pdf_exit_handle_api(p, retval);
 2208 }
 2209 
 2210 PDFLIB_API int PDFLIB_CALL
 2211 PDF_open_CCITT(
 2212     PDF *p,
 2213     const char *filename,
 2214     int width,
 2215     int height,
 2216     int BitReverse, int K, int BlackIs1)
 2217 {
 2218     static const char fn[] = "PDF_open_CCITT";
 2219     int retval = -1;
 2220 
 2221     /* scope check dependent on image type in kernel function */
 2222     if (pdf_enter_api(p, fn,
 2223         (pdf_state) (pdf_state_document | pdf_state_page |
 2224                      pdf_state_font | pdf_state_content),
 2225         "(p_%p, \"%s\", %d, %d, %d, %d, %d)\n",
 2226         (void *) p, filename, width, height,
 2227         BitReverse, K, BlackIs1))
 2228     {
 2229         char optlist[PDC_GEN_BUFSIZE];
 2230 
 2231         pdf_logg_is_deprecated(p, fn, 6);
 2232 
 2233         pdc_sprintf(p->pdc, pdc_false, optlist,
 2234             "width %d  height %d  bitreverse %s  K %d  invert %s",
 2235             width, height, PDC_BOOLSTR(BitReverse), K, PDC_BOOLSTR(BlackIs1));
 2236         filename = pdf_convert_filename(p, filename, 0,
 2237                                         "filename", PDC_CONV_WITHBOM);
 2238         retval = pdf__load_image(p, "CCITT", filename, optlist);
 2239     }
 2240 
 2241     return pdf_exit_handle_api(p, retval);
 2242 }
 2243 
 2244 PDFLIB_API int PDFLIB_CALL
 2245 PDF_open_image(
 2246     PDF *p,
 2247     const char *type,
 2248     const char *source,
 2249     const char *data,
 2250     long length,
 2251     int width,
 2252     int height,
 2253     int components,
 2254     int bpc,
 2255     const char *params)
 2256 {
 2257     static const char fn[] = "PDF_open_image";
 2258     int retval = -1;
 2259 
 2260     /* scope check dependent on image type in kernel function */
 2261     if (pdf_enter_api(p, fn,
 2262         (pdf_state) (pdf_state_document | pdf_state_page |
 2263                      pdf_state_font | pdf_state_content),
 2264         "(p_%p, \"%s\", \"%s\", idata_%p, %ld, %d, %d, %d, %d, \"%s\")\n",
 2265         (void *) p, type, source, (void *) data, length,
 2266         width, height, components, bpc, params))
 2267     {
 2268         const char *filename = data;
 2269         char optlist[PDC_GEN_BUFSIZE];
 2270         pdc_bool memory = pdc_false;
 2271 
 2272         pdf_logg_is_deprecated(p, fn, 6);
 2273 
 2274         if (type == NULL || *type == '\0')
 2275             pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "type", 0, 0, 0);
 2276 
 2277         if (source == NULL || *source == '\0')
 2278             pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "source", 0, 0, 0);
 2279 
 2280         if (!strcmp(type, "raw") && data == NULL)
 2281             pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "data", 0, 0, 0);
 2282 
 2283         /* create optlist */
 2284         optlist[0] = 0;
 2285         if (!strcmp(type, "raw") || !strcmp(type, "ccitt"))
 2286             pdc_sprintf(p->pdc, pdc_false, optlist,
 2287                 "width %d  height %d  components %d  bpc %d ",
 2288                 width, height, components, bpc);
 2289 
 2290         if (length < 0L)
 2291         {
 2292             strcat(optlist, "bitreverse true ");
 2293             length = -length;
 2294         }
 2295 
 2296         strcat(optlist, "reftype ");
 2297         if (!strcmp(source, "fileref"))
 2298             strcat(optlist, "fileref ");
 2299         else if (!strcmp(source, "memory"))
 2300         {
 2301             memory = pdc_true;
 2302             strcat(optlist, "direct ");
 2303         }
 2304         else if (!strcmp(source, "url"))
 2305             strcat(optlist, "url ");
 2306 
 2307         if (params != NULL && *params != '\0')
 2308         {
 2309             char **items;
 2310             int i, nitems;
 2311 
 2312             /* separator characters because of compatibility */
 2313             nitems = pdc_split_stringlist(p->pdc, params, "\t :", 0, &items);
 2314             for (i = 0; i < nitems; i++)
 2315             {
 2316                 if (!strcmp(items[i], "invert"))
 2317                     strcat(optlist, "invert true ");
 2318                 else if (!strcmp(items[i], "ignoremask"))
 2319                     strcat(optlist, "ignoremask true ");
 2320                 else if (!strcmp(items[i], "inline"))
 2321                     strcat(optlist, "inline true ");
 2322                 else if (!strcmp(items[i], "interpolate"))
 2323                     strcat(optlist, "interpolate true ");
 2324                 else if (!strcmp(items[i], "mask"))
 2325                     strcat(optlist, "mask true ");
 2326                 else if (!strcmp(items[i], "/K"))
 2327                     strcat(optlist, "K ");
 2328                 else if (!strcmp(items[i], "/BlackIs1"))
 2329                     strcat(optlist, "invert ");
 2330                 else
 2331                     strcat(optlist, items[i]);
 2332             }
 2333             pdc_cleanup_stringlist(p->pdc, items);
 2334         }
 2335 
 2336         /* create virtual file */
 2337         if (memory)
 2338         {
 2339             filename = "__raw__image__data__";
 2340             pdc__create_pvf(p->pdc, filename, data, (size_t) length, "");
 2341         }
 2342 
 2343         filename = pdf_convert_filename(p, filename, 0,
 2344                                         "filename", PDC_CONV_WITHBOM);
 2345         retval = pdf__load_image(p, type, filename, (const char *) optlist);
 2346 
 2347         if (memory)
 2348             (void) pdc__delete_pvf(p->pdc, filename);
 2349     }
 2350 
 2351     return pdf_exit_handle_api(p, retval);
 2352 }
 2353 
 2354 PDFLIB_API int PDFLIB_CALL
 2355 PDF_open_image_file(
 2356     PDF *p,
 2357     const char *type,
 2358     const char *filename,
 2359     const char *stringparam,
 2360     int intparam)
 2361 {
 2362     static const char fn[] = "PDF_open_image_file";
 2363     int retval = -1;
 2364 
 2365     /* scope check dependent on image type in kernel function */
 2366     if (pdf_enter_api(p, fn,
 2367         (pdf_state) (pdf_state_document | pdf_state_page |
 2368                      pdf_state_font | pdf_state_content),
 2369         "(p_%p, \"%s\", \"%s\", \"%s\", %d)\n",
 2370         (void *) p, type, filename, stringparam, intparam))
 2371     {
 2372         char optlist[PDC_GEN_BUFSIZE];
 2373 
 2374         pdf_logg_is_deprecated(p, fn, 6);
 2375 
 2376         optlist[0] = 0;
 2377         if (stringparam != NULL && *stringparam != '\0')
 2378         {
 2379             if (!strcmp(stringparam, "invert"))
 2380                 strcpy(optlist, "invert true ");
 2381             else if (!strcmp(stringparam, "inline"))
 2382                 strcpy(optlist, "inline true ");
 2383             else if (!strcmp(stringparam, "ignoremask"))
 2384                 strcpy(optlist, "ignoremask true ");
 2385             else if (!strcmp(stringparam, "mask"))
 2386                 strcpy(optlist, "mask true ");
 2387             else if (!strcmp(stringparam, "masked"))
 2388                 pdc_sprintf(p->pdc, pdc_false, optlist, "masked %d ",
 2389                             intparam);
 2390             else if (!strcmp(stringparam, "colorize"))
 2391                 pdc_sprintf(p->pdc, pdc_false, optlist, "colorize %d ",
 2392                             intparam);
 2393             else if (!strcmp(stringparam, "page"))
 2394                 pdc_sprintf(p->pdc, pdc_false, optlist, "page %d ",
 2395                             intparam);
 2396             else if (!strcmp(stringparam, "iccprofile"))
 2397                 pdc_sprintf(p->pdc, pdc_false, optlist, "iccprofile %d ",
 2398                             intparam);
 2399         }
 2400         filename = pdf_convert_filename(p, filename, 0,
 2401                                         "filename", PDC_CONV_WITHBOM);
 2402         retval = pdf__load_image(p, type, filename, optlist);
 2403     }
 2404 
 2405     return pdf_exit_handle_api(p, retval);
 2406 }
 2407 
 2408 PDFLIB_API void PDFLIB_CALL
 2409 PDF_place_image(
 2410     PDF *p,
 2411     int image,
 2412     double x,
 2413     double y,
 2414     double scale)
 2415 {
 2416     static const char fn[] = "PDF_place_image";
 2417 
 2418     /* scope check dependent on image type in kernel function */
 2419     if (pdf_enter_api(p, fn, pdf_state_firsttest,
 2420         "(p_%p, %d, %f, %f, %f)\n", (void *) p, image, x, y, scale))
 2421     {
 2422         char optlist[PDC_GEN_BUFSIZE];
 2423 
 2424         pdf_logg_is_deprecated(p, fn, 6);
 2425 
 2426         pdc_sprintf(p->pdc, pdc_false, optlist, "dpi none  scale %f", scale);
 2427         if (p->pdc->hastobepos) image -= 1;
 2428         pdf__fit_image(p, image, x, y, optlist);
 2429 
 2430         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2431     }
 2432 }
 2433 
 2434 
 2435 /**********************
 2436  *
 2437  *  p_kerning.c
 2438  *
 2439  **********************/
 2440 
 2441 PDFLIB_API double PDFLIB_CALL
 2442 PDF_get_kern_amount(
 2443     PDF *p,
 2444     int font,
 2445     int firstchar,
 2446     int secondchar)
 2447 {
 2448     static const char fn[] = "PDF_get_kern_amount";
 2449     double retval = -1;
 2450 
 2451     if (pdf_enter_api(p, fn,
 2452         (pdf_state) (pdf_state_document | pdf_state_content | pdf_state_path),
 2453         "(p_%p, %d, %d, %d)\n", (void *) p, font, firstchar, secondchar))
 2454     {
 2455         if (p->pdc->hastobepos) font -= 1;
 2456         pdc_error(p->pdc, PDF_E_UNSUPP_KERNING, 0, 0, 0, 0);
 2457 
 2458         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 2459     }
 2460 
 2461     return retval;
 2462 }
 2463 
 2464 
 2465 /**********************
 2466  *
 2467  *  p_layer.c
 2468  *
 2469  **********************/
 2470 
 2471 PDFLIB_API void PDFLIB_CALL
 2472 PDF_begin_layer(PDF *p, int layer)
 2473 {
 2474     static const char fn[] = "PDF_begin_layer";
 2475 
 2476     if (pdf_enter_api(p, fn, pdf_state_page,
 2477         "(p_%p, %d)\n", (void *) p, layer))
 2478     {
 2479         pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0);
 2480 
 2481         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2482     }
 2483 }
 2484 
 2485 PDFLIB_API int PDFLIB_CALL
 2486 PDF_define_layer(
 2487     PDF *p,
 2488     const char *name, int len,
 2489     const char *optlist)
 2490 {
 2491     static const char fn[] = "PDF_define_layer";
 2492     int retval = -1;
 2493 
 2494     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 2495         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 2496          (void *) p, name, len, len, optlist, 0))
 2497     {
 2498         pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0);
 2499     }
 2500 
 2501     return pdf_exit_handle_api(p, retval);
 2502 }
 2503 
 2504 PDFLIB_API void PDFLIB_CALL
 2505 PDF_end_layer(PDF *p)
 2506 {
 2507     static const char fn[] = "PDF_end_layer";
 2508 
 2509     if (pdf_enter_api(p, fn, pdf_state_page,
 2510         "(p_%p)\n", (void *) p))
 2511     {
 2512         pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0);
 2513 
 2514         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2515     }
 2516 }
 2517 
 2518 PDFLIB_API void PDFLIB_CALL
 2519 PDF_set_layer_dependency(
 2520     PDF *p,
 2521     const char *type,
 2522     const char *optlist)
 2523 {
 2524     static const char fn[] = "PDF_set_layer_dependency";
 2525 
 2526     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 2527         "(p_%p, \"%s\", \"%T\")\n", (void *) p, type, optlist, 0))
 2528     {
 2529         pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0);
 2530 
 2531         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2532     }
 2533 }
 2534 
 2535 
 2536 /**********************
 2537  *
 2538  *  p_mbox.c
 2539  *
 2540  **********************/
 2541 
 2542  PDFLIB_API double PDFLIB_CALL
 2543  PDF_info_matchbox(PDF *p, const char *boxname, int len, int num,
 2544      const char *keyword)
 2545  {
 2546     static const char fn[] = "PDF_info_matchbox";
 2547     double retval = 0;
 2548 
 2549     if (pdf_enter_api(p, fn,
 2550         (pdf_state) (pdf_state_content | pdf_state_path | pdf_state_font),
 2551         "(p_%p, \"%T\", /*c*/%d, %d, \"%s\")\n",
 2552         (void *) p, boxname, len, len, num, keyword))
 2553     {
 2554         retval = pdf__info_matchbox(p, boxname, len, num, keyword);
 2555 
 2556         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 2557     }
 2558 
 2559     return retval;
 2560 }
 2561 
 2562 
 2563 /**********************
 2564  *
 2565  *  p_object.c
 2566  *
 2567  **********************/
 2568 
 2569 PDFLIB_API void PDFLIB_CALL
 2570 PDF_delete(PDF *p)
 2571 {
 2572     static const char fn[] = "PDF_delete";
 2573 
 2574     if (pdf_enter_api_simple(p, fn, "(p_%p)\n", (void *) p))
 2575     {
 2576         pdf__delete(p);
 2577     }
 2578 }
 2579 
 2580 PDFLIB_API PDF * PDFLIB_CALL
 2581 PDF_new(void)
 2582 {
 2583     return pdf__new(NULL, NULL, NULL, NULL, NULL);
 2584 }
 2585 
 2586 PDFLIB_API PDF * PDFLIB_CALL
 2587 PDF_new2(
 2588     void  (*errorhandler)(PDF *p, int type, const char *msg),
 2589     void* (*allocproc)(PDF *p, size_t size, const char *caller),
 2590     void* (*reallocproc)(PDF *p, void *mem, size_t size, const char *caller),
 2591     void  (*freeproc)(PDF *p, void *mem),
 2592     void   *opaque)
 2593 {
 2594     return pdf__new(errorhandler, allocproc, reallocproc, freeproc, opaque);
 2595 }
 2596 
 2597 
 2598 /**********************
 2599  *
 2600  *  p_page.c
 2601  *
 2602  **********************/
 2603 
 2604 PDFLIB_API void PDFLIB_CALL
 2605 PDF_begin_page(PDF *p, double width, double height)
 2606 {
 2607     static const char fn[] = "\nPDF_begin_page";
 2608 
 2609     if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p, %f, %f)\n",
 2610        (void *) p, width, height))
 2611     {
 2612         pdf_logg_is_deprecated(p, fn, 6);
 2613 
 2614         pdf__begin_page(p, width, height);
 2615 
 2616         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2617     }
 2618 }
 2619 
 2620 PDFLIB_API void PDFLIB_CALL
 2621 PDF_begin_page_ext(PDF *p, double width, double height, const char *optlist)
 2622 {
 2623     static const char fn[] = "\nPDF_begin_page_ext";
 2624 
 2625     if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p, %f, %f, \"%T\")\n",
 2626        (void *) p, width, height, optlist, 0))
 2627     {
 2628         pdf__begin_page_ext(p, width, height, optlist);
 2629 
 2630         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2631     }
 2632 }
 2633 
 2634 PDFLIB_API void PDFLIB_CALL
 2635 PDF_end_page(PDF *p)
 2636 {
 2637     static const char fn[] = "PDF_end_page";
 2638 
 2639     if (pdf_enter_api(p, fn, pdf_state_page, "(p_%p)\n", (void *) p))
 2640     {
 2641         pdf_logg_is_deprecated(p, fn, 6);
 2642 
 2643         pdf__end_page_ext(p, "");
 2644 
 2645         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2646     }
 2647 }
 2648 
 2649 PDFLIB_API void PDFLIB_CALL
 2650 PDF_end_page_ext(PDF *p, const char *optlist)
 2651 {
 2652     static const char fn[] = "PDF_end_page_ext";
 2653 
 2654     if (pdf_enter_api(p, fn, pdf_state_page, "(p_%p, \"%T\")\n",
 2655         (void *) p, optlist, 0))
 2656     {
 2657         pdf__end_page_ext(p, optlist);
 2658 
 2659         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2660     }
 2661 }
 2662 
 2663 PDFLIB_API void PDFLIB_CALL
 2664 PDF_resume_page(PDF *p, const char *optlist)
 2665 {
 2666     static const char fn[] = "\nPDF_resume_page";
 2667 
 2668     if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p, \"%T\")\n",
 2669        (void *) p, optlist, 0))
 2670     {
 2671         pdf__resume_page(p, optlist);
 2672 
 2673         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2674     }
 2675 }
 2676 
 2677 PDFLIB_API void PDFLIB_CALL
 2678 PDF_suspend_page(PDF *p, const char *optlist)
 2679 {
 2680     static const char fn[] = "PDF_suspend_page";
 2681 
 2682     if (pdf_enter_api(p, fn, pdf_state_page, "(p_%p, \"%T\")\n",
 2683        (void *) p, optlist, 0))
 2684     {
 2685         pdf__suspend_page(p, optlist);
 2686 
 2687         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2688     }
 2689 }
 2690 
 2691 
 2692 /**********************
 2693  *
 2694  *  p_parameter.c
 2695  *
 2696  **********************/
 2697 
 2698 PDFLIB_API const char * PDFLIB_CALL
 2699 PDF_get_parameter(PDF *p, const char *key, double modifier)
 2700 {
 2701     static const char fn[] = "PDF_get_parameter";
 2702     const char *retval = "";
 2703 
 2704     if (!pdc_stricmp(key, "version"))
 2705     {
 2706         retval = PDFLIB_VERSIONSTRING;
 2707     }
 2708     else if (!pdc_stricmp(key, "pdi"))
 2709     {
 2710         retval = "false";
 2711     }
 2712     else if (pdf_enter_api(p, fn, (pdf_state) pdf_state_all,
 2713         "(p_%p, \"%s\", %f)\n", (void *) p, key, modifier))
 2714     {
 2715         retval = pdf__get_parameter(p, key, modifier);
 2716 
 2717         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%T\"]\n", retval, 0);
 2718     }
 2719 
 2720     return retval;
 2721 }
 2722 
 2723 PDFLIB_API double PDFLIB_CALL
 2724 PDF_get_value(PDF *p, const char *key, double modifier)
 2725 {
 2726     static const char fn[] = "PDF_get_value";
 2727     double retval = -1;
 2728 
 2729     if (!pdc_stricmp(key, "major"))
 2730     {
 2731         retval = PDFLIB_MAJORVERSION;
 2732     }
 2733     else if (!pdc_stricmp(key, "minor"))
 2734     {
 2735         retval = PDFLIB_MINORVERSION;
 2736     }
 2737     else if (!pdc_stricmp(key, "revision"))
 2738     {
 2739         retval = PDFLIB_REVISION;
 2740     }
 2741     else if (pdf_enter_api(p, fn, (pdf_state) pdf_state_all,
 2742         "(p_%p, \"%s\", %f)\n", (void *) p, key, modifier))
 2743     {
 2744         retval = pdf__get_value(p, key, modifier);
 2745 
 2746         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 2747     }
 2748 
 2749     return retval;
 2750 }
 2751 
 2752 PDFLIB_API void PDFLIB_CALL
 2753 PDF_set_parameter(PDF *p, const char *key, const char *value)
 2754 {
 2755     static const char fn[] = "PDF_set_parameter";
 2756 
 2757     if (pdf_enter_api(p, fn, (pdf_state) pdf_state_all,
 2758         "(p_%p, \"%s\", \"%T\")\n",
 2759         (void *) p, key, value, 0))
 2760     {
 2761         pdf__set_parameter(p, key, value);
 2762 
 2763         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 2764     }
 2765 }
 2766 
 2767 PDFLIB_API void PDFLIB_CALL
 2768 PDF_set_value(PDF *p, const char *key, double value)
 2769 {
 2770     static const char fn[] = "PDF_set_value";
 2771 
 2772     if (pdf_enter_api(p, fn, (pdf_state) pdf_state_all,
 2773         "(p_%p, \"%s\", %f)\n", (void *) p, key, value))
 2774     {
 2775         pdf__set_value(p, key, value);
 2776 
 2777         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 2778     }
 2779 }
 2780 
 2781 
 2782 /**********************
 2783  *
 2784  *  p_pattern.c
 2785  *
 2786  **********************/
 2787 
 2788 PDFLIB_API int PDFLIB_CALL
 2789 PDF_begin_pattern(
 2790     PDF *p,
 2791     double width,
 2792     double height,
 2793     double xstep,
 2794     double ystep,
 2795     int painttype)
 2796 {
 2797     static const char fn[] = "\nPDF_begin_pattern";
 2798     int retval = -1;
 2799 
 2800     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 2801         "(p_%p, %f, %f, %f, %f, %d)\n",
 2802         (void *) p, width, height, xstep, ystep, painttype))
 2803     {
 2804         retval = pdf__begin_pattern(p, width, height, xstep, ystep, painttype);
 2805     }
 2806 
 2807     return pdf_exit_handle_api(p, retval);
 2808 }
 2809 
 2810 PDFLIB_API void PDFLIB_CALL
 2811 PDF_end_pattern(PDF *p)
 2812 {
 2813     static const char fn[] = "PDF_end_pattern";
 2814 
 2815     if (pdf_enter_api(p, fn, pdf_state_pattern, "(p_%p)\n", (void *) p))
 2816     {
 2817         pdf__end_pattern(p);
 2818 
 2819         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2820     }
 2821 }
 2822 
 2823 
 2824 /**********************
 2825  *
 2826  *  p_pdi.c
 2827  *
 2828  **********************/
 2829 
 2830 PDFLIB_API void PDFLIB_CALL
 2831 PDF_close_pdi(PDF *p, int doc)
 2832 {
 2833     static const char fn[] = "PDF_close_pdi";
 2834 
 2835     if (pdf_enter_api(p, fn,
 2836         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2837         "(p_%p, %d)\n", (void *) p, doc))
 2838     {
 2839         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2840                              pdc_false);
 2841 
 2842         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2843     }
 2844 }
 2845 
 2846 PDFLIB_API void PDFLIB_CALL
 2847 PDF_close_pdi_document(PDF *p, int doc)
 2848 {
 2849     static const char fn[] = "PDF_close_pdi_document";
 2850 
 2851     if (pdf_enter_api(p, fn,
 2852         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2853         "(p_%p, %d)\n", (void *) p, doc))
 2854     {
 2855         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2856                              pdc_false);
 2857 
 2858         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2859     }
 2860 }
 2861 
 2862 PDFLIB_API void PDFLIB_CALL
 2863 PDF_close_pdi_page(PDF *p, int page)
 2864 {
 2865     static const char fn[] = "PDF_close_pdi_page";
 2866 
 2867     if (pdf_enter_api(p, fn,
 2868         (pdf_state) (pdf_state_document | pdf_state_page),
 2869         "(p_%p, %d)\n", (void *) p, page))
 2870     {
 2871         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2872                              pdc_false);
 2873 
 2874         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2875     }
 2876 }
 2877 
 2878 PDFLIB_API void PDFLIB_CALL
 2879 PDF_fit_pdi_page(PDF *p, int page, double x, double y, const char *optlist)
 2880 {
 2881     static const char fn[] = "PDF_fit_pdi_page";
 2882 
 2883     if (pdf_enter_api(p, fn, pdf_state_content,
 2884         "(p_%p, %d, %f, %f, \"%T\")\n", (void *) p, page, x, y, optlist, 0))
 2885     {
 2886         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2887                              pdc_false);
 2888 
 2889         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 2890     }
 2891 }
 2892 
 2893 PDFLIB_API const char *PDFLIB_CALL
 2894 PDF_get_pdi_parameter(
 2895     PDF *p,
 2896     const char *key,
 2897     int doc,
 2898     int page,
 2899     int reserved,
 2900     int *len)
 2901 {
 2902     static const char fn[] = "PDF_get_pdi_parameter";
 2903     const char *retval = "";
 2904 
 2905     if (len)
 2906         *len = 0;
 2907 
 2908     if (pdf_enter_api(p, fn, pdf_state_all,
 2909         len ? "(p_%p, \"%s\", %d, %d, %d, /*c*/&len_%p)" :
 2910               "(p_%p, \"%s\", %d, %d, %d, /*c*/NULL)\n",
 2911         (void *) p, key, doc, page, reserved, len))
 2912     {
 2913         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2914                              pdc_false);
 2915 
 2916         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%T\"]\n", retval, 0);
 2917     }
 2918 
 2919     return retval;
 2920 }
 2921 
 2922 PDFLIB_API double PDFLIB_CALL
 2923 PDF_get_pdi_value(
 2924     PDF *p,
 2925     const char *key,
 2926     int doc,
 2927     int page,
 2928     int reserved)
 2929 {
 2930     static const char fn[] = "PDF_get_pdi_value";
 2931     double retval = -1;
 2932 
 2933     if (pdf_enter_api(p, fn, pdf_state_all,
 2934         "(p_%p, \"%s\", %d, %d, %d)\n",
 2935         (void *) p, key, doc, page, reserved))
 2936     {
 2937         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2938                              pdc_false);
 2939 
 2940         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 2941     }
 2942 
 2943     return retval;
 2944 }
 2945 
 2946 PDFLIB_API int PDFLIB_CALL
 2947 PDF_open_pdi(
 2948     PDF *p,
 2949     const char *filename,
 2950     const char *optlist,
 2951     int len)
 2952 {
 2953     static const char fn[] = "PDF_open_pdi";
 2954     int retval = -1;
 2955 
 2956     /* state "object" doesn't make sense until PDFlib can handle this,
 2957     ** but is allowed here for version compatibility
 2958     */
 2959     if (pdf_enter_api(p, fn,
 2960         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2961         "(p_%p, \"%T\", \"%T\", %d)\n",
 2962         (void *) p, filename, len, optlist, 0, len))
 2963     {
 2964         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2965                              pdc_false);
 2966     }
 2967 
 2968     return pdf_exit_handle_api(p, retval);
 2969 }
 2970 
 2971 PDFLIB_API int PDFLIB_CALL
 2972 PDF_open_pdi_document(
 2973     PDF *p,
 2974     const char *filename,
 2975     int len,
 2976     const char *optlist)
 2977 {
 2978     static const char fn[] = "PDF_open_pdi_document";
 2979     int retval = -1;
 2980 
 2981     /* state "object" doesn't make sense until PDFlib can handle this,
 2982     ** but is allowed here for version compatibility
 2983     */
 2984     if (pdf_enter_api(p, fn,
 2985         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 2986         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 2987         (void *) p, filename, len, len, optlist, 0))
 2988     {
 2989         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 2990                              pdc_false);
 2991     }
 2992 
 2993     return pdf_exit_handle_api(p, retval);
 2994 }
 2995 
 2996 PDFLIB_API int PDFLIB_CALL
 2997 PDF_open_pdi_callback(
 2998     PDF *p,
 2999     void *opaque,
 3000     size_t filesize,
 3001     size_t (*readproc)(void *opaque, void *buffer, size_t size),
 3002     int (*seekproc)(void *opaque, long offset),
 3003     const char *optlist)
 3004 {
 3005     static const char fn[] = "PDF_open_pdi_callback";
 3006     int retval = -1;
 3007 
 3008     /* state "object" doesn't make sense until PDFlib can handle this,
 3009     ** but is allowed here for version compatibility
 3010     */
 3011     if (pdf_enter_api(p, fn,
 3012         (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page),
 3013         "(p_%p, opaque_%p, %ld, readproc_%p, seekproc_%p \"%T\")\n",
 3014         (void *)p, opaque, filesize, readproc, seekproc, optlist, 0))
 3015     {
 3016         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 3017                              pdc_false);
 3018     }
 3019 
 3020     return pdf_exit_handle_api(p, retval);
 3021 }
 3022 
 3023 
 3024 PDFLIB_API int PDFLIB_CALL
 3025 PDF_open_pdi_page(PDF *p, int doc, int pagenumber, const char* optlist)
 3026 {
 3027     static const char fn[] = "PDF_open_pdi_page";
 3028     int retval = -1;
 3029 
 3030     if (pdf_enter_api(p, fn,
 3031         (pdf_state) (pdf_state_document | pdf_state_page),
 3032         "(p_%p, %d, %d, \"%T\")\n", (void *) p, doc, pagenumber, optlist, 0))
 3033     {
 3034         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 3035                              pdc_false);
 3036     }
 3037 
 3038     return pdf_exit_handle_api(p, retval);
 3039 }
 3040 
 3041 /* pCOS "context free parameters"
 3042 */
 3043 typedef enum
 3044 {
 3045     cfp_none, cfp_major, cfp_minor, cfp_revision, cfp_version
 3046 } pcos_cfp;
 3047 
 3048 static pcos_cfp
 3049 get_pcos_cfp(const char *fmt, va_list args)
 3050 {
 3051     const char *cfp = fmt;
 3052 
 3053     if (strcmp(fmt, "%s") == 0)
 3054     cfp = va_arg(args, char *);
 3055 
 3056     if (strcmp(cfp, "major") == 0)
 3057     return cfp_major;
 3058 
 3059     if (strcmp(cfp, "minor") == 0)
 3060     return cfp_minor;
 3061 
 3062     if (strcmp(cfp, "revision") == 0)
 3063     return cfp_revision;
 3064 
 3065     if (strcmp(cfp, "version") == 0)
 3066     return cfp_version;
 3067 
 3068     return cfp_none;
 3069 } /* get_pcos_cfp */
 3070 
 3071 
 3072 PDFLIB_API double PDFLIB_CALL
 3073 PDF_pcos_get_number(PDF *p, int doc, const char *path, ...)
 3074 {
 3075     static const char fn[] = "PDF_pcos_get_number";
 3076 
 3077     double result = 0;
 3078     pcos_cfp cfp;
 3079 
 3080     if (pdf_enter_api(p, fn, pdf_state_all,
 3081     "(p_%p, %d, \"%s\")\n", (void *) p, doc, path))
 3082     {
 3083     va_list args;
 3084 
 3085     if (!path)
 3086         path = "";
 3087 
 3088     va_start(args, path);
 3089     cfp = get_pcos_cfp(path, args);
 3090     va_end(args);
 3091 
 3092     switch (cfp)
 3093     {
 3094         case cfp_major:
 3095         result = PDFLIB_MAJORVERSION;
 3096         break;
 3097 
 3098         case cfp_minor:
 3099         result = PDFLIB_MINORVERSION;
 3100         break;
 3101 
 3102         case cfp_revision:
 3103         result = PDFLIB_REVISION;
 3104         break;
 3105 
 3106         default:
 3107         {
 3108                 pdc_set_unsupp_error(p->pdc,
 3109                          PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI, pdc_false);
 3110         break;
 3111         }
 3112     } /* switch */
 3113 
 3114         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", result);
 3115     }
 3116     return result;
 3117 }
 3118 
 3119 PDFLIB_API const char * PDFLIB_CALL
 3120 PDF_pcos_get_string(PDF *p, int doc, const char *path, ...)
 3121 {
 3122     static const char fn[] = "PDF_pcos_get_string";
 3123 
 3124     const char *result = "";
 3125     pcos_cfp cfp;
 3126 
 3127     if (pdf_enter_api(p, fn, pdf_state_all,
 3128     "(p_%p, %d, \"%s\")\n", (void *) p, doc, path))
 3129     {
 3130     va_list args;
 3131 
 3132     if (!path)
 3133         path = "";
 3134 
 3135     va_start(args, path);
 3136     cfp = get_pcos_cfp(path, args);
 3137     va_end(args);
 3138 
 3139     switch (cfp)
 3140     {
 3141         case cfp_version:
 3142         result = PDFLIB_VERSIONSTRING;
 3143         break;
 3144 
 3145         default:
 3146         {
 3147                 pdc_set_unsupp_error(p->pdc,
 3148                          PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI, pdc_false);
 3149         break;
 3150         }
 3151     } /* switch */
 3152 
 3153         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%T\"]\n", result, 0);
 3154     }
 3155     return result;
 3156 }
 3157 
 3158 PDFLIB_API const unsigned char * PDFLIB_CALL
 3159 PDF_pcos_get_stream(
 3160     PDF *p, int doc, int *len, const char *optlist, const char *path, ...)
 3161 {
 3162     static const char fn[] = "PDF_pcos_get_stream";
 3163 
 3164     const unsigned char *result = (const unsigned char *) "";
 3165 
 3166     if (pdf_enter_api(p, fn, pdf_state_all,
 3167     "(p_%p, %d, \"%s\", \"%s\")\n", (void *) p, doc, optlist, path))
 3168     {
 3169         int length = 0;
 3170 
 3171         *len = 0;
 3172         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 3173                              pdc_false);
 3174 
 3175         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%T\", len=%d]\n",
 3176                           result, length, length);
 3177     }
 3178 
 3179     return result;
 3180 }
 3181 
 3182 PDFLIB_API void PDFLIB_CALL
 3183 PDF_place_pdi_page(PDF *p, int page, double x, double y, double sx, double sy)
 3184 {
 3185     static const char fn[] = "PDF_place_pdi_page";
 3186 
 3187     if (pdf_enter_api(p, fn, pdf_state_content,
 3188         "(p_%p, %d, %f, %f, %f, %f)\n", (void *) p, page, x, y, sx, sy))
 3189     {
 3190         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 3191                              pdc_false);
 3192 
 3193         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3194     }
 3195 }
 3196 
 3197 PDFLIB_API int PDFLIB_CALL
 3198 PDF_process_pdi(PDF *p, int doc, int page, const char *optlist)
 3199 {
 3200     static const char fn[] = "PDF_process_pdi";
 3201     int retval = -1;
 3202 
 3203     if (pdf_enter_api(p, fn,
 3204         (pdf_state) (pdf_state_document),
 3205         "(p_%p, %d, %d, \"%T\")\n", (void *) p, doc, page, optlist, 0))
 3206     {
 3207         pdc_set_unsupp_error(p->pdc, PDF_E_UNSUPP_PDI_CONFIG, PDF_E_UNSUPP_PDI,
 3208                              pdc_false);
 3209     }
 3210 
 3211     return pdf_exit_boolean_api(p, retval);
 3212 }
 3213 
 3214 
 3215 /**********************
 3216  *
 3217  *  p_resource.c
 3218  *
 3219  **********************/
 3220 
 3221 PDFLIB_API void PDFLIB_CALL
 3222 PDF_create_pvf(
 3223     PDF *p, const char *filename, int len,
 3224     const void *data, size_t size,
 3225     const char *optlist)
 3226 {
 3227     static const char fn[] = "PDF_create_pvf";
 3228 
 3229     if (pdf_enter_api(p, fn, pdf_state_all,
 3230         "(p_%p, \"%T\", /*c*/%d, data_%p, /*c*/%d, \"%T\")\n",
 3231         (void *) p, filename, len, len, data, size, optlist, 0))
 3232     {
 3233         filename = pdf_convert_filename(p, filename, len, "filename", 0);
 3234         pdc__create_pvf(p->pdc, filename, data, size, optlist);
 3235 
 3236         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 3237     }
 3238 }
 3239 
 3240 PDFLIB_API int PDFLIB_CALL
 3241 PDF_delete_pvf(PDF *p, const char *filename, int len)
 3242 {
 3243     static const char fn[] = "PDF_delete_pvf";
 3244     int retval = -1;
 3245 
 3246     if (pdf_enter_api(p, fn, pdf_state_all,
 3247         "(p_%p, \"%T\", /*c*/%d)\n",
 3248         (void *) p, filename, len, len))
 3249     {
 3250         filename = pdf_convert_filename(p, filename, len, "filename", 0);
 3251         retval = pdc__delete_pvf(p->pdc, filename);
 3252     }
 3253 
 3254     return pdf_exit_boolean_api(p, retval);
 3255 }
 3256 
 3257 
 3258 /**********************
 3259  *
 3260  *  p_shading.c
 3261  *
 3262  **********************/
 3263 
 3264 PDFLIB_API int PDFLIB_CALL
 3265 PDF_shading(
 3266     PDF *p,
 3267     const char *type,
 3268     double x_0, double y_0,
 3269     double x_1, double y_1,
 3270     double c_1, double c_2, double c_3, double c_4,
 3271     const char *optlist)
 3272 {
 3273     static const char fn[] = "PDF_shading";
 3274     int retval = -1;
 3275 
 3276     if (pdf_enter_api(p, fn,
 3277         (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font),
 3278         "(p_%p, \"%s\", %f, %f, %f, %f, %f, %f, %f, %f, \"%T\")\n",
 3279         (void *) p, type, x_0, y_0, x_1, y_1, c_1, c_2, c_3, c_4,
 3280         optlist, 0))
 3281     {
 3282         retval = pdf__shading(p, type, x_0, y_0, x_1, y_1,
 3283                               c_1, c_2, c_3, c_4, optlist);
 3284     }
 3285 
 3286     return pdf_exit_handle_api(p, retval);
 3287 }
 3288 
 3289 PDFLIB_API int PDFLIB_CALL
 3290 PDF_shading_pattern(PDF *p, int shading, const char *optlist)
 3291 {
 3292     static const char fn[] = "PDF_shading_pattern";
 3293     int retval = -1;
 3294 
 3295     if (pdf_enter_api(p, fn,
 3296         (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font),
 3297         "(p_%p, %d, \"%T\")\n", (void *) p, shading, optlist, 0))
 3298     {
 3299         if (p->pdc->hastobepos) shading -= 1;
 3300         retval = pdf__shading_pattern(p, shading, optlist);
 3301     }
 3302 
 3303     return pdf_exit_handle_api(p, retval);
 3304 }
 3305 
 3306 PDFLIB_API void PDFLIB_CALL
 3307 PDF_shfill(PDF *p, int shading)
 3308 {
 3309     static const char fn[] = "PDF_shfill";
 3310     int legal_states;
 3311 
 3312     if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p))
 3313         legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template;
 3314 
 3315     else if (PDF_GET_STATE(p) == pdf_state_pattern &&
 3316         pdf_get_shading_painttype(p) == 2)
 3317         legal_states = pdf_state_page | pdf_state_glyph | pdf_state_template;
 3318 
 3319     else
 3320         legal_states = pdf_state_content;
 3321 
 3322     if (pdf_enter_api(p, fn, (pdf_state) legal_states,
 3323         "(p_%p, %d)\n", (void *) p, shading))
 3324     {
 3325         if (p->pdc->hastobepos) shading -= 1;
 3326         pdf__shfill(p, shading);
 3327 
 3328         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3329     }
 3330 }
 3331 
 3332 
 3333 /**********************
 3334  *
 3335  *  p_table.c
 3336  *
 3337  **********************/
 3338 
 3339 PDFLIB_API int PDFLIB_CALL
 3340 PDF_add_table_cell(PDF *p, int table, int column, int row, const char *text,
 3341     int len, const char *optlist)
 3342 {
 3343     static const char fn[] = "PDF_add_table_cell";
 3344     int retval = -1;
 3345 
 3346     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3347         "(p_%p, %d, %d, %d, \"%T\", /*c*/%d, \"%T\")\n",
 3348         (void *) p, table, column, row, text, len, len, optlist, 0))
 3349     {
 3350         pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0);
 3351     }
 3352 
 3353     return pdf_exit_handle_api(p, retval);
 3354 }
 3355 
 3356 PDFLIB_API void PDFLIB_CALL
 3357 PDF_delete_table(PDF *p, int table, const char *optlist)
 3358 {
 3359     static const char fn[] = "PDF_delete_table";
 3360 
 3361     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3362         "(p_%p, %d, \"%T\")\n", (void *) p, table, optlist, 0))
 3363     {
 3364         pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0);
 3365 
 3366         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3367     }
 3368 }
 3369 
 3370 PDFLIB_API const char * PDFLIB_CALL
 3371 PDF_fit_table(PDF *p, int table, double llx, double lly,
 3372     double urx, double ury, const char *optlist)
 3373 {
 3374     static const char fn[] = "PDF_fit_table";
 3375     const char *retval = "";
 3376 
 3377     if (pdf_enter_api(p, fn, pdf_state_content,
 3378         "(p_%p, %d, %f, %f, %f, %f, \"%T\")\n",
 3379         (void *) p, table, llx, lly, urx, ury, optlist, 0))
 3380     {
 3381         pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0);
 3382 
 3383         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%s\"]\n", retval);
 3384     }
 3385 
 3386     return retval;
 3387 }
 3388 
 3389 PDFLIB_API double PDFLIB_CALL
 3390 PDF_info_table(PDF *p, int table, const char *keyword)
 3391 {
 3392     static const char fn[] = "PDF_info_table";
 3393     double retval = -1;
 3394 
 3395     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3396         "(p_%p, %d, \"%s\")\n", (void *) p, table, keyword))
 3397     {
 3398         pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0);
 3399 
 3400         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 3401     }
 3402 
 3403     return retval;
 3404 }
 3405 
 3406 
 3407 /**********************
 3408  *
 3409  *  p_tagged.c
 3410  *
 3411  **********************/
 3412 
 3413 PDFLIB_API void PDFLIB_CALL
 3414 PDF_begin_mc(PDF *p, const char *tag, const char *optlist)
 3415 {
 3416     static const char fn[] = "PDF_begin_mc";
 3417 
 3418     if (pdf_enter_api(p, fn, pdf_state_content,
 3419         "(p_%p, \"%s\", \"%T\")\n", (void *) p, tag, optlist, 0))
 3420     {
 3421         pdc_error(p->pdc, PDF_E_UNSUPP_MC, 0, 0, 0, 0);
 3422 
 3423         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3424     }
 3425 }
 3426 
 3427 PDFLIB_API void PDFLIB_CALL
 3428 PDF_end_mc(PDF *p)
 3429 {
 3430     static const char fn[] = "PDF_end_mc";
 3431 
 3432     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p", (void *) p))
 3433     {
 3434         pdc_error(p->pdc, PDF_E_UNSUPP_MC, 0, 0, 0, 0);
 3435 
 3436         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3437     }
 3438 }
 3439 
 3440 PDFLIB_API void PDFLIB_CALL
 3441 PDF_mc_point(PDF *p, const char *tag, const char *optlist)
 3442 {
 3443     static const char fn[] = "PDF_mc_point";
 3444 
 3445     if (pdf_enter_api(p, fn, pdf_state_content,
 3446         "(p_%p, \"%s\", \"%T\")\n", (void *) p, tag, optlist, 0))
 3447     {
 3448         pdc_error(p->pdc, PDF_E_UNSUPP_MC, 0, 0, 0, 0);
 3449 
 3450         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3451     }
 3452 }
 3453 
 3454 PDFLIB_API void PDFLIB_CALL
 3455 PDF_activate_item(PDF *p, int id)
 3456 {
 3457     static const char fn[] = "PDF_activate_item";
 3458 
 3459     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3460         "(p_%p, %d)\n", (void *) p, id))
 3461     {
 3462         pdc_error(p->pdc, PDF_E_UNSUPP_TAGGED, 0, 0, 0, 0);
 3463 
 3464         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3465     }
 3466 }
 3467 
 3468 PDFLIB_API int PDFLIB_CALL
 3469 PDF_begin_item(
 3470     PDF *p,
 3471     const char *tag,
 3472     const char *optlist)
 3473 {
 3474     static const char fn[] = "PDF_begin_item";
 3475     int retval = -1;
 3476 
 3477     /* further check in kernel function */
 3478     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3479         "(p_%p, \"%s\", \"%T\")\n", (void *) p, tag, optlist, 0))
 3480     {
 3481         pdc_error(p->pdc, PDF_E_UNSUPP_TAGGED, 0, 0, 0, 0);
 3482 
 3483         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 3484     }
 3485     return retval;
 3486 }
 3487 
 3488 PDFLIB_API void PDFLIB_CALL
 3489 PDF_end_item(PDF *p, int id)
 3490 {
 3491     static const char fn[] = "PDF_end_item";
 3492 
 3493     /* further check in kernel function */
 3494     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3495         "(p_%p, %d)\n", (void *) p, id))
 3496     {
 3497         pdc_error(p->pdc, PDF_E_UNSUPP_TAGGED, 0, 0, 0, 0);
 3498 
 3499         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3500     }
 3501 }
 3502 
 3503 
 3504 /**********************
 3505  *
 3506  *  p_template.c
 3507  *
 3508  **********************/
 3509 
 3510 PDFLIB_API int PDFLIB_CALL
 3511 PDF_begin_template(PDF *p, double width, double height)
 3512 {
 3513     static const char fn[] = "\nPDF_begin_template";
 3514     int retval = -1;
 3515 
 3516     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3517         "(p_%p, %f, %f)\n", (void *) p, width, height))
 3518     {
 3519         pdf_logg_is_deprecated(p, fn, 7);
 3520 
 3521         retval = pdf__begin_template(p, width, height, "");
 3522     }
 3523 
 3524     return pdf_exit_handle_api(p, retval);
 3525 }
 3526 
 3527 PDFLIB_API int PDFLIB_CALL
 3528 PDF_begin_template_ext(PDF *p, double width, double height, const char *optlist)
 3529 {
 3530     static const char fn[] = "\nPDF_begin_template_ext";
 3531     int retval = -1;
 3532 
 3533     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3534         "(p_%p, %f, %f, \"%T\")\n", (void *) p, width, height, optlist, 0))
 3535     {
 3536         retval = pdf__begin_template(p, width, height, optlist);
 3537     }
 3538 
 3539     return pdf_exit_handle_api(p, retval);
 3540 }
 3541 
 3542 PDFLIB_API void PDFLIB_CALL
 3543 PDF_end_template(PDF *p)
 3544 {
 3545     static const char fn[] = "PDF_end_template";
 3546 
 3547     if (pdf_enter_api(p, fn, pdf_state_template, "(p_%p)\n", (void *) p))
 3548     {
 3549         pdf__end_template(p);
 3550 
 3551         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 3552     }
 3553 }
 3554 
 3555 
 3556 /**********************
 3557  *
 3558  *  p_text.c
 3559  *
 3560  **********************/
 3561 
 3562 PDFLIB_API void PDFLIB_CALL
 3563 PDF_continue_text(PDF *p, const char *text)
 3564 {
 3565     static const char fn[] = "PDF_continue_text";
 3566     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, \"%T\")\n",
 3567         (void *) p, text, 0))
 3568     {
 3569         int len = text ? (int) strlen(text) : 0;
 3570         pdf__show_text(p, text, len, pdc_true);
 3571 
 3572         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3573     }
 3574 }
 3575 
 3576 PDFLIB_API void PDFLIB_CALL
 3577 PDF_continue_text2(PDF *p, const char *text, int len)
 3578 {
 3579     static const char fn[] = "PDF_continue_text2";
 3580     if (pdf_enter_api(p, fn, pdf_state_content,
 3581         "(p_%p, \"%T\", /*c*/%d)\n", (void *) p, text, len, len))
 3582     {
 3583         pdf__show_text(p, text, len, pdc_true);
 3584 
 3585         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3586     }
 3587 }
 3588 
 3589 PDFLIB_API void PDFLIB_CALL
 3590 PDF_fit_textline(PDF *p, const char *text, int len, double x, double y,
 3591                  const char *optlist)
 3592 {
 3593     static const char fn[] = "PDF_fit_textline";
 3594 
 3595     if (pdf_enter_api(p, fn, pdf_state_content,
 3596         "(p_%p, \"%T\", /*c*/%d, %f, %f, \"%T\")\n",
 3597         (void *) p, text, len, len, x, y, optlist, 0))
 3598     {
 3599         pdf__fit_textline(p, text, len, x, y, optlist);
 3600 
 3601         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3602     }
 3603 }
 3604 
 3605 PDFLIB_API double PDFLIB_CALL
 3606 PDF_info_textline(PDF *p, const char *text, int len, const char *keyword,
 3607                   const char *optlist)
 3608 {
 3609     static const char fn[] = "PDF_info_textline";
 3610     double retval = 0;
 3611 
 3612     if (pdf_enter_api(p, fn,
 3613         (pdf_state) (pdf_state_document | pdf_state_content |
 3614                      pdf_state_path | pdf_state_font),
 3615         "(p_%p, \"%T\", /*c*/%d, \"%s\", \"%T\")\n",
 3616         (void *) p, text, len, len, keyword, optlist, 0))
 3617     {
 3618         retval = pdf__info_textline(p, text, len, keyword, optlist);
 3619 
 3620         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 3621     }
 3622 
 3623     return retval;
 3624 }
 3625 
 3626 PDFLIB_API void PDFLIB_CALL
 3627 PDF_setfont(PDF *p, int font, double fontsize)
 3628 {
 3629     static const char fn[] = "PDF_setfont";
 3630 
 3631     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %d, %f)\n",
 3632         (void *) p, font, fontsize))
 3633     {
 3634         if (p->pdc->hastobepos) font -= 1;
 3635         pdf__setfont(p, font, fontsize);
 3636 
 3637         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 3638     }
 3639 }
 3640 
 3641 PDFLIB_API void PDFLIB_CALL
 3642 PDF_set_text_pos(PDF *p, double x, double y)
 3643 {
 3644     static const char fn[] = "PDF_set_text_pos";
 3645 
 3646     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f)\n",
 3647         (void *) p, x, y))
 3648     {
 3649         pdf__set_text_pos(p, x, y);
 3650 
 3651         pdc_logg_exit_api(p->pdc, pdc_false, NULL);
 3652     }
 3653 }
 3654 
 3655 PDFLIB_API void PDFLIB_CALL
 3656 PDF_show(PDF *p, const char *text)
 3657 {
 3658     static const char fn[] = "PDF_show";
 3659     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, \"%T\")\n",
 3660         (void *) p, text, 0))
 3661     {
 3662         int len = text ? (int) strlen(text) : 0;
 3663 
 3664         pdf__show_text(p, text, len, pdc_false);
 3665 
 3666         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3667     }
 3668 }
 3669 
 3670 PDFLIB_API void PDFLIB_CALL
 3671 PDF_show2(PDF *p, const char *text, int len)
 3672 {
 3673     static const char fn[] = "PDF_show2";
 3674     if (pdf_enter_api(p, fn, pdf_state_content,
 3675         "(p_%p, \"%T\", /*c*/%d)\n", (void *) p, text, len, len))
 3676     {
 3677         pdf__show_text(p, text, len, pdc_false);
 3678 
 3679         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3680     }
 3681 }
 3682 
 3683 PDFLIB_API int PDFLIB_CALL
 3684 PDF_show_boxed(
 3685     PDF *p,
 3686     const char *text,
 3687     double left,
 3688     double bottom,
 3689     double width,
 3690     double height,
 3691     const char *hmode,
 3692     const char *feature)
 3693 {
 3694     static const char fn[] = "PDF_show_boxed";
 3695     int retval = -1;
 3696 
 3697     if (pdf_enter_api(p, fn, pdf_state_content,
 3698         "(p_%p, \"%T\", %f, %f, %f, %f, \"%s\", \"%s\")\n",
 3699         (void *) p, text, 0, left, bottom, width, height, hmode, feature))
 3700     {
 3701         pdf_logg_is_deprecated(p, fn, 6);
 3702 
 3703         retval = pdf__show_boxed(p, text, 0, left, bottom, width, height,
 3704                                  hmode, feature);
 3705 
 3706         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 3707     }
 3708 
 3709     return retval;
 3710 }
 3711 
 3712 PDFLIB_API int PDFLIB_CALL
 3713 PDF_show_boxed2(
 3714     PDF *p,
 3715     const char *text,
 3716     int len,
 3717     double left,
 3718     double bottom,
 3719     double width,
 3720     double height,
 3721     const char *hmode,
 3722     const char *feature)
 3723 {
 3724     static const char fn[] = "PDF_show_boxed2";
 3725     int retval = -1;
 3726 
 3727     if (pdf_enter_api(p, fn, pdf_state_content,
 3728         "(p_%p, \"%T\", /*c*/%d, %f, %f, %f, %f, \"%s\", \"%s\")\n",
 3729         (void *) p, text, len, len, left, bottom, width, height,
 3730         hmode, feature))
 3731     {
 3732         pdf_logg_is_deprecated(p, fn, 6);
 3733 
 3734         retval = pdf__show_boxed(p, text, len, left, bottom, width, height,
 3735                                    hmode, feature);
 3736 
 3737         pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval);
 3738     }
 3739 
 3740     return retval;
 3741 }
 3742 
 3743 PDFLIB_API void PDFLIB_CALL
 3744 PDF_show_xy(PDF *p, const char *text, double x, double y)
 3745 {
 3746     static const char fn[] = "PDF_show_xy";
 3747     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, \"%T\", %f, %f)\n",
 3748         (void *) p, text, 0, x, y))
 3749     {
 3750         int len = text ? (int) strlen(text) : 0;
 3751         pdf__set_text_pos(p, x, y);
 3752         pdf__show_text(p, text, len, pdc_false);
 3753 
 3754         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3755     }
 3756 }
 3757 
 3758 PDFLIB_API void PDFLIB_CALL
 3759 PDF_show_xy2(PDF *p, const char *text, int len, double x, double y)
 3760 {
 3761     static const char fn[] = "PDF_show_xy2";
 3762     if (pdf_enter_api(p, fn, pdf_state_content,
 3763         "(p_%p, \"%T\", /*c*/%d, %f, %f)\n",
 3764         (void *) p, text, len, len, x, y))
 3765     {
 3766         pdf__set_text_pos(p, x, y);
 3767         pdf__show_text(p, text, len, pdc_false);
 3768 
 3769         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3770     }
 3771 }
 3772 
 3773 PDFLIB_API double PDFLIB_CALL
 3774 PDF_stringwidth(PDF *p, const char *text, int font, double fontsize)
 3775 {
 3776     static const char fn[] = "PDF_stringwidth";
 3777     double retval = -1;
 3778 
 3779     if (pdf_enter_api(p, fn,
 3780         (pdf_state) (pdf_state_document | pdf_state_content |
 3781                      pdf_state_path | pdf_state_font),
 3782         "(p_%p, \"%T\", %d, %f)\n",
 3783         (void *) p, text, 0, font, fontsize))
 3784     {
 3785         int len = text ? (int) strlen(text) : 0;
 3786         if (p->pdc->hastobepos) font -= 1;
 3787         retval = pdf__stringwidth(p, text, len, font, fontsize);
 3788 
 3789         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 3790     }
 3791 
 3792     return retval;
 3793 }
 3794 
 3795 PDFLIB_API double PDFLIB_CALL
 3796 PDF_stringwidth2(PDF *p, const char *text, int len, int font, double fontsize)
 3797 {
 3798     static const char fn[] = "PDF_stringwidth2";
 3799     double retval = -1;
 3800 
 3801     if (pdf_enter_api(p, fn,
 3802         (pdf_state) (pdf_state_document | pdf_state_content |
 3803                      pdf_state_path | pdf_state_font),
 3804         "(p_%p, \"%T\", /*c*/%d, %d, %f)\n",
 3805         (void *) p, text, len, len, font, fontsize))
 3806     {
 3807         if (p->pdc->hastobepos) font -= 1;
 3808         retval = pdf__stringwidth(p, text, len, font, fontsize);
 3809 
 3810         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 3811     }
 3812 
 3813     return retval;
 3814 }
 3815 
 3816 PDFLIB_API void PDFLIB_CALL
 3817 PDF_xshow(PDF *p, const char *text, int len, const double *xadvancelist)
 3818 {
 3819     static const char fn[] = "PDF_xshow";
 3820     if (pdf_enter_api(p, fn, pdf_state_content,
 3821         "(p_%p, \"%T\", %d, %p)\n", (void *) p, text, len, len, xadvancelist))
 3822     {
 3823         pdf_logg_is_unsupported(p, fn);
 3824 
 3825         pdf__xshow(p, text, len, xadvancelist);
 3826 
 3827         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3828     }
 3829 }
 3830 
 3831 
 3832 /**********************
 3833  *
 3834  *  p_textflow.c
 3835  *
 3836  **********************/
 3837 
 3838 PDFLIB_API int PDFLIB_CALL
 3839 PDF_add_textflow(PDF *p, int textflow, const char *text, int len,
 3840     const char *optlist)
 3841 {
 3842     static const char fn[] = "PDF_add_textflow";
 3843     int retval = -1;
 3844 
 3845     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3846         "(p_%p, %d, \"%T\", /*c*/%d, \"%T\")\n",
 3847         (void *) p, textflow, text, len, len, optlist, 0))
 3848     {
 3849         pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0);
 3850     }
 3851 
 3852     return pdf_exit_handle_api(p, retval);
 3853 }
 3854 
 3855 PDFLIB_API int PDFLIB_CALL
 3856 PDF_create_textflow(PDF *p, const char *text, int len, const char *optlist)
 3857 {
 3858     static const char fn[] = "PDF_create_textflow";
 3859     int retval = -1;
 3860 
 3861     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3862         "(p_%p, \"%T\", /*c*/%d, \"%T\")\n",
 3863         (void *) p, text, len, len, optlist, 0))
 3864     {
 3865         pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0);
 3866     }
 3867 
 3868     return pdf_exit_handle_api(p, retval);
 3869 }
 3870 
 3871 PDFLIB_API void PDFLIB_CALL
 3872 PDF_delete_textflow(PDF *p, int textflow)
 3873 {
 3874     static const char fn[] = "PDF_delete_textflow";
 3875 
 3876     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3877         "(p_%p, %d)\n", (void *) p, textflow))
 3878     {
 3879         pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0);
 3880 
 3881         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3882     }
 3883 }
 3884 
 3885 PDFLIB_API const char * PDFLIB_CALL
 3886 PDF_fit_textflow(
 3887     PDF *p,
 3888     int textflow,
 3889     double llx,
 3890     double lly,
 3891     double urx,
 3892     double ury,
 3893     const char *optlist)
 3894 {
 3895     static const char fn[] = "PDF_fit_textflow";
 3896     const char *retval = "";
 3897 
 3898     if (pdf_enter_api(p, fn, pdf_state_content,
 3899         "(p_%p, %d, %f, %f, %f, %f, \"%T\")\n",
 3900         (void *) p, textflow, llx, lly, urx, ury, optlist, 0))
 3901     {
 3902         pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0);
 3903 
 3904         pdc_logg_exit_api(p->pdc, pdc_true, "[\"%s\"]\n", retval);
 3905     }
 3906 
 3907     return retval;
 3908 }
 3909 
 3910 PDFLIB_API double PDFLIB_CALL
 3911 PDF_info_textflow(PDF *p, int textflow, const char *keyword)
 3912 {
 3913     static const char fn[] = "PDF_info_textflow";
 3914     double retval = -1;
 3915 
 3916     if (pdf_enter_api(p, fn, pdf_state_documentall,
 3917         "(p_%p, %d, \"%s\")\n", (void *) p, textflow, keyword))
 3918     {
 3919         pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0);
 3920 
 3921         pdc_logg_exit_api(p->pdc, pdc_true, "[%f]\n", retval);
 3922     }
 3923 
 3924     return retval;
 3925 }
 3926 
 3927 
 3928 /**********************
 3929  *
 3930  *  p_type3.c
 3931  *
 3932  **********************/
 3933 
 3934 PDFLIB_API void PDFLIB_CALL
 3935 PDF_begin_font(
 3936     PDF *p,
 3937     const char *fontname, int len,
 3938     double a, double b, double c, double d, double e, double f,
 3939     const char *optlist)
 3940 {
 3941     static const char fn[] = "\nPDF_begin_font";
 3942 
 3943     if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page),
 3944         "(p_%p, \"%T\", /*c*/%d, %f, %f, %f, %f, %f, %f, \"%T\")\n",
 3945         (void *) p, fontname, len, len, a, b, c, d, e, f, optlist, 0))
 3946     {
 3947         pdf__begin_font(p, fontname, len, a, b, c, d, e, f, optlist);
 3948 
 3949         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3950     }
 3951 }
 3952 
 3953 PDFLIB_API void PDFLIB_CALL
 3954 PDF_begin_glyph(
 3955     PDF *p,
 3956     const char *glyphname,
 3957     double wx, double llx, double lly, double urx, double ury)
 3958 {
 3959     static const char fn[] = "\nPDF_begin_glyph";
 3960 
 3961     if (pdf_enter_api(p, fn, pdf_state_font,
 3962         "(p_%p, \"%s\", %f, %f, %f, %f, %f)\n",
 3963         (void *) p, glyphname, wx, llx, lly, urx, ury))
 3964     {
 3965         pdf__begin_glyph(p, glyphname, wx, llx, lly, urx, ury);
 3966 
 3967         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3968     }
 3969 }
 3970 
 3971 PDFLIB_API void PDFLIB_CALL
 3972 PDF_end_font(PDF *p)
 3973 {
 3974     static const char fn[] = "\nPDF_end_font";
 3975 
 3976     if (pdf_enter_api(p, fn, pdf_state_font, "(p_%p)\n", (void *) p))
 3977     {
 3978         pdf__end_font(p);
 3979 
 3980         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3981     }
 3982 }
 3983 
 3984 
 3985 PDFLIB_API void PDFLIB_CALL
 3986 PDF_end_glyph(PDF *p)
 3987 {
 3988     static const char fn[] = "PDF_end_glyph";
 3989 
 3990     if (pdf_enter_api(p, fn,
 3991             (pdf_state) (pdf_state_glyph | pdf_state_glyphmetrics |
 3992                          pdf_state_glyphignore),
 3993             "(p_%p)\n", (void *) p))
 3994     {
 3995         pdf__end_glyph(p);
 3996 
 3997         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 3998     }
 3999 }
 4000 
 4001 
 4002 /**********************
 4003  *
 4004  *  p_util.c
 4005  *
 4006  **********************/
 4007 
 4008 PDFLIB_API const char * PDFLIB_CALL
 4009 PDF_utf16_to_utf8(PDF *p, const char *utf16string, int len, int *size)
 4010 {
 4011     static const char fn[] = "PDF_utf16_to_utf8";
 4012     const char *retval = "";
 4013 
 4014     if (pdf__check_context(p))
 4015     {
 4016         if (p->pdc->unicaplang)
 4017         {
 4018             retval = pdf__utf16_to_utf8(p, utf16string, len, size);
 4019         }
 4020         else
 4021         {
 4022             pdc_logg_cond(p->pdc, 1, trc_api, "/* ");
 4023             if (pdf_enter_api(p, fn, pdf_state_all,
 4024                 size ? "(p_%p, \"%T\", %d, &size_%p)" :
 4025                        "(p_%p, \"%s\", %d, NULL) */\n",
 4026                 (void *) p, utf16string, len, len, (void *) size))
 4027             {
 4028                 retval = pdf__utf16_to_utf8(p, utf16string, len, size);
 4029             }
 4030 
 4031             pdc_logg_exit_api(p->pdc, pdc_false, "/* [\"%T\", size=%d] */\n",
 4032                                retval, 0, size ? *size : 0);
 4033         }
 4034     }
 4035 
 4036     return retval;
 4037 }
 4038 
 4039 PDFLIB_API const char * PDFLIB_CALL
 4040 PDF_utf32_to_utf16(PDF *p, const char *utf32string, int len,
 4041    const char *ordering, int *size)
 4042 {
 4043     static const char fn[] = "PDF_utf32_to_utf16";
 4044     const char *retval = "";
 4045 
 4046     if (pdf__check_context(p))
 4047     {
 4048         if (p->pdc->unicaplang)
 4049         {
 4050             retval = pdf__utf32_to_utf16(p, utf32string, len, ordering, size);
 4051         }
 4052         else
 4053         {
 4054             if (size == NULL)
 4055                 pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "size", 0, 0, 0);
 4056 
 4057             pdc_logg_cond(p->pdc, 1, trc_api, "/* ");
 4058             if (pdf_enter_api(p, fn, pdf_state_all,
 4059                 "(p_%p, \"%T\", %d, \"%s\", &size_%p) */\n",
 4060                 (void *) p, utf32string, len, len, ordering, (void *) size))
 4061             {
 4062                 retval = pdf__utf32_to_utf16(p, utf32string,
 4063                         len, ordering, size);
 4064             }
 4065 
 4066             pdc_logg_exit_api(p->pdc, pdc_false, "/* [\"%T\", size=%d] */\n",
 4067                                retval, *size, *size);
 4068         }
 4069     }
 4070 
 4071     return retval;
 4072 }
 4073 
 4074 PDFLIB_API const char * PDFLIB_CALL
 4075 PDF_utf8_to_utf16(PDF *p, const char *utf8string, const char *format,
 4076    int *size)
 4077 {
 4078     static const char fn[] = "PDF_utf8_to_utf16";
 4079     const char *retval = "";
 4080 
 4081     if (pdf__check_context(p))
 4082     {
 4083         if (p->pdc->unicaplang)
 4084         {
 4085             retval = pdf__utf8_to_utf16(p, utf8string, format, size);
 4086         }
 4087         else
 4088         {
 4089             if (size == NULL)
 4090                 pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "size", 0, 0, 0);
 4091 
 4092             pdc_logg_cond(p->pdc, 1, trc_api, "/* ");
 4093             if (pdf_enter_api(p, fn, pdf_state_all,
 4094                 "(p_%p, \"%T\", \"%s\", &size_%p) */\n",
 4095                 (void *) p, utf8string, 0, format, (void *) size))
 4096             {
 4097                 retval = pdf__utf8_to_utf16(p, utf8string, format, size);
 4098             }
 4099 
 4100             pdc_logg_exit_api(p->pdc, pdc_false, "/* [\"%T\", size=%d] */\n",
 4101                               retval, *size, *size);
 4102         }
 4103     }
 4104 
 4105     return retval;
 4106 }
 4107 
 4108 
 4109 /**********************
 4110  *
 4111  *  p_xgstate.c
 4112  *
 4113  **********************/
 4114 
 4115 PDFLIB_API int PDFLIB_CALL
 4116 PDF_create_gstate(PDF *p, const char *optlist)
 4117 {
 4118     static const char fn[] = "PDF_create_gstate";
 4119     int retval = -1;
 4120 
 4121     if (pdf_enter_api(p, fn,
 4122         (pdf_state) (pdf_state_document | pdf_state_content),
 4123         "(p_%p, \"%T\")\n", (void *) p, optlist, 0))
 4124     {
 4125         retval = pdf__create_gstate(p, optlist);
 4126     }
 4127 
 4128     return pdf_exit_handle_api(p, retval);
 4129 }
 4130 
 4131 PDFLIB_API void PDFLIB_CALL
 4132 PDF_set_gstate(PDF *p, int gstate)
 4133 {
 4134     static const char fn[] = "PDF_set_gstate";
 4135 
 4136     if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %d)\n",
 4137         (void *) p, gstate))
 4138     {
 4139         if (p->pdc->hastobepos) gstate -= 1;
 4140         pdf__set_gstate(p, gstate);
 4141 
 4142         pdc_logg_exit_api(p->pdc, pdc_true, NULL);
 4143     }
 4144 }