/*
- * "$Id: accept.c,v 1.11.2.6 2002/05/16 14:00:17 mike Exp $"
+ * "$Id: accept.c,v 1.11.2.7 2002/08/22 01:43:39 mike Exp $"
*
* "accept", "disable", "enable", and "reject" commands for the Common
* UNIX Printing System (CUPS).
http_t *http; /* HTTP connection to server */
int i; /* Looping var */
char *command, /* Command to do */
- hostname[HTTP_MAX_URI],
- /* Name of host */
- printer[HTTP_MAX_URI],
- /* Name of printer or class */
uri[1024], /* Printer URI */
*reason; /* Reason for reject/disable */
- const char *server; /* Server name */
ipp_t *request; /* IPP request */
ipp_t *response; /* IPP response */
ipp_op_t op; /* Operation */
cups_lang_t *language; /* Language */
int cancel; /* Cancel jobs? */
- http_encryption_t encryption; /* Encryption? */
/*
return (1);
}
- server = cupsServer();
- http = NULL;
- reason = NULL;
- encryption = cupsEncryption();
+ http = NULL;
+ reason = NULL;
/*
* Process command-line arguments...
{
case 'E' : /* Encrypt */
#ifdef HAVE_LIBSSL
- encryption = HTTP_ENCRYPT_REQUIRED;
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
- argv[0]);
+ command);
#endif /* HAVE_LIBSSL */
break;
httpClose(http);
if (argv[i][2] != '\0')
- server = argv[i] + 2;
+ cupsSetServer(argv[i] + 2);
else
{
i ++;
return (1);
}
- server = argv[i];
- }
-
- http = httpConnectEncrypt(server, ippPort(), encryption);
-
- if (http == NULL)
- {
- fputs(argv[0], stderr);
- perror(": Unable to connect to server");
- return (1);
+ cupsSetServer(argv[i]);
}
break;
* Accept/disable/enable/reject a destination...
*/
- if (sscanf(argv[i], "%1023[^@]@%1023s", printer, hostname) == 1)
- strlcpy(hostname, server, sizeof(hostname));
-
- if (http != NULL && strcasecmp(http->hostname, hostname) != 0)
- {
- httpClose(http);
- http = NULL;
- }
-
if (http == NULL)
- http = httpConnectEncrypt(hostname, ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
if (http == NULL)
{
- fputs(argv[0], stderr);
+ fputs(command, stderr);
perror(": Unable to connect to server");
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
- snprintf(uri, sizeof(uri), "ipp://%s:%d/printers/%s", hostname, ippPort(), printer);
+ snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", argv[i]);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
- snprintf(uri, sizeof(uri), "ipp://%s:%d/printers/%s", hostname, ippPort(), printer);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
/*
- * End of "$Id: accept.c,v 1.11.2.6 2002/05/16 14:00:17 mike Exp $".
+ * End of "$Id: accept.c,v 1.11.2.7 2002/08/22 01:43:39 mike Exp $".
*/
/*
- * "$Id: cancel.c,v 1.19.2.7 2002/08/21 20:00:17 mike Exp $"
+ * "$Id: cancel.c,v 1.19.2.8 2002/08/22 01:43:39 mike Exp $"
*
* "cancel" command for the Common UNIX Printing System (CUPS).
*
ipp_t *response; /* IPP response */
ipp_op_t op; /* Operation */
cups_lang_t *language; /* Language */
- http_encryption_t encryption; /* Encryption? */
/*
job_id = 0;
dest = NULL;
http = NULL;
- encryption = cupsEncryption();
num_dests = 0;
dests = NULL;
{
case 'E' : /* Encrypt */
#ifdef HAVE_LIBSSL
- encryption = HTTP_ENCRYPT_REQUIRED;
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
argv[0]);
if (http == NULL)
if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
- encryption)) == NULL)
+ cupsEncryption())) == NULL)
{
fputs("cancel: Unable to contact server!\n", stderr);
return (1);
/*
- * End of "$Id: cancel.c,v 1.19.2.7 2002/08/21 20:00:17 mike Exp $".
+ * End of "$Id: cancel.c,v 1.19.2.8 2002/08/22 01:43:39 mike Exp $".
*/
/*
- * "$Id: lpadmin.c,v 1.22.2.12 2002/08/15 19:48:37 mike Exp $"
+ * "$Id: lpadmin.c,v 1.22.2.13 2002/08/22 01:43:39 mike Exp $"
*
* "lpadmin" command for the Common UNIX Printing System (CUPS).
*
*val; /* Pointer to allow/deny value */
int num_options; /* Number of options */
cups_option_t *options; /* Options */
- http_encryption_t encryption; /* Encryption? */
http = NULL;
printer = NULL;
num_options = 0;
options = NULL;
- encryption = cupsEncryption();
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
case 'c' : /* Add printer to class */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'd' : /* Set as default destination */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'h' : /* Connect to host */
if (http)
+ {
httpClose(http);
+ http = NULL;
+ }
if (argv[i][2] != '\0')
- http = httpConnectEncrypt(argv[i] + 2, ippPort(), encryption);
+ cupsSetServer(argv[i] + 2);
else
{
i ++;
fputs("lpadmin: Expected hostname after \'-h\' option!\n", stderr);
return (1);
}
- else
- http = httpConnectEncrypt(argv[i], ippPort(), encryption);
- }
- if (http == NULL)
- {
- perror("lpadmin: Unable to connect to server");
- return (1);
+ cupsSetServer(argv[i]);
}
- else
- cupsSetServer(http->hostname);
break;
case 'i' : /* Use the specified interface script */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
if (printer == NULL)
{
#ifdef HAVE_LIBSSL
- cupsSetEncryption(encryption = HTTP_ENCRYPT_REQUIRED);
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
argv[0]);
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'm' : /* Use the specified standard script/PPD file */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'p' : /* Add/modify a printer */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'r' : /* Remove printer from class */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'v' : /* Set the device-uri attribute */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'x' : /* Delete a printer */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'D' : /* Set the printer-info attribute */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'L' : /* Set the printer-location attribute */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'P' : /* Use the specified PPD file */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
{
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
if (http == NULL)
{
/*
- * End of "$Id: lpadmin.c,v 1.22.2.12 2002/08/15 19:48:37 mike Exp $".
+ * End of "$Id: lpadmin.c,v 1.22.2.13 2002/08/22 01:43:39 mike Exp $".
*/
/*
- * "$Id: lpinfo.c,v 1.3.2.4 2002/05/09 03:08:05 mike Exp $"
+ * "$Id: lpinfo.c,v 1.3.2.5 2002/08/22 01:43:40 mike Exp $"
*
* "lpinfo" command for the Common UNIX Printing System (CUPS).
*
int i; /* Looping var */
http_t *http; /* Connection to server */
int long_status; /* Long listing? */
- http_encryption_t encryption; /* Encryption? */
http = NULL;
long_status = 0;
- encryption = cupsEncryption();
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
{
case 'E' : /* Encrypt */
#ifdef HAVE_LIBSSL
- encryption = HTTP_ENCRYPT_REQUIRED;
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
argv[0]);
case 'm' : /* Show models */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'v' : /* Show available devices */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'h' : /* Connect to host */
if (http)
+ {
httpClose(http);
+ http = NULL;
+ }
if (argv[i][2] != '\0')
- http = httpConnectEncrypt(argv[i] + 2, ippPort(), encryption);
+ cupsSetServer(argv[i] + 2);
else
{
i ++;
return (1);
}
- http = httpConnectEncrypt(argv[i], ippPort(), encryption);
- }
-
- if (http == NULL)
- {
- perror("lpinfo: Unable to connect to server");
- return (1);
+ cupsSetServer(argv[i]);
}
break;
/*
- * End of "$Id: lpinfo.c,v 1.3.2.4 2002/05/09 03:08:05 mike Exp $".
+ * End of "$Id: lpinfo.c,v 1.3.2.5 2002/08/22 01:43:40 mike Exp $".
*/
/*
- * "$Id: lpmove.c,v 1.5.2.5 2002/06/27 19:49:15 mike Exp $"
+ * "$Id: lpmove.c,v 1.5.2.6 2002/08/22 01:43:40 mike Exp $"
*
* "lpmove" command for the Common UNIX Printing System (CUPS).
*
int num_dests; /* Number of destinations */
cups_dest_t *dests; /* Destinations */
const char *dest; /* New destination */
- http_encryption_t encryption; /* Encryption? */
- http = NULL;
- job = NULL;
- dest = NULL;
- encryption = cupsEncryption();
- num_dests = 0;
- dests = NULL;
+ http = NULL;
+ job = NULL;
+ dest = NULL;
+ num_dests = 0;
+ dests = NULL;
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
{
case 'E' : /* Encrypt */
#ifdef HAVE_LIBSSL
- encryption = HTTP_ENCRYPT_REQUIRED;
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
argv[0]);
case 'h' : /* Connect to host */
if (http)
+ {
httpClose(http);
+ http = NULL;
+ }
if (argv[i][2] != '\0')
- http = httpConnectEncrypt(argv[i] + 2, ippPort(), encryption);
+ cupsSetServer(argv[i] + 2);
else
{
i ++;
return (1);
}
- http = httpConnectEncrypt(argv[i], ippPort(), encryption);
- }
-
- if (http == NULL)
- {
- perror("lpmove: Unable to connect to server");
- return (1);
+ cupsSetServer(argv[i]);
}
break;
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
if (http == NULL)
{
/*
- * End of "$Id: lpmove.c,v 1.5.2.5 2002/06/27 19:49:15 mike Exp $".
+ * End of "$Id: lpmove.c,v 1.5.2.6 2002/08/22 01:43:40 mike Exp $".
*/
/*
- * "$Id: lpstat.c,v 1.37.2.8 2002/08/09 00:05:30 mike Exp $"
+ * "$Id: lpstat.c,v 1.37.2.9 2002/08/22 01:43:40 mike Exp $"
*
* "lpstat" command for the Common UNIX Printing System (CUPS).
*
cups_dest_t *dests; /* User destinations */
int long_status; /* Long status report? */
int ranking; /* Show job ranking? */
- http_encryption_t encryption; /* Encryption? */
http = NULL;
dests = NULL;
long_status = 0;
ranking = 0;
- encryption = cupsEncryption();
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
case 'E' : /* Encrypt */
#ifdef HAVE_LIBSSL
- encryption = HTTP_ENCRYPT_REQUIRED;
+ cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
if (http)
- httpEncryption(http, encryption);
+ httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
#else
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
argv[0]);
case 'a' : /* Show acceptance status */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'b' : /* Show both the local and remote status */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'c' : /* Show classes and members */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'h' : /* Connect to host */
if (http)
+ {
httpClose(http);
+ http = NULL;
+ }
if (argv[i][2] != '\0')
- {
- http = httpConnectEncrypt(argv[i] + 2, ippPort(), encryption);
cupsSetServer(argv[i] + 2);
- }
else
{
i ++;
return (1);
}
- http = httpConnectEncrypt(argv[i], ippPort(), encryption);
cupsSetServer(argv[i]);
}
-
- if (http == NULL)
- {
- perror("lpstat: Unable to connect to server");
- return (1);
- }
break;
case 'l' : /* Long status or long job status */
#ifdef __sgi
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'o' : /* Show jobs by destination */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'p' : /* Show printers */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'r' : /* Show scheduler status */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 's' : /* Show summary */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 't' : /* Show all info */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'u' : /* Show jobs by user */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
case 'v' : /* Show printer devices */
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
{
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
{
if (!http)
{
- http = httpConnectEncrypt(cupsServer(), ippPort(), encryption);
+ http = httpConnectEncrypt(cupsServer(), ippPort(),
+ cupsEncryption());
if (http == NULL)
{
/*
- * End of "$Id: lpstat.c,v 1.37.2.8 2002/08/09 00:05:30 mike Exp $".
+ * End of "$Id: lpstat.c,v 1.37.2.9 2002/08/22 01:43:40 mike Exp $".
*/