]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/backend.c
ca4fad2f3cb3076c13cb7fd7f1c3d2d77e650090
2 * "$Id: backend.c 7810 2008-07-29 01:11:15Z mike $"
4 * Backend functions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * cupsBackendDeviceURI() - Get the device URI for a backend.
20 * cupsBackendReport() - Write a device line from a backend.
21 * quote_string() - Write a quoted string to stdout, escaping \ and ".
25 * Include necessary headers...
37 static void quote_string(const char *s
);
41 * 'cupsBackendDeviceURI()' - Get the device URI for a backend.
43 * The "argv" argument is the argv argument passed to main(). This
44 * function returns the device URI passed in the DEVICE_URI environment
45 * variable or the device URI passed in argv[0], whichever is found
49 const char * /* O - Device URI or @code NULL@ */
50 cupsBackendDeviceURI(char **argv
) /* I - Command-line arguments */
52 const char *device_uri
; /* Device URI */
53 _cups_globals_t
*cg
= _cupsGlobals(); /* Global info */
56 if ((device_uri
= getenv("DEVICE_URI")) == NULL
)
58 if (!argv
|| !argv
[0] || !strchr(argv
[0], ':'))
64 return (_httpResolveURI(device_uri
, cg
->resolved_uri
,
65 sizeof(cg
->resolved_uri
), 1));
70 * 'cupsBackendReport()' - Write a device line from a backend.
72 * This function writes a single device line to stdout for a backend.
73 * It handles quoting of special characters in the device-make-and-model,
74 * device-info, device-id, and device-location strings.
79 const char *device_scheme
, /* I - device-scheme string */
80 const char *device_uri
, /* I - device-uri string */
81 const char *device_make_and_model
, /* I - device-make-and-model string or @code NULL@ */
82 const char *device_info
, /* I - device-info string or @code NULL@ */
83 const char *device_id
, /* I - device-id string or @code NULL@ */
84 const char *device_location
) /* I - device-location string or @code NULL@ */
86 if (!device_scheme
|| !device_uri
)
89 printf("%s %s", device_scheme
, device_uri
);
90 if (device_make_and_model
&& *device_make_and_model
)
91 quote_string(device_make_and_model
);
93 quote_string("unknown");
94 quote_string(device_info
);
95 quote_string(device_id
);
96 quote_string(device_location
);
103 * 'quote_string()' - Write a quoted string to stdout, escaping \ and ".
107 quote_string(const char *s
) /* I - String to write */
109 fputs(" \"", stdout
);
115 if (*s
== '\\' || *s
== '\"')
129 * End of "$Id: backend.c 7810 2008-07-29 01:11:15Z mike $".