]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Normalize ippeveprinter environment with ippserver:
authorMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 17 May 2019 14:02:27 +0000 (10:02 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 17 May 2019 14:02:27 +0000 (10:02 -0400)
- Add -F option to specify the output format (default is application/postscript
  when PPDs are used)
- Add pwg-xxx attributes and output format to environment.

doc/help/man-ippeveprinter.html
man/ippeveprinter.1
tools/ippeveprinter.c

index ec25dabc0f65b686189a57d4566601eb7bfd518a..d37d6355965b410eed5aed7af06e1c550d8c7c63 100644 (file)
@@ -23,6 +23,9 @@ ippeveprinter - an ipp everywhere printer application for cups
 <b>-D</b>
 <i>device-uri</i>
 ] [
+<b>-F</b>
+<i>output-type/subtype</i>
+] [
 <b>-K</b>
 <i>keypath</i>
 ] [
@@ -94,6 +97,9 @@ The URI can be a filename, directory, or a network socket URI of the form "socke
 When specifying a directory,
 <b>ippeveprinter</b>
 will create an output file using the job ID and name.
+<dt><b>-F </b><i>output-type/subtype[,...]</i>
+<dd style="margin-left: 5.0em">Specifies the output MIME media type.
+The default is "application/postscript" when the <b>-P</b> option is specified.
 <dt><b>-M </b><i>manufacturer</i>
 <dd style="margin-left: 5.0em">Set the manufacturer of the printer.
 The default is "Example".
@@ -169,12 +175,12 @@ program is unique to CUPS and conforms to the IPP Everywhere (PWG 5100.14) speci
 <b>ippeveprinter</b>
 adds environment variables starting with "IPP_" for all IPP Job attributes in the print request.
 For example, when executing a command for an IPP Job containing the "media" Job Template attribute, the "IPP_MEDIA" environment variable will be set to the value of that attribute.
-<p>In addition, all IPP "xxx-default" Printer Description attributes are added to the environment.
+<p>In addition, all IPP "xxx-default" and "pwg-xxx" Printer Description attributes are added to the environment.
 For example, the "IPP_MEDIA_DEFAULT" environment variable will be set to the default value for the "media" Job Template attribute.
 <p>Enumerated values are converted to their keyword equivalents.
 For example, a "print-quality" Job Template attribute with a enum value of 3 will become the "IPP_PRINT_QUALITY" environment variable with a value of "draft".
 This string conversion only happens for standard Job Template attributes, currently "finishings", "orientation-requested", and "print-quality".
-<p>Finally, the "CONTENT_TYPE" environment variable contains the MIME media type of the document being printed, the "DEVICE_URI" environment variable contains the device URI as specified with the "-D" option, and the "PPD" environment variable contains the PPD filename as specified with the "-P" option.
+<p>Finally, the "CONTENT_TYPE" environment variable contains the MIME media type of the document being printed, the "DEVICE_URI" environment variable contains the device URI as specified with the "-D" option, the "OUTPUT_FORMAT" environment variable contains the output MIME media type, and the "PPD" environment variable contains the PPD filename as specified with the "-P" option.
 <h2 class="title"><a name="COMMAND_OUTPUT">Command Output</a></h2>
 Unless they communicate directly with a printer, print commands send printer-ready data to the standard output.
 <p>Print commands can send messages back to
@@ -213,6 +219,8 @@ command whenever a job is sent to the server:
     ippeveprinter -c /usr/bin/file "My Cool Printer"
 </pre>
 <h2 class="title"><a name="SEE_ALSO">See Also</a></h2>
+<b>ippevepcl</b>(7),
+<b>ippeveps</b>(7),
 PWG Internet Printing Protocol Workgroup (<a href="http://www.pwg.org/ipp">http://www.pwg.org/ipp</a>)
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
 Copyright &copy; 2007-2019 by Apple Inc.
index 3165400f2a16668c6643394ff747f8fc1b340052..5753c69da6f6d9ec0e6eea6e0c3e39595c282114 100644 (file)
@@ -6,7 +6,7 @@
 .\" Licensed under Apache License v2.0.  See the file "LICENSE" for more
 .\" information.
 .\"
-.TH ippeveprinter 1 "CUPS" "3 May 2019" "Apple Inc."
+.TH ippeveprinter 1 "CUPS" "17 May 2019" "Apple Inc."
 .SH NAME
 ippeveprinter \- an ipp everywhere printer application for cups
 .SH SYNOPSIS
@@ -23,6 +23,9 @@ ippeveprinter \- an ipp everywhere printer application for cups
 .B \-D
 .I device-uri
 ] [
+.B \-F
+.I output-type/subtype
+] [
 .B \-K
 .I keypath
 ] [
@@ -99,6 +102,10 @@ When specifying a directory,
 .B ippeveprinter
 will create an output file using the job ID and name.
 .TP 5
+\fB\-F \fIoutput-type/subtype[,...]\fR
+Specifies the output MIME media type.
+The default is "application/postscript" when the \fB\-P\fR option is specified.
+.TP 5
 \fB\-M \fImanufacturer\fR
 Set the manufacturer of the printer.
 The default is "Example".
@@ -189,14 +196,14 @@ program is unique to CUPS and conforms to the IPP Everywhere (PWG 5100.14) speci
 adds environment variables starting with "IPP_" for all IPP Job attributes in the print request.
 For example, when executing a command for an IPP Job containing the "media" Job Template attribute, the "IPP_MEDIA" environment variable will be set to the value of that attribute.
 .LP
-In addition, all IPP "xxx-default" Printer Description attributes are added to the environment.
+In addition, all IPP "xxx-default" and "pwg-xxx" Printer Description attributes are added to the environment.
 For example, the "IPP_MEDIA_DEFAULT" environment variable will be set to the default value for the "media" Job Template attribute.
 .LP
 Enumerated values are converted to their keyword equivalents.
 For example, a "print-quality" Job Template attribute with a enum value of 3 will become the "IPP_PRINT_QUALITY" environment variable with a value of "draft".
 This string conversion only happens for standard Job Template attributes, currently "finishings", "orientation-requested", and "print-quality".
 .LP
-Finally, the "CONTENT_TYPE" environment variable contains the MIME media type of the document being printed, the "DEVICE_URI" environment variable contains the device URI as specified with the "\-D" option, and the "PPD" environment variable contains the PPD filename as specified with the "\-P" option.
+Finally, the "CONTENT_TYPE" environment variable contains the MIME media type of the document being printed, the "DEVICE_URI" environment variable contains the device URI as specified with the "\-D" option, the "OUTPUT_FORMAT" environment variable contains the output MIME media type, and the "PPD" environment variable contains the PPD filename as specified with the "\-P" option.
 .SH COMMAND OUTPUT
 Unless they communicate directly with a printer, print commands send printer-ready data to the standard output.
 .LP
@@ -242,6 +249,8 @@ command whenever a job is sent to the server:
     ippeveprinter \-c /usr/bin/file "My Cool Printer"
 .fi
 .SH SEE ALSO
+.BR ippevepcl (7),
+.BR ippeveps (7),
 PWG Internet Printing Protocol Workgroup (http://www.pwg.org/ipp)
 .SH COPYRIGHT
 Copyright \[co] 2007-2019 by Apple Inc.
index 954b910d05efc872bcc2713df837375ffc3d6528..3fce71594cba0c6a1d9e786c071c3da27f12af97 100644 (file)
@@ -172,6 +172,7 @@ typedef struct ippeve_printer_s             /**** Printer data ****/
                        *hostname,      /* Hostname */
                        *uri,           /* printer-uri-supported */
                        *device_uri,    /* Device URI (if any) */
+                       *output_format, /* Output format */
 #if !CUPS_LITE
                        *ppdfile,       /* PPD file (if any) */
 #endif /* !CUPS_LITE */
@@ -243,7 +244,7 @@ static int          create_job_file(ippeve_job_t *job, char *fname, size_t fnamesize, co
 static int             create_listener(const char *name, int port, int family);
 static ipp_t           *create_media_col(const char *media, const char *source, const char *type, int width, int length, int bottom, int left, int right, int top);
 static ipp_t           *create_media_size(int width, int length);
-static ippeve_printer_t        *create_printer(const char *servername, int serverport, const char *name, const char *location, const char *icon, cups_array_t *docformats, const char *subtypes, const char *directory, const char *command, const char *device_uri, ipp_t *attrs);
+static ippeve_printer_t        *create_printer(const char *servername, int serverport, const char *name, const char *location, const char *icon, cups_array_t *docformats, const char *subtypes, const char *directory, const char *command, const char *device_uri, const char *output_format, ipp_t *attrs);
 static void            debug_attributes(const char *title, ipp_t *ipp, int response);
 static void            delete_client(ippeve_client_t *client);
 static void            delete_job(ippeve_job_t *job);
@@ -330,6 +331,7 @@ main(int  argc,                             /* I - Number of command-line args */
                *attrfile = NULL,       /* ippserver attributes file */
                *command = NULL,        /* Command to run with job files */
                *device_uri = NULL,     /* Device URI */
+               *output_format = NULL,  /* Output format */
                *icon = NULL,           /* Icon file */
 #ifdef HAVE_SSL
                *keypath = NULL,        /* Keychain path */
@@ -398,6 +400,14 @@ main(int  argc,                            /* I - Number of command-line args */
              device_uri = argv[i];
              break;
 
+          case 'F' : /* -F output/format */
+             i ++;
+             if (i >= argc)
+               usage(1);
+
+             output_format = argv[i];
+             break;
+
 #ifdef HAVE_SSL
          case 'K' : /* -K keypath */
              i ++;
@@ -647,12 +657,15 @@ main(int  argc,                           /* I - Number of command-line args */
 
     if (!command)
       command = "ippeveps";
+
+    if (!output_format)
+      output_format = "application/postscript";
   }
 #endif /* !CUPS_LITE */
   else
     attrs = load_legacy_attributes(make, model, ppm, ppm_color, duplex, docformats);
 
-  if ((printer = create_printer(servername, serverport, name, location, icon, docformats, subtypes, directory, command, device_uri, attrs)) == NULL)
+  if ((printer = create_printer(servername, serverport, name, location, icon, docformats, subtypes, directory, command, device_uri, output_format, attrs)) == NULL)
     return (1);
 
   printer->web_forms = web_forms;
@@ -1241,6 +1254,7 @@ create_printer(
     const char   *directory,           /* I - Spool directory */
     const char   *command,             /* I - Command to run on job files, if any */
     const char   *device_uri,          /* I - Output device, if any */
+    const char   *output_format,       /* I - Output format, if any */
     ipp_t        *attrs)               /* I - Capability attributes */
 {
   ippeve_printer_t     *printer;       /* Printer */
@@ -1479,6 +1493,7 @@ create_printer(
   printer->dnssd_name    = strdup(name);
   printer->command       = command ? strdup(command) : NULL;
   printer->device_uri    = device_uri ? strdup(device_uri) : NULL;
+  printer->output_format = output_format ? strdup(output_format) : NULL;
   printer->directory     = strdup(directory);
   printer->icon          = icon ? strdup(icon) : NULL;
   printer->port          = serverport;
@@ -6023,6 +6038,12 @@ process_job(ippeve_job_t *job)           /* I - Job */
       myenvp[myenvc ++] = strdup(val);
     }
 
+    if (job->printer->output_format)
+    {
+      snprintf(val, sizeof(val), "OUTPUT_TYPE=%s", job->printer->output_format);
+      myenvp[myenvc ++] = strdup(val);
+    }
+
 #if !CUPS_LITE
     if (job->printer->ppdfile)
     {
@@ -6035,7 +6056,7 @@ process_job(ippeve_job_t *job)            /* I - Job */
     {
      /*
       * Convert "attribute-name-default" to "IPP_ATTRIBUTE_NAME_DEFAULT=" and
-      * then add the value(s) from the attribute.
+      * "pwg-xxx" to "IPP_PWG_XXX", then add the value(s) from the attribute.
       */
 
       const char       *name = ippGetName(attr),
@@ -6043,7 +6064,7 @@ process_job(ippeve_job_t *job)            /* I - Job */
                        *suffix = strstr(name, "-default");
                                        /* Suffix on attribute name */
 
-      if (!suffix || suffix[8])
+      if (strncmp(name, "pwg-", 4) && (!suffix || suffix[8]))
         continue;
 
       valptr = val;
@@ -7646,6 +7667,7 @@ usage(int status)                 /* O - Exit status */
   _cupsLangPuts(stderr, _("--version               Show program version"));
   _cupsLangPuts(stdout, _("-2                      Set 2-sided printing support (default=1-sided)"));
   _cupsLangPuts(stdout, _("-D device-uri           Set the device URI for the printer"));
+  _cupsLangPuts(stdout, _("-F output-type/subtype  Set the output format for the printer"));
 #ifdef HAVE_SSL
   _cupsLangPuts(stdout, _("-K keypath              Set location of server X.509 certificates and keys."));
 #endif /* HAVE_SSL */