|
↓
|
pdf_eval_type4
|
181
|
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;
}
|
|
↓
|
a85dec_apply
|
43
|
102
|
210
|
../src/base/pdf-stm-f-a85.c
|
static pdf_status_t
a85dec_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish)
{
struct pdf_stm_f_a85_s *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 = (struct pdf_stm_f_a85_s *) 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 = 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 = 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 */
if (!stm_f_a85_write_out (0, out, filter_state) ||
!stm_f_a85_write_out (0, out, filter_state) ||
!stm_f_a85_write_out (0, out, filter_state) ||
!stm_f_a85_write_out (0, out, filter_state))
return PDF_FALSE;
}
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;
oldone = PDF_TRUE;
}
else if (finish)
{ /* 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 = 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 = 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)
{
/* All we have is term code, and finish is requested. fini */
retval = PDF_EEOF;
oldone = PDF_TRUE;
}
else
{ /* finish 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 = stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK != retval)
{
oldone = PDF_TRUE;
}
}
}
return retval;
}
|
|
↓
|
a85enc_apply
|
34
|
100
|
252
|
../src/base/pdf-stm-f-a85.c
|
static pdf_status_t
a85enc_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish)
{
pdf_size_t in_size;
struct pdf_stm_f_a85_s *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 = (struct pdf_stm_f_a85_s *) 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 = 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 = 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 is set, then a partial tuple will be written later */
retval = PDF_ENINPUT;
}
} /* end of if spare_count */
if (retval == PDF_ERROR)
return retval;
retval = 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 = stm_f_a85enc_wr_tuple (tuple, 4, filter_state, out);
if (retval != PDF_OK)
return retval;
retval = 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 do a partial tuple if there are leftover bytes */
if (finish && (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 =
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 */
if (!stm_f_a85_write_out ('~', out, filter_state) ||
!stm_f_a85_write_out ('>', out, filter_state))
return PDF_ERROR;
filter_state->terminated = PDF_TRUE;
}
}
else if (PDF_ENINPUT == retval)
{ /* finish 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 && (PDF_OK == retval))
{
retval = stm_f_a85_flush_outbuff (out, filter_state);
if (PDF_OK == retval)
{ /* We have completed this filter job: */
retval = PDF_EEOF;
}
}
return retval;
}
|
|
↓
|
stm_f_dctdec_apply
|
33
|
91
|
195
|
../src/base/pdf-stm-f-dct.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_dctdec_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
struct pdf_stm_f_dctdec_s *filter_state = state;
struct jpeg_decompress_struct *pcinfo = filter_state->cinfo;
enum pdf_stm_filter_apply_status_e ret;
pdf_i32_t iret;
if (finish &&
((in->wp - in->rp) < 1 ) &&
(pcinfo->output_scanline == pcinfo->output_height) &&
(0 == filter_state->row_valid_size - filter_state->row_copy_index))
{
return PDF_STM_FILTER_APPLY_STATUS_EOF;
}
ret = PDF_STM_FILTER_APPLY_STATUS_OK;
while (ret == PDF_STM_FILTER_APPLY_STATUS_OK)
{
if (filter_state->state == DCTDEC_STATE_INIT)
{
if (!filter_state->djpeg_in)
{
filter_state->djpeg_in = pdf_buffer_new (PDF_DJPEG_CACHE_SIZE, error);
if (!filter_state->djpeg_in)
{
ret = PDF_STM_FILTER_APPLY_STATUS_ERROR;
break;
}
}
jpeg_cache_src (pcinfo, filter_state->djpeg_in);
filter_state->backup_state = DCTDEC_STATE_READHDR;
filter_state->state = DCTDEC_STATE_CACHE_IN;
}
if (filter_state->state == DCTDEC_STATE_CACHE_IN)
{
if (pdf_buffer_eob_p (in))
{
ret = PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
break;
}
ret = src_fill (pcinfo, in);
if (ret != PDF_STM_FILTER_APPLY_STATUS_OK)
break;
filter_state->state = filter_state->backup_state;
}
if (filter_state->state == DCTDEC_STATE_READHDR)
{
iret = jpeg_read_header (pcinfo, TRUE);
if (iret == JPEG_SUSPENDED)
{
/* continue the loop, go into the "cache state" */
ret = PDF_STM_FILTER_APPLY_STATUS_OK;
filter_state->backup_state = filter_state->state;
filter_state->state = DCTDEC_STATE_CACHE_IN;
continue;
}
if (iret != JPEG_HEADER_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ERROR,
"error reading JPEG header");
ret = PDF_STM_FILTER_APPLY_STATUS_ERROR;
break;
}
pdf_stm_f_dctdec_set_djpeg_param (pcinfo, filter_state);
filter_state->state = DCTDEC_STATE_STARTDJP;
}
if (filter_state->state == DCTDEC_STATE_STARTDJP)
{
iret = jpeg_start_decompress (pcinfo);
if (iret == FALSE)
{
/* continue the loop, go into the "cache state" */
ret = PDF_STM_FILTER_APPLY_STATUS_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 (filter_state->state == DCTDEC_STATE_WRITEHDR)
{
ret = write_ppm_header (pcinfo, out, error);
if (ret != PDF_STM_FILTER_APPLY_STATUS_OK)
break;
filter_state->state = DCTDEC_STATE_SCANLINE;
}
if (filter_state->state == DCTDEC_STATE_OUTPUTLINE)
{
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_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
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_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
break;
}
}
if ((ret == PDF_STM_FILTER_APPLY_STATUS_OK) &&
(pcinfo->output_scanline == pcinfo->output_height))
{
ret = PDF_STM_FILTER_APPLY_STATUS_EOF;
break;
}
}
filter_state->state = DCTDEC_STATE_SCANLINE;
}
if (filter_state->state == DCTDEC_STATE_SCANLINE)
{
ret = PDF_STM_FILTER_APPLY_STATUS_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_STM_FILTER_APPLY_STATUS_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 (ret == PDF_STM_FILTER_APPLY_STATUS_NO_INPUT &&
finish)
{
ret = PDF_STM_FILTER_APPLY_STATUS_EOF;
}
return ret;
}
|
|
↓
|
handle_char
|
29
|
87
|
271
|
../src/base/pdf-token-reader.c
|
static pdf_bool_t
handle_char (pdf_token_reader_t *reader,
pdf_u32_t flags,
pdf_char_t ch,
pdf_bool_t *again,
pdf_bool_t *eof,
pdf_token_t **token,
pdf_error_t **error)
{
/* first, handle the states that shouldn't be exited when whitespace
* or a delimiter is seen */
switch (reader->state)
{
case PDF_TOKR_STATE_EOF:
{
*eof = PDF_TRUE;
return PDF_TRUE;
}
case PDF_TOKR_STATE_STRING:
return handle_string_char (reader, flags, ch, eof, token, error);
case PDF_TOKR_STATE_HEXSTRING:
return handle_hexstring_char (reader, flags, ch, eof, token, error);
case PDF_TOKR_STATE_DICTEND:
{
if (ch != '>')
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"no dict end");
return PDF_FALSE;
}
reader->substate = 1; /* saw the closing '>' */
return exit_state (reader, flags, eof, token, error);
}
case PDF_TOKR_STATE_COMMENT:
{
if (pdf_is_eol_char (ch))
{
if (!exit_state (reader, flags, eof, token, error))
return PDF_FALSE;
/* don't accept this character, but process it next time */
*again = PDF_TRUE;
return PDF_TRUE;
}
if (!(flags & PDF_TOKEN_RET_COMMENTS))
reader->substate = 1;
if (reader->substate == 1)
return PDF_TRUE; /* we don't care about this comment */
return store_char_grow (reader, ch, error);
}
default:
/* Nothing to do */
break;
}
/* now handle delimiters and whitespace */
if (pdf_is_wspace_char (ch))
{
if (reader->state)
{
if (!exit_state (reader, flags, eof, token, error))
return PDF_FALSE;
/* avoid reading this byte so PDF_TOKEN_END_AT_STREAM
* will work properly if it's '\r' */
*again = PDF_TRUE;
return PDF_TRUE;
}
if ((flags & PDF_TOKEN_END_AT_STREAM) && ch == '\n') /* LF */
{
/* found the beginning of a stream */
enter_state (reader, PDF_TOKR_STATE_EOF);
}
return PDF_TRUE;
}
if ((flags & PDF_TOKEN_END_AT_STREAM) && ch != '%')
{
/* only allow whitespace/comments after the "stream" keyword */
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"only whitespace/comments allowed after 'stream' keyword");
return PDF_FALSE;
}
if (pdf_is_delim_char (ch))
{
/* set state 0 (UNINIT), substate 0, bufpos 0 */
if (reader->state)
{
if (!exit_state (reader, flags, eof, token, error))
return PDF_FALSE;
*again = PDF_TRUE;
return PDF_TRUE;
}
switch (ch)
{
case '%':
{
enter_state (reader, PDF_TOKR_STATE_COMMENT);
return PDF_TRUE;
}
case '(':
{
enter_state (reader, PDF_TOKR_STATE_STRING);
reader->intparam = 0;
return PDF_TRUE;
}
case ')':
{
/* this shouldn't occur outside the STRING and COMMENT states */
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"wrong ')' out of string and comment states");
return PDF_FALSE;
}
case '/':
{
enter_state (reader, PDF_TOKR_STATE_NAME);
return PDF_TRUE;
}
case '<':
{
enter_state (reader, PDF_TOKR_STATE_HEXSTRING);
return PDF_TRUE;
}
case '>':
{
enter_state (reader, PDF_TOKR_STATE_DICTEND);
return PDF_TRUE;
}
case '[':
case ']':
case '{':
case '}':
{
/* 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_TRUE;
}
default:
{
/* not reached (all delimiter chars should be handled) */
PDF_ASSERT_TRACE_NOT_REACHED ();
return PDF_FALSE;
}
}
}
/* ch is a regular character */
switch (reader->state)
{
case PDF_TOKR_STATE_PENDING:
{
if (!exit_state (reader, flags, eof, token, error))
return PDF_FALSE;
*again = PDF_TRUE;
return PDF_TRUE;
}
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, error);
case PDF_TOKR_STATE_NAME:
{
if (reader->substate == 0)
{
if ((ch < 0x21) || (ch > 0x7e))
{
/* Invalid character in a name. */
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"invalid character in a name (%d)",
ch);
return PDF_FALSE;
}
if (ch != '#' ||
(flags & PDF_TOKEN_NO_NAME_ESCAPES))
return store_char (reader, ch, error);
reader->substate = 1;
return PDF_TRUE;
}
if ((ch = HEXVAL (ch)) == 255)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"not an hex character '%c' (%d)",
ch, ch);
return PDF_FALSE;
}
if (reader->substate == 1) /* the first hex digit of an escape */
{
reader->substate = 2;
reader->charparam = ch;
return PDF_TRUE;
}
ch = (reader->charparam << 4) | ch;
if (ch == 0) /* the PDF spec forbids "#00" */
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot handle char: "
"'#00' is forbidden");
return PDF_FALSE;
}
if (!store_char (reader, ch, error))
return PDF_FALSE;
reader->substate = 0;
return PDF_TRUE;
}
default:
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot handle char: "
"invalid state (%d)",
reader->state);
return PDF_FALSE;
}
}
}
|
|
↓
|
canonicalize_path
|
28
|
53
|
112
|
../src/base/pdf-fsys-disk.c
|
static pdf_bool_t
canonicalize_path (const pdf_fsys_t *fsys,
const pdf_text_t *path,
pdf_text_t **canonicalized_path,
pdf_char_t **canonicalized_path_utf8,
pdf_error_t **error)
{
pdf_char_t *canon;
pdf_char_t *start;
pdf_char_t *p;
pdf_char_t *q;
int i;
/* Get UTF-8 encoded path */
canon = ensure_absolute_path (fsys, path, error);
if (!canon)
return PDF_FALSE;
/* Skip root */
start = skip_root_utf8 (canon);
/* POSIX allows double slashes at the start to
* mean something special (as does windows too).
* So, "//" != "/", but more than two slashes
* is treated as "/".
*/
i = 0;
for (p = start - 1;
(p >= canon) &&
IS_DIR_SEPARATOR (*p);
p--)
i++;
if (i > 2)
{
i -= 1;
start -= i;
memmove (start, start + i, strlen (start + i) + 1);
}
p = start;
while (*p != 0)
{
if (p[0] == '.' && (p[1] == 0 || IS_DIR_SEPARATOR (p[1])))
{
memmove (p, p + 1, strlen (p + 1) + 1);
}
else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || IS_DIR_SEPARATOR (p[2])))
{
q = p + 2;
/* Skip previous separator */
p = p - 2;
if (p < start)
p = start;
while (p > start && !IS_DIR_SEPARATOR (*p))
p--;
if (IS_DIR_SEPARATOR (*p))
*p++ = DIR_SEPARATOR_C;
memmove (p, q, strlen (q)+1);
}
else
{
/* Skip until next separator */
while (*p != 0 && !IS_DIR_SEPARATOR (*p))
p++;
if (*p != 0)
{
/* Canonicalize one separator */
*p++ = DIR_SEPARATOR_C;
}
}
/* Remove additional separators */
q = p;
while (*q && IS_DIR_SEPARATOR (*q))
q++;
if (p != q)
memmove (p, q, strlen (q)+1);
}
/* Remove trailing slashes */
if (p > start && IS_DIR_SEPARATOR (*(p-1)))
*(p-1) = 0;
/* If length of the canonicalized path is zero, report error */
if (canon [0] == '\0')
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_EBADDATA,
"empty canonicalized path built");
pdf_dealloc (canon);
return PDF_FALSE;
}
/* Set output(s) */
if (canonicalized_path)
*canonicalized_path = pdf_text_new_from_unicode (canon,
strlen (canon),
PDF_TEXT_UTF8,
error);
if (canonicalized_path_utf8)
*canonicalized_path_utf8 = canon;
else
pdf_dealloc (canon);
return PDF_TRUE;
}
|
|
↓
|
handle_string_char
|
26
|
59
|
138
|
../src/base/pdf-token-reader.c
|
static pdf_bool_t
handle_string_char (pdf_token_reader_t *reader,
pdf_u32_t flags,
pdf_char_t ch,
pdf_bool_t *eof,
pdf_token_t **token,
pdf_error_t **error)
{
while (PDF_TRUE)
{
switch (reader->substate)
{
case 1: /* ignore LF */
{
reader->substate = 0;
if (ch == '\n')
return PDF_TRUE;
} /* fall through */
case 0: /* no special state */
{
pdf_bool_t was_cr;
if (ch == '\\')
{
/* start an escape sequence */
reader->substate = 2;
return PDF_TRUE;
}
if (ch == ')' &&
reader->intparam <= 0) /* ')'; end of string */
{
reader->intparam = -1;
return exit_state (reader, flags, eof, token, error);
}
was_cr = (ch == '\r');
if (was_cr)
ch = '\n'; /* treat as LF */
if (!store_char_grow (reader, ch, error))
return PDF_FALSE;
if (was_cr)
{
/* ignore the next char if it's LF */
reader->substate = 1;
}
else if (ch == '(')
++reader->intparam;
else if (ch == ')')
--reader->intparam;
return PDF_TRUE;
}
case 2: /* just saw a '\\' (starting an escape sequence) */
{
reader->substate = 0;
if (ch == 'b')
ch = 8; /* BS: backspace */
else if (ch == 'f')
ch = 12; /* FF: formfeed */
else if (ch == 'n')
ch = '\n'; /* NL: newline */
else if (ch == 'r')
ch = '\r'; /* CR: carriage return */
else if (ch == 't')
ch = '\t'; /* HT: horizontal tab */
else if (ch == '\n') /* NL */
return PDF_TRUE; /* ignore the line break */
else if (ch == '\r') /* CR */
{
/* ignore the line break; also ignore the next byte if it's LF */
reader->substate = 1;
return PDF_TRUE;
}
else if (ch >= '0' && ch <= '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 - '0');
return PDF_TRUE;
}
/* for any other character, including '(', ')', and '\\',
* store the same character (dropping the leading backslash) */
return store_char_grow (reader, ch, error);
}
case 3: /* saw 1 digit of an octal escape */
{
} /* fall through */
case 4: /* saw 2 digits of an octal escape */
{
if (ch < '0' || ch > '7')
{
if (!store_char_grow (reader, reader->charparam, error))
return PDF_FALSE;
/* ch isn't part of the escape sequence, so retry */
reader->substate = 0;
continue;
}
/* ch is a digit from '0'--'7' */
reader->charparam = ((reader->charparam & 0x1f) << 3) | (ch - '0');
if (reader->substate == 4) /* this was the final digit */
{
if (!store_char_grow (reader, reader->charparam, error))
return PDF_FALSE;
reader->substate = 0;
return PDF_TRUE;
}
reader->substate = 4;
return PDF_TRUE;
}
default:
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot handle string char: "
"invalid substate (%d)",
reader->substate);
return PDF_FALSE;
}
}
}
}
|
|
↓
|
stm_f_pred_init
|
24
|
46
|
143
|
../src/base/pdf-stm-f-pred.c
|
static pdf_bool_t
stm_f_pred_init (const pdf_hash_t *params,
void **state,
pdf_error_t **error)
{
pdf_size_t actual_len;
pdf_stm_f_pred_t* filter_state;
/* Predictor decides if we need more paramters; so check it first */
if (!params || !pdf_hash_key_p (params, PRED_PARAM_PREDICTOR))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"cannot initialize predictor encoder/decoder: "
"parameter '"PRED_PARAM_PREDICTOR"' missing");
return PDF_FALSE;
}
/* We demand all parameters if predictor > 1 */
if (pdf_hash_get_size (params, PRED_PARAM_PREDICTOR) > 1)
{
if (!pdf_hash_key_p (params, PRED_PARAM_COLORS) ||
!pdf_hash_key_p (params, PRED_PARAM_BPC) ||
!pdf_hash_key_p (params, PRED_PARAM_COLUMNS))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"cannot initialize predictor encoder/decoder: "
"parameters missing ('"PRED_PARAM_COLORS"': %s, "
"'"PRED_PARAM_BPC"': %s, '"PRED_PARAM_COLUMNS"': %s)",
((params && pdf_hash_key_p (params, PRED_PARAM_COLORS)) ?
"available" : "missing"),
((params && pdf_hash_key_p (params, PRED_PARAM_BPC)) ?
"available" : "missing"),
((params && pdf_hash_key_p (params, PRED_PARAM_COLUMNS)) ?
"available" : "missing"));
return PDF_FALSE;
}
}
/* Create the private filter_state storage */
filter_state = pdf_alloc (sizeof (struct pdf_stm_f_pred_s));
if (!filter_state)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create predictor encoder/decoder internal state: "
"couldn't allocate %lu bytes",
(unsigned long) sizeof (pdf_stm_f_pred_t));
return PDF_FALSE;
}
filter_state->predictor = pdf_hash_get_size (params, PRED_PARAM_PREDICTOR);
filter_state->colors = pdf_hash_get_size (params, PRED_PARAM_COLORS);
filter_state->bits_per_component = pdf_hash_get_size (params, PRED_PARAM_BPC);
filter_state->columns = pdf_hash_get_size (params, PRED_PARAM_COLUMNS);
/* as no parameters for predictor 1 (NO_PREDICTION) is needed */
if (filter_state->predictor == PDF_STM_F_PREDENC_NO_PREDICTION)
{
/* set default values */
filter_state->colors = 1;
filter_state->bits_per_component = 1;
filter_state->columns = 1;
}
/* else wise check for bad parameter values */
else
{
if (filter_state->colors < 1
|| filter_state->columns < 1
|| filter_state->bits_per_component < 1)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"cannot initialize predictor encoder/decoder: "
"bad parameter values ('"PRED_PARAM_COLORS"': %s, "
"'"PRED_PARAM_BPC"': %s, '"PRED_PARAM_COLUMNS"': %s)",
((filter_state->colors < 1) ?
"bad" : "ok"),
((filter_state->bits_per_component < 1) ?
"bad" : "ok"),
((filter_state->columns < 1) ?
"bad" : "ok"));
return PDF_FALSE;
}
}
/* We need the number of full bytes that each row has. As defined in the
* PNG standard we can assume that if greater than 8 the bits per component
* is multiplier of eight. */
actual_len = filter_state->columns * filter_state->colors *
filter_state->bits_per_component;
filter_state->scanline_len = (actual_len >> 3) + (actual_len & 7);
/* one extra byte for PNG predictor */
filter_state->prev_row_buf = pdf_buffer_new (filter_state->scanline_len + 1,
error);
if (!(filter_state->prev_row_buf))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create predictor encoder/decoder internal buffer: "
"couldn't allocate %lu bytes",
(unsigned long) filter_state->scanline_len);
return PDF_FALSE;
}
/* hint for further optimizing (if necessary): if scanlines are smaller than
in and out buffers, curr_row_buf and out_row_buf are not needed and two
memcpys per scanline can be omitted */
filter_state->curr_row_buf = pdf_buffer_new (filter_state->scanline_len + 1,
error);
if (!(filter_state->curr_row_buf))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create predictor encoder/decoder internal buffer: "
"couldn't allocate %lu bytes",
(unsigned long) filter_state->scanline_len);
return PDF_FALSE;
}
filter_state->out_row_buf = pdf_buffer_new (filter_state->scanline_len + 1,
error);
if (!(filter_state->out_row_buf))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create predictor encoder/decoder internal buffer: "
"couldn't allocate %lu bytes",
(unsigned long) filter_state->scanline_len + 1);
return PDF_FALSE;
}
*state = filter_state;
return PDF_TRUE;
}
|
|
↓
|
stm_f_aesv2_apply
|
22
|
59
|
163
|
../src/base/pdf-stm-f-aesv2.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_aesv2_apply (pdf_stm_f_aesv2_mode_e mode,
void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
struct pdf_stm_f_aesv2_s *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 (PDF_TRUE)
{
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;
PDF_ASSERT (in->wp >= in->rp);
PDF_ASSERT (out->size >= out->wp);
/* TODO: Shouldn't this be like this?
* in_size = in->size - in->rp;
*/
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);
/* Read bytes from IN and fill IN_CACHE */
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 &&
mode == PDF_STM_F_AESV2_MODE_DECODE &&
in_cache->wp > 0)
{
/* TODO: Better error explanation */
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ERROR,
"");
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
}
/* ...pad the cache if we have reached EOD */
if (finish &&
mode == PDF_STM_F_AESV2_MODE_ENCODE &&
!pdf_buffer_full_p (in_cache))
{
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_STM_FILTER_APPLY_STATUS_NO_INPUT; /* ...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:
if (!pdf_crypt_cipher_encrypt (cipher,
(pdf_char_t *)out_cache->data,
out_cache->size,
(const pdf_char_t *)in_cache->data,
in_cache->size,
NULL,
error))
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
break;
case PDF_STM_F_AESV2_MODE_DECODE:
if (!pdf_crypt_cipher_decrypt (cipher,
(pdf_char_t *)out_cache->data,
out_cache->size,
(const pdf_char_t *)in_cache->data,
in_cache->size,
NULL,
error))
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
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)
{
pdf_size_t padding;
padding = out_cache->data[out_cache->size - 1];
if (padding > AESV2_CACHE_SIZE)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ERROR,
"Padding longer than AESv2 cache (%lu > %lu)",
(unsigned long)padding,
(unsigned long)AESV2_CACHE_SIZE);
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
}
out_cache->wp = out_cache->size - padding;
}
else /* Ask for more input */
return PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
}
/* 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)
return PDF_STM_FILTER_APPLY_STATUS_EOF;
if (pdf_buffer_full_p (out))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
/* Continue loop */
pdf_buffer_rewind (out_cache);
}
}
|
|
↓
|
pdf_text_get_unicode
|
21
|
67
|
192
|
../src/base/pdf-text.c
|
pdf_char_t *
pdf_text_get_unicode (const pdf_text_t *text,
enum pdf_text_unicode_encoding_e enc,
pdf_u32_t options,
pdf_size_t *length,
pdf_error_t **error)
{
pdf_char_t *out_data = NULL;
pdf_size_t out_length = 0;
pdf_bool_t ret;
PDF_ASSERT_POINTER_RETURN_VAL (text, NULL);
PDF_ASSERT_RETURN_VAL (enc >= PDF_TEXT_UTF8, NULL);
PDF_ASSERT_RETURN_VAL (enc < PDF_TEXT_MAX_UNICODE_ENC, NULL);
/* Lang/Country info only available for UTF-16BE */
if ((options & PDF_TEXT_UTF16BE_WITH_LANGCODE) &&
(enc != PDF_TEXT_UTF16_BE))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ETEXTENC,
"cannot get text contents unicode encoded: "
"language-code request only possible for UTF-16BE");
return NULL;
}
/* If host endianness required, check it and convert input encoding */
enc = pdf_text_transform_he_to_unicode_encoding (enc);
/* If text is empty, set empty string */
if ((text->data == NULL) ||
(text->size == 0))
{
ret = PDF_TRUE;
out_data = NULL;
/* Length is optional because you can ask for unicode output with NUL trailer */
if (length)
*length = 0;
}
else
{
/* Perform conversion */
switch (enc)
{
case PDF_TEXT_UTF8: /* UTF-8 */
ret = pdf_text_utf32he_to_utf8 (text->data,
text->size,
&out_data,
&out_length,
error);
break;
case PDF_TEXT_UTF16_LE: /* UTF-16LE */
ret = pdf_text_utf32he_to_utf16le (text->data,
text->size,
&out_data,
&out_length,
error);
break;
case PDF_TEXT_UTF16_BE: /* UTF-16BE */
ret = pdf_text_utf32he_to_utf16be (text->data,
text->size,
&out_data,
&out_length,
error);
break;
case PDF_TEXT_UTF32_LE: /* UTF-32LE */
ret = pdf_text_utf32he_to_utf32le (text->data,
text->size,
&out_data,
&out_length,
error);
break;
case PDF_TEXT_UTF32_BE: /* UTF-32BE */
ret = pdf_text_utf32he_to_utf32be (text->data,
text->size,
&out_data,
&out_length,
error);
break;
default:
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ETEXTENC,
"couldn't get text contents in the given unicode "
"encoding (%d)",
enc);
ret = PDF_FALSE;
break;
}
}
if (!ret)
{
if (out_data)
pdf_dealloc (out_data);
return NULL;
}
/* 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 (enc,
options,
pdf_text_get_language(text),
pdf_text_get_country(text),
header,
&header_size);
}
/* Compute trailer if needed */
if (options & PDF_TEXT_UNICODE_WITH_NUL_SUFFIX)
{
switch (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;
pdf_size_t new_size;
/* Allocate memory for new string */
new_size = out_length + header_size + trailer_size;
new_out_data = (pdf_char_t *) pdf_alloc (new_size);
if (!new_out_data)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"couldn't get text contents in the given unicode "
"encoding: "
"couldn't reallocate %lu bytes",
(unsigned long)new_size);
return NULL;
}
/* 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);
}
}
/* Length is optional because you can ask for unicode output with NUL trailer */
if (length)
*length = out_length;
return out_data;
}
|
|
↓
|
pdf_time_to_string_utc_asn1
|
21
|
37
|
65
|
../src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_utc_asn1(const pdf_time_t *time_var,
pdf_error_t **error)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
pdf_i32_t smallyear;
str = (pdf_char_t *) pdf_alloc (PDF_MAX_UTCASN1_STR_LENGTH);
if (!str)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_ENOMEM,
"cannot create string with UTC ASN1 time: "
"couldn't allocate %lu bytes",
PDF_MAX_UTCASN1_STR_LENGTH);
return NULL;
}
pdf_time_get_local_cal (time_var, &calendar);
/* 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 (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 (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);
}
return str;
}
|
|
↓
|
pdf_fp_func_4_new
|
20
|
156
|
272
|
../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_error_t *inner_error = NULL;
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 */
reader_stm = pdf_stm_mem_new ((pdf_uchar_t *)code,
code_size,
code_size, /* Use the default cache size */
PDF_STM_READ,
&inner_error);
if (!reader_stm)
{
/* TODO: Propagate error */
pdf_error_destroy (inner_error);
ret = PDF_ERROR;
goto fail;
}
reader = pdf_token_reader_new (reader_stm, &inner_error);
if (!reader)
{
/* TODO: Propagate error */
pdf_error_destroy (inner_error);
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_text_utf16he_to_utf32he
|
20
|
63
|
188
|
../src/base/pdf-text-encoding.c
|
pdf_bool_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,
pdf_error_t **error)
{
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADDATA,
"cannot convert from UTF-16HE to UTF-32HE: "
"invalid input data length: %lu",
(unsigned long)input_length);
return PDF_FALSE;
}
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from UTF-16HE to UTF-32HE: "
"couldn't allocate %lu bytes",
(unsigned long)new_string_length_worst);
return PDF_FALSE;
}
/* 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,
error);
if (delta_in_utf16be == 0)
{
/* Oops, invalid UTF-16HE point found! */
pdf_dealloc (data);
return PDF_FALSE;
}
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from UTF-16HE to UTF-32HE: "
"couldn't reallocate %lu bytes",
(unsigned long)new_string_length);
return PDF_FALSE;
}
}
return PDF_TRUE;
}
|
|
↓
|
stm_f_predenc_apply
|
19
|
57
|
131
|
../src/base/pdf-stm-f-pred.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_predenc_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
pdf_stm_f_pred_t *fs = state; /* filter state */
pdf_bool_t is_png_predictor;
is_png_predictor = PNG_ENC_PREDICTOR_P(fs->predictor);
pdf_char_t *curr_row;
pdf_char_t *prev_row = NULL;
pdf_char_t *out_buf;
pdf_size_t in_size;
PDF_ASSERT (in->wp >= in->rp);
size_t tocpy;
/* copy all at once instead of copying each scanline for predictor 1;
this is needed because we may not know real scanline_len and therefor use
scanline_len = 1 which would be very slow */
if (fs->predictor == PDF_STM_F_PREDENC_NO_PREDICTION)
{
tocpy = PDF_MIN (out->size - out->wp, in->wp - in->rp);
memcpy(out->data + out->wp, in->data + in->rp, tocpy);
out->wp += tocpy;
in->rp += tocpy;
}
/* copy in->data to buffer and filter it */
do
{
in_size = in->wp - in->rp;
tocpy = PDF_MIN (fs->curr_row_buf->size - fs->curr_row_buf->wp - 1,
in_size);
memcpy (fs->curr_row_buf->data + fs->curr_row_buf->wp, in->data + in->rp,
tocpy);
fs->curr_row_buf->wp += tocpy;
in->rp += tocpy;
/* one scanline is in curr_row_buf ready for filtering */
if (fs->curr_row_buf->wp - fs->curr_row_buf->rp == fs->scanline_len)
{
/* check if out buffer has enough space left */
pdf_size_t left;
left = fs->out_row_buf->size - fs->out_row_buf->wp;
/* PNG predictor needs extra byte per row */
if (left >= fs->scanline_len + (is_png_predictor? 1 : 0))
{
/* write/read PNG predictor at first byte of a row */
if (is_png_predictor)
fs->out_row_buf->data[fs->out_row_buf->wp++] = fs->predictor;
curr_row = (pdf_char_t*) fs->curr_row_buf->data;
out_buf = (pdf_char_t*) fs->out_row_buf->data
+ fs->out_row_buf->wp;
/* at first row encode_row expects prev_row to be NULL */
if (fs->prev_row_buf->wp == 0)
prev_row = NULL;
else
prev_row = (pdf_char_t*) fs->prev_row_buf->data;
if (encode_row (curr_row, prev_row, out_buf, fs, error)
== PDF_ERROR)
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
fs->out_row_buf->wp += fs->scanline_len;
/* instead of copying curr to prev, swap addresses */
pdf_buffer_t *swap_tmp_buf = fs->prev_row_buf;
fs->prev_row_buf = fs->curr_row_buf;
fs->curr_row_buf = swap_tmp_buf;
pdf_buffer_rewind (fs->curr_row_buf);
}
}
/* out_row_buf has data that can be written to out buffer */
if (out->size - out->wp > 0 && !pdf_buffer_eob_p (fs->out_row_buf))
{
tocpy = PDF_MIN (fs->out_row_buf->wp - fs->out_row_buf->rp,
out->size - out->wp);
memcpy (out->data + out->wp,
fs->out_row_buf->data + fs->out_row_buf->rp,
tocpy);
out->wp += tocpy;
fs->out_row_buf->rp += tocpy;
}
if (pdf_buffer_eob_p (fs->out_row_buf))
{
pdf_buffer_rewind (fs->out_row_buf);
}
}
while (!pdf_buffer_eob_p (in) && !pdf_buffer_full_p (out));
/* if we do PNG prediction (is_png_predictor) and in->size == out->size
* it happens that out->data is full and we have not read all of in->data */
if (pdf_buffer_full_p (out) && !pdf_buffer_eob_p (in))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
/* final call of this filter; empty out_row_buf */
if (finish && in->wp - in->rp < 1)
{
/* out_row_buf has data because out is full */
if (!pdf_buffer_eob_p (fs->out_row_buf))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
/* input % scanline_len != 0 */
if (!pdf_buffer_eob_p (fs->curr_row_buf))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"filtering with predictor encoder is incomplete: "
"out of data in the middle of a scanline "
"or wrong columns parameter detected");
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
}
return PDF_STM_FILTER_APPLY_STATUS_EOF;
}
return PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
}
|
|
↓
|
parse_integer
|
19
|
42
|
91
|
../src/base/pdf-token-reader.c
|
static pdf_i32_t
parse_integer (pdf_buffer_t *buffer,
pdf_i32_t *int_value,
pdf_i32_t *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)
*/
pdf_i32_t sign = 0;
pdf_i32_t tmpint = 0;
pdf_bool_t overflowed = PDF_FALSE;
pdf_i32_t 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)
{
pdf_i32_t chval;
pdf_char_t ch;
ch = buffer->data[buffer->rp];
if (ch == '+' || ch == '-')
{
if (*int_state != 0)
break;
*int_state = 1;
sign = (ch == '-') ? 1 : -1;
continue;
}
chval = ch - '0'; /* assume this is a digit */
if (chval < 0 || chval > 9)
break; /* 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 = PDF_TRUE; /* would overflow */
continue;
}
}
else
{
if (tmpint > (INT_MAX / 10) ||
(tmpint == (INT_MAX / 10) &&
chval > (INT_MAX % 10)))
{
overflowed = PDF_TRUE; /* would overflow */
continue;
}
}
tmpint += chval + (tmpint * 9);
}
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_pdf
|
19
|
34
|
61
|
../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_error_t **error)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar = { 0 };
str = (pdf_char_t *) pdf_alloc (PDF_MAX_PDFDATE_STR_LENGTH);
if (!str)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_ENOMEM,
"cannot create string with PDF time: "
"couldn't allocate %lu bytes",
PDF_MAX_PDFDATE_STR_LENGTH);
return NULL;
}
/* D:YYYYMMDDHHmmSSOHH'mm' */
pdf_time_get_local_cal (time_var, &calendar);
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 (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 (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);
}
return str;
}
|
|
↓
|
pdf_text_filter
|
19
|
30
|
80
|
../src/base/pdf-text.c
|
pdf_bool_t
pdf_text_filter (pdf_text_t *text,
pdf_u32_t filter,
pdf_error_t **error)
{
PDF_ASSERT_POINTER_RETURN_VAL (text, PDF_FALSE);
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ETEXTENC,
"cannot apply filters to text: "
"at most only one case conversion filter can be applied");
return PDF_FALSE;
}
/* 0x00000001 */
if ((filter & PDF_TEXT_FILTER_LINE_ENDINGS) &&
(!pdf_text_filter_normalize_line_endings (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x00000010 */
if ((filter & PDF_TEXT_FILTER_UPPER_CASE) &&
(!pdf_text_filter_upper_case (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x00000100 */
else if ((filter & PDF_TEXT_FILTER_LOWER_CASE) &&
(!pdf_text_filter_lower_case (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x00001000 */
else if ((filter & PDF_TEXT_FILTER_TITLE_CASE) &&
(!pdf_text_filter_title_case (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x00010000 */
if ((filter & PDF_TEXT_FILTER_REMOVE_AMP) &&
(!pdf_text_filter_remove_amp (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x00100000 */
if ((filter & PDF_TEXT_FILTER_NORM_WITH_FULL_WIDTH) &&
(!pdf_text_filter_normalize_full_width_ascii (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
/* 0x01000000 */
if ((filter & PDF_TEXT_FILTER_REMOVE_LINE_ENDINGS) &&
(!pdf_text_filter_remove_line_endings (text, error)))
{
pdf_prefix_error (error, "cannot apply filters to text: ");
return PDF_FALSE;
}
text->modified = PDF_TRUE;
return PDF_TRUE;
}
|
|
↓
|
stm_f_preddec_apply
|
18
|
59
|
130
|
../src/base/pdf-stm-f-pred.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_preddec_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
pdf_stm_f_pred_t *fs = state; /* filter state */
pdf_bool_t is_png_predictor;
is_png_predictor = PNG_DEC_PREDICTOR_P(fs->predictor);
pdf_char_t *curr_row;
pdf_char_t *prev_row = NULL;
pdf_char_t *out_buf;
pdf_size_t in_size;
PDF_ASSERT (in->wp >= in->rp);
size_t tocpy;
/* copy all at once instead of copying each scanline for predictor 1;
this is needed because we may not know real scanline_len and therefor use
scanline_len = 1 which would be very slow */
if (fs->predictor == PDF_STM_F_PREDDEC_NO_PREDICTION)
{
tocpy = PDF_MIN (out->size - out->wp, in->wp - in->rp);
memcpy(out->data + out->wp, in->data + in->rp, tocpy);
out->wp += tocpy;
in->rp += tocpy;
}
/* copy in->data to buffer and filter it */
do
{
in_size = in->wp - in->rp;
tocpy = fs->curr_row_buf->size - fs->curr_row_buf->wp;
/* PNG predictor needs 1 byte more in a scanline */
tocpy -= (is_png_predictor? 0 : 1);
tocpy = PDF_MIN (in_size, tocpy);
memcpy (fs->curr_row_buf->data + fs->curr_row_buf->wp, in->data + in->rp,
tocpy);
fs->curr_row_buf->wp += tocpy;
in->rp += tocpy;
/* curr_row_buf has a scanline (+PNG predictor) and is ready to filter */
if (fs->scanline_len == fs->curr_row_buf->wp - fs->curr_row_buf->rp
- (is_png_predictor ? 1 : 0))
{
/* check if out buffer has enough space left */
pdf_size_t left;
left = fs->out_row_buf->size - fs->out_row_buf->wp;
/* PNG predictor needs extra byte per row */
if (left >= fs->scanline_len + (is_png_predictor? 1 : 0))
{
/* write/read PNG predictor at first byte of a row */
if (is_png_predictor)
fs->predictor = fs->curr_row_buf->data[fs->curr_row_buf->rp++];
curr_row = (pdf_char_t*) fs->curr_row_buf->data
+ fs->curr_row_buf->rp;
out_buf = (pdf_char_t*) fs->out_row_buf->data
+ fs->out_row_buf->wp;
/* at first row decode_row expects prev_row to be NULL */
if (fs->prev_row_buf->wp == 0)
prev_row = NULL;
else
prev_row = (pdf_char_t*) fs->prev_row_buf->data;
if (decode_row (curr_row, out_buf, prev_row, fs, error)
== PDF_ERROR)
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
fs->out_row_buf->wp += fs->scanline_len;
/* copying out_row to prev_row */
memcpy (fs->prev_row_buf->data, fs->out_row_buf->data,
fs->out_row_buf->size);
fs->prev_row_buf->rp = fs->out_row_buf->rp;
fs->prev_row_buf->wp = fs->out_row_buf->wp;
pdf_buffer_rewind (fs->curr_row_buf);
}
}
/* out_row_buf has data that can be written to out buffer */
if (out->size - out->wp > 0 && !pdf_buffer_eob_p (fs->out_row_buf))
{
tocpy = PDF_MIN (fs->out_row_buf->wp - fs->out_row_buf->rp,
out->size - out->wp);
memcpy (out->data + out->wp,
fs->out_row_buf->data + fs->out_row_buf->rp, tocpy);
out->wp += tocpy;
fs->out_row_buf->rp += tocpy;
}
if (pdf_buffer_eob_p (fs->out_row_buf))
{
pdf_buffer_rewind (fs->out_row_buf);
}
}
while (!pdf_buffer_eob_p (in));
/* final call of this filter; empty out_row_buf */
if (finish && in->wp - in->rp < 1)
{
/* out_row_buf has data because out is full */
if (!pdf_buffer_eob_p (fs->out_row_buf))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
/* input % scanline_len != 0 */
if (!pdf_buffer_eob_p (fs->curr_row_buf))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"filtering with predictor decoder is incomplete: "
"out of data in the middle of a scanline "
"or wrong columns parameter detected");
return PDF_STM_FILTER_APPLY_STATUS_ERROR;
}
return PDF_STM_FILTER_APPLY_STATUS_EOF;
}
return PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
}
|
|
↓
|
pdf_text_ucd_Final_Sigma
|
18
|
45
|
105
|
../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
|
40
|
126
|
../src/base/pdf-text.c
|
pdf_text_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_error_t **error)
{
pdf_text_t *element;
pdf_bool_t bom_found = PDF_FALSE;
pdf_bool_t lang_found = PDF_FALSE;
PDF_ASSERT_POINTER_RETURN_VAL (str, NULL);
PDF_ASSERT_RETURN_VAL (size > 0, NULL);
/* Allocate and initialize element */
element = pdf_text_new (error);
if (!element)
{
pdf_prefix_error (error,
"cannot create text object "
"from PDF string: ");
return NULL;
}
/* 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 = PDF_TRUE;
/* Check Lang/Country Code initializer */
if ((size >= 4) &&
(str[3] == PDF_TEXT_LCI_1) &&
(str[2] == PDF_TEXT_LCI_0))
{
lang_found = PDF_TRUE;
}
}
/* 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 = PDF_TRUE;
}
}
/* 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,
error)))
{
pdf_prefix_error (error,
"cannot create text object "
"from PDF string: ");
pdf_text_destroy (element);
return NULL;
}
/* And finally convert to UTF-32... */
if (!pdf_text_utf16be_to_utf32he (string_start,
string_length,
&(element->data),
&(element->size),
remaining_str,
remaining_length,
error))
{
pdf_prefix_error (error,
"cannot create text object "
"from PDF string: ");
pdf_text_destroy (element);
return NULL;
}
/* Return newly created element */
return element;
}
/* Else, process PDF string as encoded in PDF Doc Encoding */
/* 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 */
if (!pdf_text_pdfdocenc_to_utf32he (str,
size,
&(element->data),
&(element->size),
error))
{
pdf_prefix_error (error,
"cannot create text object "
"from PDF string: ");
pdf_text_destroy (element);
return NULL;
}
return element;
}
|
|
↓
|
pdf_time_to_string_iso8601
|
18
|
31
|
53
|
../src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_iso8601(const pdf_time_t *time_var,
pdf_error_t **error)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *) pdf_alloc (PDF_MAX_ISO8601_STR_LENGTH);
if (!str)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_ENOMEM,
"cannot create string with ISO8601 time: "
"couldn't allocate %lu bytes",
PDF_MAX_ISO8601_STR_LENGTH);
return NULL;
}
/* YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) */
pdf_time_get_local_cal (time_var, &calendar);
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 (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 (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);
}
return str;
}
|
|
↓
|
pdf_time_to_string_generalized_asn1
|
18
|
31
|
54
|
../src/base/pdf-time-string.c
|
pdf_char_t *
pdf_time_to_string_generalized_asn1(const pdf_time_t *time_var,
pdf_error_t **error)
{
pdf_char_t *str;
struct pdf_time_cal_s calendar;
str = (pdf_char_t *) pdf_alloc (PDF_MAX_GENASN1_STR_LENGTH);
if (!str)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_ENOMEM,
"cannot create string with Generalized ASN1 time: "
"couldn't allocate %lu bytes",
PDF_MAX_GENASN1_STR_LENGTH);
return NULL;
}
/* YYYYMMDDhhmmssTZD (eg 19970716192030+01:00) */
pdf_time_get_local_cal (time_var, &calendar);
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 (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 (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);
}
return str;
}
|
|
↓
|
write_string_token
|
17
|
55
|
133
|
../src/base/pdf-token-writer.c
|
static pdf_bool_t
write_string_token (pdf_token_writer_t *writer,
pdf_u32_t flags,
const pdf_token_t *token,
pdf_error_t **error)
{
const pdf_char_t *data;
pdf_size_t size;
data = pdf_token_get_string_data (token);
size = pdf_token_get_string_size (token);
switch (writer->state)
{
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->state++;
/* 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);
if (!start_token (writer,
PDF_FALSE /* need_wspace */,
dummy_len,
error))
return PDF_FALSE;
}
pdf_buffer_rewind (writer->buffer);
writer->buffered_line_length = writer->line_length;
write_buffered_char_nocheck (writer, '(');
writer->pos = 0;
writer->state++;
/* fall through */
case 2:
while (writer->pos < size)
{
if (!write_string_char (writer,
flags,
data,
size,
writer->pos,
error))
return PDF_FALSE;
writer->pos++;
}
writer->state++;
/* fall through */
case 3:
if (!write_buffered_char (writer, ')', error))
return PDF_FALSE;
writer->state++;
/* fall through */
case 4:
return flush_buffer (writer, error);
/*** hex strings ***/
hexstring_start:
writer->state = 101;
case 101:
{
pdf_size_t dummy_len = PDF_MIN (20, 2 + size * 2);
if (!start_token (writer,
PDF_FALSE /* need_wspace */,
dummy_len,
error))
return PDF_FALSE;
}
pdf_buffer_rewind (writer->buffer);
writer->buffered_line_length = writer->line_length;
write_buffered_char_nocheck (writer, '<');
writer->pos = 0;
writer->state++;
/* fall through */
case 102:
while (writer->pos < size)
{
pdf_char_t ch;
/* 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)
{
if (!write_buffered_char (writer, '\n', error))
return PDF_FALSE;
}
ch = data[writer->pos];
if (!reserve_buffer_space (writer, 2, error))
return PDF_FALSE;
write_buffered_char_nocheck (writer, HEXCHAR (ch / 16));
if (writer->pos != (size - 1) ||
(ch % 16) != 0)
write_buffered_char_nocheck (writer, HEXCHAR (ch % 16));
writer->pos++;
}
writer->state++;
/* fall through */
case 103:
if (!write_buffered_char (writer, '>', error))
return PDF_FALSE;
writer->state++;
/* fall through */
case 104:
return flush_buffer (writer, error);
default:
PDF_ASSERT_TRACE_NOT_REACHED ();
return PDF_FALSE;
}
}
|
|
↓
|
write_string_char
|
16
|
51
|
86
|
../src/base/pdf-token-writer.c
|
static pdf_bool_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,
pdf_error_t **error)
{
const pdf_char_t *output;
pdf_size_t outlen = 1;
pdf_char_t esc[4] = { '\\', 0, 0, 0 };
pdf_char_t ch;
pdf_bool_t quote_parens;
pdf_size_t i;
output = data + pos;
ch = data[pos];
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] = 'b'; break;
case 9: esc[1] = 't'; break;
case 10: esc[1] = 'n'; break;
case 12: esc[1] = 'f'; break;
case 13: esc[1] = 'r'; break;
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;
nextch = (pos + 1 < len) ? data[pos + 1] : 0;
if (nextch >= '0' && nextch <= '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)
{
if (!reserve_buffer_space (writer, 2, error))
return PDF_FALSE;
write_buffered_char_nocheck (writer, '\\');
write_buffered_char_nocheck (writer, '\n'); /* newline */
}
if (!reserve_buffer_space (writer, outlen, error))
return PDF_FALSE;
for (i = 0; i < outlen; ++i)
write_buffered_char_nocheck (writer, output[i]);
return PDF_TRUE;
}
|
|
↓
|
get_directory_and_filename
|
16
|
44
|
103
|
../src/base/pdf-fsys-disk.c
|
static pdf_bool_t
get_directory_and_filename (const pdf_fsys_t *fsys,
const pdf_text_t *path,
pdf_text_t **directory,
pdf_text_t **filename,
pdf_char_t **filename_utf8,
pdf_error_t **error)
{
pdf_size_t utf8_size;
pdf_char_t *utf8;
pdf_char_t *p;
pdf_size_t filename_size;
/* Canonicalize path and get output in UTF-8 */
if (!canonicalize_path (fsys, path, NULL, &utf8, error))
return PDF_FALSE;
/* Move pointer to last character in the path */
utf8_size = strlen (utf8);
p = &utf8[utf8_size - 1];
/* Skip possible separator at the end of the path */
if (IS_DIR_SEPARATOR (*p))
p--;
/* Find previous directory separator */
while (p >= utf8 &&
!IS_DIR_SEPARATOR (*p))
p--;
/* Directory separator found? */
if (p < utf8)
{
/* No parent */
pdf_dealloc (utf8);
return NULL;
}
/* Filename starts always after the dir separator */
filename_size = strlen (&p[1]);
/* Get filename if requested */
if (filename)
{
*filename = pdf_text_new_from_unicode (&p[1],
filename_size,
PDF_TEXT_UTF8,
error);
if (!*filename)
{
pdf_dealloc (utf8);
return PDF_FALSE;
}
}
/* Get filename in UTF-8 if requested */
if (filename_utf8)
{
*filename_utf8 = pdf_alloc (filename_size + 1);
if (!*filename_utf8)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ENOMEM,
"cannot get filename: "
"couldn't allocate %lu bytes",
(unsigned long)(filename_size + 1));
if (filename)
pdf_text_destroy (*filename);
return PDF_FALSE;
}
memcpy (*filename_utf8, &p[1], filename_size);
(*filename_utf8)[filename_size] = '\0';
}
if (directory)
{
/* Directory last (to be NUL-ed) depends on whether the directory is the root
* directory (we shouldn't remove the dir separator from the root directory)
*/
if (p == utf8)
p[1] = '\0';
else
p[0] = '\0';
*directory = pdf_text_new_from_unicode (utf8,
strlen (utf8),
PDF_TEXT_UTF8,
error);
if (!*directory)
{
if (filename)
pdf_text_destroy (*filename);
if (filename_utf8)
pdf_dealloc (*filename_utf8);
pdf_dealloc (utf8);
return PDF_FALSE;
}
}
pdf_dealloc (utf8);
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_wb_check_rules
|
16
|
2
|
20
|
../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);
}
|
|
↓
|
read_and_inflate
|
15
|
34
|
80
|
../src/base/pdf-stm-f-flate.c
|
static enum pdf_stm_filter_apply_status_e
read_and_inflate (struct pdf_stm_f_flate_s *st,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_error_t **error)
{
/* Fill the input CHUNK */
if (!st->writing)
{
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_STM_FILTER_APPLY_STATUS_NO_INPUT;
/* we inflate and write to out */
st->stream.avail_in = st->incnt;
st->stream.next_in = (Bytef *) st->inbuf;
do {
st->stream.avail_out = PDF_STM_F_FLATE_CHUNK;
st->stream.next_out = (Bytef *) 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)
{
set_error_from_zlib_ret (error, st->zret);
return PDF_STM_FILTER_APPLY_STATUS_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 = PDF_TRUE;
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
}
} while (st->stream.avail_out == 0);
if (st->zret == Z_STREAM_END)
return PDF_STM_FILTER_APPLY_STATUS_EOF;
/* the input CHUNK now is empty, if needed, ask for input */
st->writing = PDF_FALSE;
st->incnt = 0;
if (pdf_buffer_eob_p (in))
return PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
/* ask for the input we couldn't read */
return PDF_STM_FILTER_APPLY_STATUS_OK;
}
|
|
↓
|
pdf_fp_func_0_new
|
14
|
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_text_host_to_utf32he_iconv
|
14
|
55
|
166
|
../src/base/pdf-text-host-encoding.c
|
static pdf_bool_t
pdf_text_host_to_utf32he_iconv (const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_char_t *enc,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length,
pdf_error_t **error)
{
iconv_t from_host;
size_t n_conv;
pdf_char_t *in_str;
size_t n_in;
size_t n_out;
pdf_char_t *new_data;
pdf_char_t *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"),
enc);
if (from_host == (iconv_t)-1)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ETEXTENC,
"cannot convert from host encoding: "
"conversion from '%s' to UTF-32 not available",
enc);
return PDF_FALSE;
}
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from host encoding: "
"couldn't allocate %lu bytes",
(unsigned long)worst_length);
iconv_close (from_host);
return PDF_FALSE;
}
n_out = worst_length;
/* This cast is legit because
* iconv increments the pointer
* but does not change the
* pointed memory. */
in_str = (char *)input_data;
out_str = 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from host encoding: "
"couldn't allocate %lu bytes",
(unsigned long)worst_length);
iconv_close (from_host);
return PDF_FALSE;
}
/* 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 = &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_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert to host encoding: "
"invalid data to convert from host encoding, '%s'",
strerror (errno));
return PDF_FALSE;
}
}
}
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from host encoding: "
"couldn't rellocate '%lu' bytes",
(unsigned long)new_length);
return PDF_FALSE;
}
}
/* 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_TRUE;
}
|
|
↓
|
stm_f_aesv2_init
|
14
|
38
|
91
|
../src/base/pdf-stm-f-aesv2.c
|
static pdf_bool_t
stm_f_aesv2_init (const pdf_hash_t *params,
void **state,
pdf_error_t **error)
{
struct pdf_stm_f_aesv2_s *filter_state;
const pdf_char_t *key;
pdf_size_t keysize;
/* We demand all parameters are present */
if (!params ||
!pdf_hash_key_p (params, AESv2_PARAM_KEY) ||
!pdf_hash_key_p (params, AESv2_PARAM_KEY))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"cannot initialize AESv2 encoder/decoder: "
"parameters missing ('Key': %s, 'KeySize': %s)",
((params && pdf_hash_key_p (params, AESv2_PARAM_KEY)) ?
"available" : "missing"),
((params && pdf_hash_key_p (params, AESv2_PARAM_KEY_SIZE)) ?
"available" : "missing"));
return PDF_FALSE;
}
filter_state = pdf_alloc (sizeof (struct pdf_stm_f_aesv2_s));
if (!filter_state)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create AESv2 encoder/decoder internal state: "
"couldn't allocate %lu bytes",
(unsigned long)sizeof (struct pdf_stm_f_aesv2_s));
return PDF_FALSE;
}
/* Initialize cache buffers */
filter_state->in_cache = pdf_buffer_new (AESV2_CACHE_SIZE, error);
if (!(filter_state->in_cache))
{
stm_f_aesv2_deinit (filter_state);
return PDF_FALSE;
}
filter_state->out_cache = pdf_buffer_new (AESV2_CACHE_SIZE, error);
if (!(filter_state->out_cache))
{
stm_f_aesv2_deinit (filter_state);
return PDF_FALSE;
}
/* Note that Key may NOT be NUL-terminated */
key = pdf_hash_get_value (params, AESv2_PARAM_KEY);
keysize = pdf_hash_get_size (params, AESv2_PARAM_KEY_SIZE);
/* Keep a copy of the key in the filter */
filter_state->key = (pdf_char_t *)pdf_alloc (keysize);
if (!filter_state->key)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot copy AESv2 key: "
"couldn't allocate %lu bytes",
(unsigned long)keysize);
stm_f_aesv2_deinit (filter_state);
return PDF_FALSE;
}
filter_state->keysize = keysize;
memcpy (filter_state->key, key, keysize);
filter_state->cipher = pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALGO_AESV2, error);
if (!filter_state->cipher)
{
stm_f_aesv2_deinit (filter_state);
return PDF_FALSE;
}
if (!pdf_crypt_cipher_set_key (filter_state->cipher,
filter_state->key,
filter_state->keysize,
error))
{
stm_f_aesv2_deinit (filter_state);
return PDF_FALSE;
}
*state = filter_state;
return PDF_TRUE;
}
|
|
↓
|
stm_f_lzwenc_apply
|
14
|
36
|
83
|
../src/base/pdf-stm-f-lzw.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_lzwenc_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
struct lzwenc_state_s *st;
st = state;
st->buffer.buf = out;
if (!lzw_buffer_flush (&st->buffer))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
if (st->really_finish)
return PDF_STM_FILTER_APPLY_STATUS_EOF;
if (st->must_reset)
{
lzw_buffer_put_code (&st->buffer, LZW_RESET_CODE);
st->must_reset = 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->dict.size == st->buffer.maxval - st->early_change)
{
PDF_DEBUG_BASE ("[LZW encoder] Increasing bitsize... "
"(dictsize[%d] == maxval[%d] - earlychange[%d])",
st->dict.size,
st->buffer.maxval,
st->early_change);
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)
{
lzw_buffer_put_code (&st->buffer, st->string.prefix);
if (st->dict.size == st->buffer.maxval - st->early_change)
{
PDF_DEBUG_BASE ("[LZW encoder] Increasing bitsize (FINISHING)... "
"(dictsize[%d] == maxval[%d] - earlychange[%d])",
st->dict.size,
st->buffer.maxval,
st->early_change);
lzw_buffer_inc_bitsize (&st->buffer);
}
lzw_buffer_put_code (&st->buffer, LZW_EOD_CODE);
lzw_buffer_put_code (&st->buffer, 0); /* flush */
/* Delete 0 byte if buffer was already aligned before flush. */
if (out->data[out->wp - 1] == 0x0)
out->wp--;
st->really_finish = PDF_TRUE;
return (pdf_buffer_full_p (out) ?
PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT :
PDF_STM_FILTER_APPLY_STATUS_EOF);
}
if (pdf_buffer_full_p (out))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
/* Default, request more input */
return PDF_STM_FILTER_APPLY_STATUS_NO_INPUT;
}
|
|
↓
|
stm_f_a85dec_wr_quad
|
14
|
33
|
74
|
../src/base/pdf-stm-f-a85.c
|
static pdf_status_t
stm_f_a85dec_wr_quad (const pdf_char_t *quint,
const pdf_size_t outcount,
pdf_buffer_t *out,
struct pdf_stm_f_a85_s *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++)
{
if (!stm_f_a85_write_out (outbytes[i], out, filter_state))
return PDF_ERROR;
}
}
return retval;
}
|
|
↓
|
pdf_stm_filter_apply
|
14
|
33
|
98
|
../src/base/pdf-stm-filter.c
|
pdf_bool_t
pdf_stm_filter_apply (pdf_stm_filter_t *filter,
pdf_bool_t finish,
pdf_bool_t *eof,
pdf_error_t **error)
{
/* If the filter is in an error state, just communicate it to the caller */
if (filter->error)
{
/* The error is copied, the original is left untouched */
pdf_propagate_error_dup (error, filter->error);
return PDF_FALSE;
}
/* If the filter is in EOF state, just communicate it to the caller */
*eof = filter->eof;
if (filter->eof)
return PDF_TRUE;
while (!pdf_buffer_full_p (filter->out))
{
pdf_error_t *inner_error = NULL;
enum pdf_stm_filter_apply_status_e filter_status;
pdf_bool_t input_eof;
/* Generate output */
filter_status = filter->impl->apply_fn (filter->state,
filter->in,
filter->out,
filter->really_finish,
&(filter->error));
if (filter_status == PDF_STM_FILTER_APPLY_STATUS_ERROR)
{
/* The error is copied, the original is left untouched */
pdf_propagate_error_dup (error, filter->error);
return PDF_FALSE;
}
if (filter_status == PDF_STM_FILTER_APPLY_STATUS_EOF)
{
/* The filter is now in an EOF condition. We should not call
* this filter anymore without a previous reset */
*eof = filter->eof = PDF_TRUE;
return PDF_TRUE;
}
if (filter_status == PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT)
{
/* The filter needs to generate output and the output buffer
* is full */
break;
}
/* The filter needs more input, try to get the input buffer
* filled with some data */
input_eof = PDF_FALSE;
if (!pdf_stm_filter_get_input (filter,
finish,
&input_eof,
&inner_error))
{
/* Error getting input, propagate */
filter->error = inner_error;
pdf_propagate_error_dup (error, filter->error);
return PDF_FALSE;
}
/* EOF when getting input? */
if (input_eof)
{
if (!pdf_buffer_eob_p (filter->in))
{
/* We got EOF, but data is still available in the input,
* so go on */
continue;
}
if ((!filter->really_finish) &&
((filter->mode == PDF_STM_FILTER_MODE_WRITE &&
finish) ||
(filter->mode == PDF_STM_FILTER_MODE_READ)))
{
filter->really_finish = PDF_TRUE;
continue;
}
/* Propagate EOF error without storing it */
*eof = PDF_TRUE;
return PDF_TRUE;
}
/* Filter got more input, continue */
}
/* all done */
return PDF_TRUE;
}
|
|
↓
|
pdf_text_utf32he_to_utf32he
|
14
|
31
|
118
|
../src/base/pdf-text-encoding.c
|
pdf_bool_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_error_t **error)
{
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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADDATA,
"cannot convert from UTF-32HE to UTF-32HE: "
"invalid input data length: %lu",
(unsigned long)input_length);
return PDF_FALSE;
}
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert from UTF-32HE to UTF-32HE: "
"couldn't allocate %lu bytes",
(unsigned long)new_size);
return PDF_FALSE;
}
/* 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) &&
((utf32val.i > 0x10FFFF) ||
((utf32val.i >= 0xD800) &&
(utf32val.i <= 0xDFFF))))
{
/* Invalid UTF-32 code point received */
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert from UTF-32HE to UTF-32HE: "
"invalid input code point: "
"%.2X:%.2X:%.2X:%.2X",
utf32val.c[0],
utf32val.c[1],
utf32val.c[2],
utf32val.c[3]);
return PDF_FALSE;
}
/* 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) &&
((utf32val.i > 0x10FFFF) ||
((utf32val.i >= 0xD800) &&
(utf32val.i <= 0xDFFF))))
{
/* Invalid output UTF-32 code point */
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert from UTF-32HE to UTF-32HE: "
"invalid output code point: "
"%.2X:%.2X:%.2X:%.2X",
utf32val.c[0],
utf32val.c[1],
utf32val.c[2],
utf32val.c[3]);
return PDF_FALSE;
}
/* 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_TRUE;
}
|
|
↓
|
pdf_time_check_string_pdf
|
14
|
24
|
102
|
../src/base/pdf-time-string.c
|
static pdf_bool_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_error_t **error)
{
pdf_i32_t i;
/* Check minimum length D:YYYY */
if (time_str_length < 6)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, too short (%u): '%s'",
time_str_length,
time_str);
return PDF_FALSE;
}
/* Check prefix */
if (strncmp (time_str, "D:", 2) != 0)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, no prefix: '%s",
time_str);
return PDF_FALSE;
}
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, "
"invalid time zone identifier ('%c'): '%s",
time_str[16],
time_str);
return PDF_FALSE;
}
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, "
"invalid separator ('%c'): '%s",
time_str[19],
time_str);
return PDF_FALSE;
}
if (require_trailing_apostrophe)
{
if ((time_str_length < 23) ||
((time_str[22] != '\'')))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, "
"invalid separator ('%c'): '%s",
(time_str_length >= 21) ? time_str[22] : ' ',
time_str);
return PDF_FALSE;
}
}
else
{
if (time_str_length >= 23)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid PDF time string, invalid separator ('%c'): '%s",
time_str[19],
time_str);
return PDF_FALSE;
}
}
return PDF_TRUE;
}
|
|
↓
|
flush_token
|
13
|
63
|
184
|
../src/base/pdf-token-reader.c
|
static pdf_bool_t
flush_token (pdf_token_reader_t *reader,
pdf_u32_t flags,
pdf_bool_t *eof,
pdf_token_t **token,
pdf_error_t **error)
{
pdf_token_t *new_token;
pdf_char_t *data = (pdf_char_t *)reader->buffer->data;
int datasize = reader->buffer->wp;
switch (reader->state)
{
case PDF_TOKR_STATE_NONE:
/* no state to exit */
return PDF_TRUE;
case PDF_TOKR_STATE_EOF:
/* can't continue parsing after EOF */
*eof = PDF_TRUE;
return PDF_TRUE;
case PDF_TOKR_STATE_COMMENT:
{
if (reader->substate == 1 ||
!(flags & PDF_TOKEN_RET_COMMENTS))
{
/* don't return a token */
return reset_buffer (reader, error);
}
new_token = pdf_token_comment_new (data, datasize, error);
}
break;
case PDF_TOKR_STATE_KEYWORD:
{
int value;
int ntyp;
ntyp = recognise_number (reader->buffer, &value);
if (ntyp == 1)
{
new_token = pdf_token_integer_new (value, error);
}
else if (ntyp == 2)
{
double realvalue;
if (!parse_real (reader->buffer,
pdf_tokeniser_get_decimal_point (),
&realvalue,
error))
return PDF_FALSE;
new_token = pdf_token_real_new ((float)realvalue, error);
}
else
{
new_token = pdf_token_keyword_new (data, datasize, error);
}
}
break;
case PDF_TOKR_STATE_NAME:
{
if (reader->substate != 0) /* reading an escape sequence */
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot flush token: invalid state");
return PDF_FALSE;
}
new_token = pdf_token_name_new (data, datasize, error);
}
break;
case PDF_TOKR_STATE_STRING:
{
if (reader->intparam >= 0) /* didn't see the closing ')' */
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot flush token: "
"(string) no closing ')'");
return PDF_FALSE;
}
new_token = pdf_token_string_new (data, datasize, error);
}
break;
case PDF_TOKR_STATE_HEXSTRING:
{
if (reader->substate != 3) /* didn't see the closing '>' */
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot flush token: "
"(hexstring) no closing '>'");
return PDF_FALSE;
}
new_token = pdf_token_string_new (data, datasize, error);
}
break;
case PDF_TOKR_STATE_DICTEND:
{
if (reader->substate != 1) /* didn't see a second '>' */
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADFILE,
"cannot flush token: "
"(dictend) no second '>'");
return PDF_FALSE;
}
new_token = pdf_token_valueless_new (PDF_TOKEN_DICT_END, error);
}
break;
case PDF_TOKR_STATE_PENDING:
{
switch (reader->charparam)
{
case '<':
new_token = pdf_token_valueless_new (PDF_TOKEN_DICT_START, error);
break;
case '[':
new_token = pdf_token_valueless_new (PDF_TOKEN_ARRAY_START, error);
break;
case ']':
new_token = pdf_token_valueless_new (PDF_TOKEN_ARRAY_END, error);
break;
case '{':
new_token = pdf_token_valueless_new (PDF_TOKEN_PROC_START, error);
break;
case '}':
new_token = pdf_token_valueless_new (PDF_TOKEN_PROC_END, error);
break;
default:
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot flush token: "
"invalid char found '%c' (%d)",
reader->charparam,
reader->charparam);
return PDF_FALSE;
}
}
break;
default:
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot flush token: "
"invalid state (%d)",
reader->state);
return PDF_FALSE;
}
/* If no token generated, return already set error */
if (!new_token)
{
pdf_prefix_error (error, "cannot flush token: ");
return PDF_FALSE;
}
/* Set output new token */
*token = new_token;
/* Set the beginning position of this state */
reader->beg_pos = reader->state_pos;
return reset_buffer (reader, error);
}
|
|
↓
|
get_directory_and_filename
|
13
|
39
|
97
|
../src/base/pdf-fsys-http.c
|
static pdf_bool_t
get_directory_and_filename (const pdf_fsys_t *fsys,
const pdf_text_t *path,
pdf_text_t **directory,
pdf_text_t **filename,
pdf_error_t **error)
{
pdf_size_t utf8_size;
pdf_char_t *utf8;
pdf_char_t *p;
const pdf_char_t *start;
pdf_size_t filename_size;
/* Get in UTF-8 */
utf8 = pdf_text_get_unicode (path,
PDF_TEXT_UTF8,
PDF_TEXT_UNICODE_WITH_NUL_SUFFIX,
&utf8_size,
error);
if (!utf8)
return PDF_FALSE;
start = skip_scheme_from_url (utf8);
if (!start)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"invalid URL: '%s'",
utf8);
pdf_dealloc (utf8);
return PDF_FALSE;
}
/* Move pointer to last character in the path
* We move 2 positions because utf8_size here counts last NUL byte */
p = &utf8[utf8_size - 2];
/* Skip possible separator at the end of the path */
if (*p == '/')
p--;
/* Find previous directory separator */
while (p >= start && *p != '/')
p--;
/* Directory separator found? */
if (p < start)
{
/* No parent */
pdf_dealloc (utf8);
return NULL;
}
/* Filename starts always after the dir separator */
filename_size = strlen (&p[1]);
/* Get filename if requested */
if (filename)
{
*filename = pdf_text_new_from_unicode (&p[1],
filename_size,
PDF_TEXT_UTF8,
error);
if (!*filename)
{
pdf_dealloc (utf8);
return PDF_FALSE;
}
}
if (directory)
{
/* Directory last (to be NUL-ed) depends on whether the directory is the root
* directory (we shouldn't remove the dir separator from the root directory)
*/
if (p == start)
p[1] = '\0';
else
p[0] = '\0';
*directory = pdf_text_new_from_unicode (utf8,
strlen (utf8),
PDF_TEXT_UTF8,
error);
if (!*directory)
{
if (filename)
pdf_text_destroy (*filename);
pdf_dealloc (utf8);
return PDF_FALSE;
}
}
pdf_dealloc (utf8);
return PDF_TRUE;
}
|
|
↓
|
request_http_head
|
13
|
32
|
111
|
../src/base/pdf-fsys-http.c
|
static pdf_bool_t
request_http_head (const pdf_char_t *url,
double *content_length,
pdf_error_t **error)
{
CURL *curl;
CURLcode res;
long http_res;
double inner_content_length;
pdf_bool_t accept_ranges = PDF_FALSE;
curl = curl_easy_init ();
/* Setup request options */
if ((res = curl_easy_setopt (curl,
CURLOPT_URL,
url)) != CURLE_OK ||
/* Set that no-body is requested (HTTP-HEADER only) */
(res = curl_easy_setopt (curl,
CURLOPT_NOBODY,
1L)) != CURLE_OK ||
/* Try to follow location and therefore avoid 302 errors */
(res = curl_easy_setopt (curl,
CURLOPT_FOLLOWLOCATION,
1L)) != CURLE_OK ||
/* Setup a header parsing function */
(res = curl_easy_setopt (curl,
CURLOPT_HEADERFUNCTION,
request_http_head_header_parse)) != CURLE_OK ||
/* Setup context data for the header parsing function */
(res = curl_easy_setopt (curl,
CURLOPT_HEADERDATA,
&accept_ranges)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't set request options: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Perform request, BLOCKING */
if ((res = curl_easy_perform (curl)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't perform request: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Get response code */
if ((res = curl_easy_getinfo (curl,
CURLINFO_RESPONSE_CODE,
&http_res)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't get request response code: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* If response code is NOT 200 OK, set an error here */
if (http_res != 200)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"error in HTTP request: %ld",
http_res);
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* We do not support files reported as not allowing Ranges */
if (!accept_ranges)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_EIMPLLIMIT,
"Accept-Ranges not supported by remote server");
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Get Content-Length. It is ok if we don't get one */
if (content_length)
{
if (curl_easy_getinfo (curl,
CURLINFO_CONTENT_LENGTH_DOWNLOAD,
&inner_content_length) == CURLE_OK &&
inner_content_length >= 0)
{
*content_length = inner_content_length;
}
else
{
*content_length = (double)-1;
}
}
curl_easy_cleanup (curl);
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_wb_get_property
|
13
|
25
|
29
|
../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;
if (pdf_text_ucd_wb_is_midletter (character))
return PDF_TEXT_UCD_WBP_MidLetter;
if (pdf_text_ucd_wb_is_numeric (character))
return PDF_TEXT_UCD_WBP_Numeric;
if (pdf_text_ucd_wb_is_midnum (character))
return PDF_TEXT_UCD_WBP_MidNum;
if (pdf_text_ucd_wb_is_midnumlet (character))
return PDF_TEXT_UCD_WBP_MidNumLet;
if (pdf_text_ucd_wb_is_format (character))
return PDF_TEXT_UCD_WBP_Format;
if (pdf_text_ucd_wb_is_cr (character))
return PDF_TEXT_UCD_WBP_CR;
if (pdf_text_ucd_wb_is_lf (character))
return PDF_TEXT_UCD_WBP_LF;
if (pdf_text_ucd_wb_is_newline (character))
return PDF_TEXT_UCD_WBP_Newline;
if (pdf_text_ucd_wb_is_extend (character))
return PDF_TEXT_UCD_WBP_Extend;
if (pdf_text_ucd_wb_is_katakana (character))
return PDF_TEXT_UCD_WBP_Katakana;
if (pdf_text_ucd_wb_is_extendnumlet (character))
return PDF_TEXT_UCD_WBP_ExtendNumLet;
return PDF_TEXT_UCD_WBP_None;
}
|
|
↓
|
pdf_text_utf8_point_to_utf32he_point
|
12
|
21
|
59
|
../src/base/pdf-text-encoding.c
|
static pdf_size_t
pdf_text_utf8_point_to_utf32he_point (const pdf_uchar_t utf8val[4],
const pdf_size_t n_bytes,
pdf_text_utf32_char_t *p_utf32val,
pdf_error_t **error)
{
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 < n_bytes; c++)
{
if (((c == 0) && ((utf8val[0] == 0xFF) || (utf8val[0] == 0xFE))) ||
((c != 0) && ((utf8val[c] < 0x80) || (utf8val[c] > 0xBF))))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert from UTF-8 to UTF-32HE: "
"invalid input code point: "
"%.2X:%.2X:%.2X:%.2X",
(pdf_uchar_t)utf8val[0],
((n_bytes>1)?((pdf_uchar_t)utf8val[1]):0),
((n_bytes>2)?((pdf_uchar_t)utf8val[2]):0),
((n_bytes>3)?((pdf_uchar_t)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! */
PDF_ASSERT_TRACE_NOT_REACHED ();
return 0;
}
return n_bytes;
}
|
|
↓
|
pdf_text_ucd_special_case
|
12
|
32
|
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)
{
pdf_i32_t index_in_sc_array;
/* 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;
}
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 (condition_list) > 0) &&
(pdf_text_ucd_special_case_conditions (context, condition_list))) ||
(strlen (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
|
12
|
35
|
82
|
../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
|
12
|
32
|
78
|
../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_filter_change_case
|
12
|
61
|
132
|
../src/base/pdf-text-filter.c
|
static pdf_bool_t
pdf_text_filter_change_case (pdf_text_t *text,
enum unicode_case_type new_case,
pdf_error_t **error)
{
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, error))
return PDF_FALSE;
/* 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 (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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot change case of text: "
"couldn't allocate %lu bytes",
(unsigned long)worst_length);
return PDF_FALSE;
}
/* Create new empty word boundaries list */
new_wb_list = pdf_text_create_word_boundaries_list (error);
if (new_wb_list == NULL)
{
pdf_dealloc (new_data);
return PDF_FALSE;
}
/* 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;
const struct pdf_text_wb_s *p_word;
pdf_size_t new_word_length = 0;
/* Allocate new word */
p_new_word = (struct pdf_text_wb_s *) pdf_alloc (sizeof (struct pdf_text_wb_s));
if (!p_new_word)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot change case of text: "
"couldn't allocate %lu bytes",
(unsigned long)sizeof (struct pdf_text_wb_s));
return PDF_FALSE;
}
/* Get word to process from list of words */
p_word = pdf_list_get_at (text->word_boundaries, i, error);
if (!p_word)
{
pdf_dealloc (new_data);
pdf_list_destroy (new_wb_list);
return PDF_FALSE;
}
/* Apply the case algorithm to the full word */
if (!pdf_text_ucd_word_change_case (&new_data[new_length],
&new_word_length,
new_case,
p_word->word_start,
p_word->word_size,
language,
error))
{
pdf_list_destroy (new_wb_list);
pdf_dealloc (new_data);
pdf_dealloc (p_new_word);
return PDF_FALSE;
}
/* 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 */
if (!pdf_list_add_last (new_wb_list, p_new_word, error))
return PDF_FALSE;
/* 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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot change case of text: "
"couldn't allocate %lu bytes",
(unsigned long)new_length);
pdf_text_destroy_word_boundaries_list (&new_wb_list);
return PDF_FALSE;
}
}
/* 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_TRUE;
}
|
|
↓
|
pdf_stm_flush
|
12
|
40
|
88
|
../src/base/pdf-stm.c
|
pdf_bool_t
pdf_stm_flush (pdf_stm_t *stm,
pdf_bool_t finish,
pdf_size_t *flushed_bytes,
pdf_error_t **error)
{
pdf_stm_filter_t *tail_filter;
pdf_buffer_t *tail_buffer;
pdf_error_t *inner_error = NULL;
pdf_bool_t eof = PDF_FALSE;
/* NOTE: NULL flushed_bytes is ALLOWED */
PDF_ASSERT_POINTER_RETURN_VAL (stm, -1);
/* Is this a write stream? */
if (stm->mode != PDF_STM_WRITE)
{
/* Invalid operation */
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EINVOP,
"cannot write in a read stream");
return PDF_FALSE;
}
/* Apply the head filter until the filter chain gets empty */
tail_filter = pdf_stm_filter_get_tail (stm->filter);
tail_buffer = pdf_stm_filter_get_in (tail_filter);
if (flushed_bytes)
*flushed_bytes = 0;
while (PDF_TRUE)
{
pdf_size_t cache_size;
pdf_ssize_t written_bytes;
pdf_size_t tail_size;
tail_size = tail_buffer->wp - tail_buffer->rp;
/* Break only on error */
if (!pdf_stm_filter_apply (stm->filter, finish, &eof, &inner_error))
break;
/* Update the number of flushed bytes */
if (flushed_bytes)
*flushed_bytes += tail_size - (tail_buffer->wp - tail_buffer->rp);
/* Avoid false EEOF error */
if (eof && pdf_buffer_eob_p (stm->cache))
{
eof = PDF_FALSE;
pdf_buffer_rewind (tail_buffer);
break;
}
/* Write the data from the buffer cache into the backend */
cache_size = stm->cache->wp - stm->cache->rp;
written_bytes = pdf_stm_be_write (stm->backend,
stm->cache->data + stm->cache->rp,
cache_size,
&inner_error);
if (written_bytes < 0)
break;
if (written_bytes != cache_size)
{
/* EOF, could not write all the contents of the cache buffer into
* the backend */
stm->cache->rp += written_bytes;
eof = PDF_TRUE;
break;
}
/* Rewind the cache */
pdf_buffer_rewind (stm->cache);
}
/* Propagate error */
if (inner_error)
{
pdf_propagate_error (error, inner_error);
return PDF_FALSE;
}
return (eof ? PDF_FALSE : PDF_TRUE);;
}
|
|
↓
|
stm_f_v2_init
|
12
|
31
|
79
|
../src/base/pdf-stm-f-v2.c
|
static pdf_bool_t
stm_f_v2_init (const pdf_hash_t *params,
void **state,
pdf_error_t **error)
{
struct pdf_stm_f_v2_s *filter_state;
const pdf_char_t *key;
pdf_size_t keysize;
/* We demand all parameters are present */
if (!params ||
!pdf_hash_key_p (params, V2_PARAM_KEY) ||
!pdf_hash_key_p (params, V2_PARAM_KEY_SIZE))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_EBADDATA,
"cannot initialize V2 encoder/decoder: "
"parameters missing ('Key': %s, 'KeySize': %s)",
((params && pdf_hash_key_p (params, V2_PARAM_KEY)) ?
"available" : "missing"),
((params && pdf_hash_key_p (params, V2_PARAM_KEY_SIZE)) ?
"available" : "missing"));
return PDF_FALSE;
}
filter_state = pdf_alloc (sizeof (struct pdf_stm_f_v2_s));
if (!filter_state)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot create V2 encoder/decoder internal state: "
"couldn't allocate %lu bytes",
(unsigned long)sizeof (struct pdf_stm_f_v2_s));
return PDF_FALSE;
}
filter_state->cipher = NULL;
/* Note that Key may NOT be NUL-terminated */
key = pdf_hash_get_value (params, V2_PARAM_KEY);
keysize = pdf_hash_get_size (params, V2_PARAM_KEY_SIZE);
/* Keep a copy of the key in the filter */
filter_state->key = (pdf_char_t *)pdf_alloc (keysize);
if (!filter_state->key)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_STM,
PDF_ENOMEM,
"cannot copy V2 key: "
"couldn't allocate %lu bytes",
(unsigned long)keysize);
stm_f_v2_deinit (filter_state);
return PDF_FALSE;
}
filter_state->keysize = keysize;
memcpy (filter_state->key, key, keysize);
filter_state->cipher = pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALGO_V2, error);
if (!filter_state->cipher)
{
stm_f_v2_deinit (filter_state);
return PDF_FALSE;
}
if (!pdf_crypt_cipher_set_key (filter_state->cipher,
filter_state->key,
filter_state->keysize,
error))
{
stm_f_v2_deinit (filter_state);
return PDF_FALSE;
}
*state = filter_state;
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_Before_Dot
|
12
|
29
|
68
|
../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
|
78
|
../src/base/pdf-time-string.c
|
static pdf_bool_t
pdf_time_check_string_utc_asn1 (const pdf_char_t *time_str,
const pdf_size_t time_str_length,
pdf_error_t **error)
{
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_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid UTC-ASN1 time string, invalid length (%u): '%s'",
time_str_length,
time_str);
return PDF_FALSE;
}
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid UTC-ASN1 time string, expected UTC string "
"but no Zulu timezone identifier found: '%s'",
time_str);
return PDF_FALSE;
}
if ((with_gmt_offset) &&
((time_str[time_str_length - 5] != '+') &&
(time_str[time_str_length - 5] != '-')))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"invalid UTC-ASN1 time string, expected non-UTC string "
"but no GMT offset found: '%s'",
time_str);
return PDF_FALSE;
}
/* 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_TRUE;
}
|
|
↓
|
stm_f_lzwdec_apply
|
11
|
40
|
112
|
../src/base/pdf-stm-f-lzw.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_lzwdec_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
struct lzwdec_state_s *st;
st = state;
st->buffer.buf = in;
switch (st->state_pos)
{
case LZWDEC_STATE_START:
break;
case LZWDEC_STATE_CLEAN:
goto lzwdec_state_clean;
case LZWDEC_STATE_WRITE:
goto lzwdec_state_write;
case LZWDEC_STATE_READ:
goto lzwdec_state_read;
case LZWDEC_STATE_LOOP_WRITE:
goto lzwdec_state_loop_write;
case LZWDEC_STATE_LOOP_READ:
goto lzwdec_state_loop_read;
default:
break;
}
do
{
/* need a reset */
lzw_buffer_set_bitsize (&st->buffer, LZW_MIN_BITSIZE);
lzw_dict_reset (&st->dict);
do
{
lzwdec_state_clean:
LZWDEC_CHECK (st,
LZWDEC_STATE_CLEAN,
lzw_buffer_get_code (&st->buffer,
finish,
&st->new_code));
}
while (st->new_code == LZW_RESET_CODE);
if (st->new_code != LZW_EOD_CODE)
{
lzwdec_state_write:
st->state_pos = LZWDEC_STATE_WRITE;
if (!lzwdec_put_code (st, out, st->new_code))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT; /* No more output */
st->old_code = st->new_code;
lzwdec_state_read:
LZWDEC_CHECK (st,
LZWDEC_STATE_READ,
lzw_buffer_get_code (&st->buffer,
finish,
&st->new_code));
}
while (st->new_code != LZW_EOD_CODE &&
st->new_code != LZW_RESET_CODE)
{
st->decoded = st->dec_buf + (LZW_MAX_DICTSIZE - 2);
/* Is new code in the dict? */
if (st->new_code < st->dict.size)
{
lzw_dict_decode (&st->dict, st->new_code,
&st->decoded, &st->dec_size);
lzw_dict_fast_add (&st->dict, st->old_code, st->decoded[0]);
}
else
{
lzw_dict_decode (&st->dict, st->old_code,
&st->decoded, &st->dec_size);
lzw_dict_fast_add (&st->dict, st->old_code, st->decoded[0]);
st->decoded [st->dec_size++] = st->decoded [0];
}
/* output the decoded string */
lzwdec_state_loop_write:
st->state_pos = LZWDEC_STATE_LOOP_WRITE;
if (!lzwdec_put_decoded (st, out))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT; /* No more output */
if (st->dict.size == st->buffer.maxval - 1 - st->early_change)
{
lzw_buffer_inc_bitsize (&st->buffer);
/* break; We must wait for the reset code, don't reset yet. */
}
/* get next code */
st->old_code = st->new_code;
lzwdec_state_loop_read:
LZWDEC_CHECK (st,
LZWDEC_STATE_LOOP_READ,
lzw_buffer_get_code (&st->buffer,
finish,
&st->new_code));
}
}
while (st->new_code != LZW_EOD_CODE);
st->state_pos = LZWDEC_STATE_START;
return PDF_STM_FILTER_APPLY_STATUS_EOF;
}
|
|
↓
|
write_name_token
|
11
|
42
|
101
|
../src/base/pdf-token-writer.c
|
static pdf_bool_t
write_name_token (pdf_token_writer_t *writer,
pdf_u32_t flags,
const pdf_token_t *token,
pdf_error_t **error)
{
pdf_size_t size;
const pdf_char_t *data;
data = pdf_token_get_name_data (token);
size = pdf_token_get_name_size (token);
switch (writer->state)
{
case 0:
{
pdf_size_t i;
/* Validate the name; also calculate the encoded size
* and store it in ->pos temporarily. */
writer->pos = 1 + size;
for (i = 0; i < size; ++i)
{
pdf_bool_t escape;
if (!should_escape_namechar (flags, data[i], &escape))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADDATA,
"cannot write name token: "
"bad name");
return PDF_FALSE;
}
if (escape)
writer->pos += 2; /* 2 hex characters */
}
pdf_buffer_rewind (writer->buffer);
write_buffered_char_nocheck (writer, '/');
}
writer->state++;
/* fall through */
case 1:
if (!start_token (writer,
PDF_FALSE, /* need_wspace */
writer->pos, /* encoded token length */
error))
return PDF_FALSE;
writer->pos = 0;
writer->state++;
/* fall through */
case 2:
while (writer->pos < size)
{
pdf_bool_t escape;
pdf_char_t ch;
ch = data[writer->pos];
if (!should_escape_namechar (flags, ch, &escape))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_EBADDATA,
"cannot write name token: "
"bad name");
return PDF_FALSE;
}
if (escape)
{
if (!reserve_buffer_space (writer, 3, error))
return PDF_FALSE;
write_buffered_char_nocheck (writer, '#');
write_buffered_char_nocheck (writer, HEXCHAR (ch / 16));
write_buffered_char_nocheck (writer, HEXCHAR (ch % 16));
}
else
{
if (!write_buffered_char (writer, ch, error))
return PDF_FALSE;
}
writer->pos++;
}
writer->state++;
/* fall through */
case 3:
return flush_buffer (writer, error);
default:
PDF_ASSERT_TRACE_NOT_REACHED ();
return PDF_FALSE;
}
}
|
|
↓
|
should_escape_strchar
|
11
|
8
|
22
|
../src/base/pdf-token-writer.c
|
static 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 == '\\' || ch == '\r')
return PDF_TRUE;
if (ch == '(' || ch == ')')
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 (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_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 (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
|
42
|
123
|
../src/base/pdf-text-host-encoding.c
|
static pdf_bool_t
pdf_text_utf32he_to_host_win32 (const pdf_char_t *input_data,
const pdf_size_t input_length,
const pdf_char_t *enc,
pdf_char_t **p_output_data,
pdf_size_t *p_output_length,
pdf_error_t **error)
{
pdf_char_t *temp_data;
pdf_size_t temp_size;
UINT CodePage;
DWORD dwFlags;
int output_nmbyte;
BOOL default_used = 0;
/* Firstly, convert from UTF-32HE to UTF-16LE */
if (!pdf_text_utf32he_to_utf16le (input_data,
input_length,
&temp_data,
&temp_size,
error))
return PDF_FALSE;
/* So check windows host encoding */
if (!pdf_text_convert_encoding_name_to_CP (enc,
&CodePage,
error))
{
pdf_dealloc (temp_data);
return PDF_FALSE;
}
/* 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)
{
switch (GetLastError ())
{
case ERROR_INVALID_FLAGS:
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert to host encoding: invalid flags");
break;
default:
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_EBADTEXT,
"cannot convert to host encoding: invalid data");
break;
}
pdf_dealloc (temp_data);
return PDF_FALSE;
}
/* 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_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ENOMEM,
"cannot convert to host encoding: "
"couldn't allocate %lu bytes",
(unsigned long)*p_output_length);
pdf_dealloc (temp_data);
return PDF_FALSE;
}
/* 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 */
*p_output_data, /* lpMultiByteStr */
*p_output_length, /* ccMultiByte */
NULL, /* lpDefaultChar */
&default_used) != output_nmbyte) || \
(default_used))
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TEXT,
PDF_ETEXTENC,
"cannot convert to host encoding: "
"wide char to multibyte conversion failed");
pdf_dealloc (*p_output_data);
pdf_dealloc (temp_data);
return PDF_FALSE;
}
/* 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)
{
*p_output_data = temp;
*p_output_length = *p_output_length - 1;
}
}
pdf_dealloc (temp_data);
return PDF_TRUE;
}
|
|
↓
|
stm_f_ahexenc_apply
|
11
|
41
|
96
|
../src/base/pdf-stm-f-ahex.c
|
static enum pdf_stm_filter_apply_status_e
stm_f_ahexenc_apply (void *state,
pdf_buffer_t *in,
pdf_buffer_t *out,
pdf_bool_t finish,
pdf_error_t **error)
{
struct pdf_stm_f_ahex_s *filter_state;
pdf_uchar_t first_nibble;
pdf_uchar_t second_nibble;
pdf_uchar_t in_char;
if (finish)
{
if (pdf_buffer_full_p (out))
return PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT;
out->data[out->wp++] = '>';
return PDF_STM_FILTER_APPLY_STATUS_EOF;
}
filter_state = (struct pdf_stm_f_ahex_s *) state;
while (!pdf_buffer_full_p (out))
{
if ((filter_state->written_bytes != 0) &&
(filter_state->written_bytes % PDF_STM_F_AHEX_LINE_WIDTH) == 0)
{
/* Write down a newline character */
out->data[out->wp] = '\n';
out->wp++;
filter_state->written_bytes = 0;
continue;
}
/* Write down any pending nibble, if needed, without consuming
any input byte */
if (filter_state->last_nibble != -1)
{
out->data[out->wp] = filter_state->last_nibble;
out->wp++;
filter_state->written_bytes++;
filter_state->last_nibble = -1;
continue;
}
/* Try to consume an input byte */
if (!pdf_buffer_eob_p (in))
{
/* For each byte in the input we should generate two bytes in the
output. */
in_char = in->data[in->rp];
/* Determine the hex digits to write for this input character */
if (filter_state->last_nibble != -1)
{
first_nibble = (pdf_uchar_t) filter_state->last_nibble;
second_nibble = pdf_stm_f_ahex_int2hex (in_char >> 4);
}
else
{
first_nibble = pdf_stm_f_ahex_int2hex (in_char >> 4);
second_nibble = pdf_stm_f_ahex_int2hex (in_char);
}
in->rp++;
/* Write the hex digits into the output buffer, if
possible */
/* First nibble */
out->data[out->wp] = first_nibble;
out->wp++;
filter_state->written_bytes++;
/* Maybe write the second nibble */
if (pdf_buffer_full_p (out))
{
filter_state->last_nibble = second_nibble;
}
else
{
out->data[out->wp] = second_nibble;
out->wp++;
filter_state->written_bytes++;
}
}
else
{
/* We need more input */
break;
}
}
return (pdf_buffer_full_p (out) ?
PDF_STM_FILTER_APPLY_STATUS_NO_OUTPUT :
PDF_STM_FILTER_APPLY_STATUS_NO_INPUT);
}
|
|
↓
|
parse_real
|
11
|
40
|
95
|
../src/base/pdf-token-reader.c
|
static pdf_bool_t
parse_real (pdf_buffer_t *buffer,
const pdf_char_t *locale_dec_pt,
double *value,
pdf_error_t **error)
{
pdf_size_t tmplen;
pdf_size_t wpos;
pdf_size_t ptlen;
pdf_char_t *tmp;
pdf_char_t *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)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ENOMEM,
"cannot parse real: "
"couldn't allocate '%lu' bytes",
(unsigned long)(tmplen + 1));
return PDF_FALSE;
}
wpos = 0;
for (buffer->rp = 0; buffer->rp < buffer->wp; ++buffer->rp)
{
pdf_char_t ch;
ch = buffer->data[buffer->rp];
if (wpos >= tmplen)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot parse real: "
"out of bounds, pos(%lf) >= len(%lf)",
wpos, tmplen);
pdf_dealloc (tmp);
return PDF_FALSE;
}
if (ch == '.')
{
if (wpos + ptlen > tmplen)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot parse real: "
"out of bounds, pos(%lf) + ptlen(%lf) > len(%lf)",
wpos, ptlen, tmplen);
pdf_dealloc (tmp);
return PDF_FALSE;
}
memcpy (tmp + wpos, locale_dec_pt, ptlen);
wpos += ptlen;
}
else if (ch == '+' ||
ch == '-' ||
(ch >= '0' && ch <= '9'))
{
tmp[wpos++] = ch;
}
else
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TOKENISER,
PDF_ERROR,
"cannot parse real: "
"unexpected value: %c (%d)",
ch, ch);
pdf_dealloc (tmp);
return PDF_FALSE;
}
}
/* 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)
{
pdf_dealloc (tmp);
return PDF_TRUE;
}
pdf_dealloc (tmp);
return PDF_FALSE;
}
|
|
↓
|
pdf_time_from_string_pdf
|
11
|
40
|
115
|
../src/base/pdf-time-string.c
|
pdf_bool_t
pdf_time_from_string_pdf (pdf_time_t *time_var,
const pdf_char_t *time_str,
pdf_bool_t require_trailing_apostrophe,
pdf_error_t **error)
{
/*
* 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 = { 0 };
pdf_size_t time_str_length;
time_str_length = strlen (time_str);
if (!pdf_time_check_string_pdf (time_str,
time_str_length,
require_trailing_apostrophe,
error))
{
pdf_prefix_error (error,
"couldn't get time from PDF date string: ");
return PDF_FALSE;
}
while (PDF_TRUE)
{
/* 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 !*/
pdf_time_set_from_cal (time_var, &calendar);
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_wb_detect_next
|
11
|
37
|
109
|
../src/base/pdf-text-ucd-wordbreak.c
|
pdf_bool_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_FALSE;
/* 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_TRUE;
}
/* Initialize buffer with first 3 unicode points, stored in [1],[2],[3] */
for (i = 0; i < PDF_TEXT_UCD_MWBCP; ++i)
{
if ((i > 0) &&
(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 < PDF_TEXT_UCD_MWBCP; ++i)
{
buffer[i-1] = buffer[i];
}
/* Insert new buffer element in position [3], if available */
if (n_bytes >= 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_TRUE;
}
|
|
↓
|
pdf_time_from_string_iso8601
|
11
|
36
|
118
|
../src/base/pdf-time-string.c
|
pdf_bool_t
pdf_time_from_string_iso8601 (pdf_time_t *time_var,
const pdf_char_t *time_str,
pdf_error_t **error)
{
/*
* 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 = { 0 };
pdf_size_t time_str_length;
time_str_length = strlen (time_str);
/* Check minimum length */
if (time_str_length < 4)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_TIME,
PDF_EBADDATA,
"couldn't get time from ISO-8601 date string: "
"invalid date string, too short (%u): '%s'",
time_str_length,
time_str);
return PDF_FALSE;
}
while (PDF_TRUE)
{
/* 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 !*/
pdf_time_set_from_cal (time_var, &calendar);
return PDF_TRUE;
}
|
|
↓
|
request_http_partial_get
|
11
|
31
|
117
|
../src/base/pdf-fsys-http.c
|
static pdf_bool_t
request_http_partial_get (const pdf_char_t *url,
pdf_char_t *buffer,
pdf_size_t offset,
pdf_size_t bytes,
pdf_size_t *read_bytes,
pdf_error_t **error)
{
CURL *curl;
CURLcode res;
long http_res;
pdf_char_t range [128] = { 0 };
struct partial_get_context_s context;
/* Setup context */
context.buffer = buffer;
context.available_size = bytes;
context.index = 0;
curl = curl_easy_init ();
/* Compute range string */
sprintf (range,
"%lu-%lu",
(unsigned long)offset,
(unsigned long) (offset + bytes - 1));
/* Setup request options */
if ((res = curl_easy_setopt (curl,
CURLOPT_URL,
url)) != CURLE_OK ||
/* Try to follow location and therefore avoid 302 errors */
(res = curl_easy_setopt (curl,
CURLOPT_FOLLOWLOCATION,
1L)) != CURLE_OK ||
/* Set range of bytes to download */
(res = curl_easy_setopt (curl,
CURLOPT_RANGE,
range)) != CURLE_OK ||
/* Setup a content parsing function */
(res = curl_easy_setopt (curl,
CURLOPT_WRITEFUNCTION,
request_http_partial_get_body_parse)) != CURLE_OK ||
/* Setup context data for the context parsing function */
(res = curl_easy_setopt (curl,
CURLOPT_WRITEDATA,
&context)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't set request options: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Perform request, BLOCKING */
if ((res = curl_easy_perform (curl)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't perform request: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Get response code */
if ((res = curl_easy_getinfo (curl,
CURLINFO_RESPONSE_CODE,
&http_res)) != CURLE_OK)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"couldn't get request response code: '%s'",
curl_easy_strerror (res));
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Several responses should be treated as no-errors:
* - 200 OK
* - 206 Partial Content
*/
if (http_res != 200 &&
http_res != 206)
{
/* Treat 416 Requested Range Not Satisfiable in a special way */
if (http_res == 416)
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_EINVRANGE,
"invalid range requested: %ld",
http_res);
}
else
{
pdf_set_error (error,
PDF_EDOMAIN_BASE_FSYS,
PDF_ERROR,
"error in HTTP request: %ld",
http_res);
}
curl_easy_cleanup (curl);
return PDF_FALSE;
}
/* Set number of read bytes */
*read_bytes = context.index;
curl_easy_cleanup (curl);
return PDF_TRUE;
}
|
|
↓
|
pdf_text_ucd_special_case_conditions
|
11
|
29
|
71
|
../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 (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 (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))
{
/* Invalid condition!!! */
PDF_DEBUG_BASE ("Invalid condition in Special Case check: '%s'",
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
|
64
|
../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);
}
|
|
↓
|
stm_f_a85enc_wr_tuple
|
11
|
29
|
66
|
../src/base/pdf-stm-f-a85.c
|
static pdf_status_t
stm_f_a85enc_wr_tuple (pdf_u32_t tuple,
pdf_u8_t tuple_bytes, /* always 4 for a full tuple */
void *state,
pdf_buffer_t *out)
{
struct pdf_stm_f_a85_s *filter_state;
pdf_char_t buf[5];
int i;
filter_state = (struct pdf_stm_f_a85_s *) state;
/* partial tuple doesn't get z handling */
if (tuple == 0 &&
tuple_bytes == 4)
{
/* Four 0s in row */
/*
* PDF_FALSE from pdf_stm_f_a85_write_out means full buffer
* This should never happen because buffer should have been
* flushed before starting this set of output data. All
* subsequent calls to _write_out will fail with PDF_FALSE
* also, so it is reasonable to ignore the pass or fail
* status of these invocations within this function. The
* error will be reported back to the caller of this function.
*/
if (!stm_f_a85_write_out ('z', out, filter_state))
return PDF_ERROR;
filter_state->line_length++;
if (filter_state->line_length >= A85_ENC_LINE_LENGTH)
{
if (!stm_f_a85_write_out ('\n', out, filter_state))
return PDF_ERROR;
filter_state->line_length = 0;
}
return PDF_OK;
}
/* Encode this tuple in base-85 */
for (i = 0; i < 5; i++)
{
buf[i] = (pdf_char_t) (tuple % 85);
tuple = tuple / 85;
}
for (i = tuple_bytes; i >= 0; i--)
{
if (!stm_f_a85_write_out (buf[i] + (pdf_char_t) '!',
out, filter_state))
return PDF_ERROR;
filter_state->line_length++;
if (filter_state->line_length >= A85_ENC_LINE_LENGTH)
{
if (!stm_f_a85_write_out ('\n', out, filter_state))
return PDF_ERROR;
filter_state->line_length = 0;
}
}
return PDF_OK;
}
|
|
↓
|
pdf_token_reader_read
|
11
|
28
|
69
|
../src/base/pdf-token-reader.c
|
pdf_token_t *
pdf_token_reader_read (pdf_token_reader_t *reader,
pdf_u32_t flags,
pdf_error_t **error)
{
pdf_token_t *new_token = NULL;
pdf_bool_t eof;
pdf_uchar_t ch;
PDF_ASSERT_POINTER_RETURN_VAL (reader, NULL);
PDF_ASSERT_POINTER_RETURN_VAL (reader->stream, NULL);
while (pdf_stm_peek_char (reader->stream, &ch, error))
{
pdf_bool_t again = PDF_FALSE;
eof = PDF_FALSE;
if (!handle_char (reader,
flags,
(pdf_char_t)ch,
&again,
&eof,
&new_token,
error))
return NULL;
/* On EOF, return NULL without error */
if (eof)
return NULL;
if (!again)
{
/* The character we peeked at was accepted, so get rid of it. */
if (!pdf_stm_read_char (reader->stream, &ch, error))
{
if (new_token)
pdf_token_destroy (new_token);
return PDF_FALSE;
}
}
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. */
return new_token;
}
/* Keep on loop. Note that if again == TRUE,
* we peek again the same char */
}
eof = PDF_FALSE;
if (!exit_state (reader, flags, &eof, &new_token, error))
return NULL;
/* On EOF, return NULL without error */
if (eof)
return NULL;
reader->state = PDF_TOKR_STATE_EOF;
if (new_token)
return new_token;
/* Mark EOF */
return NULL;
}
|
|
|
pdf_text_get_unicode_string_header
|
11
|
22
|
69
|
../src/base/pdf-text.c
|
|
|
|
↓
|
is_absolute_path
|
11
|
16
|
43
|
../src/base/pdf-fsys-disk.c
|
static pdf_bool_t
is_absolute_path (const pdf_text_t *path,
pdf_error_t **error)
{
pdf_char_t *utf8;
pdf_size_t utf8_size;
utf8 = pdf_text_get_unicode (path,
PDF_TEXT_UTF8,
PDF_TEXT_UNICODE_WITH_NUL_SUFFIX,
&utf8_size,
error);
if (!utf8)
return PDF_FALSE;
if (utf8_size == 0)
{
pdf_dealloc (utf8);
return PDF_FALSE;
}
if (IS_DIR_SEPARATOR (utf8[0]))
{
pdf_dealloc (utf8);
return PDF_TRUE;
}
#ifdef PDF_HOST_WIN32
/* Recognize drive letter in native windows */
if (utf8_size >= 3 &&
((utf8[0] >= 'a' && utf8[0] <= 'z') ||
(utf8[0] >= 'A' && utf8[0] <= 'Z')) &&
utf8[1] == ':' &&
IS_DIR_SEPARATOR (utf8[2]))
{
pdf_dealloc (utf8);
return PDF_TRUE;
}
#endif /* PDF_HOST_WIN32 */
pdf_dealloc (utf8);
return PDF_FALSE;
}
|
|
|
pdf_text_utf32he_to_host_iconv
|
10
|
53
|
155
|
../src/base/pdf-text-host-encoding.c
|
|
|
pdf_time_from_string_generalized_asn1
|
10
|
36
|
117
|
../src/base/pdf-time-string.c
|
|
|
pdf_stm_write
|
10
|
35
|
87
|
../src/base/pdf-stm.c
|
|
|
pdf_text_get_replacement_pointers
|
10
|
34
|
90
|
../src/base/pdf-text.c
|
|
|
pdf_time_from_string_utc_asn1
|
10
|
31
|
85
|
../src/base/pdf-time-string.c
|
|
|
stm_f_rlenc_apply
|
10
|
27
|
68
|
../src/base/pdf-stm-f-rl.c
|
|
|
pdf_fsys_item_props_to_hash
|
10
|
26
|
80
|
../src/base/pdf-fsys.c
|
|
|
handle_hexstring_char
|
10
|
25
|
67
|
../src/base/pdf-token-reader.c
|
|
|
scan_string
|
10
|
25
|
52
|
../src/base/pdf-token-writer.c
|
|
|
validate_real
|
10
|
19
|
49
|
../src/base/pdf-token-reader.c
|
|
|
pdf_text_utf8_to_utf32he
|
9
|
40
|
114
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_time_get_cal
|
9
|
40
|
100
|
../src/base/pdf-time.c
|
|
|
get_item_props
|
9
|
39
|
94
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_compare_words
|
9
|
34
|
80
|
../src/base/pdf-text.c
|
|
|
stm_f_ahexdec_apply
|
9
|
33
|
94
|
../src/base/pdf-stm-f-ahex.c
|
|
|
pdf_text_cmp_non_case_sensitive
|
9
|
32
|
82
|
../src/base/pdf-text.c
|
|
|
deflate_inbuf
|
9
|
26
|
63
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_prefix_error
|
9
|
24
|
50
|
../src/base/pdf-error.c
|
|
|
spline_interpolation
|
9
|
18
|
24
|
../src/base/pdf-fp-func.c
|
|
|
pdf_token_equal_p
|
9
|
15
|
52
|
../src/base/pdf-token.c
|
|
|
write_real_token
|
9
|
18
|
53
|
../src/base/pdf-token-writer.c
|
|
|
pdf_text_host_to_utf32he_win32
|
9
|
36
|
118
|
../src/base/pdf-text-host-encoding.c
|
|
|
skip_root_utf8
|
8
|
6
|
20
|
../src/base/pdf-fsys-disk.c
|
|
|
get_folder_contents
|
8
|
36
|
87
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_eval_linear
|
8
|
32
|
55
|
../src/base/pdf-fp-func.c
|
|
|
pdf_text_ucd_word_change_case
|
8
|
31
|
81
|
../src/base/pdf-text-ucd-case.c
|
|
|
read_type0_sample_table
|
8
|
30
|
57
|
../src/base/pdf-fp-func.c
|
|
|
encode_buffer_number
|
8
|
29
|
80
|
../src/base/pdf-token-writer.c
|
|
|
pdf_stm_read
|
8
|
29
|
72
|
../src/base/pdf-stm.c
|
|
|
pdf_eval_stitch
|
8
|
28
|
59
|
../src/base/pdf-fp-func.c
|
|
|
hash_add
|
8
|
25
|
67
|
../src/base/pdf-hash.c
|
|
|
lzw_dict_add
|
8
|
24
|
60
|
../src/base/pdf-stm-f-lzw.c
|
|
|
stm_f_rldec_apply
|
8
|
24
|
52
|
../src/base/pdf-stm-f-rl.c
|
|
|
pdf_text_ucd_special_case_check_single
|
8
|
20
|
51
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_text_utf32he_point_to_pdfdocenc_point
|
8
|
17
|
49
|
../src/base/pdf-text-encoding.c
|
|
|
should_escape_namechar
|
7
|
8
|
24
|
../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
|
14
|
../src/base/pdf-stm-f-ahex.c
|
|
|
build_path
|
7
|
46
|
111
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_eval_spline
|
7
|
36
|
55
|
../src/base/pdf-fp-func.c
|
|
|
pdf_text_utf32he_to_utf16he
|
7
|
35
|
96
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_text_substitute_line_ending
|
7
|
35
|
74
|
../src/base/pdf-text-filter.c
|
|
|
aesv2_encrypt
|
7
|
32
|
83
|
../src/base/pdf-crypt-c-aesv2.c
|
|
|
aesv2_decrypt
|
7
|
32
|
83
|
../src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_stm_filter_new
|
7
|
31
|
82
|
../src/base/pdf-stm-filter.c
|
|
|
decode_row_paeth
|
7
|
28
|
55
|
../src/base/pdf-stm-f-pred.c
|
|
|
encode_row_paeth
|
7
|
27
|
54
|
../src/base/pdf-stm-f-pred.c
|
|
|
stm_f_jbig2dec_apply
|
7
|
26
|
76
|
../src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_text_replace_multiple
|
7
|
26
|
74
|
../src/base/pdf-text.c
|
|
|
compare_path_p
|
7
|
25
|
66
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_fill_word_boundaries_list
|
7
|
24
|
77
|
../src/base/pdf-text.c
|
|
|
write_data
|
7
|
18
|
33
|
../src/base/pdf-token-writer.c
|
|
|
pdf_text_ucd_special_case_get_next_condition
|
7
|
16
|
43
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_text_get_lang_from_utf16be
|
7
|
16
|
50
|
../src/base/pdf-text.c
|
|
|
stm_f_a85_flush_outbuff
|
7
|
16
|
41
|
../src/base/pdf-stm-f-a85.c
|
|
|
start_token
|
7
|
10
|
27
|
../src/base/pdf-token-writer.c
|
|
|
str_escape_len
|
7
|
8
|
30
|
../src/base/pdf-token-writer.c
|
|
|
write_comment_token
|
7
|
25
|
64
|
../src/base/pdf-token-writer.c
|
|
|
stm_f_v2_apply
|
6
|
21
|
60
|
../src/base/pdf-stm-f-v2.c
|
|
|
pdf_stm_filter_destroy
|
6
|
9
|
17
|
../src/base/pdf-stm-filter.c
|
|
|
read_and_deflate
|
6
|
8
|
32
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_stm_f_dctdec_set_djpeg_param
|
6
|
8
|
23
|
../src/base/pdf-stm-f-dct.c
|
|
|
pdf_text_utf32he_to_utf8
|
6
|
32
|
88
|
../src/base/pdf-text-encoding.c
|
|
|
stm_f_md5enc_apply
|
6
|
28
|
56
|
../src/base/pdf-stm-f-md5.c
|
|
|
pdf_text_get_hex
|
6
|
27
|
72
|
../src/base/pdf-text.c
|
|
|
solve_spline
|
6
|
26
|
47
|
../src/base/pdf-fp-func.c
|
|
|
stm_f_dctdec_init
|
6
|
25
|
66
|
../src/base/pdf-stm-f-dct.c
|
|
|
file_open
|
6
|
24
|
70
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_text_replace_ascii
|
6
|
24
|
68
|
../src/base/pdf-text.c
|
|
|
pdf_text_ucd_wb_rule_13a
|
6
|
2
|
10
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_concat
|
6
|
21
|
72
|
../src/base/pdf-text.c
|
|
|
copy_next_bytes
|
6
|
19
|
34
|
../src/base/pdf-stm-f-rl.c
|
|
|
pdf_time_calendar_add_months
|
6
|
19
|
43
|
../src/base/pdf-time.c
|
|
|
pdf_eval_exponential
|
6
|
18
|
27
|
../src/base/pdf-fp-func.c
|
|
|
pdf_fsys_add
|
6
|
18
|
50
|
../src/base/pdf-fsys.c
|
|
|
pdf_stm_read_peek_char
|
6
|
17
|
49
|
../src/base/pdf-stm.c
|
|
|
pdf_stm_init
|
6
|
16
|
50
|
../src/base/pdf-stm.c
|
|
|
pdf_text_filter_normalize_full_width_ascii
|
6
|
15
|
32
|
../src/base/pdf-text-filter.c
|
|
|
pdf_text_detect_host_language_and_country
|
6
|
15
|
47
|
../src/base/pdf-text-context.c
|
|
|
pdf_text_ucd_get_combining_class
|
6
|
14
|
37
|
../src/base/pdf-text-ucd-combclass.c
|
|
|
pdf_list_iterator_next
|
6
|
14
|
27
|
../src/base/pdf-list.c
|
|
|
pdf_text_ucd_find_case_index
|
6
|
14
|
37
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_hash_iterator_next
|
6
|
14
|
27
|
../src/base/pdf-hash.c
|
|
|
pdf_text_ucd_get_general_category
|
6
|
14
|
37
|
../src/base/pdf-text-ucd-gencat.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_text_utf16he_point_to_utf32he_point
|
6
|
10
|
63
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_text_check_unicode_bom
|
6
|
5
|
31
|
../src/base/pdf-text-encoding.c
|
|
|
get_token
|
5
|
29
|
81
|
../src/base/pdf-fp-func.c
|
|
|
error_new_valist
|
5
|
9
|
25
|
../src/base/pdf-error.c
|
|
|
pdf_time_calendar_add_years
|
5
|
8
|
24
|
../src/base/pdf-time.c
|
|
|
pdf_time_set_from_cal
|
5
|
29
|
69
|
../src/base/pdf-time.c
|
|
|
pdf_text_perform_replacements
|
5
|
28
|
64
|
../src/base/pdf-text.c
|
|
|
pdf_time_calendar_add_days
|
5
|
23
|
58
|
../src/base/pdf-time.c
|
|
|
pdf_text_concat_ascii
|
5
|
23
|
56
|
../src/base/pdf-text.c
|
|
|
stm_f_jbig2dec_init
|
5
|
22
|
71
|
../src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_text_utf32he_point_to_utf8_point
|
5
|
22
|
63
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_stm_bseek
|
5
|
21
|
55
|
../src/base/pdf-stm.c
|
|
|
pdf_text_ucd_wb_rule_13b
|
5
|
2
|
9
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_token_reader_new
|
5
|
21
|
54
|
../src/base/pdf-token-reader.c
|
|
|
pdf_spline_init
|
5
|
20
|
32
|
../src/base/pdf-fp-func.c
|
|
|
ensure_absolute_path
|
5
|
20
|
56
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_token_writer_new
|
5
|
19
|
50
|
../src/base/pdf-token-writer.c
|
|
|
build_path
|
5
|
18
|
40
|
../src/base/pdf-fsys-disk.c
|
|
|
win32_device_p
|
5
|
17
|
42
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_utf32he_point_to_utf16he_point
|
5
|
16
|
62
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_error
|
5
|
15
|
30
|
../src/base/pdf-error.c
|
|
|
pdf_time_get_century_in_sliding_window
|
5
|
15
|
35
|
../src/base/pdf-time-string.c
|
|
|
recognise_number
|
5
|
14
|
24
|
../src/base/pdf-token-reader.c
|
|
|
pdf_stm_filter_get_input
|
5
|
14
|
34
|
../src/base/pdf-stm-filter.c
|
|
|
stm_be_cfile_write
|
5
|
14
|
52
|
../src/base/pdf-stm-be-cfile.c
|
|
|
pdf_text_cmp
|
5
|
14
|
27
|
../src/base/pdf-text.c
|
|
|
stm_be_cfile_read
|
5
|
14
|
52
|
../src/base/pdf-stm-be-cfile.c
|
|
|
stm_be_file_read
|
5
|
14
|
45
|
../src/base/pdf-stm-be-file.c
|
|
|
lzw_buffer_get_code
|
5
|
13
|
32
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_list_add_at
|
5
|
13
|
47
|
../src/base/pdf-list.c
|
|
|
get_stat_info_from_host_path
|
5
|
13
|
38
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_host_encoding_is_available
|
5
|
12
|
28
|
../src/base/pdf-text-host-encoding.c
|
|
|
pdf_text_check_replacement_patterns
|
5
|
12
|
33
|
../src/base/pdf-text.c
|
|
|
pdf_list_indexof_from_to
|
5
|
10
|
39
|
../src/base/pdf-list.c
|
|
|
stm_f_aesv2_deinit
|
5
|
10
|
15
|
../src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_text_ucd_is_case_ignorable
|
4
|
4
|
28
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_text_set_unicode
|
4
|
28
|
78
|
../src/base/pdf-text.c
|
|
|
pdf_token_destroy
|
4
|
7
|
27
|
../src/base/pdf-token.c
|
|
|
pdf_fp_func_destroy
|
4
|
34
|
58
|
../src/base/pdf-fp-func.c
|
|
|
write_integer_token
|
4
|
9
|
32
|
../src/base/pdf-token-writer.c
|
|
|
write_keyword_token
|
4
|
15
|
48
|
../src/base/pdf-token-writer.c
|
|
|
encode_rl_char
|
4
|
9
|
21
|
../src/base/pdf-stm-f-rl.c
|
|
|
write_ppm_header
|
4
|
17
|
49
|
../src/base/pdf-stm-f-dct.c
|
|
|
pdf_text_detect_host_encoding
|
4
|
9
|
25
|
../src/base/pdf-text-context.c
|
|
|
pdf_list_sorted_indexof_from_to
|
4
|
9
|
37
|
../src/base/pdf-list.c
|
|
|
pdf_list_sorted_search_from_to
|
4
|
9
|
37
|
../src/base/pdf-list.c
|
|
|
pdf_list_iterator_init_from_to
|
4
|
9
|
34
|
../src/base/pdf-list.c
|
|
|
write_data_using_pos
|
4
|
9
|
29
|
../src/base/pdf-token-writer.c
|
|
|
skip_scheme_from_url
|
4
|
8
|
19
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_list_set_at
|
4
|
8
|
37
|
../src/base/pdf-list.c
|
|
|
pdf_text_destroy
|
4
|
8
|
18
|
../src/base/pdf-text.c
|
|
|
pdf_fsys_remove
|
4
|
8
|
23
|
../src/base/pdf-fsys.c
|
|
|
pdf_list_search_from_to
|
4
|
8
|
34
|
../src/base/pdf-list.c
|
|
|
stm_be_ensure_correct_offset
|
4
|
8
|
20
|
../src/base/pdf-stm-be-file.c
|
|
|
pdf_text_ucd_wb_in_interval
|
4
|
7
|
17
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
lzw_buffer_flush
|
4
|
7
|
17
|
../src/base/pdf-stm-f-lzw.c
|
|
|
stm_f_a85_write_out
|
4
|
7
|
20
|
../src/base/pdf-stm-f-a85.c
|
|
|
pdf_text_ucd_pl_in_interval
|
4
|
7
|
17
|
../src/base/pdf-text-ucd-proplist.c
|
|
|
request_http_head_header_parse
|
4
|
6
|
30
|
../src/base/pdf-fsys-http.c
|
|
|
hash_element_dispose
|
4
|
6
|
12
|
../src/base/pdf-hash.c
|
|
|
pdf_text_transform_he_to_unicode_encoding
|
4
|
4
|
7
|
../src/base/pdf-text.c
|
|
|
get_current_path
|
4
|
25
|
71
|
../src/base/pdf-fsys-disk.c
|
|
|
decode_row_sub_colorl8
|
4
|
24
|
34
|
../src/base/pdf-stm-f-pred.c
|
|
|
encode_row_sub_colorl8
|
4
|
24
|
34
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_text_ucd_check_lang
|
4
|
2
|
9
|
../src/base/pdf-text-ucd-case.c
|
|
|
src_fill
|
4
|
22
|
43
|
../src/base/pdf-stm-f-dct.c
|
|
|
pdf_text_pdfdocenc_to_utf32he
|
4
|
22
|
60
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_text_ucd_wb_rule_12
|
4
|
2
|
8
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_11
|
4
|
2
|
8
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_7
|
4
|
2
|
8
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_6
|
4
|
2
|
8
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3b
|
4
|
2
|
8
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3a
|
4
|
2
|
8
|
../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
|
|
|
md5_read
|
4
|
19
|
55
|
../src/base/pdf-crypt-md-md5.c
|
|
|
encode_row_sub_color8
|
4
|
19
|
28
|
../src/base/pdf-stm-f-pred.c
|
|
|
file_open
|
4
|
19
|
54
|
../src/base/pdf-fsys-disk.c
|
|
|
encode_row_sub_color16
|
4
|
19
|
30
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_text_new
|
4
|
19
|
49
|
../src/base/pdf-text.c
|
|
|
pdf_time_w32_set_from_filetime
|
4
|
18
|
62
|
../src/base/pdf-time.c
|
|
|
pdf_time_calendar_add_seconds
|
4
|
18
|
40
|
../src/base/pdf-time.c
|
|
|
pdf_time_calendar_add_minutes
|
4
|
18
|
40
|
../src/base/pdf-time.c
|
|
|
pdf_time_calendar_add_hours
|
4
|
18
|
40
|
../src/base/pdf-time.c
|
|
|
compare_path_p
|
4
|
17
|
34
|
../src/base/pdf-fsys-http.c
|
|
|
stm_f_lzwdec_init
|
4
|
17
|
39
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_text_utf32he_to_pdfdocenc
|
4
|
17
|
56
|
../src/base/pdf-text-encoding.c
|
|
|
get_host_path
|
4
|
17
|
49
|
../src/base/pdf-fsys-disk.c
|
|
|
eval_spline
|
4
|
16
|
39
|
../src/base/pdf-fp-func.c
|
|
|
file_open_tmp
|
4
|
16
|
47
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_dup
|
4
|
16
|
46
|
../src/base/pdf-text.c
|
|
|
pdf_stm_mem_new
|
4
|
16
|
43
|
../src/base/pdf-stm.c
|
|
|
pdf_stm_file_new
|
4
|
15
|
42
|
../src/base/pdf-stm.c
|
|
|
decode_row_average
|
4
|
15
|
30
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_time_context_init
|
4
|
15
|
35
|
../src/base/pdf-time-context.c
|
|
|
pdf_stm_cfile_new
|
4
|
15
|
42
|
../src/base/pdf-stm.c
|
|
|
stm_f_md5enc_init
|
4
|
15
|
37
|
../src/base/pdf-stm-f-md5.c
|
|
|
encode_row_average
|
4
|
15
|
29
|
../src/base/pdf-stm-f-pred.c
|
|
|
stm_f_lzwenc_init
|
4
|
15
|
38
|
../src/base/pdf-stm-f-lzw.c
|
|
|
token_buffer_new
|
4
|
14
|
35
|
../src/base/pdf-token.c
|
|
|
stm_f_a85dec_getnext
|
4
|
13
|
30
|
../src/base/pdf-stm-f-a85.c
|
|
|
guess_decimal_point
|
4
|
13
|
37
|
../src/base/pdf-tokeniser.c
|
|
|
pdf_text_new_from_unicode
|
4
|
13
|
38
|
../src/base/pdf-text.c
|
|
|
pdf_text_clean_contents
|
4
|
13
|
29
|
../src/base/pdf-text.c
|
|
|
stm_be_file_write
|
4
|
12
|
42
|
../src/base/pdf-stm-be-file.c
|
|
|
pdf_text_get_printable
|
4
|
12
|
34
|
../src/base/pdf-text.c
|
|
|
stm_be_mem_write
|
4
|
12
|
32
|
../src/base/pdf-stm-be-mem.c
|
|
|
stm_be_mem_read
|
4
|
12
|
33
|
../src/base/pdf-stm-be-mem.c
|
|
|
pdf_text_ucd_to_case
|
4
|
11
|
40
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_token_real_new
|
4
|
11
|
30
|
../src/base/pdf-token.c
|
|
|
pdf_text_convert_encoding_name_to_CP
|
4
|
11
|
42
|
../src/base/pdf-text-host-encoding.c
|
|
|
linear_interpolation
|
4
|
11
|
32
|
../src/base/pdf-fp-func.c
|
|
|
pdf_list_add_last
|
4
|
10
|
33
|
../src/base/pdf-list.c
|
|
|
pdf_list_add_first
|
4
|
10
|
33
|
../src/base/pdf-list.c
|
|
|
decode_rl_char
|
4
|
10
|
22
|
../src/base/pdf-stm-f-rl.c
|
|
|
stm_be_file_seek
|
4
|
10
|
19
|
../src/base/pdf-stm-be-file.c
|
|
|
init_base_file_data
|
4
|
10
|
35
|
../src/base/pdf-fsys-disk.c
|
|
|
stm_be_ensure_correct_offset
|
4
|
10
|
24
|
../src/base/pdf-stm-be-cfile.c
|
|
|
file_read
|
4
|
10
|
30
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_token_valueless_new
|
3
|
3
|
21
|
../src/base/pdf-token.c
|
|
|
pdf_text_ucd_simple_case
|
3
|
12
|
41
|
../src/base/pdf-text-ucd-case.c
|
|
|
write_valueless_token
|
3
|
8
|
28
|
../src/base/pdf-token-writer.c
|
|
|
pdf_crypt_cipher_new
|
3
|
3
|
16
|
../src/base/pdf-crypt.c
|
|
|
v2_decrypt
|
3
|
9
|
29
|
../src/base/pdf-crypt-c-v2.c
|
|
|
v2_encrypt
|
3
|
9
|
29
|
../src/base/pdf-crypt-c-v2.c
|
|
|
pdf_token_keyword_new
|
3
|
9
|
29
|
../src/base/pdf-token.c
|
|
|
pdf_token_comment_new
|
3
|
9
|
29
|
../src/base/pdf-token.c
|
|
|
pdf_text_ucd_create_case_context
|
3
|
9
|
31
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_token_name_new
|
3
|
9
|
29
|
../src/base/pdf-token.c
|
|
|
pdf_fsys_impl_helper_file_init
|
3
|
9
|
23
|
../src/base/pdf-fsys.c
|
|
|
stm_f_flatedec_init
|
3
|
9
|
26
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_context_init
|
3
|
9
|
23
|
../src/base/pdf-text-context.c
|
|
|
file_set_size
|
3
|
9
|
24
|
../src/base/pdf-fsys-disk.c
|
|
|
stm_f_flateenc_init
|
3
|
9
|
26
|
../src/base/pdf-stm-f-flate.c
|
|
|
file_set_pos
|
3
|
8
|
29
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_hash_add_duplicated_time
|
3
|
8
|
23
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_hash_add_duplicated_text
|
3
|
8
|
23
|
../src/base/pdf-hash-helper.c
|
|
|
hash_search_key
|
3
|
8
|
20
|
../src/base/pdf-hash.c
|
|
|
flush_buffer
|
3
|
8
|
23
|
../src/base/pdf-token-writer.c
|
|
|
pdf_set_error
|
3
|
8
|
27
|
../src/base/pdf-error.c
|
|
|
lzw_buffer_put_code
|
3
|
8
|
23
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_fsys_http_init
|
3
|
8
|
44
|
../src/base/pdf-fsys-http.c
|
|
|
decode_row_up
|
3
|
7
|
21
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_stm_filter_reset
|
3
|
7
|
20
|
../src/base/pdf-stm-filter.c
|
|
|
encode_row_up
|
3
|
7
|
19
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_text_is_ascii7
|
3
|
7
|
14
|
../src/base/pdf-text.c
|
|
|
stm_be_mem_seek
|
3
|
7
|
17
|
../src/base/pdf-stm-be-mem.c
|
|
|
stm_f_md5enc_deinit
|
3
|
6
|
11
|
../src/base/pdf-stm-f-md5.c
|
|
|
pdf_list_remove_at
|
3
|
6
|
22
|
../src/base/pdf-list.c
|
|
|
reserve_buffer_space
|
3
|
6
|
16
|
../src/base/pdf-token-writer.c
|
|
|
pdf_text_clean_word_boundaries_list
|
3
|
6
|
19
|
../src/base/pdf-text.c
|
|
|
stm_f_v2_deinit
|
3
|
6
|
11
|
../src/base/pdf-stm-f-v2.c
|
|
|
is_writable_from_host_path
|
3
|
5
|
17
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_time_cmp
|
3
|
5
|
10
|
../src/base/pdf-time.c
|
|
|
is_readable_from_host_path
|
3
|
5
|
17
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_tokeniser_init
|
3
|
5
|
11
|
../src/base/pdf-tokeniser.c
|
|
|
clip
|
3
|
5
|
10
|
../src/base/pdf-fp-func.c
|
|
|
pdf_fsys_init
|
3
|
5
|
15
|
../src/base/pdf-fsys.c
|
|
|
pdf_token_reader_destroy
|
3
|
5
|
10
|
../src/base/pdf-token-reader.c
|
|
|
pdf_text_host_encoding_is_available
|
3
|
5
|
14
|
../src/base/pdf-text-host-encoding.c
|
|
|
pdf_token_writer_destroy
|
3
|
5
|
10
|
../src/base/pdf-token-writer.c
|
|
|
store_char_grow
|
3
|
4
|
12
|
../src/base/pdf-token-reader.c
|
|
|
pdf_clear_error
|
3
|
4
|
10
|
../src/base/pdf-error.c
|
|
|
pdf_error_destroy
|
3
|
3
|
10
|
../src/base/pdf-error.c
|
|
|
reset_buffer
|
3
|
3
|
12
|
../src/base/pdf-token-reader.c
|
|
|
pdf_fp_func_3_new
|
3
|
29
|
53
|
../src/base/pdf-fp-func.c
|
|
|
pdf_text_filter_remove_amp
|
3
|
2
|
8
|
../src/base/pdf-text-filter.c
|
|
|
pdf_text_ucd_wb_rule_13
|
3
|
2
|
7
|
../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
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_8
|
3
|
2
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_5
|
3
|
2
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_4
|
3
|
2
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_rule_3
|
3
|
2
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
get_item_props
|
3
|
20
|
42
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_text_set_host
|
3
|
15
|
45
|
../src/base/pdf-text.c
|
|
|
pdf_time_add_cal_span_with_sign
|
3
|
15
|
30
|
../src/base/pdf-time.c
|
|
|
pdf_text_set_pdfdocenc
|
3
|
14
|
38
|
../src/base/pdf-text.c
|
|
|
pdf_text_get_pdfdocenc
|
3
|
14
|
41
|
../src/base/pdf-text.c
|
|
|
stm_f_null_apply
|
3
|
14
|
33
|
../src/base/pdf-stm-f-null.c
|
|
|
pdf_buffer_new
|
3
|
14
|
42
|
../src/base/pdf-types-buffer.c
|
|
|
pdf_crypt_cipher_aesv2_new
|
3
|
14
|
41
|
../src/base/pdf-crypt-c-aesv2.c
|
|
|
item_writable_p
|
3
|
14
|
26
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_rename_key
|
3
|
14
|
36
|
../src/base/pdf-hash.c
|
|
|
item_readable_p
|
3
|
14
|
26
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_buffer_resize
|
3
|
14
|
33
|
../src/base/pdf-types-buffer.c
|
|
|
lzwdec_put_decoded
|
3
|
13
|
28
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_stm_install_filter
|
3
|
13
|
33
|
../src/base/pdf-stm.c
|
|
|
pdf_text_new_from_host
|
3
|
13
|
37
|
../src/base/pdf-text.c
|
|
|
pdf_stm_destroy
|
3
|
13
|
30
|
../src/base/pdf-stm.c
|
|
|
pdf_crypt_cipher_v2_new
|
3
|
13
|
40
|
../src/base/pdf-crypt-c-v2.c
|
|
|
get_free_space
|
3
|
13
|
34
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_crypt_md_md5_new
|
3
|
13
|
37
|
../src/base/pdf-crypt-md-md5.c
|
|
|
get_free_space
|
3
|
13
|
55
|
../src/base/pdf-fsys-disk.c
|
|
|
file_read
|
3
|
12
|
35
|
../src/base/pdf-fsys-disk.c
|
|
|
remove_folder
|
3
|
11
|
29
|
../src/base/pdf-fsys-disk.c
|
|
|
create_folder
|
3
|
11
|
36
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_get_best_encoding
|
3
|
11
|
38
|
../src/base/pdf-text.c
|
|
|
stm_be_cfile_seek
|
3
|
11
|
25
|
../src/base/pdf-stm-be-cfile.c
|
|
|
request_http_partial_get_body_parse
|
3
|
11
|
26
|
../src/base/pdf-fsys-http.c
|
|
|
item_p
|
3
|
11
|
29
|
../src/base/pdf-fsys-disk.c
|
|
|
item_p
|
3
|
10
|
26
|
../src/base/pdf-fsys-http.c
|
|
|
file_close
|
3
|
10
|
30
|
../src/base/pdf-fsys-disk.c
|
|
|
skip_input_data
|
3
|
10
|
23
|
../src/base/pdf-stm-f-dct.c
|
|
|
pdf_fsys_foreach
|
3
|
10
|
25
|
../src/base/pdf-fsys.c
|
|
|
pdf_list_indexof_from
|
3
|
10
|
33
|
../src/base/pdf-list.c
|
|
|
pdf_time_get_days_in_month
|
3
|
5
|
25
|
../src/base/pdf-time.c
|
|
|
pdf_token_writer_write
|
3
|
30
|
55
|
../src/base/pdf-token-writer.c
|
|
|
pdf_token_dup
|
3
|
11
|
47
|
../src/base/pdf-token.c
|
|
|
decode_row
|
3
|
24
|
85
|
../src/base/pdf-stm-f-pred.c
|
|
|
encode_row
|
3
|
24
|
84
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_time_set_from_string
|
2
|
9
|
30
|
../src/base/pdf-time.c
|
|
|
pdf_time_to_string
|
2
|
8
|
27
|
../src/base/pdf-time.c
|
|
|
stm_f_a85dec_apply
|
2
|
7
|
30
|
../src/base/pdf-stm-f-a85.c
|
|
|
stm_f_a85enc_apply
|
2
|
7
|
30
|
../src/base/pdf-stm-f-a85.c
|
|
|
set_error_from_zlib_ret
|
2
|
12
|
30
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_ucd_is_cased
|
2
|
2
|
16
|
../src/base/pdf-text-ucd-case.c
|
|
|
pdf_uuid_generate
|
2
|
7
|
19
|
../src/base/pdf-types-uuid.c
|
|
|
hash
|
2
|
7
|
35
|
../src/base/pdf-fp-func.c
|
|
|
pdf_stm_be_new_file
|
2
|
9
|
27
|
../src/base/pdf-stm-be-file.c
|
|
|
pdf_stm_be_new_cfile
|
2
|
9
|
27
|
../src/base/pdf-stm-be-cfile.c
|
|
|
stm_f_ahex_init
|
2
|
9
|
29
|
../src/base/pdf-stm-f-ahex.c
|
|
|
pdf_hash_add_duplicated_string
|
2
|
9
|
27
|
../src/base/pdf-hash-helper.c
|
|
|
stm_f_dctdec_deinit
|
2
|
9
|
19
|
../src/base/pdf-stm-f-dct.c
|
|
|
file_get_pos
|
2
|
9
|
23
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_get_host
|
2
|
8
|
28
|
../src/base/pdf-text.c
|
|
|
pdf_list_sorted_add
|
2
|
8
|
23
|
../src/base/pdf-list.c
|
|
|
pdf_text_destroy_word_boundaries_list
|
2
|
8
|
20
|
../src/base/pdf-text.c
|
|
|
file_flush
|
2
|
8
|
31
|
../src/base/pdf-fsys-disk.c
|
|
|
file_set_pos
|
2
|
8
|
25
|
../src/base/pdf-fsys-disk.c
|
|
|
token_new
|
2
|
7
|
21
|
../src/base/pdf-token.c
|
|
|
enlarge_buffer
|
2
|
7
|
15
|
../src/base/pdf-token-reader.c
|
|
|
decode_row_sub
|
2
|
7
|
16
|
../src/base/pdf-stm-f-pred.c
|
|
|
aesv2_set_key
|
2
|
7
|
22
|
../src/base/pdf-crypt-c-aesv2.c
|
|
|
file_close
|
2
|
7
|
15
|
../src/base/pdf-fsys-http.c
|
|
|
v2_set_key
|
2
|
7
|
22
|
../src/base/pdf-crypt-c-v2.c
|
|
|
hash_element_pjw
|
2
|
7
|
11
|
../src/base/pdf-hash.c
|
|
|
encode_row_sub
|
2
|
7
|
14
|
../src/base/pdf-stm-f-pred.c
|
|
|
lzw_dict_decode
|
2
|
7
|
18
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_hash_remove
|
2
|
7
|
19
|
../src/base/pdf-hash.c
|
|
|
lzw_dict_init
|
2
|
7
|
16
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_fsys_get
|
2
|
7
|
15
|
../src/base/pdf-fsys.c
|
|
|
get_parent
|
2
|
6
|
22
|
../src/base/pdf-fsys-disk.c
|
|
|
get_basename
|
2
|
6
|
22
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_list_search_from
|
2
|
6
|
25
|
../src/base/pdf-list.c
|
|
|
get_parent
|
2
|
6
|
21
|
../src/base/pdf-fsys-http.c
|
|
|
get_basename
|
2
|
6
|
21
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_dup
|
2
|
6
|
14
|
../src/base/pdf-time.c
|
|
|
stm_f_flatedec_apply
|
2
|
6
|
18
|
../src/base/pdf-stm-f-flate.c
|
|
|
stm_f_flateenc_apply
|
2
|
6
|
18
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_hash_get_value
|
2
|
6
|
13
|
../src/base/pdf-hash.c
|
|
|
file_get_size
|
2
|
6
|
18
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_new
|
2
|
5
|
18
|
../src/base/pdf-hash.c
|
|
|
store_char
|
2
|
5
|
18
|
../src/base/pdf-token-reader.c
|
|
|
exit_state
|
2
|
5
|
14
|
../src/base/pdf-token-reader.c
|
|
|
pdf_time_new
|
2
|
5
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_time_allocate
|
2
|
5
|
19
|
../src/base/pdf-time.c
|
|
|
pdf_list_new
|
2
|
5
|
21
|
../src/base/pdf-list.c
|
|
|
pdf_token_integer_new
|
2
|
5
|
12
|
../src/base/pdf-token.c
|
|
|
pdf_list_get_at
|
2
|
5
|
22
|
../src/base/pdf-list.c
|
|
|
pdf_fsys_disk_init
|
2
|
5
|
20
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_context_deinit
|
2
|
5
|
12
|
../src/base/pdf-text-context.c
|
|
|
lzw_buffer_inc_bitsize
|
2
|
5
|
11
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_list_indexof
|
2
|
5
|
14
|
../src/base/pdf-list.c
|
|
|
file_reopen
|
2
|
5
|
20
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_get_days_before_month
|
2
|
5
|
13
|
../src/base/pdf-time.c
|
|
|
pdf_buffer_destroy
|
2
|
4
|
9
|
../src/base/pdf-types-buffer.c
|
|
|
pdf_list_sorted_remove
|
2
|
4
|
13
|
../src/base/pdf-list.c
|
|
|
lzwdec_put_code
|
2
|
4
|
11
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_uuid_string
|
2
|
4
|
12
|
../src/base/pdf-types-uuid.c
|
|
|
pdf_list_remove
|
2
|
4
|
10
|
../src/base/pdf-list.c
|
|
|
pdf_time_context_deinit
|
2
|
4
|
10
|
../src/base/pdf-time-context.c
|
|
|
pdf_list_remove_node
|
2
|
4
|
11
|
../src/base/pdf-list.c
|
|
|
pdf_crypt_init
|
2
|
4
|
16
|
../src/base/pdf-crypt.c
|
|
|
pdf_propagate_error
|
2
|
4
|
11
|
../src/base/pdf-error.c
|
|
|
write_buffered_char
|
2
|
4
|
11
|
../src/base/pdf-token-writer.c
|
|
|
write_buffered_char_nocheck
|
2
|
4
|
10
|
../src/base/pdf-token-writer.c
|
|
|
jbig2dec_error_cb
|
2
|
4
|
13
|
../src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_fsys_disk_deinit_cb
|
2
|
4
|
11
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_fsys_http_deinit_cb
|
2
|
4
|
20
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_hash_key_p
|
2
|
4
|
10
|
../src/base/pdf-hash.c
|
|
|
pdf_hash_size
|
2
|
3
|
7
|
../src/base/pdf-hash.c
|
|
|
pdf_buffer_eob_p
|
2
|
3
|
8
|
../src/base/pdf-types-buffer.c
|
|
|
pdf_buffer_full_p
|
2
|
3
|
8
|
../src/base/pdf-types-buffer.c
|
|
|
pdf_text_empty_p
|
2
|
3
|
7
|
../src/base/pdf-text.c
|
|
|
pdf_fsys_impl_helper_file_deinit
|
2
|
3
|
8
|
../src/base/pdf-fsys.c
|
|
|
pdf_propagate_error_dup
|
2
|
3
|
9
|
../src/base/pdf-error.c
|
|
|
pdf_stm_filter_get_tail
|
2
|
3
|
8
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_token_get_type
|
2
|
3
|
10
|
../src/base/pdf-token.c
|
|
|
deinit_base_file_data
|
2
|
3
|
8
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_tokeniser_deinit
|
2
|
2
|
6
|
../src/base/pdf-tokeniser.c
|
|
|
pdf_hash_destroy
|
2
|
2
|
6
|
../src/base/pdf-hash.c
|
|
|
pdf_list_size
|
2
|
2
|
7
|
../src/base/pdf-list.c
|
|
|
pdf_uuid_equal_p
|
2
|
2
|
6
|
../src/base/pdf-types-uuid.c
|
|
|
pdf_list_destroy
|
2
|
2
|
6
|
../src/base/pdf-list.c
|
|
|
pdf_list_iterator_deinit
|
2
|
2
|
6
|
../src/base/pdf-list.c
|
|
|
pdf_time_destroy
|
2
|
2
|
6
|
../src/base/pdf-time.c
|
|
|
pdf_time_diff_cal
|
2
|
23
|
63
|
../src/base/pdf-time.c
|
|
|
hash_element_equal
|
2
|
2
|
7
|
../src/base/pdf-hash.c
|
|
|
pdf_hash_iterator_deinit
|
2
|
2
|
6
|
../src/base/pdf-hash.c
|
|
|
pdf_text_context_get_host_eol
|
2
|
2
|
7
|
../src/base/pdf-text-context.c
|
|
|
pdf_text_generate_word_boundaries
|
2
|
2
|
11
|
../src/base/pdf-text.c
|
|
|
pdf_text_deinit
|
2
|
2
|
7
|
../src/base/pdf-text.c
|
|
|
pdf_stm_filter_p
|
2
|
2
|
5
|
../src/base/pdf-stm-filter.c
|
|
|
get_status_from_errno
|
2
|
9
|
49
|
../src/base/pdf-fsys-disk.c
|
|
|
stm_f_flate_init
|
2
|
17
|
35
|
../src/base/pdf-stm-f-flate.c
|
|
|
stm_f_rl_init
|
2
|
15
|
32
|
../src/base/pdf-stm-f-rl.c
|
|
|
pdf_stm_btell
|
2
|
13
|
27
|
../src/base/pdf-stm.c
|
|
|
file_reopen
|
2
|
13
|
33
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_new_from_u32
|
2
|
12
|
29
|
../src/base/pdf-text.c
|
|
|
pdf_text_get_dwflags_for_cp
|
2
|
2
|
80
|
../src/base/pdf-text-host-encoding.c
|
|
|
jpeg_cache_src
|
2
|
12
|
27
|
../src/base/pdf-stm-f-dct.c
|
|
|
stm_f_a85_init
|
2
|
11
|
30
|
../src/base/pdf-stm-f-a85.c
|
|
|
pdf_stm_be_new_mem
|
2
|
10
|
29
|
../src/base/pdf-stm-be-mem.c
|
|
|
file_write
|
2
|
10
|
31
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_time_add_cal_span_with_base
|
1
|
8
|
19
|
../src/base/pdf-time.c
|
|
|
lzw_buffer_init
|
1
|
7
|
12
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_time_span_from_cal_span
|
1
|
7
|
18
|
../src/base/pdf-time.c
|
|
|
pdf_error_new
|
1
|
6
|
17
|
../src/base/pdf-error.c
|
|
|
pdf_text_set_language
|
1
|
5
|
12
|
../src/base/pdf-text.c
|
|
|
pdf_text_set_country
|
1
|
5
|
12
|
../src/base/pdf-text.c
|
|
|
pred_bit_ptr_init
|
1
|
5
|
11
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_token_writer_reset
|
1
|
5
|
11
|
../src/base/pdf-token-writer.c
|
|
|
stm_f_pred_deinit
|
1
|
5
|
10
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_time_span_to_cal_span
|
1
|
5
|
18
|
../src/base/pdf-time.c
|
|
|
pdf_text_detect_host_endianness
|
1
|
4
|
11
|
../src/base/pdf-text-context.c
|
|
|
pdf_list_sorted_indexof
|
1
|
4
|
13
|
../src/base/pdf-list.c
|
|
|
pdf_list_sorted_search
|
1
|
4
|
13
|
../src/base/pdf-list.c
|
|
|
pdf_time_copy
|
1
|
4
|
10
|
../src/base/pdf-time.c
|
|
|
pdf_token_reader_reset
|
1
|
4
|
10
|
../src/base/pdf-token-reader.c
|
|
|
file_can_set_size_p
|
1
|
4
|
12
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_text_replace
|
1
|
4
|
16
|
../src/base/pdf-text.c
|
|
|
pdf_time_cal_span_diff
|
1
|
4
|
14
|
../src/base/pdf-time.c
|
|
|
file_get_size
|
1
|
3
|
11
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_diff
|
1
|
3
|
9
|
../src/base/pdf-time.c
|
|
|
file_get_pos
|
1
|
3
|
10
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_get_utc_cal
|
1
|
3
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_time_get_local_cal
|
1
|
3
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_time_sub_span
|
1
|
3
|
9
|
../src/base/pdf-time.c
|
|
|
get_url_from_path
|
1
|
3
|
15
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_list_search
|
1
|
3
|
10
|
../src/base/pdf-list.c
|
|
|
pdf_time_sub_cal_span
|
1
|
3
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_time_add_cal_span
|
1
|
3
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_fp_func_get_bounds
|
1
|
3
|
10
|
../src/base/pdf-fp-func.c
|
|
|
pdf_time_set_local
|
1
|
3
|
11
|
../src/base/pdf-time.c
|
|
|
pdf_time_set_utc
|
1
|
3
|
9
|
../src/base/pdf-time.c
|
|
|
pdf_time_init_dup
|
1
|
3
|
9
|
../src/base/pdf-time.c
|
|
|
pdf_token_get_keyword_data
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_token_get_keyword_size
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_stm_peek_char
|
1
|
3
|
10
|
../src/base/pdf-stm.c
|
|
|
pdf_stm_read_char
|
1
|
3
|
10
|
../src/base/pdf-stm.c
|
|
|
pdf_list_iterator_init
|
1
|
3
|
9
|
../src/base/pdf-list.c
|
|
|
pdf_token_get_comment_data
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_token_get_comment_size
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_stm_supported_filter_p
|
1
|
3
|
8
|
../src/base/pdf-stm.c
|
|
|
pdf_dealloc
|
1
|
3
|
10
|
../src/base/pdf-alloc.c
|
|
|
pdf_token_get_string_data
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
md5_write
|
1
|
3
|
11
|
../src/base/pdf-crypt-md-md5.c
|
|
|
pdf_token_get_string_size
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_token_get_name_data
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_token_get_name_size
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_alloc
|
1
|
3
|
8
|
../src/base/pdf-alloc.c
|
|
|
pdf_token_get_real_value
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
pdf_text_filter_normalize_line_endings
|
1
|
3
|
13
|
../src/base/pdf-text-filter.c
|
|
|
stm_f_flatedec_deinit
|
1
|
3
|
8
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_token_get_integer_value
|
1
|
3
|
8
|
../src/base/pdf-token.c
|
|
|
lzw_dict_fast_add
|
1
|
3
|
9
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_hash_iterator_init
|
1
|
3
|
9
|
../src/base/pdf-hash.c
|
|
|
pdf_list_node_value
|
1
|
3
|
10
|
../src/base/pdf-list.c
|
|
|
aesv2_destroy
|
1
|
3
|
8
|
../src/base/pdf-crypt-c-aesv2.c
|
|
|
pdf_hash_replace
|
1
|
3
|
12
|
../src/base/pdf-hash.c
|
|
|
pdf_hash_add
|
1
|
3
|
12
|
../src/base/pdf-hash.c
|
|
|
stm_f_flateenc_deinit
|
1
|
3
|
8
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_text_pdfdocenc_point_to_utf32he_point
|
1
|
3
|
8
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_list_previous_node
|
1
|
3
|
10
|
../src/base/pdf-list.c
|
|
|
pdf_list_next_node
|
1
|
3
|
10
|
../src/base/pdf-list.c
|
|
|
stm_f_jbig2dec_deinit
|
1
|
3
|
8
|
../src/base/pdf-stm-f-jbig2.c
|
|
|
pdf_buffer_rewind
|
1
|
3
|
8
|
../src/base/pdf-types-buffer.c
|
|
|
v2_destroy
|
1
|
3
|
8
|
../src/base/pdf-crypt-c-v2.c
|
|
|
md5_destroy
|
1
|
3
|
8
|
../src/base/pdf-crypt-md-md5.c
|
|
|
file_request_ria
|
1
|
3
|
16
|
../src/base/pdf-fsys-http.c
|
|
|
validate_implementation
|
1
|
30
|
61
|
../src/base/pdf-fsys.c
|
|
|
pdf_time_set_local_offset
|
1
|
2
|
8
|
../src/base/pdf-time.c
|
|
|
pdf_text_host_to_utf32he
|
1
|
2
|
24
|
../src/base/pdf-text-host-encoding.c
|
|
|
pdf_crypt_md_new
|
1
|
2
|
9
|
../src/base/pdf-crypt.c
|
|
|
get_path_from_url
|
1
|
2
|
15
|
../src/base/pdf-fsys-http.c
|
|
|
setmap
|
1
|
2
|
6
|
../src/base/pdf-fp-func.c
|
|
|
pdf_text_utf32he_to_host
|
1
|
2
|
24
|
../src/base/pdf-text-host-encoding.c
|
|
|
pdf_time_add_span
|
1
|
2
|
12
|
../src/base/pdf-time.c
|
|
|
remove_folder
|
1
|
2
|
11
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_stm_tell
|
1
|
2
|
7
|
../src/base/pdf-stm.c
|
|
|
pdf_time_clear
|
1
|
2
|
8
|
../src/base/pdf-time.c
|
|
|
pdf_realloc
|
1
|
2
|
6
|
../src/base/pdf-alloc.c
|
|
|
pdf_text_check_host_encoding
|
1
|
2
|
9
|
../src/base/pdf-text.c
|
|
|
pdf_time_init
|
1
|
2
|
7
|
../src/base/pdf-time.c
|
|
|
pdf_crypt_nonce
|
1
|
2
|
7
|
../src/base/pdf-crypt.c
|
|
|
pdf_text_get_language
|
1
|
2
|
7
|
../src/base/pdf-text.c
|
|
|
pdf_text_get_country
|
1
|
2
|
7
|
../src/base/pdf-text.c
|
|
|
get_folder_contents
|
1
|
2
|
15
|
../src/base/pdf-fsys-http.c
|
|
|
create_folder
|
1
|
2
|
11
|
../src/base/pdf-fsys-http.c
|
|
|
file_open_tmp
|
1
|
2
|
10
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_token_string_new
|
1
|
2
|
13
|
../src/base/pdf-token.c
|
|
|
pdf_tokeniser_get_decimal_point
|
1
|
2
|
7
|
../src/base/pdf-tokeniser.c
|
|
|
pdf_text_filter_remove_line_endings
|
1
|
2
|
11
|
../src/base/pdf-text-filter.c
|
|
|
stm_be_cfile_tell
|
1
|
2
|
7
|
../src/base/pdf-stm-be-cfile.c
|
|
|
pdf_fsys_deinit
|
1
|
2
|
11
|
../src/base/pdf-fsys.c
|
|
|
stm_be_file_tell
|
1
|
2
|
7
|
../src/base/pdf-stm-be-file.c
|
|
|
pdf_stm_get_mode
|
1
|
2
|
7
|
../src/base/pdf-stm.c
|
|
|
stm_be_mem_tell
|
1
|
2
|
7
|
../src/base/pdf-stm-be-mem.c
|
|
|
lzw_buffer_set_bitsize
|
1
|
2
|
7
|
../src/base/pdf-stm-f-lzw.c
|
|
|
enter_state
|
1
|
2
|
7
|
../src/base/pdf-token-reader.c
|
|
|
pdf_error_get_message
|
1
|
2
|
7
|
../src/base/pdf-error.c
|
|
|
set_host_path
|
1
|
2
|
21
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_error_get_domain
|
1
|
2
|
7
|
../src/base/pdf-error.c
|
|
|
file_request_ria
|
1
|
2
|
12
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_error_get_status
|
1
|
2
|
7
|
../src/base/pdf-error.c
|
|
|
pdf_text_detect_host_eol
|
1
|
2
|
23
|
../src/base/pdf-text-context.c
|
|
|
pdf_error_dup
|
1
|
2
|
9
|
../src/base/pdf-error.c
|
|
|
get_path_from_url
|
1
|
2
|
11
|
../src/base/pdf-fsys-disk.c
|
|
|
get_url_from_path
|
1
|
2
|
11
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_token_reader_begin_pos
|
1
|
2
|
7
|
../src/base/pdf-token-reader.c
|
|
|
file_cancel_ria
|
1
|
2
|
11
|
../src/base/pdf-fsys-http.c
|
|
|
file_has_ria
|
1
|
2
|
9
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_set_to_current_utc_time
|
1
|
2
|
7
|
../src/base/pdf-time.c
|
|
|
file_flush
|
1
|
2
|
10
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_set_to_current_local_time
|
1
|
2
|
8
|
../src/base/pdf-time.c
|
|
|
file_write
|
1
|
2
|
13
|
../src/base/pdf-fsys-http.c
|
|
|
file_set_size
|
1
|
2
|
11
|
../src/base/pdf-fsys-http.c
|
|
|
stm_be_file_destroy
|
1
|
1
|
6
|
../src/base/pdf-stm-be-file.c
|
|
|
stm_be_cfile_destroy
|
1
|
1
|
6
|
../src/base/pdf-stm-be-cfile.c
|
|
|
stm_be_mem_destroy
|
1
|
1
|
6
|
../src/base/pdf-stm-be-mem.c
|
|
|
pdf_fp_exp
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
file_can_set_size_p
|
1
|
1
|
7
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_time_context_get_gmt_offset
|
1
|
1
|
5
|
../src/base/pdf-time-context.c
|
|
|
pdf_text_ucd_wb_is_extendnumlet
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_linear_init
|
1
|
1
|
5
|
../src/base/pdf-fp-func.c
|
|
|
pdf_text_ucd_wb_is_numeric
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_midnumlet
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
stm_f_ahex_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-ahex.c
|
|
|
pdf_text_ucd_wb_is_midnum
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_midletter
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_aletter
|
1
|
1
|
7
|
../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
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_format
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_extend
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_newline
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_lf
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_text_ucd_wb_is_cr
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-wordbreak.c
|
|
|
pdf_fp_atan2
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
pdf_hash_add_time
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_fp_cos
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
get_free_space
|
1
|
1
|
8
|
../src/base/pdf-fsys-http.c
|
|
|
item_writable_p
|
1
|
1
|
7
|
../src/base/pdf-fsys-http.c
|
|
|
item_readable_p
|
1
|
1
|
7
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_perror
|
1
|
1
|
6
|
../src/base/pdf-error.c
|
|
|
pdf_fp_sin
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
pdf_hash_get_text
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.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
|
|
|
decode_row_none
|
1
|
1
|
8
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_fp_mod
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
pdf_text_get_host_encoding
|
1
|
1
|
5
|
../src/base/pdf-text.c
|
|
|
stm_f_lzwdec_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_fp_div
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
pdf_time_module_init
|
1
|
1
|
6
|
../src/base/pdf-time.c
|
|
|
stm_f_lzwenc_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_fp_mul
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
pdf_time_cal_span_cmp
|
1
|
14
|
28
|
../src/base/pdf-time.c
|
|
|
pdf_fp_sub
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
hash_element_compare
|
1
|
1
|
6
|
../src/base/pdf-hash.c
|
|
|
stm_f_aesv2dec_apply
|
1
|
1
|
14
|
../src/base/pdf-stm-f-aesv2.c
|
|
|
stm_f_aesv2enc_apply
|
1
|
1
|
14
|
../src/base/pdf-stm-f-aesv2.c
|
|
|
pdf_hash_get_string
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_hash_add_text
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
encode_row_none
|
1
|
1
|
8
|
../src/base/pdf-stm-f-pred.c
|
|
|
pdf_hash_add_static_string
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_fp_func_2_new
|
1
|
13
|
31
|
../src/base/pdf-fp-func.c
|
|
|
pdf_stm_f_ahex_int2hex
|
1
|
1
|
5
|
../src/base/pdf-stm-f-ahex.c
|
|
|
pdf_fp_add
|
1
|
1
|
6
|
../src/base/pdf-fp.c
|
|
|
lzw_dict_reset
|
1
|
1
|
5
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_hash_add_string
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_hash_get_size
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_stm_filter_get_next
|
1
|
1
|
5
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_hash_add_size
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_stm_filter_get_in
|
1
|
1
|
5
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_hash_get_u32
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_stm_filter_set_out
|
1
|
1
|
6
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_stm_filter_set_be
|
1
|
1
|
6
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_text_context_get_host_country
|
1
|
1
|
5
|
../src/base/pdf-text-context.c
|
|
|
pdf_hash_add_u32
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_stm_filter_set_next
|
1
|
1
|
6
|
../src/base/pdf-stm-filter.c
|
|
|
pdf_text_context_get_host_language
|
1
|
1
|
5
|
../src/base/pdf-text-context.c
|
|
|
pdf_hash_get_i32
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
stm_f_v2dec_apply
|
1
|
1
|
14
|
../src/base/pdf-stm-f-v2.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_hash_add_i32
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_text_context_initialized
|
1
|
1
|
5
|
../src/base/pdf-text-context.c
|
|
|
stm_f_v2enc_apply
|
1
|
1
|
14
|
../src/base/pdf-stm-f-v2.c
|
|
|
pdf_hash_get_bool
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
lzw_string_init
|
1
|
1
|
5
|
../src/base/pdf-stm-f-lzw.c
|
|
|
pdf_text_create_word_boundaries_list
|
1
|
1
|
9
|
../src/base/pdf-text.c
|
|
|
fill_input_buffer
|
1
|
1
|
6
|
../src/base/pdf-stm-f-dct.c
|
|
|
pdf_hash_add_bool
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_fsys_disk_deinit
|
1
|
1
|
5
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_get_stm
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_text_filter_title_case
|
1
|
1
|
8
|
../src/base/pdf-text-filter.c
|
|
|
get_mode_string
|
1
|
1
|
5
|
../src/base/pdf-fsys-disk.c
|
|
|
write_char
|
1
|
1
|
7
|
../src/base/pdf-token-writer.c
|
|
|
pdf_hash_add_stm
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_text_filter_lower_case
|
1
|
1
|
8
|
../src/base/pdf-text-filter.c
|
|
|
pdf_hash_get_hash
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_text_filter_upper_case
|
1
|
1
|
8
|
../src/base/pdf-text-filter.c
|
|
|
file_cancel_ria
|
1
|
1
|
10
|
../src/base/pdf-fsys-disk.c
|
|
|
file_has_ria
|
1
|
1
|
7
|
../src/base/pdf-fsys-disk.c
|
|
|
pdf_hash_add_hash
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_hash_get_list
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_hash_add_list
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_text_init
|
1
|
1
|
6
|
../src/base/pdf-text.c
|
|
|
pdf_hash_get_time
|
1
|
1
|
6
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_fp_ceil
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
pdf_text_get_unicode_encoding_name
|
1
|
1
|
5
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_text_ucd_pl_is_Soft_Dotted
|
1
|
1
|
7
|
../src/base/pdf-text-ucd-proplist.c
|
|
|
pdf_text_get_unicode_bom
|
1
|
1
|
5
|
../src/base/pdf-text-encoding.c
|
|
|
pdf_fsys_http_deinit
|
1
|
1
|
5
|
../src/base/pdf-fsys-http.c
|
|
|
pdf_fp_floor
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
pdf_hash_add_static_time
|
1
|
1
|
12
|
../src/base/pdf-hash-helper.c
|
|
|
pdf_fp_log
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
stm_f_rl_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-rl.c
|
|
|
pdf_fp_log10
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
stm_f_flate_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-flate.c
|
|
|
pdf_fp_abs
|
1
|
1
|
5
|
../src/base/pdf-fp.c
|
|
|
stm_f_a85_deinit
|
1
|
1
|
5
|
../src/base/pdf-stm-f-a85.c
|
|
|
pdf_time_deinit
|
1
|
0
|
5
|
../src/base/pdf-time.c
|
|
|
term_source
|
1
|
0
|
5
|
../src/base/pdf-stm-f-dct.c
|
|
|
init_source
|
1
|
0
|
5
|
../src/base/pdf-stm-f-dct.c
|