int main(int argc,char **argv){ setlocale(LC_ALL,""); int section; int opt; while((opt=getopt(argc,argv,"d:t:")) != -1){ switch(opt){ case 'd': section=hexstr2i(optarg); if(section>=0){ show_section(section); } else { wprintf(L"wrong number, must in range 0x00 ~ 0xff\n"); } return 0; case 't': decode_and_print(optarg); return 0; } } for(int i=0;i<256;i++){ show_section(i); } }
static int show_widget (CmdConfig *cmd_config, CameraWidget *widget) { CameraWidget *parent; CameraWidgetType type; CHECK (gp_widget_get_type (widget, &type)); switch (type) { case GP_WIDGET_WINDOW: case GP_WIDGET_SECTION: CHECK (show_section (cmd_config, widget)); break; case GP_WIDGET_DATE: CHECK (show_date (cmd_config, widget)); CHECK (show_time (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_MENU: case GP_WIDGET_RADIO: CHECK (show_radio (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_RANGE: CHECK (show_range (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_TEXT: CHECK (show_text (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; case GP_WIDGET_TOGGLE: CHECK (show_toggle (cmd_config, widget)); CHECK (gp_widget_get_parent (widget, &parent)); CHECK (show_widget (cmd_config, parent)); break; default: return (GP_ERROR_NOT_SUPPORTED); } return (GP_OK); }
int main(int argc, char **argv) { int ret = 0; parse_opts(argc, argv); input_file = argv[optind++]; if(input_file == NULL || strcmp(input_file, "-") == 0) { ini = mini_finit(stdin); input_file = "<stdin>"; } else { ini = mini_init(input_file); } if(!ini) { ret = 1; goto cleanup; } for(; optind < argc; optind++) { directives = alpm_list_add(directives, argv[optind]); } if(alpm_list_count(directives) != 1) { verbose = 1; } if(section_list) { list_sections(); } else if(section_name) { show_section(); } else { show_directives(); } if(!ini->eof) { fprintf(stderr, "error reading '%s' (%s)\n", argv[1], strerror(errno)); return 1; } cleanup: cleanup(); return ret; }
static void show(char *data, const char *mib) { size_t reclen, seclen; if (mib != NULL) printf("<!-- MIB: %s -->\n", mib); printf("<record>\n"); reclen = show_header((void*)data) - sizeof(struct mca_record_header); data += sizeof(struct mca_record_header); while (reclen > sizeof(struct mca_section_header)) { seclen = show_section((void*)data); reclen -= seclen; data += seclen; } printf("</record>\n"); }
int look_map(int cn,int x,int y) { int dir,m; if (cn<1 || cn>=MAXCHARS) { error=ERR_ILLEGAL_CHARNO; return 0; } if (ch[cn].flags&(CF_DEAD)) { error=ERR_DEAD; return 0; } if (x<1 || y<1 || x>=MAXMAP || y>=MAXMAP) { error=ERR_ILLEGAL_COORDS; return 0; } m=x+y*MAXMAP; dir=offset2dx(ch[cn].x,ch[cn].y,x,y); if (dir) turn(cn,dir); if (!los_can_see(cn,ch[cn].x,ch[cn].y,x,y,DIST)) { log_char(cn,LOG_SYSTEM,0,"Too far away or hidden."); return 0; } show_section(x,y,cn); if (map[m].flags&MF_RESTAREA) { log_char(cn,LOG_SYSTEM,0,"This place is a rest area."); } if (map[m].flags&MF_CLAN) { log_char(cn,LOG_SYSTEM,0,"This is a clan area."); } if (map[m].flags&MF_ARENA) { log_char(cn,LOG_SYSTEM,0,"This place is an arena."); } if (map[m].flags&MF_PEACE) { log_char(cn,LOG_SYSTEM,0,"This place is a peaceful zone."); } //log_char(cn,LOG_SYSTEM,0,"Light=%d.",map[m].light); return 1; }