Lines Matching refs:state
377 static struct code128_step * code128_alloc_step(struct code128_state * state) in code128_alloc_step() argument
379 if(state->todo_ix >= state->allocated_steps) { in code128_alloc_step()
380 state->allocated_steps += 1024; in code128_alloc_step()
381 state->steps = (struct code128_step *) CODE128_REALLOC(state->steps, in code128_alloc_step()
382 … state->allocated_steps * sizeof(struct code128_step)); in code128_alloc_step()
385 struct code128_step * step = &state->steps[state->todo_ix]; in code128_alloc_step()
391 static void code128_do_step(struct code128_state * state) in code128_do_step() argument
393 struct code128_step * step = &state->steps[state->current_ix]; in code128_do_step()
396 if((step->len < state->maxlength) || in code128_do_step()
397 (state->best_ix < 0 && step->len == state->maxlength)) { in code128_do_step()
398 state->best_ix = state->current_ix; in code128_do_step()
401 state->maxlength = step->len; in code128_do_step()
408 if(step->len >= state->maxlength) in code128_do_step()
412 code128_alloc_step(state); in code128_do_step()
416 if(code128_do_c_step(state->steps, state->current_ix, state->todo_ix)) { in code128_do_step()
417 state->todo_ix++; in code128_do_step()
418 code128_alloc_step(state); in code128_do_step()
425 if(code128_do_a_step(state->steps, state->current_ix, state->todo_ix) || in code128_do_step()
426 code128_do_b_step(state->steps, state->current_ix, state->todo_ix)) in code128_do_step()
427 state->todo_ix++; in code128_do_step()
432 if(code128_do_b_step(state->steps, state->current_ix, state->todo_ix) || in code128_do_step()
433 code128_do_a_step(state->steps, state->current_ix, state->todo_ix)) in code128_do_step()
434 state->todo_ix++; in code128_do_step()
443 if(code128_do_a_step(state->steps, state->current_ix, state->todo_ix)) { in code128_do_step()
444 state->todo_ix++; in code128_do_step()
445 code128_alloc_step(state); in code128_do_step()
447 if(code128_do_b_step(state->steps, state->current_ix, state->todo_ix)) in code128_do_step()
448 state->todo_ix++; in code128_do_step()
454 struct code128_state state; in code128_encode_raw() local
466 state.allocated_steps = 256; in code128_encode_raw()
467 …state.steps = (struct code128_step *) CODE128_MALLOC(state.allocated_steps * sizeof(struct code128… in code128_encode_raw()
468 state.current_ix = 0; in code128_encode_raw()
469 state.todo_ix = 0; in code128_encode_raw()
470 state.maxlength = maxlength - overhead; in code128_encode_raw()
471 state.best_ix = -1; in code128_encode_raw()
474 state.steps[0].prev_ix = -1; in code128_encode_raw()
475 state.steps[0].next_input = s; in code128_encode_raw()
476 state.steps[0].len = CODE128_CHAR_LEN; in code128_encode_raw()
477 state.steps[0].mode = CODE128_MODE_C; in code128_encode_raw()
478 state.steps[0].code = CODE128_START_CODE_C; in code128_encode_raw()
480 state.steps[1].prev_ix = -1; in code128_encode_raw()
481 state.steps[1].next_input = s; in code128_encode_raw()
482 state.steps[1].len = CODE128_CHAR_LEN; in code128_encode_raw()
483 state.steps[1].mode = CODE128_MODE_A; in code128_encode_raw()
484 state.steps[1].code = CODE128_START_CODE_A; in code128_encode_raw()
486 state.steps[2].prev_ix = -1; in code128_encode_raw()
487 state.steps[2].next_input = s; in code128_encode_raw()
488 state.steps[2].len = CODE128_CHAR_LEN; in code128_encode_raw()
489 state.steps[2].mode = CODE128_MODE_B; in code128_encode_raw()
490 state.steps[2].code = CODE128_START_CODE_B; in code128_encode_raw()
492 state.todo_ix = 3; in code128_encode_raw()
496 code128_do_step(&state); in code128_encode_raw()
497 state.current_ix++; in code128_encode_raw()
498 } while(state.current_ix != state.todo_ix); in code128_encode_raw()
501 if(state.best_ix < 0) { in code128_encode_raw()
502 CODE128_FREE(state.steps); in code128_encode_raw()
507 size_t num_codes = state.maxlength / CODE128_CHAR_LEN; in code128_encode_raw()
511 struct code128_step * step = &state.steps[state.best_ix]; in code128_encode_raw()
514 struct code128_step * prev_step = &state.steps[step->prev_ix]; in code128_encode_raw()
525 size_t actual_length = state.maxlength + overhead; in code128_encode_raw()
542 CODE128_FREE(state.steps); in code128_encode_raw()