void ofxCUPS::updatePrinterInfo() { cups_dest_t *dests; int num_dests = cupsGetDests(&dests); cups_dest_t *dest = cupsGetDest(printerName.c_str(), NULL, num_dests, dests); const char *value; value = cupsGetOption("printer-state", dest->num_options, dest->options); // printf("%s printer-state: %s\n", dest->name, value ? value : "no description"); setPrinterState(ofToInt(value)); value = cupsGetOption("printer-state-reasons", dest->num_options, dest->options); // printf("%s printer-state-reasons: %s\n", dest->name, value ? value : "(no description)"); setPrinterInfo(ofToString(value)); cupsFreeDests(num_dests, dests); }
void ofxCUPS::updatePrinterInfo() { cups_dest_t *dests; int num_dests = cupsGetDests(&dests); cups_dest_t *dest = NULL; dest = cupsGetDest(printerName.c_str(), NULL, num_dests, dests); if ( dest == NULL) { ofLogError() << "NO PRINTER - PRINTER NAME >> [" << printerName << "]" <<endl; return; } const char *value; value = cupsGetOption("printer-state", dest->num_options, dest->options); // printf("%s printer-state: %s\n", dest->name, value ? value : "no description"); setPrinterState(ofToInt(value)); value = cupsGetOption("printer-state-reasons", dest->num_options, dest->options); // printf("%s printer-state-reasons: %s\n", dest->name, value ? value : "(no description)"); setPrinterInfo(ofToString(value)); cupsFreeDests(num_dests, dests); }
int simulatorControl ( ) { char inputChar; refreshScreen(); inputChar = getchar(); while (inputChar != EOF) { /*if (scanf("%c",&inputChar) < 0) { perror("Simulator input error:"); }*/ switch(inputChar) { case ADD_ONE_CORRECT_PRODUCT : addProducts(1, TRUE); break; case ADD_MANY_CORRECT_PRODUCTS : addProducts(MANY_MEANING, TRUE); break; case ADD_ONE_DEFECTIVE_PRODUCT : addProducts(1, FALSE); break; case ADD_MANY_DEFECTIVE_PRODUCTS : addProducts(MANY_MEANING, FALSE); break; case EMERGENCY_STOP : EmergencyStopHandler(); break; case TOGGLE_MISSING_BOX : if (boxMissing()) { setBoxMissing(FALSE); } else { setBoxMissing(TRUE); } break; case TOGGLE_PRINTR1_BROKEN : if (printerState(PRINTR1)) { setPrinterState(PRINTR1,FALSE); } else { setPrinterState(PRINTR1,TRUE); } break; case TOGGLE_PRINTR2_BROKEN : if (printerState(PRINTR2)) { setPrinterState(PRINTR2,FALSE); } else { setPrinterState(PRINTR2,TRUE); } break; case REFRESH : default : break; } refreshScreen(); inputChar = getchar(); } return 0; }