char* cngplpIDtoKey(int id) { char *ret = NULL; if(id < ID_DEVICE_INFO){ ret = ToChar(IDtoPPDOption(id - 1)); }else if(id < ID_COMMON_OPTION){ ret = ToChar(IDtoDevOption(id)); }else if(id < ID_IMAGE_OPTION){ ret = ToChar(IDtoCommonOption(id - ID_COMMON_OPTION - 1)); }else if(id < ID_TEXT_OPTION){ ret = ToChar(IDtoImageOption(id - ID_IMAGE_OPTION - 1)); }else if(id < ID_HPGL_OPTION){ ret = ToChar(IDtoTextOption(id - ID_TEXT_OPTION - 1)); }else if(id < ID_BOTTON_EVENT){ ret = ToChar(IDtoHPGLOption(id - ID_HPGL_OPTION - 1)); } return ret; }
char* GetDataCommonOption(cngplpData *data, int id) { char *list = NULL; int i; char curr[256]; char *option = NULL; int index = id - ID_COMMON_OPTION - 1; option = IDtoCommonOption(index); memset(curr, 0, 255); switch(id){ case ID_PRINTERNAME: snprintf(curr, 255, "%s:%s<0>", data->curr_printer, data->printer_names[0]); list = AddList(list, curr); for(i = 1; i < data->printer_num; i++){ char tmp[256]; memset(tmp, 0, 255); snprintf(tmp, 255, "%s<0>", data->printer_names[i]); list = AddList(list, tmp); } break; case ID_NUMBER_UP: snprintf(curr, 255, "%s:%s<0>", GetCupsValue(data->cups_opt->common->option, "number-up"), NupTextValue_table[0].text); list = AddList(list, curr); for(i = 1; NupTextValue_table[i].text != NULL; i++){ char tmp[256]; memset(tmp, 0, 255); snprintf(tmp, 255, "%s<0>", NupTextValue_table[i].text); list = AddList(list, tmp); } break; case ID_FILTER: snprintf(curr, 255, "%s:%s<0>", GetCupsValue(data->cups_opt->common->option, "Filter"), g_filter_options[0]); list = AddList(list, curr); for(i = 1; g_filter_options[i] != NULL; i++){ char tmp[256]; memset(tmp, 0, 255); snprintf(tmp, 255, "%s<0>", g_filter_options[i]); list = AddList(list, tmp); } break; case ID_JOB_SHEETS_START: snprintf(curr, 255, "%s:%s<0>", GetCupsValue(data->cups_opt->common->option, "job-sheets-start"), g_banner_option[0]); list = AddList(list, curr); for(i = 1; g_banner_option[i] != NULL; i++){ char tmp[256]; memset(tmp, 0, 255); snprintf(tmp, 255, "%s<0>", g_banner_option[i]); list = AddList(list, tmp); } break; case ID_JOB_SHEETS_END: snprintf(curr, 255, "%s:%s<0>", GetCupsValue(data->cups_opt->common->option, "job-sheets-end"), g_banner_option[0]); list = AddList(list, curr); for(i = 1; g_banner_option[i] != NULL; i++){ char tmp[256]; memset(tmp, 0, 255); snprintf(tmp, 255, "%s<0>", g_banner_option[i]); list = AddList(list, tmp); } break; default: if(option != NULL) return ToChar(GetCupsValue(data->cups_opt->common->option, option)); break; } return list; }