void pdc_bs_toupper(pdc_bstr *s) { pdc_byte * buf = s->buf ? s->buf : s->buf0; int i; for (i = 0; i < (int) s->len; ++i) buf[i] = pdc_toupper(buf[i]); } /* pdc_bs_toupper */
static int PFA_data_fill(PDF *p, PDF_data_source *src) { static const char *fn = "PFA_data_fill"; pdc_bool logg6 = pdc_logg_is_enabled(p->pdc, 6, trc_font); #ifndef PDFLIB_EBCDIC static const char HexToBin['F' - '0' + 1] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15 }; #else #endif char *s, *c; int i; int len; t1_private_data *t1; pdf_t1portion t1portion; t1 = (t1_private_data *) src->private_data; if (t1->portion == t1_eof) return pdc_false; if (src->buffer_start == NULL) { src->buffer_start = (pdc_byte *) pdc_malloc(p->pdc, PDC_BUFSIZE + 1, fn); src->buffer_length = PDC_BUFSIZE; } if (logg6) pdc_logg(p->pdc, "\t\t\tdata fill: portion=%s\n", pdc_get_keyword(t1->portion, pdf_t1portion_keylist)); s = pdc_fgetline((char *) src->buffer_start, PDC_BUFSIZE, t1->fontfile); if (s == NULL) return pdc_false; /* set unix line end */ len = (int) strlen(s); s[len] = '\n'; len++; s[len] = 0; /* check for line of zeros: set t1_zero flag if found */ if (*s == '0') { for (i = 0; s[i] == '0'; i++) { /* */ ; } if (s[i] == '\n') { t1->portion = t1_zeros; if (logg6) pdc_logg(p->pdc, "\t\t\tlinefeed detected: set portion %s\n", pdc_get_keyword(t1->portion, pdf_t1portion_keylist)); } } /* check whether font data portion follows: set t1_encrypted flag later */ t1portion = t1->portion; if (t1->portion != t1_encrypted && !strncmp((const char *)s, PDF_CURRENTFILE, strlen(PDF_CURRENTFILE))) { t1portion = t1_encrypted; if (logg6) pdc_logg(p->pdc, "\t\t\t\"%s\" detected\n", PDF_CURRENTFILE); } src->next_byte = src->buffer_start; switch (t1->portion) { case t1_ascii: { t1->length[1] += (size_t) len; src->bytes_available = (size_t) len; } break; case t1_encrypted: { src->bytes_available = 0; /* Convert to upper case for safe binary conversion */ for (c = s; *c != '\n'; c++) { *c = (char) pdc_toupper(*c); } /* convert ASCII to binary in-place */ for (i = 0; s[i] != '\n'; i += 2) { if ((!pdc_isxdigit(s[i]) && !pdc_isspace(s[i])) || (!pdc_isxdigit(s[i+1]) && !pdc_isspace(s[i+1]))) { pdc_fclose(t1->fontfile); pdc_error(p->pdc, PDF_E_FONT_CORRUPT_PFA, 0, 0, 0, 0); } s[i/2] = (char) (16*HexToBin[s[i]-'0'] + HexToBin[s[i+1]-'0']); src->bytes_available++; } t1->length[2] += src->bytes_available; } break; case t1_zeros: { t1->length[3] += (size_t) len; src->bytes_available = (size_t) len; } break; default: break; } t1->portion = t1portion; if (logg6) pdc_logg(p->pdc, "\t\t\tset portion %s\n", pdc_get_keyword(t1->portion, pdf_t1portion_keylist)); return pdc_true; }