|
↓
|
pdf_eval_type4
|
225
|
455
|
469
|
src/base/pdf-fp-func.c
|
static pdf_status_t
pdf_eval_type4 (pdf_fp_func_t t,
const pdf_real_t in[],
pdf_real_t out[],
pdf_fp_func_debug_t * debug)
{
struct t_stack {
double v;
enum { BOOL, INT, REAL } t;
} stack[NSTACK+2];
pdf_char_t *op;
pdf_u32_t n;
double tmp;
struct t_stack tmp_s;
pdf_i32_t sp;
pdf_i32_t pc;
pdf_fp_func_debug_t debug_info;
pdf_i32_t aux;
op = t->u.t4.opcodes;
n = t->u.t4.n_opcodes;
for (sp = 0; sp < t->m; sp++)
{
stack[sp].v = clip(in[sp], t->domain + 2*sp);
stack[sp].t = REAL;
}
sp--;
for (pc = 0; pc < n; pc++)
{
switch ((PDF_TYPE4_OPC) op[pc])
{
case OPC_ret:
if (sp+1 < t->n) goto stack_underflow;
if (sp+1 > t->n) goto stack_error;
for (sp = 0; sp < t->n; sp++)
{
if (!P_NUM(stack[sp])) goto type_error;
out[sp] = clip(stack[sp].v, t->range + 2*sp);
}
return PDF_OK;
break;
case OPC_lit_i:
if (sp >= NSTACK) goto stack_overflow;
sp++;
memcpy(&stack[sp].v, op+pc+1, sizeof(stack[0].v));
stack[sp].t = INT;
pc += sizeof(stack[0].v);
break;
case OPC_lit_r:
if (sp >= NSTACK) goto stack_overflow;
sp++;
memcpy(&stack[sp].v, op+pc+1, sizeof(stack[0].v));
stack[sp].t = REAL;
pc += sizeof(stack[0].v);
break;
case OPC_jmp:
memcpy(&pc,op+pc+1,sizeof(pc));
break;
case OPC_jnt:
if (sp < 0) goto stack_underflow;
if (!P_BOOL(stack[sp])) goto type_error;
if (P_TRUE(stack[sp]))
pc += sizeof(pc);
else if (P_FALSE(stack[sp]))
memcpy(&pc,op+pc+1,sizeof(pc));
else goto type_error;
sp--;
break;
case OPC_dup:
if (sp < 0) goto stack_underflow;
if (sp >= NSTACK) goto stack_overflow;
stack[sp+1] = stack[sp];
sp++;
break;
case OPC_pop:
if (sp < 0) goto stack_underflow;
sp--;
break;
case OPC_exch:
if (sp < 1) goto stack_underflow;
tmp_s = stack[sp-1];
stack[sp-1] = stack[sp];
stack[sp] = tmp_s;
break;
case OPC_sin:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = pdf_fp_sin ((180/PDF_PI)*stack[sp].v);
stack[sp].t = REAL;
break;
case OPC_cos:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = pdf_fp_cos ((180/PDF_PI)*stack[sp].v);
stack[sp].t = REAL;
break;
case OPC_neg:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = - stack[sp].v;
break;
case OPC_abs:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = pdf_fp_abs (stack[sp].v);
break;
case OPC_exp:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
tmp = pdf_fp_pow (stack[sp-1].v, stack[sp].v);
if (isinf(tmp) || tmp == HUGE_VAL) goto math_error;
stack[sp-1].v = tmp;
sp--;
break;
case OPC_log:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
if (stack[sp].v <= 0) goto range_error;
stack[sp].v = pdf_fp_log10 (stack[sp].v);
stack[sp].t = REAL;
break;
case OPC_ln:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
if (stack[sp].v <= 0) goto range_error;
stack[sp].v = pdf_fp_log (stack[sp].v);
stack[sp].t = REAL;
break;
case OPC_sqrt:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
if (stack[sp].v < 0) goto range_error;
stack[sp].v = pdf_fp_sqrt (stack[sp].v);
stack[sp].t = REAL;
break;
case OPC_floor:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
tmp = pdf_fp_floor (stack[sp].v);
if (isnan(tmp)) goto limit_error;
stack[sp].v = tmp;
break;
case OPC_ceiling:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
tmp = pdf_fp_ceil (stack[sp].v);
if (isnan(tmp)) goto limit_error;
stack[sp].v = tmp;
break;
case OPC_truncate:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
/* C99 stack[sp] = trunc(stack[sp]); */
stack[sp].v = TRUNC(stack[sp].v);
break;
case OPC_round:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = pdf_fp_floor (0.5 + stack[sp].v);
break;
case OPC_cvi:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].v = INT(stack[sp].v);
stack[sp].t = INT;
break;
case OPC_index:
if (sp < 0) goto stack_underflow;
if (!P_INT(stack[sp])) goto type_error;
if (stack[sp].v < 0 || stack[sp].v > sp-1) goto range_error;
/* copy complete stack element with type info */
stack[sp] = stack[sp-1-INT(stack[sp].v)];
break;
case OPC_copy:
{
pdf_i32_t n,i;
if (sp < 0) goto stack_underflow;
if (!P_INT(stack[sp])) goto type_error;
n = INT(stack[sp].v);
if (n < 0 || n > sp) goto range_error;
if (sp + n >= NSTACK) goto stack_overflow;
sp = sp - n;
for (i = 0; i < n; i++, sp++)
{
/* copy complete stack element with type info */
stack[sp+n] = stack[sp];
}
if (n > 0)
{
sp++;
}
break;
}
case OPC_roll:
{
pdf_i32_t n,s,j;
if (sp < 2) goto stack_underflow;
if (!P_INT(stack[sp]) || !P_INT(stack[sp-1])) goto type_error;
n = INT(stack[sp-1].v);
j = INT(stack[sp].v);
sp -= 2;
if (n < 0 || n > sp) goto range_error;
if (n >= 2)
{
struct t_stack pp[NSTACK];
int pos;
s = (j-1) % n;
for (pos = 0; pos < n; pos++)
{
if (s < 0)
s = n - 1;
pp[pos] = stack[sp-s];
s--;
}
memcpy(&stack[sp-n+1],pp,n*sizeof(stack[0]));
}
break;
}
case OPC_cvr:
if (sp < 0) goto stack_underflow;
if (!P_NUM(stack[sp])) goto type_error;
stack[sp].t = REAL;
break;
case OPC_add:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
if (isinf(tmp = pdf_fp_add(stack[sp-1].v, stack[sp].v)))
goto limit_error;
stack[sp-1].v = tmp;
stack[sp-1].t = NUM_TYPE(stack[sp-1], stack[sp]);
sp--;
break;
case OPC_sub:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
if (isinf(tmp = pdf_fp_sub(stack[sp-1].v, stack[sp].v)))
goto limit_error;
stack[sp-1].v = tmp;
stack[sp-1].t = NUM_TYPE(stack[sp-1], stack[sp]);
sp--;
break;
case OPC_mul:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
if (isinf(tmp = pdf_fp_mul(stack[sp-1].v, stack[sp].v)))
goto limit_error;
stack[sp-1].v = tmp;
stack[sp-1].t = NUM_TYPE(stack[sp-1], stack[sp]);
sp--;
break;
case OPC_div:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
if (stack[sp].v == 0) goto math_error;
if (isinf(tmp = pdf_fp_div(stack[sp-1].v, stack[sp].v)))
goto limit_error;
stack[sp-1].v = tmp;
stack[sp-1].t = NUM_TYPE(stack[sp-1], stack[sp]);
sp--;
break;
case OPC_atan:
if (sp < 1) goto stack_underflow;
if (!P_NUM(stack[sp-1]) || !P_NUM(stack[sp])) goto type_error;
stack[sp-1].v = (180/PDF_PI) *
pdf_fp_atan2 (stack[sp-1].v, stack[sp].v);
stack[sp-1].t = REAL;
/* check against Ghostscript */
sp--;
break;
case OPC_idiv:
if (sp < 1) goto stack_underflow;
if (!P_INT(stack[sp-1]) || !P_INT(stack[sp])) goto type_error;
if (stack[sp].v == 0) goto math_error;
stack[sp-1].v = INT(pdf_fp_div(INT(stack[sp-1].v), INT(stack[sp].v)));
sp--;
break;
case OPC_mod:
if (sp < 1) goto stack_underflow;
if (!P_INT(stack[sp-1]) || !P_INT(stack[sp])) goto type_error;
if (stack[sp].v == 0) goto math_error;
stack[sp-1].v = pdf_fp_mod(stack[sp-1].v, stack[sp].v);
sp--;
break;
case OPC_and:
if (sp < 1) goto stack_underflow;
if (P_INT(stack[sp-1]) && P_INT(stack[sp]))
stack[sp-1].v = INT(stack[sp-1].v) & INT(stack[sp].v);
else if (P_BOOL(stack[sp-1]) && P_BOOL(stack[sp]))
stack[sp-1].v = BOOL(P_TRUE(stack[sp-1]) && P_TRUE(stack[sp]));
else
goto type_error;
sp--;
break;
case OPC_bitshift:
if (sp < 1) goto stack_underflow;
if (!P_INT(stack[sp-1]) || !P_INT(stack[sp]))
goto type_error;
{
pdf_i32_t x;
pdf_i32_t i = INT(stack[sp].v);
if ((stack[sp].v > PDF_I32_MAX) ||
(stack[sp].v < PDF_I32_MIN))
goto limit_error;
x = INT(stack[sp-1].v);
if (i >= 0)
x = (i < 32) ? (x< -32) ? (x>>-i) : 0;
stack[sp-1].v = x;
}
sp--;
break;
case OPC_or:
if (sp < 1) goto stack_underflow;
if (P_INT(stack[sp-1]) && P_INT(stack[sp]))
stack[sp-1].v = INT(stack[sp-1].v) | INT(stack[sp].v);
else if (P_BOOL(stack[sp-1]) && P_BOOL(stack[sp]))
stack[sp-1].v = BOOL(P_TRUE(stack[sp-1]) || P_TRUE(stack[sp]));
else
goto type_error;
sp--;
break;
case OPC_xor:
if (sp < 1) goto stack_underflow;
if (P_INT(stack[sp-1]) && P_INT(stack[sp]))
stack[sp-1].v = INT(stack[sp-1].v) ^ INT(stack[sp].v);
else if (P_BOOL(stack[sp-1]) && P_BOOL(stack[sp]))
stack[sp-1].v = BOOL((P_TRUE(stack[sp-1]) || P_TRUE(stack[sp])) &&
(stack[sp-1].v != stack[sp].v));
else
goto type_error;
sp--;
break;
case OPC_not:
if (sp < 0) goto stack_underflow;
if (P_INT(stack[sp]))
stack[sp].v = ~INT(stack[sp].v);
else if (P_BOOL(stack[sp]))
stack[sp].v = BOOL(!P_TRUE(stack[sp]));
else
goto type_error;
break;
case OPC_eq:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
/* any comparison involving NaN is false. */
/* this should not go unnoticed */
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v == stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_ne:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v != stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_lt:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v < stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_le:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v <= stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_ge:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v >= stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_gt:
if (sp < 1) goto stack_underflow;
if (isnan(stack[sp-1].v) || isnan(stack[sp].v))
goto math_error;
if ((P_NUM(stack[sp-1]) && P_NUM(stack[sp])) ||
(P_BOOL(stack[sp-1]) && P_BOOL(stack[sp])))
stack[sp-1].v = BOOL(stack[sp-1].v > stack[sp].v);
else
goto type_error;
stack[sp-1].t = BOOL;
sp--;
break;
case OPC_true:
if (sp >= NSTACK) goto stack_overflow;
sp++;
stack[sp].v = REP_TRUE;
stack[sp].t = BOOL;
break;
case OPC_false:
if (sp >= NSTACK) goto stack_overflow;
sp++;
stack[sp].v = REP_FALSE;
stack[sp].t = BOOL;
break;
default:
goto block_error;
}
}
block_error: debug_info.type4.status = PDF_ERROR; goto end;
stack_error: debug_info.type4.status = PDF_EINVRANGE; goto end;
stack_underflow: debug_info.type4.status = PDF_EUNDERFLOW; goto end;
stack_overflow: debug_info.type4.status = PDF_EOVERFLOW; goto end;
range_error: debug_info.type4.status = PDF_EINVRANGE; goto end;
type_error: debug_info.type4.status = PDF_EBADTYPE; goto end;
math_error: debug_info.type4.status = PDF_EMATH; goto end;
limit_error: debug_info.type4.status = PDF_EIMPLLIMIT; goto end;
end:
/* Found that code was compiled to the opcode for debugging. */
debug_info.type4.op = -1;
for (aux = 0; aux < t->u.t4.debug_size; aux++)
{
if (t->u.t4.debug_off[aux][0] == pc)
{
debug_info.type4.op = t->u.t4.debug_off[aux][1];
break;
}
}
/* Copy some elements from the stack for debugging */
for (aux = 0; aux <= sp; aux++)
{
debug_info.type4.stack[aux] = stack[sp - aux].v;
}
debug_info.type4.stack_size = sp + 1;
if (debug != NULL)
*debug = debug_info;
return PDF_ETYPE4;
}
|
|
↓
|
pdf_stm_f_a85dec_apply
|
39
|
106
|
212
|
src/base/pdf-stm-f-a85.c
|
pdf_status_t
pdf_stm_f_a85dec_apply (pdf_hash_t params, void *state, pdf_buffer_t in,
pdf_buffer_t out, pdf_bool_t finish_p)
{
pdf_stm_f_a85_t filter_state;
pdf_char_t quint[5];
pdf_char_t tr_quint[5];
pdf_size_t q_idx;
int i;
int done;
int oldone; /* Outer Loop Done */
pdf_size_t term_idx;
pdf_status_t retval = PDF_OK;
int k;
filter_state = (pdf_stm_f_a85_t) state;
/* Fill the output buffer with the contents of the input buffer, but
note that the second may be bigger than the former */
/* Only process the next bit of input if the output buffer is empty */
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK != retval)
{
return retval;
}
oldone = PDF_FALSE;
while (!oldone)
{
q_idx = 0;
term_idx = A85_INVALID_TERM_IDX;
/* First pull any leftover bytes from last _apply(...) and prepend here */
if (filter_state->spare_count)
{
/* First pull the spare_bytes into the quint */
for (i = 0; i < filter_state->spare_count; i++)
{
quint[q_idx] = filter_state->spare_bytes[i];
if ('~' == quint[q_idx])
{
term_idx = q_idx;
}
q_idx++;
}
filter_state->spare_count = 0;
}
/* Now attempt to fill up the rest of the quint from the input stream */
done = PDF_FALSE;
for (i = q_idx; ((i < 5) && !done); i++)
{
retval = pdf_stm_f_a85dec_getnext (in, &(quint[q_idx]));
if (PDF_ENINPUT == retval)
{ /* Ran out of input before filling quint */
done = PDF_TRUE;
}
else
{
if ('~' == quint[q_idx])
{
term_idx = q_idx;
}
if ((0 == q_idx) && ('z' == quint[0]))
{
done = PDF_TRUE;
}
q_idx++;
}
}
if (A85_INVALID_TERM_IDX == term_idx)
{ /* Normal Processing */
if (5 != q_idx)
{
if ((1 == q_idx) && ('z' == quint[0]) && (PDF_OK == retval))
{ /* special case 'z' encodes value 0x00000000 */
retval = pdf_stm_f_a85_write_out (0, out, filter_state);
retval = pdf_stm_f_a85_write_out (0, out, filter_state);
retval = pdf_stm_f_a85_write_out (0, out, filter_state);
retval = pdf_stm_f_a85_write_out (0, out, filter_state);
q_idx = 0;
}
else if (PDF_ENINPUT == retval)
{ /* Not full dataset. Save this data for later */
for (i = 0; i < q_idx; i++)
{
filter_state->spare_bytes[i] = quint[i];
}
filter_state->spare_count = q_idx;
q_idx = 0; /* Clear this so that the output loop is skipped.*/
oldone = PDF_TRUE;
}
else if (finish_p)
{ /* finish specified, but valid term. sequence not present */
retval = PDF_ERROR;
oldone = PDF_TRUE;
}
else
{ /* some other error than PDF_ENINPUT */
/* Let this other error pass through. */
oldone = PDF_TRUE;
}
}
else if ((5 == q_idx) && (PDF_OK == retval))
{ /* 5 good output bytes present */
/* remove the offset from each byte */
for (i = 0; i < 5; i++)
{
tr_quint[i] = quint[i] - '!';
}
retval = pdf_stm_f_a85dec_wr_quad (tr_quint, 4, out,
filter_state);
if (PDF_OK != retval)
{
/* Something wrong in writing out data. Save for next call */
for (i = 0; i < q_idx; i++)
{
filter_state->spare_bytes[i] = quint[i];
}
filter_state->spare_count = q_idx;
oldone = PDF_TRUE;
}
}
}
else
{ /* Start of termination pattern detected. */
if (1 == term_idx)
{
/* There is a single byte to process before term sequence */
/* This is an error */
retval = PDF_ERROR;
oldone = PDF_TRUE;
}
else if (term_idx > 1)
{
/* Prepare quint for handoff to wr_quad */
for (i = 0; i < (5 - term_idx); i++)
{ /* Pad with zeroes */
tr_quint[i] = 0;
}
for (i = 0; i < term_idx; i++)
{ /* Pull in data bytes */
tr_quint[(5 - term_idx) + i] = quint[i] - '!';
}
retval = pdf_stm_f_a85dec_wr_quad (tr_quint, (term_idx - 1), out,
filter_state);
/* Now put remaining parts of the term. seq. at beg. of quint */
k = 0;
for (i = term_idx; i < q_idx; i++)
{
quint[k++] = quint[i];
}
q_idx = k;
}
else
{
/* 0 == term_idx - only term sequence - no quad output */
}
/* Now check to see if we have valid finishing conditions: */
if ((PDF_ENINPUT == retval) && (2 == q_idx)
&& ('~' == quint[0]) && ('>' == quint[1]))
{
if (finish_p)
{
/* All we have is term code, and finish is requested. fini */
retval = PDF_EEOF;
oldone = PDF_TRUE;
}
else
{ /* finish_p not set. save the bytes for later */
for (i = 0; i < q_idx; i++)
{
filter_state->spare_bytes[i] = quint[i];
}
filter_state->spare_count = q_idx;
oldone = PDF_TRUE;
}
}
}
if (!oldone && PDF_OK == retval)
{
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK != retval)
{
oldone = PDF_TRUE;
}
}
}
return retval;
}
|
|
↓
|
pdf_stm_f_dctdec_apply
|
33
|
89
|
193
|
src/base/pdf-stm-f-dct.c
|
pdf_status_t
pdf_stm_f_dctdec_apply (pdf_hash_t params,
void *state,
pdf_buffer_t in,
pdf_buffer_t out,
pdf_bool_t finish_p)
{
pdf_status_t ret = PDF_OK;
pdf_i32_t iret;
pdf_stm_f_dctdec_t filter_state = (pdf_stm_f_dctdec_t)state;
struct jpeg_decompress_struct *pcinfo = filter_state->cinfo;
if (finish_p
&& ((in->wp - in->rp) < 1 )
&& (pcinfo->output_scanline == pcinfo->output_height)
&& (0 == filter_state->row_valid_size - filter_state->row_copy_index))
{
return PDF_EEOF;
}
while (ret == PDF_OK)
{
if (DCTDEC_STATE_INIT == filter_state->state)
{
if (!filter_state->djpeg_in)
{
filter_state->djpeg_in = pdf_buffer_new (PDF_DJPEG_CACHE_SIZE);
if(!filter_state->djpeg_in)
{
ret = PDF_ERROR;
break;
}
}
pdf_stm_f_dctdec_jpeg_cache_src (pcinfo, filter_state->djpeg_in);
filter_state->backup_state = DCTDEC_STATE_READHDR;
filter_state->state = DCTDEC_STATE_CACHE_IN;
}
if (DCTDEC_STATE_CACHE_IN == filter_state->state)
{
if (pdf_buffer_eob_p (in))
{
ret = PDF_ENINPUT;
break;
}
ret = pdf_stm_f_dctdec_src_fill (pcinfo, in);
if(PDF_OK != ret)
{
break;
}
filter_state->state = filter_state->backup_state;
}
if (DCTDEC_STATE_READHDR == filter_state->state)
{
iret = jpeg_read_header (pcinfo, TRUE);
if (iret == JPEG_SUSPENDED)
{
/* continue the loop, go into the "cache state" */
ret = PDF_OK;
filter_state->backup_state = filter_state->state;
filter_state->state = DCTDEC_STATE_CACHE_IN;
continue;
}
if (iret != JPEG_HEADER_OK)
{
ret = PDF_ERROR;
break;
}
pdf_stm_f_dctdec_set_djpeg_param (pcinfo, filter_state);
filter_state->state = DCTDEC_STATE_STARTDJP;
}
if(DCTDEC_STATE_STARTDJP == filter_state->state)
{
iret = jpeg_start_decompress (pcinfo);
if (iret == FALSE)
{
/* continue the loop, go into the "cache state" */
ret = PDF_OK;
filter_state->backup_state = filter_state->state;
filter_state->state = DCTDEC_STATE_CACHE_IN;
continue;
}
/* here we know the output size, so allocate memory for them. */
filter_state->row_stride = pcinfo->output_width * pcinfo->output_components;
/* Make a one-row-high sample array that will go away when done with image */
filter_state->row_buf = (*pcinfo->mem->alloc_sarray)
((j_common_ptr) pcinfo, JPOOL_IMAGE, filter_state->row_stride, 1);
filter_state->row_valid_size = 0;
filter_state->row_copy_index = 0;
filter_state->state = DCTDEC_STATE_WRITEHDR;
}
if (DCTDEC_STATE_WRITEHDR == filter_state->state)
{
ret = pdf_stm_f_dctdec_write_ppm_header (pcinfo, out);
if (PDF_OK != ret)
{
break;
}
filter_state->state = DCTDEC_STATE_SCANLINE;
}
if (DCTDEC_STATE_OUTPUTLINE == filter_state->state)
{
if ((filter_state->row_valid_size > 0)
&& (filter_state->row_valid_size > filter_state->row_copy_index))
{
if (pdf_buffer_full_p (out))
{
ret = PDF_ENOUTPUT;
break;
}
else
{
pdf_size_t bytes_to_copy =
PDF_MIN (filter_state->row_valid_size - filter_state->row_copy_index,
out->size - out->wp);
if (bytes_to_copy > 0)
{
memcpy (out->data+out->wp,
filter_state->row_buf[0]+filter_state->row_copy_index,
bytes_to_copy);
out->wp += bytes_to_copy;
}
filter_state->row_copy_index += bytes_to_copy;
if (filter_state->row_copy_index != filter_state->row_valid_size)
{
ret = PDF_ENOUTPUT;
break;
}
}
if ((PDF_OK == ret)
&& (pcinfo->output_scanline == pcinfo->output_height))
{
ret = PDF_EEOF;
break;
}
}
filter_state->state = DCTDEC_STATE_SCANLINE;
}
if(DCTDEC_STATE_SCANLINE == filter_state->state)
{
ret = PDF_OK;
if (pcinfo->output_scanline < pcinfo->output_height)
{
pdf_i32_t scannum;
scannum = jpeg_read_scanlines (pcinfo,
filter_state->row_buf,
1);
if(scannum == 0)
{
filter_state->backup_state = filter_state->state;
filter_state->state = DCTDEC_STATE_CACHE_IN;
break;
}
if (scannum != 1)
{
ret = PDF_ERROR;
break;
}
filter_state->num_scanlines += scannum;
filter_state->row_valid_size = scannum * filter_state->row_stride;
filter_state->row_copy_index = 0;
filter_state->state = DCTDEC_STATE_OUTPUTLINE;
}
}
}
if (PDF_ENINPUT == ret && finish_p)
{
ret = PDF_EEOF;
}
return ret;
}
|
|
↓
|
pdf_i64_div
|
31
|
116
|
278
|
src/base/pdf-types.c
|
void
pdf_i64_div (pdf_i64_t *dest,
const pdf_i64_t const_dividend,
const pdf_i64_t const_divisor,
pdf_status_t *p_status)
{
/*Knuth method*/
int i, j; /*counters*/
/*k is used to find the first non-zero digit in the divisor, q_bar
is where the partial result of the division is stored, z is used to find
the highest non-zero digit in the dividend*/
/*See Knuth for definitions of m and n*/
pdf_u32_t k, q_bar, n, z;
pdf_i32_t m;
/*divisor_nor stores normalised divisor, d_pdf is used to
normalise divisor and dividend, v_pdf is the internal pdf_i64_t
version of divisor, q_bar_pdf is the pdf_i64_t version of the
partial division result, temp is a temporary variable used int
the procedures*/
pdf_i64_t divisor_nor, d_pdf,v_pdf, q_bar_pdf, temp;
pdf_i64_t divisor;
pdf_i64_t dividend;
pdf_u32_t v[8]; /*where divisor is stored*/
/*q is where result is stored, u is where the dividend is stored,
and temporal is a temporal vector used in the different procedures*/
pdf_u32_t q[8] = {0, 0, 0, 0, 0, 0, 0, 0}, u[16], temporal[8];
pdf_u32_t d; /*used to normalise divisor and dividend*/
pdf_u32_t b = PDF_U8_DIV; /*base of the division*/
pdf_u32_t mask = 0xFF000000; /*mask used to pass info from pdf_i64_t types and arrays*/
pdf_i64_t zero = pdf_i64_new(0 , 0); /*zero in pdf_i64_t format*/
int result_sign = 1; /*used to carry the sign of the result till the end*/
ASSIGN_SAFE(p_status, PDF_OK);
if (dest != NULL)
{
z = 0;
k = 0;
/* Make a non-const divisor */
divisor = pdf_i64_new (0, 0);
pdf_i64_copy (const_divisor, &divisor, p_status);
/* Make a non-const dividend */
dividend = pdf_i64_new (0, 0);
pdf_i64_copy (const_dividend, ÷nd, p_status);
/*Check first if divisor != 0*/
if (pdf_i64_cmp(zero,divisor) == 0)
{
ASSIGN_SAFE(p_status, PDF_EDIVBYZERO);
return;
}
/*Now check the signs fo divisor and dividend*/
if (pdf_i64_cmp(divisor,zero) < 0)
{
result_sign = -1;
pdf_i64_abs(&divisor,divisor, p_status);
}
if (pdf_i64_cmp(dividend,zero) < 0)
{
pdf_i64_abs(÷nd,dividend, p_status);
if (result_sign == -1)
{
result_sign = 1;
}
else
{
result_sign = -1;
}
}
/*We check if abs(divisor) > abs(dividend)*/
if (pdf_i64_cmp(divisor, dividend) == 1)
{
pdf_i64_assign(dest,0,0, p_status);
}
/*we store divisor in array*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
v[i] = ((divisor.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
v[i] = ((divisor.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*we store dividend in temporal array*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
temporal[i] = ((dividend.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
temporal[i] = ((dividend.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*With z we'll find the highest non-zero 8 bit number in the dividend*/
for (i = 7; i >= 0; i--)
{
if (temporal[i] != 0)
{
z = i;
}
}
/*with k we'll find the highest non-zero 8 bit number in the divisor*/
for (i = 7; i >= 0; i--)
{
if (v[i] != 0)
{
k = i;
}
}
/*With z and k the relative sizes of the different numbers are found.
See Knuth algorithm for more details on n and m.*/
n = 8 - k; /*n = size of non zero v*/
m = k - z;
/*d is used to normalise divisor and dividend; see Knuth for details*/
d = b/(v[k] + 1);
/*we store d in pdf_i64_t type*/
d_pdf = pdf_i64_new(0, d);
/*Here u and v are multiplied by d to normalise them*/
/*we use a extra long version of pdf_i64_t multiplication to avoid
unwanted overflows*/
/*normalised dividend is stored in variable u*/
mult_long(u, dividend, d_pdf);
/*normalised divisor is stored in varialbe divisor_d*/
pdf_i64_mult(&divisor_nor, divisor, d_pdf, p_status);
/*We add up 8 to z to adapt it to the new 16 bit array, but
1 is subtracted due to the inclusion of Uo. See Knuth vol2
for more details on Uo*/
z = z + 7;
/*normalised divisor is stored in array v*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
v[i] = ((divisor_nor.high & (mask >> (i * 8))) >> ((3 - i) * 8));
}
else
{
v[i] = ((divisor_nor.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*With u and v normalised we start the algorithm*/
/*Always add z when going through u array to get rid of non-useful zeros*/
/*The different steps follow the algorithm described in Knuth vol 2*/
for (j = 0;j <= m; j++)
{
/*Step D3*/
if (u[j + z] == v[k])
{
q_bar = b - 1;
}
else
{
q_bar = (u[j + z] * b + u[j + z + 1])/v[k];
}
if (k < 7)
{
while (v[k + 1] * q_bar >
((u[j + z] * b + u[j + z + 1] - q_bar * v[k] ) * b + u[j + z + 2] ))
{
q_bar = q_bar - 1;
}
}
/*Step D4*/
/*We put q_bar into a i64 type to be able to multiply it by the normalised divisor*/
q_bar_pdf = pdf_i64_new(0, q_bar);
pdf_i64_mult(&v_pdf, divisor_nor, q_bar_pdf, p_status);
/*put u[j]...u[j + n] into a pdf_i64_t type and subtract v_pdf*/
temp = pdf_i64_new(0,0);
for (i = j + n; i >= j; i--)
{
int kk = j + n -3;
if (i >= kk)
{
temp.low = temp.low + (u[i + z] << (8 * (j + n - i)));
}
else
{
temp.high = temp.high + (u[i + z] << (8 * (j + n - i)));
}
}
pdf_i64_subtraction(&temp, temp, v_pdf, p_status);
/*We finally put q_bar in the results array*/
q[j] = q_bar;
/*If the remainder is less than zero then we re-add the divisor and subtract one from q
Step D6*/
if (pdf_i64_cmp(temp, zero) < 0)
{
q[j] = q[j] - 1;
pdf_i64_add(&temp, divisor_nor, temp, p_status);
}
/*Step D5; uj...uj+n is substituted with the uj...uj+n obtained above*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
temporal[i] = ((temp.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
temporal[i] = ((temp.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
for (i = 7; i >= 0;i--)
{
u[z + j + n - 7 + i] = temporal[i];
}
}/*end of for in j*/
pdf_i64_assign(&temp,0,0, p_status);
for (i = m; i >= 0; i--)
{
if (m > 3)
{
if (i >= (m -3))
{
temp.low = temp.low + (q[i] << (8* (m - i)));
}
else
{
temp.high = temp.high + (q[i] << (8* (m - i - 4)));
}
}
else
{
temp.low = temp.low + (q[i] << (8* (m - i)));
}
}
if (result_sign == -1)
{
pdf_i64_neg(dest, temp, p_status);
}
else
{
pdf_i64_assign(dest, temp.high, temp.low, p_status);
}
}
else
{
ASSIGN_SAFE(p_status, PDF_EBADDATA);
}
}
|
|
↓
|
pdf_stm_f_a85enc_apply
|
30
|
96
|
247
|
src/base/pdf-stm-f-a85.c
|
pdf_status_t
pdf_stm_f_a85enc_apply (pdf_hash_t params, void *state, pdf_buffer_t in,
pdf_buffer_t out, pdf_bool_t finish_p)
{
pdf_size_t in_size;
pdf_stm_f_a85_t filter_state;
pdf_u32_t tuple;
pdf_size_t read_bytes;
pdf_size_t pos_in;
int avail;
int i;
pdf_char_t buf[5];
pdf_char_t temp_byte;
pdf_status_t retval = PDF_OK;
filter_state = (pdf_stm_f_a85_t) state;
/*
* ASCII base-85 encoding produces 5 ASCII characters for every 4
* bytes in the input data.
*
* But take care of the EOD marker (~>) and the newlines/whitespace.
*
* Note that 0x00000000 is coded with 'z',
*/
/*
* Make sure that the output_buff is flushed and ready to accept another
* batch of data
*/
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK != retval)
{ /* Probably this is PDF_ENOUTPUT - meaning output_buff still has data */
return retval;
}
/* Pull any leftover data from last _apply from state->spare_bytes */
if (filter_state->spare_count)
{
avail = in->wp - in->rp;
if ((avail + filter_state->spare_count) >= 4)
{ /* There is a full tuple available */
tuple = 0;
i = 0;
tuple = tuple | (filter_state->spare_bytes[i++] << 24);
filter_state->spare_count--;
if (filter_state->spare_count)
{
temp_byte = filter_state->spare_bytes[i++];
filter_state->spare_count--;
}
else
{
temp_byte = in->data[in->rp++];
}
tuple = tuple | (temp_byte << 16);
if (filter_state->spare_count)
{ /* don't bother incrementing i here - not used again */
temp_byte = filter_state->spare_bytes[i];
filter_state->spare_count--;
}
else
{
temp_byte = in->data[in->rp++];
}
tuple = tuple | (temp_byte << 8);
tuple = tuple | in->data[in->rp++];
retval = pdf_stm_f_a85enc_wr_tuple (tuple, 4, filter_state, out);
} /* End of if there is a full tuple available */
else
{
/* There was no full tuple available - do nothing.
If finish_p is set, then a partial tuple will be written later */
retval = PDF_ENINPUT;
}
} /* end of if spare_count */
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK != retval)
{ /* Probably this is PDF_ENOUTPUT - meaning output_buff still has data */
return retval;
}
/* Now do all normal tuples */
in_size = in->wp - in->rp;
if ((PDF_OK == retval) && (in_size >= 4))
{
for (pos_in = 0; (pos_in < in_size) && (PDF_OK == retval); pos_in += 4)
{
tuple = 0;
avail = in_size - pos_in;
if (avail >= 4)
{
tuple = tuple | (in->data[in->rp] << 24);
tuple = tuple | (in->data[in->rp + 1] << 16);
tuple = tuple | (in->data[in->rp + 2] << 8);
tuple = tuple | in->data[in->rp + 3];
in->rp += 4;
retval = pdf_stm_f_a85enc_wr_tuple (tuple, 4, filter_state, out);
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
} /* end of whole tuple available */
} /* end for loop */
if (PDF_OK == retval)
{ /* Loop terminated by PDF_ENINPUT */
retval = PDF_ENINPUT;
}
} /* End if retval == PDF_OK && whole tuple available */
else if ((PDF_OK == retval) && (in_size < 4))
{
retval = PDF_ENINPUT;
}
/* Now if finish_p do a partial tuple if there are leftover bytes */
if (finish_p && (PDF_ENINPUT == retval))
{
/* If the length of the binary data to be encoded is not a multiple of 4
bytes, the last, partial group of 4 is used to produce a last, partial
group of 5 output characters. Given n (1, 2 or 3) bytes of binary
data, the encoder first appends 4 - n zero bytes to make a complete
group of 4. It then encodes this group in the usual way, but without
applying the special z case. Finally, it writes only the first n + 1
characters of the resulting group of 5. */
in_size = filter_state->spare_count + (in->wp - in->rp);
if (in_size)
{
for (i = 0; i < (4 - in_size); i++)
{
buf[i] = 0;
}
read_bytes = 0;
for (i = (4 - in_size); i < 4; i++)
{
avail = in->wp - in->rp;
if (filter_state->spare_count || avail)
{
if (filter_state->spare_count)
{
buf[i] = filter_state->spare_bytes[read_bytes++];
filter_state->spare_count--;
}
else
{
buf[i] = in->data[in->rp++];
}
}
else
{
buf[i] = 0;
}
}
tuple = 0;
tuple = tuple | buf[0] << 24;
tuple = tuple | buf[1] << 16;
tuple = tuple | buf[2] << 8;
tuple = tuple | buf[3];
retval =
pdf_stm_f_a85enc_wr_tuple (tuple, in_size, filter_state, out);
} /* end of if (in_size) */
else
{
/* There was no partial tuple to write out. Do Nothing. */
}
if (!filter_state->terminated)
{
/* Insert the EOD marker */
retval = pdf_stm_f_a85_write_out ('~', out, filter_state);
retval = pdf_stm_f_a85_write_out ('>', out, filter_state);
filter_state->terminated = PDF_TRUE;
}
}
else if (PDF_ENINPUT == retval)
{ /* finish_p not set, so save partial tuple (if present) for next call */
avail = in->wp - in->rp;
while (avail)
{
if (filter_state->spare_count >= A85_SPARE_BYTES_LEN)
{
retval = PDF_ERROR;
}
else
{
filter_state->spare_bytes[filter_state->spare_count++] =
in->data[in->rp++];
}
avail--;
}
}
if (finish_p && (PDF_OK == retval))
{
retval = pdf_stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK == retval)
{ /* We have completed this filter job: */
retval = PDF_EEOF;
}
}
return retval;
}
|
|
↓
|
handle_char
|
45
|
80
|
183
|
src/base/pdf-token-reader.c
|
static pdf_status_t
handle_char (pdf_token_reader_t reader, pdf_u32_t flags,
pdf_char_t ch, pdf_token_t *token)
{
pdf_status_t rv;
/* first, handle the states that shouldn't be exited when whitespace
* or a delimiter is seen */
switch (reader->state)
{
case PDF_TOKR_STATE_EOF:
return PDF_EEOF;
case PDF_TOKR_STATE_STRING:
return handle_string_char (reader, flags, ch, token);
case PDF_TOKR_STATE_HEXSTRING:
return handle_hexstring_char (reader, flags, ch, token);
case PDF_TOKR_STATE_DICTEND:
if (ch != 62) /* '>' */
return PDF_EBADFILE;
reader->substate = 1; /* saw the closing '>' */
return exit_state (reader, flags, token);
case PDF_TOKR_STATE_COMMENT:
if (pdf_is_eol_char (ch))
{
rv = exit_state (reader, flags, token);
if (rv != PDF_OK)
return rv;
/* don't accept this character, but process it next time */
return PDF_EAGAIN;
}
if (!(flags & PDF_TOKEN_RET_COMMENTS))
reader->substate = 1;
if (reader->substate == 1)
return PDF_OK; /* we don't care about this comment */
return store_char_grow (reader, ch);
default: ;
}
/* now handle delimiters and whitespace */
if (pdf_is_wspace_char (ch))
{
if (reader->state)
{
rv = exit_state (reader, flags, token);
if (rv != PDF_OK)
return rv;
/* avoid reading this byte so PDF_TOKEN_END_AT_STREAM
* will work properly if it's '\r' */
return PDF_EAGAIN;
}
if ((flags & PDF_TOKEN_END_AT_STREAM) && ch == 10) /* LF */
{
/* found the beginning of a stream */
enter_state (reader, PDF_TOKR_STATE_EOF);
}
return PDF_OK;
}
else if ((flags & PDF_TOKEN_END_AT_STREAM) && ch != 37) /* 37=='%' */
{
/* only allow whitespace/comments after the "stream" keyword */
return PDF_EBADFILE;
}
if (pdf_is_delim_char (ch))
{
/* set state 0 (UNINIT), substate 0, bufpos 0 */
if (reader->state)
{
rv = exit_state (reader, flags, token);
if (rv != PDF_OK)
return rv;
return PDF_EAGAIN;
}
switch (ch)
{
case 37: /* '%' */
enter_state (reader, PDF_TOKR_STATE_COMMENT);
return PDF_OK;
case 40: /* '(' */
enter_state (reader, PDF_TOKR_STATE_STRING);
reader->intparam = 0;
return PDF_OK;
case 41: /* ')' */
/* this shouldn't occur outside the STRING and COMMENT states */
return PDF_EBADFILE;
case 47: /* '/' */
enter_state (reader, PDF_TOKR_STATE_NAME);
return PDF_OK;
case 60: /* '<' */
enter_state (reader, PDF_TOKR_STATE_HEXSTRING);
return PDF_OK;
case 62: /* '>' */
enter_state (reader, PDF_TOKR_STATE_DICTEND);
return PDF_OK;
case 91: /* '[' */
/* fall through */
case 93: /* ']' */
/* fall through */
case 123: /* '{' */
/* fall through */
case 125: /* '}' */
/* exit_state may have emitted a token, so we can't emit another
* one now; we'll do it when exiting the PENDING state */
enter_state (reader, PDF_TOKR_STATE_PENDING);
reader->charparam = ch;
return PDF_OK;
}
/* not reached (all delimiter chars should be handled) */
assert (0);
}
/* ch is a regular character */
switch (reader->state)
{
case PDF_TOKR_STATE_PENDING:
rv = exit_state (reader, flags, token);
if (rv != PDF_OK)
return rv;
return PDF_EAGAIN;
case PDF_TOKR_STATE_NONE:
enter_state (reader, PDF_TOKR_STATE_KEYWORD);
/* fall through */
case PDF_TOKR_STATE_KEYWORD:
/* Note: numbers are treated as keywords until flush_token is called. */
return store_char (reader, ch);
case PDF_TOKR_STATE_NAME:
if (reader->substate == 0)
{
if ((ch < 0x21) || (ch > 0x7e))
{
/* Invalid character in a name. */
return PDF_EBADFILE;
}
if (ch != 35 /* '#' */
|| (flags & PDF_TOKEN_NO_NAME_ESCAPES) )
return store_char (reader, ch);
reader->substate = 1;
return PDF_OK;
}
if ( (ch = hexval (ch)) >= 16 )
return PDF_EBADFILE;
if (reader->substate == 1) /* the first hex digit of an escape */
{
reader->substate = 2;
reader->charparam = ch;
return PDF_OK;
}
ch = (reader->charparam << 4) | ch;
if (ch == 0) /* the PDF spec forbids "#00" */
return PDF_EBADFILE;
rv = store_char (reader, ch);
if (rv == PDF_OK) reader->substate = 0;
return rv;
default:
assert (0);
return PDF_ERROR;
}
}
|
|
↓
|
pdf_i64_mod
|
28
|
114
|
255
|
src/base/pdf-types.c
|
void
pdf_i64_mod(pdf_i64_t *dest,
const pdf_i64_t const_dividend,
const pdf_i64_t const_divisor,
pdf_status_t *p_status)
{
/*Knuth method*/
int i, j; /*counters*/
/*k is used to find the first non-zero digit in the divisor, q_bar
is where the partial result of the division is stored, z is used to find
the highest non-zero digit in the dividend*/
/*See Knuth for definitions of m and n*/
pdf_u32_t k, q_bar, n, z;
pdf_i32_t m;
/*divisor_nor stores normalised divisor, d_pdf is used to
normalise divisor and dividend, v_pdf is the internal pdf_i64_t
version of divisor, q_bar_pdf is the pdf_i64_t version of the
partial division result, temp is a temporary variable used int
the procedures*/
pdf_i64_t divisor_nor, d_pdf,v_pdf, q_bar_pdf, temp;
pdf_i64_t divisor;
pdf_i64_t dividend;
pdf_u32_t v[8]; /*where divisor is stored*/
/*q is where result is stored, u is where the dividend is stored,
and temporal is a temporal vector used in the different procedures*/
pdf_u32_t q[8] = {0, 0, 0, 0, 0, 0, 0, 0}, u[16], temporal[8];
pdf_u32_t d; /*used to normalise divisor and dividend*/
pdf_u32_t b = PDF_U8_DIV; /*base of the division*/
pdf_u32_t mask = 0xFF000000; /*mask used to pass info from pdf_i64_t types and arrays*/
pdf_i64_t zero = pdf_i64_new(0 , 0); /*zero in pdf_i64_t format*/
int result_sign = 1; /*used to carry the sign of the result till the end*/
ASSIGN_SAFE(p_status, PDF_OK);
if (dest != NULL)
{
z = 0;
k = 0;
/* Make a non-const divisor */
divisor = pdf_i64_new (0, 0);
pdf_i64_copy (const_divisor, &divisor, p_status);
/* Make a non-const dividend */
dividend = pdf_i64_new (0, 0);
pdf_i64_copy (const_dividend, ÷nd, p_status);
/*Check first if divisor != 0*/
if (pdf_i64_cmp(zero,divisor) == 0)
{
ASSIGN_SAFE(p_status, PDF_EDIVBYZERO);
return;
}
/*Now check the signs fo divisor and dividend*/
if (pdf_i64_cmp(divisor,zero) < 0)
{
pdf_i64_abs(&divisor,divisor, p_status);
}
if (pdf_i64_cmp(dividend,zero) < 0)
{
pdf_i64_abs(÷nd,dividend, p_status);
result_sign = -1;
}
/*We check if abs(divisor) > abs(dividend)*/
if (pdf_i64_cmp(divisor, dividend) == 1)
{
pdf_i64_assign(dest,0,0, p_status);
}
/*we store divisor in array*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
v[i] = ((divisor.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
v[i] = ((divisor.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*we store dividend in temporal array*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
temporal[i] = ((dividend.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
temporal[i] = ((dividend.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*With z we'll find the highest non-zero 8 bit number in the dividend*/
for (i = 7; i >= 0; i--)
{
if (temporal[i] != 0)
{
z = i;
}
}
/*with k we'll find the highest non-zero 8 bit number in the divisor*/
for (i = 7; i >= 0; i--)
{
if (v[i] != 0)
{
k = i;
}
}
/*With z and k the relative sizes of the different numbers are found.
See Knuth algorithm for more details on n and m.*/
n = 8 - k; /*n = size of non zero v*/
m = k - z;
/*d is used to normalise divisor and dividend; see Knuth for details*/
d = b/(v[k] + 1);
/*we store d in pdf_i64_t type*/
d_pdf = pdf_i64_new(0, d);
/*Here u and v are multiplied by d to normalise them*/
/*we use a extra long version of pdf_i64_t multiplication to avoid
unwanted overflows*/
/*normalised dividend is stored in variable u*/
mult_long(u, dividend, d_pdf);
/*normalised divisor is stored in varialbe divisor_d*/
pdf_i64_mult(&divisor_nor, divisor, d_pdf, p_status);
/*We add up 8 to z to adapt it to the new 16 bit array, but
1 is subtracted due to the inclusion of Uo. See Knuth vol2
for more details on Uo*/
z = z + 7;
/*normalised divisor is stored in array v*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
v[i] = ((divisor_nor.high & (mask >> (i * 8))) >> ((3 - i) * 8));
}
else
{
v[i] = ((divisor_nor.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
/*With u and v normalised we start the algorithm*/
/*Always add z when going through u array to get rid of non-useful zeros*/
/*The different steps follow the algorithm described in Knuth vol 2*/
for (j = 0;j <= m; j++)
{
/*Step D3*/
if (u[j + z] == v[k])
{
q_bar = b - 1;
}
else
{
q_bar = (u[j + z] * b + u[j + z + 1])/v[k];
}
while (v[k + 1] * q_bar >((u[j + z] * b + u[j + z + 1] - q_bar * v[k] ) * b + u[j + z + 2] ))
{
q_bar = q_bar - 1;
}
/*Step D4*/
/*We put q_bar into a i64 type to be able to multiply it by the normalised divisor*/
q_bar_pdf = pdf_i64_new(0, q_bar);
pdf_i64_mult(&v_pdf, divisor_nor, q_bar_pdf, p_status);
/*put u[j]...u[j + n] into a pdf_i64_t type and subtract v_pdf*/
temp = pdf_i64_new(0,0);
for (i = j + n; i >= j; i--)
{
int kk = j + n -3;
if (i >= kk)
{
temp.low = temp.low + (u[i + z] << (8 * (j + n - i)));
}
else
{
temp.high = temp.high + (u[i + z] << (8 * (j + n - i)));
}
}
pdf_i64_subtraction(&temp, temp, v_pdf, p_status);
/*We finally put q_bar in the results array*/
q[j] = q_bar;
/*If the remainder is less than zero then we re-add the divisor and subtract one from q
Step D6*/
if (pdf_i64_cmp(temp, zero) < 0)
{
q[j] = q[j] - 1;
pdf_i64_add(&temp, divisor_nor, temp, p_status);
}
/*Step D5; uj...uj+n is substituted with the uj...uj+n obtained above*/
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
temporal[i] = ((temp.high & (mask >> (i * 8))) >> ((3 - i) * 8)) ;
}
else
{
temporal[i] = ((temp.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
for (i = 7; i >= 0;i--)
{
u[z + j + n - 7 + i] = temporal[i];
}
}/*end of for in j*/
pdf_i64_assign(&temp,0,0, p_status);
for (i = 0; i < 8;i++)
{
if (i <=3)
{
temp.high = temp.high + (u[i + 8] << (8 * (7 - i)));
}
else
{
temp.low = temp.low + (u[i + 8] << (8 * (7 - i)));
}
}
if (result_sign == -1)
{
pdf_i64_t temp_sign;
pdf_i64_assign(&temp_sign,0,0, p_status);
pdf_i64_div(&temp_sign,temp,d_pdf, p_status);
pdf_i64_neg(dest, temp_sign, p_status);
}
else
{
pdf_i64_assign(dest,0,0, p_status);
pdf_i64_div(dest,temp,d_pdf, p_status);
}
}
else
{
ASSIGN_SAFE(p_status, PDF_EBADDATA);
}
}
|
|
↓
|
handle_string_char
|
29
|
59
|
112
|
src/base/pdf-token-reader.c
|
static INLINE pdf_status_t
handle_string_char (pdf_token_reader_t reader,
pdf_u32_t flags,
pdf_char_t ch,
pdf_token_t *token)
{
pdf_status_t rv;
start:
switch (reader->substate)
{
case 1: /* ignore LF */
reader->substate = 0;
if (ch == 10)
return PDF_OK;
/* fall through */
case 0: /* no special state */
{
if (ch == 92) /* '\\' */
{
reader->substate = 2; /* start an escape sequence */
return PDF_OK;
}
else if (ch == 41 && reader->intparam <= 0) /* ')'; end of string */
{
reader->intparam = -1;
return exit_state (reader, flags, token);
}
pdf_bool_t wasCR = (ch == 13);
if (wasCR)
ch = 10; /* treat as LF */
rv = store_char_grow (reader, ch);
if (rv == PDF_OK)
{
if (wasCR) /* '\r' */
reader->substate = 1; /* ignore the next char if it's LF */
else if (ch == 40) /* '(' */
++reader->intparam;
else if (ch == 41) /* ')' */
--reader->intparam;
}
return rv;
}
case 2: /* just saw a '\\' (starting an escape sequence) */
reader->substate = 0;
if (ch == 98) /* 'b' */
ch = 8; /* BS: backspace */
else if (ch == 102) /* 'f' */
ch = 12; /* FF: formfeed */
else if (ch == 110) /* 'n' */
ch = 10; /* NL: newline */
else if (ch == 114) /* 'r' */
ch = 13; /* CR: carriage return */
else if (ch == 116) /* 't' */
ch = 9; /* HT: horizontal tab */
else if (ch == 10) /* NL */
return PDF_OK; /* ignore the line break */
else if (ch == 13) /* CR */
{
/* ignore the line break; also ignore the next byte if it's LF */
reader->substate = 1;
return PDF_OK;
}
else if (ch >= 48 && ch <= 48+7) /* digits '0'--'7' */
{
/* starting an octal escape; we'll read three digits even if the
* first is '4'--'7' (and calculate the final char modulo 256),
* since the PDF/PS specs say to ignore high-order overflow */
reader->substate = 3;
reader->charparam = (ch-48);
return PDF_OK;
}
/* for any other character, including '(', ')', and '\\',
* store the same character (dropping the leading backslash) */
return store_char_grow (reader, ch);
case 3: /* saw 1 digit of an octal escape */
/* fall through */
case 4: /* saw 2 digits of an octal escape */
if (ch < 48 || ch > 48+7) /* not digits '0'--'7' */
{
rv = store_char_grow (reader, reader->charparam);
if (rv != PDF_OK) return rv;
/* ch isn't part of the escape sequence, so retry */
reader->substate = 0;
goto start;
}
/* ch is a digit from '0'--'7' */
reader->charparam = ((reader->charparam & 0x1f) << 3) | (ch - 48);
if (reader->substate == 4) /* this was the final digit */
{
rv = store_char_grow (reader, reader->charparam);
if (rv != PDF_OK) return rv;
reader->substate = 0;
return PDF_OK;
}
reader->substate = 4;
return PDF_OK;
default:
assert (0);
}
}
|
|
↓
|
pdf_time_to_string_utc_asn1
|
22
|
38
|
65
|
src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_utc_asn1(const pdf_time_t time_var)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *)pdf_alloc(PDF_MAX_UTCASN1_STR_LENGTH*sizeof(pdf_char_t));
if(str != NULL)
{
if(pdf_time_get_local_cal(time_var, &calendar) == PDF_OK)
{
pdf_i32_t smallyear;
/* Convert 4-digit year to 2-digit year */
smallyear = calendar.year -1900;
while(smallyear > 99)
{
smallyear -= 100;
}
if(calendar.gmt_offset != 0)
{
pdf_i32_t offset_hours;
pdf_i32_t offset_minutes;
offset_hours = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) / 3600;
offset_minutes = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) % 3600;
offset_minutes /= 60;
/* yymmddhhmmss+hhmm
* yymmddhhmmss-hhmm
*/
sprintf((char *)str, "%s%d%s%d%s%d%s%d%s%d%s%d%c%s%d%s%d", \
(smallyear < 10 ? "0" : ""), smallyear,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second,
((calendar.gmt_offset < 0) ? '-' : '+'),
(offset_hours < 10 ? "0" : ""), offset_hours,
(offset_minutes < 10 ? "0" : ""), offset_minutes);
}
else
{
/*
* yymmddhhmmssZ
*/
sprintf((char *)str, "%s%d%s%d%s%d%s%d%s%d%s%dZ", \
(smallyear < 10 ? "0" : ""), smallyear,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second);
}
}
else
{
PDF_DEBUG_BASE("Could not get local calendar from pdf_time_t...");
pdf_dealloc(str);
str = NULL;
}
}
return str;
}
|
|
↓
|
pdf_fp_func_4_new
|
26
|
151
|
267
|
src/base/pdf-fp-func.c
|
pdf_status_t
pdf_fp_func_4_new (pdf_u32_t m,
pdf_u32_t n,
pdf_real_t domain[],
pdf_real_t range[],
pdf_char_t *code,
pdf_size_t code_size,
pdf_size_t *error_at,
pdf_fp_func_t *function)
{
pdf_fp_func_t f;
pdf_u32_t off[BRACES_MAX_LEVEL];
pdf_u32_t braces_pos[BRACES_MAX_LEVEL];
pdf_char_t *op;
pdf_i32_t at;
pdf_i32_t to;
pdf_i32_t alloc;
pdf_i32_t bsp;
pdf_i32_t blevel; /* braces level depth */
double lit;
pdf_i32_t opc;
pdf_size_t beg_pos; /* beginning of current token */
pdf_status_t ret;
pdf_u32_t (*debug_off)[2];
pdf_size_t debug_size;
pdf_size_t debug_alloc;
size_t s_domain = sizeof(pdf_real_t)*m*2;
size_t s_range = sizeof(pdf_real_t)*n*2;
pdf_stm_t reader_stm;
pdf_token_reader_t reader;
/* Common data */
f = pdf_alloc (sizeof(struct pdf_fp_func_s));
f->m = m;
f->n = n;
f->type = 4;
f->domain = pdf_alloc (s_domain);
f->range = pdf_alloc (s_range);
memcpy (f->domain, domain, s_domain);
memcpy (f->range, range, s_range);
/* Specific data */
beg_pos = 0;
alloc = 64;
op = pdf_alloc (alloc);
debug_alloc = 64;
debug_size = 0;
debug_off = pdf_alloc (sizeof(*debug_off) * debug_alloc);
/* Initialize the token reader */
if (pdf_stm_mem_new (code,
code_size,
code_size, /* Use the default cache size */
PDF_STM_READ,
&reader_stm) != PDF_OK)
{
/* FIXME: REFINE */
ret = PDF_ERROR;
goto fail;
}
if (pdf_token_reader_new (reader_stm, &reader) != PDF_OK)
{
/* FIXME: REFINE */
ret = PDF_ERROR;
goto fail;
}
opc = get_token (reader, &lit, &beg_pos);
if (opc != OPC_begin)
{
ret = PDF_ENOWRAP;
goto fail;
}
blevel = 1;
bsp = 0;
at = 0;
for(;;)
{
if (bsp >= BRACES_MAX_LEVEL)
{
ret = PDF_ETOODEPTH;
goto fail;
}
if (at+1+sizeof(lit) >= alloc)
{
alloc *= 2;
op = pdf_realloc (op,alloc);
}
if (debug_size >= debug_alloc)
{
debug_alloc *= 2;
debug_off = pdf_realloc (debug_off, sizeof(*debug_off) * debug_alloc);
}
opc = get_token (reader, &lit, &beg_pos);
if (opc < 0)
{
ret = PDF_EEOF;
goto fail;
}
switch ((PDF_TYPE4_OPC)opc)
{
case OPC_lit_i:
case OPC_lit_r:
{
debug_off[debug_size][0] = at;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[at++] = opc;
memcpy (op+at, &lit, sizeof(lit));
at += sizeof (lit);
break;
}
case OPC_begin:
{
blevel++;
off[bsp] = at; /* backpatched by if/ifelse */
braces_pos[bsp] = beg_pos;
bsp++;
debug_off[debug_size][0] = at;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[at] = OPC_begin; /* OPC_error */
at += 1+sizeof(at);
break;
}
case OPC_end:
{
blevel--;
if (blevel)
{
off[bsp] = at;
braces_pos[bsp] = beg_pos;
bsp++;
}
else
{
void *r;
debug_off[debug_size][0] = at;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[at++] = OPC_ret;
if (get_token (reader, &lit, &beg_pos) >= 0)
{
ret = PDF_ENOWRAP;
goto fail;
}
if (bsp)
{
beg_pos = braces_pos[--bsp]; /* reporting error offset */
ret = PDF_EMISSIF;
goto fail;
}
/* memory is transferred to f, not freed here */
debug_off = pdf_realloc (debug_off, sizeof(*debug_off) * debug_alloc);
r = pdf_realloc (op,at);
if (r)
{
op = r;
}
f->u.t4.opcodes = op;
f->u.t4.n_opcodes = at;
f->u.t4.debug_off = debug_off;
f->u.t4.debug_size = debug_size;
f->eval = pdf_eval_type4;
goto success;
}
break;
}
case OPC_if:
{
if (bsp < 2 || at != off[--bsp])
{
ret = PDF_EMISSBODY;
goto fail;
}
debug_off[debug_size][0] = --bsp;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[off[bsp]] = OPC_jnt;
to = at - 1;
memcpy(op+1+off[bsp],&to,sizeof(to));
break;
}
case OPC_ifelse:
{
if (bsp < 4 || at != off[--bsp])
{
ret = PDF_EMISSBODY;
goto fail;
}
debug_off[debug_size][0] = --bsp;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[off[bsp]] = OPC_jmp;
to = at-1;
memcpy(op+off[bsp]+1,&to,sizeof(to));
to = off[bsp--];
if (to != off[bsp--])
{
ret = PDF_EMISSBODY;
goto fail;
}
to += sizeof(to);
op[off[bsp]] = OPC_jnt;
memcpy(op+off[bsp]+1,&to,sizeof(to));
break;
}
case OPC_bad:
{
ret = PDF_EBADOP;
goto fail;
break;
}
default:
{
debug_off[debug_size][0] = at;
debug_off[debug_size][1] = beg_pos;
debug_size++;
op[at++] = opc;
break;
}
}
}
/* not reached */
fail:
pdf_dealloc (op);
pdf_dealloc (debug_off);
if (error_at != NULL)
{
*error_at = beg_pos;
}
*function = NULL;
return ret;
success:
*function = f;
return PDF_OK;
}
|
|
↓
|
pdf_stm_f_aesv2_apply
|
21
|
54
|
144
|
src/base/pdf-stm-f-aesv2.c
|
static inline pdf_status_t
pdf_stm_f_aesv2_apply (pdf_stm_f_aesv2_mode_t mode,
pdf_hash_t params, void *state, pdf_buffer_t in,
pdf_buffer_t out, pdf_bool_t finish_p)
{
pdf_stm_f_aesv2_t filter_state = state;
pdf_crypt_cipher_t cipher = filter_state->cipher;
pdf_buffer_t in_cache = filter_state->in_cache;
pdf_buffer_t out_cache = filter_state->out_cache;
while(1)
{
pdf_size_t in_size;
pdf_size_t out_size;
pdf_size_t in_cache_size;
pdf_size_t out_cache_size;
pdf_size_t bytes_to_read;
pdf_size_t bytes_to_write;
/* Read bytes from IN and fill IN_CACHE*/
in_size = in->wp - in->rp;
in_cache_size = in_cache->size - in_cache->wp;
bytes_to_read = PDF_MIN (in_size, in_cache_size);
memcpy (in_cache->data + in_cache->wp,
in->data + in->rp,
bytes_to_read);
in_cache->wp += bytes_to_read;
in->rp += bytes_to_read;
/* If we cannot fill all IN_CACHE... */
if (!pdf_buffer_full_p (in_cache))
{
if (finish_p && mode == PDF_STM_F_AESV2_MODE_DECODE
&& in_cache->wp > 0)
return PDF_ERROR;
/* ...pad the cache if we have reached EOD */
if (finish_p
&& !pdf_buffer_full_p (in_cache)
&& mode == PDF_STM_F_AESV2_MODE_ENCODE)
{
pdf_size_t padding;
padding = in_cache->size - in_cache->wp;
memset (in_cache->data + in_cache->wp,
padding,
padding);
in_cache->wp += padding;
}
else
{
if (pdf_buffer_eob_p (out_cache))
return PDF_ENINPUT; /* ...ask more input */
}
}
/* If OUT_CACHE is empty and IN_CACHE is full, then it is ready
to be processed. */
if (pdf_buffer_full_p (in_cache) && pdf_buffer_eob_p (out_cache))
{
switch (mode)
{
case PDF_STM_F_AESV2_MODE_ENCODE:
pdf_crypt_cipher_encrypt (cipher,
out_cache->data,
out_cache->size,
in_cache->data,
in_cache->size,
NULL);
break;
case PDF_STM_F_AESV2_MODE_DECODE:
pdf_crypt_cipher_decrypt (cipher,
out_cache->data,
out_cache->size,
in_cache->data,
in_cache->size,
NULL);
break;
default: /* not reached */
break;
}
/* Both cache are full now */
pdf_buffer_rewind (in_cache);
out_cache->wp = out_cache->size;
}
/* When we are decrypting data, we need know what block is the
last. If both IN and IN_CACHE are empty, then OUT_CACHE could
hold it. So, we ask more input to we make sure.*/
if (mode == PDF_STM_F_AESV2_MODE_DECODE
&& pdf_buffer_eob_p (in) && pdf_buffer_eob_p (in_cache))
{
/* When we know it is the last, remove the padding. */
if (finish_p)
{
pdf_size_t padding;
padding = out_cache->data[out_cache->size - 1];
if (padding > AESV2_CACHE_SIZE)
return PDF_ERROR;
out_cache->wp = out_cache->size - padding;
}
else
return PDF_ENINPUT;
}
/* Finally, we fill the OUT buffer */
out_size = out->size - out->wp;
out_cache_size = out_cache->wp - out_cache->rp;
bytes_to_write = PDF_MIN (out_size, out_cache_size);
memcpy (out->data + out->wp,
out_cache->data + out_cache->rp,
bytes_to_write);
out_cache->rp += bytes_to_write;
out->wp += bytes_to_write;
if (finish_p)
{
return PDF_EEOF;
}
else if (pdf_buffer_full_p (out))
{
return PDF_ENOUTPUT;
}
else
{
pdf_buffer_rewind (out_cache);
}
}
}
|
|
↓
|
pdf_text_utf16he_to_utf32he
|
20
|
62
|
168
|
src/base/pdf-text-encoding.c
|
pdf_status_t
pdf_text_utf16he_to_utf32he(const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_bool_t swap,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length,
pdf_char_t **p_remaining_data,
pdf_size_t *p_remaining_length)
{
/* Note: UTF-16 has either 16 or 32 bits per character.
* This means that, if length of origin string is N bytes, the number of
* required bytes for the UTF-32 representation of the string is 2N in
* the worst case (in the case of having all the UTF-16 characters encoded
* with 16bits).
* (Each UTF-16 is expanded to 4 bytes in UTF-32. */
pdf_char_t *data;
pdf_size_t new_string_length;
pdf_size_t new_string_length_worst;
pdf_size_t delta_in_utf16be;
int i; /* index for the origin string data */
int j; /* index for the destination string data */
pdf_text_utf16_char_t utf16val[2];
pdf_text_utf32_char_t utf32val;
short stop_conversion = PDF_FALSE;
short check_lang_code = PDF_FALSE;
int bom_bytes = 0;
/* Check if length is multiple of 2 (data must come in pairs of bytes!) */
if((input_length < 2) || \
(input_length % 2) != 0)
{
PDF_DEBUG_BASE("Input length must be multiple of 2 and greater than 2!"
" Invalid UTF-16 data. (Length: %d)", (int)input_length);
return PDF_EBADDATA;
}
/* Check if BOM is present... and skip it if so */
if(pdf_text_check_unicode_bom (input_data, input_length,
PDF_TEXT_UTF16_HE, swap))
{
/* Skip BOM */
bom_bytes = 2;
}
/* Get new string worst length... (don't consider BOM bytes) */
new_string_length_worst = 2 * (input_length - bom_bytes);
/* Create destination string with worst size (but empty!) */
data = (pdf_char_t *)pdf_alloc(new_string_length_worst);
if(data == NULL)
{
return PDF_ENOMEM;
}
/* Initiate final string length */
new_string_length = 0;
/* Initiate indexes */
i = bom_bytes; /* Skipping BOM if present... */
j = 0;
/* Check if specific country/language could be found */
if((p_remaining_length != NULL) && \
(p_remaining_data != NULL))
{
check_lang_code = PDF_TRUE;
}
/* This while loop will be done until the end of the input data OR until
* the moment a new country/language code identifier is found. But, this
* extra stop condition will only be available if valid `p_remaining_data'
* and `p_remaining_length' pointers are given as input. */
while((i < input_length) && \
(!stop_conversion))
{
if((check_lang_code) && \
(input_data[i+1] == PDF_TEXT_LCI_1) && \
(input_data[i] == PDF_TEXT_LCI_0))
{
/* Stop conversion... due to new lang/code initializer */
stop_conversion = PDF_TRUE;
/* Set the output remaining data... */
*p_remaining_length = input_length - i;
*p_remaining_data = (pdf_char_t *) &input_data[i];
}
else
{
/* Store the UTF-16(BE/LE) data in the intermediate variable */
utf16val[0].c[0] = input_data[i];
utf16val[0].c[1] = input_data[i+1];
if((i+3) < input_length)
{
utf16val[1].c[0] = input_data[i+2];
utf16val[1].c[1] = input_data[i+3];
}
/* else, last point should be only 1-word length */
else
{
utf16val[1].c[0] = 0x00;
utf16val[1].c[1] = 0x00;
}
if(swap)
{
/* Input data must be swapped in order to convert it to
* host endian */
utf16val[0].i = PDF_TEXT_CHANGE_ENDIANNESS_16BIT(utf16val[0].i);
utf16val[1].i = PDF_TEXT_CHANGE_ENDIANNESS_16BIT(utf16val[1].i);
}
/* Change UTF-16HE point to UTF-32HE point */
delta_in_utf16be = pdf_text_utf16he_point_to_utf32he_point(utf16val,
&utf32val);
if(delta_in_utf16be == 0)
{
/* Oops, invalid UTF-16HE point found! */
pdf_dealloc(data);
PDF_DEBUG_BASE("Conversion from UTF-16 to UTF-32HE stopped");
return PDF_EBADTEXT;
}
/* Finally, store the UTF-32 representation of the char in the output
* string... */
data[j] = utf32val.c[0];
data[j+1] = utf32val.c[1];
data[j+2] = utf32val.c[2];
data[j+3] = utf32val.c[3];
/* Update final string length after having added this character */
new_string_length+=4;
/* Update indexes */
i += delta_in_utf16be;
j += 4;
}
}
/* Everything went ok, set output data */
*p_output_data = data;
/* Set output length... */
*p_output_length = new_string_length;
/* Check if the stop flag was set due to finding lang/country code
* initializer. If not found, set zero remaining length and NULL
* remaining str */
if((!stop_conversion) && \
(p_remaining_length != NULL) && \
(p_remaining_data != NULL))
{
*p_remaining_length = 0;
*p_remaining_data = NULL;
}
/* Now, if the real output string length is not equal to the worst string
* length, we will reallocate memory for the correct size. This will only
* happen when at least one character is not encoded with 32bits in UTF-16. */
if(new_string_length != new_string_length_worst)
{
/* Recreate object with correct size... */
*p_output_data = (pdf_char_t *)pdf_realloc(*p_output_data,
new_string_length);
if(*p_output_data == NULL)
{
return PDF_ENOMEM;
}
}
return PDF_OK;
}
|
|
↓
|
pdf_time_to_string_pdf
|
20
|
35
|
59
|
src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_pdf (const pdf_time_t time_var,
pdf_bool_t include_trailing_apostrophe)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *) pdf_alloc (PDF_MAX_PDFDATE_STR_LENGTH * sizeof(pdf_char_t));
if(str != NULL)
{
/* D:YYYYMMDDHHmmSSOHH'mm' */
if (pdf_time_get_local_cal(time_var, &calendar) == PDF_OK)
{
if (calendar.gmt_offset != 0)
{
pdf_i32_t offset_hours;
pdf_i32_t offset_minutes;
offset_hours = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) / 3600;
offset_minutes = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) % 3600;
offset_minutes /= 60; /* Get only full minutes */
sprintf((char *)str, "D:%4d%s%d%s%d%s%d%s%d%s%d%c%s%d'%s%d", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second,
((calendar.gmt_offset < 0) ? '-' : '+'),
(offset_hours < 10 ? "0" : ""), offset_hours,
(offset_minutes < 10 ? "0" : ""), offset_minutes);
if (include_trailing_apostrophe)
{
str[PDF_MAX_PDFDATE_STR_LENGTH - 2] = '\'';
str[PDF_MAX_PDFDATE_STR_LENGTH - 1] = 0;
}
}
else
{
sprintf((char *)str, "D:%4d%s%d%s%d%s%d%s%d%s%dZ", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second);
}
}
else
{
PDF_DEBUG_BASE("Could not get local calendar from pdf_time_t...");
pdf_dealloc(str);
str = NULL;
}
}
return str;
}
|
|
↓
|
pdf_text_get_unicode
|
29
|
59
|
160
|
src/base/pdf-text.c
|
pdf_status_t
pdf_text_get_unicode (pdf_char_t **contents,
pdf_size_t *length,
const pdf_text_t text,
const enum pdf_text_unicode_encoding_e enc,
const pdf_u32_t options)
{
pdf_status_t ret_code;
enum pdf_text_unicode_encoding_e new_enc;
pdf_char_t *out_data = NULL;
pdf_size_t out_length = 0;
/* Check for invalid options... */
if((options & PDF_TEXT_UTF16BE_WITH_LANGCODE) && \
(enc != PDF_TEXT_UTF16_BE))
{
PDF_DEBUG_BASE("Lang/Country info only available for UTF-16BE");
/* Not allowed!!! */
return PDF_EBADDATA;
}
/* If host endianness required, check it and convert input encoding */
new_enc = pdf_text_transform_he_to_unicode_encoding(enc);
/* If text is empty, set empty string */
if((text->data == NULL) || \
(text->size == 0))
{
out_data = NULL;
out_length = 0;
ret_code = PDF_OK;
}
else
{
/* Perform conversion */
switch(new_enc)
{
case PDF_TEXT_UTF8: /* UTF-8 */
ret_code = pdf_text_utf32he_to_utf8(text->data, text->size,
&out_data, &out_length);
break;
case PDF_TEXT_UTF16_LE: /* UTF-16LE */
ret_code = pdf_text_utf32he_to_utf16le(text->data, text->size,
&out_data, &out_length);
break;
case PDF_TEXT_UTF16_BE: /* UTF-16BE */
ret_code = pdf_text_utf32he_to_utf16be(text->data, text->size,
&out_data, &out_length);
break;
case PDF_TEXT_UTF32_LE: /* UTF-32LE */
ret_code = pdf_text_utf32he_to_utf32le(text->data, text->size,
&out_data, &out_length);
break;
case PDF_TEXT_UTF32_BE: /* UTF-32BE */
ret_code = pdf_text_utf32he_to_utf32be(text->data, text->size,
&out_data, &out_length);
break;
default:
ret_code = PDF_ETEXTENC;
}
}
/* Check if specific options were requested */
if(options != PDF_TEXT_UNICODE_NO_OPTION)
{
pdf_char_t header[PDF_TEXT_USHMAXL];
pdf_size_t header_size = 0;
pdf_size_t trailer_size = 0;
/* Compute header if needed */
if((options & PDF_TEXT_UNICODE_WITH_BOM) || \
(options & PDF_TEXT_UTF16BE_WITH_LANGCODE))
{
/* Clear header array */
memset(&(header[0]), 0, PDF_TEXT_USHMAXL);
/* Get requested header (BOM and/or lang/country info) */
pdf_text_get_unicode_string_header(header,
&header_size,
new_enc,
options,
pdf_text_get_language(text),
pdf_text_get_country(text));
}
/* Compute trailer if needed */
if(options & PDF_TEXT_UNICODE_WITH_NUL_SUFFIX)
{
switch(new_enc)
{
case PDF_TEXT_UTF8:
trailer_size = 1;
break;
case PDF_TEXT_UTF16_BE:
case PDF_TEXT_UTF16_LE:
case PDF_TEXT_UTF16_HE:
trailer_size = 2;
break;
case PDF_TEXT_UTF32_BE:
case PDF_TEXT_UTF32_LE:
case PDF_TEXT_UTF32_HE:
trailer_size = 4;
break;
default:
trailer_size = 0;
break;
}
}
if((header_size > 0) || \
(trailer_size > 0))
{
pdf_char_t *new_out_data = NULL;
/* Allocate memory for new string */
new_out_data = (pdf_char_t *)pdf_alloc(out_length + \
header_size + \
trailer_size);
if(new_out_data == NULL)
{
return PDF_ENOMEM;
}
/* Store header */
memcpy(new_out_data, &header[0], header_size);
if((out_data != NULL) && \
(out_length != 0))
{
/* Store unicode data, if any */
memcpy(&new_out_data[header_size], out_data, out_length);
/* Reset output data array, if any */
pdf_dealloc(out_data);
}
/* Store trailer (N-byte NUL) */
if(trailer_size > 0)
{
memset(&new_out_data[out_length+header_size],0,trailer_size);
}
out_data = new_out_data;
out_length += (header_size + trailer_size);
}
else
{
PDF_DEBUG_BASE("Invalid unicode option requested (%u)",
(unsigned int)options);
}
}
/* Only store in the output element if and only if everything went ok */
if(ret_code == PDF_OK)
{
*contents = out_data;
*length = out_length;
}
else if(out_data != NULL)
{
pdf_dealloc(out_data);
}
return ret_code;
}
|
|
↓
|
parse_integer
|
19
|
38
|
79
|
src/base/pdf-token-reader.c
|
static INLINE int
parse_integer (pdf_buffer_t buffer, int *int_value, int *int_state)
{
/* Parse an ASCII integer with the given radix, at the beginning of
* the buffer (possibly leaving unread bytes at the end).
*
* Return value is 0 on failure, or a bitmask otherwise:
* 1 = valid integer
* 2 = signed
* 4 = overflowed (no value stored in *int_value)
*/
int sign = 0, tmpint = 0, overflowed = 0, ret;
/* Integer states (int_state):
* 0 = at start (looking for sign or digits)
* 1 = saw sign
* 2 = saw digits
*/
*int_state = 0;
for (; buffer->rp < buffer->wp; ++buffer->rp)
{
int chval;
pdf_char_t ch = buffer->data[buffer->rp];
if (ch == 43 || ch == 45) /* '+','-' */
{
if (*int_state != 0)
goto out;
*int_state = 1;
sign = (ch == 43) ? 1 : -1;
continue;
}
chval = ch - 48; /* assume this is a digit */
if (chval < 0 || chval > 9)
goto out; /* not a valid number */
*int_state = 2;
if (overflowed)
continue;
/* convert the digits to an integer, if possible */
if (sign < 0)
{
chval = -chval;
if ( tmpint < (INT_MIN/10)
|| (tmpint == (INT_MIN/10) && chval < (INT_MIN%10)) )
{
overflowed = 1; /* would overflow */
continue;
}
}
else
{
if ( tmpint > (INT_MAX/10)
|| (tmpint == (INT_MAX/10) && chval > (INT_MAX%10)) )
{
overflowed = 1; /* would overflow */
continue;
}
}
tmpint += chval + (tmpint * 9);
}
out:
if (*int_state != 2)
return 0; /* never saw any digits */
ret = 1;
if (sign) ret += 2;
if (overflowed)
ret += 4;
else
*int_value = tmpint;
return ret;
}
|
|
↓
|
pdf_time_to_string_iso8601
|
19
|
32
|
52
|
src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_iso8601(const pdf_time_t time_var)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *)pdf_alloc(PDF_MAX_ISO8601_STR_LENGTH*sizeof(pdf_char_t));
if(str != NULL)
{
/* YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) */
if(pdf_time_get_local_cal(time_var, &calendar) == PDF_OK)
{
if(calendar.gmt_offset != 0)
{
pdf_i32_t offset_hours;
pdf_i32_t offset_minutes;
offset_hours = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) / 3600;
offset_minutes = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) % 3600;
offset_minutes /= 60; /* Get only full minutes */
sprintf((char *)str, "%4d-%s%d-%s%dT%s%d:%s%d:%s%d%c%s%d:%s%d", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second,
((calendar.gmt_offset < 0) ? '-' : '+'),
(offset_hours < 10 ? "0" : ""), offset_hours,
(offset_minutes < 10 ? "0" : ""), offset_minutes);
}
else
{
sprintf((char *)str, "%4d-%s%d-%s%dT%s%d:%s%d:%s%dZ", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second);
}
}
else
{
PDF_DEBUG_BASE("Could not get local calendar from pdf_time_t...");
pdf_dealloc(str);
str = NULL;
}
}
return str;
}
|
|
↓
|
pdf_time_to_string_generalized_asn1
|
19
|
32
|
52
|
src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_generalized_asn1(const pdf_time_t time_var)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *)pdf_alloc(PDF_MAX_ISO8601_STR_LENGTH*sizeof(pdf_char_t));
if(str != NULL)
{
/* YYYYMMDDhhmmssTZD (eg 19970716192030+01:00) */
if(pdf_time_get_local_cal(time_var, &calendar) == PDF_OK)
{
if(calendar.gmt_offset != 0)
{
pdf_i32_t offset_hours;
pdf_i32_t offset_minutes;
offset_hours = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) / 3600;
offset_minutes = (((calendar.gmt_offset < 0) ? (-1) : (1)) * calendar.gmt_offset) % 3600;
offset_minutes /= 60;
sprintf((char *)str, "%4d%s%d%s%d%s%d%s%d%s%d%c%s%d%s%d", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second,
((calendar.gmt_offset < 0) ? '-' : '+'),
(offset_hours < 10 ? "0" : ""), offset_hours,
(offset_minutes < 10 ? "0" : ""), offset_minutes);
}
else
{
sprintf((char *)str, "%4d%s%d%s%d%s%d%s%d%s%dZ", \
calendar.year,
(calendar.month < 10 ? "0" : ""), calendar.month,
(calendar.day < 10 ? "0" : ""), calendar.day,
(calendar.hour < 10 ? "0" : ""), calendar.hour,
(calendar.minute < 10 ? "0" : ""), calendar.minute,
(calendar.second < 10 ? "0" : ""), calendar.second);
}
}
else
{
PDF_DEBUG_BASE("Could not get local calendar from pdf_time_t...");
pdf_dealloc(str);
str = NULL;
}
}
return str;
}
|
|
↓
|
pdf_text_filter
|
19
|
29
|
73
|
src/base/pdf-text.c
|
pdf_status_t
pdf_text_filter (pdf_text_t text,
const pdf_u32_t filter)
{
/* More than one filter at the same time can be requested! But Caution!
* UpperCase filter, LowerCase filter and TitleCase filter are mutually
* exclusive (at most only one of them must be enabled) */
if((((filter & PDF_TEXT_FILTER_UPPER_CASE) ? 1 : 0) + \
((filter & PDF_TEXT_FILTER_LOWER_CASE) ? 1 : 0) + \
((filter & PDF_TEXT_FILTER_TITLE_CASE) ? 1 : 0)) > 1)
{
PDF_DEBUG_BASE("At most only one case conversion filter can be applied");
return PDF_EBADDATA;
}
/* 0x00000001 */
if((filter & PDF_TEXT_FILTER_LINE_ENDINGS) && \
(pdf_text_filter_normalize_line_endings(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying Line Ending normalization filter");
return PDF_ETEXTENC;
}
/* 0x00000010 */
if((filter & PDF_TEXT_FILTER_UPPER_CASE) && \
(pdf_text_filter_upper_case(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying Upper Case filter");
return PDF_ETEXTENC;
}
/* 0x00000100 */
else if((filter & PDF_TEXT_FILTER_LOWER_CASE) && \
(pdf_text_filter_lower_case(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying Lower Case filter");
return PDF_ETEXTENC;
}
/* 0x00001000 */
else if((filter & PDF_TEXT_FILTER_TITLE_CASE) && \
(pdf_text_filter_title_case(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying Title Case filter");
return PDF_ETEXTENC;
}
/* 0x00010000 */
if((filter & PDF_TEXT_FILTER_REMOVE_AMP) && \
(pdf_text_filter_remove_amp(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying Ampersand Removal filter");
return PDF_ETEXTENC;
}
/* 0x00100000 */
if((filter & PDF_TEXT_FILTER_NORM_WITH_FULL_WIDTH) && \
(pdf_text_filter_normalize_full_width_ascii(text) != PDF_OK))
{
PDF_DEBUG_BASE("Error applying FullWidth Normalization filter");
return PDF_ETEXTENC;
}
/* 0x01000000 */
if ((filter & PDF_TEXT_FILTER_REMOVE_LINE_ENDINGS) &&
(pdf_text_filter_remove_line_endings (text) != PDF_OK))
{
PDF_DEBUG_BASE ("Error applying Line Ending Removal filter");
return PDF_ETEXTENC;
}
text->modified = PDF_TRUE;
return PDF_OK;
}
|
|
↓
|
pdf_text_ucd_Final_Sigma
|
18
|
45
|
103
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_Final_Sigma(const pdf_text_ucd_context_t *context)
{
pdf_char_t *walker;
short stop;
int n_case_ignorable;
int cased_found;
if((context->unicode_point < context->context_start) || \
(context->unicode_point > context->context_stop))
{
PDF_DEBUG_BASE("Unicode point outside context interval");
/* The unicode point must not be outside the context interval */
return PDF_FALSE;
}
if(context->unicode_point == context->context_start)
{
/* If the unicode point is the start of the context, then it is impossible
* to have a sequence before it */
return PDF_FALSE;
}
/*----- Check backward -----*/
n_case_ignorable = 0;
walker = (pdf_char_t *)(context->unicode_point - 4);
stop = 0;
cased_found = 0;
while(!stop)
{
if(walker < context->context_start)
{
/* Arrived to context start, stop loop */
stop = 1;
}
else
{
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
if(pdf_text_ucd_is_case_ignorable(aux_point))
{
n_case_ignorable++;
}
else if(pdf_text_ucd_is_cased(aux_point))
{
cased_found = 1; /* Cased char found, stop loop */
stop = 1;
}
if(!stop)
{
walker -= 4; /* Point to previous UTF-32 char */
}
}
}
/* Check status of previous characters */
if((cased_found == 1) && \
(n_case_ignorable >= 0))
{
/*----- Check forward -----*/
walker = (pdf_char_t *)(context->unicode_point + 4);
stop = 0;
cased_found = 0;
n_case_ignorable = 0;
while(!stop)
{
if(walker > context->context_stop)
{
/* Arrived to context end, stop loop */
stop = 1;
}
else
{
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
if(pdf_text_ucd_is_case_ignorable(aux_point))
{
n_case_ignorable++;
}
else if(pdf_text_ucd_is_cased(aux_point))
{
cased_found = 1; /* Cased char found, stop loop */
stop = 1;
}
if(!stop)
{
walker += 4; /* Point to next UTF-32 char */
}
}
}
/* Check status of next characters */
if((cased_found == 0) && \
(n_case_ignorable == 0))
{
return PDF_TRUE;
}
}
return PDF_FALSE;
}
|
|
↓
|
pdf_text_new_from_pdf_string
|
18
|
37
|
117
|
src/base/pdf-text.c
|
pdf_status_t
pdf_text_new_from_pdf_string (const pdf_char_t *str,
const pdf_size_t size,
pdf_char_t **remaining_str,
pdf_size_t *remaining_length,
pdf_text_t *text)
{
pdf_status_t ret_code = PDF_ETEXTENC;
pdf_status_t ret_code_new;
pdf_text_t element = NULL;
short bom_found = 0;
short lang_found = 0;
if(str == NULL)
{
return PDF_EBADDATA;
}
/* Allocate and initialize element */
ret_code_new = pdf_text_new (&element);
if (ret_code_new != PDF_OK)
{
/* Oops, element creation failed due to some error... */
return ret_code_new;
}
/* First of all, check first two bytes to detect UTF-16BE BOM or lang/country
* code initializer.
* If length of the text is less than 2, then we can assume it is encoded in
* PDF Doc Encoding */
if(size >= 2)
{
/* Check Unicode Byte Order Marker encoded in UTF-16BE */
if(pdf_text_check_unicode_bom(str, size, PDF_TEXT_UTF16_BE, 0))
{
bom_found = 1;
/* Check Lang/Country Code initializer */
if((size >= 4) && \
(str[3] == PDF_TEXT_LCI_1) && \
(str[2] == PDF_TEXT_LCI_0))
{
lang_found = 1;
}
}
/* Check Lang/Country Code initializer (if this is the nth call to the
* function parsing a single UTF-16BE string.*/
else if((str[1] == PDF_TEXT_LCI_1) && \
(str[0] == PDF_TEXT_LCI_0))
{
lang_found = 1;
}
}
/* If either BOM or Lang Marker are found, process PDF string as encoded
* in UTF16-BE */
if(bom_found || lang_found)
{
pdf_char_t *string_start = (pdf_char_t *)str;
pdf_size_t string_length = size;
/* Skip 2-bytes BOM */
if(bom_found)
{
string_start += 2;
string_length -= 2;
}
/* If lang/country code available, obtain and store the information */
if((lang_found) && \
(pdf_text_get_lang_from_utf16be(element,
&string_start, &string_length,
string_start, string_length)!=PDF_OK))
{
PDF_DEBUG_BASE("Invalid Lang/Code info detected");
pdf_text_destroy(element);
return PDF_ETEXTENC;
}
/* And finally convert to UTF-32... */
ret_code = pdf_text_utf16be_to_utf32he(string_start,
string_length,
&(element->data),
&(element->size),
remaining_str,
remaining_length);
}
/* Else, process PDF string as encoded in PDF Doc Encoding */
else
{
/* We already know that this string will be fully stored, without
* splitting in chunks */
if(remaining_length != NULL)
{
*remaining_length = 0;
}
if(remaining_str != NULL)
{
*remaining_str = NULL;
}
/* And perform the conversion */
ret_code = pdf_text_pdfdocenc_to_utf32he(str,
size,
&(element->data),
&(element->size));
}
/* Only store in the output element if and only if everything went ok */
if(ret_code == PDF_OK)
{
*text = element;
}
else
{
pdf_text_destroy(element);
}
return ret_code;
}
|
|
↓
|
write_string_token
|
25
|
61
|
99
|
src/base/pdf-token-writer.c
|
static INLINE pdf_status_t
write_string_token (pdf_token_writer_t writer, pdf_u32_t flags,
pdf_token_t token)
{
pdf_status_t rv;
const pdf_char_t *data = pdf_token_get_string_data (token);
pdf_size_t size = pdf_token_get_string_size (token);
switch (writer->stage)
{
case 0:
{
pdf_bool_t use_hex = (flags & PDF_TOKEN_HEX_STRINGS);
if (!use_hex)
scan_string (writer, flags, data, size, &use_hex);
if (use_hex)
goto hexstring_start;
}
++writer->stage; /* fall through */
case 1:
{
/* Passing a correct length to start_token isn't important
* since we can split the string across multiple lines. */
pdf_size_t dummy_len = PDF_MIN(20, 2 + size);
rv = start_token (writer, PDF_FALSE /*need_wspace*/, dummy_len);
if (rv != PDF_OK) return rv;
}
pdf_buffer_rewind (writer->buffer);
writer->buffered_line_length = writer->line_length;
write_buffered_char_nocheck (writer, 40 /* '(' */);
writer->pos = 0;
++writer->stage; /* fall through */
case 2:
while (writer->pos < size)
{
rv = write_string_char (writer, flags, data, size, writer->pos);
if (rv != PDF_OK) return rv;
++writer->pos;
}
++writer->stage; /* fall through */
case 3:
rv = write_buffered_char (writer, 41 /* ')' */);
if (rv != PDF_OK) return rv;
++writer->stage; /* fall through */
case 4:
return flush_buffer (writer);
/*** hex strings ***/
hexstring_start:
writer->stage = 101;
case 101:
{
pdf_size_t dummy_len = PDF_MIN(20, 2 + size*2);
rv = start_token (writer, PDF_FALSE /*need_wspace*/, dummy_len);
if (rv != PDF_OK) return rv;
}
pdf_buffer_rewind (writer->buffer);
writer->buffered_line_length = writer->line_length;
write_buffered_char_nocheck (writer, 60 /* '<' */);
writer->pos = 0;
++writer->stage; /* fall through */
case 102:
while (writer->pos < size)
{
/* If this line would be too long, start a new one. */
if (writer->buffered_line_length + 2 > writer->max_line_length
&& writer->max_line_length > 0)
{
rv = write_buffered_char (writer, 10); /* newline */
if (rv != PDF_OK) return rv;
assert (writer->buffered_line_length == 0);
}
pdf_char_t ch = data[writer->pos];
rv = reserve_buffer_space (writer, 2);
if (rv != PDF_OK) return rv;
write_buffered_char_nocheck (writer, hexchar (ch / 16));
if (writer->pos == size-1 && (ch%16) == 0)
; /* don't write a final 0 */
else
write_buffered_char_nocheck (writer, hexchar (ch % 16));
++writer->pos;
}
++writer->stage; /* fall through */
case 103:
rv = write_buffered_char (writer, 62 /* '>' */);
if (rv != PDF_OK) return rv;
++writer->stage; /* fall through */
case 104:
return flush_buffer (writer);
default:
return PDF_EBADDATA;
}
}
|
|
↓
|
write_string_char
|
25
|
51
|
74
|
src/base/pdf-token-writer.c
|
static INLINE pdf_status_t
write_string_char (pdf_token_writer_t writer, pdf_u32_t flags,
const pdf_char_t *data, pdf_char_t len,
pdf_size_t pos)
{
assert (len > 0);
pdf_status_t rv;
const pdf_char_t *output = data + pos;
pdf_size_t outlen = 1;
pdf_char_t esc[4] = {92 /* '\\' */, 0, 0, 0};
pdf_char_t ch = data[pos];
pdf_bool_t quote_parens = (pos >= writer->paren_quoting_start
&& pos < writer->paren_quoting_end);
if (should_escape_strchar (flags, ch, quote_parens, writer->utf8))
{
/* escape the character */
output = esc;
outlen = 2;
switch (ch)
{
case 8: esc[1] = 98; break; /* 'b' */
case 9: esc[1] = 116; break; /* 't' */
case 10: esc[1] = 110; break; /* 'n' */
case 12: esc[1] = 102; break; /* 'f' */
case 13: esc[1] = 114; break; /* 'r' */
case 40: /* '('; fall through */
case 41: /* ')'; fall through */
case 92: /* '\\' */
esc[1] = ch;
break;
default: /* use an octal escape */
{
pdf_size_t digits;
pdf_char_t nextch = (pos+1 < len) ? data[pos+1] : 0;
if (nextch >= 48 && nextch <= 57) /* '0'..'9' */
digits = 3; /* must use 3 octal characters */
else if (ch > 0100) digits = 3;
else if (ch > 010) digits = 2;
else digits = 1;
outlen = 1;
switch (digits)
{
/* fall through each case */
case 3: esc[outlen++] = hexchar (ch / 0100);
case 2: esc[outlen++] = hexchar ((ch % 0100) / 010);
case 1: esc[outlen++] = hexchar (ch % 010);
}
}
}
}
/* If the line will be too long, split it (the length cannot be equal to
* the maximum, since this would leave no room for the backslash). */
if (writer->max_line_length > 0 && !pdf_is_eol_char (output[0])
&& writer->buffered_line_length + outlen >= writer->max_line_length)
{
rv = reserve_buffer_space (writer, 2);
if (rv != PDF_OK) return rv;
write_buffered_char_nocheck (writer, 92); /* '\\' */
write_buffered_char_nocheck (writer, 10); /* newline */
assert (writer->buffered_line_length == 0);
}
rv = reserve_buffer_space (writer, outlen);
if (rv == PDF_OK)
{
pdf_size_t i;
for (i = 0; i < outlen; ++i)
write_buffered_char_nocheck (writer, output[i]);
}
return rv;
}
|
|
↓
|
pdf_text_ucd_wb_check_rules
|
16
|
2
|
19
|
src/base/pdf-text-ucd-wordbreak.c
|
static pdf_bool_t
pdf_text_ucd_wb_check_rules(const pdf_text_ucd_wb_t buffer [PDF_TEXT_UCD_MWBCP])
{
return (((pdf_text_ucd_wb_rule_3(buffer)) || \
(pdf_text_ucd_wb_rule_3a(buffer)) || \
(pdf_text_ucd_wb_rule_3b(buffer)) || \
(pdf_text_ucd_wb_rule_4(buffer)) || \
(pdf_text_ucd_wb_rule_5(buffer)) || \
(pdf_text_ucd_wb_rule_6(buffer)) || \
(pdf_text_ucd_wb_rule_7(buffer)) || \
(pdf_text_ucd_wb_rule_8(buffer)) || \
(pdf_text_ucd_wb_rule_9(buffer)) || \
(pdf_text_ucd_wb_rule_10(buffer)) || \
(pdf_text_ucd_wb_rule_11(buffer)) || \
(pdf_text_ucd_wb_rule_12(buffer)) || \
(pdf_text_ucd_wb_rule_13(buffer)) || \
(pdf_text_ucd_wb_rule_13a(buffer)) || \
(pdf_text_ucd_wb_rule_13b(buffer))) ? PDF_TRUE : PDF_FALSE);
}
|
|
↓
|
pdf_text_compare_words
|
15
|
46
|
96
|
src/base/pdf-text.c
|
static pdf_i32_t
pdf_text_compare_words(const pdf_char_t *word1,
const pdf_size_t size1,
const pdf_char_t *word2,
const pdf_size_t size2,
const pdf_char_t *language1,
const pdf_char_t *language2,
pdf_status_t *p_ret_code)
{
pdf_char_t *lower1;
pdf_char_t *lower2;
pdf_size_t new_size1;
pdf_size_t new_size2;
pdf_size_t worst_size;
if(p_ret_code != NULL)
{
*p_ret_code = PDF_OK;
}
/* Compare sizes of words */
if(size1 != size2)
{
return ((size1 > size2) ? 1 : -1);
}
/* Compute new worst word length */
worst_size = size1 * UCD_SC_MAX_EXPAND;
/* Allocate memory for lowercases */
lower1 = (pdf_char_t *)pdf_alloc(worst_size);
lower2 = (pdf_char_t *)pdf_alloc(worst_size);
if((lower1 == NULL) || \
(lower2 == NULL))
{
PDF_DEBUG_BASE("Unable to compare words");
if(p_ret_code != NULL)
{
*p_ret_code = PDF_ENOMEM;
}
if(lower1 != NULL)
{
pdf_dealloc(lower1);
}
if(lower2 != NULL)
{
pdf_dealloc(lower2);
}
return -1;
}
/* Lowercase words */
if(pdf_text_ucd_word_change_case(lower1, &new_size1,
UNICODE_CASE_INFO_LOWER_CASE,
word1, size1, language1)!= PDF_OK)
{
PDF_DEBUG_BASE("Problem lowercasing word 1");
pdf_dealloc(lower1);
pdf_dealloc(lower2);
if(p_ret_code != NULL)
{
*p_ret_code = PDF_ETEXTENC;
}
return -1;
}
if(pdf_text_ucd_word_change_case(lower2, &new_size2,
UNICODE_CASE_INFO_LOWER_CASE,
word2, size2, language2)!= PDF_OK)
{
PDF_DEBUG_BASE("Problem lowercasing word 2");
pdf_dealloc(lower1);
pdf_dealloc(lower2);
if(p_ret_code != NULL)
{
*p_ret_code = PDF_ETEXTENC;
}
return -1;
}
/* Compare NEW sizes of words */
if(new_size1 != new_size2)
{
pdf_dealloc(lower1);
pdf_dealloc(lower2);
return ((new_size1 > new_size2) ? 1 : -1);
}
else
{
/* Compare contents of words */
pdf_i32_t ret_val;
ret_val = memcmp(lower1, lower2, new_size1);
pdf_dealloc(lower1);
pdf_dealloc(lower2);
return ret_val;
}
}
|
|
↓
|
read_and_inflate
|
15
|
34
|
76
|
src/base/pdf-stm-f-flate.c
|
static pdf_status_t read_and_inflate (pdf_stm_f_flate_t st, pdf_buffer_t in,
pdf_buffer_t out)
{
/* Fill the input CHUNK */
if (!st->writing_p)
{
while (st->incnt < PDF_STM_F_FLATE_CHUNK && !pdf_buffer_eob_p(in))
{
st->inbuf[st->incnt] = in->data[in->rp];
st->incnt++;
in->rp++;
}
}
else
{
/*
* Not nice, but keeps the writing process code clear.
* Notice that the labeled code is inside a while loop,
* so I feel that avoiding this goto won't bring us better code.
*/
goto writing;
}
if (st->incnt == 0)
{
return PDF_ENINPUT;
}
/* we inflate and write to out */
st->stream.avail_in = st->incnt;
st->stream.next_in = st->inbuf;
do {
st->stream.avail_out = PDF_STM_F_FLATE_CHUNK;
st->stream.next_out = st->outbuf;
st->outcnt = 0;
st->zret = inflate(&(st->stream), Z_NO_FLUSH);
if (st->zret == Z_STREAM_ERROR || st->zret == Z_NEED_DICT ||
st->zret == Z_DATA_ERROR || st->zret == Z_MEM_ERROR)
{
/* should not be reached */
inflateEnd(&(st->stream));
return PDF_ERROR;
}
st->to_write = PDF_STM_F_FLATE_CHUNK - st->stream.avail_out;
writing:
while (st->outcnt < st->to_write && !pdf_buffer_full_p(out))
{
out->data[out->wp] = st->outbuf[st->outcnt];
out->wp++;
st->outcnt++;
}
if (pdf_buffer_full_p(out))
{
st->writing_p = PDF_TRUE;
return PDF_ENOUTPUT;
}
} while (st->stream.avail_out == 0);
if (st->zret == Z_STREAM_END)
{
return PDF_EEOF;
}
/* the input CHUNK now is empty, if needed, ask for input */
st->writing_p = PDF_FALSE;
st->incnt = 0;
if (pdf_buffer_eob_p(in))
{
return PDF_ENINPUT;
}
/* ask for the input we couldn't read */
return PDF_OK;
}
|
|
↓
|
pdf_stm_filter_apply
|
15
|
31
|
80
|
src/base/pdf-stm-filter.c
|
pdf_status_t
pdf_stm_filter_apply (pdf_stm_filter_t filter,
pdf_bool_t finish_p)
{
pdf_status_t ret;
pdf_status_t apply_ret;
pdf_status_t ret_in;
/* If the filter is in an error state or it is in an eof state, just
communicate it to the caller */
if (filter->status != PDF_OK)
{
return filter->status;
}
ret = PDF_OK;
while (!pdf_buffer_full_p (filter->out))
{
/* Generate output */
apply_ret = filter->impl.apply_fn (filter->params,
filter->state,
filter->in,
filter->out,
filter->really_finish_p);
if (apply_ret == PDF_ERROR)
{
/* The filter is now in an error condition. We should not
call this filter anymore without a previous reset */
filter->status = PDF_ERROR;
ret = filter->status;
break;
}
if (apply_ret == PDF_EEOF)
{
/* The filter is now in an EOF condition. We should not call
this filter anymore without a previous reset */
filter->status = PDF_EEOF;
ret = filter->status;
break;
}
if (apply_ret == PDF_ENINPUT)
{
/* The filter needs more input, try to get the input buffer
filled with some data */
ret_in = pdf_stm_filter_get_input (filter, finish_p);
if (ret_in == PDF_ERROR)
{
filter->status = PDF_ERROR;
ret = filter->status;
break;
}
else if ((ret_in == PDF_EEOF)
&& (pdf_buffer_eob_p (filter->in)))
{
if (((filter->mode == PDF_STM_FILTER_MODE_WRITE)
&& ((finish_p) && (!filter->really_finish_p))) ||
((filter->mode == PDF_STM_FILTER_MODE_READ)
&& (!filter->really_finish_p)))
{
filter->really_finish_p = PDF_TRUE;
}
else
{
ret = PDF_EEOF;
break;
}
}
}
if (apply_ret == PDF_ENOUTPUT)
{
/* The filter needs to generate output and the output buffer
is full */
filter->status = PDF_OK;
break;
}
}
return ret;
}
|
|
↓
|
pdf_fp_func_0_new
|
21
|
66
|
151
|
src/base/pdf-fp-func.c
|
pdf_status_t
pdf_fp_func_0_new (pdf_u32_t m,
pdf_u32_t n,
const pdf_real_t domain[],
const pdf_real_t range[],
pdf_u32_t size[],
pdf_u32_t bps,
pdf_u32_t order,
const pdf_real_t encode[],
const pdf_real_t decode[],
pdf_char_t *samples,
pdf_size_t samples_size,
pdf_fp_func_t *function)
{
pdf_status_t ret;
pdf_fp_func_t f;
pdf_u32_t i, j, k;
pdf_u32_t nsamples;
pdf_u32_t nsamples_limit;
ret = PDF_OK;
/* Common data */
f = pdf_alloc (sizeof(struct pdf_fp_func_s));
f->m = m;
f->n = n;
f->type = 0;
/* Specific data */
f->u.t0.size = size;
/* Get the number of samples */
nsamples = 1;
nsamples_limit = 1U<<28/f->n; /* insane values */
for (i = 0; i < m; i++)
{
if (f->u.t0.size[i] > nsamples_limit/nsamples) /* avoid overflow */
{
return PDF_EOVERFLOW;
}
nsamples *= f->u.t0.size[i];
}
f->u.t0.nsamples = nsamples;
/* Manage the bits per sample value */
switch (bps)
{
case 1:
case 2:
case 4:
case 8:
case 12:
case 16:
case 24:
case 32: /* possible loss of precision in conversion to pdf_real_t */
{
break;
}
default:
{
/* ths implementation allows any value between 1 and 32 */
/* the spec does not */
return PDF_EBADDATA;
}
}
f->u.t0.m = f->m;
f->u.t0.n = f->n;
if (f->u.t0.m > 12 ) /* sanity check */
{
return PDF_EMTOOBIG;
}
f->u.t0.y = read_type0_sample_table (samples,
samples_size,
bps,
nsamples,
f->n);
if (!f->u.t0.y)
{
return PDF_EBADSAMPLES;
}
if (encode != NULL)
{
f->u.t0.encode = pdf_alloc (2 * f->m * sizeof(f->u.t0.encode[0]));
for (k = 0; k < f->m; k++)
{
setmap(f->u.t0.encode + (2 * k),
encode + (2 * k),
f->domain + (2 * k));
}
}
else
{
/* Use the default encoding array */
pdf_real_t enc[2];
enc[0] = 0;
for (k = 0; k < f->m; k++)
{
enc[1] = f->u.t0.size[k] - 1;
setmap(f->u.t0.encode + 2*k, enc, f->domain+2*k);
}
}
if (decode != NULL)
{
f->u.t0.decode = pdf_alloc (2 * f->n * sizeof(f->u.t0.decode[0]));
for (j = 0; j < f->n; j++)
{
setmap (f->u.t0.decode + (2 * j),
f->range + (2 * j),
decode + (2 * j));
}
}
else
{
/* Use the default decoding array */
pdf_real_t dec[2];
dec[0] = 0;
dec[1] = (bps < 32) ? ((1U<n; j++)
{
setmap (f->u.t0.decode + (2 * j),
f->range + (2 * j),
dec);
}
}
f->u.t0.k = pdf_alloc (m * sizeof(f->u.t0.k[0]));
f->u.t0.w0 = pdf_alloc (m * sizeof(f->u.t0.w0[0]));
f->u.t0.w1 = pdf_alloc (m * sizeof(f->u.t0.w1[0]));
if (order == 3)
{
f->u.t0.wm = pdf_alloc (m * sizeof(f->u.t0.wm[0]));
f->u.t0.w2 = pdf_alloc (m * sizeof(f->u.t0.w2[0]));
f->eval = pdf_eval_spline;
}
else
{
f->eval = pdf_eval_linear;
}
*function = f;
return ret;
}
|
|
↓
|
pdf_i64_mult
|
14
|
55
|
121
|
src/base/pdf-types.c
|
void
pdf_i64_mult (pdf_i64_t *dest,
const pdf_i64_t factor_1,
const pdf_i64_t factor_2,
pdf_status_t *p_status)
{
int i, j;
/* Variables follow the nomenclature of the algorithm
presented in Knuth vol 2.
k is the carry bit, t is a variable used to save partial results,
the mask is used to tranfer data from arrays to pdf_i64_t types,
and cont is a simple counter */
pdf_u32_t mask, t , k;
pdf_i64_t multiplier, multiplicand;
/* The result is stored in w */
pdf_u32_t w[] ={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/* v is an array where the multiplier is stored, and u is where the
multiplicand is stored*/
pdf_u32_t v[8], u[8];
int result_sign = 1; /* Used to carry the sign of the result till the end */
pdf_i64_t zero; /* Used to store zero value in pdf_i64_t format */
pdf_i64_t temp; /* Variable used to save partial results */
ASSIGN_SAFE(p_status, PDF_OK);
if (dest != NULL)
{
pdf_i64_abs (&multiplicand, factor_1, p_status);
pdf_i64_abs (&multiplier, factor_2, p_status);
/*Knuth vol 2 method*/
/* Now check the signs of multiplier and multiplicand */
pdf_i64_assign(&zero,0,0, p_status);
if (pdf_i64_cmp(factor_1,zero) < 0)
{
result_sign = -1;
pdf_i64_abs(&multiplier,multiplier, p_status);
}
if (pdf_i64_cmp(factor_2,zero) < 0)
{
pdf_i64_abs(&multiplicand,multiplicand, p_status);
if (result_sign == -1)
{
result_sign = 1;
}
else
{
result_sign = -1;
}
}
mask = 0xFF000000;
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
v[i] = ((multiplier.high & (mask >> (i * 8))) >> ((3 - i) * 8));
}
else
{
v[i] = ((multiplier.low & (mask >> ((i - 4) * 8))) >> ( (7 - i) * 8));
}
}
for (i = 0; i < 8;i++)
{
if (i <= 3)
{
u[i] = ((multiplicand.high & (mask >> (i * 8))) >> ((3 - i) * 8));
}
else
{
u[i] = ((multiplicand.low & (mask >> ((i - 4) * 8))) >> ((7 - i) * 8));
}
}
for (j = 7; j >= 0;j--)
{
k = 0;
for(i = 7; i >= 0;i--)
{
t = u[i] * v[j] + w[i + j + 1] + k;
w[i + j + 1] = t % PDF_U8_DIV;
k = t / PDF_U8_DIV;
}
}
pdf_i64_assign(&temp, 0, 0, p_status);
for (i = 0; i < 8;i++)
{
if (i <=3)
{
temp.high = temp.high + (w[i + 8] << (8 * (7 - i)));
}
else
{
temp.low = temp.low + (w[i + 8] << (8 * (7 - i)));
}
}
/* Accomodate final result to the sign of the multiplicand and
multiplier */
if (result_sign == -1)
{
pdf_i64_neg(dest, temp, p_status);
}
else
{
pdf_i64_assign(dest, temp.high, temp.low, p_status);
}
}
else
{
ASSIGN_SAFE(p_status, PDF_EBADDATA);
}
}
|
|
↓
|
pdf_text_host_to_utf32he_iconv
|
14
|
52
|
131
|
src/base/pdf-text-host-encoding.c
|
static pdf_status_t
pdf_text_host_to_utf32he_iconv(const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_text_host_encoding_t enc,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length)
{
iconv_t from_host;
size_t n_conv;
char *in_str;
size_t n_in;
size_t n_out;
pdf_char_t *new_data;
char *out_str;
pdf_size_t worst_length;
pdf_size_t new_length;
/* Check if conversion is available. If we just specify "UTF-32" as the
* output encoding requested, iconv will insert the BOM by default, and
* we don't want it, so we specify directly the endianness required in the
* name of the encoding, depending on the host endianness */
from_host = iconv_open((PDF_IS_BIG_ENDIAN ? "UTF-32BE" : "UTF-32LE"),
(char *)enc.name);
if(from_host == (iconv_t)-1)
{
PDF_DEBUG_BASE("Conversion from '%s' to UTF-32 not available",
enc.name);
return PDF_ETEXTENC;
}
/* Prepare lengths and locations.
* The worst length is computed as having 4 output bytes for each input
* single byte, taking into account that iconv adds an extra 32-bit NUL
* value (4 bytes equal to 0) at the end of the converted string. */
worst_length = (input_length+1)*4;
new_data = (pdf_char_t *)pdf_alloc(worst_length);
if(new_data == NULL)
{
iconv_close(from_host);
return PDF_ENOMEM;
}
n_out = worst_length;
in_str = (char *)input_data;
out_str = (char *)new_data;
n_in = input_length;
while(n_in > 0)
{
/* Convert */
n_conv = iconv(from_host, &in_str, &n_in, &out_str, &n_out);
/* Check conversion output status. We check errno to see if the problem
* is that more buffer is needed in the output. If this is the case,
* we just give a second try to the worst length and reallocate memory.
* There is no problem to use errno in multi-threaded applications
* if the library is compiled with -D_REENTRANT */
if(n_conv == (size_t)-1)
{
if(errno == E2BIG)
{
pdf_size_t n_bytes_generated = 0;
/* Compute the number of bytes actually generated in the
* output buffer. `n_out' stores the number of bytes still
* available in the output buffer. As the number of bytes
* allocated is multiple of four, and UTF-32 always uses 4
* bytes for each character, this value should always be 0 */
n_bytes_generated = (pdf_size_t) (worst_length - n_out);
/* We need more output buffer */
worst_length += (n_in * 4);
PDF_DEBUG_BASE("Reallocating to '%lu'. "
"'%lu' bytes are already generated",
(unsigned long) worst_length,
(unsigned long) n_bytes_generated);
/* Reallocate buffer with greater size */
new_data = (pdf_char_t *)pdf_realloc(new_data,worst_length);
if(new_data == NULL)
{
iconv_close(from_host);
return PDF_ENOMEM;
}
/* The re-allocated new data does not have to be in the same
* memory place as the original one, so the `out_str' pointer
* must be reset */
out_str = (char *) &new_data[n_bytes_generated];
/* The number of bytes available in the buffer must also be
* reset */
n_out = (worst_length - n_bytes_generated);
}
else
{
iconv_close(from_host);
pdf_dealloc(new_data);
PDF_DEBUG_BASE("Invalid data to convert from Host Encoding:"
"'%s'",strerror(errno));
return PDF_EBADTEXT;
}
}
}
/* Compute new final length */
new_length = worst_length - n_out;
/* Remove from the length the bytes related to the 4-byte NUL UTF-32 char */
if((new_data[new_length-1] == '\0') && \
(new_data[new_length-2] == '\0') && \
(new_data[new_length-3] == '\0') && \
(new_data[new_length-4] == '\0'))
{
new_length -= 4;
}
/* Finally, reset the buffer length to its correct size */
if(new_length != worst_length)
{
new_data = (pdf_char_t *)pdf_realloc(new_data,new_length);
if(new_data == NULL)
{
return PDF_ENOMEM;
}
}
/* And set the output values within pdf_text_t */
*p_output_data = new_data;
*p_output_length = new_length;
iconv_close(from_host);
return PDF_OK;
}
|
|
↓
|
pdf_stm_f_lzwenc_apply
|
14
|
38
|
85
|
src/base/pdf-stm-f-lzw.c
|
pdf_status_t
pdf_stm_f_lzwenc_apply (pdf_hash_t params,
void *ext_state,
pdf_buffer_t in,
pdf_buffer_t out,
pdf_bool_t finish_p)
{
pdf_status_t ret;
lzwenc_state_t st;
ret = PDF_OK;
st = ext_state;
lzw_buffer_set (&st->buffer, out);
ret = lzw_buffer_flush (&st->buffer);
if (ret != PDF_OK)
{
return ret;
}
if (st->really_finish_p)
{
return PDF_EEOF;
}
if (st->must_reset_p)
{
lzw_buffer_put_code (&st->buffer, LZW_RESET_CODE);
st->must_reset_p = PDF_FALSE;
}
while (!pdf_buffer_eob_p (in) &&
!pdf_buffer_full_p (out))
{
st->string.suffix = in->data [in->rp++];
if (lzw_dict_add (&st->dict, &st->string))
{
lzw_buffer_put_code (&st->buffer, st->string.prefix);
st->string.prefix = st->string.suffix;
if (st->buffer.maxval - st->early_change == st->dict.size)
{
if (!lzw_buffer_inc_bitsize(&st->buffer))
{
lzw_buffer_put_code (&st->buffer, LZW_RESET_CODE);
lzw_buffer_set_bitsize (&st->buffer, LZW_MIN_BITSIZE);
lzw_dict_reset (&st->dict);
}
}
}
}
if (finish_p)
{
lzw_buffer_put_code (&st->buffer, st->string.prefix);
if ((st->buffer.maxval - st->early_change) == st->dict.size)
{
lzw_buffer_inc_bitsize(&st->buffer);
}
lzw_buffer_put_code (&st->buffer, LZW_EOD_CODE);
lzw_buffer_put_code (&st->buffer, 0); /* flush */
if (pdf_buffer_full_p (out))
{
ret = PDF_ENOUTPUT;
}
else
{
ret = PDF_EEOF;
}
st->really_finish_p = PDF_TRUE;
}
else if (pdf_buffer_full_p (out))
{
ret = PDF_ENOUTPUT;
}
else if (pdf_buffer_eob_p (in))
{
ret = PDF_ENINPUT;
}
return ret;
}
|
|
↓
|
pdf_text_utf32he_to_utf32he
|
14
|
32
|
101
|
src/base/pdf-text-encoding.c
|
pdf_status_t
pdf_text_utf32he_to_utf32he(const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_bool_t swap,
const pdf_bool_t check_input_he,
const pdf_bool_t check_output_he,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length)
{
pdf_size_t walker;
pdf_size_t bom_bytes = 0;
pdf_char_t *new_data = NULL;
pdf_size_t new_size = 0;
if(input_length % 4 != 0)
{
/* Invalid number of bytes! */
PDF_DEBUG_BASE("Input length must be multiple of 4! Invalid UTF-32 data."
" (Length: %d)", (int)input_length);
return PDF_EBADDATA;
}
/* Check if BOM is present... and skip it if so */
if(pdf_text_check_unicode_bom (input_data, input_length,
PDF_TEXT_UTF32_HE, swap))
{
/* Skip BOM */
bom_bytes = 4;
}
/* Allocate memory */
new_size = input_length - bom_bytes;
/* Create destination string with correct size (but empty!) */
new_data = (pdf_char_t *)pdf_alloc(new_size);
if(new_data == NULL)
{
return PDF_ENOMEM;
}
/* Change endianness of each 32bit value... */
for(walker = bom_bytes; walker < input_length; walker+=4)
{
pdf_text_utf32_char_t utf32val;
memcpy(&utf32val, &input_data[walker], 4);
/* Check code point validity (if the input is Host Endian) */
/* Code point must not be a surrogate code unit, and must be in the
* U+00000000 - U+0010FFFF range */
if(check_input_he)
{
if((utf32val.i > 0x10FFFF) || \
((utf32val.i >= 0xD800) && \
(utf32val.i <= 0xDFFF)))
{
/* Invalid UTF-32 code point received */
PDF_DEBUG_BASE("Invalid input UTF-32HE code point: "
"%.2X:%.2X:%.2X:%.2X",
utf32val.c[0],
utf32val.c[1],
utf32val.c[2],
utf32val.c[3]);
return PDF_EBADTEXT;
}
}
/* Swap bytes */
if(swap)
{
utf32val.i = PDF_TEXT_CHANGE_ENDIANNESS_32BIT(utf32val.i);
}
/* Check code point validity (if the output is Host Endian) */
/* Code point must not be a surrogate code unit, and must be in the
* U+00000000 - U+0010FFFF range */
if(check_output_he)
{
if((utf32val.i > 0x10FFFF) || \
((utf32val.i >= 0xD800) && \
(utf32val.i <= 0xDFFF)))
{
/* Invalid UTF-32 code point received */
PDF_DEBUG_BASE("Invalid output UTF-32HE code point: "
"%.2X:%.2X:%.2X:%.2X",
utf32val.c[0],
utf32val.c[1],
utf32val.c[2],
utf32val.c[3]);
return PDF_EBADTEXT;
}
}
/* Copy value */
memcpy(&(new_data[walker-bom_bytes]), &utf32val, 4);
}
/* Really set output data */
*p_output_data = new_data;
*p_output_length = new_size;
return PDF_OK;
}
|
|
|
pdf_text_get_unicode_string_header
|
14
|
25
|
81
|
src/base/pdf-text.c
|
|
|
|
↓
|
pdf_time_check_string_pdf
|
14
|
24
|
76
|
src/base/pdf-time-string.c
|
static pdf_status_t
pdf_time_check_string_pdf (const pdf_char_t *time_str,
const pdf_size_t time_str_length,
pdf_bool_t require_trailing_apostrophe)
{
pdf_i32_t i;
/* Check minimum length D:YYYY */
if(time_str_length < 6)
{
PDF_DEBUG_BASE("Invalid PDF time string (too short): '%s'",
time_str);
return PDF_EBADDATA;
}
/* Check prefix */
if(strncmp((char *)time_str,"D:",2) != 0)
{
PDF_DEBUG_BASE("Invalid PDF time string (no prefix): '%s'",
time_str);
return PDF_EBADDATA;
}
/* We need to check the input characters are digits when we expect digits and
* the opposite as well. */
#define PDF_STRING_DIGIT_MASK 0x36FFFC /* 0011 0110 1111 1111 1111 1100 */
/* Don't really need to check again two first bytes, as already done before */
i = 2;
__CHECK_MASK(PDF_STRING_DIGIT_MASK, time_str_length, time_str, i);
/* Check time zone definer */
if((time_str_length >=16) && \
(time_str[16] != 'Z') && \
(time_str[16] != '+') && \
(time_str[16] != '-'))
{
PDF_DEBUG_BASE("Invalid time zone definer '%c' found in '%s'",
time_str[16], time_str);
return PDF_EBADDATA;
}
/* Check additional ' characters. Remember that the last ' character is
* mandatory depending on the require_trailing_apostrophe parameter */
if ((time_str_length >= 20) &&
(time_str[19] != '\''))
{
PDF_DEBUG_BASE("Invalid separator found ('%c') in '%s'",
time_str[19], time_str);
return PDF_EBADDATA;
}
if (require_trailing_apostrophe)
{
if ((time_str_length < 23) ||
((time_str[22] != '\'')))
{
PDF_DEBUG_BASE("Invalid separator found ('%c') in '%s'",
(time_str_length >= 21) ? time_str[22] : ' ',
time_str);
return PDF_EBADDATA;
}
}
else
{
if (time_str_length >= 23)
{
PDF_DEBUG_BASE("Invalid separator found ('%c') in '%s'",
time_str[19], time_str);
return PDF_EBADDATA;
}
}
return PDF_OK;
}
|
|
↓
|
flush_token
|
25
|
59
|
113
|
src/base/pdf-token-reader.c
|
static pdf_status_t
flush_token (pdf_token_reader_t reader, pdf_u32_t flags, pdf_token_t *token)
{
pdf_status_t rv;
pdf_token_t new_tok;
pdf_char_t *data = reader->buffer->data;
int datasize = reader->buffer->wp;
switch (reader->state)
{
case PDF_TOKR_STATE_NONE:
return PDF_OK; /* no state to exit */
case PDF_TOKR_STATE_EOF:
return PDF_EEOF; /* can't continue parsing after EOF */
case PDF_TOKR_STATE_COMMENT:
if ((reader->substate == 1) || !(flags & PDF_TOKEN_RET_COMMENTS))
goto finish; /* don't return a token */
rv = pdf_token_comment_new (data, datasize, &new_tok);
break;
case PDF_TOKR_STATE_KEYWORD:
{
int value;
int ntyp = recognise_number (reader->buffer, &value);
if (ntyp == 1)
rv = pdf_token_integer_new (value, &new_tok);
else if (ntyp == 2)
{
double realvalue;
rv = parse_real (reader->buffer,
reader->decimal_point,
&realvalue);
if (rv != PDF_OK)
return rv;
rv = pdf_token_real_new ((float)realvalue, &new_tok);
}
else
rv = pdf_token_keyword_new (data, datasize, &new_tok);
}
break;
case PDF_TOKR_STATE_NAME:
if (reader->substate != 0) /* reading an escape sequence */
return PDF_EBADFILE;
rv = pdf_token_name_new (data, datasize, &new_tok);
break;
case PDF_TOKR_STATE_STRING:
if (reader->intparam >= 0) /* didn't see the closing ')' */
return PDF_EBADFILE;
rv = pdf_token_string_new (data, datasize, &new_tok);
break;
case PDF_TOKR_STATE_HEXSTRING:
if (reader->substate != 3) /* didn't see the closing '>' */
return PDF_EBADFILE;
rv = pdf_token_string_new (data, datasize, &new_tok);
break;
case PDF_TOKR_STATE_DICTEND:
if (reader->substate != 1) /* didn't see a second '>' */
return PDF_EBADFILE;
rv = pdf_token_valueless_new (PDF_TOKEN_DICT_END, &new_tok);
break;
case PDF_TOKR_STATE_PENDING:
switch (reader->charparam)
{
case 60: /* '<' */
rv = pdf_token_valueless_new (PDF_TOKEN_DICT_START, &new_tok);
break;
case 91: /* '[' */
rv = pdf_token_valueless_new (PDF_TOKEN_ARRAY_START, &new_tok);
break;
case 93: /* ']' */
rv = pdf_token_valueless_new (PDF_TOKEN_ARRAY_END, &new_tok);
break;
case 123: /* '{' */
rv = pdf_token_valueless_new (PDF_TOKEN_PROC_START, &new_tok);
break;
case 125: /* '}' */
rv = pdf_token_valueless_new (PDF_TOKEN_PROC_END, &new_tok);
break;
default:
assert (0);
return PDF_ERROR;
}
break;
default:
assert (0);
return PDF_ERROR;
}
if (rv != PDF_OK)
return rv;
*token = new_tok;
/* Set the beginning position of this state */
reader->beg_pos = reader->state_pos;
finish:
reset_buffer (reader);
return PDF_OK;
}
|
|
↓
|
pdf_stm_f_a85dec_wr_quad
|
13
|
32
|
71
|
src/base/pdf-stm-f-a85.c
|
static pdf_status_t
pdf_stm_f_a85dec_wr_quad (const pdf_char_t * quint, const pdf_size_t outcount,
pdf_buffer_t out, pdf_stm_f_a85_t filter_state)
{
pdf_status_t retval = PDF_OK;
pdf_u32_t quad;
int i;
pdf_char_t outbytes[4];
if ((outcount < 1) || (outcount > 4))
{
retval = PDF_ERROR;
return retval;
}
/* Error check on quint contents */
if (quint[0] > 82)
{ /* 83 * 85^4 is greater than 2^32 all by itself. */
retval = PDF_ERROR;
}
if ((quint[1] > 84) || (quint[2] > 84) ||
(quint[3] > 84) || (quint[4] > 84))
{ /* any character here greater than 84 is an error */
retval = PDF_ERROR;
}
/* Begin Conversion to quad. */
quad = (pdf_u32_t) quint[0] * 85u;
quad = (quad + (pdf_u32_t) quint[1]) * 85u;
quad = (quad + (pdf_u32_t) quint[2]) * 85u;
/* Now we could be adding up to too big a number */
/* Go in smaller steps and check for potential overflow: */
quad = (quad + (pdf_u32_t) quint[3]);
if (quad > (pdf_u32_t) ((pdf_u32_t) UINT32_MAX / (pdf_u32_t) 85u))
{ /* This would overflow, so it's an error. Bail */
retval = PDF_ERROR;
}
else
{
quad = quad * 85u; /* Complete the incorporation of quint[3] */
if (((pdf_u32_t) (UINT32_MAX - quad)) >= (pdf_u32_t) quint[4])
{
quad += quint[4];
}
else
{
retval = PDF_ERROR;
}
}
if (PDF_OK == retval)
{
for (i = 0; i < 4; i++)
{
outbytes[3 - i] = quad % 256;
quad = quad / 256;
}
for (i = (4 - outcount); i < 4; i++)
{
retval = pdf_stm_f_a85_write_out (outbytes[i], out, filter_state);
}
}
return retval;
}
|
|
↓
|
pdf_token_read
|
13
|
26
|
50
|
src/base/pdf-token-reader.c
|
pdf_status_t
pdf_token_read (pdf_token_reader_t reader, pdf_u32_t flags, pdf_token_t *token)
{
pdf_status_t rv;
pdf_char_t ch;
pdf_token_t new_token = NULL;
if (!reader || !reader->stream || !token)
return PDF_EBADDATA;
while ( (rv = pdf_stm_peek_char (reader->stream, &ch)) == PDF_OK )
{
rv = handle_char (reader, flags, ch, &new_token);
if (rv == PDF_OK)
{
/* The character we peeked at was accepted, so get rid of it. */
pdf_stm_read_char (reader->stream, &ch);
}
if (new_token)
{
/* Don't return an error code if we got a valid token.
* We'll probably see the same error on the next call since we
* didn't call read_char. */
assert (rv == PDF_OK || rv == PDF_EAGAIN);
goto ret_token;
}
else if (rv != PDF_OK && rv != PDF_EAGAIN)
return rv;
}
/* peek_char returned an error code (rv) */
if (rv != PDF_EEOF)
return rv;
rv = exit_state (reader, flags, &new_token);
if (rv != PDF_OK)
return rv;
reader->state = PDF_TOKR_STATE_EOF;
if (new_token)
goto ret_token;
else
return PDF_EEOF;
ret_token:
assert (new_token);
*token = new_token;
return PDF_OK;
}
|
|
↓
|
pdf_text_ucd_wb_get_property
|
13
|
25
|
56
|
src/base/pdf-text-ucd-wordbreak.c
|
enum pdf_text_ucd_wb_property_e
pdf_text_ucd_wb_get_property(pdf_u32_t character)
{
if(pdf_text_ucd_wb_is_aletter(character))
{
return PDF_TEXT_UCD_WBP_ALetter;
}
else if(pdf_text_ucd_wb_is_midletter(character))
{
return PDF_TEXT_UCD_WBP_MidLetter;
}
else if(pdf_text_ucd_wb_is_numeric(character))
{
return PDF_TEXT_UCD_WBP_Numeric;
}
else if(pdf_text_ucd_wb_is_midnum(character))
{
return PDF_TEXT_UCD_WBP_MidNum;
}
else if(pdf_text_ucd_wb_is_midnumlet(character))
{
return PDF_TEXT_UCD_WBP_MidNumLet;
}
else if(pdf_text_ucd_wb_is_format(character))
{
return PDF_TEXT_UCD_WBP_Format;
}
else if(pdf_text_ucd_wb_is_cr(character))
{
return PDF_TEXT_UCD_WBP_CR;
}
else if(pdf_text_ucd_wb_is_lf(character))
{
return PDF_TEXT_UCD_WBP_LF;
}
else if(pdf_text_ucd_wb_is_newline(character))
{
return PDF_TEXT_UCD_WBP_Newline;
}
else if(pdf_text_ucd_wb_is_extend(character))
{
return PDF_TEXT_UCD_WBP_Extend;
}
else if(pdf_text_ucd_wb_is_katakana(character))
{
return PDF_TEXT_UCD_WBP_Katakana;
}
else if(pdf_text_ucd_wb_is_extendnumlet(character))
{
return PDF_TEXT_UCD_WBP_ExtendNumLet;
}
else
{
return PDF_TEXT_UCD_WBP_None;
}
}
|
|
↓
|
pdf_text_utf8_point_to_utf32he_point
|
15
|
20
|
52
|
src/base/pdf-text-encoding.c
|
static pdf_size_t
pdf_text_utf8_point_to_utf32he_point(const pdf_text_utf8_char_t utf8val[4],
const pdf_size_t n_bytes,
pdf_text_utf32_char_t *p_utf32val)
{
int c; /* index for the utf-8 representation of every char */
/* Check validity of the UTF-8 bytes:
* - First byte can be neither 0xFF nor 0xFE
* - The following bytes must be in the [80-BF] range! (10xxxxxx) */
for(c=0; c 0xBF))))
{
PDF_DEBUG_BASE("Invalid UTF-8 character: %.2X:%.2X:%.2X:%.2X",
(int)utf8val[0],
((n_bytes>1)?((int)utf8val[1]):0),
((n_bytes>2)?((int)utf8val[2]):0),
((n_bytes>3)?((int)utf8val[3]):0));
return 0;
}
}
/* Load all the bytes of the UTF-8 representation in the UTF-32HE var */
switch(n_bytes)
{
case 1:
(*p_utf32val).i = (utf8val[0] & 0x7F); /* 0111 1111 */
break;
case 2:
(*p_utf32val).i = ((utf8val[0] & 0x1F) << 6) + /* 0001 1111 */
(utf8val[1] & 0x3F); /* 0011 1111 */
break;
case 3:
(*p_utf32val).i = ((utf8val[0] & 0x0F) << 12) + /* 0000 1111 */
((utf8val[1] & 0x3F) << 6) + /* 0011 1111 */
(utf8val[2] & 0x3F); /* 0011 1111 */
break;
case 4:
(*p_utf32val).i = ((utf8val[0] & 0x07) << 18) + /* 0000 1111 */
((utf8val[1] & 0x3F) << 12) + /* 0000 1111 */
((utf8val[2] & 0x3F) << 6) + /* 0011 1111 */
(utf8val[3] & 0x3F); /* 0011 1111 */
break;
default:
/* Should never happen! */
return 0;
}
return n_bytes;
}
|
|
↓
|
pdf_text_ucd_special_case
|
14
|
31
|
99
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_special_case(pdf_u32_t to_he[UCD_SC_MAX_EXPAND],
pdf_size_t *p_n_points,
const pdf_u32_t from_he,
const pdf_i32_t index_in_array,
const pdf_text_ucd_context_t *context,
const enum unicode_case_type to_case)
{
int index = 0;
pdf_char_t *condition_list = NULL;
while(index < PDF_TEXT_MNSC)
{
/* Check if a special case is available for this unicode point */
if(unicode_case_info[index_in_array].special_case_indexes[index] == -1)
{
/* Return 0 if no special case was found... */
return PDF_FALSE;
}
else
{
pdf_i32_t index_in_sc_array = unicode_case_info[index_in_array].special_case_indexes[index];
/* Sanity check to see if we really found the correct unicode point */
if(from_he != unicode_special_case_info[index_in_sc_array].unicode_point)
{
PDF_DEBUG_BASE("Invalid search was done in the Special "
"Casing array! (%lu vs %lu). "
"index_in_sc_array: %ld, index_in_array: %ld",
(unsigned long)from_he,
(unsigned long)unicode_special_case_info[index_in_sc_array].unicode_point,
(long)index_in_sc_array,
(long)index_in_array);
return PDF_FALSE;
}
/* Ok, there is a special case */
/* Get conditions list in Special Case, if any */
condition_list = (pdf_char_t *)unicode_special_case_info[index_in_sc_array].condition_list;
/* Check special case conditions */
if(((strlen((char *)condition_list)>0) && \
(pdf_text_ucd_special_case_conditions(context, condition_list)))||
(strlen((char *)condition_list) == 0))
{
pdf_u32_t *dest = NULL;
/* If conditions fullfiled, or there was no condition.... */
/* Delta is the good one! */
switch(to_case)
{
case UNICODE_CASE_INFO_UPPER_CASE:
dest = &(unicode_special_case_info[index_in_sc_array].uppercase_point[0]);
break;
case UNICODE_CASE_INFO_LOWER_CASE:
dest = &(unicode_special_case_info[index_in_sc_array].lowercase_point[0]);
break;
case UNICODE_CASE_INFO_TITLE_CASE:
dest = &(unicode_special_case_info[index_in_sc_array].titlecase_point[0]);
break;
default:
/* Will never happen */
return PDF_FALSE;
}
/* Copy contents */
memcpy(&to_he[0], dest, UCD_SC_MAX_EXPAND*4);
/* Compute number of valid points */
if(p_n_points != NULL)
{
if(to_he[2] != 0)
{
*p_n_points = (pdf_size_t)3;
}
else if(to_he[1] != 0)
{
*p_n_points = (pdf_size_t)2;
}
else if(to_he[0] != 0)
{
*p_n_points = (pdf_size_t)1;
}
else
{
/* It can really happen that a given Unicode point MUST
* dissappear when converting to uppercase or titlecase,
* for example combining marks. E.g: 0x0307 */
*p_n_points = (pdf_size_t)0;
}
}
return PDF_TRUE; /* Conversion was done... */
}
/* check next condition, if any */
index++;
}
}
/* else, just return a not found flag */
return PDF_FALSE;
}
|
|
↓
|
pdf_text_ucd_After_Soft_Dotted
|
13
|
35
|
79
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_After_Soft_Dotted(const pdf_text_ucd_context_t *context)
{
pdf_char_t *walker;
short stop;
int n_combclass230;
int n_combclass0;
int soft_dotted_found;
if((context->unicode_point < context->context_start) || \
(context->unicode_point > context->context_stop))
{
PDF_DEBUG_BASE("Unicode point outside context interval");
/* The unicode point must not be outside the context interval */
return PDF_FALSE;
}
if(context->unicode_point == context->context_start)
{
PDF_DEBUG_BASE("Unicode point is context start");
/* If the unicode point is the start of the context, then it is impossible
* to have a sequence before it */
return PDF_FALSE;
}
/*----- Check backward -----*/
n_combclass0 = 0;
n_combclass230 = 0;
soft_dotted_found = 0;
walker = (pdf_char_t *)(context->unicode_point - 4);
stop = 0;
while(!stop)
{
if(walker < context->context_start)
{
/* Arrived to context start, stop loop */
stop = 1;
}
else
{
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
/* Check for point being Soft_Dotted before checking combining class,
* as the Soft_Dotted character can also be of combining class 0 */
if(pdf_text_ucd_pl_is_Soft_Dotted(aux_point))
{
soft_dotted_found = 1;
stop = 1;
}
else
{
pdf_u8_t comb_class;
comb_class = pdf_text_ucd_get_combining_class(aux_point);
switch(comb_class)
{
case 0:
n_combclass0++;
break;
case 230:
n_combclass230++;
break;
default:
break;
}
}
if(!stop)
{
walker -= 4; /* Point to previous UTF-32 char */
}
}
}
return (((soft_dotted_found) && \
(n_combclass0 == 0) && \
(n_combclass230 == 0)) ? PDF_TRUE : PDF_FALSE);
}
|
|
↓
|
pdf_text_ucd_After_I
|
13
|
32
|
76
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_After_I(const pdf_text_ucd_context_t *context)
{
pdf_char_t *walker;
short stop;
int n_combclass230;
int n_combclass0;
int upper_i_found;
if((context->unicode_point < context->context_start) || \
(context->unicode_point > context->context_stop))
{
PDF_DEBUG_BASE("Unicode point outside context interval");
/* The unicode point must not be outside the context interval */
return PDF_FALSE;
}
if(context->unicode_point == context->context_start)
{
/* If the unicode point is the start of the context, then it is impossible
* to have a sequence before it */
return PDF_FALSE;
}
/*----- Check backward -----*/
n_combclass0 = 0;
n_combclass230 = 0;
upper_i_found = 0;
walker = (pdf_char_t *)(context->unicode_point - 4);
stop = 0;
while(!stop)
{
if(walker < context->context_start)
{
/* Arrived to context start, stop loop */
stop = 1;
}
else
{
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
/* Check for character being I before checking combining class, as
* code point I has a 0 value combining class... */
if(aux_point == 0x49) /* 0x49 == 'I' */
{
upper_i_found = 1;
stop = 1;
}
else
{
switch(pdf_text_ucd_get_combining_class(aux_point))
{
case 0:
n_combclass0++;
break;
case 230:
n_combclass230++;
break;
default:
break;
}
}
if(!stop)
{
walker -= 4; /* Point to previous UTF-32 char */
}
}
}
return (((upper_i_found) && \
(n_combclass0 == 0) && \
(n_combclass230 == 0)) ? PDF_TRUE : PDF_FALSE);
}
|
|
↓
|
pdf_text_ucd_word_change_case
|
12
|
35
|
88
|
src/base/pdf-text-ucd-case.c
|
pdf_status_t
pdf_text_ucd_word_change_case(pdf_char_t *destination_word,
pdf_size_t *p_destination_length,
enum unicode_case_type destination_case,
const pdf_char_t *origin_word,
const pdf_size_t origin_length,
const pdf_char_t *origin_lang)
{
pdf_text_ucd_context_t context;
pdf_size_t i = 0; /* Index in the original word */
pdf_size_t j = 0; /* Index in the destination word */
pdf_char_t new_length;
pdf_size_t new_char_size = 0;
if((destination_word == NULL) || \
(origin_word == NULL) || \
(origin_lang == NULL) || \
(p_destination_length == NULL))
{
PDF_DEBUG_BASE("Invalid inputs");
return PDF_EBADDATA;
}
/* Create context for this word */
if(pdf_text_ucd_create_case_context(&context,
origin_word,
origin_length,
origin_lang) != PDF_OK)
{
PDF_DEBUG_BASE("Error creating casing context");
return PDF_EBADDATA;
}
new_length = 0;
for(i = 0; i < origin_length; i+=4, j+=new_char_size)
{
enum unicode_case_type new_case;
pdf_u32_t dest_character[UCD_SC_MAX_EXPAND];
pdf_u32_t character;
/* In title case, only title-case the first character, and lower-case all
* the others */
new_case = ((destination_case==UNICODE_CASE_INFO_TITLE_CASE)&&(i>0)) ? \
UNICODE_CASE_INFO_LOWER_CASE : destination_case;
/* Store pointer to character within the context */
context.unicode_point = (pdf_char_t *)(&origin_word[i]);
/* Store language info in context */
if(strlen((char *)origin_lang) == 2)
{
memcpy(&context.locale[0],origin_lang,2);
}
else
{
memset(&context.locale[0],0,2);
}
/* Store character */
memcpy(&character, &origin_word[i], 4);
/* Perform conversion */
new_char_size = pdf_text_ucd_to_case(dest_character,
character,
&context,
new_case);
/* Remember that after casing, a given character can even disappear, so
* new_char_size could also be 0 */
if(new_char_size > UCD_SC_MAX_EXPAND)
{
PDF_DEBUG_BASE("Invalid length for case converted char: %u\n",
(unsigned int) new_char_size);
return PDF_ETEXTENC;
}
else if(new_char_size > 0)
{
/* Convert new char size to bytes */
new_char_size*=4;
/* Update length of new word (in bytes!) */
new_length += new_char_size;
/* Store case-converted character */
memcpy(&destination_word[j], &dest_character[0], new_char_size);
}
}
/* Set output data length of word, in bytes! */
*p_destination_length = new_length;
return PDF_OK;
}
|
|
↓
|
pdf_stm_write
|
12
|
32
|
78
|
src/base/pdf-stm.c
|
pdf_status_t
pdf_stm_write (pdf_stm_t stm,
const pdf_char_t *buf,
pdf_size_t bytes,
pdf_size_t *written_bytes)
{
pdf_status_t ret;
pdf_size_t pending_bytes;
pdf_size_t to_write_bytes;
pdf_stm_filter_t tail_filter;
pdf_buffer_t tail_buffer;
pdf_size_t tail_buffer_size;
pdf_size_t flushed_bytes;
if (stm->mode != PDF_STM_WRITE)
{
/* Invalid operation */
return PDF_EINVOP;
}
tail_filter = pdf_stm_filter_get_tail (stm->filter);
tail_buffer = pdf_stm_filter_get_in (tail_filter);
ret = PDF_OK;
*written_bytes = 0;
while ((*written_bytes < bytes) &&
(ret == PDF_OK))
{
if ((pdf_buffer_full_p (tail_buffer)) &&
(!pdf_buffer_eob_p (tail_buffer)))
{
/* Flush the cache */
tail_buffer_size = tail_buffer->wp - tail_buffer->rp;
if (pdf_stm_flush (stm, PDF_FALSE, &flushed_bytes)
== PDF_ERROR)
{
ret = PDF_ERROR;
}
else if (flushed_bytes < tail_buffer_size)
{
ret = PDF_EEOF;
}
}
if (ret == PDF_OK)
{
/* Write the data into the tail buffer. Note that at this
point the tail buffer should be empty */
tail_buffer_size = tail_buffer->size - tail_buffer->wp;
pending_bytes = bytes - *written_bytes;
to_write_bytes = PDF_MIN(pending_bytes, tail_buffer_size);
if (to_write_bytes != 0)
{
memcpy ((char *) tail_buffer->data + tail_buffer->wp,
(char *) buf + *written_bytes,
to_write_bytes);
*written_bytes += to_write_bytes;
tail_buffer->wp += to_write_bytes;
}
}
}
if ((*written_bytes == bytes) &&
(ret == PDF_EEOF))
{
/* Avoid a false PDF_EEOF in the current operation */
ret = PDF_OK;
}
/* Update the sequential counter */
stm->seq_counter += *written_bytes;
return ret;
}
|
|
↓
|
pdf_text_ucd_Before_Dot
|
12
|
29
|
65
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_Before_Dot(const pdf_text_ucd_context_t *context)
{
pdf_char_t *walker;
short stop;
int dotAbovefound;
int n_combclass0or230;
if((context->unicode_point < context->context_start) || \
(context->unicode_point > context->context_stop))
{
PDF_DEBUG_BASE("Unicode point outside context interval");
/* The unicode point must not be outside the context interval */
return PDF_FALSE;
}
if(context->unicode_point == context->context_stop)
{
/* If the unicode point is the start of the context, then it is impossible
* to have a sequence before it */
return PDF_FALSE;
}
/*----- Check forward -----*/
walker = (pdf_char_t *)(context->unicode_point + 4);
stop = 0;
dotAbovefound = 0;
n_combclass0or230 = 0;
while(!stop)
{
if(walker > context->context_stop)
{
/* Arrived to context end, stop loop */
stop = 1;
}
else
{
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
if(aux_point == 0x0307)
{
dotAbovefound = 1;
stop = 1;
}
else
{
pdf_u8_t combining_class;
combining_class = pdf_text_ucd_get_combining_class(aux_point);
if((combining_class == 0) || \
(combining_class == 230))
{
n_combclass0or230++;
}
}
if(!stop)
{
walker += 4; /* Point to next UTF-32 char */
}
}
}
return (((dotAbovefound) && \
(n_combclass0or230 == 0)) ? PDF_TRUE : PDF_FALSE);
}
|
|
↓
|
pdf_time_check_string_utc_asn1
|
12
|
26
|
62
|
src/base/pdf-time-string.c
|
static pdf_status_t
pdf_time_check_string_utc_asn1(const pdf_char_t *time_str,
const pdf_size_t time_str_length)
{
pdf_i32_t i;
pdf_i32_t base_mask;
pdf_i32_t mask_length;
pdf_bool_t with_gmt_offset;
#define UTCASN1_STRING_DIGIT_MASK1 0x03FF /* 0000 0011 1111 1111 */
#define UTCASN1_STRING_DIGIT_MASK2 0x0FFF /* 0000 1111 1111 1111 */
/* Check length */
if((time_str_length == 11) || \
(time_str_length == 15))
{
base_mask = UTCASN1_STRING_DIGIT_MASK1;
mask_length = 10;
}
else if((time_str_length == 13) || \
(time_str_length == 17))
{
base_mask = UTCASN1_STRING_DIGIT_MASK2;
mask_length = 12;
}
else
{
PDF_DEBUG_BASE("Invalid UTC-ASN1 time string (invalid length): '%s'",
time_str);
return PDF_EBADDATA;
}
/* Check if GMT offset is expected */
with_gmt_offset = (time_str_length >=15) ? PDF_TRUE : PDF_FALSE;
/* Check extra non-digit characters */
if((!with_gmt_offset) && \
(time_str[time_str_length-1] != 'Z'))
{
PDF_DEBUG_BASE("Expected UTC string, but not valid");
return PDF_EBADDATA;
}
else if((with_gmt_offset) && \
((time_str[time_str_length-5] != '+') && \
(time_str[time_str_length-5] != '-')))
{
PDF_DEBUG_BASE("Expected non-UTC string, but not valid");
return PDF_EBADDATA;
}
/* Check mask if base string */
i=0;
__CHECK_MASK(base_mask, mask_length, time_str, i);
/* Check mask of offset string if available */
if(with_gmt_offset)
{
i=time_str_length-4;
__CHECK_MASK(0x000F, 4, time_str, i);
}
return PDF_OK;
}
|
|
↓
|
pdf_text_get_lang_from_utf16be
|
12
|
21
|
70
|
src/base/pdf-text.c
|
static pdf_status_t
pdf_text_get_lang_from_utf16be(pdf_text_t element,
pdf_char_t **str_out,
pdf_size_t *str_out_length,
const pdf_char_t *str_in,
const pdf_size_t str_in_length)
{
/* Country code is optional */
short country_available = PDF_FALSE;
pdf_char_t aux[PDF_TEXT_CCL];
/* Check first code marker and MINIMUM length of array */
if((str_in_length < PDF_TEXT_LCMINL) || \
(str_in[1] != PDF_TEXT_LCI_1) || \
(str_in[0] != PDF_TEXT_LCI_0))
{
return PDF_EBADDATA;
}
/* Check last code marker position and MAXIMUM length of array.
* Additionally, set `str_out' and `str_out_length' */
if((str_in[5] != PDF_TEXT_LCI_1) || \
(str_in[4] != PDF_TEXT_LCI_0))
{
/* Check last marker in bytes 6 and 7... */
if((str_in_length >= PDF_TEXT_LCMAXL) && \
(str_in[7] == PDF_TEXT_LCI_1) && \
(str_in[6] == PDF_TEXT_LCI_0))
{
country_available = PDF_TRUE;
*str_out = (pdf_char_t *)str_in + PDF_TEXT_LCMAXL;
*str_out_length = str_in_length - PDF_TEXT_LCMAXL;
}
else
{
/* Either size is too short or last marker not found. This is a
* problem in the input data string */
return PDF_EBADDATA;
}
}
else
{
/* There is no optional country code info */
*str_out = (pdf_char_t *)str_in + PDF_TEXT_LCMINL;
*str_out_length = str_in_length - PDF_TEXT_LCMINL;
}
/* Store 2-bytes ISO 639 language code */
memcpy(&aux[0], &str_in[2], PDF_TEXT_CCL-1);
aux[PDF_TEXT_CCL-1] = '\0';
if(pdf_text_set_language(element, (pdf_char_t *)aux) != PDF_OK)
{
return PDF_ETEXTENC;
}
/* If optional country code is also available, store it... */
if(country_available)
{
memcpy(&aux[0], &str_in[4], PDF_TEXT_CCL-1);
/* Last NUL byte is already set */
/* Store 2-bytes ISO 3166 country code */
if(pdf_text_set_country(element, (pdf_char_t *)aux) != PDF_OK)
{
return PDF_ETEXTENC;
}
}
return PDF_OK;
}
|
|
↓
|
pdf_list_sorted_search_from_to
|
12
|
10
|
38
|
src/base/pdf-list.h
|
STATIC_INLINE pdf_status_t
pdf_list_sorted_search_from_to (const pdf_list_t list,
pdf_list_element_compar_fn_t compar_fn,
const pdf_size_t start_index, const pdf_size_t end_index,
const void* element, pdf_list_node_t *node)
{
pdf_status_t st;
st = PDF_OK;
if (compar_fn != NULL && node != NULL && element != NULL)
{
if (((start_index < pdf_list_size (list) && start_index > 0) ||
(start_index == 0)) &&
((end_index <= pdf_list_size (list) && end_index > 0) ||
(end_index == 0)) &&
(start_index < end_index))
{
node->gl_node = gl_sortedlist_search_from_to((gl_list_t)list.gl_list,
compar_fn, start_index,
end_index, element);
if (node->gl_node == NULL)
{
st = PDF_ENONODE;
}
}
else
{
st = PDF_EINVRANGE;
}
}
else
{
st = PDF_EBADDATA;
}
return (st);
}
|
|
↓
|
write_name_token
|
14
|
42
|
66
|
src/base/pdf-token-writer.c
|
static INLINE pdf_status_t
write_name_token (pdf_token_writer_t writer, pdf_u32_t flags,
pdf_token_t token)
{
pdf_status_t rv;
pdf_size_t size = pdf_token_get_name_size (token);
const pdf_char_t *data = pdf_token_get_name_data (token);
switch (writer->stage)
{
case 0:
/* Validate the name; also calculate the encoded size
* and store it in ->pos temporarily. */
writer->pos = 1 + size;
{
pdf_size_t i;
for (i = 0; i < size; ++i)
{
pdf_bool_t escape;
rv = should_escape_namechar (flags, data[i], &escape);
if (rv != PDF_OK) return rv; /* bad name */
if (escape)
writer->pos += 2; /* 2 hex characters */
}
}
pdf_buffer_rewind (writer->buffer);
write_buffered_char_nocheck (writer, 47 /* '/' */);
++writer->stage; /* fall through */
case 1:
rv = start_token (writer, PDF_FALSE /*need_wspace*/,
writer->pos /* encoded token length */);
if (rv != PDF_OK) return rv;
writer->pos = 0;
++writer->stage; /* fall through */
case 2:
while (writer->pos < size)
{
pdf_bool_t escape;
pdf_char_t ch = data[writer->pos];
rv = should_escape_namechar (flags, ch, &escape);
if (rv != PDF_OK) return rv; /* bad name */
if (escape)
{
rv = reserve_buffer_space (writer, 3);
if (rv != PDF_OK) return rv;
write_buffered_char_nocheck (writer, 35 /* '#' */);
write_buffered_char_nocheck (writer, hexchar (ch / 16));
write_buffered_char_nocheck (writer, hexchar (ch % 16));
}
else
{
rv = write_buffered_char (writer, ch);
if (rv != PDF_OK) return rv;
}
++writer->pos;
}
++writer->stage; /* fall through */
case 3:
return flush_buffer (writer);
default:
return PDF_EBADDATA;
}
}
|
|
↓
|
should_escape_strchar
|
11
|
8
|
21
|
src/base/pdf-token-writer.c
|
/***** String tokens *****/
static INLINE pdf_bool_t
should_escape_strchar (pdf_u32_t flags, pdf_char_t ch,
pdf_bool_t quote_parens, pdf_bool_t is_utf8)
{
if (ch == 92 /* '\\' */ || ch == 13 /* CR */)
return PDF_TRUE;
if (ch == 40 /* '(' */ || ch == 41 /* ')' */)
return quote_parens;
if (flags & PDF_TOKEN_READABLE_STRINGS)
{
if (ch == 127 || (ch < 32 && ch != 10)
|| (ch >= 128 && !is_utf8))
return PDF_TRUE;
}
return PDF_FALSE;
}
|
|
↓
|
pdf_eval_linear
|
11
|
63
|
89
|
src/base/pdf-fp-func.c
|
static pdf_status_t
pdf_eval_linear (pdf_fp_func_t fun,
const pdf_real_t t[],
pdf_real_t out[])
/* the original code (postscript) was almost certainly more stack oriented */
{
pdf_u32_t xcp;
double x,y;
struct pdf_func0_s *p;
pdf_u32_t m;
pdf_u32_t i,j,s,k,i0;
pdf_u32_t cc;
double t0[TYPE0_MAX_DIM];
double t1[TYPE0_MAX_DIM];
p = &fun->u.t0;
m = fun->m;
PDF_ASSERT_BASE (m <= TYPE0_MAX_DIM);
xcp = 0;
i0 = 0;
cc = 1;
for (k = 0; k < m; k++)
{
x = t[k] * p->encode[2*k] + p->encode[2*k+1];
if (!(x < p->size[k]-1)) /* catch NaN, and size [k] == 1, too */
{
i = p->size[k]-1;
xcp |= (1U<size[k];
}
j = 0;
for (j = 0; j < p->n; j++)
{
for (i = 0; i < (1U<size[k];
}
p->r[i] = p->y[s];
printf("\n\tsample[%u] = [%u]",i,s);
}
printf("\n");
for (k = 0; k < m; k++) /* reduction steps */
{
/* i is dominant loop index. */
for (i = 0; i < 1U<<(m-k-1); i++)
{
p->r[i] = t0[k]*p->r[2*i] + t1[k] * p->r[2*i+1];
}
}
y = p->r[0];
y = fun->u.t0.decode[2*j] * y + fun->u.t0.decode[2*j+1];
if (fun->range)
y = clip(y,fun->range+2*j);
out[j] = y;
}
return PDF_OK;
}
|
|
↓
|
pdf_text_filter_change_case
|
11
|
59
|
120
|
src/base/pdf-text-filter.c
|
static pdf_status_t
pdf_text_filter_change_case(pdf_text_t text,
enum unicode_case_type new_case)
{
pdf_size_t i;
pdf_size_t n_words;
pdf_size_t worst_length;
pdf_size_t new_length;
pdf_char_t *new_data;
pdf_list_t new_wb_list;
const pdf_char_t *language;
/* Generate original word boundaries list, if not already done */
if(pdf_text_generate_word_boundaries(text) != PDF_OK)
{
PDF_DEBUG_BASE("Couldn't create list of word boundaries");
return PDF_ETEXTENC;
}
/* Get text language ID. First, try to get it from the pdf_text_t element */
language = pdf_text_get_language(text);
/* If text element doesn't have a language ID, get it from the text context */
if(strlen((char *)language) == 0)
{
language = pdf_text_context_get_host_language();
}
/* Worst length will be having 3 output UTF-32 characters per each input
* UTF-32 character. First of all, allocate memory for the worst length */
worst_length = text->size * UCD_SC_MAX_EXPAND;
new_data = (pdf_char_t *)pdf_alloc(worst_length);
if(new_data == NULL)
{
return PDF_ENOMEM;
}
/* Create new empty word boundaries list */
if(pdf_text_create_word_boundaries_list(&new_wb_list) != PDF_OK)
{
PDF_DEBUG_BASE("Unable to create empty list");
pdf_dealloc(new_data);
return PDF_ETEXTENC;
}
/* Walk list of words, uppercasing all of them */
n_words = pdf_list_size(text->word_boundaries);
new_length = 0;
for(i = 0; i < n_words; ++i)
{
struct pdf_text_wb_s *p_new_word;
struct pdf_text_wb_s *p_word;
pdf_size_t new_word_length = 0;
pdf_status_t ret_code;
/* Allocate new word */
p_new_word = (struct pdf_text_wb_s *)pdf_alloc(sizeof(struct pdf_text_wb_s));
if(p_new_word == NULL)
{
return PDF_ENOMEM;
}
/* Get word to process from list of words */
if(pdf_list_get_at(text->word_boundaries, \
i, \
(const void **)&p_word) != PDF_OK)
{
pdf_dealloc(new_data);
pdf_list_destroy(new_wb_list);
return PDF_ETEXTENC;
}
/* Apply the case algorithm to the full word */
if((ret_code = pdf_text_ucd_word_change_case(&new_data[new_length],
&new_word_length,
new_case,
p_word->word_start,
p_word->word_size,
language)) != PDF_OK)
{
PDF_DEBUG_BASE("Problem x-casing full word");
pdf_list_destroy(new_wb_list);
pdf_dealloc(new_data);
pdf_dealloc(p_new_word);
return ret_code;
}
/* Create new word info */
p_new_word->word_start = &new_data[new_length];
p_new_word->word_size = new_word_length;
p_new_word->word_stop = &new_data[new_length + new_word_length -4];
/* Add word to new list */
pdf_list_add_last(new_wb_list, p_new_word, NULL);
/* Update new length */
new_length += new_word_length;
}
/* Finally, reset the buffer length to its correct size */
if(new_length != worst_length)
{
new_data = (pdf_char_t *)pdf_realloc(new_data,new_length);
if(new_data == NULL)
{
pdf_text_destroy_word_boundaries_list(&new_wb_list);
return PDF_ENOMEM;
}
}
/* Replace contents (data and word boundary list) */
pdf_dealloc(text->data);
text->data = new_data;
text->size = new_length;
pdf_text_destroy_word_boundaries_list(&(text->word_boundaries));
text->word_boundaries = new_wb_list;
return PDF_OK;
}
|
|
↓
|
pdf_eval_spline
|
11
|
53
|
91
|
src/base/pdf-fp-func.c
|
static pdf_status_t
pdf_eval_spline (pdf_fp_func_t fun,
const pdf_real_t in[],
pdf_real_t out[],
pdf_fp_func_debug_t * debug)
{
pdf_u32_t i,j;
double t,v;
for (i = 0; i < fun->m; i++)
{
t = in[i] * fun->u.t0.encode[2*i] + fun->u.t0.encode[2*i+1];
if (isnan(t))
{
return PDF_ERROR;
}
v = t - pdf_fp_floor (t);
fun->u.t0.k[i] = (pdf_u32_t) pdf_fp_floor (t);
if (t >= fun->u.t0.size[i]-1)
{
fun->u.t0.k[i] = fun->u.t0.size[i]-1;
fun->u.t0.wm[i] = 0;
fun->u.t0.w0[i] = 1;
fun->u.t0.w1[i] = 0;
fun->u.t0.w2[i] = 0;
}
else if (t+1 >= fun->u.t0.size[i]-1)
{
if (t-1 >= 0)
{
fun->u.t0.wm[i] = -0.5*v*(1-v);
fun->u.t0.w0[i] = 1-v*v;
fun->u.t0.w1[i] = 0.5*v*(1+v);
}
else /* linear */
{
fun->u.t0.wm[i] = 0;
fun->u.t0.w0[i] = 1-v;
fun->u.t0.w1[i] = v;
}
fun->u.t0.w2[i] = 0;
}
else
{
if (t >= 1)
{
fun->u.t0.wm[i] = ((-0.5 * v + 1)*v-0.5)*v;
fun->u.t0.w0[i] = (1.5* v -2.5)*v*v+1;
fun->u.t0.w1[i] = ((-1.5*v+2)*v+0.5)*v;
fun->u.t0.w2[i] = (0.5*v-0.5)*v*v;
}
else if (t > 0)
{
PDF_ASSERT_BASE (fun->u.t0.k[i] == 0);
fun->u.t0.wm[i] = 0;
fun->u.t0.w0[i] = (0.5*v-1.5)*v +1;
fun->u.t0.w1[i] = (2-v)*v;
fun->u.t0.w2[i] = 0.5*(v-1)*v;
}
else /* no samples */
{
fun->u.t0.k[i] = 0;
fun->u.t0.wm[i] = 0;
fun->u.t0.w0[i] = 1;
fun->u.t0.w1[i] = 0;
fun->u.t0.w2[i] = 0;
}
}
}
for (j = 0; j < fun->n; j++)
{
double y;
y = spline_interpolation(fun->m-1,
fun->u.t0.wm,fun->u.t0.w0,fun->u.t0.w1,fun->u.t0.w2,
fun->u.t0.k,&fun->u.t0.y[j*fun->u.t0.nsamples], fun->u.t0.nsamples, fun->u.t0.size);
y = y * fun->u.t0.decode[2*j] + fun->u.t0.decode[2*j+1];
if (fun->range)
y = clip(y,fun->range+2*j);
if (isnan(y))
{
return PDF_ERROR;
}
out[j] = y;
}
return PDF_OK;
}
|
|
↓
|
pdf_text_utf32he_to_host_win32
|
11
|
45
|
117
|
src/base/pdf-text-host-encoding.c
|
static pdf_status_t
pdf_text_utf32he_to_host_win32(const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_text_host_encoding_t enc,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length)
{
pdf_status_t ret_code;
pdf_char_t *temp_data;
pdf_size_t temp_size;
UINT CodePage;
/* Firstly, convert from UTF-32HE to UTF-16LE */
ret_code = pdf_text_utf32he_to_utf16le(input_data,
input_length,
&temp_data,
&temp_size);
if(ret_code != PDF_OK)
{
PDF_DEBUG_BASE("Couldn't convert from UTF-32HE to UTF-16LE");
return PDF_ETEXTENC;
}
/* In windows, the charset name stored in the pdf_text_host_encoding_t
* element will be in the following format: "CPn", where 'n' is the
* code page number (unsigned integer) obtained with GetACP() */
/* So check windows host encoding */
if(pdf_text_convert_encoding_name_to_CP(enc.name, &CodePage) != PDF_OK)
{
PDF_DEBUG_BASE("Invalid windows encoding name received...");
pdf_dealloc(temp_data);
return PDF_ETEXTENC;
}
else
{
DWORD dwFlags;
int output_nmbyte;
BOOL default_used = 0;
/* Get dwFlags value */
dwFlags = 0;
/* First of all, query the length of the output string */
SetLastError(0);
output_nmbyte = WideCharToMultiByte(CodePage, /* CodePage */
dwFlags, /* dwFlags */
(LPCWSTR)temp_data, /* lpWideCharStr */
(temp_size/sizeof(WCHAR)), /* cbWideChar */
NULL, /* lpMultiByteStr */
0, /* ccMultiByte */
NULL, /* lpDefaultChar */
&default_used); /* lpUsedDefaultChar */
/* Check if we got an error with the call to WideCharToMultiByte */
if(output_nmbyte == 0 || default_used)
{
#ifdef HAVE_DEBUG_BASE
switch(GetLastError())
{
case ERROR_INVALID_FLAGS:
PDF_DEBUG_BASE("Invalid data to convert to Host Encoding:"
" 'Invalid flags'");
break;
default:
PDF_DEBUG_BASE("Invalid data to convert to Host Encoding");
break;
}
#endif
pdf_dealloc(temp_data);
return PDF_EBADTEXT;
}
/* Allocate memory for output buffer */
*p_output_length = output_nmbyte;
*p_output_data = (pdf_char_t *)pdf_alloc(*p_output_length);
if(*p_output_data == NULL)
{
pdf_dealloc(temp_data);
return PDF_ENOMEM;
}
/* Launch the conversion to host encoding */
SetLastError(0);
default_used = 0;
if((WideCharToMultiByte(CodePage, /* CodePage */
dwFlags, /* dwFlags */
(LPCWSTR)temp_data, /* lpWideCharStr */
(temp_size/sizeof(WCHAR)), /* cbWideChar */
(char *)*p_output_data, /* lpMultiByteStr */
*p_output_length, /* ccMultiByte */
NULL, /* lpDefaultChar */
&default_used) != output_nmbyte) || \
(default_used))
{
PDF_DEBUG_BASE("Problem performing the host encoding conversion");
pdf_dealloc(*p_output_data);
pdf_dealloc(temp_data);
return PDF_ETEXTENC;
}
else
{
/* Check last byte... could be NUL and we don't want it */
if((*p_output_data)[*p_output_length -1] == '\0')
{
pdf_char_t *temp;
temp = pdf_realloc((*p_output_data), (*p_output_length -1));
if(temp != NULL)
{
*p_output_data = temp;
*p_output_length = *p_output_length -1;
}
}
pdf_dealloc(temp_data);
return PDF_OK;
}
}
}
|
|
↓
|
pdf_time_from_string_pdf
|
11
|
42
|
119
|
src/base/pdf-time-string.c
|
pdf_status_t
pdf_time_from_string_pdf (pdf_time_t time_var,
const pdf_char_t *time_str,
pdf_bool_t require_trailing_apostrophe)
{
/*
* From PDF Reference 1.7: ( D:YYYYMMDDHHmmSSOHH'mm' )
* From ISO 32000: ( D:YYYYMMDDHHmmSSOHH'mm )
*
* Notes: Year is mandatory, all the other fields may appear if the preceding
* also appear.
*
* D: = string "D:"
* YYYY = four-digit year
* MM = two-digit month (01=January, etc.)
* DD = two-digit day of month (01 through 31)
* HH = two digits of hour (00 through 23)
* mm = two digits of minute (00 through 59)
* SS = two digits of second (00 through 59)
* O = either '+', '-' or 'Z'
* HH = two digits of hour (00 through 23) for the GMT offset
* ' = string "'"
* MM = two digits of minute (00 through 59) for the GMT offset
* ' = string "'" (NOTE: Mandatory in 1.7, non-valid in ISO32000)
*/
struct pdf_time_cal_s calendar;
pdf_status_t ret_code;
pdf_size_t time_str_length = strlen((char *)time_str);
ret_code = pdf_time_check_string_pdf (time_str,
time_str_length,
require_trailing_apostrophe);
if(ret_code != PDF_OK)
{
PDF_DEBUG_BASE("Input Date in PDF format is not valid (%s)",
time_str);
return ret_code;
}
/* Reset calendar (all integers to zero) */
memset(&calendar, 0, sizeof(calendar));
while(1)
{
/* Get century */
__GET_FIELD2(time_str, 2, calendar.year);
calendar.year *= 100;
/* Get year in century */
__GET_FIELD2(time_str, 4, calendar.year);
/* more than year ? */
if(time_str_length == 6)
{
calendar.month = 1;
calendar.day = 1;
break;
}
/* Get month */
__GET_FIELD2(time_str, 6, calendar.month);
/* more than month ? */
if(time_str_length == 8)
{
calendar.day = 1;
break;
}
/* Get day */
__GET_FIELD2(time_str, 8, calendar.day);
/* more than day ? */
if(time_str_length == 10)
break;
/* Get hour */
__GET_FIELD2(time_str, 10, calendar.hour);
/* more than hour ? */
if(time_str_length == 12)
break;
/* Get minute */
__GET_FIELD2(time_str, 12, calendar.minute);
/* more than minute ? */
if(time_str_length == 14)
break;
/* Get second */
__GET_FIELD2(time_str, 14, calendar.second);
/* more than second ? */
if(time_str_length <= 17) /* Considering timezone offset separator */
break;
/* Get timezone offset hours */
__GET_FIELD2(time_str, 17, calendar.gmt_offset);
/* And convert it in minutes */
calendar.gmt_offset *= 60;
/* Get timezone offset minutes */
if(time_str_length > 19)
{
__GET_FIELD2(time_str, 20, calendar.gmt_offset);
}
/* Convert from minutes to seconds */
calendar.gmt_offset *= 60;
/* Set proper sign */
if(time_str[16]=='-')
{
calendar.gmt_offset *= (-1);
}
/* Stop loop :-) */
break;
}
/* Get time value from break-down UTC calendar !*/
ret_code = pdf_time_from_cal(time_var, &calendar);
return ret_code;
}
|
|
↓
|
pdf_text_ucd_wb_detect_next
|
11
|
37
|
111
|
src/base/pdf-text-ucd-wordbreak.c
|
pdf_status_t
pdf_text_ucd_wb_detect_next(const pdf_char_t *current,
const pdf_size_t n_bytes_left_in,
pdf_char_t **next,
pdf_size_t *n_bytes_left_out)
{
/* Buffer to store the unicode points as they are being parsed in the
* algorithm. Indexes are treated as follows:
* [0] [1] x [2] [3]
* This means that possible word breaks are ALWAYS considered between code
* points [1] and [2], being [0] the previous character to [1] and being
* [3] the next character to [2].
* When the buffer is updated, the code points are moved one position to the
* the left, so that code point in [0] disappears and a new code point
* enters in [3], and the word break is again checked between [1] and [2].
*/
pdf_text_ucd_wb_t buffer [PDF_TEXT_UCD_MWBCP];
pdf_u32_t i;
pdf_size_t n_bytes;
pdf_bool_t found;
/* Check validity of input number of bytes */
if(n_bytes_left_in % 4 != 0)
{
return PDF_EBADDATA;
}
/* Check if the string is just one character long */
if(n_bytes_left_in == 4)
{
*n_bytes_left_out = 0;
*next = (pdf_char_t *)current;
return PDF_OK;
}
/* Initialize buffer with first 3 unicode points, stored in [1],[2],[3] */
for(i=0; i0) && \
(n_bytes_left_in >= (4*i)))
{
/* Store pointer */
buffer[i].walker = (pdf_char_t *)(¤t[4*(i-1)]);
/* Store unsigned 32-bit number */
memcpy(&(buffer[i].utf32val), buffer[i].walker, 4);
/* Get Word-Break property value from character */
buffer[i].wbp = pdf_text_ucd_wb_get_property(buffer[i].utf32val);
}
else
{
buffer[i].walker = NULL;
buffer[i].utf32val = 0x0;
buffer[i].wbp = PDF_TEXT_UCD_WBP_None;
}
}
n_bytes = n_bytes_left_in;
found = 0;
/* Start walking the unicode points. At each loop at least 2 unicode points
* (8 bytes) must be available to check the word break!!!! */
while((!found) && \
(n_bytes >= 8))
{
/* If any of the rules returns true, don't break word */
if(pdf_text_ucd_wb_check_rules(buffer))
{
/* If word break is not found, continue with next UTF-32 point */
/* Update number of bytes pending */
n_bytes -= 4;
/* Shift left contents of the buffer */
for(i=1; i= 12)
{
buffer[3].walker = buffer[2].walker + 4;
/* Store unsigned 32-bit number */
memcpy(&(buffer[3].utf32val), buffer[3].walker, 4);
/* Get Word-Break property value from character */
buffer[3].wbp =pdf_text_ucd_wb_get_property(buffer[3].utf32val);
}
}
else
{
/* RULE WB14: Otherwise, break everywhere (including around
* ideographs) */
found = 1;
}
}
/* The exit of the loop could be due to two different reasons:
* 1. A word break was found in the loop. If it is found, the contents of
* the buffer remain unchanged, so the word break is between [1] and [2],
* and n_bytes considers the bytes of [1]
* 2. RULE WB2: Break at end of text ( % EOT). In this case, n_bytes will be
* equal to 4, and the contents of the buffer would have been shifted left
* so that the last character is pointed by [1].
* So, perfect, both cases can be handled in the same way.
*/
*next = buffer[1].walker;
*n_bytes_left_out = n_bytes - 4;
return PDF_OK;
}
|
|
↓
|
pdf_time_from_string_iso8601
|
11
|
35
|
118
|
src/base/pdf-time-string.c
|
pdf_status_t
pdf_time_from_string_iso8601(pdf_time_t time_var,
const pdf_char_t *time_str)
{
/*
* Year:
* YYYY (eg 1997)
* Year and month:
* YYYY-MM (eg 1997-07)
* Complete date:
* YYYY-MM-DD (eg 1997-07-16)
* Complete date plus hours and minutes:
* YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
* Complete date plus hours, minutes and seconds:
* YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
* Complete date plus hours, minutes, seconds and a decimal fraction of a
* second
* YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
*
* where:
*
* YYYY = four-digit year
* MM = two-digit month (01=January, etc.)
* DD = two-digit day of month (01 through 31)
* hh = two digits of hour (00 through 23) (am/pm NOT allowed)
* mm = two digits of minute (00 through 59)
* ss = two digits of second (00 through 59)
* s = one or more digits representing a decimal fraction of a second
* TZD = time zone designator (Z or +hh:mm or -hh:mm)
*
*/
struct pdf_time_cal_s calendar;
pdf_size_t time_str_length = strlen((char *)time_str);
/* Check minimum length */
if(time_str_length < 4)
{
PDF_DEBUG_BASE("Invalid ISO-8601 time string (too short): '%s'",
time_str);
return PDF_EBADDATA;
}
/* Reset calendar */
memset(&calendar, 0, sizeof(calendar));
while(1)
{
/* Get century */
__GET_FIELD2(time_str, 0, calendar.year);
calendar.year *= 100;
/* Get year in century */
__GET_FIELD2(time_str, 2, calendar.year);
/* more than year ? */
if(time_str_length == 4)
{
calendar.month = 1;
calendar.day = 1;
break;
}
/* Get month */
__GET_FIELD2(time_str, 5, calendar.month);
/* more than month ? */
if(time_str_length == 7)
{
calendar.day = 1;
break;
}
/* Get day */
__GET_FIELD2(time_str, 8, calendar.day);
/* more than day ? */
if(time_str_length == 10)
break;
/* Get hour and minutes */
__GET_FIELD2(time_str, 11, calendar.hour);
__GET_FIELD2(time_str, 14, calendar.minute);
/* Get second if available */
if((time_str[17] >= '0') && \
(time_str[17] <= '9') && \
(time_str[16] == ':'))
{
__GET_FIELD2(time_str, 17, calendar.second);
}
/* Note: Fractional part of seconds not considered */
if(time_str[time_str_length-1] == 'Z')
{
break;
}
/* Get timezone offset hours */
__GET_FIELD2(time_str, (time_str_length-5), calendar.gmt_offset);
/* And convert it in minutes */
calendar.gmt_offset *= 60;
/* Get timezone offset minutes */
__GET_FIELD2(time_str, (time_str_length-2), calendar.gmt_offset);
/* Convert from minutes to seconds */
calendar.gmt_offset *= 60;
/* Set proper sign */
if(time_str[(time_str_length-6)]=='-')
{
calendar.gmt_offset *= (-1);
}
/* Stop loop :-) */
break;
}
/* Get time value from break-down calendar !*/
return pdf_time_from_cal(time_var, &calendar);
}
|
|
↓
|
parse_real
|
11
|
34
|
52
|
src/base/pdf-token-reader.c
|
static INLINE pdf_status_t
parse_real (pdf_buffer_t buffer, char *locale_dec_pt, double *value)
{
pdf_status_t ret;
size_t tmplen, wpos, ptlen;
char *tmp, *endptr;
ptlen = strlen (locale_dec_pt);
/* we may remove 1 byte ('.') and replace it with ptlen bytes */
tmplen = buffer->wp - 1 + ptlen;
tmp = pdf_alloc (tmplen + 1);
if (!tmp)
return PDF_ENOMEM;
wpos = 0;
ret = PDF_ERROR; /* nothing should fail if the buffer was validated */
for (buffer->rp = 0; buffer->rp < buffer->wp; ++buffer->rp)
{
pdf_char_t ch = buffer->data[buffer->rp];
if (wpos >= tmplen)
goto out;
if (ch == 46) /* '.' */
{
if (wpos + ptlen > tmplen)
goto out;
memcpy (tmp + wpos, locale_dec_pt, ptlen);
wpos += ptlen;
}
else if (ch == 43) /* '+' */
tmp[wpos++] = '+';
else if (ch == 45) /* '-' */
tmp[wpos++] = '-';
else if (ch >= 48+0 && ch <= 48+9) /* '0'--'9' */
tmp[wpos++] = '0' + (ch-48);
else
goto out;
}
/* null-terminate the new string, and call strtod to get its value
* (strtof would also work if it's available) */
tmp[wpos] = '\0';
*value = strtod (tmp, &endptr);
if (endptr == tmp + wpos)
ret = PDF_OK;
out:
pdf_dealloc (tmp);
return ret;
}
|
|
↓
|
pdf_text_ucd_special_case_conditions
|
11
|
29
|
73
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_special_case_conditions(const pdf_text_ucd_context_t *context,
const pdf_char_t *condition_list)
{
pdf_char_t *walker;
pdf_char_t *internal_condition_list;
pdf_bool_t is_last;
pdf_size_t condition_list_size;
if((condition_list == NULL) || \
(context == NULL) || \
(context->unicode_point == NULL) || \
(strlen((char *)condition_list) == 0))
{
return PDF_FALSE; /* Default is the condition not being fulfilled */
}
/* Copy condition list, as this function will modify it to create NUL
* terminated strings per condition */
condition_list_size = strlen((char *)condition_list);
internal_condition_list = (pdf_char_t *)pdf_alloc(condition_list_size+1);
if(internal_condition_list == NULL)
{
PDF_DEBUG_BASE("Problem dupping condition list");
return PDF_FALSE;
}
memcpy(internal_condition_list,condition_list,condition_list_size);
internal_condition_list[condition_list_size] = '\0';
/* Initiate walker */
walker = internal_condition_list;
/* Walk the whole character string, until last NUL char */
is_last = 0;
while((!is_last) && \
(*walker != '\0'))
{
pdf_char_t *field_end;
pdf_bool_t fulfilled;
/* Get NUL-terminated string to next condition */
is_last = pdf_text_ucd_special_case_get_next_condition(&walker, \
&field_end);
/* Check single condition */
if(pdf_text_ucd_special_case_check_single(context, \
walker, \
&fulfilled) != PDF_OK)
{
/* Invalid condition!!! */
PDF_DEBUG_BASE("Invalid condition in Special Case check: '%s'",
(char *)walker);
return PDF_FALSE;
}
/* Check if single condition was fulfilled */
if(!fulfilled)
{
pdf_dealloc(internal_condition_list);
return PDF_FALSE;
}
/* Update walker if not last */
if(!is_last)
{
walker = field_end+1;
}
}
/* If arrived here, this means that all the conditions were fulfilled */
pdf_dealloc(internal_condition_list);
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_More_Above
|
11
|
29
|
62
|
src/base/pdf-text-ucd-case.c
|
static pdf_bool_t
pdf_text_ucd_More_Above(const pdf_text_ucd_context_t *context)
{
pdf_char_t *walker;
short stop;
int combclass230found;
int n_combclass0;
if((context->unicode_point < context->context_start) || \
(context->unicode_point > context->context_stop))
{
PDF_DEBUG_BASE("Unicode point outside context interval");
/* The unicode point must not be outside the context interval */
return PDF_FALSE;
}
if(context->unicode_point == context->context_stop)
{
/* If the unicode point is the start of the context, then it is impossible
* to have a sequence before it */
return PDF_FALSE;
}
/*----- Check forward -----*/
walker = (pdf_char_t *)(context->unicode_point + 4);
stop = 0;
combclass230found = 0;
n_combclass0 = 0;
while(!stop)
{
if(walker > context->context_stop)
{
/* Arrived to context end, stop loop */
stop = 1;
}
else
{
pdf_u8_t combining_class = 0;
pdf_u32_t aux_point;
memcpy(&aux_point, walker, 4);
combining_class = pdf_text_ucd_get_combining_class(aux_point);
if(combining_class == 0)
{
n_combclass0++;
}
else if(combining_class == 230)
{
combclass230found = 1;
stop = 1;
}
if(!stop)
{
walker += 4; /* Point to next UTF-32 char */
}
}
}
return (((combclass230found) && \
(n_combclass0 == 0)) ? PDF_TRUE : PDF_FALSE);
}
|
|
↓
|
pdf_list_sorted_indexof_from_to
|
11
|
10
|
39
|
src/base/pdf-list.h
|
STATIC_INLINE pdf_status_t
pdf_list_sorted_indexof_from_to (const pdf_list_t list,
pdf_list_element_compar_fn_t compar_fn,
const pdf_size_t start_index, const pdf_size_t end_index,
const void* element, pdf_size_t *position)
{
pdf_status_t st;
st = PDF_OK;
if (compar_fn != NULL && position != NULL && element != NULL)
{
if (((start_index > 0 && start_index < pdf_list_size (list)) ||
start_index == 0) &&
(end_index > 0 && end_index <= pdf_list_size (list)) &&
(start_index < end_index))
{
*position = (pdf_size_t)
gl_sortedlist_indexof_from_to ((gl_list_t)list.gl_list, compar_fn,
start_index, end_index,
element);
if (*position == -1)
{
st = PDF_ENONODE;
}
}
else
{
st = PDF_EINVRANGE;
}
}
else
{
st = PDF_EBADDATA;
}
return (st);
}
|
|
↓
|
pdf_list_search_from_to
|
11
|
10
|
39
|
src/base/pdf-list.h
|
STATIC_INLINE pdf_status_t
pdf_list_search_from_to (const pdf_list_t list,
const pdf_size_t start_index,
const pdf_size_t end_index,
const void* element,
pdf_list_node_t *node)
{
pdf_status_t st;
st = PDF_OK;
if (node != NULL && element != NULL)
{
if (((start_index < pdf_list_size (list) && start_index > 0) ||
(start_index == 0)) &&
((end_index <= pdf_list_size (list) && end_index > 0) ||
(end_index == 0)) &&
(start_index < end_index))
{
node->gl_node = gl_list_search_from_to((gl_list_t)list.gl_list,
start_index, end_index,
element);
if (node->gl_node == NULL)
{
st = PDF_ENONODE;
}
}
else
{
st = PDF_EINVRANGE;
}
}
else
{
st = PDF_EBADDATA;
}
return (st);
}
|
|
|
pdf_stm_f_lzwdec_apply
|
15
|
37
|
100
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_time_get_cal
|
10
|
51
|
110
|
src/base/pdf-time.c
|
|
|
pdf_text_utf32he_to_host_iconv
|
10
|
49
|
118
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_stm_f_ahexenc_apply
|
10
|
43
|
105
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_stm_f_ahexdec_apply
|
10
|
42
|
105
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_time_from_string_generalized_asn1
|
10
|
35
|
116
|
src/base/pdf-time-string.c
|
|
|
pdf_text_cmp_non_case_sensitive
|
10
|
34
|
88
|
src/base/pdf-text.c
|
|
|
pdf_text_get_replacement_pointers
|
10
|
33
|
77
|
src/base/pdf-text.c
|
|
|
pdf_time_from_string_utc_asn1
|
10
|
30
|
84
|
src/base/pdf-time-string.c
|
|
|
pdf_stm_f_aesv2_init
|
10
|
29
|
67
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_stm_f_rlenc_apply
|
10
|
27
|
69
|
src/base/pdf-stm-f-rl.c
|
|
|
handle_hexstring_char
|
10
|
26
|
53
|
src/base/pdf-token-reader.c
|
|
|
pdf_time_is_valid_cal_p
|
10
|
2
|
25
|
src/base/pdf-time.c
|
|
|
pdf_list_indexof_from_to
|
10
|
10
|
39
|
src/base/pdf-list.h
|
|
|
pdf_is_delim_char
|
10
|
1
|
8
|
src/base/pdf-token.h
|
|
|
pdf_text_utf8_to_utf32he
|
9
|
39
|
97
|
src/base/pdf-text-encoding.c
|
|
|
pdf_fsys_item_props_to_hash
|
9
|
39
|
88
|
src/base/pdf-fsys.c
|
|
|
mult_long
|
9
|
36
|
64
|
src/base/pdf-types.c
|
|
|
pdf_token_writer_new
|
9
|
34
|
57
|
src/base/pdf-token-writer.c
|
|
|
scan_string
|
9
|
24
|
41
|
src/base/pdf-token-writer.c
|
|
|
pdf_fsys_disk_get_folder_contents
|
9
|
22
|
67
|
src/base/pdf-fsys-disk.c
|
|
|
spline_interpolation
|
9
|
18
|
24
|
src/base/pdf-fp-func.c
|
|
|
validate_real
|
9
|
17
|
44
|
src/base/pdf-token-reader.c
|
|
|
pdf_list_add_at
|
9
|
13
|
47
|
src/base/pdf-list.h
|
|
|
pdf_list_set_at
|
9
|
13
|
48
|
src/base/pdf-list.h
|
|
|
pdf_text_host_to_utf32he_win32
|
9
|
35
|
107
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_list_iterator_from_to
|
8
|
8
|
32
|
src/base/pdf-list.h
|
|
|
pdf_token_reader_new
|
8
|
33
|
59
|
src/base/pdf-token-reader.c
|
|
|
pdf_stm_f_pred_decode
|
8
|
32
|
57
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_eval_linear
|
8
|
32
|
55
|
src/base/pdf-fp-func.c
|
|
|
read_type0_sample_table
|
8
|
31
|
57
|
src/base/pdf-fp-func.c
|
|
|
pdf_eval_stitch
|
8
|
28
|
59
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_f_v2_init
|
8
|
25
|
55
|
src/base/pdf-stm-f-v2.c
|
|
|
lzw_dict_add
|
8
|
24
|
60
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_stm_f_rldec_apply
|
8
|
24
|
54
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_stm_read
|
8
|
23
|
57
|
src/base/pdf-stm.c
|
|
|
encode_buffer_number
|
8
|
20
|
42
|
src/base/pdf-token-writer.c
|
|
|
pdf_text_replace_multiple
|
8
|
20
|
69
|
src/base/pdf-text.c
|
|
|
pdf_text_ucd_special_case_check_single
|
8
|
19
|
50
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_fsys_disk_get_item_props
|
8
|
18
|
66
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_stm_read_peek_char
|
8
|
17
|
52
|
src/base/pdf-stm.c
|
|
|
pdf_text_utf32he_point_to_pdfdocenc_point
|
8
|
16
|
50
|
src/base/pdf-text-encoding.c
|
|
|
pdf_time_cal_span_cmp
|
8
|
14
|
36
|
src/base/pdf-time.c
|
|
|
pdf_time_get_century_in_sliding_window
|
8
|
13
|
33
|
src/base/pdf-time-string.c
|
|
|
write_real_token
|
10
|
17
|
34
|
src/base/pdf-token-writer.c
|
|
|
pdf_stm_f_dctdec_set_djpeg_param
|
8
|
11
|
51
|
src/base/pdf-stm-f-dct.c
|
|
|
should_escape_namechar
|
7
|
8
|
22
|
src/base/pdf-token-writer.c
|
|
|
in_word_set
|
7
|
8
|
70
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_f_ahex_hex2int
|
7
|
7
|
18
|
src/base/pdf-stm-f-ahex.c
|
|
|
hexval
|
7
|
7
|
11
|
src/base/pdf-token-reader.c
|
|
|
pdf_eval_spline
|
7
|
36
|
55
|
src/base/pdf-fp-func.c
|
|
|
pdf_fsys_disk_build_path
|
7
|
34
|
64
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_utf32he_to_utf16he
|
7
|
34
|
84
|
src/base/pdf-text-encoding.c
|
|
|
pdf_stm_f_pred_encode
|
7
|
31
|
57
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_flush
|
7
|
29
|
66
|
src/base/pdf-stm.c
|
|
|
decode_row_paeth
|
7
|
28
|
55
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_f_jbig2dec_apply
|
7
|
28
|
80
|
src/base/pdf-stm-f-jbig2.c
|
|
|
encode_row_paeth
|
7
|
27
|
54
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_crypt_cipher_aesv2_decrypt
|
7
|
27
|
51
|
src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_crypt_cipher_aesv2_encrypt
|
7
|
27
|
51
|
src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_stm_f_a85enc_wr_tuple
|
7
|
25
|
61
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_fsys_disk_file_open
|
7
|
23
|
68
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_disk_file_reopen
|
7
|
23
|
58
|
src/base/pdf-fsys-disk.c
|
|
|
deflate_inbuf
|
7
|
22
|
47
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_host_encoding_is_available
|
7
|
20
|
46
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_text_ucd_special_case_get_next_condition
|
7
|
16
|
46
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_stm_f_a85_flush_outbuff
|
7
|
16
|
40
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_text_detect_host_language_and_country
|
7
|
16
|
41
|
src/base/pdf-text-context.c
|
|
|
start_token
|
7
|
12
|
26
|
src/base/pdf-token-writer.c
|
|
|
pdf_list_indexof_from
|
7
|
10
|
34
|
src/base/pdf-list.h
|
|
|
pdf_list_search_from
|
7
|
10
|
34
|
src/base/pdf-list.h
|
|
|
str_escape_len
|
14
|
8
|
28
|
src/base/pdf-token-writer.c
|
|
|
write_comment_token
|
11
|
25
|
39
|
src/base/pdf-token-writer.c
|
|
|
shift_right_long
|
6
|
9
|
28
|
src/base/pdf-types.c
|
|
|
read_and_deflate
|
6
|
8
|
26
|
src/base/pdf-stm-f-flate.c
|
|
|
key_numeric_p
|
6
|
7
|
19
|
src/base/pdf-hash.c
|
|
|
pdf_text_utf32he_to_utf8
|
6
|
31
|
74
|
src/base/pdf-text-encoding.c
|
|
|
pdf_text_substitute_line_ending
|
6
|
29
|
64
|
src/base/pdf-text-filter.c
|
|
|
solve_spline
|
6
|
26
|
47
|
src/base/pdf-fp-func.c
|
|
|
pdf_time_from_cal
|
6
|
25
|
67
|
src/base/pdf-time.c
|
|
|
pdf_text_get_hex
|
6
|
22
|
53
|
src/base/pdf-text.c
|
|
|
pdf_text_context_init
|
6
|
22
|
51
|
src/base/pdf-text-context.c
|
|
|
pdf_hash_rename
|
6
|
22
|
56
|
src/base/pdf-hash.c
|
|
|
pdf_hash_add
|
6
|
20
|
47
|
src/base/pdf-hash.c
|
|
|
pdf_text_ucd_wb_rule_13a
|
6
|
2
|
10
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
copy_next_bytes
|
6
|
19
|
35
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_text_fill_word_boundaries_list
|
6
|
19
|
56
|
src/base/pdf-text.c
|
|
|
pdf_fsys_disk_get_free_space
|
6
|
19
|
59
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_eval_exponential
|
6
|
18
|
27
|
src/base/pdf-fp-func.c
|
|
|
pdf_text_concat
|
6
|
15
|
47
|
src/base/pdf-text.c
|
|
|
pdf_text_ucd_get_combining_class
|
6
|
15
|
44
|
src/base/pdf-text-ucd-combclass.c
|
|
|
add_long
|
6
|
15
|
34
|
src/base/pdf-types.c
|
|
|
pdf_text_filter_normalize_full_width_ascii
|
6
|
15
|
29
|
src/base/pdf-text-filter.c
|
|
|
pdf_text_ucd_get_general_category
|
6
|
15
|
44
|
src/base/pdf-text-ucd-gencat.c
|
|
|
pdf_text_ucd_find_case_index
|
6
|
14
|
37
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_fsys_disk_file_write
|
6
|
14
|
47
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_disk_file_read
|
6
|
14
|
43
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_disk_file_close
|
6
|
13
|
33
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_time_calendar_add_months
|
6
|
12
|
31
|
src/base/pdf-time.c
|
|
|
encode_rl_char
|
6
|
12
|
25
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_fsys_disk_file_get_url
|
6
|
10
|
35
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_utf16he_point_to_utf32he_point
|
6
|
10
|
56
|
src/base/pdf-text-encoding.c
|
|
|
pdf_stm_f_ahex_hex_p
|
6
|
1
|
7
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_stm_f_ahex_white_p
|
6
|
1
|
10
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_is_wspace_char
|
6
|
1
|
6
|
src/base/pdf-token.h
|
|
|
pdf_token_equal_p
|
17
|
11
|
40
|
src/base/pdf-token.c
|
|
|
pdf_text_check_unicode_bom
|
12
|
5
|
29
|
src/base/pdf-text-encoding.c
|
|
|
pdf_text_set_unicode
|
9
|
23
|
58
|
src/base/pdf-text.c
|
|
|
pdf_i64_cmp
|
5
|
9
|
31
|
src/base/pdf-types.c
|
|
|
pdf_list_sorted_indexof
|
5
|
8
|
26
|
src/base/pdf-list.h
|
|
|
pdf_list_sorted_search
|
5
|
8
|
25
|
src/base/pdf-list.h
|
|
|
pdf_list_get_at
|
5
|
8
|
28
|
src/base/pdf-list.h
|
|
|
pdf_text_cmp
|
5
|
8
|
26
|
src/base/pdf-text.c
|
|
|
__pdf_fsys_deinit_base_file_data
|
5
|
7
|
18
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_utf32he_point_to_utf8_point
|
5
|
22
|
54
|
src/base/pdf-text-encoding.c
|
|
|
pdf_time_diff_cal
|
5
|
22
|
67
|
src/base/pdf-time.c
|
|
|
pdf_fsys_build_path
|
5
|
22
|
47
|
src/base/pdf-fsys.c
|
|
|
pdf_stm_f_dctdec_init
|
5
|
21
|
43
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_spline_init
|
5
|
20
|
32
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_f_md5enc_init
|
5
|
20
|
45
|
src/base/pdf-stm-f-md5.c
|
|
|
pdf_time_calendar_add_days
|
5
|
20
|
53
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_v2_apply
|
5
|
20
|
60
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_text_concat_ascii
|
5
|
20
|
44
|
src/base/pdf-text.c
|
|
|
pdf_text_ucd_wb_rule_13b
|
5
|
2
|
9
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_stm_init
|
5
|
19
|
69
|
src/base/pdf-stm.c
|
|
|
pdf_token_buffer_new
|
5
|
17
|
32
|
src/base/pdf-token.c
|
|
|
pdf_text_utf32he_point_to_utf16he_point
|
5
|
16
|
51
|
src/base/pdf-text-encoding.c
|
|
|
pdf_text_replace_ascii
|
5
|
16
|
50
|
src/base/pdf-text.c
|
|
|
pdf_error
|
5
|
15
|
30
|
src/base/pdf-error.c
|
|
|
recognise_number
|
5
|
14
|
26
|
src/base/pdf-token-reader.c
|
|
|
pdf_text_new_from_unicode
|
5
|
14
|
43
|
src/base/pdf-text.c
|
|
|
__pdf_fsys_init_base_file_data
|
5
|
14
|
35
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_detect_host_encoding
|
5
|
13
|
28
|
src/base/pdf-text-context.c
|
|
|
lzw_buffer_get_code
|
5
|
13
|
36
|
src/base/pdf-stm-f-lzw.c
|
|
|
deflate_inbuf_return
|
5
|
13
|
36
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_new_from_host
|
5
|
13
|
41
|
src/base/pdf-text.c
|
|
|
pdf_text_dup
|
5
|
13
|
42
|
src/base/pdf-text.c
|
|
|
pdf_stm_be_mem_write
|
5
|
12
|
38
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_be_mem_read
|
5
|
12
|
37
|
src/base/pdf-stm-be.c
|
|
|
pdf_hash_destroy
|
5
|
12
|
26
|
src/base/pdf-hash.c
|
|
|
pdf_list_add_last
|
5
|
11
|
30
|
src/base/pdf-list.h
|
|
|
pdf_list_add_first
|
5
|
11
|
31
|
src/base/pdf-list.h
|
|
|
pdf_time_cal_span_diff
|
5
|
11
|
35
|
src/base/pdf-time.c
|
|
|
pdf_time_add_cal_span_with_base
|
5
|
11
|
35
|
src/base/pdf-time.c
|
|
|
pdf_text_check_replacement_patterns
|
5
|
11
|
27
|
src/base/pdf-text.c
|
|
|
pdf_stm_f_a85_write_out
|
5
|
11
|
30
|
src/base/pdf-stm-f-a85.c
|
|
|
__pdf_fsys_disk_is_writable_from_host_path
|
5
|
10
|
30
|
src/base/pdf-fsys-disk.c
|
|
|
__pdf_fsys_disk_is_readable_from_host_path
|
5
|
10
|
30
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_stm_filter_new
|
22
|
97
|
203
|
src/base/pdf-stm-filter.c
|
|
|
get_token
|
9
|
27
|
82
|
src/base/pdf-fp-func.c
|
|
|
pdf_text_ucd_is_case_ignorable
|
8
|
4
|
28
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_fp_func_destroy
|
7
|
34
|
58
|
src/base/pdf-fp-func.c
|
|
|
write_keyword_token
|
6
|
13
|
26
|
src/base/pdf-token-writer.c
|
|
|
write_integer_token
|
6
|
12
|
25
|
src/base/pdf-token-writer.c
|
|
|
pdf_stm_f_dctdec_write_ppm_header
|
5
|
15
|
47
|
src/base/pdf-stm-f-dct.c
|
|
|
write_valueless_token
|
5
|
10
|
22
|
src/base/pdf-token-writer.c
|
|
|
pdf_fsys_disk_file_set_mode
|
4
|
9
|
28
|
src/base/pdf-fsys-disk.c
|
|
|
__pdf_fsys_disk_file_get_size_from_host_path
|
4
|
8
|
27
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_list_indexof
|
4
|
8
|
25
|
src/base/pdf-list.h
|
|
|
pdf_list_search
|
4
|
8
|
23
|
src/base/pdf-list.h
|
|
|
pdf_time_span_to_cal_span
|
4
|
8
|
26
|
src/base/pdf-time.c
|
|
|
pdf_fsys_disk_file_get_pos
|
4
|
8
|
24
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_ucd_wb_in_interval
|
4
|
7
|
17
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
key_compare
|
4
|
7
|
20
|
src/base/pdf-hash.c
|
|
|
shift_right
|
4
|
7
|
22
|
src/base/pdf-types.c
|
|
|
pdf_token_real_new
|
4
|
7
|
14
|
src/base/pdf-token.c
|
|
|
lzw_buffer_flush
|
4
|
7
|
19
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_text_ucd_pl_in_interval
|
4
|
7
|
17
|
src/base/pdf-text-ucd-proplist.c
|
|
|
pdf_list_remove_at
|
4
|
6
|
19
|
src/base/pdf-list.h
|
|
|
pdf_text_transform_he_to_unicode_encoding
|
4
|
4
|
10
|
src/base/pdf-text.c
|
|
|
__pdf_fsys_disk_set_host_path
|
4
|
4
|
28
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_ucd_check_lang
|
4
|
3
|
15
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_time_calendar_add_years
|
4
|
3
|
16
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_md5enc_apply
|
4
|
25
|
45
|
src/base/pdf-stm-f-md5.c
|
|
|
pdf_text_perform_replacements
|
4
|
25
|
51
|
src/base/pdf-text.c
|
|
|
decode_row_sub_colorl8
|
4
|
24
|
33
|
src/base/pdf-stm-f-pred.c
|
|
|
encode_row_sub_colorl8
|
4
|
24
|
33
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_f_flatedec_init
|
4
|
22
|
44
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_stm_f_dctdec_src_fill
|
4
|
22
|
43
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_stm_f_jbig2dec_init
|
4
|
21
|
63
|
src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_stm_f_flateenc_init
|
4
|
20
|
41
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_pdfdocenc_to_utf32he
|
4
|
20
|
46
|
src/base/pdf-text-encoding.c
|
|
|
pdf_time_is_leap_year_p
|
4
|
2
|
10
|
src/base/pdf-time.c
|
|
|
pdf_text_ucd_wb_rule_12
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_11
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_7
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_6
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3b
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3a
|
4
|
2
|
7
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
decode_row_sub_color8
|
4
|
19
|
29
|
src/base/pdf-stm-f-pred.c
|
|
|
decode_row_sub_color16
|
4
|
19
|
26
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_f_lzwdec_init
|
4
|
19
|
35
|
src/base/pdf-stm-f-lzw.c
|
|
|
encode_row_sub_color8
|
4
|
19
|
28
|
src/base/pdf-stm-f-pred.c
|
|
|
encode_row_sub_color16
|
4
|
19
|
30
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_bseek
|
4
|
18
|
51
|
src/base/pdf-stm.c
|
|
|
pdf_fsys_disk_file_open_tmp
|
4
|
18
|
49
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_remove
|
4
|
18
|
42
|
src/base/pdf-hash.c
|
|
|
pdf_time_w32_set_from_filetime
|
4
|
17
|
56
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_lzwenc_init
|
4
|
17
|
33
|
src/base/pdf-stm-f-lzw.c
|
|
|
__pdf_fsys_disk_get_host_path
|
4
|
17
|
48
|
src/base/pdf-fsys-disk.c
|
|
|
eval_spline
|
4
|
16
|
40
|
src/base/pdf-fp-func.c
|
|
|
pdf_text_utf32he_to_pdfdocenc
|
4
|
16
|
44
|
src/base/pdf-text-encoding.c
|
|
|
decode_row_average
|
4
|
15
|
30
|
src/base/pdf-stm-f-pred.c
|
|
|
encode_row_average
|
4
|
15
|
29
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_text_new
|
4
|
15
|
36
|
src/base/pdf-text.c
|
|
|
write_data
|
4
|
14
|
26
|
src/base/pdf-token-writer.c
|
|
|
pdf_text_get_pdfdocenc
|
4
|
13
|
35
|
src/base/pdf-text.c
|
|
|
pdf_stm_f_a85dec_getnext
|
4
|
13
|
29
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_stm_filter_get_input
|
4
|
13
|
34
|
src/base/pdf-stm-filter.c
|
|
|
pdf_crypt_md_read
|
4
|
13
|
31
|
src/base/pdf-crypt.h
|
|
|
pdf_hash_get
|
4
|
13
|
32
|
src/base/pdf-hash.c
|
|
|
__pdf_fsys_disk_win32_device_p
|
4
|
13
|
36
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_time_add_cal_span_with_sign
|
4
|
12
|
29
|
src/base/pdf-time.c
|
|
|
pdf_fsys_disk_create_folder
|
4
|
12
|
40
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_list_sorted_add
|
4
|
11
|
31
|
src/base/pdf-list.h
|
|
|
pdf_hash_new
|
4
|
11
|
35
|
src/base/pdf-hash.c
|
|
|
pdf_fsys_disk_remove_folder
|
4
|
11
|
34
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_ucd_to_case
|
4
|
11
|
41
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_text_convert_encoding_name_to_CP
|
4
|
11
|
36
|
src/base/pdf-text-host-encoding.c
|
|
|
linear_interpolation
|
4
|
11
|
32
|
src/base/pdf-fp-func.c
|
|
|
decode_rl_char
|
4
|
10
|
22
|
src/base/pdf-stm-f-rl.c
|
|
|
write_data_using_pos
|
4
|
10
|
20
|
src/base/pdf-token-writer.c
|
|
|
pdf_time_span_from_cal_span
|
4
|
10
|
26
|
src/base/pdf-time.c
|
|
|
pdf_text_ucd_simple_case
|
5
|
12
|
41
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_crypt_cipher_new
|
4
|
23
|
48
|
src/base/pdf-crypt.h
|
|
|
key_numeric_cmp
|
3
|
9
|
20
|
src/base/pdf-hash.c
|
|
|
pdf_text_ucd_create_case_context
|
3
|
9
|
30
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_list_new
|
3
|
9
|
29
|
src/base/pdf-list.h
|
|
|
flush_buffer
|
3
|
9
|
22
|
src/base/pdf-token-writer.c
|
|
|
pdf_text_get_printable
|
3
|
9
|
25
|
src/base/pdf-text.c
|
|
|
pdf_fsys_disk_file_same_p
|
3
|
9
|
33
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_disk_item_writable_p
|
3
|
8
|
20
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_disk_item_readable_p
|
3
|
8
|
20
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_check_host_encoding
|
3
|
8
|
22
|
src/base/pdf-text.c
|
|
|
pdf_stm_f_dctdec_src_fill_eoi
|
3
|
8
|
19
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_stm_be_file_seek
|
3
|
8
|
22
|
src/base/pdf-stm-be.c
|
|
|
pdf_list_previous_node
|
3
|
8
|
23
|
src/base/pdf-list.h
|
|
|
pdf_list_next_node
|
3
|
8
|
25
|
src/base/pdf-list.h
|
|
|
pdf_text_destroy
|
3
|
8
|
23
|
src/base/pdf-text.c
|
|
|
pdf_token_reader_destroy
|
3
|
8
|
13
|
src/base/pdf-token-reader.c
|
|
|
lzw_buffer_put_code
|
3
|
8
|
23
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_token_writer_destroy
|
3
|
8
|
13
|
src/base/pdf-token-writer.c
|
|
|
pdf_list_sorted_remove
|
3
|
7
|
21
|
src/base/pdf-list.h
|
|
|
pdf_i64_assign_quick
|
3
|
7
|
24
|
src/base/pdf-types.c
|
|
|
decode_row_up
|
3
|
7
|
21
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_token_keyword_new
|
3
|
7
|
15
|
src/base/pdf-token.c
|
|
|
pdf_hash_iterator_next
|
3
|
7
|
22
|
src/base/pdf-hash.c
|
|
|
pdf_token_comment_new
|
3
|
7
|
15
|
src/base/pdf-token.c
|
|
|
pdf_token_name_new
|
3
|
7
|
14
|
src/base/pdf-token.c
|
|
|
reserve_buffer_space
|
3
|
7
|
14
|
src/base/pdf-token-writer.c
|
|
|
pdf_text_is_ascii7
|
3
|
7
|
14
|
src/base/pdf-text.c
|
|
|
encode_row_up
|
3
|
7
|
19
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_fsys_disk_file_set_pos
|
3
|
7
|
23
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_stm_be_mem_seek
|
3
|
6
|
19
|
src/base/pdf-stm-be.c
|
|
|
store_char_grow
|
3
|
6
|
12
|
src/base/pdf-token-reader.c
|
|
|
pdf_crypt_cipher_v2_decrypt
|
3
|
6
|
19
|
src/base/pdf-crypt-c-v2.c
|
|
|
pdf_crypt_cipher_v2_encrypt
|
3
|
6
|
19
|
src/base/pdf-crypt-c-v2.c
|
|
|
pdf_fsys_disk_item_p
|
3
|
5
|
17
|
src/base/pdf-fsys-disk.c
|
|
|
clip
|
3
|
5
|
10
|
src/base/pdf-fp-func.c
|
|
|
pdf_fsys_file_reopen
|
3
|
5
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_close
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_cancel_ria
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_has_ria
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_request_ria
|
3
|
5
|
21
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_flush
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_write
|
3
|
5
|
21
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_read
|
3
|
5
|
21
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_set_size
|
3
|
5
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_get_size
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_text_set_language
|
3
|
5
|
15
|
src/base/pdf-text.c
|
|
|
pdf_time_dup
|
3
|
5
|
14
|
src/base/pdf-time.c
|
|
|
pdf_fsys_file_can_set_size_p
|
3
|
5
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_text_set_country
|
3
|
5
|
15
|
src/base/pdf-text.c
|
|
|
pdf_fsys_file_set_pos
|
3
|
5
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_get_pos
|
3
|
5
|
18
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_same_p
|
3
|
5
|
18
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_set_mode
|
3
|
5
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_get_url
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_get_mode
|
3
|
5
|
17
|
src/base/pdf-fsys.c
|
|
|
hexchar
|
3
|
5
|
14
|
src/base/pdf-token-writer.c
|
|
|
pdf_fsys_disk_get_parent
|
3
|
3
|
14
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fp_func_3_new
|
3
|
29
|
53
|
src/base/pdf-fp-func.c
|
|
|
pdf_fsys_disk_file_get_mode
|
3
|
2
|
7
|
src/base/pdf-fsys-disk.c
|
|
|
__pdf_fsys_disk_get_mode_string
|
3
|
2
|
8
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_ucd_wb_rule_13
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_10
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_9
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_8
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_5
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_4
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3
|
3
|
2
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_stm_f_rlenc_init
|
3
|
18
|
33
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_stm_destroy
|
3
|
16
|
35
|
src/base/pdf-stm.c
|
|
|
pdf_stm_f_null_apply
|
3
|
15
|
42
|
src/base/pdf-stm-f-null.c
|
|
|
pdf_crypt_cipher_aesv2_new
|
3
|
14
|
33
|
src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_crypt_md_new
|
3
|
14
|
32
|
src/base/pdf-crypt.h
|
|
|
lzwdec_put_decoded
|
3
|
13
|
26
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_time_context_init
|
3
|
13
|
30
|
src/base/pdf-time-context.c
|
|
|
pdf_crypt_cipher_v2_new
|
3
|
13
|
32
|
src/base/pdf-crypt-c-v2.c
|
|
|
pdf_stm_install_filter
|
3
|
13
|
36
|
src/base/pdf-stm.c
|
|
|
pdf_time_calendar_add_seconds
|
3
|
12
|
32
|
src/base/pdf-time.c
|
|
|
pdf_time_calendar_add_minutes
|
3
|
12
|
32
|
src/base/pdf-time.c
|
|
|
pdf_time_calendar_add_hours
|
3
|
12
|
31
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_dctdec_dealloc_state
|
3
|
12
|
26
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_i64_abs
|
3
|
12
|
31
|
src/base/pdf-types.c
|
|
|
pdf_text_destroy_word_boundaries_list
|
3
|
12
|
25
|
src/base/pdf-text.c
|
|
|
pdf_text_set_pdfdocenc
|
3
|
11
|
26
|
src/base/pdf-text.c
|
|
|
pdf_text_set_host
|
3
|
11
|
28
|
src/base/pdf-text.c
|
|
|
pdf_stm_be_file_write
|
3
|
11
|
37
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_be_file_read
|
3
|
11
|
37
|
src/base/pdf-stm-be.c
|
|
|
pdf_text_clean_contents
|
3
|
11
|
25
|
src/base/pdf-text.c
|
|
|
pdf_fsys_disk_get_free_space
|
3
|
11
|
60
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_get_best_encoding
|
3
|
10
|
32
|
src/base/pdf-text.c
|
|
|
pdf_stm_be_cfile_seek
|
3
|
10
|
26
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_f_dctdec_skip_input_data
|
3
|
10
|
22
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_time_get_days_in_month
|
14
|
5
|
25
|
src/base/pdf-time.c
|
|
|
pdf_token_write
|
14
|
30
|
54
|
src/base/pdf-token-writer.c
|
|
|
encode_row
|
13
|
22
|
73
|
src/base/pdf-stm-f-pred.c
|
|
|
decode_row
|
13
|
21
|
73
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_token_valueless_new
|
7
|
2
|
17
|
src/base/pdf-token.c
|
|
|
pdf_token_destroy
|
5
|
6
|
24
|
src/base/pdf-token.c
|
|
|
pdf_time_from_string
|
5
|
5
|
20
|
src/base/pdf-time.c
|
|
|
pdf_time_to_string
|
5
|
5
|
20
|
src/base/pdf-time.c
|
|
|
pdf_stm_be_tell
|
4
|
9
|
31
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_be_seek
|
4
|
9
|
32
|
src/base/pdf-stm-be.c
|
|
|
pdf_text_ucd_is_cased
|
4
|
2
|
16
|
src/base/pdf-text-ucd-case.c
|
|
|
pdf_stm_be_write
|
4
|
10
|
40
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_be_read
|
4
|
10
|
40
|
src/base/pdf-stm-be.c
|
|
|
hash
|
3
|
7
|
35
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_f_fax_apply
|
3
|
5
|
26
|
src/base/pdf-stm-f-fax.c
|
|
|
pdf_stm_f_pred_apply
|
3
|
3
|
21
|
src/base/pdf-stm-f-pred.c
|
|
|
__pdf_fsys_disk_get_status_from_errno
|
21
|
9
|
49
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_get_dwflags_for_cp
|
21
|
2
|
80
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_stm_f_a85dec_init
|
2
|
9
|
22
|
src/base/pdf-stm-f-a85.c
|
|
|
hash_pjw
|
2
|
9
|
14
|
src/base/pdf-hash.c
|
|
|
pdf_stm_be_new_cfile
|
2
|
8
|
21
|
src/base/pdf-stm-be.c
|
|
|
pdf_token_new
|
2
|
8
|
14
|
src/base/pdf-token.c
|
|
|
pdf_stm_f_ahexenc_init
|
2
|
8
|
22
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_hash_add_string
|
2
|
8
|
17
|
src/base/pdf-hash-helper.c
|
|
|
pdf_buffer_resize
|
2
|
8
|
13
|
src/base/pdf-types.c
|
|
|
pdf_fsys_disk_file_flush
|
2
|
8
|
25
|
src/base/pdf-fsys-disk.c
|
|
|
decode_row_sub
|
2
|
7
|
16
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_text_new_from_u32
|
2
|
7
|
23
|
src/base/pdf-text.c
|
|
|
lzw_dict_decode
|
2
|
7
|
18
|
src/base/pdf-stm-f-lzw.c
|
|
|
lzw_dict_init
|
2
|
7
|
16
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_stm_f_flatedec_apply
|
2
|
7
|
15
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_stm_f_flateenc_apply
|
2
|
7
|
15
|
src/base/pdf-stm-f-flate.c
|
|
|
encode_row_sub
|
2
|
7
|
14
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_buffer_new
|
2
|
7
|
16
|
src/base/pdf-types.c
|
|
|
pdf_list_iterator
|
2
|
6
|
20
|
src/base/pdf-list.h
|
|
|
pdf_time_new
|
2
|
6
|
18
|
src/base/pdf-time.c
|
|
|
pdf_hash_iterator_new
|
2
|
6
|
20
|
src/base/pdf-hash.c
|
|
|
pdf_i64_subtraction
|
2
|
6
|
20
|
src/base/pdf-types.c
|
|
|
pdf_hash_get_size
|
2
|
6
|
13
|
src/base/pdf-hash-helper.c
|
|
|
pdf_hash_add_size
|
2
|
6
|
15
|
src/base/pdf-hash-helper.c
|
|
|
pdf_hash_get_bool
|
2
|
6
|
14
|
src/base/pdf-hash-helper.c
|
|
|
pdf_time_set_to_current_utc_time
|
2
|
6
|
14
|
src/base/pdf-time.c
|
|
|
pdf_hash_add_bool
|
2
|
6
|
15
|
src/base/pdf-hash-helper.c
|
|
|
pdf_list_iterator_next
|
2
|
5
|
16
|
src/base/pdf-list.h
|
|
|
pdf_list_remove
|
2
|
5
|
12
|
src/base/pdf-list.h
|
|
|
pdf_i64_assign
|
2
|
5
|
18
|
src/base/pdf-types.c
|
|
|
exit_state
|
2
|
5
|
11
|
src/base/pdf-token-reader.c
|
|
|
jbig2dec_error_cb
|
2
|
5
|
17
|
src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_text_create_word_boundaries_list
|
2
|
5
|
14
|
src/base/pdf-text.c
|
|
|
pdf_text_filter_remove_amp
|
2
|
5
|
11
|
src/base/pdf-text-filter.c
|
|
|
lzw_buffer_inc_bitsize
|
2
|
5
|
13
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_time_get_days_before_month
|
2
|
5
|
11
|
src/base/pdf-time.c
|
|
|
pdf_time_span_negate
|
2
|
5
|
9
|
src/base/pdf-time.c
|
|
|
pdf_i64_copy
|
2
|
5
|
17
|
src/base/pdf-types.c
|
|
|
pdf_time_set_to_current_local_time
|
2
|
4
|
14
|
src/base/pdf-time.c
|
|
|
pdf_crypt_cipher_v2_setkey
|
2
|
4
|
15
|
src/base/pdf-crypt-c-v2.c
|
|
|
lzwdec_put_code
|
2
|
4
|
14
|
src/base/pdf-stm-f-lzw.c
|
|
|
store_char
|
2
|
4
|
8
|
src/base/pdf-token-reader.c
|
|
|
enlarge_buffer
|
2
|
4
|
9
|
src/base/pdf-token-reader.c
|
|
|
write_buffered_char
|
2
|
4
|
8
|
src/base/pdf-token-writer.c
|
|
|
pdf_token_integer_new
|
2
|
4
|
9
|
src/base/pdf-token.c
|
|
|
write_buffered_char_nocheck
|
2
|
4
|
9
|
src/base/pdf-token-writer.c
|
|
|
pdf_text_clean_word_boundaries_list
|
2
|
4
|
17
|
src/base/pdf-text.c
|
|
|
pdf_fsys_disk_file_get_size
|
2
|
4
|
15
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_crypt_cipher_aesv2_setkey
|
2
|
4
|
15
|
src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_fsys_get_parent
|
2
|
3
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_get_folder_contents
|
2
|
3
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_create_folder
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_get_free_space
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_get_filesystem
|
2
|
3
|
8
|
src/base/pdf-fsys.c
|
|
|
pdf_hash_iterator_destroy
|
2
|
3
|
11
|
src/base/pdf-hash.c
|
|
|
pdf_stm_filter_get_tail
|
2
|
3
|
12
|
src/base/pdf-stm-filter.c
|
|
|
pdf_fsys_file_open_tmp
|
2
|
3
|
15
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_file_open
|
2
|
3
|
20
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_item_writable_p
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_text_context_get_host_eol
|
2
|
3
|
12
|
src/base/pdf-text-context.c
|
|
|
pdf_fsys_item_readable_p
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_fsys_item_p
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_text_generate_word_boundaries
|
2
|
3
|
14
|
src/base/pdf-text.c
|
|
|
pdf_fsys_get_item_props
|
2
|
3
|
19
|
src/base/pdf-fsys.c
|
|
|
pdf_hash_key_p
|
2
|
3
|
11
|
src/base/pdf-hash.c
|
|
|
reset_buffer
|
2
|
3
|
10
|
src/base/pdf-token-reader.c
|
|
|
pdf_fsys_remove_folder
|
2
|
3
|
17
|
src/base/pdf-fsys.c
|
|
|
pdf_text_empty_p
|
2
|
2
|
5
|
src/base/pdf-text.c
|
|
|
pdf_token_get_keyword_data
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_keyword_size
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_comment_data
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_comment_size
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_string_data
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_string_size
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_name_data
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_name_size
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_real_value
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_token_get_integer_value
|
2
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_i64_to_i32
|
2
|
2
|
6
|
src/base/pdf-types.c
|
|
|
pdf_i64_add
|
2
|
14
|
47
|
src/base/pdf-types.c
|
|
|
pdf_stm_f_dctdec_jpeg_cache_src
|
2
|
12
|
26
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_stm_btell
|
2
|
12
|
26
|
src/base/pdf-stm.c
|
|
|
pdf_stm_f_a85enc_init
|
2
|
10
|
22
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_i64_neg
|
2
|
10
|
25
|
src/base/pdf-types.c
|
|
|
pdf_stm_f_ahexdec_init
|
2
|
10
|
25
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_is_regular_char
|
2
|
1
|
5
|
src/base/pdf-token.h
|
|
|
pdf_is_eol_char
|
2
|
1
|
5
|
src/base/pdf-token.h
|
|
|
pdf_token_dup
|
13
|
9
|
41
|
src/base/pdf-token.c
|
|
|
pdf_fsys_create
|
1
|
8
|
24
|
src/base/pdf-fsys.c
|
|
|
pdf_stm_be_new_mem
|
1
|
7
|
18
|
src/base/pdf-stm-be.c
|
|
|
lzw_buffer_init
|
1
|
7
|
12
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_stm_be_new_file
|
1
|
6
|
16
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_f_aesv2_dealloc_state
|
1
|
6
|
10
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_text_detect_host_endianness
|
1
|
5
|
12
|
src/base/pdf-text-context.c
|
|
|
pred_bit_ptr_init
|
1
|
5
|
11
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_crypt_cipher_destroy
|
1
|
5
|
10
|
src/base/pdf-crypt.h
|
|
|
pdf_stm_f_jbig2dec_dealloc_state
|
1
|
5
|
11
|
src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_text_detect_host_eol
|
1
|
5
|
26
|
src/base/pdf-text-context.c
|
|
|
pdf_stm_f_md5enc_dealloc_state
|
1
|
5
|
9
|
src/base/pdf-stm-f-md5.c
|
|
|
pdf_token_writer_reset
|
1
|
4
|
8
|
src/base/pdf-token-writer.c
|
|
|
pdf_stm_f_fax_dealloc
|
1
|
4
|
10
|
src/base/pdf-stm-f-fax.c
|
|
|
pdf_stm_mem_new
|
1
|
4
|
21
|
src/base/pdf-stm.c
|
|
|
pdf_crypt_cipher_aesv2_destroy
|
1
|
4
|
8
|
src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_stm_f_a85dec_dealloc_state
|
1
|
4
|
9
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_stm_f_pred_dealloc
|
1
|
4
|
10
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_fsys_destroy
|
1
|
4
|
13
|
src/base/pdf-fsys.c
|
|
|
pdf_crypt_cipher_v2_destroy
|
1
|
4
|
8
|
src/base/pdf-crypt-c-v2.c
|
|
|
pdf_stm_file_new
|
1
|
4
|
20
|
src/base/pdf-stm.c
|
|
|
pdf_time_clear
|
1
|
4
|
10
|
src/base/pdf-time.c
|
|
|
pdf_time_copy
|
1
|
4
|
9
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_a85enc_dealloc_state
|
1
|
4
|
9
|
src/base/pdf-stm-f-a85.c
|
|
|
pdf_stm_cfile_new
|
1
|
4
|
20
|
src/base/pdf-stm.c
|
|
|
pdf_i64_new
|
1
|
4
|
9
|
src/base/pdf-types.c
|
|
|
elem_key_equal
|
1
|
4
|
10
|
src/base/pdf-hash.c
|
|
|
pdf_stm_f_ahexdec_dealloc_state
|
1
|
4
|
10
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_stm_filter_destroy
|
1
|
4
|
12
|
src/base/pdf-stm-filter.c
|
|
|
stm_dispose_fn
|
1
|
4
|
9
|
src/base/pdf-hash-helper.c
|
|
|
pdf_stm_f_flatedec_dealloc_state
|
1
|
4
|
8
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_stm_f_v2_dealloc_state
|
1
|
4
|
8
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_stm_f_ahexenc_dealloc_state
|
1
|
4
|
10
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_token_reader_reset
|
1
|
4
|
8
|
src/base/pdf-token-reader.c
|
|
|
pdf_stm_f_fax_decode
|
1
|
4
|
15
|
src/base/pdf-stm-f-fax.c
|
|
|
pdf_i64_cmp_i32
|
1
|
4
|
10
|
src/base/pdf-types.c
|
|
|
pdf_stm_f_fax_encode
|
1
|
4
|
15
|
src/base/pdf-stm-f-fax.c
|
|
|
pdf_time_span_dup
|
1
|
4
|
8
|
src/base/pdf-time.c
|
|
|
pdf_time_diff
|
1
|
3
|
9
|
src/base/pdf-time.c
|
|
|
pdf_fsys_alloc
|
1
|
3
|
9
|
src/base/pdf-fsys.c
|
|
|
pdf_time_sub_span
|
1
|
3
|
10
|
src/base/pdf-time.c
|
|
|
pdf_time_add_span
|
1
|
3
|
10
|
src/base/pdf-time.c
|
|
|
pdf_fp_func_get_bounds
|
1
|
3
|
10
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_alloc
|
1
|
3
|
8
|
src/base/pdf-stm.c
|
|
|
pdf_time_set_from_i64
|
1
|
3
|
8
|
src/base/pdf-time.c
|
|
|
pdf_time_set_from_u32
|
1
|
3
|
8
|
src/base/pdf-time.c
|
|
|
pdf_time_destroy
|
1
|
3
|
7
|
src/base/pdf-time.c
|
|
|
pdf_stm_be_cfile_write
|
1
|
3
|
14
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_be_cfile_read
|
1
|
3
|
14
|
src/base/pdf-stm-be.c
|
|
|
pdf_dealloc
|
1
|
3
|
10
|
src/base/pdf-alloc.c
|
|
|
enter_state
|
1
|
3
|
9
|
src/base/pdf-token-reader.c
|
|
|
pdf_stm_filter_reset
|
1
|
3
|
8
|
src/base/pdf-stm-filter.c
|
|
|
pdf_alloc
|
1
|
3
|
8
|
src/base/pdf-alloc.c
|
|
|
pdf_crypt_md_destroy
|
1
|
3
|
7
|
src/base/pdf-crypt.h
|
|
|
lzw_dict_fast_add
|
1
|
3
|
9
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_text_filter_normalize_line_endings
|
1
|
3
|
9
|
src/base/pdf-text-filter.c
|
|
|
pdf_crypt_md_write
|
1
|
3
|
8
|
src/base/pdf-crypt.h
|
|
|
pdf_text_pdfdocenc_point_to_utf32he_point
|
1
|
3
|
7
|
src/base/pdf-text-encoding.c
|
|
|
pdf_buffer_rewind
|
1
|
3
|
8
|
src/base/pdf-types.c
|
|
|
pdf_buffer_destroy
|
1
|
3
|
8
|
src/base/pdf-types.c
|
|
|
pdf_i64_mod_i32_divisor
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_mod_i32_dividend
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_div_i32_divisor
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_div_i32_dividend
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_mult_i32
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_subtraction_i32_sub
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_i64_subtraction_i32_min
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_time_span_diff
|
1
|
3
|
9
|
src/base/pdf-time.c
|
|
|
pdf_time_span_copy
|
1
|
3
|
8
|
src/base/pdf-time.c
|
|
|
pdf_i64_add_i32
|
1
|
3
|
11
|
src/base/pdf-types.c
|
|
|
pdf_time_span_add
|
1
|
3
|
9
|
src/base/pdf-time.c
|
|
|
pdf_time_span_set_from_i32
|
1
|
3
|
8
|
src/base/pdf-time.c
|
|
|
pdf_time_span_set
|
1
|
3
|
9
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_dctenc_apply
|
1
|
2
|
10
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_fsys_disk_init
|
1
|
2
|
7
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_time_set_local_offset
|
1
|
2
|
7
|
src/base/pdf-time.c
|
|
|
pdf_list_iterator_free
|
1
|
2
|
7
|
src/base/pdf-list.h
|
|
|
setmap
|
1
|
2
|
6
|
src/base/pdf-fp-func.c
|
|
|
pdf_text_host_to_utf32he
|
1
|
2
|
21
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_stm_f_lzwdec_dealloc_state
|
1
|
2
|
6
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_list_remove_node
|
1
|
2
|
6
|
src/base/pdf-list.h
|
|
|
pdf_realloc
|
1
|
2
|
6
|
src/base/pdf-alloc.c
|
|
|
pdf_stm_f_lzwenc_dealloc_state
|
1
|
2
|
6
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_text_utf32he_to_host
|
1
|
2
|
21
|
src/base/pdf-text-host-encoding.c
|
|
|
pdf_text_filter_remove_line_endings
|
1
|
2
|
7
|
src/base/pdf-text-filter.c
|
|
|
pdf_stm_filter_set_out
|
1
|
2
|
7
|
src/base/pdf-stm-filter.c
|
|
|
pdf_stm_filter_set_be
|
1
|
2
|
7
|
src/base/pdf-stm-filter.c
|
|
|
pdf_stm_filter_set_next
|
1
|
2
|
7
|
src/base/pdf-stm-filter.c
|
|
|
pdf_stm_f_rldec_dealloc_state
|
1
|
2
|
6
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_list_destroy
|
1
|
2
|
6
|
src/base/pdf-list.h
|
|
|
list_dispose_fn
|
1
|
2
|
6
|
src/base/pdf-hash-helper.c
|
|
|
time_dispose_fn
|
1
|
2
|
6
|
src/base/pdf-hash-helper.c
|
|
|
lzw_buffer_set_bitsize
|
1
|
2
|
7
|
src/base/pdf-stm-f-lzw.c
|
|
|
text_dispose_fn
|
1
|
2
|
6
|
src/base/pdf-hash-helper.c
|
|
|
pdf_stm_f_flateenc_dealloc_state
|
1
|
2
|
6
|
src/base/pdf-stm-f-flate.c
|
|
|
pdf_crypt_nonce
|
1
|
2
|
6
|
src/base/pdf-crypt.h
|
|
|
pdf_stm_f_rlenc_dealloc_state
|
1
|
2
|
6
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_crypt_init
|
1
|
2
|
6
|
src/base/pdf-crypt.h
|
|
|
write_char
|
1
|
2
|
6
|
src/base/pdf-token-writer.c
|
|
|
pdf_token_get_type
|
1
|
2
|
6
|
src/base/pdf-token.c
|
|
|
pdf_stm_be_destroy
|
1
|
2
|
9
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_f_fax_init
|
1
|
15
|
25
|
src/base/pdf-stm-f-fax.c
|
|
|
pdf_stm_f_pred_init
|
1
|
14
|
30
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_fp_func_2_new
|
1
|
13
|
31
|
src/base/pdf-fp-func.c
|
|
|
pdf_fp_exp
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_text_ucd_wb_is_extendnumlet
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_fsys_disk_cleanup
|
1
|
1
|
6
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_text_ucd_wb_is_numeric
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_linear_init
|
1
|
1
|
5
|
src/base/pdf-fp-func.c
|
|
|
pdf_text_ucd_wb_is_midnumlet
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_hash_get_stm
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_ucd_wb_is_midnum
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_midletter
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_time_cmp
|
1
|
1
|
6
|
src/base/pdf-time.c
|
|
|
pdf_text_ucd_wb_is_aletter
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_fp_pow
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_text_ucd_wb_is_katakana
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_stm_f_null_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-null.c
|
|
|
pdf_text_ucd_wb_is_format
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_stm_f_dctenc_init
|
1
|
1
|
6
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_text_ucd_wb_is_extend
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_hash_add_stm
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_ucd_wb_is_newline
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_lf
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_cr
|
1
|
1
|
6
|
src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_fp_atan2
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_time_context_get_gmt_offset
|
1
|
1
|
5
|
src/base/pdf-time-context.c
|
|
|
lzw_buffer_set
|
1
|
1
|
6
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_hash_get_hash
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_fsys_dealloc
|
1
|
1
|
5
|
src/base/pdf-fsys.c
|
|
|
pdf_fp_cos
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_stm_f_rldec_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-rl.c
|
|
|
pdf_token_reader_begin_pos
|
1
|
1
|
5
|
src/base/pdf-token-reader.c
|
|
|
pdf_hash_add_hash
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_time_get_utc_cal
|
1
|
1
|
7
|
src/base/pdf-time.c
|
|
|
pdf_time_get_local_cal
|
1
|
1
|
7
|
src/base/pdf-time.c
|
|
|
pdf_fp_sin
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_time_sub_cal_span
|
1
|
1
|
6
|
src/base/pdf-time.c
|
|
|
pdf_time_add_cal_span
|
1
|
1
|
6
|
src/base/pdf-time.c
|
|
|
pdf_hash_get_list
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_fsys_http_file_set_size
|
1
|
1
|
6
|
src/base/pdf-fsys-http.c
|
|
|
pdf_fp_sqrt
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_fp_func_eval
|
1
|
1
|
8
|
src/base/pdf-fp-func.c
|
|
|
pdf_stm_dealloc
|
1
|
1
|
5
|
src/base/pdf-stm.c
|
|
|
pdf_hash_add_list
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_get_host
|
1
|
1
|
10
|
src/base/pdf-text.c
|
|
|
pdf_fp_mod
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_hash_get_time
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_get_host_encoding
|
1
|
1
|
5
|
src/base/pdf-text.c
|
|
|
pdf_fp_div
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_stm_be_cfile_tell
|
1
|
1
|
5
|
src/base/pdf-stm-be.c
|
|
|
pdf_hash_add_time
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_get_language
|
1
|
1
|
5
|
src/base/pdf-text.c
|
|
|
pdf_list_node_value
|
1
|
1
|
6
|
src/base/pdf-list.h
|
|
|
pdf_stm_tell
|
1
|
1
|
5
|
src/base/pdf-stm.c
|
|
|
pdf_time_init
|
1
|
1
|
6
|
src/base/pdf-time.c
|
|
|
pdf_text_get_country
|
1
|
1
|
5
|
src/base/pdf-text.c
|
|
|
decode_row_none
|
1
|
1
|
8
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_be_file_tell
|
1
|
1
|
5
|
src/base/pdf-stm-be.c
|
|
|
pdf_stm_f_dctdec_fill_input_buffer
|
1
|
1
|
6
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_fp_mul
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_perror
|
1
|
1
|
5
|
src/base/pdf-error.c
|
|
|
pdf_stm_be_mem_tell
|
1
|
1
|
5
|
src/base/pdf-stm-be.c
|
|
|
pdf_hash_get_text
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
key_equal
|
1
|
1
|
5
|
src/base/pdf-hash.c
|
|
|
pdf_hash_key_dealloc_fn
|
1
|
1
|
5
|
src/base/pdf-hash.c
|
|
|
pdf_hash_element_dealloc_fn
|
1
|
1
|
5
|
src/base/pdf-hash.c
|
|
|
pdf_stm_peek_char
|
1
|
1
|
5
|
src/base/pdf-stm.c
|
|
|
pdf_stm_read_char
|
1
|
1
|
5
|
src/base/pdf-stm.c
|
|
|
pdf_fp_sub
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_hash_add_text
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_stm_f_null_init
|
1
|
1
|
9
|
src/base/pdf-stm-f-null.c
|
|
|
can_store_char
|
1
|
1
|
5
|
src/base/pdf-token-reader.c
|
|
|
pdf_stm_f_ahex_int2hex
|
1
|
1
|
5
|
src/base/pdf-stm-f-ahex.c
|
|
|
pdf_stm_f_aesv2dec_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_stm_f_aesv2dec_apply
|
1
|
1
|
7
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_stm_f_aesv2dec_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_fp_add
|
1
|
1
|
6
|
src/base/pdf-fp.c
|
|
|
pdf_stm_f_aesv2enc_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-aesv2.c
|
|
|
lzw_dict_reset
|
1
|
1
|
5
|
src/base/pdf-stm-f-lzw.c
|
|
|
pdf_token_string_new
|
1
|
1
|
7
|
src/base/pdf-token.c
|
|
|
pdf_stm_f_aesv2enc_apply
|
1
|
1
|
7
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_stm_f_aesv2enc_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_stm_filter_get_in
|
1
|
1
|
5
|
src/base/pdf-stm-filter.c
|
|
|
pdf_text_context_get_host_country
|
1
|
1
|
5
|
src/base/pdf-text-context.c
|
|
|
pdf_text_context_get_host_language
|
1
|
1
|
5
|
src/base/pdf-text-context.c
|
|
|
pdf_text_context_get_host_encoding
|
1
|
1
|
5
|
src/base/pdf-text-context.c
|
|
|
pdf_text_context_get_host_endianness
|
1
|
1
|
5
|
src/base/pdf-text-context.c
|
|
|
pdf_text_context_initialized
|
1
|
1
|
5
|
src/base/pdf-text-context.c
|
|
|
pdf_crypt_cipher_decrypt
|
1
|
1
|
8
|
src/base/pdf-crypt.h
|
|
|
pdf_crypt_cipher_encrypt
|
1
|
1
|
8
|
src/base/pdf-crypt.h
|
|
|
pdf_list_size
|
1
|
1
|
5
|
src/base/pdf-list.h
|
|
|
pdf_stm_f_v2dec_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_crypt_cipher_setkey
|
1
|
1
|
6
|
src/base/pdf-crypt.h
|
|
|
pdf_stm_f_v2dec_apply
|
1
|
1
|
7
|
src/base/pdf-stm-f-v2.c
|
|
|
lzw_string_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-lzw.c
|
|
|
hash_dispose_fn
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_stm_f_v2dec_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_stm_f_v2enc_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_stm_f_v2enc_apply
|
1
|
1
|
7
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_stm_f_v2enc_init
|
1
|
1
|
5
|
src/base/pdf-stm-f-v2.c
|
|
|
pdf_hash_get_string
|
1
|
1
|
5
|
src/base/pdf-hash-helper.c
|
|
|
pdf_text_filter_title_case
|
1
|
1
|
5
|
src/base/pdf-text-filter.c
|
|
|
pdf_text_filter_lower_case
|
1
|
1
|
5
|
src/base/pdf-text-filter.c
|
|
|
pdf_text_filter_upper_case
|
1
|
1
|
5
|
src/base/pdf-text-filter.c
|
|
|
pdf_stm_get_mode
|
1
|
1
|
5
|
src/base/pdf-stm.c
|
|
|
pdf_text_init
|
1
|
1
|
6
|
src/base/pdf-text.c
|
|
|
pdf_fsys_disk_file_cancel_ria
|
1
|
1
|
8
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_size
|
1
|
1
|
5
|
src/base/pdf-hash.c
|
|
|
pdf_fsys_disk_file_has_ria
|
1
|
1
|
8
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_fp_ceil
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_fsys_disk_file_request_ria
|
1
|
1
|
10
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_buffer_eob_p
|
1
|
1
|
5
|
src/base/pdf-types.c
|
|
|
pdf_buffer_full_p
|
1
|
1
|
5
|
src/base/pdf-types.c
|
|
|
pdf_text_ucd_pl_is_Soft_Dotted
|
1
|
1
|
7
|
src/base/pdf-text-ucd-proplist.c
|
|
|
encode_row_none
|
1
|
1
|
8
|
src/base/pdf-stm-f-pred.c
|
|
|
pdf_fp_floor
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_fp_log
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_fsys_disk_file_set_size
|
1
|
1
|
7
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_time_span_cmp
|
1
|
1
|
6
|
src/base/pdf-time.c
|
|
|
pdf_fsys_disk_file_can_set_size_p
|
1
|
1
|
7
|
src/base/pdf-fsys-disk.c
|
|
|
pdf_time_span_to_secs
|
1
|
1
|
5
|
src/base/pdf-time.c
|
|
|
pdf_text_get_unicode_bom
|
1
|
1
|
5
|
src/base/pdf-text-encoding.c
|
|
|
pdf_fp_log10
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_text_replace
|
1
|
1
|
7
|
src/base/pdf-text.c
|
|
|
pdf_stm_f_dctenc_dealloc_state
|
1
|
1
|
5
|
src/base/pdf-stm-f-dct.c
|
|
|
pdf_time_span_destroy
|
1
|
1
|
5
|
src/base/pdf-time.c
|
|
|
pdf_fp_abs
|
1
|
1
|
5
|
src/base/pdf-fp.c
|
|
|
pdf_time_span_new
|
1
|
1
|
5
|
src/base/pdf-time.c
|
|
|
pdf_stm_f_dctdec_term_source
|
1
|
0
|
5
|
src/base/pdf-stm-f-dct.c
|