int main(int ac, char *av[]) { papi_status_t status; papi_service_t svc = NULL; papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; char *printer = NULL; int c; (void) setlocale(LC_ALL, ""); (void) textdomain("SUNW_OST_OSCMD"); while ((c = getopt(ac, av, "EP:")) != EOF) switch (c) { case 'E': encryption = PAPI_ENCRYPT_REQUIRED; break; case 'P': printer = optarg; break; default: usage(av[0]); } if ((printer == NULL) && ((printer = getenv("PRINTER")) == NULL) && ((printer = getenv("LPDEST")) == NULL)) printer = DEFAULT_DEST; status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, encryption, NULL); if (status != PAPI_OK) { fprintf(stderr, gettext( "Failed to contact service for %s: %s\n"), printer, verbose_papi_message(svc, status)); papiServiceDestroy(svc); return (1); } berkeley_cancel_request(svc, stdout, printer, ac - optind, &av[optind]); papiServiceDestroy(svc); return (0); }
int cancel_jobs_for_user(char *user, papi_encryption_t encryption, char *pname) { papi_status_t status; papi_service_t svc = NULL; char **printers = NULL; int i, exit_code; if (pname == NULL) { status = papiServiceCreate(&svc, NULL, NULL, NULL, cli_auth_callback, encryption, NULL); printers = interest_list(svc); papiServiceDestroy(svc); } else { list_append(&printers, strdup(pname)); } if (printers == NULL) exit(0); for (i = 0; printers[i] != NULL; i++) { char *printer = printers[i]; status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback, encryption, NULL); if (status != PAPI_OK) { fprintf(stderr, gettext( "Failed to contact service for %s: %s\n"), printer, verbose_papi_message(svc, status)); exit(1); } exit_code = berkeley_cancel_request(svc, stdout, printer, 1, &user); papiServiceDestroy(svc); if (exit_code != 0) break; } free(printers); return (exit_code); }