From: mike Date: Tue, 1 Feb 2000 02:52:25 +0000 (+0000) Subject: Added templates, CGI variable code, and updated printers CGI to use X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=13c1a6d96ae50127555263cf6e2a345c20e16c1d;p=thirdparty%2Fcups.git Added templates, CGI variable code, and updated printers CGI to use new code (dropped about 200 lines of code...) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@892 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile index 1f8d39c52d..9455f18368 100644 --- a/cgi-bin/Makefile +++ b/cgi-bin/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.7 2000/01/30 13:38:16 mike Exp $" +# "$Id: Makefile,v 1.8 2000/02/01 02:52:23 mike Exp $" # # CGI makefile for the Common UNIX Printing System (CUPS). # @@ -25,7 +25,7 @@ include ../Makedefs TARGETS = libcgi.a admin.cgi classes.cgi jobs.cgi printers.cgi -LIBOBJS = abort.o email.o html.o template.o var.o +LIBOBJS = abort.o email.o html.o ipp-var.o template.o var.o OBJS = $(LIBOBJS) admin.o classes.o jobs.o printers.o @@ -60,10 +60,11 @@ install: libcgi.a: $(LIBOBJS) echo Archiving $@... $(RM) $@ - $(AR) $(ARFLAGS) $@ $(OBJS) + $(AR) $(ARFLAGS) $@ $(LIBOBJS) $(RANLIB) $@ $(LIBOBJS): cgi.h +ipp-var.o: ipp-var.h # @@ -74,7 +75,7 @@ admin.cgi: admin.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ admin.o libcgi.a $(LIBS) -admin.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/language.h +admin.o: cgi.h ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/language.h # @@ -85,7 +86,7 @@ classes.cgi: classes.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ classes.o libcgi.a $(LIBS) -classes.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/language.h +classes.o: cgi.h ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/language.h # @@ -96,7 +97,7 @@ jobs.cgi: jobs.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ jobs.o libcgi.a $(LIBS) -jobs.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/language.h +jobs.o: cgi.h ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/language.h # @@ -107,10 +108,10 @@ printers.cgi: printers.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ printers.o libcgi.a $(LIBS) -printers.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/language.h +printers.o: cgi.h ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/language.h $(OBJS): ../Makedefs # -# End of "$Id: Makefile,v 1.7 2000/01/30 13:38:16 mike Exp $". +# End of "$Id: Makefile,v 1.8 2000/02/01 02:52:23 mike Exp $". # diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 791b4eaa27..74d922f5e7 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,9 +1,9 @@ /* - * "$Id: admin.c,v 1.1 2000/01/30 13:38:16 mike Exp $" + * "$Id: admin.c,v 1.2 2000/02/01 02:52:23 mike Exp $" * * Class status CGI for the Common UNIX Printing System (CUPS). * - * Copyright 1997-1999 by Easy Software Products. + * Copyright 1997-2000 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -158,7 +158,7 @@ main(int argc, /* I - Number of command-line arguments */ puts("

The Common UNIX Printing System, CUPS, and the CUPS logo are the"); puts("trademark property of Easy Software"); - puts("Products. CUPS is copyright 1997-1999 by Easy Software Products,"); + puts("Products. CUPS is copyright 1997-2000 by Easy Software Products,"); puts("All Rights Reserved."); puts(""); @@ -482,5 +482,5 @@ show_class_info(http_t *http, /* - * End of "$Id: admin.c,v 1.1 2000/01/30 13:38:16 mike Exp $". + * End of "$Id: admin.c,v 1.2 2000/02/01 02:52:23 mike Exp $". */ diff --git a/cgi-bin/classes.c b/cgi-bin/classes.c index ae0da523c0..07bf78d9ff 100644 --- a/cgi-bin/classes.c +++ b/cgi-bin/classes.c @@ -1,9 +1,9 @@ /* - * "$Id: classes.c,v 1.11 1999/11/04 14:57:57 mike Exp $" + * "$Id: classes.c,v 1.12 2000/02/01 02:52:23 mike Exp $" * * Class status CGI for the Common UNIX Printing System (CUPS). * - * Copyright 1997-1999 by Easy Software Products. + * Copyright 1997-2000 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -158,7 +158,7 @@ main(int argc, /* I - Number of command-line arguments */ puts("

The Common UNIX Printing System, CUPS, and the CUPS logo are the"); puts("trademark property of Easy Software"); - puts("Products. CUPS is copyright 1997-1999 by Easy Software Products,"); + puts("Products. CUPS is copyright 1997-2000 by Easy Software Products,"); puts("All Rights Reserved."); puts(""); @@ -482,5 +482,5 @@ show_class_info(http_t *http, /* - * End of "$Id: classes.c,v 1.11 1999/11/04 14:57:57 mike Exp $". + * End of "$Id: classes.c,v 1.12 2000/02/01 02:52:23 mike Exp $". */ diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c new file mode 100644 index 0000000000..2294f9b7d9 --- /dev/null +++ b/cgi-bin/ipp-var.c @@ -0,0 +1,147 @@ +/* + * "$Id: ipp-var.c,v 1.1 2000/02/01 02:52:23 mike Exp $" + * + * IPP variable routines for the Common UNIX Printing System (CUPS). + * + * Copyright 1997-1999 by Easy Software Products. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636-3111 USA + * + * Voice: (301) 373-9603 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + * + * Contents: + * + * ippSetCGIVars() - Set CGI variables from an IPP response. + */ + +/* + * Include necessary headers... + */ + +#include "ipp-var.h" + + +/* + * 'ippSetCGIVars()' - Set CGI variables from an IPP response. + */ + +void +ippSetCGIVars(ipp_t *response) /* I - Response data to be copied... */ +{ + int element; /* Element in CGI array */ + ipp_attribute_t *attr; /* Attribute in response... */ + int i; /* Looping var */ + char name[1024], /* Name of attribute */ + value[16384], /* Value(s) */ + *valptr; /* Pointer into value */ + + + cgiSetVariable("SERVER_NAME", getenv("SERVER_NAME")); + cgiSetVariable("REMOTE_USER", getenv("REMOTE_USER")); + cgiSetVariable("CUPS_VERSION", CUPS_SVERSION); + + for (element = 0, attr = response->attrs; + attr != NULL; + attr = attr->next, element ++) + { + /* + * Copy attributes to a separator... + */ + + for (; attr != NULL && attr->group_tag != IPP_TAG_ZERO; attr = attr->next) + { + /* + * Copy the attribute name, substituting "_" for "-"... + */ + + if (attr->name == NULL) + continue; + + for (i = 0; attr->name[i]; i ++) + if (attr->name[i] == '-') + name[i] = '_'; + else + name[i] = attr->name[i]; + + name[i] = '\0'; + + /* + * Copy values... + */ + + value[0] = '\0'; + valptr = value; + + for (i = 0; i < attr->num_values; i ++) + { + if (i) + strcat(valptr, ","); + + valptr += strlen(valptr); + + switch (attr->value_tag) + { + case IPP_TAG_INTEGER : + case IPP_TAG_ENUM : + sprintf(valptr, "%d", attr->values[i].integer); + break; + + case IPP_TAG_BOOLEAN : + if (!attr->values[i].boolean) + strcat(valptr, "no"); + + case IPP_TAG_NOVALUE : + strcat(valptr, attr->name); + break; + + case IPP_TAG_RANGE : + sprintf(valptr, "%d-%d", attr->values[i].range.lower, + attr->values[i].range.upper); + break; + + case IPP_TAG_RESOLUTION : + sprintf(valptr, "%dx%d%s", attr->values[i].resolution.xres, + attr->values[i].resolution.yres, + attr->values[i].resolution.units == IPP_RES_PER_INCH ? + "dpi" : "dpc"); + break; + + case IPP_TAG_STRING : + case IPP_TAG_TEXT : + case IPP_TAG_NAME : + case IPP_TAG_KEYWORD : + case IPP_TAG_CHARSET : + case IPP_TAG_LANGUAGE : + strcat(valptr, attr->values[i].string.text); + break; + } + } + + /* + * Add the element... + */ + + cgiSetArray(name, element, value); + } + + if (attr == NULL) + break; + } +} + + +/* + * End of "$Id: ipp-var.c,v 1.1 2000/02/01 02:52:23 mike Exp $". + */ diff --git a/cgi-bin/ipp-var.h b/cgi-bin/ipp-var.h new file mode 100644 index 0000000000..fd0624ef4b --- /dev/null +++ b/cgi-bin/ipp-var.h @@ -0,0 +1,54 @@ +/* + * "$Id: ipp-var.h,v 1.1 2000/02/01 02:52:23 mike Exp $" + * + * IPP variable definitions for the Common UNIX Printing System (CUPS). + * + * Copyright 1997-2000 by Easy Software Products. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636-3111 USA + * + * Voice: (301) 373-9603 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + */ + +/* + * Include necessary headers... + */ + +#include +#include +#include +#include +#include +#include "cgi.h" + + +/* + * Definitions... + */ + +#define TEMPLATES "/home/mike/c/cups/templates" +/*#define TEMPLATES CUPS_DATADIR "/templates"*/ + + +/* + * Prototype... + */ + +extern void ippSetCGIVars(ipp_t *response); + + +/* + * End of "$Id: ipp-var.h,v 1.1 2000/02/01 02:52:23 mike Exp $". + */ diff --git a/cgi-bin/jobs.c b/cgi-bin/jobs.c index cbbab2158d..9ce659d60e 100644 --- a/cgi-bin/jobs.c +++ b/cgi-bin/jobs.c @@ -1,9 +1,9 @@ /* - * "$Id: jobs.c,v 1.10 1999/11/04 14:57:57 mike Exp $" + * "$Id: jobs.c,v 1.11 2000/02/01 02:52:23 mike Exp $" * * Job status CGI for the Common UNIX Printing System (CUPS). * - * Copyright 1997-1999 by Easy Software Products. + * Copyright 1997-2000 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -145,7 +145,7 @@ main(int argc, /* I - Number of command-line arguments */ puts("

The Common UNIX Printing System, CUPS, and the CUPS logo are the"); puts("trademark property of Easy Software"); - puts("Products. CUPS is copyright 1997-1999 by Easy Software Products,"); + puts("Products. CUPS is copyright 1997-2000 by Easy Software Products,"); puts("All Rights Reserved."); puts(""); @@ -580,5 +580,5 @@ show_job_info(http_t *http, /* I - Server connection */ /* - * End of "$Id: jobs.c,v 1.10 1999/11/04 14:57:57 mike Exp $". + * End of "$Id: jobs.c,v 1.11 2000/02/01 02:52:23 mike Exp $". */ diff --git a/cgi-bin/printers.c b/cgi-bin/printers.c index c8b8f3a4f6..dd5170e5fa 100644 --- a/cgi-bin/printers.c +++ b/cgi-bin/printers.c @@ -1,9 +1,9 @@ /* - * "$Id: printers.c,v 1.13 1999/11/04 14:57:57 mike Exp $" + * "$Id: printers.c,v 1.14 2000/02/01 02:52:23 mike Exp $" * * Printer status CGI for the Common UNIX Printing System (CUPS). * - * Copyright 1997-1999 by Easy Software Products. + * Copyright 1997-2000 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -23,31 +23,14 @@ * * Contents: * - * main() - Main entry for CGI. - * show_printer_list() - Show a list of printers... - * show_printer_info() - Show printer information. + * main() - Main entry for CGI. */ /* * Include necessary headers... */ -#include -#include -#include -#include -#include -#include -#include - - -/* - * Local functions... - */ - -static void show_printer_list(http_t *http, cups_lang_t *language); -static void show_printer_info(http_t *http, cups_lang_t *language, - char *name); +#include "ipp-var.h" /* @@ -61,7 +44,14 @@ main(int argc, /* I - Number of command-line arguments */ cups_lang_t *language; /* Language information */ char *printer; /* Printer name */ http_t *http; /* Connection to the server */ + ipp_t *request, /* IPP request */ + *response; /* IPP response */ + ipp_attribute_t *attr; /* IPP attribute */ + char uri[HTTP_MAX_URI]; + /* Printer URI */ + + setbuf(stdout, NULL); /* * Get the request language... @@ -88,298 +78,42 @@ main(int argc, /* I - Number of command-line arguments */ printer = argv[0]; if (strcmp(printer, "/") == 0 || strcmp(printer, "printers.cgi") == 0) + { printer = NULL; - - /* - * Print the standard header... - */ - - puts(""); - puts(""); - if (printer) - puts(""); - else - puts(""); - printf("%s on %s - " CUPS_SVERSION "\n", - printer == NULL ? "Printers" : printer, getenv("SERVER_NAME")); - puts(""); - puts(""); -#ifdef ESPPRINTPRO - puts("\"Current"); - puts("\"Current"); - puts("\"Current"); - puts("\"Read"); - puts("\"Download"); - puts("\"Get"); -#else - puts("\"Current"); - puts("\"Current"); - puts("\"Current"); - puts("\"Read"); - puts("\"Download"); -#endif /* ESPPRINTPRO */ - puts(""); - puts(""); - puts(""); - puts("

"); - puts(""); - puts("\"Easy"); - puts(""); - - printf("

%s on %s

\n", printer == NULL ? "Printers" : printer, - getenv("SERVER_NAME")); - fflush(stdout); - - puts("
"); - puts(""); - puts(""); - puts(""); - puts(""); - puts(""); - puts(""); - - /* - * Show the information... - */ - - if (printer == NULL) - show_printer_list(http, language); + cgiSetVariable("TITLE", "Printers"); + } else - show_printer_info(http, language, printer); + cgiSetVariable("TITLE", printer); /* - * Write a standard trailer... - */ - - puts("
NameStatusJobs
"); - puts("
"); - - puts("
"); - - puts("

The Common UNIX Printing System, CUPS, and the CUPS logo are the"); - puts("trademark property of Easy Software"); - puts("Products. CUPS is copyright 1997-1999 by Easy Software Products,"); - puts("All Rights Reserved."); - - puts(""); - puts(""); - - /* - * Close the HTTP server connection... - */ - - httpClose(http); - cupsLangFree(language); - - /* - * Return with no errors... - */ - - return (0); -} - - -/* - * 'show_printer_list()' - Show a list of printers... - */ - -static void -show_printer_list(http_t *http, /* I - HTTP connection */ - cups_lang_t *language)/* I - Client's language */ -{ - ipp_t *request, /* IPP request */ - *response; /* IPP response */ - ipp_attribute_t *attr; /* IPP attribute */ - - - /* - * Build a CUPS_GET_PRINTERS request, which requires the following - * attributes: - * - * attributes-charset - * attributes-natural-language + * Get the printer info... */ request = ippNew(); - request->request.op.operation_id = CUPS_GET_PRINTERS; - request->request.op.request_id = 1; - - 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); - /* - * Do the request and get back a response... - */ - - if ((response = cupsDoRequest(http, request, "/")) != NULL) + if (printer == NULL) { /* - * Loop through the printers returned in the list and display - * their devices... + * Build a CUPS_GET_PRINTERS request, which requires the following + * attributes: + * + * attributes-charset + * attributes-natural-language */ - for (attr = response->attrs; attr != NULL; attr = attr->next) - { - /* - * Skip leading attributes until we hit a job... - */ - - while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER) - attr = attr->next; - - if (attr == NULL) - break; - - /* - * Show the printer status for each printer... - */ - - while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) - { - if (strcmp(attr->name, "printer-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - show_printer_info(http, language, attr->values[0].string.text); - - attr = attr->next; - } - - if (attr == NULL) - break; - } - - ippDelete(response); - } -} - - -/* - * 'show_printer_info()' - Show printer information. - */ - -static void -show_printer_info(http_t *http, - cups_lang_t *language, - char *name) -{ - ipp_t *request, /* IPP request */ - *response, /* IPP response */ - *jobs; /* IPP Get Jobs response */ - int jobcount; /* Number of jobs */ - ipp_attribute_t *attr; /* IPP attribute */ - char *message; /* Printer state message */ - int accepting; /* Accepting requests? */ - ipp_pstate_t pstate; /* Printer state */ - char uri[HTTP_MAX_URI];/* Printer URI */ - - - /* - * Build a IPP_GET_PRINTER_ATTRIBUTES request, which requires the following - * attributes: - * - * attributes-charset - * attributes-natural-language - * printer-uri - */ - - request = ippNew(); - - request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; - request->request.op.request_id = 1; - - 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); - - snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", name); - - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - - /* - * Do the request and get back a response... - */ - - if ((response = cupsDoRequest(http, request, "/")) == NULL) - { - puts("

Unable to communicate with CUPS server!"); - return; - } - - if (response->request.status.status_code == IPP_NOT_FOUND) - { - puts("

Printer does not exist."); - ippDelete(response); - return; + request->request.op.operation_id = CUPS_GET_PRINTERS; + request->request.op.request_id = 1; } - - /* - * Grab the needed printer attributes... - */ - - if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) - pstate = (ipp_pstate_t)attr->values[0].integer; - else - pstate = IPP_PRINTER_IDLE; - - if ((attr = ippFindAttribute(response, "printer-state-message", IPP_TAG_TEXT)) != NULL) - message = attr->values[0].string.text; else - message = NULL; - - if ((attr = ippFindAttribute(response, "printer-is-accepting-jobs", - IPP_TAG_BOOLEAN)) != NULL) - accepting = attr->values[0].boolean; - else - accepting = 1; - - if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL) - { - strcpy(uri, "http:"); - strncpy(uri + 5, strchr(attr->values[0].string.text, '/'), sizeof(uri) - 6); - uri[sizeof(uri) - 1] = '\0'; - } - - /* - * Display the printer entry... - */ - - puts(""); - - printf("%s\n", uri, name); - - printf("\n", - pstate == IPP_PRINTER_IDLE ? "idle" : - pstate == IPP_PRINTER_PROCESSING ? "processing" : "stopped"); - - printf("%s: %s, %s
\n", - cupsLangString(language, CUPS_MSG_PRINTER_STATE), - cupsLangString(language, pstate == IPP_PRINTER_IDLE ? CUPS_MSG_IDLE : - pstate == IPP_PRINTER_PROCESSING ? - CUPS_MSG_PROCESSING : CUPS_MSG_STOPPED), - cupsLangString(language, accepting ? CUPS_MSG_ACCEPTING_JOBS : - CUPS_MSG_NOT_ACCEPTING_JOBS)); - - if (message) - printf("
\"%s\"\n", message); - else if (!accepting || pstate == IPP_PRINTER_STOPPED) - puts("
\"Reason Unknown\""); - - puts(""); - - /* - * Show a list of jobs as needed... - */ - - if (pstate != IPP_PRINTER_IDLE) { /* - * Build an IPP_GET_JOBS request, which requires the following + * Build a IPP_GET_PRINTER_ATTRIBUTES request, which requires the following * attributes: * * attributes-charset @@ -387,102 +121,48 @@ show_printer_info(http_t *http, * printer-uri */ - request = ippNew(); - - request->request.op.operation_id = IPP_GET_JOBS; + request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; request->request.op.request_id = 1; - 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); - - snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", name); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, - "printer-uri", NULL, uri); - - jobs = cupsDoRequest(http, request, "/"); + snprintf(uri, sizeof(uri), "ipp://%s/printers/%s", getenv("SERVER_NAME"), + printer); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, + uri); } - else - jobs = NULL; - puts(""); - jobcount = 0; + /* + * Do the request and get back a response... + */ - if (jobs != NULL) + if ((response = cupsDoRequest(http, request, "/")) != NULL) { - char *username; /* Pointer to job-originating-user-name */ - int jobid, /* job-id */ - size; /* job-k-octets */ - - - for (attr = jobs->attrs; attr != NULL; attr = attr->next) - { - /* - * Skip leading attributes until we hit a job... - */ - - while (attr != NULL && attr->group_tag != IPP_TAG_JOB) - attr = attr->next; - - if (attr == NULL) - break; - - /* - * Pull the needed attributes from this job... - */ - - jobid = 0; - size = 0; - username = NULL; - - while (attr != NULL && attr->group_tag == IPP_TAG_JOB) - { - if (strcmp(attr->name, "job-id") == 0 && - attr->value_tag == IPP_TAG_INTEGER) - jobid = attr->values[0].integer; - - if (strcmp(attr->name, "job-k-octets") == 0 && - attr->value_tag == IPP_TAG_INTEGER) - size = attr->values[0].integer; - - if (strcmp(attr->name, "job-originating-user-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - username = attr->values[0].string.text; - - attr = attr->next; - } + ippSetCGIVars(response); + ippDelete(response); + } - /* - * Display the job if it matches the current printer... - */ + /* + * Write the report... + */ - if (username != NULL) - { - jobcount ++; - printf("%s-%d %s %dk
\n", jobid, name, - jobid, username, size); - } + cgiCopyTemplateFile(stdout, TEMPLATES "/header.tmpl"); + cgiCopyTemplateFile(stdout, TEMPLATES "/printers.tmpl"); + cgiCopyTemplateFile(stdout, TEMPLATES "/trailer.tmpl"); - if (attr == NULL) - break; - } + /* + * Close the HTTP server connection... + */ - ippDelete(jobs); - } + httpClose(http); + cupsLangFree(language); - if (jobcount == 0) - puts("None"); - puts(""); - puts(""); + /* + * Return with no errors... + */ - ippDelete(response); + return (0); } /* - * End of "$Id: printers.c,v 1.13 1999/11/04 14:57:57 mike Exp $". + * End of "$Id: printers.c,v 1.14 2000/02/01 02:52:23 mike Exp $". */ diff --git a/templates/add-class.tmpl b/templates/add-class.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/add-class.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/add-printer.tmpl b/templates/add-printer.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/add-printer.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/admin.tmpl b/templates/admin.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/admin.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/choose-device.tmpl b/templates/choose-device.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/choose-device.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/choose-make.tmpl b/templates/choose-make.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/choose-make.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/choose-model.tmpl b/templates/choose-model.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/choose-model.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/choose-uri.tmpl b/templates/choose-uri.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/choose-uri.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/classes.tmpl b/templates/classes.tmpl new file mode 100644 index 0000000000..6bed37805b --- /dev/null +++ b/templates/classes.tmpl @@ -0,0 +1,23 @@ + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Description: {printer_info}
+ Location: {printer_location}
+ Class State: {printer_state=3?idle:{printer_state=4?processing:stopped}}}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ Print Test Page + Start Class + Stop Class + Accept Jobs + Reject Jobs +

diff --git a/templates/header.tmpl b/templates/header.tmpl new file mode 100644 index 0000000000..f3237f5897 --- /dev/null +++ b/templates/header.tmpl @@ -0,0 +1,18 @@ + + + {title} on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + +

+ +Easy Software Products Home Page + +

{title}

diff --git a/templates/jobs.tmpl b/templates/jobs.tmpl new file mode 100644 index 0000000000..5ea00f99bb --- /dev/null +++ b/templates/jobs.tmpl @@ -0,0 +1,20 @@ + + + + + +{[job_id] + + + + +} +
IDInformation
{job_id}Name: {job_name}
+ Who: {job_originating_user_name}
+ Size: {job_k_octets}k
+ State: {job_state=3?pending:{job_state=4?held:processing}}. +

+ Hold Job + Resume Job + Cancel Job +

diff --git a/templates/modify-class.tmpl b/templates/modify-class.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/modify-class.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/modify-printer.tmpl b/templates/modify-printer.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/modify-printer.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/option-boolean.tmpl b/templates/option-boolean.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/option-boolean.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/option-header.tmpl b/templates/option-header.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/option-header.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/option-pickmany.tmpl b/templates/option-pickmany.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/option-pickmany.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/option-pickone.tmpl b/templates/option-pickone.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/option-pickone.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/option-trailer.tmpl b/templates/option-trailer.tmpl new file mode 100644 index 0000000000..64e3b006ce --- /dev/null +++ b/templates/option-trailer.tmpl @@ -0,0 +1,62 @@ + + + Printers on {server_name} - {cups_version} + + + Current Printer Status + Current Printer Classes Status + Current Jobs Status + Read CUPS Documentation On-Line + Download the Current CUPS Software + + + + +

+ +Easy Software Products Home Page + + +

Printers on {server_name}

+ + + + + + + + + +{[printer_name] + + + + +} +
NameInformation
+
{printer_name}
Make and Model: {printer_make_and_model}
+ Location: {printer_location}
+ Printer State: {printer_idle}, + {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}. +

+ + + + + + + +

+ +
+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-1999 by Easy Software Products, +All Rights Reserved. + + diff --git a/templates/printers.tmpl b/templates/printers.tmpl index 64e3b006ce..c79710bdd3 100644 --- a/templates/printers.tmpl +++ b/templates/printers.tmpl @@ -1,62 +1,24 @@ - - - Printers on {server_name} - {cups_version} - - - Current Printer Status - Current Printer Classes Status - Current Jobs Status - Read CUPS Documentation On-Line - Download the Current CUPS Software - - - - -

- -Easy Software Products Home Page - - -

Printers on {server_name}

- - - - {[printer_name] +
{printer_name} }
Name Information
-
{printer_name}
Make and Model: {printer_make_and_model}
+ Description: {printer_info}
Location: {printer_location}
- Printer State: {printer_idle}, + Printer State: {printer_state=3?idle:{printer_state=4?processing:stopped}}, {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}.

- - - - - - - + Print Test Page + Start Printer + Stop Printer + Accept Jobs + Reject Jobs

- -
-

The Common UNIX Printing System, CUPS, and the CUPS logo are the -trademark property of Easy Software -Products. CUPS is copyright 1997-1999 by Easy Software Products, -All Rights Reserved. - - diff --git a/templates/trailer.tmpl b/templates/trailer.tmpl new file mode 100644 index 0000000000..74706939ad --- /dev/null +++ b/templates/trailer.tmpl @@ -0,0 +1,7 @@ +


+

The Common UNIX Printing System, CUPS, and the CUPS logo are the +trademark property of Easy Software +Products. CUPS is copyright 1997-2000 by Easy Software Products, +All Rights Reserved. + +