int pdf_insert_utilstring(PDF *p, const char *utilstring, pdc_bool kdup) { static const char fn[] = "pdf_insert_utilstring"; char **utilstrlist; int i = 0; if (p->utilstrlist_index == -1) { utilstrlist = (char **) pdc_calloc(p->pdc, PDF_MAX_UTILSTRLISTS * sizeof (char *), fn); p->utilstrlist_index = pdf_insert_stringlist(p, utilstrlist, PDF_MAX_UTILSTRLISTS); } utilstrlist = p->stringlists[p->utilstrlist_index]; if (p->utilstring_number >= PDF_MAX_UTILSTRLISTS) p->utilstring_number = 0; i = p->utilstring_number; if (utilstrlist[i] != NULL) pdc_free(p->pdc, utilstrlist[i]); if (kdup) utilstrlist[i] = pdc_strdup_ext(p->pdc, utilstring, 0, fn); else utilstrlist[i] = (char *) utilstring; p->utilstring_number++; return i; }
char * pdc_get_filename(pdc_core *pdc, char *filename) { char *ffname; #if defined(PDC_UNICODE_FILENAME) static const char fn[] = "pdc_get_filename"; ffname = pdc_strdup_ext(pdc, filename, 0, fn); #else ffname = pdc_hostbytes_to_utf8(pdc, pdc->honorlang, filename); #endif return ffname; }
pdc_bool pdf_get_metrics_afm( PDF *p, pdf_font *font, const char *fontname, pdc_encoding enc, const char *filename, pdc_bool requested) { static const char fn[] = "pdf_get_metrics_afm"; char fullname[PDC_FILENAMELEN]; pdc_file *afmfile; /* open AFM file */ afmfile = pdc_fsearch_fopen(p->pdc, filename, fullname, "AFM ", PDC_FILE_TEXT); if (afmfile == NULL) return pdc_check_fopen_errmsg(p->pdc, requested); pdc_logg_cond(p->pdc, 1, trc_font, "\tLoading AFM metric fontfile \"%s\":\n", fullname); /* parse AFM file */ if (pdf_parse_afm(p, afmfile, font, fontname, fullname) == pdc_false) return pdc_false; /* members not fount */ if (font->ft.m.type == fnt_unknownType) font->ft.m.type = fnt_Type1; if (font->ft.name == NULL) { font->ft.name = pdc_strdup(p->pdc, fontname); font->ft.m.name = pdc_strdup(p->pdc, fontname); } /* save full filename */ font->metricfilename = pdc_strdup_ext(p->pdc, fullname, 0, fn); /* process metric data */ font->ft.enc = enc; if (pdf_process_metrics_data(p, font, fontname) == pdc_false) return pdc_false; if (!pdf_make_fontflag(p, font)) return pdc_false; return pdc_true; }
pdc_vtr * pdf_new_mboxes(PDF *p, pdf_mbox *mbox, pdc_vtr *mboxes) { static const char fn[] = "pdf_new_mboxes"; char *name = mbox->name; if (mboxes == NULL) mboxes = pdc_vtr_new(p->pdc, &pdf_mbox_ced, p, &pdf_mbox_parms); if (mbox->name != NULL) mbox->name = pdc_strdup_ext(p->pdc, mbox->name, 0, fn); pdc_vtr_push(mboxes, *mbox, pdf_mbox); mbox->name = name; return mboxes; }
pdc_bool pdf_get_metrics_pfm( PDF *p, pdf_font *font, const char *fontname, pdc_encoding enc, const char *filename, pdc_bool requested) { static const char fn[] = "pdf_get_metrics_pfm"; char fullname[PDC_FILENAMELEN]; pdc_file *pfmfile; (void) fontname; /* open PFM file */ pfmfile = pdc_fsearch_fopen(p->pdc, filename, fullname, "PFM ", PDC_FILE_BINARY); if (pfmfile == NULL) return pdc_check_fopen_errmsg(p->pdc, requested); pdc_logg_cond(p->pdc, 1, trc_font, "\tLoading PFM metric fontfile \"%s\":\n", fullname); /* Read PFM metrics */ if (!pdf_parse_pfm(p, pfmfile, font)) { pdc_set_errmsg(p->pdc, PDF_E_FONT_CORRUPT, "PFM", fullname, 0, 0); return pdc_false; } /* save full filename */ font->metricfilename = pdc_strdup_ext(p->pdc, fullname, 0, fn); /* Check encoding */ if (!pdf_check_pfm_encoding(p, font, enc)) return pdc_false; if (!pdf_make_fontflag(p, font)) return pdc_false; return pdc_true; }
void pdc_push_errmsg( pdc_core * pdc, int errnum, const char *parm1, const char *parm2, const char *parm3, const char *parm4) { static const char fn[] = "pdc_push_errmsg"; const pdc_error_info *ei = get_error_info(pdc, errnum); pdc_pop_errmsg(pdc); make_errmsg(pdc, ei, parm1, parm2, parm3, parm4, pdc_false); pdc->pr->premsg = pdc_strdup_ext(pdc, pdc->pr->errbuf, 0, fn); } /* pdc_push_errmsg */
/* * flags: PDC_INT_HEXADEC, PDC_INT_CASESENS */ int pdc_get_keycode_num(pdc_core *pdc, const char *option, const char *i_keyword, int flags, const pdc_keyconn *keyconn, int *o_num) { static const char *fn = "pdc_get_keycode_num"; char *keyword; int i, len, keycode; keyword = pdc_strdup_ext(pdc, i_keyword, 0, fn); len = (int) strlen(keyword); *o_num = -1; /* parse number */ for (i = 0; i < len; i++) { if (pdc_isdigit(keyword[i])) { if (pdc_str2integer(&keyword[i], flags, o_num)) { keyword[i] = 0; } else { pdc_set_errmsg(pdc, PDC_E_OPT_ILLINTEGER, option, &keyword[i], 0, 0); } break; } } if (flags & PDC_INT_CASESENS) keycode = pdc_get_keycode(keyword, keyconn); else keycode = pdc_get_keycode_ci(keyword, keyconn); if (keycode == PDC_KEY_NOTFOUND) pdc_set_errmsg(pdc, PDC_E_OPT_ILLKEYWORD, option, keyword, 0, 0); pdc_free(pdc, keyword); return keycode; }
pdc_file * pdc_fopen(pdc_core *pdc, const char *filename, const char *qualifier, const pdc_byte *data, size_t size, int flags) { static const char fn[] = "pdc_fopen"; pdc_file *sfp; sfp = (pdc_file *) pdc_calloc(pdc, sizeof(pdc_file), fn); /* initialize */ sfp->pdc = pdc; sfp->filename = pdc_strdup_ext(pdc, filename, 0, fn); if (flags & PDC_FILE_WRITEMODE || flags & PDC_FILE_APPENDMODE) sfp->wrmode = pdc_true; if (data != NULL || size > 0) { /* virtual file */ if (sfp->wrmode) { sfp->data = (pdc_byte *) pdc_calloc(pdc, size, fn); if (data != NULL) { /* append mode */ memcpy(sfp->data, data, size); sfp->pos = sfp->data + size; } else { sfp->pos = sfp->data; } sfp->end = sfp->pos; sfp->limit = sfp->data + size; } else { sfp->data = (pdc_byte *) data; sfp->pos = sfp->data; sfp->end = sfp->data + size; } } else { const char *mode; /* disk file */ if (flags & PDC_FILE_BINARY) mode = READBMODE; else mode = READTMODE; if (flags & PDC_FILE_APPENDMODE) mode = APPENDMODE; else if (flags & PDC_FILE_WRITEMODE) mode = WRITEMODE; sfp->fp = pdc_fopen_logg(pdc, filename, mode); if (sfp->fp == NULL) { pdc_fclose(sfp); if (qualifier == NULL) qualifier = ""; pdc_set_fopen_errmsg(pdc, PDC_E_IO_RDOPEN, qualifier, filename); return NULL; } } return sfp; }