static void update_button_state (pixma_sane_t * ss, SANE_Int * info) { SANE_Int b1 = OVAL (opt_button_1).w; SANE_Int b2 = OVAL (opt_button_2).w; uint32_t ev = pixma_wait_event (ss->s, 300); switch (ev & ~PIXMA_EV_ACTION_MASK) { case PIXMA_EV_BUTTON1: b1 = 1; break; case PIXMA_EV_BUTTON2: b2 = 1; break; } if (b1 != OVAL (opt_button_1).w || b2 != OVAL (opt_button_2).w) { *info |= SANE_INFO_RELOAD_OPTIONS; OVAL (opt_button_1).w = b1; OVAL (opt_button_2).w = b2; OVAL (opt_original).w = GET_EV_ORIGINAL(ev); OVAL (opt_target).w = GET_EV_TARGET(ev); } mark_all_button_options_cached(ss); }
void vset (object_t * vo, size_t i, object_t * val) { vector_t *v = OVAL (vo); object_t *o = v->v[i]; v->v[i] = val; obj_destroy (o); }
object_t *vget_check (object_t * vo, object_t * io) { int i = into2int (io); vector_t *v = OVAL (vo); if (i < 0 || i >= (int) v->len) THROW (out_of_bounds, UPREF (io)); return UPREF (vget (vo, i)); }
uint32_t vector_hash (object_t * o) { uint32_t accum = 0; vector_t *v = OVAL (o); size_t i; for (i = 0; i < v->len; i++) accum ^= obj_hash (v->v[i]); return accum; }
object_t *vector_sub (object_t * vo, int start, int end) { vector_t *v = OVAL (vo); if (end == -1) end = v->len - 1; object_t *newv = c_vec (1 + end - start, NIL); int i; for (i = start; i <= end; i++) vset (newv, i - start, UPREF (vget (vo, i))); return newv; }
object_t *c_vec (size_t len, object_t * init) { object_t *o = obj_create (VECTOR); vector_t *v = OVAL (o); v->len = len; if (len == 0) len = 1; v->v = xmalloc (sizeof (object_t **) * len); size_t i; for (i = 0; i < v->len; i++) v->v[i] = UPREF (init); return o; }
void vec_print (object_t * vo) { vector_t *v = OVAL (vo); if (v->len == 0) { printf ("[]"); return; } printf ("["); size_t i; for (i = 0; i < v->len - 1; i++) { obj_print (v->v[i], 0); printf (" "); } obj_print (v->v[v->len - 1], 0); printf ("]"); }
static unsigned long pp_char(char *c, char *refc) { unsigned long r = 0; c ++; if (*c == '\\') { int i; c ++; switch (*c) { case 'n': r = '\n'; c ++; break; case 't': r = '\t'; c ++; break; case 'v': r = '\v'; c ++; break; case 'b': r = '\b'; c ++; break; case 'r': r = '\r'; c ++; break; case 'f': r = '\f'; c ++; break; case 'a': r = '\a'; c ++; break; case '\\': r = '\\'; c ++; break; case '\?': r = '\?'; c ++; break; case '\'': r = '\''; c ++; break; case '\"': r = '\"'; c ++; break; case 'u': for (i = 0, c ++; i < 4 && HEXAD(*c); i ++, c ++) { r = (r * 16) + HVAL(*c); } if (i != 4) { error(eval_line, "malformed UCN in %s", refc); throw(eval_exception); } break; case 'U': for (i = 0, c ++; i < 8 && HEXAD(*c); i ++, c ++) { r = (r * 16) + HVAL(*c); } if (i != 8) { error(eval_line, "malformed UCN in %s", refc); throw(eval_exception); } break; case 'x': for (c ++; HEXAD(*c); c ++) r = (r * 16) + HVAL(*c); break; default: if (OCTAL(*c)) { r = OVAL(*(c ++)); if (OCTAL(*c)) r = (r * 8) + OVAL(*(c ++)); if (OCTAL(*c)) r = (r * 8) + OVAL(*(c ++)); } else { error(eval_line, "invalid escape sequence " "'\\%c'", *c); throw(eval_exception); } } } else if (*c == '\'') { error(eval_line, "empty character constant"); throw(eval_exception); } else { r = *((unsigned char *)(c ++)); } if (transient_characters && r < 256) { r = transient_characters[(size_t)r]; } if (*c != '\'' && emit_eval_warnings) { warning(eval_line, "multicharacter constant"); } return r; }
object_t *vget (object_t * vo, size_t i) { vector_t *v = OVAL (vo); return v->v[i]; }