static void dump_sue(dump *ctx, type *ty) { struct_union_enum_st *sue = type_is_s_or_u_or_e(ty); sue_member **mi; if(!sue) return; dump_inc(ctx); for(mi = sue->members; mi && *mi; mi++){ if(sue->primitive == type_enum){ enum_member *emem = (*mi)->enum_member; dump_desc(ctx, emem->spel, emem, &emem->where); if(emem->val && emem->val != (expr *)-1){ dump_inc(ctx); dump_expr(emem->val, ctx); dump_dec(ctx); } dump_attributes(emem->attr, ctx); }else{ decl *d = (*mi)->struct_member; dump_decl(d, ctx, "member"); dump_sue(ctx, d->ref); } } dump_dec(ctx); }
/* LCD Output: 1 Descriptor -> 1 Framebuffer. */ static int lcd_output_desc_attach(struct jz_fb_win_info *win, void *mem) { /* Get new descriptor. */ struct jz_fb_dma_desc *desc = dma_desc_get(win); struct jz_fb_win_attr_info *a = &win->attr; D("Called."); if (!desc) { return -ENOMEM; } dma_desc_init(desc); /* Attach framebuffer to desciptors. */ dma_desc_set_mem(desc, mem); dma_desc_set_data_size(desc, win->fb_frame_len); dma_desc_set_area_size(desc, a->w, a->h); dma_desc_add_to_chain(desc); dump_desc(desc); return 0; }
static void dump_gasm(symtable_gasm *gasm, dump *ctx) { dump_desc(ctx, "global asm", gasm, &gasm->where); dump_inc(ctx); dump_strliteral(ctx, gasm->asm_str, strlen(gasm->asm_str)); dump_dec(ctx); }
void dump_desc(pst_desc_tree *ptr) { while (ptr) { DEBUG_INFO(("\n\n\nLooking at block desc id %#"PRIx64"\n", ptr->d_id)); if (ptr->desc && ptr->desc->i_id) dumper(ptr->desc->i_id); if (ptr->assoc_tree && ptr->assoc_tree->i_id) dumper(ptr->assoc_tree->i_id); if (ptr->child) dump_desc(ptr->child); ptr = ptr->next; } }
void dump_desc(pst_desc_tree *ptr, pst_desc_tree *parent) { while (ptr) { uint64_t parent_d_id = (parent) ? parent->d_id : 0; printf("Descriptor block d_id %#"PRIx64" parent d_id %#"PRIx64" children %i desc.i_id=%#"PRIx64", assoc tree.i_id=%#"PRIx64"\n", ptr->d_id, parent_d_id, ptr->no_child, (ptr->desc ? ptr->desc->i_id : (uint64_t)0), (ptr->assoc_tree ? ptr->assoc_tree->i_id : (uint64_t)0)); if (ptr->desc && ptr->desc->i_id) dumper(ptr->desc->i_id); if (ptr->assoc_tree && ptr->assoc_tree->i_id) dumper(ptr->assoc_tree->i_id); if (ptr->child) dump_desc(ptr->child, ptr); ptr = ptr->next; } }
void dump_init(dump *ctx, decl_init *dinit) { if(dinit == DYNARRAY_NULL){ dump_printf(ctx, "<null init>\n"); return; } switch(dinit->type){ case decl_init_scalar: { dump_expr(dinit->bits.expr, ctx); break; } case decl_init_brace: { decl_init **i; dump_desc(ctx, "brace init", dinit, &dinit->where); dump_inc(ctx); for(i = dinit->bits.ar.inits; i && *i; i++) dump_init(ctx, *i); dump_dec(ctx); break; } case decl_init_copy: { struct init_cpy *cpy = *dinit->bits.range_copy; dump_init(ctx, cpy->range_init); break; } } }
int main(int argc, char* const* argv) { // pass the id number to display on the command line char *fname, *sid; uint64_t i_id; int c; DEBUG_INIT("getidblock.log", NULL); DEBUG_ENT("main"); while ((c = getopt(argc, argv, "bp")) != -1) { switch (c) { case 'b': // enable binary output binary = 1; break; case 'p': // enable procesing of block process = 1; break; default: usage(); exit(EXIT_FAILURE); } } if (optind + 1 >= argc) { // no more items on the cmd usage(); exit(EXIT_FAILURE); } fname = argv[optind]; sid = argv[optind + 1]; i_id = (uint64_t)strtoll(sid, NULL, 0); DEBUG_INFO(("Opening file\n")); memset(&pstfile, 0, sizeof(pstfile)); if (pst_open(&pstfile, fname, NULL)) { DIE(("Error opening file\n")); } DEBUG_INFO(("Loading Index\n")); if (pst_load_index(&pstfile) != 0) { DIE(("Error loading file index\n")); } if (i_id) { dumper(i_id); } else { size_t i; for (i = 0; i < pstfile.i_count; i++) { dumper(pstfile.i_table[i].i_id); } dump_desc(pstfile.d_head, NULL); } if (pst_close(&pstfile) != 0) { DIE(("pst_close failed\n")); } DEBUG_RET(); return 0; }
static void* sane_idainit(FILE *fp, char *filename, unsigned int page, struct ida_image_info *info, int thumbnail) { const SANE_Option_Descriptor *opt; SANE_Int flags, count; struct sane_state *h; int rc,i,value,dpi = 0; h = malloc(sizeof(*h)); memset(h,0,sizeof(*h)); if (SANE_STATUS_GOOD != (rc = sane_init(NULL,NULL))) { fprintf(stderr,"sane_init: %s\n",sane_strstatus(rc)); goto oops; } if (SANE_STATUS_GOOD != (rc = sane_open(filename,&h->sane))) { fprintf(stderr,"sane_open: %s\n",sane_strstatus(rc)); goto oops; } /* set options */ opt = sane_get_option_descriptor(h->sane,0); rc = sane_control_option(h->sane, 0, SANE_ACTION_GET_VALUE, &count, &flags); for (i = 1; i < count; i++) { opt = sane_get_option_descriptor(h->sane,i); if (opt->name && 0 == strcmp(opt->name,SANE_NAME_SCAN_TL_X)) { value = opt->constraint.range->min; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &value, &flags); } else if (opt->name && 0 == strcmp(opt->name,SANE_NAME_SCAN_TL_Y)) { value = opt->constraint.range->min; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &value, &flags); } else if (opt->name && 0 == strcmp(opt->name,SANE_NAME_SCAN_BR_X)) { value = opt->constraint.range->max; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &value, &flags); } else if (opt->name && 0 == strcmp(opt->name,SANE_NAME_SCAN_BR_Y)) { value = opt->constraint.range->max; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &value, &flags); } else if (opt->name && 0 == strcmp(opt->name,SANE_NAME_PREVIEW)) { value = SANE_FALSE; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &value, &flags); } else if (opt->cap & SANE_CAP_AUTOMATIC) sane_control_option(h->sane, i, SANE_ACTION_SET_AUTO, NULL, &flags); if (opt->name && 0 == strcmp(opt->name,SANE_NAME_SCAN_RESOLUTION)) { if (sane_res) { dpi = sane_res; sane_control_option(h->sane, i, SANE_ACTION_SET_VALUE, &dpi, &flags); } sane_control_option(h->sane, i, SANE_ACTION_GET_VALUE, &dpi, &flags); } if (debug) dump_desc(h->sane,i,opt); } if (SANE_STATUS_GOOD != (rc = sane_start(h->sane))) { fprintf(stderr,"sane_start: %s\n",sane_strstatus(rc)); goto oops; } h->started = 1; if (SANE_STATUS_GOOD != (rc = sane_get_parameters(h->sane,&h->parm))) { fprintf(stderr,"sane_get_parameters: %s\n",sane_strstatus(rc)); goto oops; } if (h->parm.format != SANE_FRAME_GRAY && h->parm.format != SANE_FRAME_RGB) { fprintf(stderr,"sane: unsupported frame format (%d)\n",h->parm.format); goto oops; } if (h->parm.depth != 8) { fprintf(stderr,"sane: unsupported color depth (%d)\n",h->parm.depth); goto oops; } if (-1 == h->parm.lines) { fprintf(stderr,"sane: can't handle unknown image size\n"); goto oops; } info->width = h->parm.pixels_per_line; info->height = h->parm.lines; if (dpi) info->dpi = dpi; h->buf = malloc(h->parm.bytes_per_line * BUF_LINES); if (debug) fprintf(stderr,"sane: scanning %dx%d %s\n",info->width,info->height, (h->parm.format == SANE_FRAME_GRAY) ? "gray" : "color"); return h; oops: if (h->buf) free(h->buf); if (h->started) sane_cancel(h->sane); if (h->sane) sane_close(h->sane); sane_exit(); free(h); return NULL; }