/*
- * "$Id: accept.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: accept.c 5104 2006-02-15 03:21:04Z mike $"
*
* "accept", "disable", "enable", and "reject" commands for the Common
* UNIX Printing System (CUPS).
ipp_t *request; /* IPP request */
ipp_t *response; /* IPP response */
ipp_op_t op; /* Operation */
- cups_lang_t *language; /* Language */
int cancel; /* Cancel jobs? */
else
command = argv[0];
- cancel = 0;
- language = cupsLangDefault();
+ cancel = 0;
if (!strcmp(command, "accept"))
op = CUPS_ACCEPT_JOBS;
else if (!strcmp(command, "reject"))
op = CUPS_REJECT_JOBS;
- else if (!strcmp(command, "disable"))
+ else if (!strcmp(command, "cupsdisable") || !strcmp(command, "disable"))
op = IPP_PAUSE_PRINTER;
- else if (!strcmp(command, "enable"))
+ else if (!strcmp(command, "cupsenable") || !strcmp(command, "enable"))
op = IPP_RESUME_PRINTER;
else
{
- _cupsLangPrintf(stderr, language, _("%s: Don't know what to do!\n"),
+ _cupsLangPrintf(stderr, _("%s: Don't know what to do!\n"),
command);
return (1);
}
if (http)
httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
- _cupsLangPrintf(stderr, language,
+ _cupsLangPrintf(stderr,
_("%s: Sorry, no encryption support compiled in!\n"),
command);
#endif /* HAVE_SSL */
break;
+ case 'U' : /* Username */
+ if (argv[i][2] != '\0')
+ cupsSetUser(argv[i] + 2);
+ else
+ {
+ i ++;
+ if (i >= argc)
+ {
+ _cupsLangPrintf(stderr,
+ _("%s: Error - expected username after "
+ "\'-U\' option!\n"),
+ command);
+ return (1);
+ }
+
+ cupsSetUser(argv[i]);
+ }
+ break;
+
case 'c' : /* Cancel jobs */
cancel = 1;
break;
i ++;
if (i >= argc)
{
- _cupsLangPrintf(stderr, language,
- _("%s: Expected server name after -h!\n"),
+ _cupsLangPrintf(stderr,
+ _("%s: Error - expected hostname after "
+ "\'-h\' option!\n"),
command);
return (1);
}
i ++;
if (i >= argc)
{
- _cupsLangPrintf(stderr, language,
- _("%s: Expected reason text after -r!\n"),
+ _cupsLangPrintf(stderr,
+ _("%s: Error - expected reason text after "
+ "\'-r\' option!\n"),
command);
return (1);
}
break;
default :
- _cupsLangPrintf(stderr, language, _("%s: Unknown option \'%c\'!\n"),
+ _cupsLangPrintf(stderr, _("%s: Error - unknown option \'%c\'!\n"),
command, argv[i][1]);
return (1);
}
if (http == NULL)
{
- _cupsLangPrintf(stderr, language,
+ _cupsLangPrintf(stderr,
_("%s: Unable to connect to server: %s\n"),
command, strerror(errno));
return (1);
* printer-state-message [optional]
*/
- request = ippNew();
-
- request->request.op.operation_id = op;
- request->request.op.request_id = 1;
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, cupsLangEncoding(language));
+ request = ippNewRequest(op);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL, language->language);
-
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", argv[i]);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", argv[i]);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ "requesting-user-name", NULL, cupsUser());
+
if (reason != NULL)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_TEXT,
"printer-state-message", NULL, reason);
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, language,
+ _cupsLangPrintf(stderr,
_("%s: Operation failed: %s\n"),
command, ippErrorString(cupsLastError()));
return (1);
}
else
{
- _cupsLangPrintf(stderr, language,
- _("%s: Operation failed: %s\n"),
- command, ippErrorString(cupsLastError()));
+ _cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
return (1);
}
* printer-uri
*/
- request = ippNew();
-
- request->request.op.operation_id = IPP_PURGE_JOBS;
- request->request.op.request_id = 1;
-
- language = cupsLangDefault();
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, cupsLangEncoding(language));
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL, language->language);
+ request = ippNewRequest(IPP_PURGE_JOBS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, language,
- _("%s: Operation failed: %s\n"),
- command, ippErrorString(cupsLastError()));
+ _cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
return (1);
}
}
else
{
- _cupsLangPrintf(stderr, language,
- _("%s: Operation failed: %s\n"),
- command, ippErrorString(cupsLastError()));
+ _cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
return (1);
}
}
/*
- * End of "$Id: accept.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: accept.c 5104 2006-02-15 03:21:04Z mike $".
*/