int cngplpInitOptions(cngplpData *data) { cups_dest_t *all_dests; cups_dest_t *curr_dest; int num; num = cupsGetDests(&all_dests); if(data->curr_printer == NULL) return -1; curr_dest = cupsGetDest(data->curr_printer, NULL, num, all_dests); if(curr_dest == NULL) return -1; data->cups_opt = (CupsOptions *)malloc(sizeof(CupsOptions)); if(data->cups_opt == NULL) return -1; if(CreateCupsOptions(data) < 0){ MemFree(data->cups_opt); return -1; } SetCupsStoreOption(data, curr_dest); data->ppd_opt = (PPDOptions *)malloc(sizeof(PPDOptions)); if(data->ppd_opt == NULL){ DeleteCupsOptions(data->cups_opt); return -1; } if(CreatePPDOptions(data) < 0){ DeleteCupsOptions(data->cups_opt); DeletePPDOptions(data); return -1; } if(data->ppdfile){ SetPPDStoreOption(data, curr_dest); } if(data->ppd_opt->uivalue != NULL){ SetPPDStoreUIValue(data, curr_dest); } if(CreateSaveOptions(data) < 0){ DeleteCupsOptions(data->cups_opt); DeletePPDOptions(data); return -1; } cupsFreeDests(num, all_dests); return 0; }
void cngplpFreeOptions(cngplpData *data) { if(data) { DeleteSaveOptions(data); DeleteCupsOptions(data->cups_opt); DeletePPDOptions(data); data->cups_opt = NULL; data->ppd_opt = NULL; } }