Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| bda8d17e59 |
@@ -1,33 +0,0 @@
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
cups-config
|
||||
cups.list
|
||||
cups.sh
|
||||
make.log
|
||||
printpro.common
|
||||
printpro.version
|
||||
Makedefs
|
||||
aix-4.3-powerpc
|
||||
darwin-5.2-powerpc
|
||||
darwin-5.3-powerpc
|
||||
darwin-6.0-powerpc
|
||||
freebsd-4.5-intel
|
||||
hpux-10.20-hppa
|
||||
hpux-11.00-hppa
|
||||
irix-5.3-mips
|
||||
irix-6.5-mips
|
||||
linux-2.0-intel
|
||||
linux-2.2-intel
|
||||
linux-2.4-intel
|
||||
solaris-2.5-intel
|
||||
solaris-2.5-sparc
|
||||
solaris-2.7-intel
|
||||
solaris-2.7-sparc
|
||||
solaris-2.8-intel
|
||||
solaris-2.8-sparc
|
||||
solaris-2.9-intel
|
||||
solaris-2.9-sparc
|
||||
tru64-4.0-alpha
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
CGI - CUPS v1.1.21 - 06/29/2004
|
||||
-------------------------------
|
||||
|
||||
This file describes the experimental scripting/CGI support
|
||||
provided by CUPS starting with CUPS 1.1.19.
|
||||
|
||||
WARNING: CGI support is not complete; you may run into problems
|
||||
and limitations in the implementation of CGI in CUPS that are
|
||||
not present in full-featured web servers like Apache.
|
||||
|
||||
|
||||
OVERVIEW OF CGI SUPPORT IN CUPS
|
||||
|
||||
CUPS has traditionally provided a dynamic web interface through
|
||||
four CGI programs that are executed when users open special
|
||||
directories on the CUPS server. Each CGI performs
|
||||
administration, class, job, and printer functions as directed by
|
||||
the user, but the actual programs that are run and functions
|
||||
that are available are limited to those that were originally
|
||||
designed into the scheduler.
|
||||
|
||||
Starting with CUPS 1.1.19, support is now available for CGI
|
||||
programs and specific scripting languages, currently Java, Perl,
|
||||
PHP, and Python. The interpreters for these languages are
|
||||
currently configured at compile time. Future versions may
|
||||
expand the interface to allow for generic support of scripting
|
||||
languages similar to the Apache "AddHandler" directive, but with
|
||||
external programs instead of modules.
|
||||
|
||||
The following MIME types are reserved for the CGI support in
|
||||
CUPS (the names have been chosen to mirror those used by
|
||||
Apache):
|
||||
|
||||
application/x-httpd-cgi CGI script/program
|
||||
application/x-httpd-java Java program
|
||||
application/x-httpd-perl Perl script
|
||||
application/x-httpd-php PHP script
|
||||
application/x-httpd-python Python script
|
||||
|
||||
In order to enable the corresponding type, you must create a new
|
||||
/etc/cups/cgi.types file which maps the filename extensions to
|
||||
the appropriate MIME type, for example:
|
||||
|
||||
application/x-httpd-cgi cgi
|
||||
application/x-httpd-php php
|
||||
|
||||
CGI scripts/programs (application/x-httpd-cgi) also must have
|
||||
execution permissions to be treated as a CGI script or program.
|
||||
|
||||
|
||||
LIMITATIONS
|
||||
|
||||
CUPS implements most of the CGI/1.1 specification, with the
|
||||
following limitations:
|
||||
|
||||
- No Location: redirection support.
|
||||
- No PATH_INFO or PATH_TRANSLATED support.
|
||||
- Limited HTTP field support; only the Content-Length
|
||||
(CONTENT_LENGTH), Cookie (HTTP_COOKIE), and User-Agent
|
||||
(HTTP_USER_AGENT) fields are placed in environment
|
||||
variables at this time.
|
||||
|
||||
|
||||
REPORTING PROBLEMS
|
||||
|
||||
If you have problems, READ THE DOCUMENTATION FIRST! If the
|
||||
documentation does not solve your problems please send an email
|
||||
to "cups-support@cups.org". Include your operating system and
|
||||
version, compiler and version, and any errors or problems you've
|
||||
run into. The "/var/log/cups/error_log" file should also be sent,
|
||||
as it often helps to determine the cause of your problem.
|
||||
|
||||
If you are running a version of Linux, be sure to provide the
|
||||
Linux distribution you have, too.
|
||||
|
||||
Please note that the "cups-support@cups.org" email address goes
|
||||
to the CUPS developers; they are busy people, so your email may
|
||||
go unanswered for days or weeks. In general, only general build
|
||||
or distribution problems will actually get answered - for
|
||||
end-user support see the "README.txt" for a summary of the
|
||||
resources available.
|
||||
@@ -0,0 +1,217 @@
|
||||
CHANGES-1.0.txt
|
||||
---------------
|
||||
|
||||
CHANGES IN CUPS v1.0.5
|
||||
|
||||
- The HP-GL/2 filter did not correctly set the pen color
|
||||
for pens other than #1.
|
||||
- The scheduler would only accept 26 simultaneous jobs
|
||||
under some OS releases (mkstemp() limitation.) It now
|
||||
handles up to 2^32 simultaneous jobs.
|
||||
- The PostScript filter loaded the printer's PPD file
|
||||
twice.
|
||||
- The PAM authentication code now uses pam_strerror() to
|
||||
provide a textual error message in the error_log file.
|
||||
- The scheduler now copies PPD and interface script
|
||||
files instead of moving them; this fixes installations
|
||||
with a separate requests directory.
|
||||
- The PostScript RIP did not generate correct 6-color
|
||||
output.
|
||||
- Several filters were marking PPD options twice when
|
||||
they didn't need to.
|
||||
- The scheduler did not save the printer or class state
|
||||
after an accept-jobs or reject-jobs operation.
|
||||
- The cupsGetDefault() function now ignores the PRINTER
|
||||
environment variable if it is set to "lp".
|
||||
- New ippErrorString() function to get textual error
|
||||
messages.
|
||||
- Better error reporting in the System V commands.
|
||||
- The lpadmin and lpstat commands always tried to
|
||||
connect to the default server.
|
||||
- The text filter didn't load the charset files from the
|
||||
correct location.
|
||||
- Wasn't sending a WWW-Authenticate: field to HTTP
|
||||
clients when authentication was required.
|
||||
- httpSeparate() didn't always set the default port
|
||||
number for known methods.
|
||||
- The HP-GL/2 filter now looks for "PSwidth,length"
|
||||
instead of (the correct) "PSlength,width" as
|
||||
documented by HP. It appears that many major CAD
|
||||
applications are broken and this change allows the
|
||||
auto-rotation to work with them.
|
||||
- The IPP "printer-resolution" option was not being
|
||||
translated.
|
||||
- The charset files did not include the Microsoft
|
||||
"standard" characters from 128 to 159 (unused by the
|
||||
ISO-8859-x charsets)
|
||||
- The scheduler was chunking the Content-Type field from
|
||||
CGI programs; this problem was most noticeable with
|
||||
Microsoft Internet Explorer 5.
|
||||
- By popular demand, the printers, jobs, and classes
|
||||
CGIs no longer force a reload of the page every 10/30
|
||||
seconds.
|
||||
- The scheduler incorrectly required that the IPP client
|
||||
provide a document-format attribute for the
|
||||
validate-job operation.
|
||||
- Clients that sent bad IPP requests without the
|
||||
required attributes-natural-language and
|
||||
attributes-charset attributes would crash the
|
||||
scheduler.
|
||||
|
||||
|
||||
CHANGES IN CUPS v1.0.4
|
||||
|
||||
- Documentation updates.
|
||||
- Jobs would get stuck in the queue and wouldn't print
|
||||
until you enabled the queue.
|
||||
- The lp and lpr commands now catch SIGHUP and SIGINTR.
|
||||
- The lp and lpr commands now use sigaction or sigset
|
||||
when available.
|
||||
- CUPS library updates for WIN32/OS-2
|
||||
|
||||
|
||||
CHANGES IN CUPS v1.0.3
|
||||
|
||||
- Documentation updates.
|
||||
- The lpq man page was missing.
|
||||
- The configure script was not properly detecting the
|
||||
image libraries.
|
||||
- The top-level makefile was calling "make" instead of
|
||||
"$(MAKE)".
|
||||
- PostScript filter fixes for number-up, OutputOrder,
|
||||
and %Trailer.
|
||||
- The imagetops filter didn't end the base-85 encoding
|
||||
properly if the image data was not a multiple of 4
|
||||
bytes in length.
|
||||
- The imagetoraster filter didn't generate good banded
|
||||
RGB or CMY data (was dividing the line width by 4
|
||||
instead of 3...)
|
||||
- The imagetoraster filter now records the bounding
|
||||
box of the image on the page.
|
||||
- The CUPS image library cache code wasn't working as
|
||||
designed; images larger than the maximum RIP cache
|
||||
would eventually thrash using the same cache tile.
|
||||
- The CUPS image library TIFF loading code didn't
|
||||
handle unknown resolution units properly; the fixed
|
||||
code uses a default resolution of 128 PPI.
|
||||
- cupsGetClasses() and cupsGetPrinters() did not free
|
||||
existing strings if they ran out of memory.
|
||||
- The scheduler logs incorrectly contained 3 digits for
|
||||
the timezone offset instead of 4.
|
||||
- The scheduler now does a lookup for the default user
|
||||
and group ID; the previous hardcoded values caused
|
||||
problems with the LPD backend.
|
||||
- The cancel-job operation now allows any user in the
|
||||
system group to cancel any job.
|
||||
- The cancel-job operation stopped the print queue if
|
||||
the job was being printed.
|
||||
- Now only stop printers if the backend fails. If the
|
||||
filter fails then the failure is noted in the
|
||||
error_log and printing continues with the next file in
|
||||
the queue.
|
||||
- Now log whether a filter fails because of a signal
|
||||
or because it returned a non-zero exit status.
|
||||
- The root user now always passes the system group test.
|
||||
- Printers with an interface script and remote printers
|
||||
and classes didn't have a printer-make-and-model
|
||||
attribute.
|
||||
- Added logging of lost/timed-out remote printers.
|
||||
- The HP-GL/2 filter was scaling the pen width twice.
|
||||
- Updated the HP-GL/2 filter to use a single SP (Set
|
||||
Pen) procedure. This makes the output smaller and is
|
||||
more appropriate since the filter keeps track of the
|
||||
pen states already.
|
||||
- The scheduler didn't handle passwords with spaces.
|
||||
- The IPP backend now does multiple copies and retries
|
||||
if the destination server requires it (e.g. HP
|
||||
JetDirect.)
|
||||
- The disable command didn't implement the "-c" option
|
||||
(cancel all jobs.)
|
||||
- Changed the CMYK generation function for the image file
|
||||
and PostScript RIPs.
|
||||
- The lp command didn't support the "-h" option as
|
||||
documented.
|
||||
- The AppSocket, IPP, and LPD backends now retry on all
|
||||
network errors. This should prevent stopped queues
|
||||
caused by a printer being disconnected from the
|
||||
network or powered off.
|
||||
- The scheduler now restarts a job if the corresponding
|
||||
printer is modified.
|
||||
- The image RIPs now rotate the image if needed to fit
|
||||
on the page.
|
||||
|
||||
|
||||
CHANGES IN CUPS v1.0.2
|
||||
|
||||
- The HP-GL/2 filter didn't always scale the output
|
||||
correctly.
|
||||
- The HP-GL/2 filter now supports changing the page size
|
||||
automatically when the "fitplot" option is not used.
|
||||
- The cancel-job operation was expecting a resource name
|
||||
of the form "/job/#" instead of "/jobs/#"; this
|
||||
prevented the cancel and lprm commands from working.
|
||||
- The backends didn't log pages when files were printed
|
||||
using the "-oraw" option.
|
||||
- The authorization code did not work with the Slackware
|
||||
long shadow password package because its crypt() can
|
||||
return NULL.
|
||||
- The chunking code didn't work for reading the response
|
||||
of a POST request.
|
||||
- cupsGetPPD() now does authentication as needed.
|
||||
- The N-up code in the PostScript filter didn't work
|
||||
with some printers (grestoreall would restore the
|
||||
default blank page and device settings).
|
||||
- The N-up code in the PostScript filter didn't scale
|
||||
the pages to fit within the imageable area of the
|
||||
page.
|
||||
- Wasn't doing an fchown() on the request files. This
|
||||
caused problems when the default root account group
|
||||
and CUPS group were not the same.
|
||||
|
||||
|
||||
CHANGES IN CUPS v1.0.1
|
||||
|
||||
- Documentation updates.
|
||||
- Fixed a bunch of possible buffer-overflow conditions.
|
||||
- The scheduler now supports authentication using PAM.
|
||||
- Updated the Italian message file.
|
||||
- httpEncode64() didn't add an extra "=" if there was
|
||||
only one byte in the last three-byte group.
|
||||
- Now drop any trailing character set from the locale
|
||||
string (e.g. "en_US.ISO_8859-1" becomes "en_US")
|
||||
- Fixed "timezone" vs "tm_gmtoff" usage for BSD-based
|
||||
operating systems.
|
||||
- Updated IPP security so that "get" operations can be
|
||||
done from any resource name; this allows the CGIs to
|
||||
work with printer authentication enabled so long as
|
||||
authentication isn't turned on for the whole "site".
|
||||
- The IPP code didn't properly handle the "unsupported"
|
||||
group; this caused problems with the HP JetDirect since
|
||||
it doesn't seem to support the "copies" attribute.
|
||||
- The HTTP chunking code was missing a CR LF pair at the
|
||||
end of a 0-length chunk.
|
||||
- The httpSeparate() function didn't handle embedded
|
||||
usernames and passwords in the URI properly.
|
||||
- Doing "lpadmin -p printer -E" didn't restart printing
|
||||
if there were pending jobs.
|
||||
- The cancel-job operation now requires either a
|
||||
requesting-user-name attribute or an authenticated
|
||||
username.
|
||||
- The add-printer code did not report errors if the
|
||||
interface script or PPD file could not be renamed.
|
||||
- Request files are now created without world read
|
||||
permissions.
|
||||
- Added a cupsLastError() function to the CUPS API to
|
||||
retrieve the IPP error code from the last request.
|
||||
- Options are now case-insensitive.
|
||||
- The lpq command now provides 10 characters for the
|
||||
username instead of the original (Berkeley standard)
|
||||
7.
|
||||
- The cancel command needed a local CUPS server to work
|
||||
(or the appropriate ServerName in cupsd.conf)
|
||||
- The cancel and lprm commands didn't report the IPP
|
||||
error if the job could not be cancelled.
|
||||
- The lp and lpr commands didn't intercept SIGTERM to
|
||||
remove temporary files when printing from stdin.
|
||||
- The lp and lpr commands didn't report the IPP error if
|
||||
the job could not be printed.
|
||||
+3462
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+1261
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+843
-3611
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+40
-26
@@ -1,33 +1,47 @@
|
||||
CREDITS.txt - 04/26/2003
|
||||
CREDITS.txt - 2008-06-16
|
||||
------------------------
|
||||
|
||||
Few projects are completed by one person, and CUPS is no exception. We'd
|
||||
like to thank the following individuals for their contributions:
|
||||
|
||||
Nathaniel Barbour - Lots of testing and feedback.
|
||||
N. Becker - setsid().
|
||||
Jean-Eric Cuendet - GhostScript filters for CUPS.
|
||||
Van Dang - HTTP and IPP policeman.
|
||||
L. Peter Deutsch - MD5 code.
|
||||
Dr. ZP Han - setgid()/setuid().
|
||||
Guy Harris - *BSD shared libraries and lots of other fixes.
|
||||
Bjoern Jacke - I18N stuff.
|
||||
Wang Jian - CUPS RPM corrections.
|
||||
Roderick Johnstone - Beta tester of the millenium.
|
||||
Till Kamppeter - Bug fixes, beta testing, evangelism.
|
||||
Kiko - Bug fixes.
|
||||
Sergey V. Kovalyov - ESP Print Pro and CUPS beta tester.
|
||||
Mark Lawrence - Microsoft interoperability testing.
|
||||
Jeff Licquia - Bug fixes, beta testing, evangelism.
|
||||
Jason McMullan - Original CUPS RPM distributions.
|
||||
Wes Morgan - *BSD fixes.
|
||||
Ulrich Oldendorf - German locale.
|
||||
Giulio Orsero - Bug fixes and testing.
|
||||
Kurt Pfeifle - Bug fixes, beta testing, evangelism.
|
||||
Gilles QUERRET - French man pages.
|
||||
Petter Reinholdtsen - HP-UX compiler stuff.
|
||||
Stuart Stevens - HP JetDirect IPP information.
|
||||
Andrea Suatoni - IRIX desktop integration and testing.
|
||||
Nathaniel Barbour - Lots of testing and feedback.
|
||||
N. Becker - setsid().
|
||||
Philippe Combes - French localization and buttons script.
|
||||
Jean-Eric Cuendet - GhostScript filters for CUPS.
|
||||
Van Dang - HTTP and IPP policeman.
|
||||
L. Peter Deutsch - MD5 code.
|
||||
Dr. ZP Han - setgid()/setuid().
|
||||
Guy Harris - *BSD shared libraries and lots of other
|
||||
fixes.
|
||||
Bjoern Jacke - I18N stuff.
|
||||
Wang Jian - CUPS RPM corrections.
|
||||
Roderick Johnstone - Beta tester of the millenium.
|
||||
Till Kamppeter - Bug fixes, beta testing, evangelism.
|
||||
Kenshi Muto - Japanese localization, patches, and
|
||||
testing.
|
||||
Tomohiro Kato - Japanese localization.
|
||||
Kiko - Bug fixes.
|
||||
Sergey V. Kovalyov - ESP Print Pro and CUPS beta tester.
|
||||
Marek Laane - Estonian translation.
|
||||
Mark Lawrence - Microsoft interoperability testing.
|
||||
Jeff Licquia - Bug fixes, beta testing, evangelism.
|
||||
Jason McMullan - Original CUPS RPM distributions.
|
||||
Wes Morgan - *BSD fixes.
|
||||
Daniel Nylander - Swedish localization.
|
||||
Giulio Orsero - Bug fixes and testing.
|
||||
Michal Osowiecki - Polish localization.
|
||||
Citra Paska - Indonesian localization.
|
||||
Kurt Pfeifle - Bug fixes, beta testing, evangelism.
|
||||
Vincenzo Reale - Italian localization.
|
||||
Petter Reinholdtsen - HP-UX compiler stuff.
|
||||
Juan Pablo González Riopedre - Spanish localization.
|
||||
Opher Shachar - Hebrew localization.
|
||||
Stuart Stevens - HP JetDirect IPP information.
|
||||
Andrea Suatoni - IRIX desktop integration and testing.
|
||||
Teppo Turlianen - Finnish localization.
|
||||
Tim Waugh - Lots of patches, testing, and Linux
|
||||
integration.
|
||||
Yugami - LDAP browsing support.
|
||||
|
||||
If I've missed someone, please let me know by sending an email to
|
||||
"mike@easysw.com".
|
||||
"msweet@apple.com".
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
ENCRYPTION - CUPS v1.1.20 - 11/24/2003
|
||||
--------------------------------------
|
||||
|
||||
This file describes the encryption support provided by CUPS.
|
||||
|
||||
WARNING: CLIENTS CURRENTLY TRUST ALL CERTIFICATES FROM SERVERS.
|
||||
This makes the CUPS client applications vulnerable to "man in
|
||||
the middle" attacks, so we don't recommend using this to do
|
||||
remote administration over WANs at this time.
|
||||
|
||||
Future versions of CUPS will keep track of server certificates
|
||||
and provide a callback/confirmation interface for accepting new
|
||||
certificates and warning when a certificate has changed.
|
||||
|
||||
|
||||
LEGAL STUFF
|
||||
|
||||
BEFORE USING THE ENCRYPTION SUPPORT, PLEASE VERIFY THAT IT IS
|
||||
LEGAL TO DO SO IN YOUR COUNTRY. CUPS by itself doesn't include
|
||||
any encryption code, but it can link against the OpenSSL, GNU
|
||||
TLS, or CDSA libraries which do.
|
||||
|
||||
|
||||
OVERVIEW OF ENCRYPTION SUPPORT IN CUPS
|
||||
|
||||
CUPS supports SSL/2.0, SSL/3.0, and TLS/1.0 encryption using
|
||||
keys as large as 128-bits. Encryption support is provided via
|
||||
the OpenSSL, GNU TLS, or CDSA libraries and some new hooks in
|
||||
the CUPS code.
|
||||
|
||||
CUPS provides support for dedicated (https) and "upgrade" (TLS)
|
||||
encryption of sessions. The "HTTP Upgrade" method is described
|
||||
in RFC 2817; basically, the client can be secure or unsecure,
|
||||
and the client or server initiates an upgrade to a secure
|
||||
connection via some new HTTP fields and status codes. The HTTP
|
||||
Upgrade method is new and no browsers we know of support it yet.
|
||||
Stick with "https" for web browsers.
|
||||
|
||||
The current implementation is very basic. The CUPS client
|
||||
software (lp, lpr, etc.) uses encryption as requested by the
|
||||
user or server.
|
||||
|
||||
The user can specify the "-E" option with the printing commands
|
||||
to force encryption of the connection. Encryption can also be
|
||||
specified using the Encryption directive in the client.conf file
|
||||
or in the CUPS_ENCRYPTION environment variable:
|
||||
|
||||
Never
|
||||
|
||||
Never do encryption.
|
||||
|
||||
Always
|
||||
|
||||
Always do SSL/TLS encryption using the https scheme.
|
||||
|
||||
IfRequested
|
||||
|
||||
Upgrade to TLS encryption if the server asks for it.
|
||||
This is the default setting.
|
||||
|
||||
Required
|
||||
|
||||
Always upgrade to TLS encryption as soon as the
|
||||
connection is made. This is different than the "Always"
|
||||
mode above since the connection is initially unsecure
|
||||
and the client initiates the upgrade to TLS encryption.
|
||||
(same as using the "-E" option)
|
||||
|
||||
These keywords are also used in the cupsd.conf file to secure
|
||||
particular locations. To secure all traffic on the server, listen
|
||||
on port 443 (https port) instead of port 631 and change the "ipp"
|
||||
service listing (or add it if you don't have one) in /etc/services
|
||||
to 443. To provide both secure and normal methods, add a line
|
||||
reading:
|
||||
|
||||
SSLPort 443
|
||||
|
||||
to /etc/cups/cupsd.conf.
|
||||
|
||||
|
||||
BEFORE YOU BEGIN
|
||||
|
||||
You'll need the OpenSSL, GNU TLS, or CDSA libraries from:
|
||||
|
||||
http://www.openssl.org/
|
||||
http://www.gnutls.org/
|
||||
http://www.intel.com/labs/archive/cdsa.htm
|
||||
|
||||
|
||||
CONFIGURING WITH ENCRYPTION SUPPORT
|
||||
|
||||
Once you have the OpenSSL, GNU TLS, or CDSA libraries installed,
|
||||
you'll need to configure CUPS to use it with the "--enable-ssl"
|
||||
option:
|
||||
|
||||
./configure --enable-ssl
|
||||
|
||||
If the library stuff is not in a standard location, make sure to
|
||||
define the CFLAGS, CXXFLAGS, and LDFLAGS environment variables
|
||||
with the appropriate compiler and linker options first.
|
||||
|
||||
|
||||
GENERATING A SERVER CERTIFICATE AND KEY
|
||||
|
||||
The following OpenSSL command will generate a server certificate
|
||||
and key that you can play with. Since the certificate is not
|
||||
properly signed it will generate all kinds of warnings in
|
||||
Netscape and MSIE:
|
||||
|
||||
openssl req -new -x509 -keyout /etc/cups/ssl/server.key \
|
||||
-out /etc/cups/ssl/server.crt -days 365 -nodes
|
||||
|
||||
chmod 600 /etc/cups/ssl/server.*
|
||||
|
||||
The "-nodes" option prevents the certificate and key from being
|
||||
encrypted. The cupsd process runs in the background, detached
|
||||
from any input source; if you encrypt these files then cupsd
|
||||
will not be able to load them!
|
||||
|
||||
Send all rants about non-encrypted certificate and key files to
|
||||
/dev/null. It makes sense to encrypt user files, but not for
|
||||
files used by system processes/daemons...
|
||||
|
||||
|
||||
REPORTING PROBLEMS
|
||||
|
||||
If you have problems, READ THE DOCUMENTATION FIRST! If the
|
||||
documentation does not solve your problems please send an email
|
||||
to "cups-support@cups.org". Include your operating system and
|
||||
version, compiler and version, and any errors or problems you've
|
||||
run into. The "/var/log/cups/error_log" file should also be sent,
|
||||
as it often helps to determine the cause of your problem.
|
||||
|
||||
If you are running a version of Linux, be sure to provide the
|
||||
Linux distribution you have, too.
|
||||
|
||||
Please note that the "cups-support@cups.org" email address goes
|
||||
to the CUPS developers; they are busy people, so your email may
|
||||
go unanswered for days or weeks. In general, only general build
|
||||
or distribution problems will actually get answered - for
|
||||
end-user support see the "README.txt" for a summary of the
|
||||
resources available.
|
||||
+117
-126
@@ -1,4 +1,4 @@
|
||||
INSTALL - CUPS v1.1.20 - 11/24/2003
|
||||
INSTALL - CUPS v1.3.11 - 2009-06-26
|
||||
-----------------------------------
|
||||
|
||||
This file describes how to compile and install CUPS from source
|
||||
@@ -6,185 +6,176 @@ code. For more information on CUPS see the file called
|
||||
"README.txt". A complete change log can be found in
|
||||
"CHANGES.txt".
|
||||
|
||||
**** IF YOU HAVE A NON-POSTSCRIPT PRINTER, YOU WILL ALSO ****
|
||||
**** NEED TO INSTALL ESP GHOSTSCRIPT OR A PATCHED VERSION ****
|
||||
**** OF THE STANDARD GHOSTSCRIPT RELEASES. ****
|
||||
**** IF YOU HAVE A NON-POSTSCRIPT PRINTER AND ARE NOT ****
|
||||
**** RUNNING MAC OS X, YOU WILL ALSO NEED TO INSTALL GPL ****
|
||||
**** GHOSTSCRIPT WITH THE "cups" DRIVER AFTER YOU INSTALL ****
|
||||
**** CUPS. ****
|
||||
|
||||
|
||||
BEFORE YOU BEGIN
|
||||
|
||||
You'll need ANSI-compliant C and C++ compilers, plus a make
|
||||
program and Bourne shell. The GNU compiler tools work well -
|
||||
we've tested the current CUPS code against GCC 2.95.x with
|
||||
excellent results.
|
||||
You'll need ANSI-compliant C and C++ compilers, plus a make
|
||||
program and Bourne shell. The GNU compiler tools work well -
|
||||
we've tested the current CUPS code against several versions
|
||||
of GCC with excellent results.
|
||||
|
||||
The makefiles used by the project should work with all versions
|
||||
of make. We've tested them with GNU make as well as the make
|
||||
programs shipped by Compaq, HP, SGI, and Sun. FreeBSD users
|
||||
should use GNU make (gmake).
|
||||
The makefiles used by the project should work with all
|
||||
versions of make. We've tested them with GNU make as well as
|
||||
the make programs shipped by Compaq, HP, SGI, and Sun.
|
||||
BSD users should use GNU make (gmake).
|
||||
|
||||
Besides these tools you'll want the following libraries:
|
||||
Besides these tools you'll want the JPEG, PNG, TIFF, and ZLIB
|
||||
libraries for image support, the CDSA, GNU TLS, or OpenSSL
|
||||
libraries for encryption support, and the OpenLDAP and
|
||||
OpenSLP libraries for directory services support. CUPS will
|
||||
compile and run without these, however you'll miss out on
|
||||
many of the features provided by CUPS.
|
||||
|
||||
- JPEG 6b or higher
|
||||
- PNG 1.0.6 or higher
|
||||
- TIFF 3.4 or higher
|
||||
- ZLIB 1.1.3 or higher
|
||||
Kerberos support requires MIT Kerberos 1.6.3 or later or
|
||||
Heimdal Kerberos, along with the corresponding GSSAPI
|
||||
pieces.
|
||||
|
||||
CUPS will compile and run without these, however you'll miss out on
|
||||
many of the features provided by CUPS.
|
||||
|
||||
Also, please note that CUPS no longer includes the Ghostscript-
|
||||
based pstoraster filter. You *must* download Ghostscript
|
||||
separately and patch it using the files in the pstoraster
|
||||
subdirectory, or download the ESP Ghostscript distribution from
|
||||
the CUPS web site. For more information see the README file in
|
||||
the pstoraster subdirectory.
|
||||
Also, please note that CUPS no longer includes the
|
||||
Ghostscript- based pstoraster filter. You *must* download
|
||||
GPL Ghostscript separately from the CUPS web site if you want
|
||||
to print PostScript files to non-PostScript printers on
|
||||
operating systems other than Mac OS X.
|
||||
|
||||
|
||||
COMPILING FROM CVS
|
||||
COMPILING FROM SUBVERSION
|
||||
|
||||
The CUPS CVS repository doesn't hold a copy of the pre-built
|
||||
configure script. You'll need to run the GNU autoconf software
|
||||
(2.52 or higher) before compiling the software from CVS:
|
||||
The CUPS Subversion repository doesn't hold a copy of the
|
||||
pre-built configure script. You'll need to run the GNU
|
||||
autoconf software (2.60 or higher) before compiling the
|
||||
software from Subversion:
|
||||
|
||||
autoconf ENTER
|
||||
autoconf -f
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
|
||||
CUPS uses GNU autoconf, so you should find the usual "configure"
|
||||
script in the main CUPS source directory. To configure CUPS for
|
||||
your system, type:
|
||||
CUPS uses GNU autoconf, so you should find the usual
|
||||
"configure" script in the main CUPS source directory. To
|
||||
configure CUPS for your system, type:
|
||||
|
||||
./configure ENTER
|
||||
./configure
|
||||
|
||||
The default installation will put the CUPS software in the
|
||||
"/etc", "/usr", and "/var" directories on your system, which
|
||||
will overwrite any existing printing commands on your system.
|
||||
Use the "--prefix" option to install the CUPS software in
|
||||
another location:
|
||||
The default installation will put the CUPS software in the
|
||||
"/etc", "/usr", and "/var" directories on your system, which
|
||||
will overwrite any existing printing commands on your system.
|
||||
Use the "--prefix" option to install the CUPS software in
|
||||
another location:
|
||||
|
||||
./configure --prefix=/some/directory ENTER
|
||||
./configure --prefix=/some/directory
|
||||
|
||||
If the PNG, JPEG, TIFF, and ZLIB libraries are not installed in
|
||||
a system default location (typically "/usr/include" and
|
||||
"/usr/lib") you'll need to set the CFLAGS, CXXFLAGS, DSOFLAGS,
|
||||
and LDFLAGS environment variables prior to running configure:
|
||||
To see a complete list of configuration options, use the
|
||||
--help option:
|
||||
|
||||
setenv CFLAGS "-I/some/directory" ENTER
|
||||
setenv CXXFLAGS "-I/some/directory" ENTER
|
||||
setenv DSOFLAGS "-L/some/directory" ENTER
|
||||
setenv LDFLAGS "-L/some/directory" ENTER
|
||||
./configure ... ENTER
|
||||
./configure --help
|
||||
|
||||
or:
|
||||
If any of the dependent libraries are not installed in a
|
||||
system default location (typically "/usr/include" and
|
||||
"/usr/lib") you'll need to set the CFLAGS, CPPFLAGS,
|
||||
CXXFLAGS, DSOFLAGS, and LDFLAGS environment variables prior
|
||||
to running configure:
|
||||
|
||||
CFLAGS="-I/some/directory"; export CFLAGS ENTER
|
||||
CXXFLAGS="-I/some/directory"; export CXXFLAGS ENTER
|
||||
DSOFLAGS="-L/some/directory"; export DSOFLAGS ENTER
|
||||
LDFLAGS="-L/some/directory"; export LDFLAGS ENTER
|
||||
./configure ... ENTER
|
||||
setenv CFLAGS "-I/some/directory"
|
||||
setenv CPPFLAGS "-I/some/directory"
|
||||
setenv CXXFLAGS "-I/some/directory"
|
||||
setenv DSOFLAGS "-L/some/directory"
|
||||
setenv LDFLAGS "-L/some/directory"
|
||||
./configure ...
|
||||
|
||||
To enable support for encryption, you'll also want to add the
|
||||
"--enable-ssl" option:
|
||||
or:
|
||||
|
||||
./configure --enable-ssl
|
||||
CFLAGS="-I/some/directory" \
|
||||
CPPFLAGS="-I/some/directory" \
|
||||
CXXFLAGS="-I/some/directory" \
|
||||
DSOFLAGS="-L/some/directory" \
|
||||
LDFLAGS="-L/some/directory" \
|
||||
./configure ...
|
||||
|
||||
SSL and TLS support require the OpenSSL library, available at:
|
||||
Once you have configured things, just type:
|
||||
|
||||
http://www.openssl.org
|
||||
make ENTER
|
||||
|
||||
If the OpenSSL header files and libraries are not in a standard
|
||||
location, specify the locations of these files using the
|
||||
--with-openssl-includes and --with-openssl-libs directives:
|
||||
or if you have FreeBSD, NetBSD, or OpenBSD type:
|
||||
|
||||
./configure --enable-ssl \
|
||||
--with-openssl-includes=/foo/bar/include \
|
||||
--with-openssl-libs=/foo/bar/lib
|
||||
gmake ENTER
|
||||
|
||||
See the file "ENCRYPTION.txt" for information on using the
|
||||
encryption support in CUPS.
|
||||
|
||||
Once you have configured things, just type:
|
||||
|
||||
make ENTER
|
||||
|
||||
or if you have FreeBSD, NetBSD, or OpenBSD type:
|
||||
|
||||
gmake ENTER
|
||||
|
||||
to build the software.
|
||||
to build the software.
|
||||
|
||||
|
||||
INSTALLING THE SOFTWARE
|
||||
|
||||
Once you have built the software you need to install it. The
|
||||
"install" target provides a quick way to install the software on
|
||||
your local system:
|
||||
Once you have built the software you need to install it. The
|
||||
"install" target provides a quick way to install the software
|
||||
on your local system:
|
||||
|
||||
make install ENTER
|
||||
make install ENTER
|
||||
|
||||
or for FreeBSD, NetBSD, or OpenBSD:
|
||||
or for FreeBSD, NetBSD, or OpenBSD:
|
||||
|
||||
gmake install ENTER
|
||||
gmake install ENTER
|
||||
|
||||
You can also build binary packages that can be installed on other
|
||||
machines using the RPM spec file ("cups.spec") or EPM list file
|
||||
("cups.list"). The latter also supports building of binary RPMs,
|
||||
so it may be more convenient to use - we use EPM to build all of
|
||||
our binary distributions.
|
||||
You can also build binary packages that can be installed on
|
||||
other machines using the RPM spec file
|
||||
("packaging/cups.spec") or EPM list file
|
||||
("packaging/cups.list"). The latter also supports building
|
||||
of binary RPMs, so it may be more convenient to use - we use
|
||||
EPM to build all of our binary distributions.
|
||||
|
||||
You can find the RPM software at:
|
||||
You can find the RPM software at:
|
||||
|
||||
http://www.rpm.org
|
||||
http://www.rpm.org/
|
||||
|
||||
The EPM software is at:
|
||||
The EPM software is available at:
|
||||
|
||||
http://www.easysw.com/epm/
|
||||
http://www.easysw.com/epm/
|
||||
|
||||
|
||||
CREATING BINARY DISTRIBUTIONS WITH EPM
|
||||
|
||||
The top level makefile supports generation of many types of binary
|
||||
distributions using EPM. To build a binary distribution type:
|
||||
The top level makefile supports generation of many types of binary
|
||||
distributions using EPM. To build a binary distribution type:
|
||||
|
||||
make <format> ENTER
|
||||
make <format> ENTER
|
||||
|
||||
or
|
||||
or
|
||||
|
||||
gmake <format> ENTER
|
||||
gmake <format> ENTER
|
||||
|
||||
for FreeBSD, NetBSD, and OpenBSD. The <format> target is one of
|
||||
the following:
|
||||
for FreeBSD, NetBSD, and OpenBSD. The <format> target is one of
|
||||
the following:
|
||||
|
||||
epm - Builds a portable shell script and tar file based
|
||||
distribution. This format will also backup your
|
||||
existing printing system if you decide to remove
|
||||
CUPS at some future time.
|
||||
aix - Builds an AIX binary distribution.
|
||||
bsd - Builds a *BSD binary distribution.
|
||||
deb - Builds a Debian binary distribution.
|
||||
depot - Builds a HP-UX binary distribution.
|
||||
pkg - Builds a Solaris binary distribution.
|
||||
rpm - Builds a RPM binary distribution.
|
||||
tardist - Builds an IRIX binary distribution.
|
||||
epm - Builds a script + tarfile package
|
||||
aix - Builds an AIX package
|
||||
bsd - Builds a *BSD package
|
||||
deb - Builds a Debian package
|
||||
depot - Builds a HP-UX package (also swinstall)
|
||||
inst - Builds an IRIX package (also tardist)
|
||||
osx - Builds a MacOS X package
|
||||
pkg - Builds a Solaris package
|
||||
rpm - Builds a RPM package
|
||||
setld - Build a Tru64 UNIX package
|
||||
slackware - Build a Slackware package
|
||||
swinstall - Build a HP-UX package (also depot)
|
||||
tardist - Builds an IRIX package (also inst)
|
||||
|
||||
|
||||
REPORTING PROBLEMS
|
||||
|
||||
If you have problems, READ THE DOCUMENTATION FIRST! If the
|
||||
documentation does not solve your problems please send an email
|
||||
to "cups-support@cups.org". Include your operating system and
|
||||
version, compiler and version, and any errors or problems you've
|
||||
run into. The "/var/log/cups/error_log" file should also be sent,
|
||||
as it often helps to determine the cause of your problem.
|
||||
If you have problems, READ THE DOCUMENTATION FIRST! If the
|
||||
documentation does not solve your problems, please post a
|
||||
message on the "cups.general" forum at:
|
||||
|
||||
If you are running a version of Linux, be sure to provide the
|
||||
Linux distribution you have, too.
|
||||
http://www.cups.org/newsgroups.php
|
||||
|
||||
Please note that the "cups-support@cups.org" email address goes
|
||||
to the CUPS developers; they are busy people, so your email may
|
||||
go unanswered for days or weeks. In general, only general build
|
||||
or distribution problems will actually get answered - for
|
||||
end-user support see the "README.txt" for a summary of the
|
||||
resources available.
|
||||
Include your operating system and version, compiler and
|
||||
version, and any errors or problems you've run into. The
|
||||
"config.log" file and the output from the configure script
|
||||
and make should also be sent, as it often helps to determine
|
||||
the cause of your problem.
|
||||
|
||||
If you are running a version of Linux, be sure to provide the
|
||||
Linux distribution you have, too.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
INSTALL_fr - CUPS v1.1.19 - 04/08/2003
|
||||
--------------------------------------
|
||||
|
||||
Vous cherchez des instructions d'installation ? Lisez le fichier
|
||||
INSTALL.txt (anglais) et/ou reportez vous au "Manuel de
|
||||
l'administrateur" (en français) situé dans le sous-répertoire
|
||||
"doc/fr"
|
||||
|
||||
Vous trouverez deux autres manuels en français dans ce
|
||||
sous-répertoire :
|
||||
|
||||
- Aperçu de CUPS
|
||||
- Manuel de l'utilisateur
|
||||
|
||||
Une fois CUPS installé, si vous configurez votre navigateur
|
||||
"web" pour que la langue de base soit le français, vous
|
||||
disposerez également d'une interface "web" en français pour
|
||||
l'administration et d'utilistation de CUPS.
|
||||
|
||||
+179
-67
@@ -1,28 +1,25 @@
|
||||
Common UNIX Printing System License Agreement
|
||||
CUPS License Agreement
|
||||
|
||||
Copyright 1997-2004 by Easy Software Products
|
||||
44141 AIRPORT VIEW DR STE 204
|
||||
HOLLYWOOD, MARYLAND 20636-3142 USA
|
||||
Copyright 2007-2009 by Apple Inc.
|
||||
1 Infinite Loop
|
||||
Cupertino, CA 95014 USA
|
||||
|
||||
Voice: +1.301.373.9600
|
||||
Email: cups-info@cups.org
|
||||
WWW: http://www.cups.org
|
||||
WWW: http://www.cups.org/
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
The Common UNIX Printing System(tm), ("CUPS(tm)"), is provided
|
||||
under the GNU General Public License ("GPL") and GNU Library
|
||||
General Public License ("LGPL"), Version 2, with exceptions for
|
||||
Apple operating systems and the OpenSSL toolkit. A copy of the
|
||||
exceptions and licenses follow this introduction.
|
||||
CUPS(tm) is provided under the GNU General Public License ("GPL")
|
||||
and GNU Library General Public License ("LGPL"), Version 2, with
|
||||
exceptions for Apple operating systems and the OpenSSL toolkit. A
|
||||
copy of the exceptions and licenses follow this introduction.
|
||||
|
||||
The GNU LGPL applies to the CUPS API library, located in the
|
||||
"cups" subdirectory of the CUPS source distribution and in the
|
||||
"cups" include directory and library files in the binary
|
||||
distributions. The GNU GPL applies to the remainder of the CUPS
|
||||
distribution, including the "pdftops" filter which is based upon
|
||||
Xpdf and the CUPS imaging library.
|
||||
The GNU LGPL applies to the CUPS and CUPS Imaging libraries
|
||||
located in the "cups" and "filter" subdirectories of the CUPS
|
||||
source distribution and in the "cups" include directory and
|
||||
library files in the binary distributions. The GNU GPL applies to
|
||||
the remainder of the CUPS distribution, including the "pdftops"
|
||||
filter which is based upon Xpdf.
|
||||
|
||||
For those not familiar with the GNU GPL, the license basically
|
||||
allows you to:
|
||||
@@ -32,28 +29,25 @@ allows you to:
|
||||
binary form.
|
||||
- Sell verbatim copies of the software for a media fee, or
|
||||
sell support for the software.
|
||||
- Distribute or sell printer drivers and filters that use
|
||||
CUPS so long as source code is made available under the
|
||||
GPL.
|
||||
|
||||
What this license *does not* allow you to do is make changes or
|
||||
add features to CUPS and then sell a binary distribution without
|
||||
source code. You must provide source for any new drivers,
|
||||
changes, or additions to the software, and all code must be
|
||||
provided under the GPL or LGPL as appropriate. The only
|
||||
exceptions to this are the portions of the CUPS software covered
|
||||
by the Apple operating system license exceptions outlined later
|
||||
in this license agreement.
|
||||
source code. You must provide source for any changes or additions
|
||||
to the software, and all code must be provided under the GPL or
|
||||
LGPL as appropriate. The only exceptions to this are the portions
|
||||
of the CUPS software covered by the Apple operating system
|
||||
license exceptions outlined later in this license agreement.
|
||||
|
||||
The GNU LGPL relaxes the "link-to" restriction, allowing you to
|
||||
develop applications that use the CUPS API library under other
|
||||
licenses and/or conditions as appropriate for your application.
|
||||
develop applications that use the CUPS and CUPS Imaging libraries
|
||||
under other licenses and/or conditions as appropriate for your
|
||||
application, driver, or filter.
|
||||
|
||||
|
||||
LICENSE EXCEPTIONS
|
||||
|
||||
In addition, as the copyright holder of CUPS, Easy Software
|
||||
Products grants the following special exceptions:
|
||||
In addition, as the copyright holder of CUPS, Apple Inc. grants
|
||||
the following special exceptions:
|
||||
|
||||
1. Apple Operating System Development License Exception;
|
||||
|
||||
@@ -96,49 +90,64 @@ Products grants the following special exceptions:
|
||||
|
||||
2. OpenSSL Toolkit License Exception;
|
||||
|
||||
a. Easy Software Products explicitly allows the
|
||||
compilation and distribution of the CUPS software
|
||||
with the OpenSSL Toolkit.
|
||||
a. Apple Inc. explicitly allows the compilation and
|
||||
distribution of the CUPS software with the OpenSSL
|
||||
Toolkit.
|
||||
|
||||
No developer is required to provide these exceptions in a
|
||||
derived work.
|
||||
|
||||
|
||||
KERBEROS SUPPORT CODE
|
||||
|
||||
The Kerberos support code ("KSC") is copyright 2006 by Jelmer
|
||||
Vernooij and is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author or Apple Inc. be held
|
||||
liable for any damages arising from the use of the KSC.
|
||||
|
||||
Sources files containing KSC have the following text at the top
|
||||
of each source file:
|
||||
|
||||
This file contains Kerberos support code, copyright 2006 by
|
||||
Jelmer Vernooij.
|
||||
|
||||
The KSC copyright and license apply only to Kerberos-related
|
||||
feature code in CUPS. Such code is typically conditionally
|
||||
compiled based on the present of the HAVE_GSSAPI preprocessor
|
||||
definition.
|
||||
|
||||
Permission is granted to anyone to use the KSC for any purpose,
|
||||
including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of the KSC must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If
|
||||
you use the KSC in a product, an acknowledgment in the
|
||||
product documentation would be appreciated but is not
|
||||
required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such,
|
||||
and must not be misrepresented as being the original
|
||||
software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
TRADEMARKS
|
||||
|
||||
Easy Software Products has trademarked the Common UNIX Printing
|
||||
System, CUPS, and CUPS logo. You may use these names and logos
|
||||
in any direct port or binary distribution of CUPS. Please
|
||||
contact Easy Software Products for written permission to use
|
||||
them in derivative products. Our intention is to protect the
|
||||
value of these trademarks and ensure that any derivative product
|
||||
meets the same high-quality standards as the original.
|
||||
|
||||
|
||||
BINARY DISTRIBUTION RIGHTS
|
||||
|
||||
Easy Software Products also sells rights to the CUPS source code
|
||||
under a binary distribution license for vendors that are unable
|
||||
to release source code for their drivers, additions, and
|
||||
modifications to CUPS under the GNU GPL and LGPL. For
|
||||
information please contact us at the address shown above.
|
||||
|
||||
The Common UNIX Printing System provides a "pdftops" filter that
|
||||
is based on the Xpdf software. For binary distribution licensing
|
||||
of this software, please contact:
|
||||
|
||||
Derek B. Noonburg
|
||||
Email: derekn@foolabs.com
|
||||
WWW: http://www.foolabs.com/xpdf/
|
||||
|
||||
|
||||
SUPPORT
|
||||
|
||||
Easy Software Products sells software support for CUPS as well
|
||||
as a commercial printing product based on CUPS called ESP Print
|
||||
Pro. You can find out more at our web site:
|
||||
|
||||
http://www.easysw.com/
|
||||
CUPS and the CUPS logo (the "CUPS Marks") are trademarks of Apple
|
||||
Inc. Apple grants you a non-exclusive and non-transferable right
|
||||
to use the CUPS Marks in any direct port or binary distribution
|
||||
incorporating CUPS software and in any promotional material
|
||||
therefor. You agree that your products will meet the highest
|
||||
levels of quality and integrity for similar goods, not be unlawful,
|
||||
and be developed, manufactured, and distributed in compliance with
|
||||
this license. You will not interfere with Apple's rights in the
|
||||
CUPS Marks, and all use of the CUPS Marks shall inure to the
|
||||
benefit of Apple. This license does not apply to use of the CUPS
|
||||
Marks in a derivative products, which requires prior written
|
||||
permission from Apple Inc.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
@@ -420,6 +429,65 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
@@ -859,3 +927,47 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
+133
-48
@@ -3,23 +3,14 @@
|
||||
#
|
||||
# Common makefile definitions for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
# Copyright 2007-2008 by Apple Inc.
|
||||
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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-3142 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
#
|
||||
@@ -33,12 +24,14 @@ CXX = @LIBTOOL@ @CXX@
|
||||
DSO = @DSO@
|
||||
HTMLDOC = @HTMLDOC@
|
||||
INSTALL = @INSTALL@
|
||||
LD = @LD@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN = @LN@ -sf
|
||||
MV = @MV@
|
||||
NROFF = @NROFF@
|
||||
PHPCONFIG = @PHPCONFIG@
|
||||
RANLIB = @RANLIB@
|
||||
RM = @RM@ -f
|
||||
RMDIR = @RMDIR@
|
||||
SED = @SED@
|
||||
SHELL = /bin/sh
|
||||
STRIP = @STRIP@
|
||||
@@ -47,7 +40,8 @@ STRIP = @STRIP@
|
||||
# Installation programs...
|
||||
#
|
||||
|
||||
INSTALL_BIN = $(LIBTOOL) $(INSTALL) -m 755 -s
|
||||
INSTALL_BIN = $(LIBTOOL) $(INSTALL) -m 755
|
||||
INSTALL_CONFIG = $(INSTALL) -m @CUPS_CONFIG_FILE_PERM@
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
INSTALL_DIR = $(INSTALL) -d
|
||||
INSTALL_LIB = $(LIBTOOL) $(INSTALL) -m 755
|
||||
@@ -55,11 +49,28 @@ INSTALL_MAN = $(INSTALL) -m 644
|
||||
INSTALL_SCRIPT = $(INSTALL) -m 755
|
||||
|
||||
#
|
||||
# Default user and group for the scheduler...
|
||||
# Default user, group, and system groups for the scheduler...
|
||||
#
|
||||
|
||||
CUPS_USER = @CUPS_USER@
|
||||
CUPS_GROUP = @CUPS_GROUP@
|
||||
CUPS_SYSTEM_GROUPS = @CUPS_SYSTEM_GROUPS@
|
||||
CUPS_PRIMARY_SYSTEM_GROUP = @CUPS_PRIMARY_SYSTEM_GROUP@
|
||||
|
||||
#
|
||||
# Default permissions...
|
||||
#
|
||||
|
||||
CUPS_CONFIG_FILE_PERM = @CUPS_CONFIG_FILE_PERM@
|
||||
CUPS_LOG_FILE_PERM = @CUPS_LOG_FILE_PERM@
|
||||
|
||||
#
|
||||
# Languages to install...
|
||||
#
|
||||
|
||||
LANGUAGES = @LANGUAGES@
|
||||
INSTALL_LANGUAGES = @INSTALL_LANGUAGES@
|
||||
UNINSTALL_LANGUAGES = @UNINSTALL_LANGUAGES@
|
||||
|
||||
#
|
||||
# Libraries...
|
||||
@@ -68,41 +79,91 @@ CUPS_GROUP = @CUPS_GROUP@
|
||||
LIBCUPS = @LIBCUPS@
|
||||
LIBCUPSIMAGE = @LIBCUPSIMAGE@
|
||||
LIBJPEG = @LIBJPEG@
|
||||
LIBLDAP = @LIBLDAP@
|
||||
LIBMALLOC = @LIBMALLOC@
|
||||
LIBPAPER = @LIBPAPER@
|
||||
LIBPNG = @LIBPNG@
|
||||
LIBSLP = @LIBSLP@
|
||||
LIBGSSAPI = @LIBGSSAPI@
|
||||
LIBTIFF = @LIBTIFF@
|
||||
LIBZ = @LIBZ@
|
||||
|
||||
#
|
||||
# Program options...
|
||||
#
|
||||
# OPTIM defines the common compiler optimization/debugging options.
|
||||
# OPTIONS defines other compile-time options (currently only -dDEBUG for
|
||||
# extra debug info)
|
||||
# Install static libraries?
|
||||
#
|
||||
|
||||
INSTALLSTATIC = @INSTALLSTATIC@
|
||||
|
||||
#
|
||||
# Program options...
|
||||
#
|
||||
# ARCHFLAGS Defines the default architecture build options.
|
||||
# ARCH32FLAGS Defines the 32-bit architecture build options, used
|
||||
# when compiling separate 32/64-bit libraries.
|
||||
# ARCH64FLAGS Defines the 64-bit architecture build options, used
|
||||
# when compiling separate 32/64-bit libraries.
|
||||
# OPTIM Defines the common compiler optimization/debugging options
|
||||
# for all architectures.
|
||||
# OPTIONS Defines other compile-time options (currently only -DDEBUG
|
||||
# for extra debug info)
|
||||
#
|
||||
|
||||
ALL_CFLAGS = -I.. -D_CUPS_SOURCE $(CFLAGS) $(SSLFLAGS) \
|
||||
@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
|
||||
ALL_CXXFLAGS = -I.. -D_CUPS_SOURCE $(CXXFLAGS) $(SSLFLAGS) \
|
||||
@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
|
||||
ARCHFLAGS = @ARCHFLAGS@
|
||||
ARFLAGS = @ARFLAGS@
|
||||
BACKLIBS = @BACKLIBS@
|
||||
CFLAGS = $(RC_CFLAGS) $(SSLFLAGS) @CPPFLAGS@ @CFLAGS@ -I.. $(OPTIONS)
|
||||
COMMONLIBS = @COMMONLIBS@
|
||||
CXXFLAGS = $(RC_CFLAGS) @CPPFLAGS@ @CXXFLAGS@ -I.. $(OPTIONS)
|
||||
CFLAGS = @CPPFLAGS@ @CFLAGS@
|
||||
COMMONLIBS = @LIBS@
|
||||
CUPSDLIBS = @CUPSDLIBS@
|
||||
CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@
|
||||
CXXLIBS = @CXXLIBS@
|
||||
DSOFLAGS = @DSOFLAGS@
|
||||
DSOLIBS = @DSOLIBS@ $(COMMONLIBS)
|
||||
IMGLIBS = @IMGLIBS@ -lm
|
||||
LDFLAGS = -L../cups -L../filter $(RC_CFLAGS) @LDFLAGS@ $(OPTIM)
|
||||
LINKCUPS = @LINKCUPS@
|
||||
DNSSDLIBS = @DNSSDLIBS@
|
||||
FONTS = @FONTS@
|
||||
IMGLIBS = @IMGLIBS@
|
||||
IMGFILTERS = @IMGFILTERS@
|
||||
LAUNCHDLIBS = @LAUNCHDLIBS@
|
||||
LDFLAGS = -L../cups -L../filter @LDARCHFLAGS@ \
|
||||
@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
|
||||
LEGACY_BACKENDS = @LEGACY_BACKENDS@
|
||||
LIBCUPSORDER = @LIBCUPSORDER@
|
||||
LIBCUPSIMAGEORDER = @LIBCUPSIMAGEORDER@
|
||||
LINKCUPS = @LINKCUPS@ $(SSLLIBS)
|
||||
LINKCUPSIMAGE = @LINKCUPSIMAGE@
|
||||
LIBS = $(LINKCUPS) $(NETLIBS) @LIBS@ $(COMMONLIBS)
|
||||
NETLIBS = @NETLIBS@
|
||||
LIBS = $(LINKCUPS) $(COMMONLIBS)
|
||||
OPTIM = @OPTIM@
|
||||
OPTIONS =
|
||||
PAMLIBS = @PAMLIBS@
|
||||
PAP = @PAP@
|
||||
PDFTOPS = @PDFTOPS@
|
||||
PHPDIR = @PHPDIR@
|
||||
SSLFLAGS = @SSLFLAGS@
|
||||
SSLLIBS = @SSLLIBS@
|
||||
|
||||
#
|
||||
# Separate 32/64-bit library support...
|
||||
#
|
||||
|
||||
ARCH32FLAGS = @ARCH32FLAGS@
|
||||
DSO32FLAGS = @DSO32FLAGS@
|
||||
INSTALL32 = @INSTALL32@
|
||||
LIB32CUPS = @LIB32CUPS@
|
||||
LIB32CUPSIMAGE = @LIB32CUPSIMAGE@
|
||||
LIB32DIR = $(BUILDROOT)@LIB32DIR@
|
||||
UNINSTALL32 = @UNINSTALL32@
|
||||
|
||||
ARCH64FLAGS = @ARCH64FLAGS@
|
||||
DSO64FLAGS = @DSO64FLAGS@
|
||||
INSTALL64 = @INSTALL64@
|
||||
LIB64CUPS = @LIB64CUPS@
|
||||
LIB64CUPSIMAGE = @LIB64CUPSIMAGE@
|
||||
LIB64DIR = $(BUILDROOT)@LIB64DIR@
|
||||
UNINSTALL64 = @UNINSTALL64@
|
||||
|
||||
#
|
||||
# Directories...
|
||||
#
|
||||
@@ -111,12 +172,16 @@ SSLLIBS = @SSLLIBS@
|
||||
# We have to define these first because autoconf uses ${prefix}
|
||||
# and ${exec_prefix} for most of the other directories...
|
||||
#
|
||||
# The "datarootdir" variable may not get defined if you are using
|
||||
# a version of autoconf prior to 2.60.
|
||||
#
|
||||
# This is immediately followed by definition in ALL CAPS for the
|
||||
# needed directories...
|
||||
#
|
||||
|
||||
bindir = @bindir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
exec_prefix = @exec_prefix@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
@@ -136,8 +201,10 @@ BUILDROOT = $(DSTROOT)
|
||||
|
||||
AMANDIR = $(BUILDROOT)@AMANDIR@
|
||||
BINDIR = $(BUILDROOT)@bindir@
|
||||
CACHEDIR = $(BUILDROOT)@CUPS_CACHEDIR@
|
||||
DATADIR = $(BUILDROOT)@CUPS_DATADIR@
|
||||
DOCDIR = $(BUILDROOT)@CUPS_DOCROOT@
|
||||
ICONDIR = @ICONDIR@
|
||||
INCLUDEDIR = $(BUILDROOT)$(includedir)
|
||||
INITDIR = @INITDIR@
|
||||
INITDDIR = @INITDDIR@
|
||||
@@ -145,45 +212,63 @@ LIBDIR = $(BUILDROOT)$(libdir)
|
||||
LOCALEDIR = $(BUILDROOT)@CUPS_LOCALEDIR@
|
||||
LOGDIR = $(BUILDROOT)@CUPS_LOGDIR@
|
||||
MANDIR = $(BUILDROOT)@mandir@
|
||||
MENUDIR = @MENUDIR@
|
||||
PMANDIR = $(BUILDROOT)@PMANDIR@
|
||||
RCLEVELS = @RCLEVELS@
|
||||
RCSTART = @RCSTART@
|
||||
RCSTOP = @RCSTOP@
|
||||
REQUESTS = $(BUILDROOT)@CUPS_REQUESTS@
|
||||
SBINDIR = $(BUILDROOT)@sbindir@
|
||||
SERVERBIN = $(BUILDROOT)@CUPS_SERVERBIN@
|
||||
SERVERROOT = $(BUILDROOT)@CUPS_SERVERROOT@
|
||||
STATEDIR = $(BUILDROOT)@CUPS_STATEDIR@
|
||||
XINETD = @XINETD@
|
||||
|
||||
CAT1EXT = @CAT1EXT@
|
||||
CAT3EXT = @CAT3EXT@
|
||||
CAT5EXT = @CAT5EXT@
|
||||
CAT8EXT = @CAT8EXT@
|
||||
MAN1EXT = @MAN1EXT@
|
||||
MAN5EXT = @MAN5EXT@
|
||||
MAN7EXT = @MAN7EXT@
|
||||
MAN8EXT = @MAN8EXT@
|
||||
MAN8DIR = @MAN8DIR@
|
||||
|
||||
PAMDIR = $(BUILDROOT)@PAMDIR@
|
||||
PAMDIR = @PAMDIR@
|
||||
PAMFILE = @PAMFILE@
|
||||
|
||||
DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@
|
||||
DBUSDIR = @DBUSDIR@
|
||||
|
||||
|
||||
#
|
||||
# Rules...
|
||||
#
|
||||
|
||||
.SILENT:
|
||||
.SUFFIXES: .a .c .cxx .h .man .o .0 .1 .1m .3 .5 .8 .z
|
||||
.SUFFIXES: .1 .1.gz .1m .1m.gz .5 .5.gz .7 .7.gz .8 .8.gz .a .c .cxx .h .man .o .32.o .64.o .gz
|
||||
|
||||
.c.o:
|
||||
echo Compiling $<...
|
||||
$(CC) $(OPTIM) $(CFLAGS) -c $<
|
||||
$(CC) $(ARCHFLAGS) $(OPTIM) $(ALL_CFLAGS) -c $<
|
||||
|
||||
.c.32.o:
|
||||
echo Compiling 32-bit $<...
|
||||
$(CC) $(ARCH32FLAGS) $(OPTIM) $(ALL_CFLAGS) -c -o $@ $<
|
||||
|
||||
.c.64.o:
|
||||
echo Compiling 64-bit $<...
|
||||
$(CC) $(ARCH64FLAGS) $(OPTIM) $(ALL_CFLAGS) -c -o $@ $<
|
||||
|
||||
.cxx.o:
|
||||
echo Compiling $<...
|
||||
$(CXX) $(OPTIM) $(CXXFLAGS) -c $<
|
||||
.man.0 .man.1 .man.1m .man.3 .man.5 .man.8:
|
||||
echo Formatting $<...
|
||||
$(CXX) $(ARCHFLAGS) $(OPTIM) $(ALL_CXXFLAGS) -c $<
|
||||
|
||||
.man.1 .man.1m .man.5 .man.7 .man.8:
|
||||
echo Linking $<...
|
||||
$(RM) $@
|
||||
-$(NROFF) -man $< >$@
|
||||
.man.z:
|
||||
echo Formatting $<...
|
||||
$(RM) $@ $@.tmp $@.tmp.z
|
||||
-$(NROFF) -man $< >$@.tmp
|
||||
pack -f $@.tmp
|
||||
$(MV) $@.tmp.z $@
|
||||
$(LN) $< $@
|
||||
|
||||
.man.1.gz .man.1m.gz .man.5.gz .man.7.gz .man.8.gz .man.gz:
|
||||
echo -n Compressing $<...
|
||||
$(RM) $@
|
||||
gzip -v9 <$< >$@
|
||||
|
||||
|
||||
#
|
||||
|
||||
+200
-70
@@ -3,23 +3,14 @@
|
||||
#
|
||||
# Top-level Makefile for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
# Copyright 2007-2009 by Apple Inc.
|
||||
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
include Makedefs
|
||||
@@ -28,8 +19,11 @@ include Makedefs
|
||||
# Directories to make...
|
||||
#
|
||||
|
||||
DIRS = cups backend berkeley cgi-bin filter man pdftops \
|
||||
scheduler systemv
|
||||
DIRS = cups backend berkeley cgi-bin filter locale man monitor \
|
||||
notifier scheduler systemv test \
|
||||
$(PHPDIR) \
|
||||
conf data doc $(FONTS) ppd templates
|
||||
|
||||
|
||||
#
|
||||
# Make all targets...
|
||||
@@ -37,11 +31,16 @@ DIRS = cups backend berkeley cgi-bin filter man pdftops \
|
||||
|
||||
all:
|
||||
chmod +x cups-config
|
||||
echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
|
||||
echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
|
||||
echo Using LDFLAGS="$(LDFLAGS)"
|
||||
echo Using LIBS="$(LIBS)"
|
||||
for dir in $(DIRS); do\
|
||||
echo Making all in $$dir... ;\
|
||||
(cd $$dir ; $(MAKE) $(MFLAGS)) || exit 1;\
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Remove object and target files...
|
||||
#
|
||||
@@ -52,6 +51,28 @@ clean:
|
||||
(cd $$dir; $(MAKE) $(MFLAGS) clean) || exit 1;\
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Remove all non-distribution files...
|
||||
#
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makedefs config.h config.log config.status
|
||||
$(RM) cups-config
|
||||
$(RM) conf/cupsd.conf conf/mime.convs conf/pam.std conf/snmp.conf
|
||||
$(RM) doc/help/ref-cupsd-conf.html doc/help/standard.html doc/index.html
|
||||
$(RM) init/cups.sh init/cups-lpd init/org.cups.cups-lpd.plist
|
||||
$(RM) man/client.conf.man
|
||||
$(RM) man/cups-deviced.man man/cups-driverd.man
|
||||
$(RM) man/cups-lpd.man man/cupsaddsmb.man man/cupsd.man
|
||||
$(RM) man/cupsd.conf.man man/lpoptions.man
|
||||
$(RM) packaging/cups.list
|
||||
$(RM) templates/header.tmpl
|
||||
-$(RM) doc/*/index.html
|
||||
-$(RM) templates/*/header.tmpl
|
||||
-$(RM) -r autom4te*.cache
|
||||
|
||||
|
||||
#
|
||||
# Make dependencies
|
||||
#
|
||||
@@ -63,6 +84,25 @@ depend:
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Run the clang.llvm.org static code analysis tool on the C sources.
|
||||
#
|
||||
|
||||
.PHONY: clang
|
||||
clang:
|
||||
$(RM) -r clang
|
||||
scan-build -k -o `pwd`/clang $(MAKE) $(MFLAGS) \
|
||||
CC=ccc-analyzer CXX=ccc-analyzer clean all
|
||||
|
||||
|
||||
#
|
||||
# Generate a ctags file...
|
||||
#
|
||||
|
||||
ctags:
|
||||
ctags -R .
|
||||
|
||||
|
||||
#
|
||||
# Install object and target files...
|
||||
#
|
||||
@@ -72,98 +112,188 @@ install: installhdrs
|
||||
echo Installing in $$dir... ;\
|
||||
(cd $$dir; $(MAKE) $(MFLAGS) install) || exit 1;\
|
||||
done
|
||||
echo Installing in conf...
|
||||
(cd conf; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in data...
|
||||
(cd data; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in doc...
|
||||
(cd doc; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in fonts...
|
||||
(cd fonts; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in locale...
|
||||
(cd locale; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in ppd...
|
||||
(cd ppd; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing in templates...
|
||||
(cd templates; $(MAKE) $(MFLAGS) install)
|
||||
echo Installing cups-config script...
|
||||
$(INSTALL_DIR) $(BINDIR)
|
||||
$(INSTALL_DIR) -m 755 $(BINDIR)
|
||||
$(INSTALL_SCRIPT) cups-config $(BINDIR)/cups-config
|
||||
echo Installing startup script...
|
||||
if test "x$(INITDIR)" != "x"; then \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/init.d; \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc0.d; \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc2.d; \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc3.d; \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc5.d; \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
|
||||
if test "x$(INITDIR)" != x; then \
|
||||
echo Installing init scripts...; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/init.d; \
|
||||
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \
|
||||
for level in $(RCLEVELS); do \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc$${level}.d; \
|
||||
$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/S$(RCSTART)cups; \
|
||||
if test `uname` = HP-UX; then \
|
||||
level=`expr $$level - 1`; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc$${level}.d; \
|
||||
fi; \
|
||||
$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/K$(RCSTOP)cups; \
|
||||
done; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc0.d; \
|
||||
$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc0.d/K$(RCSTOP)cups; \
|
||||
fi
|
||||
if test "x$(INITDIR)" = "x" -a "x$(INITDDIR)" != "x"; then \
|
||||
if test "x$(INITDIR)" = x -a "x$(INITDDIR)" != x; then \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDDIR); \
|
||||
if test "$(INITDDIR)" = "/System/Library/StartupItems/PrintingServices"; then \
|
||||
$(INSTALL_SCRIPT) cups.osx $(BUILDROOT)$(INITDDIR)/PrintingServices; \
|
||||
$(INSTALL_DATA) cups.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
|
||||
echo Installing StartupItems files...; \
|
||||
$(INSTALL_SCRIPT) init/PrintingServices $(BUILDROOT)$(INITDDIR)/PrintingServices; \
|
||||
$(INSTALL_DATA) init/StartupParameters.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
|
||||
$(INSTALL_DATA) cups.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
|
||||
$(INSTALL_DATA) init/Localizable.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
|
||||
elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
|
||||
echo Installing LaunchDaemons configuration files...; \
|
||||
$(INSTALL_DATA) init/org.cups.cupsd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \
|
||||
$(INSTALL_DATA) init/org.cups.cups-lpd.plist $(BUILDROOT)/System/Library/LaunchDaemons; \
|
||||
case `uname -r` in \
|
||||
8.*) \
|
||||
$(INSTALL_DIR) $(BUILDROOT)/System/Library/StartupItems/PrintingServices; \
|
||||
$(INSTALL_SCRIPT) init/PrintingServices.launchd $(BUILDROOT)/System/Library/StartupItems/PrintingServices/PrintingServices; \
|
||||
$(INSTALL_DATA) init/StartupParameters.plist $(BUILDROOT)/System/Library/StartupItems/PrintingServices/StartupParameters.plist; \
|
||||
$(INSTALL_DIR) $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj; \
|
||||
$(INSTALL_DATA) init/Localizable.strings $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj/Localizable.strings; \
|
||||
;; \
|
||||
esac \
|
||||
else \
|
||||
$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
|
||||
echo Installing RC script...; \
|
||||
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
|
||||
fi \
|
||||
fi
|
||||
if test "x$(DBUSDIR)" != x; then \
|
||||
echo Installing cups.conf in $(DBUSDIR)...;\
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(DBUSDIR)/system.d; \
|
||||
$(INSTALL_DATA) packaging/cups-dbus.conf $(BUILDROOT)$(DBUSDIR)/system.d/cups.conf; \
|
||||
fi
|
||||
if test "x$(XINETD)" != x; then \
|
||||
echo Installing xinetd configuration file for cups-lpd...; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(XINETD); \
|
||||
$(INSTALL_DATA) init/cups-lpd $(BUILDROOT)$(XINETD)/cups-lpd; \
|
||||
fi
|
||||
if test "x$(MENUDIR)" != x; then \
|
||||
echo Installing desktop menu...; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(MENUDIR); \
|
||||
$(INSTALL_DATA) desktop/cups.desktop $(BUILDROOT)$(MENUDIR); \
|
||||
fi
|
||||
if test "x$(ICONDIR)" != x; then \
|
||||
echo Installing desktop icons...; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/16x16/apps; \
|
||||
$(INSTALL_DATA) desktop/cups-16.png $(BUILDROOT)$(ICONDIR)/hicolor/16x16/apps/cups.png; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/32x32/apps; \
|
||||
$(INSTALL_DATA) desktop/cups-32.png $(BUILDROOT)$(ICONDIR)/hicolor/32x32/apps/cups.png; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/64x64/apps; \
|
||||
$(INSTALL_DATA) desktop/cups-64.png $(BUILDROOT)$(ICONDIR)/hicolor/64x64/apps/cups.png; \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/128x128/apps; \
|
||||
$(INSTALL_DATA) desktop/cups-128.png $(BUILDROOT)$(ICONDIR)/hicolor/128x128/apps/cups.png; \
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Install source and header files...
|
||||
#
|
||||
|
||||
installsrc:
|
||||
gnutar --dereference --exclude=CVS -cf - . | gnutar -C $(SRCROOT) -xf -
|
||||
gnutar --dereference --exclude=.svn -cf - . | gnutar -C $(SRCROOT) -xf -
|
||||
|
||||
installhdrs:
|
||||
(cd cups ; $(MAKE) $(MFLAGS) installhdrs) || exit 1;\
|
||||
(cd filter ; $(MAKE) $(MFLAGS) installhdrs) || exit 1;
|
||||
|
||||
|
||||
#
|
||||
# Uninstall object and target files...
|
||||
#
|
||||
|
||||
uninstall:
|
||||
for dir in $(DIRS); do\
|
||||
echo Uninstalling in $$dir... ;\
|
||||
(cd $$dir; $(MAKE) $(MFLAGS) uninstall) || exit 1;\
|
||||
done
|
||||
echo Uninstalling cups-config script...
|
||||
$(RM) $(BINDIR)/cups-config
|
||||
-$(RMDIR) $(BINDIR)
|
||||
echo Uninstalling startup script...
|
||||
if test "x$(INITDIR)" != x; then \
|
||||
$(RM) $(BUILDROOT)$(INITDIR)/init.d/cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDIR)/init.d; \
|
||||
$(RM) $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDIR)/rc0.d; \
|
||||
$(RM) $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDIR)/rc2.d; \
|
||||
$(RM) $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDIR)/rc3.d; \
|
||||
$(RM) $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDIR)/rc5.d; \
|
||||
fi
|
||||
if test "x$(INITDIR)" = x -a "x$(INITDDIR)" != x; then \
|
||||
if test "$(INITDDIR)" = "/System/Library/StartupItems/PrintingServices"; then \
|
||||
$(RM) $(BUILDROOT)$(INITDDIR)/PrintingServices; \
|
||||
$(RM) $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
|
||||
$(RM) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
|
||||
elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
|
||||
$(RM) $(BUILDROOT)$(INITDDIR)/org.cups.cupsd.plist; \
|
||||
$(RM) $(BUILDROOT)$(INITDDIR)/org.cups.cups-lpd.plist; \
|
||||
$(RMDIR) $(BUILDROOT)/System/Library/StartupItems/PrintingServices; \
|
||||
else \
|
||||
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
|
||||
fi \
|
||||
$(RMDIR) $(BUILDROOT)$(INITDDIR); \
|
||||
fi
|
||||
if test "x$(DBUSDIR)" != x; then \
|
||||
echo Uninstalling cups.conf in $(DBUSDIR)...;\
|
||||
$(RM) $(BUILDROOT)$(DBUSDIR)/cups.conf; \
|
||||
$(RMDIR) $(BUILDROOT)$(DBUSDIR); \
|
||||
fi
|
||||
$(RM) $(BUILDROOT)/etc/xinetd.d/cups-lpd
|
||||
$(RM) $(BUILDROOT)/usr/share/applications/cups.desktop
|
||||
$(RM) $(BUILDROOT)/usr/share/icons/hicolor/16x16/apps/cups.png
|
||||
$(RM) $(BUILDROOT)/usr/share/icons/hicolor/32x32/apps/cups.png
|
||||
$(RM) $(BUILDROOT)/usr/share/icons/hicolor/64x64/apps/cups.png
|
||||
$(RM) $(BUILDROOT)/usr/share/icons/hicolor/128x128/apps/cups.png
|
||||
|
||||
|
||||
#
|
||||
# Run the test suite...
|
||||
#
|
||||
|
||||
check test: all
|
||||
test: all
|
||||
echo Running CUPS test suite...
|
||||
cd test; ./run-stp-tests.sh
|
||||
|
||||
|
||||
check: all
|
||||
echo Running CUPS test suite with defaults...
|
||||
cd test; ./run-stp-tests.sh 1 0 n
|
||||
|
||||
|
||||
#
|
||||
# Make software distributions using EPM (http://www.easysw.com/epm)...
|
||||
# Make software distributions using EPM (http://www.easysw.com/epm/)...
|
||||
#
|
||||
|
||||
EPMFLAGS = -v
|
||||
EPMFLAGS = -v --output-dir dist $(EPMARCH)
|
||||
|
||||
aix:
|
||||
epm $(EPMFLAGS) -f aix cups
|
||||
|
||||
bsd:
|
||||
epm $(EPMFLAGS) -f bsd cups
|
||||
aix bsd deb depot inst pkg setld slackware swinstall tardist:
|
||||
epm $(EPMFLAGS) -f $@ cups packaging/cups.list
|
||||
|
||||
epm:
|
||||
epm $(EPMFLAGS) cups
|
||||
epm $(EPMFLAGS) -s packaging/installer.gif cups packaging/cups.list
|
||||
|
||||
osx:
|
||||
epm $(EPMFLAGS) -f osx -s packaging/installer.tif cups packaging/cups.list
|
||||
|
||||
rpm:
|
||||
epm $(EPMFLAGS) -f rpm cups
|
||||
epm $(EPMFLAGS) -f rpm -s packaging/installer.gif cups packaging/cups.list
|
||||
|
||||
deb:
|
||||
epm $(EPMFLAGS) -f deb cups
|
||||
.PHONEY: dist
|
||||
dist: all
|
||||
$(RM) -r dist
|
||||
$(MAKE) $(MFLAGS) epm
|
||||
case `uname` in \
|
||||
*BSD*) $(MAKE) $(MFLAGS) bsd;; \
|
||||
Darwin*) $(MAKE) $(MFLAGS) osx;; \
|
||||
IRIX*) $(MAKE) $(MFLAGS) tardist;; \
|
||||
Linux*) test ! -x /usr/bin/rpm || $(MAKE) $(MFLAGS) rpm;; \
|
||||
SunOS*) $(MAKE) $(MFLAGS) pkg;; \
|
||||
esac
|
||||
|
||||
depot:
|
||||
epm $(EPMFLAGS) -f depot cups
|
||||
|
||||
pkg:
|
||||
epm $(EPMFLAGS) -f pkg cups
|
||||
|
||||
tardist:
|
||||
epm $(EPMFLAGS) -f tardist cups
|
||||
|
||||
#
|
||||
# End of "$Id$".
|
||||
|
||||
+110
-220
@@ -1,283 +1,173 @@
|
||||
README - CUPS v1.1.20 - 11/24/2003
|
||||
README - CUPS v1.3.11 - 2009-06-26
|
||||
----------------------------------
|
||||
|
||||
Looking for compile instructions? Read the file "INSTALL.txt"
|
||||
instead...
|
||||
|
||||
**** IF YOU HAVE A NON-POSTSCRIPT PRINTER, YOU WILL ALSO ****
|
||||
**** NEED TO INSTALL ESP GHOSTSCRIPT OR A PATCHED VERSION ****
|
||||
**** OF THE STANDARD GHOSTSCRIPT RELEASES. ****
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
CUPS provides a portable printing layer for UNIX(r)-based
|
||||
operating systems. It has been developed by Easy Software
|
||||
Products to promote a standard printing solution for all UNIX
|
||||
vendors and users. CUPS provides the System V and Berkeley
|
||||
command-line interfaces.
|
||||
CUPS provides a portable printing layer for UNIX(r)-based
|
||||
operating systems. It was developed by Easy Software Products
|
||||
and is now owned and maintained by Apple Inc. to promote a
|
||||
standard printing solution for all UNIX vendors and users. CUPS
|
||||
provides the System V and Berkeley command-line interfaces.
|
||||
|
||||
CUPS uses the Internet Printing Protocol ("IPP") as the basis
|
||||
for managing print jobs and queues. The Line Printer Daemon
|
||||
("LPD") Server Message Block ("SMB"), and AppSocket (a.k.a.
|
||||
JetDirect) protocols are also supported with reduced
|
||||
functionality. CUPS adds network printer browsing and
|
||||
PostScript Printer Description ("PPD") based printing options to
|
||||
support real-world printing under UNIX.
|
||||
CUPS uses the Internet Printing Protocol ("IPP") as the basis
|
||||
for managing print jobs and queues. The Line Printer Daemon
|
||||
("LPD") Server Message Block ("SMB"), and AppSocket (a.k.a.
|
||||
JetDirect) protocols are also supported with reduced
|
||||
functionality. CUPS adds network printer browsing and
|
||||
PostScript Printer Description ("PPD") based printing options
|
||||
to support real-world printing under UNIX.
|
||||
|
||||
CUPS includes an image file RIP that supports printing of image
|
||||
files to non-PostScript printers. A customized version of GNU
|
||||
Ghostscript 7.05 for CUPS called ESP Ghostscript is available
|
||||
separately to support printing of PostScript files within the
|
||||
CUPS driver framework. Sample drivers for Dymo, EPSON, HP, and
|
||||
OKIDATA printers are included that use these filters.
|
||||
CUPS includes an image file RIP that supports printing of
|
||||
image files to non-PostScript printers. GPL Ghostscript now
|
||||
includes the "cups" driver to support printing of PostScript
|
||||
files within the CUPS driver framework. Sample drivers for
|
||||
Dymo, EPSON, HP, OKIDATA, and Zebra printers are included that
|
||||
use these filters.
|
||||
|
||||
Drivers for thousands of printers are provided with our ESP
|
||||
Print Pro software, available at:
|
||||
|
||||
http://www.easysw.com/printpro
|
||||
|
||||
CUPS is licensed under the GNU General Public License and GNU
|
||||
Library General Public License. Please contact Easy Software
|
||||
Products for commercial support and "binary distribution"
|
||||
rights.
|
||||
|
||||
|
||||
SYSTEM REQUIREMENTS
|
||||
|
||||
Binary distributions require a minimum of 10MB of free disk
|
||||
space. We do not recommend using CUPS on a workstation with less
|
||||
than 32MB of RAM or a PC with less than 16MB of RAM.
|
||||
|
||||
If you are installing from source you'll need ANSI-compliant C
|
||||
and C++ compilers and optionally one or more image file support
|
||||
libraries. Complete source installation instructions can be
|
||||
found in the file "INSTALL.txt".
|
||||
|
||||
|
||||
SOFTWARE REQUIREMENTS
|
||||
|
||||
The following operating system software is required to install
|
||||
one of the binary distributions from Easy Software Products:
|
||||
|
||||
- AIX 4.3 or higher
|
||||
- Compaq Tru64 UNIX (aka OSF1 aka Digital UNIX) 4.0 or higher
|
||||
- HP-UX 10.20 or higher
|
||||
- IRIX 5.3 or higher
|
||||
- Linux 2.0 with glibc2 or higher
|
||||
- Solaris 2.5 or higher (SPARC or Intel)
|
||||
|
||||
|
||||
INSTALLING "PORTABLE" CUPS DISTRIBUTIONS
|
||||
|
||||
We are currently distributing "portable" CUPS binary
|
||||
distributions in TAR format with installation and removal
|
||||
scripts generated by our ESP Package Manager (EPM) software,
|
||||
which is available from:
|
||||
|
||||
http://www.easysw.com/epm
|
||||
|
||||
WARNING: Installing CUPS will overwrite your existing printing
|
||||
system. Backup files are made by the installation script and
|
||||
restored by the removal script, so if you experience problems
|
||||
you should be able to remove the CUPS software to restore your
|
||||
previous configuration. However, Easy Software Products makes
|
||||
no warranty for this and will not be liable for any lost
|
||||
revenues, etc.
|
||||
|
||||
To install the CUPS software you will need to be logged in as
|
||||
root (doing an "su" is good enough). Once you are the root
|
||||
user, run the installation script with:
|
||||
|
||||
./cups.install ENTER
|
||||
|
||||
After asking you a few yes/no questions the CUPS software will
|
||||
be installed and the scheduler will be started automatically.
|
||||
|
||||
|
||||
INSTALLING HOST-SPECIFIC (RPM, DEBIAN, ETC.) DISTRIBUTIONS
|
||||
|
||||
The host-specific distributions use the operating system
|
||||
software installation tools. To install a host-specific
|
||||
distribution please consult the CUPS Software Administrators
|
||||
Manual or your operating system documentation.
|
||||
CUPS is licensed under the GNU General Public License and GNU
|
||||
Library General Public License versions 2.
|
||||
|
||||
|
||||
READING THE DOCUMENTATION
|
||||
|
||||
Once you have installed the software you can access the
|
||||
documentation (and a bunch of other stuff) on-line at:
|
||||
Once you have installed the software you can access the
|
||||
documentation (and a bunch of other stuff) on-line at:
|
||||
|
||||
http://localhost:631
|
||||
http://localhost:631/
|
||||
|
||||
If you're having trouble getting that far, the documentation is
|
||||
located in the "/usr/share/doc/cups" directory in the binary
|
||||
distributions, and under the "doc" directory in the source
|
||||
archives.
|
||||
If you're having trouble getting that far, the documentation
|
||||
is located under the "doc/help" directory.
|
||||
|
||||
Please read the documentation before asking questions.
|
||||
Please read the documentation before asking questions.
|
||||
|
||||
|
||||
GETTING SUPPORT AND OTHER RESOURCES
|
||||
|
||||
If you have problems, READ THE DOCUMENTATION FIRST!
|
||||
If you have problems, READ THE DOCUMENTATION FIRST! We also
|
||||
provide many discussion forums which are available at:
|
||||
|
||||
You can subscribe to the CUPS mailing list by sending a message
|
||||
containing "subscribe cups" to majordomo@cups.org. This list is
|
||||
provided to discuss problems, questions, and improvements to the
|
||||
CUPS software. New releases of CUPS are announced to this list
|
||||
as well.
|
||||
http://www.cups.org/newsgroups.php
|
||||
|
||||
Commercial support (with a guaranteed response time) is
|
||||
available from Easy Software Products. For more information
|
||||
see:
|
||||
|
||||
http://www.easysw.com/cups
|
||||
|
||||
See the CUPS web site at "http://www.cups.org" for other site
|
||||
links.
|
||||
See the CUPS web site at "http://www.cups.org/" for other
|
||||
site links.
|
||||
|
||||
|
||||
SETTING UP PRINTER QUEUES USING YOUR WEB BROWSER
|
||||
|
||||
CUPS 1.1 includes a new web-based administration tool that
|
||||
allows you to manage printers, classes, and jobs on your
|
||||
server. To access the printer administration tools open the
|
||||
following URL in your browser:
|
||||
CUPS 1.3 includes a web-based administration tool that allows
|
||||
you to manage printers, classes, and jobs on your server.
|
||||
Open the following URL in your browser to access the printer
|
||||
administration tools:
|
||||
|
||||
http://localhost:631/admin
|
||||
http://localhost:631/admin/
|
||||
|
||||
You will be asked for the administration password (root or any
|
||||
other user in the sys/system/root group on your system) and then
|
||||
shown a menu of available functions.
|
||||
DO NOT use the hostname for your machine - it will not work
|
||||
with the default CUPS configuration. To enable
|
||||
administration access on other addresses, check the "Allow
|
||||
Remote Administration" box and click on the "Change Settings"
|
||||
button.
|
||||
|
||||
DO NOT use the hostname for your machine - it will not work with
|
||||
the default CUPS configuration. To enable administration access
|
||||
on other addresses, consult the CUPS Software Administrators
|
||||
Manual.
|
||||
You will be asked for the administration password (root or
|
||||
any other user in the sys/system/root group on your system)
|
||||
when performing any administrative function.
|
||||
|
||||
|
||||
SETTING UP PRINTER QUEUES FROM THE COMMAND-LINE
|
||||
|
||||
CUPS works best with PPD (PostScript Printer Description)
|
||||
files. In a pinch you can also use System V style printer
|
||||
interface scripts.
|
||||
CUPS works best with PPD (PostScript Printer Description)
|
||||
files. In a pinch you can also use System V style printer
|
||||
interface scripts.
|
||||
|
||||
Six sample PPD files are provided with this distribution that
|
||||
utilize the PostScript and image file RIPs and the sample EPSON
|
||||
and HP printer drivers. To add the sample DeskJet driver to the
|
||||
system for a printer connected to the parallel port, use one of
|
||||
the following commands:
|
||||
CUPS includes several sample PPD files you can use:
|
||||
|
||||
Digital UNIX:
|
||||
Driver PPD File
|
||||
----------------------------- ------------
|
||||
Dymo Label Printers dymo.ppd
|
||||
Intellitech Intellibar intelbar.ppd
|
||||
EPSON Stylus Color Series stcolor.ppd
|
||||
EPSON Stylus Photo Series stphoto.ppd
|
||||
EPSON Stylus New Color Series stcolor2.ppd
|
||||
EPSON Stylus New Photo Series stphoto2.ppd
|
||||
EPSON 9-pin Series epson9.ppd
|
||||
EPSON 24-pin Series epson24.ppd
|
||||
HP DeskJet Series deskjet.ppd
|
||||
HP LaserJet Series laserjet.ppd
|
||||
OKIDATA 9-Pin Series okidata9.ppd
|
||||
OKIDATA 24-Pin Series okidat24.ppd
|
||||
Zebra CPCL Label Printer zebracpl.ppd
|
||||
Zebra EPL1 Label Printer zebraep1.ppd
|
||||
Zebra EPL2 Label Printer zebraep2.ppd
|
||||
Zebra ZPL Label Printer zebra.ppd
|
||||
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp0 -E
|
||||
Run the "lpinfo" command to list the available printers:
|
||||
|
||||
HP-UX:
|
||||
lpinfo -v
|
||||
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/c2t0d0_lp -E
|
||||
Then use the correct URI to add the printer using the
|
||||
"lpadmin" command:
|
||||
|
||||
IRIX:
|
||||
lpadmin -p printername -E -v URI -m filename.ppd
|
||||
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/plp -E
|
||||
Network printers typically use "socket" or "lpd" URIs:
|
||||
|
||||
Linux:
|
||||
lpadmin -p printername -E -v socket://11.22.33.44 -m filename.ppd
|
||||
lpadmin -p printername -E -v lpd://11.22.33.44/ -m filename.ppd
|
||||
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp0 -E
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp1 -E
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp2 -E
|
||||
|
||||
Solaris:
|
||||
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/bpp0 -E
|
||||
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/ecpp0 -E
|
||||
|
||||
Similarly, for the other sample drivers you can use:
|
||||
|
||||
Driver PPD File
|
||||
----------------------------- ------------
|
||||
Dymo Label Printers dymo.ppd
|
||||
EPSON Stylus Color Series stcolor.ppd
|
||||
EPSON Stylus Photo Series stphoto.ppd
|
||||
EPSON Stylus New Color Series stcolor2.ppd
|
||||
EPSON Stylus New Photo Series stphoto2.ppd
|
||||
EPSON 9-pin Series epson9.ppd
|
||||
EPSON 24-pin Series epson24.ppd
|
||||
HP DeskJet Series deskjet.ppd
|
||||
HP New DeskJet Series deskjet2.ppd
|
||||
HP LaserJet Series laserjet.ppd
|
||||
OKIDATA 9-Pin Series okidata9.ppd
|
||||
OKIDATA 24-Pin Series okidat24.ppd
|
||||
|
||||
These sample drivers provide basic printing capabilities, but
|
||||
generally do not exercise the full potential of the printers or
|
||||
CUPS. For commercial printer drivers check out our ESP Print
|
||||
Pro software at:
|
||||
|
||||
http://www.easysw.com/printpro
|
||||
The sample drivers provide basic printing capabilities, but
|
||||
generally do not exercise the full potential of the printers
|
||||
or CUPS.
|
||||
|
||||
|
||||
PRINTING FILES
|
||||
|
||||
CUPS provides both the System V "lp" and Berkeley "lpr" commands
|
||||
for printing:
|
||||
CUPS provides both the System V "lp" and Berkeley "lpr"
|
||||
commands for printing:
|
||||
|
||||
lp filename
|
||||
lpr filename
|
||||
lp filename
|
||||
lpr filename
|
||||
|
||||
Both the "lp" and "lpr" commands support printing options for
|
||||
the driver:
|
||||
Both the "lp" and "lpr" commands support printing options for
|
||||
the driver:
|
||||
|
||||
lp -omedia=A4 -oresolution=600dpi filename
|
||||
lpr -omedia=A4 -oresolution=600dpi filename
|
||||
lp -omedia=A4 -oresolution=600dpi filename
|
||||
lpr -omedia=A4 -oresolution=600dpi filename
|
||||
|
||||
CUPS recognizes many types of images files as well as PDF,
|
||||
PostScript, HP-GL/2, and text files, so you can print those
|
||||
files directly rather than through an application.
|
||||
CUPS recognizes many types of images files as well as PDF,
|
||||
PostScript, HP-GL/2, and text files, so you can print those
|
||||
files directly rather than through an application.
|
||||
|
||||
If you have an application that generates output specifically
|
||||
for your printer then you need to use the "-oraw" or "-l"
|
||||
options:
|
||||
If you have an application that generates output specifically
|
||||
for your printer then you need to use the "-oraw" or "-l"
|
||||
options:
|
||||
|
||||
lp -oraw filename
|
||||
lpr -l filename
|
||||
lp -oraw filename
|
||||
lpr -l filename
|
||||
|
||||
This will prevent the filters from misinterpreting your print
|
||||
file.
|
||||
This will prevent the filters from misinterpreting your print
|
||||
file.
|
||||
|
||||
|
||||
LEGAL STUFF
|
||||
|
||||
CUPS is Copyright 1993-2004 by Easy Software Products. CUPS,
|
||||
the CUPS logo, and the Common UNIX Printing System are the
|
||||
trademark property of Easy Software Products.
|
||||
CUPS is Copyright 2007-2009 by Apple Inc. CUPS and the CUPS
|
||||
logo are trademarks of Apple Inc.
|
||||
|
||||
The MD5 Digest code is Copyright 1999 Aladdin Enterprises.
|
||||
The MD5 Digest code is Copyright 1999 Aladdin Enterprises.
|
||||
|
||||
The PDF filter (pdftops) is based on the Xpdf software,
|
||||
Copyright 1996-2002 by Derek B. Noonburg.
|
||||
The PDF filter (pdftops) is based on the Xpdf software,
|
||||
Copyright 1996-2005 by Derek B. Noonburg.
|
||||
|
||||
This software is based in part on the work of the Independent
|
||||
JPEG Group.
|
||||
This software is based in part on the work of the Independent
|
||||
JPEG Group.
|
||||
|
||||
CUPS is provided under the terms of the GNU General Public
|
||||
License and GNU Library General Public License. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the "LICENSE.html",
|
||||
"LICENSE.txt", or "cups.license" files for more information.
|
||||
|
||||
For commercial licensing information, please contact:
|
||||
|
||||
Attn: CUPS Licensing Information
|
||||
Easy Software Products
|
||||
44141 Airport View Drive, Suite 204
|
||||
Hollywood, Maryland 20636-3111 USA
|
||||
|
||||
Voice: +1.301.373.9600
|
||||
Email: cups-info@cups.org
|
||||
WWW: http://www.cups.org
|
||||
|
||||
Note that commercial licensors may also require a license from
|
||||
Derek B. Noonburg who developed the Xpdf software used to print
|
||||
PDF files.
|
||||
CUPS is provided under the terms of the GNU General Public
|
||||
License and GNU Library General Public License. This program
|
||||
is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
"doc/help/license.html" or "LICENSE.txt" files for more
|
||||
information.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
README_fr - CUPS v1.1.19 - 04/08/2003
|
||||
-------------------------------------
|
||||
|
||||
Vous cherchez des instructions d'installation ? Lisez le fichier
|
||||
INSTALL.txt (anglais) et/ou reportez vous au "Manuel de
|
||||
l'administrateur" (en français) situé dans le sous-répertoire
|
||||
"doc/fr"
|
||||
|
||||
Vous trouverez deux autres manuels en français dans ce
|
||||
sous-répertoire :
|
||||
|
||||
- Aperçu de CUPS
|
||||
- Manuel de l'utilisateur
|
||||
|
||||
Une fois CUPS installé, si vous configurez votre navigateur
|
||||
"web" pour que la langue de base soit le français, vous
|
||||
disposerez également d'une interface "web" en français pour
|
||||
l'administration et d'utilistation de CUPS.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
betest
|
||||
ipp
|
||||
lpd
|
||||
parallel
|
||||
scsi
|
||||
serial
|
||||
socket
|
||||
usb
|
||||
+42
-15
@@ -1,17 +1,44 @@
|
||||
# DO NOT DELETE
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
betest.o: ../cups/string.h ../config.h
|
||||
ipp.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
ipp.o: ../cups/ppd.h ../cups/language.h ../cups/string.h ../config.h
|
||||
lpd.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
lpd.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
parallel.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
parallel.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
scsi.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
scsi.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
serial.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
serial.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
socket.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
socket.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
usb.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
usb.o: ../cups/ppd.h ../cups/string.h ../config.h
|
||||
ipp.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
|
||||
ipp.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/backend.h ../cups/cups.h
|
||||
ipp.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
ipp.o: ../cups/language.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h
|
||||
lpd.o: ../cups/backend.h ../cups/http-private.h ../config.h ../cups/http.h
|
||||
lpd.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h
|
||||
lpd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
lpd.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h
|
||||
pap.o: ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
pap.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/backend.h
|
||||
pap.o: ../cups/sidechannel.h ../cups/i18n.h ../cups/transcode.h
|
||||
parallel.o: backend-private.h ../cups/backend.h ../cups/sidechannel.h
|
||||
parallel.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
parallel.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
|
||||
parallel.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h
|
||||
scsi.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
scsi.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
scsi.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h
|
||||
serial.o: backend-private.h ../cups/backend.h ../cups/sidechannel.h
|
||||
serial.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
serial.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
|
||||
serial.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h
|
||||
snmp.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
|
||||
snmp.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h
|
||||
snmp.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h ../cups/ppd.h
|
||||
snmp.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
|
||||
snmp.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../cups/array.h
|
||||
snmp.o: ../cups/file.h
|
||||
socket.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
|
||||
socket.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h
|
||||
socket.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h
|
||||
socket.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
socket.o: ../cups/debug.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h
|
||||
test1284.o: ../cups/string.h ../config.h ieee1284.c backend-private.h
|
||||
test1284.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h
|
||||
test1284.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h
|
||||
test1284.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/i18n.h
|
||||
test1284.o: ../cups/transcode.h
|
||||
usb.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
usb.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
usb.o: ../cups/string.h ../config.h ../cups/i18n.h ../cups/transcode.h
|
||||
|
||||
+96
-29
@@ -3,32 +3,26 @@
|
||||
#
|
||||
# Backend makefile for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
# Copyright 2007 by Apple Inc.
|
||||
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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-3142 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
# This file is subject to the Apple OS-Developed Software exception.
|
||||
#
|
||||
|
||||
include ../Makedefs
|
||||
|
||||
BACKENDS = ipp lpd parallel scsi serial socket usb
|
||||
TARGETS = betest $(BACKENDS)
|
||||
OBJS = betest.o ipp.o lpd.o parallel.o scsi.o serial.o socket.o usb.o
|
||||
RBACKENDS = ipp lpd
|
||||
UBACKENDS = $(PAP) $(LEGACY_BACKENDS) serial snmp socket usb
|
||||
TARGETS = betest test1284 libbackend.a $(RBACKENDS) $(UBACKENDS)
|
||||
LIBOBJS = ieee1284.o runloop.o
|
||||
OBJS = betest.o ipp.o lpd.o pap.o parallel.o scsi.o \
|
||||
serial.o snmp.o socket.o test1284.o usb.o
|
||||
|
||||
|
||||
#
|
||||
@@ -43,7 +37,7 @@ all: $(TARGETS)
|
||||
#
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(TARGETS) http
|
||||
$(RM) $(OBJS) $(TARGETS) $(LIBOBJS) http
|
||||
|
||||
|
||||
#
|
||||
@@ -59,12 +53,34 @@ depend:
|
||||
#
|
||||
|
||||
install: all
|
||||
$(INSTALL_DIR) $(SERVERBIN)/backend
|
||||
for file in $(BACKENDS); do \
|
||||
$(INSTALL_DIR) -m 755 $(SERVERBIN)/backend
|
||||
for file in $(RBACKENDS); do \
|
||||
$(LIBTOOL) $(INSTALL) -m 700 $$file $(SERVERBIN)/backend; \
|
||||
done
|
||||
for file in $(UBACKENDS); do \
|
||||
$(INSTALL_BIN) $$file $(SERVERBIN)/backend; \
|
||||
done
|
||||
$(RM) $(SERVERBIN)/backend/http
|
||||
$(LN) ipp $(SERVERBIN)/backend/http
|
||||
if test "x$(SYMROOT)" != "x"; then \
|
||||
$(INSTALL_DIR) $(SYMROOT); \
|
||||
for file in $(TARGETS); do \
|
||||
cp $$file $(SYMROOT); \
|
||||
done \
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Uninstall all targets...
|
||||
#
|
||||
|
||||
uninstall:
|
||||
for file in $(RBACKENDS) $(UBACKENDS); do \
|
||||
$(RM) $(SERVERBIN)/backend/$$file; \
|
||||
done
|
||||
$(RM) $(SERVERBIN)/backend/http
|
||||
-$(RMDIR) $(SERVERBIN)/backend
|
||||
-$(RMDIR) $(SERVERBIN)
|
||||
|
||||
|
||||
#
|
||||
@@ -76,6 +92,39 @@ betest: betest.o ../cups/$(LIBCUPS)
|
||||
$(CC) $(LDFLAGS) -o betest betest.o $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# test1284
|
||||
#
|
||||
|
||||
test1284: test1284.o ../cups/libcups.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o test1284 test1284.o ../cups/libcups.a \
|
||||
$(SSLLIBS) $(COMMONLIBS) $(LIBZ)
|
||||
|
||||
|
||||
#
|
||||
# libbackend.a
|
||||
#
|
||||
|
||||
libbackend.a: $(LIBOBJS)
|
||||
echo Archiving $@...
|
||||
$(RM) $@
|
||||
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
#
|
||||
# ieee1394
|
||||
#
|
||||
|
||||
ieee1394: ieee1394.o ieee1394-linux.o
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o ieee1394 ieee1394.o ieee1394-linux.o -lraw1394 $(LIBS)
|
||||
|
||||
ieee1394.o: ieee1394.h
|
||||
ieee1394-linux.o: ieee1394.h
|
||||
|
||||
|
||||
#
|
||||
# ipp
|
||||
#
|
||||
@@ -96,13 +145,22 @@ lpd: lpd.o ../cups/$(LIBCUPS)
|
||||
$(CC) $(LDFLAGS) -o lpd lpd.o $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# pap
|
||||
#
|
||||
|
||||
pap: pap.o ../cups/$(LIBCUPS)
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o pap pap.o $(BACKLIBS) $(LIBS) -framework AppleTalk
|
||||
|
||||
|
||||
#
|
||||
# parallel
|
||||
#
|
||||
|
||||
parallel: parallel.o ../cups/$(LIBCUPS)
|
||||
parallel: parallel.o ../cups/$(LIBCUPS) libbackend.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o parallel parallel.o $(LIBS)
|
||||
$(CC) $(LDFLAGS) -o parallel parallel.o libbackend.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
@@ -120,27 +178,36 @@ scsi.o: scsi.c scsi-irix.c scsi-linux.c
|
||||
# serial
|
||||
#
|
||||
|
||||
serial: serial.o ../cups/$(LIBCUPS)
|
||||
serial: serial.o ../cups/$(LIBCUPS) libbackend.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o serial serial.o $(BACKLIBS) $(LIBS)
|
||||
$(CC) $(LDFLAGS) -o serial serial.o libbackend.a $(BACKLIBS) $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# snmp
|
||||
#
|
||||
|
||||
snmp: snmp.o ../cups/$(LIBCUPS) libbackend.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o snmp snmp.o libbackend.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# socket
|
||||
#
|
||||
|
||||
socket: socket.o ../cups/$(LIBCUPS)
|
||||
socket: socket.o ../cups/$(LIBCUPS) libbackend.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o socket socket.o $(LIBS)
|
||||
$(CC) $(LDFLAGS) -o socket socket.o libbackend.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# usb
|
||||
#
|
||||
|
||||
usb: usb.o ../cups/$(LIBCUPS)
|
||||
usb: usb.o ../cups/$(LIBCUPS) libbackend.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o usb usb.o $(BACKLIBS) $(LIBS)
|
||||
$(CC) $(LDFLAGS) -o usb usb.o libbackend.a $(BACKLIBS) $(LIBS)
|
||||
usb.o: usb.c usb-darwin.c usb-unix.c
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Backend support definitions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" which should have been included with this file. If this
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*/
|
||||
|
||||
#ifndef _CUPS_BACKEND_PRIVATE_H_
|
||||
# define _CUPS_BACKEND_PRIVATE_H_
|
||||
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
# include <cups/backend.h>
|
||||
# include <cups/sidechannel.h>
|
||||
# include <cups/cups.h>
|
||||
# include <cups/debug.h>
|
||||
# include <cups/i18n.h>
|
||||
# include <stdlib.h>
|
||||
# include <errno.h>
|
||||
# include <cups/string.h>
|
||||
# include <signal.h>
|
||||
|
||||
|
||||
/*
|
||||
* C++ magic...
|
||||
*/
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif /* __cplusplus */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes...
|
||||
*/
|
||||
|
||||
extern int backendDrainOutput(int print_fd, int device_fd);
|
||||
extern int backendGetDeviceID(int fd, char *device_id, int device_id_size,
|
||||
char *make_model, int make_model_size,
|
||||
const char *scheme, char *uri, int uri_size);
|
||||
extern int backendGetMakeModel(const char *device_id, char *make_model,
|
||||
int make_model_size);
|
||||
extern ssize_t backendRunLoop(int print_fd, int device_fd, int use_bc,
|
||||
void (*side_cb)(int print_fd, int device_fd,
|
||||
int use_bc));
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif /* __cplusplus */
|
||||
#endif /* !_CUPS_BACKEND_PRIVATE_H_ */
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+5
-14
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* Backend test program for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* 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
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" 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-3142 USA
|
||||
*
|
||||
* Voice: (301) 373-9600
|
||||
* EMail: cups-info@cups.org
|
||||
* WWW: http://www.cups.org
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
Preliminary Design for CUPS Firewire Printer Backend - 03/19/2002
|
||||
-----------------------------------------------------------------
|
||||
|
||||
OVERVIEW
|
||||
|
||||
Easy Software Products will develop an IEEE-1394, a.k.a.
|
||||
Firewire, printing interface for its Common UNIX Printing
|
||||
System ("CUPS") for initial use under the Linux operating
|
||||
system. A follow-on implementation for MacOS X is
|
||||
anticipated as well.
|
||||
|
||||
The operating system interfaces for IEEE-1394 ports vary
|
||||
widely; the CUPS printing interface will abstract the OS
|
||||
layer to a simpler interface geared towards discovering,
|
||||
opening, reading from, writing to, and closing IEEE-1394
|
||||
printers.
|
||||
|
||||
The initial development of the CUPS backend will be targeted
|
||||
at the EPSON Stylus Pro 10000 large format printer, which
|
||||
requires the bandwidth provided by Firewire in order to
|
||||
print at full speed. This printer supports printing via
|
||||
Serial Bus Protocol 2 (SBP-2) using the SCSI and PWG command
|
||||
sets. The CUPS backend will implement the PWG command set on
|
||||
LUN 0 only.
|
||||
|
||||
|
||||
OS ABSTRACTION LAYER
|
||||
|
||||
The OS abstraction layer will be a thin client library that
|
||||
implements the following functions:
|
||||
|
||||
ieee1394_list
|
||||
ieee1394_open
|
||||
ieee1394_close
|
||||
ieee1394_read
|
||||
ieee1394_write
|
||||
ieee1394_error
|
||||
|
||||
The "ieee1394_list" function will list all of the available
|
||||
printer devices on the bus. The device information will
|
||||
consist of the device URI (ieee1394:/something) used to
|
||||
access the device and the make and model information, if
|
||||
available, for the device ("EPSON Stylus Printer").
|
||||
|
||||
The "ieee1394_open" and "ieee1394_close" functions will open
|
||||
and close a connection to the printer, respectively.
|
||||
|
||||
The "ieee1394_read" and "ieee1394_write" functions will read
|
||||
and write data to and from the printer, respectively. The
|
||||
read function will be non-blocking, returning data only if
|
||||
there is data coming back from the printer.
|
||||
|
||||
The "ieee1394_error" function will return a string
|
||||
describing the last error or NULL if no error occurred.
|
||||
|
||||
The library will be responsible for creating any background
|
||||
threads that are needed to monitor the connection to the
|
||||
printer.
|
||||
|
||||
|
||||
CUPS BACKEND
|
||||
|
||||
The CUPS backend will use the OS abstraction layer to list
|
||||
and access the Firewire printers. The "main" function will
|
||||
read and write printer data, while the "list_devices"
|
||||
function will be called as necessary to identify the
|
||||
available devices.
|
||||
|
||||
The CUPS 1.1 backend will record any status information in
|
||||
the error log file, while the 1.2 backend will supply it to
|
||||
the printer driver process.
|
||||
@@ -0,0 +1,35 @@
|
||||
Easy Software Products
|
||||
44141 Airport View Drive
|
||||
Suite 204
|
||||
Hollywood, Maryland 20636
|
||||
+1.301.373.9600
|
||||
March 8, 2002
|
||||
|
||||
|
||||
Subject: EPSON Firewire Printer Driver for Linux
|
||||
|
||||
Currently, no Firewire printer support exists for Linux. Since
|
||||
the latest EPSON printer products depend on the Firewire
|
||||
interface to print at full speed, a solution is needed to
|
||||
support customers using Linux as their server platform.
|
||||
|
||||
The Linux Firewire subsystem provides a user-mode driver
|
||||
interface that allows driver programs to access Firewire
|
||||
devices. Easy Software Products will utilize this interface to
|
||||
develop a "backend" program for the Common UNIX Printing System
|
||||
that will allow users to print to EPSON printers using the
|
||||
Firewire interface.
|
||||
|
||||
After examining the Linux interface, we estimate that it will
|
||||
require approximately 30 hours of development time to write,
|
||||
test, and document the Firewire backend, for a total cost of
|
||||
$3,000. The new backend will become a standard part of the CUPS
|
||||
software distribution and will be included with at least the
|
||||
following Linux distributions:
|
||||
|
||||
- Caldera Linux
|
||||
- Mandrake Linux
|
||||
- Red Hat Linux
|
||||
- SuSE Linux
|
||||
|
||||
ESP will provide EPSON with binaries for Red Hat Linux 7.2.
|
||||
@@ -0,0 +1,623 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* IEEE-1284 support functions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" which should have been included with this file. If this
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* backendGetDeviceID() - Get the IEEE-1284 device ID string and
|
||||
* corresponding URI.
|
||||
* backendGetMakeModel() - Get the make and model string from the device ID.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include "backend-private.h"
|
||||
|
||||
#ifdef __linux
|
||||
# include <sys/ioctl.h>
|
||||
# include <linux/lp.h>
|
||||
# define IOCNR_GET_DEVICE_ID 1
|
||||
# define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
|
||||
# include <linux/parport.h>
|
||||
# include <linux/ppdev.h>
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
#endif /* __linux */
|
||||
|
||||
#ifdef __sun
|
||||
# ifdef __sparc
|
||||
# include <sys/ecppio.h>
|
||||
# else
|
||||
# include <sys/ioccom.h>
|
||||
# include <sys/ecppsys.h>
|
||||
# endif /* __sparc */
|
||||
#endif /* __sun */
|
||||
|
||||
|
||||
/*
|
||||
* 'backendGetDeviceID()' - Get the IEEE-1284 device ID string and
|
||||
* corresponding URI.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
backendGetDeviceID(
|
||||
int fd, /* I - File descriptor */
|
||||
char *device_id, /* O - 1284 device ID */
|
||||
int device_id_size, /* I - Size of buffer */
|
||||
char *make_model, /* O - Make/model */
|
||||
int make_model_size, /* I - Size of buffer */
|
||||
const char *scheme, /* I - URI scheme */
|
||||
char *uri, /* O - Device URI */
|
||||
int uri_size) /* I - Size of buffer */
|
||||
{
|
||||
#ifdef __APPLE__ /* This function is a no-op */
|
||||
return (-1);
|
||||
|
||||
#else /* Get the device ID from the specified file descriptor... */
|
||||
char *attr, /* 1284 attribute */
|
||||
*delim, /* 1284 delimiter */
|
||||
*uriptr, /* Pointer into URI */
|
||||
manufacturer[256], /* Manufacturer string */
|
||||
serial_number[1024]; /* Serial number string */
|
||||
int manulen; /* Length of manufacturer string */
|
||||
# ifdef __linux
|
||||
int length; /* Length of device ID info */
|
||||
int got_id = 0;
|
||||
# endif /* __linux */
|
||||
# if defined(__sun) && defined(ECPPIOC_GETDEVID)
|
||||
struct ecpp_device_id did; /* Device ID buffer */
|
||||
# endif /* __sun && ECPPIOC_GETDEVID */
|
||||
|
||||
|
||||
DEBUG_printf(("backendGetDeviceID(fd=%d, device_id=%p, device_id_size=%d, "
|
||||
"make_model=%p, make_model_size=%d, scheme=\"%s\", "
|
||||
"uri=%p, uri_size=%d)\n", fd, device_id, device_id_size,
|
||||
make_model, make_model_size, scheme ? scheme : "(null)",
|
||||
uri, uri_size));
|
||||
|
||||
/*
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (!device_id || device_id_size < 32)
|
||||
{
|
||||
DEBUG_puts("backendGetDeviceID: Bad args!");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (make_model)
|
||||
*make_model = '\0';
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
/*
|
||||
* Get the device ID string...
|
||||
*/
|
||||
|
||||
*device_id = '\0';
|
||||
|
||||
# ifdef __linux
|
||||
if (ioctl(fd, LPIOC_GET_DEVICE_ID(device_id_size), device_id))
|
||||
{
|
||||
/*
|
||||
* Linux has to implement things differently for every device it seems.
|
||||
* Since the standard parallel port driver does not provide a simple
|
||||
* ioctl() to get the 1284 device ID, we have to open the "raw" parallel
|
||||
* device corresponding to this port and do some negotiation trickery
|
||||
* to get the current device ID.
|
||||
*/
|
||||
|
||||
if (uri && !strncmp(uri, "parallel:/dev/", 14))
|
||||
{
|
||||
char devparport[16]; /* /dev/parportN */
|
||||
int devparportfd, /* File descriptor for raw device */
|
||||
mode; /* Port mode */
|
||||
|
||||
|
||||
/*
|
||||
* Since the Linux parallel backend only supports 4 parallel port
|
||||
* devices, just grab the trailing digit and use it to construct a
|
||||
* /dev/parportN filename...
|
||||
*/
|
||||
|
||||
snprintf(devparport, sizeof(devparport), "/dev/parport%s",
|
||||
uri + strlen(uri) - 1);
|
||||
|
||||
if ((devparportfd = open(devparport, O_RDWR | O_NOCTTY)) != -1)
|
||||
{
|
||||
/*
|
||||
* Claim the device...
|
||||
*/
|
||||
|
||||
if (!ioctl(devparportfd, PPCLAIM))
|
||||
{
|
||||
fcntl(devparportfd, F_SETFL, fcntl(devparportfd, F_GETFL) | O_NONBLOCK);
|
||||
|
||||
mode = IEEE1284_MODE_COMPAT;
|
||||
|
||||
if (!ioctl(devparportfd, PPNEGOT, &mode))
|
||||
{
|
||||
/*
|
||||
* Put the device into Device ID mode...
|
||||
*/
|
||||
|
||||
mode = IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID;
|
||||
|
||||
if (!ioctl(devparportfd, PPNEGOT, &mode))
|
||||
{
|
||||
/*
|
||||
* Read the 1284 device ID...
|
||||
*/
|
||||
|
||||
if ((length = read(devparportfd, device_id,
|
||||
device_id_size - 1)) >= 2)
|
||||
{
|
||||
device_id[length] = '\0';
|
||||
got_id = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the device...
|
||||
*/
|
||||
|
||||
ioctl(devparportfd, PPRELEASE);
|
||||
}
|
||||
|
||||
close(devparportfd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
got_id = 1;
|
||||
|
||||
if (got_id)
|
||||
{
|
||||
/*
|
||||
* Extract the length of the device ID string from the first two
|
||||
* bytes. The 1284 spec says the length is stored MSB first...
|
||||
*/
|
||||
|
||||
length = (((unsigned)device_id[0] & 255) << 8) +
|
||||
((unsigned)device_id[1] & 255);
|
||||
|
||||
/*
|
||||
* Check to see if the length is larger than our buffer; first
|
||||
* assume that the vendor incorrectly implemented the 1284 spec,
|
||||
* and then limit the length to the size of our buffer...
|
||||
*/
|
||||
|
||||
if (length > (device_id_size - 2))
|
||||
length = (((unsigned)device_id[1] & 255) << 8) +
|
||||
((unsigned)device_id[0] & 255);
|
||||
|
||||
if (length > (device_id_size - 2))
|
||||
length = device_id_size - 2;
|
||||
|
||||
/*
|
||||
* Copy the device ID text to the beginning of the buffer and
|
||||
* nul-terminate.
|
||||
*/
|
||||
|
||||
memmove(device_id, device_id + 2, length);
|
||||
device_id[length] = '\0';
|
||||
}
|
||||
# ifdef DEBUG
|
||||
else
|
||||
printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno));
|
||||
# endif /* DEBUG */
|
||||
# endif /* __linux */
|
||||
|
||||
# if defined(__sun) && defined(ECPPIOC_GETDEVID)
|
||||
did.mode = ECPP_CENTRONICS;
|
||||
did.len = device_id_size - 1;
|
||||
did.rlen = 0;
|
||||
did.addr = device_id;
|
||||
|
||||
if (!ioctl(fd, ECPPIOC_GETDEVID, &did))
|
||||
{
|
||||
/*
|
||||
* Nul-terminate the device ID text.
|
||||
*/
|
||||
|
||||
if (did.rlen < (device_id_size - 1))
|
||||
device_id[did.rlen] = '\0';
|
||||
else
|
||||
device_id[device_id_size - 1] = '\0';
|
||||
}
|
||||
# ifdef DEBUG
|
||||
else
|
||||
printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno));
|
||||
# endif /* DEBUG */
|
||||
# endif /* __sun && ECPPIOC_GETDEVID */
|
||||
}
|
||||
|
||||
DEBUG_printf(("backendGetDeviceID: device_id=\"%s\"\n", device_id));
|
||||
|
||||
if (scheme && uri)
|
||||
*uri = '\0';
|
||||
|
||||
if (!*device_id)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Get the make and model...
|
||||
*/
|
||||
|
||||
if (make_model)
|
||||
backendGetMakeModel(device_id, make_model, make_model_size);
|
||||
|
||||
/*
|
||||
* Then generate a device URI...
|
||||
*/
|
||||
|
||||
if (scheme && uri && uri_size > 32)
|
||||
{
|
||||
/*
|
||||
* Look for the serial number field...
|
||||
*/
|
||||
|
||||
if ((attr = strstr(device_id, "SERN:")) != NULL)
|
||||
attr += 5;
|
||||
else if ((attr = strstr(device_id, "SERIALNUMBER:")) != NULL)
|
||||
attr += 13;
|
||||
else if ((attr = strstr(device_id, ";SN:")) != NULL)
|
||||
attr += 4;
|
||||
|
||||
if (attr)
|
||||
{
|
||||
strlcpy(serial_number, attr, sizeof(serial_number));
|
||||
|
||||
if ((delim = strchr(serial_number, ';')) != NULL)
|
||||
*delim = '\0';
|
||||
}
|
||||
else
|
||||
serial_number[0] = '\0';
|
||||
|
||||
/*
|
||||
* Generate the device URI from the manufacturer, make_model, and
|
||||
* serial number strings.
|
||||
*/
|
||||
|
||||
snprintf(uri, uri_size, "%s://", scheme);
|
||||
|
||||
if ((attr = strstr(device_id, "MANUFACTURER:")) != NULL)
|
||||
attr += 13;
|
||||
else if ((attr = strstr(device_id, "Manufacturer:")) != NULL)
|
||||
attr += 13;
|
||||
else if ((attr = strstr(device_id, "MFG:")) != NULL)
|
||||
attr += 4;
|
||||
|
||||
if (attr)
|
||||
{
|
||||
strlcpy(manufacturer, attr, sizeof(manufacturer));
|
||||
|
||||
if ((delim = strchr(manufacturer, ';')) != NULL)
|
||||
*delim = '\0';
|
||||
|
||||
if (!strcasecmp(manufacturer, "Hewlett-Packard"))
|
||||
strcpy(manufacturer, "HP");
|
||||
else if (!strcasecmp(manufacturer, "Lexmark International"))
|
||||
strcpy(manufacturer, "Lexmark");
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(manufacturer, make_model, sizeof(manufacturer));
|
||||
|
||||
if ((delim = strchr(manufacturer, ' ')) != NULL)
|
||||
*delim = '\0';
|
||||
}
|
||||
|
||||
manulen = strlen(manufacturer);
|
||||
|
||||
for (uriptr = uri + strlen(uri), delim = manufacturer;
|
||||
*delim && uriptr < (uri + uri_size - 3);
|
||||
delim ++)
|
||||
if (*delim == ' ')
|
||||
{
|
||||
*uriptr++ = '%';
|
||||
*uriptr++ = '2';
|
||||
*uriptr++ = '0';
|
||||
}
|
||||
else
|
||||
*uriptr++ = *delim;
|
||||
|
||||
*uriptr++ = '/';
|
||||
|
||||
if (!strncasecmp(make_model, manufacturer, manulen))
|
||||
{
|
||||
delim = make_model + manulen;
|
||||
|
||||
while (isspace(*delim & 255))
|
||||
delim ++;
|
||||
}
|
||||
else
|
||||
delim = make_model;
|
||||
|
||||
for (; *delim && uriptr < (uri + uri_size - 3); delim ++)
|
||||
if (*delim == ' ')
|
||||
{
|
||||
*uriptr++ = '%';
|
||||
*uriptr++ = '2';
|
||||
*uriptr++ = '0';
|
||||
}
|
||||
else
|
||||
*uriptr++ = *delim;
|
||||
|
||||
if (serial_number[0])
|
||||
{
|
||||
/*
|
||||
* Add the serial number to the URI...
|
||||
*/
|
||||
|
||||
strlcpy(uriptr, "?serial=", uri_size - (uriptr - uri));
|
||||
strlcat(uriptr, serial_number, uri_size - (uriptr - uri));
|
||||
}
|
||||
else
|
||||
*uriptr = '\0';
|
||||
}
|
||||
|
||||
return (0);
|
||||
#endif /* __APPLE__ */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'backendGetMakeModel()' - Get the make and model string from the device ID.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
backendGetMakeModel(
|
||||
const char *device_id, /* O - 1284 device ID */
|
||||
char *make_model, /* O - Make/model */
|
||||
int make_model_size) /* I - Size of buffer */
|
||||
{
|
||||
char *attr, /* 1284 attribute */
|
||||
*delim, /* 1284 delimiter */
|
||||
*mfg, /* Manufacturer string */
|
||||
*mdl; /* Model string */
|
||||
|
||||
|
||||
DEBUG_printf(("backendGetMakeModel(device_id=\"%s\", "
|
||||
"make_model=%p, make_model_size=%d)\n", device_id,
|
||||
make_model, make_model_size));
|
||||
|
||||
/*
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (!device_id || !*device_id || !make_model || make_model_size < 32)
|
||||
{
|
||||
DEBUG_puts("backendGetMakeModel: Bad args!");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*make_model = '\0';
|
||||
|
||||
/*
|
||||
* Look for the description field...
|
||||
*/
|
||||
|
||||
if ((attr = strstr(device_id, "DES:")) != NULL)
|
||||
attr += 4;
|
||||
else if ((attr = strstr(device_id, "DESCRIPTION:")) != NULL)
|
||||
attr += 12;
|
||||
|
||||
if (attr)
|
||||
{
|
||||
/*
|
||||
* Make sure the description contains something useful, since some
|
||||
* printer manufacturers (HP) apparently don't follow the standards
|
||||
* they helped to define...
|
||||
*
|
||||
* Here we require the description to be 8 or more characters in length,
|
||||
* containing at least one space and one letter.
|
||||
*/
|
||||
|
||||
if ((delim = strchr(attr, ';')) == NULL)
|
||||
delim = attr + strlen(attr);
|
||||
|
||||
if ((delim - attr) < 8)
|
||||
attr = NULL;
|
||||
else
|
||||
{
|
||||
char *ptr; /* Pointer into description */
|
||||
int letters, /* Number of letters seen */
|
||||
spaces; /* Number of spaces seen */
|
||||
|
||||
|
||||
for (ptr = attr, letters = 0, spaces = 0; ptr < delim; ptr ++)
|
||||
{
|
||||
if (isspace(*ptr & 255))
|
||||
spaces ++;
|
||||
else if (isalpha(*ptr & 255))
|
||||
letters ++;
|
||||
|
||||
if (spaces && letters)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!spaces || !letters)
|
||||
attr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mfg = strstr(device_id, "MANUFACTURER:")) != NULL)
|
||||
mfg += 13;
|
||||
else if ((mfg = strstr(device_id, "Manufacturer:")) != NULL)
|
||||
mfg += 13;
|
||||
else if ((mfg = strstr(device_id, "MFG:")) != NULL)
|
||||
mfg += 4;
|
||||
|
||||
if ((mdl = strstr(device_id, "MODEL:")) != NULL)
|
||||
mdl += 6;
|
||||
else if ((mdl = strstr(device_id, "Model:")) != NULL)
|
||||
mdl += 6;
|
||||
else if ((mdl = strstr(device_id, "MDL:")) != NULL)
|
||||
mdl += 4;
|
||||
|
||||
if (mdl)
|
||||
{
|
||||
/*
|
||||
* Build a make-model string from the manufacturer and model attributes...
|
||||
*/
|
||||
|
||||
if (mfg)
|
||||
{
|
||||
/*
|
||||
* Skip leading whitespace...
|
||||
*/
|
||||
|
||||
while (isspace(*mfg & 255))
|
||||
mfg ++;
|
||||
|
||||
/*
|
||||
* Map common bad names to the ones we use for driver selection...
|
||||
*/
|
||||
|
||||
if (!strncasecmp(mfg, "Hewlett-Packard", 15))
|
||||
strlcpy(make_model, "HP", make_model_size);
|
||||
else if (!strncasecmp(mfg, "Lexmark International", 21))
|
||||
strlcpy(make_model, "Lexmark", make_model_size);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Use the manufacturer that is supplied...
|
||||
*/
|
||||
|
||||
strlcpy(make_model, mfg, make_model_size);
|
||||
|
||||
if ((delim = strchr(make_model, ';')) != NULL)
|
||||
*delim = '\0';
|
||||
|
||||
/*
|
||||
* But strip trailing whitespace...
|
||||
*/
|
||||
|
||||
for (delim = make_model + strlen(make_model) - 1;
|
||||
delim > make_model && *delim == ' ';
|
||||
delim --)
|
||||
*delim = '\0';
|
||||
}
|
||||
|
||||
if (!strncasecmp(make_model, mdl, strlen(make_model)))
|
||||
{
|
||||
/*
|
||||
* Just copy model string, since it has the manufacturer...
|
||||
*/
|
||||
|
||||
strlcpy(make_model, mdl, make_model_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Concatenate the make and model...
|
||||
*/
|
||||
|
||||
while (isspace(*mdl & 255))
|
||||
mdl ++;
|
||||
|
||||
strlcat(make_model, " ", make_model_size);
|
||||
strlcat(make_model, mdl, make_model_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just copy model string, since it has the manufacturer...
|
||||
*/
|
||||
|
||||
while (isspace(*mdl & 255))
|
||||
mdl ++;
|
||||
|
||||
strlcpy(make_model, mdl, make_model_size);
|
||||
}
|
||||
}
|
||||
else if (attr)
|
||||
{
|
||||
/*
|
||||
* Use description...
|
||||
*/
|
||||
|
||||
while (isspace(*attr & 255))
|
||||
attr ++;
|
||||
|
||||
if (!strncasecmp(attr, "Hewlett-Packard hp ", 19))
|
||||
{
|
||||
/*
|
||||
* Check for a common HP bug...
|
||||
*/
|
||||
|
||||
strlcpy(make_model, "HP ", make_model_size);
|
||||
strlcpy(make_model + 3, attr + 19, make_model_size - 3);
|
||||
}
|
||||
else if (!strncasecmp(attr, "Hewlett-Packard ", 16))
|
||||
{
|
||||
strlcpy(make_model, "HP ", make_model_size);
|
||||
strlcpy(make_model + 3, attr + 16, make_model_size - 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(make_model, attr, make_model_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Use "Unknown" as the printer make and model...
|
||||
*/
|
||||
|
||||
strlcpy(make_model, "Unknown", make_model_size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip trailing data...
|
||||
*/
|
||||
|
||||
if ((delim = strchr(make_model, ';')) != NULL)
|
||||
*delim = '\0';
|
||||
|
||||
for (delim = make_model + strlen(make_model) - 1;
|
||||
delim > make_model && *delim == ' ';
|
||||
delim --)
|
||||
*delim = '\0';
|
||||
|
||||
/*
|
||||
* Strip trailing whitespace...
|
||||
*/
|
||||
|
||||
for (delim = make_model + strlen(make_model) - 1; delim >= make_model; delim --)
|
||||
if (isspace(*delim & 255))
|
||||
*delim = '\0';
|
||||
else
|
||||
break;
|
||||
|
||||
/*
|
||||
* Return...
|
||||
*/
|
||||
|
||||
if (make_model[0])
|
||||
return (0);
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,878 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Linux IEEE-1394 glue for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2002 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the
|
||||
* above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use
|
||||
* of this software must display the following
|
||||
* acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Easy
|
||||
* Software Products.
|
||||
*
|
||||
* 4. The name of Easy Software Products may not be used to
|
||||
* endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* get_device_id() - Get the IEEE-1284 device ID for a node...
|
||||
* get_unit_type() - Get the unit type for a node...
|
||||
* show_data() - Show a data node...
|
||||
* show_dir() - Show a directory list...
|
||||
* ieee1394_list() - List the available printer devices.
|
||||
* ieee1394_open() - Open a printer device.
|
||||
* ieee1394_close() - Close a printer device.
|
||||
* ieee1394_read() - Read from a printer device.
|
||||
* ieee1394_write() - Write data to a printer device.
|
||||
* ieee1394_error() - Return the last error.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include "ieee1394.h"
|
||||
#include <cups/debug.h>
|
||||
#include <libraw1394/raw1394.h>
|
||||
#include <libraw1394/csr.h>
|
||||
|
||||
|
||||
/*
|
||||
* Limits...
|
||||
*/
|
||||
|
||||
#define MAX_NODES 100
|
||||
|
||||
|
||||
/*
|
||||
* Structures...
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char uri[HTTP_MAX_URI],/* URI for this node... */
|
||||
description[128],/* Description of port */
|
||||
make_model[128];/* Make and model */
|
||||
int port, /* Port where this node is found */
|
||||
node; /* Node number */
|
||||
unsigned long long addr; /* Management address */
|
||||
} linux1394_node_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
raw1394handle_t handle; /* Handle for printer device */
|
||||
int node; /* Node number for printer device */
|
||||
unsigned long long addr; /* Management address */
|
||||
} linux1394_dev_t;
|
||||
|
||||
|
||||
/*
|
||||
* ORB messages for communication with the device...
|
||||
*/
|
||||
|
||||
typedef struct /**** Login ORB Message */
|
||||
{
|
||||
unsigned char passwd_addr[8]; /* Password address */
|
||||
unsigned char resp_addr[8]; /* Login response address */
|
||||
unsigned char notify_excl; /* Notify and exclusive bits */
|
||||
unsigned char recon_func; /* Reconnect time and function */
|
||||
unsigned char lun[2]; /* Logical unit number */
|
||||
unsigned char passwd_len[2]; /* Length of password */
|
||||
unsigned char resp_len[2]; /* Length of login response */
|
||||
unsigned char fifo_addr[8]; /* Local status FIFO address */
|
||||
} login_orb_t;
|
||||
|
||||
typedef struct /**** Login Response Message ****/
|
||||
{
|
||||
unsigned char length[2]; /* Length of response */
|
||||
unsigned char login_id[2]; /* Login ID */
|
||||
unsigned char cmd_addr[8]; /* Command block agent address */
|
||||
unsigned char reserved[2]; /* Reserved (0) */
|
||||
unsigned char recon_hold[2]; /* Number of seconds to hold login */
|
||||
} login_resp_t;
|
||||
|
||||
|
||||
/*
|
||||
* Local globals...
|
||||
*/
|
||||
|
||||
static char error_string[1024] = "";
|
||||
static int num_nodes;
|
||||
static linux1394_node_t nodes[MAX_NODES];
|
||||
|
||||
|
||||
/*
|
||||
* 'get_device_id()' - Get the IEEE-1284 device ID for a node...
|
||||
*/
|
||||
|
||||
static char * /* O - Device ID */
|
||||
get_device_id(raw1394handle_t handle,/* I - Handle for device */
|
||||
int node, /* I - Node number */
|
||||
unsigned long long offset,/* I - Offset to directory */
|
||||
char *id, /* O - ID string */
|
||||
int idlen) /* I - Size of ID string */
|
||||
{
|
||||
unsigned char data[1024], /* Data from ROM */
|
||||
*dataptr; /* Pointer into data */
|
||||
int length; /* Length of directory */
|
||||
int datalen; /* Length of data */
|
||||
unsigned long long dataoff; /* Offset of data */
|
||||
|
||||
|
||||
DEBUG_printf(("get_device_id(handle = %p, node = %d, offset = %llx, id = %p, idlen = %d)\n",
|
||||
handle, node, offset, id, idlen));
|
||||
|
||||
*id = '\0';
|
||||
|
||||
/*
|
||||
* Read the directory length from the first quadlet...
|
||||
*/
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (NULL);
|
||||
|
||||
offset += 4;
|
||||
|
||||
/*
|
||||
* The length is in the upper 16 bits...
|
||||
*/
|
||||
|
||||
length = (data[0] << 8) | data[1];
|
||||
|
||||
DEBUG_printf((" length = %d\n", length));
|
||||
|
||||
/*
|
||||
* Then read the directory, looking for unit directory or device tags...
|
||||
*/
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (NULL);
|
||||
|
||||
DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1],
|
||||
data[2], data[3]));
|
||||
|
||||
if (data[0] == 0xd1)
|
||||
{
|
||||
/*
|
||||
* Found the unit directory...
|
||||
*/
|
||||
|
||||
offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2;
|
||||
|
||||
return (get_device_id(handle, node, offset, id, idlen));
|
||||
}
|
||||
else if (data[0] == 0x81)
|
||||
{
|
||||
/*
|
||||
* Found potential IEEE-1284 device ID...
|
||||
*/
|
||||
|
||||
dataoff = offset + (((((data[1] << 8) | data[2]) << 8) | data[3]) << 2);
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, dataoff, 4, (quadlet_t *)data) < 0)
|
||||
return (NULL);
|
||||
|
||||
dataoff += 4;
|
||||
|
||||
/*
|
||||
* Read the leaf value...
|
||||
*/
|
||||
|
||||
datalen = (data[0] << 8) | data[1];
|
||||
|
||||
if (datalen > (sizeof(data) / 4))
|
||||
datalen = sizeof(data) / 4;
|
||||
|
||||
for (dataptr = data; datalen > 0; datalen --, dataptr += 4, dataoff += 4)
|
||||
if (raw1394_read(handle, 0xffc0 | node, dataoff, 4,
|
||||
(quadlet_t *)dataptr) < 0)
|
||||
return (NULL);
|
||||
|
||||
if (data[0] == 0 && memcmp(data + 8, "MFG:", 4) == 0)
|
||||
{
|
||||
/*
|
||||
* Found the device ID...
|
||||
*/
|
||||
|
||||
datalen = dataptr - data - 8;
|
||||
if (datalen >= idlen)
|
||||
datalen --;
|
||||
|
||||
memcpy(id, data + 8, datalen);
|
||||
id[datalen] = '\0';
|
||||
|
||||
return (id);
|
||||
}
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
length --;
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'get_man_addr()' - Get the management address for a node...
|
||||
*/
|
||||
|
||||
static int /* O - Unit type */
|
||||
get_man_addr(raw1394handle_t handle, /* I - Handle for device */
|
||||
int node, /* I - Node number */
|
||||
unsigned long long offset) /* I - Offset to directory */
|
||||
{
|
||||
unsigned char data[4]; /* Data from ROM */
|
||||
int length; /* Length of directory */
|
||||
|
||||
|
||||
DEBUG_printf(("get_man_addr(handle = %p, node = %d, offset = %llx)\n",
|
||||
handle, node, offset));
|
||||
|
||||
/*
|
||||
* Read the directory length from the first quadlet...
|
||||
*/
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (-1);
|
||||
|
||||
offset += 4;
|
||||
|
||||
/*
|
||||
* The length is in the upper 16 bits...
|
||||
*/
|
||||
|
||||
length = (data[0] << 8) | data[1];
|
||||
|
||||
DEBUG_printf((" length = %d\n", length));
|
||||
|
||||
/*
|
||||
* Then read the directory, looking for unit directory or type tags...
|
||||
*/
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (-1);
|
||||
|
||||
DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1],
|
||||
data[2], data[3]));
|
||||
|
||||
if (data[0] == 0xd1)
|
||||
{
|
||||
/*
|
||||
* Found the unit directory...
|
||||
*/
|
||||
|
||||
offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2;
|
||||
|
||||
return (get_man_addr(handle, node, offset));
|
||||
}
|
||||
else if (data[0] == 0x54)
|
||||
{
|
||||
/*
|
||||
* Found the management address...
|
||||
*/
|
||||
|
||||
return (((((data[1] << 8) | data[2]) << 8) | data[3]) << 2);
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
length --;
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'get_unit_type()' - Get the unit type for a node...
|
||||
*/
|
||||
|
||||
static int /* O - Unit type */
|
||||
get_unit_type(raw1394handle_t handle,/* I - Handle for device */
|
||||
int node, /* I - Node number */
|
||||
unsigned long long offset)/* I - Offset to directory */
|
||||
{
|
||||
unsigned char data[4]; /* Data from ROM */
|
||||
int length; /* Length of directory */
|
||||
|
||||
|
||||
DEBUG_printf(("get_unit_type(handle = %p, node = %d, offset = %llx)\n",
|
||||
handle, node, offset));
|
||||
|
||||
/*
|
||||
* Read the directory length from the first quadlet...
|
||||
*/
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (-1);
|
||||
|
||||
offset += 4;
|
||||
|
||||
/*
|
||||
* The length is in the upper 16 bits...
|
||||
*/
|
||||
|
||||
length = (data[0] << 8) | data[1];
|
||||
|
||||
DEBUG_printf((" length = %d\n", length));
|
||||
|
||||
/*
|
||||
* Then read the directory, looking for unit directory or type tags...
|
||||
*/
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return (-1);
|
||||
|
||||
DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1],
|
||||
data[2], data[3]));
|
||||
|
||||
if (data[0] == 0xd1)
|
||||
{
|
||||
/*
|
||||
* Found the unit directory...
|
||||
*/
|
||||
|
||||
offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2;
|
||||
|
||||
return (get_unit_type(handle, node, offset));
|
||||
}
|
||||
else if (data[0] == 0x14)
|
||||
{
|
||||
/*
|
||||
* Found the unit type...
|
||||
*/
|
||||
|
||||
return (data[1] & 0x1f);
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
length --;
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* 'show_data()' - Show a data node...
|
||||
*/
|
||||
|
||||
static void
|
||||
show_data(raw1394handle_t handle, /* I - Handle for device */
|
||||
int node, /* I - Node number */
|
||||
unsigned long long offset, /* I - Offset to directory */
|
||||
int indent) /* Amount to indent */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
unsigned char data[4]; /* Data from ROM */
|
||||
int length; /* Length of data */
|
||||
|
||||
|
||||
/*
|
||||
* Read the data length from the first quadlet...
|
||||
*/
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return;
|
||||
|
||||
offset += 4;
|
||||
|
||||
/*
|
||||
* The length is in the upper 16 bits...
|
||||
*/
|
||||
|
||||
length = (data[0] << 8) | data[1];
|
||||
|
||||
/*
|
||||
* Then read the data...
|
||||
*/
|
||||
|
||||
for (i = 0; i < indent; i ++)
|
||||
putchar(' ');
|
||||
|
||||
printf("LEAF (%d quadlets)\n", length);
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < indent; i ++)
|
||||
putchar(' ');
|
||||
|
||||
printf("%02X %02X %02X %02X '%c%c%c%c'\n",
|
||||
data[0], data[1], data[2], data[3],
|
||||
(data[0] < ' ' || data[0] >= 0x7f) ? '.' : data[0],
|
||||
(data[1] < ' ' || data[1] >= 0x7f) ? '.' : data[1],
|
||||
(data[2] < ' ' || data[2] >= 0x7f) ? '.' : data[2],
|
||||
(data[3] < ' ' || data[3] >= 0x7f) ? '.' : data[3]);
|
||||
|
||||
offset += 4;
|
||||
length --;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_dir()' - Show a directory list...
|
||||
*/
|
||||
|
||||
static void
|
||||
show_dir(raw1394handle_t handle, /* I - Handle for device */
|
||||
int node, /* I - Node number */
|
||||
unsigned long long offset, /* I - Offset to directory */
|
||||
int indent) /* Amount to indent */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
unsigned char data[4]; /* Data from ROM */
|
||||
int length; /* Length of directory */
|
||||
int value; /* Value in directory */
|
||||
|
||||
|
||||
/*
|
||||
* Read the directory length from the first quadlet...
|
||||
*/
|
||||
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return;
|
||||
|
||||
offset += 4;
|
||||
|
||||
/*
|
||||
* The length is in the upper 16 bits...
|
||||
*/
|
||||
|
||||
length = (data[0] << 8) | data[1];
|
||||
|
||||
/*
|
||||
* Then read the directory...
|
||||
*/
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < indent; i ++)
|
||||
putchar(' ');
|
||||
|
||||
printf("%02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
|
||||
|
||||
value = (((data[1] << 8) | data[2]) << 8) | data[3];
|
||||
|
||||
switch (data[0] & 0xc0)
|
||||
{
|
||||
case 0x00 :
|
||||
for (i = -4; i < indent; i ++)
|
||||
putchar(' ');
|
||||
|
||||
printf("IMMEDIATE %d\n", value);
|
||||
break;
|
||||
|
||||
case 0x40 :
|
||||
for (i = -4; i < indent; i ++)
|
||||
putchar(' ');
|
||||
|
||||
printf("CSR OFFSET +%06X\n", value);
|
||||
break;
|
||||
|
||||
case 0x80 :
|
||||
show_data(handle, node, offset + value * 4, indent + 4);
|
||||
break;
|
||||
|
||||
case 0xc0 :
|
||||
show_dir(handle, node, offset + value * 4, indent + 4);
|
||||
break;
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
length --;
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_list()' - List the available printer devices.
|
||||
*/
|
||||
|
||||
ieee1394_info_t * /* O - Printer information */
|
||||
ieee1394_list(int *num_devices) /* O - Number of printers */
|
||||
{
|
||||
int i, j; /* Looping vars */
|
||||
raw1394handle_t handle; /* 1394 handle */
|
||||
int num_ports; /* Number of ports */
|
||||
struct raw1394_portinfo ports[100]; /* Port data... */
|
||||
unsigned char guid[8]; /* Global unique ID */
|
||||
int vendor; /* Vendor portion of GUID */
|
||||
int unit_type; /* Unit type */
|
||||
int addr; /* Management address offset */
|
||||
char id[1024], /* Device ID string */
|
||||
*idptr, /* Pointer into ID string */
|
||||
*idsep; /* Pointer to separator */
|
||||
ieee1394_info_t *devices; /* Device list */
|
||||
|
||||
|
||||
/*
|
||||
* Connect to the user-mode driver interface...
|
||||
*/
|
||||
|
||||
handle = raw1394_new_handle();
|
||||
num_ports = raw1394_get_port_info(handle, ports,
|
||||
sizeof(ports) / sizeof(ports[0]));
|
||||
|
||||
DEBUG_printf(("num_ports = %d\n", num_ports));
|
||||
|
||||
/*
|
||||
* Loop through the ports to discover what nodes are available.
|
||||
*/
|
||||
|
||||
num_nodes = 0;
|
||||
|
||||
for (i = 0; i < num_ports; i ++)
|
||||
{
|
||||
DEBUG_printf(("ports[%d] = { nodes = %d, name = \"%s\" }\n", i,
|
||||
ports[i].nodes, ports[i].name));
|
||||
|
||||
raw1394_set_port(handle, i);
|
||||
|
||||
for (j = 0; j < ports[i].nodes; j ++)
|
||||
{
|
||||
if (raw1394_read(handle, 0xffc0 | j,
|
||||
CSR_REGISTER_BASE + CSR_CONFIG_ROM + 12, 4,
|
||||
(quadlet_t *)guid) < 0)
|
||||
{
|
||||
DEBUG_printf((" Node #%d: Unable to contact (%s)!\n", j,
|
||||
strerror(errno)));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
raw1394_read(handle, 0xffc0 | j,
|
||||
CSR_REGISTER_BASE + CSR_CONFIG_ROM + 16, 4,
|
||||
(quadlet_t *)(guid + 4));
|
||||
|
||||
DEBUG_printf((" Node #%d: GUID = %02X%02X%02X%02X%02X%02X%02X%02X\n",
|
||||
j, guid[0], guid[1], guid[2], guid[3], guid[4],
|
||||
guid[5], guid[6], guid[7]));
|
||||
|
||||
vendor = (((guid[0] << 8) | guid[1]) << 8) | guid[2];
|
||||
unit_type = get_unit_type(handle, j,
|
||||
CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20);
|
||||
|
||||
DEBUG_printf(("vendor = %x, unit_type = %d\n", vendor, unit_type));
|
||||
|
||||
if (unit_type == 2 && num_nodes < MAX_NODES)
|
||||
{
|
||||
/*
|
||||
* Found a printer device; add it to the nodes list...
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
show_dir(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20, 0);
|
||||
#endif /* DEBUG */
|
||||
|
||||
memset(nodes + num_nodes, 0, sizeof(linux1394_node_t));
|
||||
|
||||
sprintf(nodes[num_nodes].uri, "ieee1394://%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
guid[0], guid[1], guid[2], guid[3], guid[4],
|
||||
guid[5], guid[6], guid[7]);
|
||||
|
||||
nodes[num_nodes].port = i;
|
||||
nodes[num_nodes].node = j;
|
||||
|
||||
addr = get_man_addr(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20);
|
||||
|
||||
if (addr < 0)
|
||||
continue;
|
||||
|
||||
nodes[num_nodes].addr = CSR_REGISTER_BASE + addr;
|
||||
|
||||
DEBUG_printf(("Node address = %llx\n", nodes[num_nodes].addr));
|
||||
|
||||
get_device_id(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20,
|
||||
id, sizeof(id));
|
||||
|
||||
if (id[0])
|
||||
{
|
||||
/*
|
||||
* Grab the manufacturer and model name from the device ID
|
||||
* string...
|
||||
*/
|
||||
|
||||
idptr = id + 4;
|
||||
idsep = strchr(id, ';');
|
||||
if (idsep)
|
||||
*idsep++ = '\0';
|
||||
else
|
||||
idsep = idptr;
|
||||
|
||||
snprintf(nodes[num_nodes].description,
|
||||
sizeof(nodes[num_nodes].description),
|
||||
"%s Firewire Printer", idptr);
|
||||
|
||||
if ((idptr = strstr(idsep, "DES:")) == NULL)
|
||||
idptr = strstr(idsep, "MDL:");
|
||||
|
||||
if (idptr == NULL)
|
||||
strcpy(nodes[num_nodes].make_model, "Unknown");
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Grab the DES or MDL code...
|
||||
*/
|
||||
|
||||
idptr += 4;
|
||||
idsep = strchr(idptr, ';');
|
||||
if (idsep)
|
||||
*idsep = '\0';
|
||||
|
||||
if (strncmp(id + 4, idptr, strlen(id + 4)) == 0)
|
||||
{
|
||||
/*
|
||||
* Use the description directly...
|
||||
*/
|
||||
|
||||
strlcpy(nodes[num_nodes].make_model, idptr,
|
||||
sizeof(nodes[num_nodes].make_model));
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Add the manufacturer to the front of the name...
|
||||
*/
|
||||
|
||||
snprintf(nodes[num_nodes].make_model,
|
||||
sizeof(nodes[num_nodes].make_model),
|
||||
"%s %s", id + 4, idptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Flag it as an unknown printer...
|
||||
*/
|
||||
|
||||
sprintf(nodes[num_nodes].description,
|
||||
"Unknown%06X Firewire Printer", vendor);
|
||||
strcpy(nodes[num_nodes].make_model, "Unknown");
|
||||
}
|
||||
|
||||
num_nodes ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Done querying the Firewire bus...
|
||||
*/
|
||||
|
||||
raw1394_destroy_handle(handle);
|
||||
|
||||
/*
|
||||
* Build an array of device info structures as needed...
|
||||
*/
|
||||
|
||||
if (num_devices == NULL)
|
||||
return (NULL);
|
||||
|
||||
*num_devices = num_nodes;
|
||||
|
||||
if (num_nodes)
|
||||
{
|
||||
if ((devices = calloc(sizeof(ieee1394_info_t), num_nodes)) != NULL)
|
||||
{
|
||||
for (i = 0; i < num_nodes; i ++)
|
||||
{
|
||||
strcpy(devices[i].uri, nodes[i].uri);
|
||||
strcpy(devices[i].description, nodes[i].description);
|
||||
strcpy(devices[i].make_model, nodes[i].make_model);
|
||||
}
|
||||
}
|
||||
|
||||
return (devices);
|
||||
}
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_open()' - Open a printer device.
|
||||
*/
|
||||
|
||||
ieee1394_dev_t /* O - Printer device or NULL */
|
||||
ieee1394_open(const char *uri) /* I - Device URI */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
linux1394_dev_t *ldev; /* Linux device */
|
||||
|
||||
|
||||
/*
|
||||
* Return early if we can't see any printers...
|
||||
*/
|
||||
|
||||
if (num_nodes == 0)
|
||||
ieee1394_list(NULL);
|
||||
|
||||
if (num_nodes == 0)
|
||||
{
|
||||
strcpy(error_string, "No IEEE-1394 printers found!");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for the URI...
|
||||
*/
|
||||
|
||||
for (i = 0; i < num_nodes; i ++)
|
||||
if (strcmp(nodes[i].uri, uri) == 0)
|
||||
break;
|
||||
|
||||
if (i >= num_nodes)
|
||||
{
|
||||
snprintf(error_string, sizeof(error_string), "Device %s not found!", uri);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now create a new device structure...
|
||||
*/
|
||||
|
||||
if ((ldev = calloc(sizeof(linux1394_dev_t), 1)) == NULL)
|
||||
{
|
||||
strcpy(error_string, "Out of memory!");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ldev->handle = raw1394_new_handle();
|
||||
ldev->node = nodes[i].node;
|
||||
ldev->addr = nodes[i].addr;
|
||||
|
||||
raw1394_set_port(ldev->handle, nodes[i].port);
|
||||
|
||||
error_string[0] = '\0';
|
||||
|
||||
return ((ieee1394_dev_t)ldev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_close()' - Close a printer device.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
ieee1394_close(ieee1394_dev_t dev) /* I - Printer device */
|
||||
{
|
||||
linux1394_dev_t *ldev; /* Linux device */
|
||||
|
||||
|
||||
ldev = (linux1394_dev_t *)dev;
|
||||
|
||||
raw1394_destroy_handle(ldev->handle);
|
||||
|
||||
free(ldev);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_read()' - Read from a printer device.
|
||||
*/
|
||||
|
||||
int /* O - Number of bytes read or -1 */
|
||||
ieee1394_read(ieee1394_dev_t dev, /* I - Printer device */
|
||||
char *buffer, /* I - Read buffer */
|
||||
int len) /* I - Max bytes to read */
|
||||
{
|
||||
linux1394_dev_t *ldev; /* Linux device */
|
||||
|
||||
|
||||
ldev = (linux1394_dev_t *)dev;
|
||||
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_write()' - Write data to a printer device.
|
||||
*/
|
||||
|
||||
int /* O - Number of bytes written or -1 */
|
||||
ieee1394_write(ieee1394_dev_t dev, /* I - Printer device */
|
||||
char *buffer, /* I - Buffer to write */
|
||||
int len) /* I - Number of bytes to write */
|
||||
{
|
||||
linux1394_dev_t *ldev; /* Linux device */
|
||||
|
||||
|
||||
ldev = (linux1394_dev_t *)dev;
|
||||
|
||||
|
||||
/* if (raw1394_write(handle, 0xffc0 | j, 0, ,
|
||||
(quadlet_t *)guid) < 0)*/
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'ieee1394_error()' - Return the last error.
|
||||
*/
|
||||
|
||||
const char * /* O - Error string or NULL */
|
||||
ieee1394_error(void)
|
||||
{
|
||||
if (error_string[0])
|
||||
return (error_string);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* IEEE-1394 backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2002 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the
|
||||
* above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use
|
||||
* of this software must display the following
|
||||
* acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Easy
|
||||
* Software Products.
|
||||
*
|
||||
* 4. The name of Easy Software Products may not be used to
|
||||
* endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Send a file to the printer.
|
||||
* list_devices() - List all known printer devices...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include "ieee1394.h"
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void list_devices(void);
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Send a file to the printer.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* printer-uri job-id user title copies options [file]
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
ieee1394_dev_t dev; /* Printer device */
|
||||
int fp; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
int rbytes; /* Number of bytes read from device */
|
||||
size_t nbytes, /* Number of bytes read from file */
|
||||
tbytes; /* Total number of bytes written */
|
||||
char buffer[8192]; /* Input/output buffer */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
/*
|
||||
* Make sure status messages are not buffered...
|
||||
*/
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/*
|
||||
* Check command-line...
|
||||
*/
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
list_devices();
|
||||
|
||||
return (0);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s job-id user title copies options [file]\n",
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have 7 arguments, print the file named on the command-line.
|
||||
* Otherwise, send stdin instead...
|
||||
*/
|
||||
|
||||
if (argc == 6)
|
||||
{
|
||||
fp = 0;
|
||||
copies = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Try to open the print file...
|
||||
*/
|
||||
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
perror("ERROR: unable to open print file");
|
||||
return (1);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to open the printer device...
|
||||
*/
|
||||
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
if ((dev = ieee1394_open(argv[0])) == NULL)
|
||||
{
|
||||
fputs("INFO: Firewire printer busy; will retry in 30 seconds...\n", stderr);
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
while (dev == NULL);
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
* can finish out any page data the driver sends (e.g. to eject the
|
||||
* current page... Only ignore SIGTERM if we are printing data from
|
||||
* stdin (otherwise you can't cancel raw jobs...)
|
||||
*/
|
||||
|
||||
if (argc < 7)
|
||||
{
|
||||
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
|
||||
sigset(SIGTERM, SIG_IGN);
|
||||
#elif defined(HAVE_SIGACTION)
|
||||
memset(&action, 0, sizeof(action));
|
||||
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
#else
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
#endif /* HAVE_SIGSET */
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, send the print file...
|
||||
*/
|
||||
|
||||
while (copies > 0)
|
||||
{
|
||||
copies --;
|
||||
|
||||
if (fp != 0)
|
||||
{
|
||||
fputs("PAGE: 1 1\n", stderr);
|
||||
lseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
tbytes = 0;
|
||||
while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0)
|
||||
{
|
||||
/*
|
||||
* Write the print data to the printer...
|
||||
*/
|
||||
|
||||
tbytes += nbytes;
|
||||
|
||||
if (ieee1394_write(dev, buffer, nbytes) < 0)
|
||||
{
|
||||
perror("ERROR: Unable to send print file to printer");
|
||||
break;
|
||||
}
|
||||
|
||||
if ((rbytes = ieee1394_read(dev, buffer, sizeof(buffer))) > 0)
|
||||
fprintf(stderr, "INFO: Read %d bytes from printer...\n", rbytes);
|
||||
|
||||
if (argc > 6)
|
||||
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
|
||||
(unsigned long)tbytes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the printer device and input file and return...
|
||||
*/
|
||||
|
||||
ieee1394_close(dev);
|
||||
|
||||
if (fp != 0)
|
||||
close(fp);
|
||||
|
||||
fputs("INFO: Ready to print.\n", stderr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'list_devices()' - List all known devices...
|
||||
*/
|
||||
|
||||
void
|
||||
list_devices(void)
|
||||
{
|
||||
int i, /* Looping var */
|
||||
num_info; /* Number of devices */
|
||||
ieee1394_info_t *info; /* Devices... */
|
||||
|
||||
|
||||
/*
|
||||
* Get the available devices...
|
||||
*/
|
||||
|
||||
info = ieee1394_list(&num_info);
|
||||
|
||||
/*
|
||||
* List them as needed...
|
||||
*/
|
||||
|
||||
if (num_info > 0)
|
||||
{
|
||||
for (i = 0; i < num_info; i ++)
|
||||
printf("direct %s \"%s\" \"%s\"\n", info[i].uri,
|
||||
info[i].make_model, info[i].description);
|
||||
|
||||
free(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* IEEE-1394 header for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2002 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the
|
||||
* above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use
|
||||
* of this software must display the following
|
||||
* acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Easy
|
||||
* Software Products.
|
||||
*
|
||||
* 4. The name of Easy Software Products may not be used to
|
||||
* endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/cups.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <cups/string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
/*
|
||||
* Device information structure...
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char uri[HTTP_MAX_URI], /* Device URI */
|
||||
description[128], /* Description of port */
|
||||
make_model[128]; /* Make and model */
|
||||
} ieee1394_info_t;
|
||||
|
||||
|
||||
/*
|
||||
* Private device connection information...
|
||||
*/
|
||||
|
||||
typedef void *ieee1394_dev_t;
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for standard IEEE-1394 interface...
|
||||
*/
|
||||
|
||||
extern ieee1394_info_t *ieee1394_list(int *num_devices);
|
||||
extern ieee1394_dev_t ieee1394_open(const char *uri);
|
||||
extern int ieee1394_close(ieee1394_dev_t dev);
|
||||
extern int ieee1394_read(ieee1394_dev_t dev, char *buffer, int len);
|
||||
extern int ieee1394_write(ieee1394_dev_t dev, char *buffer, int len);
|
||||
extern const char *ieee1394_error(void);
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+932
-438
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+554
-281
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+1689
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+222
-226
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* Parallel port backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* 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
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" 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-3142 USA
|
||||
*
|
||||
* Voice: (301) 373-9600
|
||||
* EMail: cups-info@cups.org
|
||||
* WWW: http://www.cups.org
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
@@ -27,18 +18,20 @@
|
||||
*
|
||||
* main() - Send a file to the specified parallel port.
|
||||
* list_devices() - List all parallel devices.
|
||||
* side_cb() - Handle side-channel requests...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/cups.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cups/string.h>
|
||||
#include <signal.h>
|
||||
#include "backend-private.h"
|
||||
|
||||
#ifdef __hpux
|
||||
# include <sys/time.h>
|
||||
#else
|
||||
# include <sys/select.h>
|
||||
#endif /* __hpux */
|
||||
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
@@ -46,6 +39,7 @@
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
# include <termios.h>
|
||||
# include <sys/socket.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __sgi
|
||||
@@ -64,7 +58,8 @@
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void list_devices(void);
|
||||
static void list_devices(void);
|
||||
static void side_cb(int print_fd, int device_fd, int use_bc);
|
||||
|
||||
|
||||
/*
|
||||
@@ -75,27 +70,24 @@ void list_devices(void);
|
||||
* printer-uri job-id user title copies options [file]
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024], /* Resource info (device and options) */
|
||||
*options; /* Pointer to options */
|
||||
int port; /* Port number (not used) */
|
||||
int fp; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
int fd; /* Parallel device */
|
||||
int wbytes; /* Number of bytes written */
|
||||
size_t nbytes, /* Number of bytes read */
|
||||
tbytes; /* Total number of bytes written */
|
||||
char buffer[8192], /* Output buffer */
|
||||
*bufptr; /* Pointer into buffer */
|
||||
struct termios opts; /* Parallel port options */
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024], /* Resource info (device and options) */
|
||||
*options; /* Pointer to options */
|
||||
int port; /* Port number (not used) */
|
||||
int print_fd, /* Print file */
|
||||
device_fd, /* Parallel device */
|
||||
use_bc; /* Read back-channel data? */
|
||||
int copies; /* Number of copies to print */
|
||||
size_t tbytes; /* Total number of bytes written */
|
||||
struct termios opts; /* Parallel port options */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
@@ -126,12 +118,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if (argc == 1)
|
||||
{
|
||||
list_devices();
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fputs("Usage: parallel job-id user title copies options [file]\n", stderr);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("Usage: %s job-id user title copies options [file]\n"),
|
||||
argv[0]);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -141,8 +135,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
|
||||
if (argc == 6)
|
||||
{
|
||||
fp = 0;
|
||||
copies = 1;
|
||||
print_fd = 0;
|
||||
copies = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -150,10 +144,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Try to open the print file...
|
||||
*/
|
||||
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
perror("ERROR: unable to open print file");
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
@@ -163,7 +157,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Extract the device name and options from the URI...
|
||||
*/
|
||||
|
||||
httpSeparate(argv[0], method, username, hostname, &port, resource);
|
||||
httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
|
||||
method, sizeof(method), username, sizeof(username),
|
||||
hostname, sizeof(hostname), &port,
|
||||
resource, sizeof(resource));
|
||||
|
||||
/*
|
||||
* See if there are any options...
|
||||
@@ -183,124 +180,129 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Open the parallel port device...
|
||||
*/
|
||||
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
if ((fd = open(resource, O_WRONLY | O_EXCL)) == -1)
|
||||
#if defined(__linux) || defined(__FreeBSD__)
|
||||
/*
|
||||
* The Linux and FreeBSD parallel port drivers currently are broken WRT
|
||||
* select() and bidirection I/O...
|
||||
*/
|
||||
|
||||
device_fd = open(resource, O_WRONLY | O_EXCL);
|
||||
use_bc = 0;
|
||||
|
||||
#else
|
||||
if ((device_fd = open(resource, O_RDWR | O_EXCL)) < 0)
|
||||
{
|
||||
device_fd = open(resource, O_WRONLY | O_EXCL);
|
||||
use_bc = 0;
|
||||
}
|
||||
else
|
||||
use_bc = 1;
|
||||
#endif /* __linux || __FreeBSD__ */
|
||||
|
||||
if (device_fd == -1)
|
||||
{
|
||||
if (getenv("CLASS") != NULL)
|
||||
{
|
||||
/*
|
||||
* If the CLASS environment variable is set, the job was submitted
|
||||
* to a class and not to a specific queue. In this case, we want
|
||||
* to abort immediately so that the job can be requeued on the next
|
||||
* available printer in the class.
|
||||
*/
|
||||
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Unable to contact printer, queuing on next "
|
||||
"printer in class...\n"));
|
||||
|
||||
/*
|
||||
* Sleep 5 seconds to keep the job from requeuing too rapidly...
|
||||
*/
|
||||
|
||||
sleep(5);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
if (errno == EBUSY)
|
||||
{
|
||||
fputs("INFO: Parallel port busy; will retry in 30 seconds...\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Printer busy; will retry in 30 seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
else if (errno == ENXIO || errno == EIO || errno == ENOENT)
|
||||
{
|
||||
fputs("INFO: Printer not connected; will retry in 30 seconds...\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Printer not connected; will retry in 30 "
|
||||
"seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open parallel port device file \"%s\": %s\n",
|
||||
resource, strerror(errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("ERROR: Unable to open device file \"%s\": %s\n"),
|
||||
resource, strerror(errno));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (fd < 0);
|
||||
while (device_fd < 0);
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
|
||||
/*
|
||||
* Set any options provided...
|
||||
*/
|
||||
|
||||
tcgetattr(fd, &opts);
|
||||
tcgetattr(device_fd, &opts);
|
||||
|
||||
opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */
|
||||
|
||||
/**** No options supported yet ****/
|
||||
|
||||
tcsetattr(fd, TCSANOW, &opts);
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
* can finish out any page data the driver sends (e.g. to eject the
|
||||
* current page... Only ignore SIGTERM if we are printing data from
|
||||
* stdin (otherwise you can't cancel raw jobs...)
|
||||
*/
|
||||
|
||||
if (argc < 7)
|
||||
{
|
||||
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
|
||||
sigset(SIGTERM, SIG_IGN);
|
||||
#elif defined(HAVE_SIGACTION)
|
||||
memset(&action, 0, sizeof(action));
|
||||
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
#else
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
#endif /* HAVE_SIGSET */
|
||||
}
|
||||
tcsetattr(device_fd, TCSANOW, &opts);
|
||||
|
||||
/*
|
||||
* Finally, send the print file...
|
||||
*/
|
||||
|
||||
wbytes = 0;
|
||||
tbytes = 0;
|
||||
|
||||
while (copies > 0)
|
||||
while (copies > 0 && tbytes >= 0)
|
||||
{
|
||||
copies --;
|
||||
|
||||
if (fp != 0)
|
||||
if (print_fd != 0)
|
||||
{
|
||||
fputs("PAGE: 1 1\n", stderr);
|
||||
lseek(fp, 0, SEEK_SET);
|
||||
lseek(print_fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
tbytes = 0;
|
||||
while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0)
|
||||
{
|
||||
/*
|
||||
* Write the print data to the printer...
|
||||
*/
|
||||
tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);
|
||||
|
||||
tbytes += nbytes;
|
||||
bufptr = buffer;
|
||||
|
||||
while (nbytes > 0)
|
||||
{
|
||||
if ((wbytes = write(fd, bufptr, nbytes)) < 0)
|
||||
if (errno == ENOTTY)
|
||||
wbytes = write(fd, bufptr, nbytes);
|
||||
|
||||
if (wbytes < 0)
|
||||
{
|
||||
perror("ERROR: Unable to send print file to printer");
|
||||
break;
|
||||
}
|
||||
|
||||
nbytes -= wbytes;
|
||||
bufptr += wbytes;
|
||||
}
|
||||
|
||||
if (wbytes < 0)
|
||||
break;
|
||||
|
||||
if (argc > 6)
|
||||
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
|
||||
(unsigned long)tbytes);
|
||||
}
|
||||
if (print_fd != 0 && tbytes >= 0)
|
||||
_cupsLangPrintf(stderr,
|
||||
#ifdef HAVE_LONG_LONG
|
||||
_("INFO: Sent print file, %lld bytes...\n"),
|
||||
#else
|
||||
_("INFO: Sent print file, %ld bytes...\n"),
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
CUPS_LLCAST tbytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the socket connection and input file and return...
|
||||
*/
|
||||
|
||||
close(fd);
|
||||
if (fp != 0)
|
||||
close(fp);
|
||||
close(device_fd);
|
||||
|
||||
return (wbytes < 0);
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (tbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +310,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* 'list_devices()' - List all parallel devices.
|
||||
*/
|
||||
|
||||
void
|
||||
static void
|
||||
list_devices(void)
|
||||
{
|
||||
#if defined(__hpux) || defined(__sgi) || defined(__sun)
|
||||
@@ -320,120 +322,46 @@ list_devices(void)
|
||||
int i; /* Looping var */
|
||||
int fd; /* File descriptor */
|
||||
char device[255], /* Device filename */
|
||||
probefile[255], /* Probe filename */
|
||||
basedevice[255]; /* Base device filename for ports */
|
||||
FILE *probe; /* /proc/parport/n/autoprobe file */
|
||||
char line[1024], /* Line from file */
|
||||
*delim, /* Delimiter in file */
|
||||
make[IPP_MAX_NAME], /* Make from file */
|
||||
model[IPP_MAX_NAME]; /* Model from file */
|
||||
basedevice[255], /* Base device filename for ports */
|
||||
device_id[1024], /* Device ID string */
|
||||
make_model[1024], /* Make and model */
|
||||
uri[1024]; /* Device URI */
|
||||
|
||||
|
||||
if (!access("/dev/parallel/", 0))
|
||||
strcpy(basedevice, "/dev/parallel/");
|
||||
else if (!access("/dev/printers/", 0))
|
||||
strcpy(basedevice, "/dev/printers/");
|
||||
else
|
||||
strcpy(basedevice, "/dev/lp");
|
||||
|
||||
for (i = 0; i < 4; i ++)
|
||||
{
|
||||
/*
|
||||
* First open the device to make sure the driver module is loaded...
|
||||
* Open the port, if available...
|
||||
*/
|
||||
|
||||
if ((fd = open("/dev/parallel/0", O_WRONLY)) >= 0)
|
||||
sprintf(device, "%s%d", basedevice, i);
|
||||
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
|
||||
fd = open(device, O_WRONLY);
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
/*
|
||||
* Now grab the IEEE 1284 device ID string...
|
||||
*/
|
||||
|
||||
snprintf(uri, sizeof(uri), "parallel:%s", device);
|
||||
|
||||
if (!backendGetDeviceID(fd, device_id, sizeof(device_id),
|
||||
make_model, sizeof(make_model),
|
||||
NULL, uri, sizeof(uri)))
|
||||
printf("direct %s \"%s\" \"%s LPT #%d\" \"%s\"\n", uri,
|
||||
make_model, make_model, i + 1, device_id);
|
||||
else
|
||||
printf("direct %s \"Unknown\" \"LPT #%d\"\n", uri, i + 1);
|
||||
|
||||
close(fd);
|
||||
strcpy(basedevice, "/dev/parallel/");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(device, "/dev/lp%d", i);
|
||||
if ((fd = open(device, O_WRONLY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
strcpy(basedevice, "/dev/lp");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(device, "/dev/par%d", i);
|
||||
if ((fd = open(device, O_WRONLY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
strcpy(basedevice, "/dev/par");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(device, "/dev/printers/%d", i);
|
||||
if ((fd = open(device, O_WRONLY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
strcpy(basedevice, "/dev/printers/");
|
||||
}
|
||||
else
|
||||
strcpy(basedevice, "/dev/unknown-parallel");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Then try looking at the probe file...
|
||||
*/
|
||||
|
||||
sprintf(probefile, "/proc/parport/%d/autoprobe", i);
|
||||
if ((probe = fopen(probefile, "r")) == NULL)
|
||||
{
|
||||
/*
|
||||
* Linux 2.4 kernel has different path...
|
||||
*/
|
||||
|
||||
sprintf(probefile, "/proc/sys/dev/parport/parport%d/autoprobe", i);
|
||||
probe = fopen(probefile, "r");
|
||||
}
|
||||
|
||||
if (probe != NULL)
|
||||
{
|
||||
/*
|
||||
* Found a probe file!
|
||||
*/
|
||||
|
||||
memset(make, 0, sizeof(make));
|
||||
memset(model, 0, sizeof(model));
|
||||
strcpy(model, "Unknown");
|
||||
|
||||
while (fgets(line, sizeof(line), probe) != NULL)
|
||||
{
|
||||
/*
|
||||
* Strip trailing ; and/or newline.
|
||||
*/
|
||||
|
||||
if ((delim = strrchr(line, ';')) != NULL)
|
||||
*delim = '\0';
|
||||
else if ((delim = strrchr(line, '\n')) != NULL)
|
||||
*delim = '\0';
|
||||
|
||||
/*
|
||||
* Look for MODEL and MANUFACTURER lines...
|
||||
*/
|
||||
|
||||
if (strncmp(line, "MODEL:", 6) == 0 &&
|
||||
strncmp(line, "MODEL:Unknown", 13) != 0)
|
||||
strlcpy(model, line + 6, sizeof(model));
|
||||
else if (strncmp(line, "MANUFACTURER:", 13) == 0 &&
|
||||
strncmp(line, "MANUFACTURER:Unknown", 20) != 0)
|
||||
strlcpy(make, line + 13, sizeof(make));
|
||||
}
|
||||
|
||||
fclose(probe);
|
||||
|
||||
if (make[0])
|
||||
printf("direct parallel:%s%d \"%s %s\" \"Parallel Port #%d\"\n",
|
||||
basedevice, i, make, model, i + 1);
|
||||
else
|
||||
printf("direct parallel:%s%d \"%s\" \"Parallel Port #%d\"\n",
|
||||
basedevice, i, model, i + 1);
|
||||
}
|
||||
else if (fd >= 0)
|
||||
{
|
||||
/*
|
||||
* No probe file, but we know the port is there...
|
||||
*/
|
||||
|
||||
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
|
||||
}
|
||||
}
|
||||
#elif defined(__sgi)
|
||||
@@ -633,7 +561,7 @@ list_devices(void)
|
||||
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
|
||||
}
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
int i; /* Looping var */
|
||||
int fd; /* File descriptor */
|
||||
char device[255]; /* Device filename */
|
||||
@@ -674,6 +602,74 @@ list_devices(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'side_cb()' - Handle side-channel requests...
|
||||
*/
|
||||
|
||||
static void
|
||||
side_cb(int print_fd, /* I - Print file */
|
||||
int device_fd, /* I - Device file */
|
||||
int use_bc) /* I - Using back-channel? */
|
||||
{
|
||||
cups_sc_command_t command; /* Request command */
|
||||
cups_sc_status_t status; /* Request/response status */
|
||||
char data[2048]; /* Request/response data */
|
||||
int datalen; /* Request/response data size */
|
||||
|
||||
|
||||
datalen = sizeof(data);
|
||||
|
||||
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
|
||||
{
|
||||
_cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case CUPS_SC_CMD_DRAIN_OUTPUT :
|
||||
if (backendDrainOutput(print_fd, device_fd))
|
||||
status = CUPS_SC_STATUS_IO_ERROR;
|
||||
else if (tcdrain(device_fd))
|
||||
status = CUPS_SC_STATUS_IO_ERROR;
|
||||
else
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
|
||||
datalen = 0;
|
||||
break;
|
||||
|
||||
case CUPS_SC_CMD_GET_BIDI :
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
data[0] = use_bc;
|
||||
datalen = 1;
|
||||
break;
|
||||
|
||||
case CUPS_SC_CMD_GET_DEVICE_ID :
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
if (backendGetDeviceID(device_fd, data, sizeof(data) - 1,
|
||||
NULL, 0, NULL, NULL, 0))
|
||||
{
|
||||
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
|
||||
datalen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
datalen = strlen(data);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
|
||||
datalen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
cupsSideChannelWrite(command, status, data, datalen, 1.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Common run loop APIs for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" which should have been included with this file. If this
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* backendDrainOutput() - Drain pending print data to the device.
|
||||
* backendRunLoop() - Read and write print and back-channel data.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include "backend-private.h"
|
||||
#ifdef __hpux
|
||||
# include <sys/time.h>
|
||||
#else
|
||||
# include <sys/select.h>
|
||||
#endif /* __hpux */
|
||||
|
||||
|
||||
/*
|
||||
* 'backendDrainOutput()' - Drain pending print data to the device.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on error */
|
||||
backendDrainOutput(int print_fd, /* I - Print file descriptor */
|
||||
int device_fd) /* I - Device file descriptor */
|
||||
{
|
||||
int nfds; /* Maximum file descriptor value + 1 */
|
||||
fd_set input; /* Input set for reading */
|
||||
ssize_t print_bytes, /* Print bytes read */
|
||||
bytes; /* Bytes written */
|
||||
char print_buffer[8192], /* Print data buffer */
|
||||
*print_ptr; /* Pointer into print data buffer */
|
||||
struct timeval timeout; /* Timeout for read... */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG: backendDrainOutput(print_fd=%d, device_fd=%d)\n",
|
||||
print_fd, device_fd);
|
||||
|
||||
/*
|
||||
* Figure out the maximum file descriptor value to use with select()...
|
||||
*/
|
||||
|
||||
nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
|
||||
|
||||
/*
|
||||
* Now loop until we are out of data from print_fd...
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/*
|
||||
* Use select() to determine whether we have data to copy around...
|
||||
*/
|
||||
|
||||
FD_ZERO(&input);
|
||||
FD_SET(print_fd, &input);
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (select(nfds, &input, NULL, NULL, &timeout) < 0)
|
||||
return (-1);
|
||||
|
||||
if (!FD_ISSET(print_fd, &input))
|
||||
return (0);
|
||||
|
||||
if ((print_bytes = read(print_fd, print_buffer,
|
||||
sizeof(print_buffer))) < 0)
|
||||
{
|
||||
/*
|
||||
* Read error - bail if we don't see EAGAIN or EINTR...
|
||||
*/
|
||||
|
||||
if (errno != EAGAIN || errno != EINTR)
|
||||
{
|
||||
perror("ERROR: Unable to read print data");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
print_bytes = 0;
|
||||
}
|
||||
else if (print_bytes == 0)
|
||||
{
|
||||
/*
|
||||
* End of file, return...
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG: Read %d bytes of print data...\n",
|
||||
(int)print_bytes);
|
||||
|
||||
for (print_ptr = print_buffer; print_bytes > 0;)
|
||||
{
|
||||
if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
|
||||
{
|
||||
/*
|
||||
* Write error - bail if we don't see an error we can retry...
|
||||
*/
|
||||
|
||||
if (errno != ENOSPC && errno != ENXIO && errno != EAGAIN &&
|
||||
errno != EINTR && errno != ENOTTY)
|
||||
{
|
||||
_cupsLangPrintf(stderr, _("ERROR: Unable to write print data: %s\n"),
|
||||
strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "DEBUG: Wrote %d bytes of print data...\n", (int)bytes);
|
||||
|
||||
print_bytes -= bytes;
|
||||
print_ptr += bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'backendRunLoop()' - Read and write print and back-channel data.
|
||||
*/
|
||||
|
||||
ssize_t /* O - Total bytes on success, -1 on error */
|
||||
backendRunLoop(
|
||||
int print_fd, /* I - Print file descriptor */
|
||||
int device_fd, /* I - Device file descriptor */
|
||||
int use_bc, /* I - Use back-channel? */
|
||||
void (*side_cb)(int, int, int)) /* I - Side-channel callback */
|
||||
{
|
||||
int nfds; /* Maximum file descriptor value + 1 */
|
||||
fd_set input, /* Input set for reading */
|
||||
output; /* Output set for writing */
|
||||
ssize_t print_bytes, /* Print bytes read */
|
||||
bc_bytes, /* Backchannel bytes read */
|
||||
total_bytes, /* Total bytes written */
|
||||
bytes; /* Bytes written */
|
||||
int paperout; /* "Paper out" status */
|
||||
int offline; /* "Off-line" status */
|
||||
char print_buffer[8192], /* Print data buffer */
|
||||
*print_ptr, /* Pointer into print data buffer */
|
||||
bc_buffer[1024]; /* Back-channel data buffer */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
fprintf(stderr,
|
||||
"DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, use_bc=%d, "
|
||||
"side_cb=%p)\n",
|
||||
print_fd, device_fd, use_bc, side_cb);
|
||||
|
||||
/*
|
||||
* If we are printing data from a print driver on stdin, ignore SIGTERM
|
||||
* so that the driver can finish out any page data, e.g. to eject the
|
||||
* current page. We only do this for stdin printing as otherwise there
|
||||
* is no way to cancel a raw print job...
|
||||
*/
|
||||
|
||||
if (!print_fd)
|
||||
{
|
||||
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
|
||||
sigset(SIGTERM, SIG_IGN);
|
||||
#elif defined(HAVE_SIGACTION)
|
||||
memset(&action, 0, sizeof(action));
|
||||
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
#else
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
#endif /* HAVE_SIGSET */
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out the maximum file descriptor value to use with select()...
|
||||
*/
|
||||
|
||||
nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
|
||||
|
||||
/*
|
||||
* Now loop until we are out of data from print_fd...
|
||||
*/
|
||||
|
||||
for (print_bytes = 0, print_ptr = print_buffer, offline = -1,
|
||||
paperout = -1, total_bytes = 0;;)
|
||||
{
|
||||
/*
|
||||
* Use select() to determine whether we have data to copy around...
|
||||
*/
|
||||
|
||||
FD_ZERO(&input);
|
||||
if (!print_bytes)
|
||||
FD_SET(print_fd, &input);
|
||||
if (use_bc)
|
||||
FD_SET(device_fd, &input);
|
||||
if (!print_bytes && side_cb)
|
||||
FD_SET(CUPS_SC_FD, &input);
|
||||
|
||||
FD_ZERO(&output);
|
||||
if (print_bytes || (!use_bc && !side_cb))
|
||||
FD_SET(device_fd, &output);
|
||||
|
||||
if (use_bc || side_cb)
|
||||
{
|
||||
if (select(nfds, &input, &output, NULL, NULL) < 0)
|
||||
{
|
||||
/*
|
||||
* Pause printing to clear any pending errors...
|
||||
*/
|
||||
|
||||
if (errno == ENXIO && offline != 1)
|
||||
{
|
||||
fputs("STATE: +offline-error\n", stderr);
|
||||
_cupsLangPuts(stderr, _("INFO: Printer is currently off-line.\n"));
|
||||
offline = 1;
|
||||
}
|
||||
else if (errno == EINTR && total_bytes == 0)
|
||||
{
|
||||
fputs("DEBUG: Received an interrupt before any bytes were "
|
||||
"written, aborting!\n", stderr);
|
||||
return (0);
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have a side-channel request ready...
|
||||
*/
|
||||
|
||||
if (side_cb && FD_ISSET(CUPS_SC_FD, &input))
|
||||
{
|
||||
/*
|
||||
* Do the side-channel request, then start back over in the select
|
||||
* loop since it may have read from print_fd...
|
||||
*/
|
||||
|
||||
(*side_cb)(print_fd, device_fd, use_bc);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have back-channel data ready...
|
||||
*/
|
||||
|
||||
if (FD_ISSET(device_fd, &input))
|
||||
{
|
||||
if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n",
|
||||
CUPS_LLCAST bc_bytes);
|
||||
cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
|
||||
}
|
||||
else if (bc_bytes < 0 && errno != EAGAIN && errno != EINTR)
|
||||
{
|
||||
fprintf(stderr, "DEBUG: Error reading back-channel data: %s\n",
|
||||
strerror(errno));
|
||||
use_bc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have print data ready...
|
||||
*/
|
||||
|
||||
if (FD_ISSET(print_fd, &input))
|
||||
{
|
||||
if ((print_bytes = read(print_fd, print_buffer,
|
||||
sizeof(print_buffer))) < 0)
|
||||
{
|
||||
/*
|
||||
* Read error - bail if we don't see EAGAIN or EINTR...
|
||||
*/
|
||||
|
||||
if (errno != EAGAIN || errno != EINTR)
|
||||
{
|
||||
perror("ERROR: Unable to read print data");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
print_bytes = 0;
|
||||
}
|
||||
else if (print_bytes == 0)
|
||||
{
|
||||
/*
|
||||
* End of file, break out of the loop...
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
print_ptr = print_buffer;
|
||||
|
||||
fprintf(stderr, "DEBUG: Read %d bytes of print data...\n",
|
||||
(int)print_bytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the device is ready to receive data and we have data to
|
||||
* send...
|
||||
*/
|
||||
|
||||
if (print_bytes && FD_ISSET(device_fd, &output))
|
||||
{
|
||||
if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
|
||||
{
|
||||
/*
|
||||
* Write error - bail if we don't see an error we can retry...
|
||||
*/
|
||||
|
||||
if (errno == ENOSPC)
|
||||
{
|
||||
if (paperout != 1)
|
||||
{
|
||||
fputs("STATE: +media-empty-error\n", stderr);
|
||||
_cupsLangPuts(stderr, _("ERROR: Out of paper!\n"));
|
||||
paperout = 1;
|
||||
}
|
||||
}
|
||||
else if (errno == ENXIO)
|
||||
{
|
||||
if (offline != 1)
|
||||
{
|
||||
fputs("STATE: +offline-error\n", stderr);
|
||||
_cupsLangPuts(stderr, _("INFO: Printer is currently off-line.\n"));
|
||||
offline = 1;
|
||||
}
|
||||
}
|
||||
else if (errno != EAGAIN && errno != EINTR && errno != ENOTTY)
|
||||
{
|
||||
fprintf(stderr, _("ERROR: Unable to write print data: %s\n"),
|
||||
strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paperout)
|
||||
{
|
||||
fputs("STATE: -media-empty-error\n", stderr);
|
||||
paperout = 0;
|
||||
}
|
||||
|
||||
if (offline)
|
||||
{
|
||||
fputs("STATE: -offline-error\n", stderr);
|
||||
_cupsLangPuts(stderr, _("INFO: Printer is now on-line.\n"));
|
||||
offline = 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG: Wrote %d bytes of print data...\n", (int)bytes);
|
||||
|
||||
print_bytes -= bytes;
|
||||
print_ptr += bytes;
|
||||
total_bytes += bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return with success...
|
||||
*/
|
||||
|
||||
return (total_bytes);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+44
-14
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* IRIX SCSI printer support for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2003-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2003-2005 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
@@ -95,34 +96,62 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
if (strncmp(resource, "/dev/scsi/", 10) != 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Bad SCSI device file \"%s\"!\n", resource);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"),
|
||||
resource);
|
||||
return (CUPS_BACKEND_STOP);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the SCSI device file...
|
||||
*/
|
||||
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1)
|
||||
{
|
||||
if (getenv("CLASS") != NULL)
|
||||
{
|
||||
/*
|
||||
* If the CLASS environment variable is set, the job was submitted
|
||||
* to a class and not to a specific queue. In this case, we want
|
||||
* to abort immediately so that the job can be requeued on the next
|
||||
* available printer in the class.
|
||||
*/
|
||||
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Unable to contact printer, queuing on next "
|
||||
"printer in class...\n"));
|
||||
|
||||
/*
|
||||
* Sleep 5 seconds to keep the job from requeuing too rapidly...
|
||||
*/
|
||||
|
||||
sleep(5);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (errno != EAGAIN && errno != EBUSY)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open SCSI device \"%s\" - %s\n",
|
||||
resource, strerror(errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("ERROR: Unable to open device file \"%s\": %s\n"),
|
||||
resource, strerror(errno));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "INFO: SCSI device \"%s\" busy; retrying...\n",
|
||||
resource);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Printer busy; will retry in 30 seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (scsi_fd == -1);
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
* can finish out any page data the driver sends (e.g. to eject the
|
||||
@@ -176,8 +205,9 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
if (ioctl(scsi_fd, DS_ENTER, &scsi_req) < 0 ||
|
||||
scsi_req.ds_status != 0)
|
||||
{
|
||||
fprintf(stderr, "WARNING: SCSI command timed out (%d); retrying...\n",
|
||||
scsi_req.ds_status);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("WARNING: SCSI command timed out (%d); "
|
||||
"retrying...\n"), scsi_req.ds_status);
|
||||
sleep(try + 1);
|
||||
}
|
||||
else
|
||||
@@ -185,10 +215,10 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
if (try >= 10)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to send print data (%d)\n",
|
||||
scsi_req.ds_status);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
|
||||
scsi_req.ds_status);
|
||||
close(scsi_fd);
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +231,7 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
close(fd);
|
||||
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+46
-15
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* Linux SCSI printer support for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2003-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2003-2005 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
@@ -55,6 +56,7 @@
|
||||
*/
|
||||
|
||||
#include <scsi/sg.h>
|
||||
#include <cups/i18n.h>
|
||||
|
||||
|
||||
/*
|
||||
@@ -95,7 +97,7 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
int bytes; /* Number of bytes */
|
||||
int try; /* Current try */
|
||||
sg_io_hdr_t scsi_req; /* SCSI request */
|
||||
char scsi_cmd[6], /* SCSI command data */
|
||||
unsigned char scsi_cmd[6], /* SCSI command data */
|
||||
scsi_sense[32]; /* SCSI sense data */
|
||||
# if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
@@ -108,34 +110,62 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
if (strncmp(resource, "/dev/sg", 7) != 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Bad SCSI device file \"%s\"!\n", resource);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"),
|
||||
resource);
|
||||
return (CUPS_BACKEND_STOP);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the SCSI device file...
|
||||
*/
|
||||
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1)
|
||||
{
|
||||
if (getenv("CLASS") != NULL)
|
||||
{
|
||||
/*
|
||||
* If the CLASS environment variable is set, the job was submitted
|
||||
* to a class and not to a specific queue. In this case, we want
|
||||
* to abort immediately so that the job can be requeued on the next
|
||||
* available printer in the class.
|
||||
*/
|
||||
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Unable to contact printer, queuing on next "
|
||||
"printer in class...\n"));
|
||||
|
||||
/*
|
||||
* Sleep 5 seconds to keep the job from requeuing too rapidly...
|
||||
*/
|
||||
|
||||
sleep(5);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
if (errno != EAGAIN && errno != EBUSY)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open SCSI device \"%s\" - %s\n",
|
||||
resource, strerror(errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("ERROR: Unable to open device file \"%s\": %s\n"),
|
||||
resource, strerror(errno));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "INFO: SCSI device \"%s\" busy; retrying...\n",
|
||||
resource);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Printer busy; will retry in 30 seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (scsi_fd == -1);
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
* can finish out any page data the driver sends (e.g. to eject the
|
||||
@@ -193,8 +223,9 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
if (ioctl(scsi_fd, SG_IO, &scsi_req) < 0 ||
|
||||
scsi_req.status != 0)
|
||||
{
|
||||
fprintf(stderr, "WARNING: SCSI command timed out (%d); retrying...\n",
|
||||
scsi_req.status);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("WARNING: SCSI command timed out (%d); "
|
||||
"retrying...\n"), scsi_req.status);
|
||||
sleep(try + 1);
|
||||
}
|
||||
else
|
||||
@@ -202,10 +233,10 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
if (try >= 10)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to send print data (%d)\n",
|
||||
scsi_req.status);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
|
||||
scsi_req.status);
|
||||
close(scsi_fd);
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +249,7 @@ print_device(const char *resource, /* I - SCSI device */
|
||||
|
||||
close(fd);
|
||||
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
#endif /* !SG_DXFER_TO_DEV */
|
||||
|
||||
|
||||
+18
-9
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* SCSI printer backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2003-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2003-2006 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the
|
||||
@@ -53,11 +54,14 @@
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/backend.h>
|
||||
#include <cups/cups.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cups/string.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -79,7 +83,7 @@ void list_devices(void);
|
||||
int print_device(const char *resource, int fd, int copies);
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) && defined(HAVE_SCSI_SG_H)
|
||||
# include "scsi-linux.c"
|
||||
#elif defined(__sgi)
|
||||
# include "scsi-irix.c"
|
||||
@@ -88,8 +92,8 @@ int print_device(const char *resource, int fd, int copies);
|
||||
* Dummy functions that do nothing on unsupported platforms...
|
||||
*/
|
||||
void list_devices(void) {}
|
||||
int print_device(const char *resource, int fd, int copies) { return (1); }
|
||||
#endif /* __linux */
|
||||
int print_device(const char *resource, int fd, int copies) { return (CUPS_BACKEND_FAILED); }
|
||||
#endif /* __linux && HAVE_SCSI_SG_H */
|
||||
|
||||
|
||||
/*
|
||||
@@ -145,12 +149,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if (argc == 1)
|
||||
{
|
||||
list_devices();
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fputs("Usage: scsi:/dev/file job-id user title copies options [file]\n", stderr);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("Usage: %s job-id user title copies options [file]\n"),
|
||||
argv[0]);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -172,7 +178,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
perror("ERROR: unable to open print file");
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
@@ -182,7 +188,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Extract the device name and options from the URI...
|
||||
*/
|
||||
|
||||
httpSeparate(argv[0], method, username, hostname, &port, resource);
|
||||
httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
|
||||
method, sizeof(method), username, sizeof(username),
|
||||
hostname, sizeof(hostname), &port,
|
||||
resource, sizeof(resource));
|
||||
|
||||
/*
|
||||
* See if there are any options...
|
||||
|
||||
+475
-171
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* Serial port backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* 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
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" 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-3142 USA
|
||||
*
|
||||
* Voice: (301) 373-9600
|
||||
* EMail: cups-info@cups.org
|
||||
* WWW: http://www.cups.org
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
@@ -27,18 +18,14 @@
|
||||
*
|
||||
* main() - Send a file to the printer or server.
|
||||
* list_devices() - List all serial devices.
|
||||
* side_cb() - Handle side-channel requests...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/cups.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cups/string.h>
|
||||
#include <signal.h>
|
||||
#include "backend-private.h"
|
||||
|
||||
#ifdef __hpux
|
||||
# include <sys/modem.h>
|
||||
@@ -50,6 +37,11 @@
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
# include <termios.h>
|
||||
# ifdef __hpux
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <sys/select.h>
|
||||
# endif /* __hpux */
|
||||
# ifdef HAVE_SYS_IOCTL_H
|
||||
# include <sys/ioctl.h>
|
||||
# endif /* HAVE_SYS_IOCTL_H */
|
||||
@@ -81,12 +73,18 @@
|
||||
# include <IOKit/IOBSD.h>
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#if defined(__linux) && defined(TIOCGSERIAL)
|
||||
# include <linux/serial.h>
|
||||
# include <linux/ioctl.h>
|
||||
#endif /* __linux && TIOCGSERIAL */
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void list_devices(void);
|
||||
static void list_devices(void);
|
||||
static void side_cb(int print_fd, int device_fd, int use_bc);
|
||||
|
||||
|
||||
/*
|
||||
@@ -97,33 +95,38 @@ void list_devices(void);
|
||||
* printer-uri job-id user title copies options [file]
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024], /* Resource info (device and options) */
|
||||
*options, /* Pointer to options */
|
||||
name[255], /* Name of option */
|
||||
value[255], /* Value of option */
|
||||
*ptr; /* Pointer into name or value */
|
||||
int port; /* Port number (not used) */
|
||||
int fp; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
int fd; /* Parallel device */
|
||||
int wbytes; /* Number of bytes written */
|
||||
size_t nbytes, /* Number of bytes read */
|
||||
tbytes; /* Total number of bytes written */
|
||||
int dtrdsr; /* Do dtr/dsr flow control? */
|
||||
int bufsize; /* Size of output buffer for writes */
|
||||
char buffer[8192], /* Output buffer */
|
||||
*bufptr; /* Pointer into buffer */
|
||||
struct termios opts; /* Serial port options */
|
||||
struct termios origopts; /* Original port options */
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024], /* Resource info (device and options) */
|
||||
*options, /* Pointer to options */
|
||||
*name, /* Name of option */
|
||||
*value, /* Value of option */
|
||||
sep; /* Option separator */
|
||||
int port; /* Port number (not used) */
|
||||
int copies; /* Number of copies to print */
|
||||
int print_fd, /* Print file */
|
||||
device_fd; /* Serial device */
|
||||
int nfds; /* Maximum file descriptor value + 1 */
|
||||
fd_set input, /* Input set for reading */
|
||||
output; /* Output set for writing */
|
||||
ssize_t print_bytes, /* Print bytes read */
|
||||
bc_bytes, /* Backchannel bytes read */
|
||||
total_bytes, /* Total bytes written */
|
||||
bytes; /* Bytes written */
|
||||
int dtrdsr; /* Do dtr/dsr flow control? */
|
||||
int print_size; /* Size of output buffer for writes */
|
||||
char print_buffer[8192], /* Print data buffer */
|
||||
*print_ptr, /* Pointer into print data buffer */
|
||||
bc_buffer[1024]; /* Back-channel data buffer */
|
||||
struct termios opts; /* Serial port options */
|
||||
struct termios origopts; /* Original port options */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
@@ -154,12 +157,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if (argc == 1)
|
||||
{
|
||||
list_devices();
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fputs("Usage: serial job-id user title copies options [file]\n", stderr);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("Usage: %s job-id user title copies options [file]\n"),
|
||||
argv[0]);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -169,8 +174,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
|
||||
if (argc == 6)
|
||||
{
|
||||
fp = 0;
|
||||
copies = 1;
|
||||
print_fd = 0;
|
||||
copies = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,10 +183,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Try to open the print file...
|
||||
*/
|
||||
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
perror("ERROR: unable to open print file");
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
@@ -191,7 +196,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Extract the device name and options from the URI...
|
||||
*/
|
||||
|
||||
httpSeparate(argv[0], method, username, hostname, &port, resource);
|
||||
httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
|
||||
method, sizeof(method), username, sizeof(username),
|
||||
hostname, sizeof(hostname), &port,
|
||||
resource, sizeof(resource));
|
||||
|
||||
/*
|
||||
* See if there are any options...
|
||||
@@ -211,80 +219,112 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Open the serial port device...
|
||||
*/
|
||||
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
if ((fd = open(resource, O_WRONLY | O_NOCTTY | O_EXCL | O_NDELAY)) == -1)
|
||||
if ((device_fd = open(resource, O_RDWR | O_NOCTTY | O_EXCL |
|
||||
O_NDELAY)) == -1)
|
||||
{
|
||||
if (getenv("CLASS") != NULL)
|
||||
{
|
||||
/*
|
||||
* If the CLASS environment variable is set, the job was submitted
|
||||
* to a class and not to a specific queue. In this case, we want
|
||||
* to abort immediately so that the job can be requeued on the next
|
||||
* available printer in the class.
|
||||
*/
|
||||
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Unable to contact printer, queuing on next "
|
||||
"printer in class...\n"));
|
||||
|
||||
/*
|
||||
* Sleep 5 seconds to keep the job from requeuing too rapidly...
|
||||
*/
|
||||
|
||||
sleep(5);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
if (errno == EBUSY)
|
||||
{
|
||||
fputs("INFO: Serial port busy; will retry in 30 seconds...\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Printer busy; will retry in 30 seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open serial port device file \"%s\": %s\n",
|
||||
resource, strerror(errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("ERROR: Unable to open device file \"%s\": %s\n"),
|
||||
resource, strerror(errno));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (fd < 0);
|
||||
while (device_fd < 0);
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
|
||||
/*
|
||||
* Set any options provided...
|
||||
*/
|
||||
|
||||
tcgetattr(fd, &origopts);
|
||||
tcgetattr(fd, &opts);
|
||||
tcgetattr(device_fd, &origopts);
|
||||
tcgetattr(device_fd, &opts);
|
||||
|
||||
opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */
|
||||
opts.c_oflag &= ~OPOST; /* Don't post-process */
|
||||
opts.c_lflag &= ~(ICANON | ECHO | ISIG);
|
||||
/* Raw mode */
|
||||
opts.c_oflag &= ~OPOST; /* Don't post-process */
|
||||
|
||||
bufsize = 96; /* 9600 baud / 10 bits/char / 10Hz */
|
||||
dtrdsr = 0; /* No dtr/dsr flow control */
|
||||
print_size = 96; /* 9600 baud / 10 bits/char / 10Hz */
|
||||
dtrdsr = 0; /* No dtr/dsr flow control */
|
||||
|
||||
if (options != NULL)
|
||||
if (options)
|
||||
{
|
||||
while (*options)
|
||||
{
|
||||
/*
|
||||
* Get the name...
|
||||
*/
|
||||
|
||||
for (ptr = name; *options && *options != '=';)
|
||||
if (ptr < (name + sizeof(name) - 1))
|
||||
*ptr++ = *options++;
|
||||
*ptr = '\0';
|
||||
name = options;
|
||||
|
||||
if (*options == '=')
|
||||
while (*options && *options != '=' && *options != '+' && *options != '&')
|
||||
options ++;
|
||||
|
||||
if ((sep = *options) != '\0')
|
||||
*options++ = '\0';
|
||||
|
||||
if (sep == '=')
|
||||
{
|
||||
/*
|
||||
* Get the value...
|
||||
*/
|
||||
|
||||
options ++;
|
||||
value = options;
|
||||
|
||||
for (ptr = value; *options && *options != '+';)
|
||||
if (ptr < (value + sizeof(value) - 1))
|
||||
*ptr++ = *options++;
|
||||
*ptr = '\0';
|
||||
|
||||
if (*options == '+')
|
||||
while (*options && *options != '+' && *options != '&')
|
||||
options ++;
|
||||
|
||||
if (*options)
|
||||
*options++ = '\0';
|
||||
}
|
||||
else
|
||||
value[0] = '\0';
|
||||
value = (char *)"";
|
||||
|
||||
/*
|
||||
* Process the option...
|
||||
*/
|
||||
|
||||
if (strcasecmp(name, "baud") == 0)
|
||||
if (!strcasecmp(name, "baud"))
|
||||
{
|
||||
/*
|
||||
* Set the baud rate...
|
||||
*/
|
||||
|
||||
bufsize = atoi(value) / 100;
|
||||
print_size = atoi(value) / 100;
|
||||
|
||||
#if B19200 == 19200
|
||||
cfsetispeed(&opts, atoi(value));
|
||||
@@ -335,12 +375,13 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
break;
|
||||
# endif /* B230400 */
|
||||
default :
|
||||
fprintf(stderr, "WARNING: Unsupported baud rate %s!\n", value);
|
||||
_cupsLangPrintf(stderr, _("WARNING: Unsupported baud rate %s!\n"),
|
||||
value);
|
||||
break;
|
||||
}
|
||||
#endif /* B19200 == 19200 */
|
||||
}
|
||||
else if (strcasecmp(name, "bits") == 0)
|
||||
else if (!strcasecmp(name, "bits"))
|
||||
{
|
||||
/*
|
||||
* Set number of data bits...
|
||||
@@ -361,48 +402,70 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(name, "parity") == 0)
|
||||
else if (!strcasecmp(name, "parity"))
|
||||
{
|
||||
/*
|
||||
* Set parity checking...
|
||||
*/
|
||||
|
||||
if (strcasecmp(value, "even") == 0)
|
||||
if (!strcasecmp(value, "even"))
|
||||
{
|
||||
opts.c_cflag |= PARENB;
|
||||
opts.c_cflag &= ~PARODD;
|
||||
}
|
||||
else if (strcasecmp(value, "odd") == 0)
|
||||
else if (!strcasecmp(value, "odd"))
|
||||
{
|
||||
opts.c_cflag |= PARENB;
|
||||
opts.c_cflag |= PARODD;
|
||||
}
|
||||
else if (strcasecmp(value, "none") == 0)
|
||||
else if (!strcasecmp(value, "none"))
|
||||
opts.c_cflag &= ~PARENB;
|
||||
else if (!strcasecmp(value, "space"))
|
||||
{
|
||||
/*
|
||||
* Note: we only support space parity with 7 bits per character...
|
||||
*/
|
||||
|
||||
opts.c_cflag &= ~CSIZE;
|
||||
opts.c_cflag |= CS8;
|
||||
opts.c_cflag &= ~PARENB;
|
||||
}
|
||||
else if (!strcasecmp(value, "mark"))
|
||||
{
|
||||
/*
|
||||
* Note: we only support mark parity with 7 bits per character
|
||||
* and 1 stop bit...
|
||||
*/
|
||||
|
||||
opts.c_cflag &= ~CSIZE;
|
||||
opts.c_cflag |= CS7;
|
||||
opts.c_cflag &= ~PARENB;
|
||||
opts.c_cflag |= CSTOPB;
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(name, "flow") == 0)
|
||||
else if (!strcasecmp(name, "flow"))
|
||||
{
|
||||
/*
|
||||
* Set flow control...
|
||||
*/
|
||||
|
||||
if (strcasecmp(value, "none") == 0)
|
||||
if (!strcasecmp(value, "none"))
|
||||
{
|
||||
opts.c_iflag &= ~(IXON | IXOFF);
|
||||
opts.c_cflag &= ~CRTSCTS;
|
||||
}
|
||||
else if (strcasecmp(value, "soft") == 0)
|
||||
else if (!strcasecmp(value, "soft"))
|
||||
{
|
||||
opts.c_iflag |= IXON | IXOFF;
|
||||
opts.c_cflag &= ~CRTSCTS;
|
||||
}
|
||||
else if (strcasecmp(value, "hard") == 0 ||
|
||||
strcasecmp(value, "rtscts") == 0)
|
||||
else if (!strcasecmp(value, "hard") ||
|
||||
!strcasecmp(value, "rtscts"))
|
||||
{
|
||||
opts.c_iflag &= ~(IXON | IXOFF);
|
||||
opts.c_cflag |= CRTSCTS;
|
||||
}
|
||||
else if (strcasecmp(value, "dtrdsr") == 0)
|
||||
else if (!strcasecmp(value, "dtrdsr"))
|
||||
{
|
||||
opts.c_iflag &= ~(IXON | IXOFF);
|
||||
opts.c_cflag &= ~CRTSCTS;
|
||||
@@ -410,10 +473,24 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
dtrdsr = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(name, "stop"))
|
||||
{
|
||||
switch (atoi(value))
|
||||
{
|
||||
case 1 :
|
||||
opts.c_cflag &= ~CSTOPB;
|
||||
break;
|
||||
|
||||
tcsetattr(fd, TCSANOW, &opts);
|
||||
fcntl(fd, F_SETFL, 0);
|
||||
case 2 :
|
||||
opts.c_cflag |= CSTOPB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tcsetattr(device_fd, TCSANOW, &opts);
|
||||
fcntl(device_fd, F_SETFL, 0);
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
@@ -422,7 +499,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* stdin (otherwise you can't cancel raw jobs...)
|
||||
*/
|
||||
|
||||
if (argc < 7)
|
||||
if (print_fd != 0)
|
||||
{
|
||||
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
|
||||
sigset(SIGTERM, SIG_IGN);
|
||||
@@ -438,86 +515,198 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, send the print file...
|
||||
* Figure out the maximum file descriptor value to use with select()...
|
||||
*/
|
||||
|
||||
if (bufsize > sizeof(buffer))
|
||||
bufsize = sizeof(buffer);
|
||||
nfds = (print_fd > device_fd ? print_fd : device_fd) + 1;
|
||||
|
||||
wbytes = 0;
|
||||
/*
|
||||
* Finally, send the print file. Ordinarily we would just use the
|
||||
* backendRunLoop() function, however since we need to use smaller
|
||||
* writes and may need to do DSR/DTR flow control, we duplicate much
|
||||
* of the code here instead...
|
||||
*/
|
||||
|
||||
if (print_size > sizeof(print_buffer))
|
||||
print_size = sizeof(print_buffer);
|
||||
|
||||
total_bytes = 0;
|
||||
|
||||
while (copies > 0)
|
||||
{
|
||||
copies --;
|
||||
|
||||
if (fp != 0)
|
||||
if (print_fd != 0)
|
||||
{
|
||||
fputs("PAGE: 1 1\n", stderr);
|
||||
lseek(fp, 0, SEEK_SET);
|
||||
lseek(print_fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
if (dtrdsr)
|
||||
/*
|
||||
* Now loop until we are out of data from print_fd...
|
||||
*/
|
||||
|
||||
for (print_bytes = 0, print_ptr = print_buffer;;)
|
||||
{
|
||||
/*
|
||||
* Check the port and sleep until DSR is set...
|
||||
* Use select() to determine whether we have data to copy around...
|
||||
*/
|
||||
|
||||
int status;
|
||||
FD_ZERO(&input);
|
||||
if (!print_bytes)
|
||||
FD_SET(print_fd, &input);
|
||||
FD_SET(device_fd, &input);
|
||||
if (!print_bytes)
|
||||
FD_SET(CUPS_SC_FD, &input);
|
||||
|
||||
FD_ZERO(&output);
|
||||
if (print_bytes)
|
||||
FD_SET(device_fd, &output);
|
||||
|
||||
if (!ioctl(fd, TIOCMGET, &status))
|
||||
if (!(status & TIOCM_DSR))
|
||||
{
|
||||
/*
|
||||
* Wait for DSR to go high...
|
||||
*/
|
||||
if (select(nfds, &input, &output, NULL, NULL) < 0)
|
||||
continue; /* Ignore errors here */
|
||||
|
||||
fputs("DEBUG: DSR is low; waiting for device...\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
sleep(1);
|
||||
if (ioctl(fd, TIOCMGET, &status))
|
||||
break;
|
||||
}
|
||||
while (!(status & TIOCM_DSR));
|
||||
|
||||
fputs("DEBUG: DSR is high; writing to device...\n", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
tbytes = 0;
|
||||
while ((nbytes = read(fp, buffer, bufsize)) > 0)
|
||||
{
|
||||
/*
|
||||
* Write the print data to the printer...
|
||||
* Check if we have a side-channel request ready...
|
||||
*/
|
||||
|
||||
tbytes += nbytes;
|
||||
bufptr = buffer;
|
||||
|
||||
while (nbytes > 0)
|
||||
if (FD_ISSET(CUPS_SC_FD, &input))
|
||||
{
|
||||
if ((wbytes = write(fd, bufptr, nbytes)) < 0)
|
||||
if (errno == ENOTTY)
|
||||
wbytes = write(fd, bufptr, nbytes);
|
||||
/*
|
||||
* Do the side-channel request, then start back over in the select
|
||||
* loop since it may have read from print_fd...
|
||||
*/
|
||||
|
||||
if (wbytes < 0)
|
||||
{
|
||||
perror("ERROR: Unable to send print file to printer");
|
||||
break;
|
||||
}
|
||||
|
||||
nbytes -= wbytes;
|
||||
bufptr += wbytes;
|
||||
side_cb(print_fd, device_fd, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wbytes < 0)
|
||||
break;
|
||||
/*
|
||||
* Check if we have back-channel data ready...
|
||||
*/
|
||||
|
||||
if (argc > 6)
|
||||
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
|
||||
(unsigned long)tbytes);
|
||||
if (FD_ISSET(device_fd, &input))
|
||||
{
|
||||
if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n",
|
||||
CUPS_LLCAST bc_bytes);
|
||||
cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have print data ready...
|
||||
*/
|
||||
|
||||
if (FD_ISSET(print_fd, &input))
|
||||
{
|
||||
if ((print_bytes = read(print_fd, print_buffer, print_size)) < 0)
|
||||
{
|
||||
/*
|
||||
* Read error - bail if we don't see EAGAIN or EINTR...
|
||||
*/
|
||||
|
||||
if (errno != EAGAIN || errno != EINTR)
|
||||
{
|
||||
perror("ERROR: Unable to read print data");
|
||||
|
||||
tcsetattr(device_fd, TCSADRAIN, &origopts);
|
||||
|
||||
close(device_fd);
|
||||
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
print_bytes = 0;
|
||||
}
|
||||
else if (print_bytes == 0)
|
||||
{
|
||||
/*
|
||||
* End of file, break out of the loop...
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
print_ptr = print_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the device is ready to receive data and we have data to
|
||||
* send...
|
||||
*/
|
||||
|
||||
if (print_bytes && FD_ISSET(device_fd, &output))
|
||||
{
|
||||
if (dtrdsr)
|
||||
{
|
||||
/*
|
||||
* Check the port and sleep until DSR is set...
|
||||
*/
|
||||
|
||||
int status;
|
||||
|
||||
|
||||
if (!ioctl(device_fd, TIOCMGET, &status))
|
||||
if (!(status & TIOCM_DSR))
|
||||
{
|
||||
/*
|
||||
* Wait for DSR to go high...
|
||||
*/
|
||||
|
||||
fputs("DEBUG: DSR is low; waiting for device...\n", stderr);
|
||||
|
||||
do
|
||||
{
|
||||
/*
|
||||
* Poll every 100ms...
|
||||
*/
|
||||
|
||||
usleep(100000);
|
||||
|
||||
if (ioctl(device_fd, TIOCMGET, &status))
|
||||
break;
|
||||
}
|
||||
while (!(status & TIOCM_DSR));
|
||||
|
||||
fputs("DEBUG: DSR is high; writing to device...\n", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
|
||||
{
|
||||
/*
|
||||
* Write error - bail if we don't see an error we can retry...
|
||||
*/
|
||||
|
||||
if (errno != EAGAIN && errno != EINTR && errno != ENOTTY)
|
||||
{
|
||||
perror("ERROR: Unable to write print data");
|
||||
|
||||
tcsetattr(device_fd, TCSADRAIN, &origopts);
|
||||
|
||||
close(device_fd);
|
||||
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "DEBUG: Wrote %d bytes...\n", (int)bytes);
|
||||
|
||||
print_bytes -= bytes;
|
||||
print_ptr += bytes;
|
||||
total_bytes += bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,13 +714,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Close the serial port and input file and return...
|
||||
*/
|
||||
|
||||
tcsetattr(fd, TCSADRAIN, &origopts);
|
||||
tcsetattr(device_fd, TCSADRAIN, &origopts);
|
||||
|
||||
close(fd);
|
||||
if (fp != 0)
|
||||
close(fp);
|
||||
close(device_fd);
|
||||
|
||||
return (wbytes < 0);
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (total_bytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -539,26 +729,53 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* 'list_devices()' - List all serial devices.
|
||||
*/
|
||||
|
||||
void
|
||||
static void
|
||||
list_devices(void)
|
||||
{
|
||||
#if defined(__hpux) || defined(__sgi) || defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__hpux) || defined(__sgi) || defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
static char *funky_hex = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
/* Funky hex numbering used for some devices */
|
||||
/* Funky hex numbering used for some *
|
||||
* devices */
|
||||
#endif /* __hpux || __sgi || __sun || __FreeBSD__ || __OpenBSD__ */
|
||||
|
||||
#if defined(__linux) || defined(linux) || defined(__linux__)
|
||||
int i; /* Looping var */
|
||||
int fd; /* File descriptor */
|
||||
char device[255]; /* Device filename */
|
||||
#ifdef __linux
|
||||
int i, j; /* Looping vars */
|
||||
int fd; /* File descriptor */
|
||||
char device[255]; /* Device filename */
|
||||
# ifdef TIOCGSERIAL
|
||||
struct serial_struct serinfo; /* serial port info */
|
||||
# endif /* TIOCGSERIAL */
|
||||
|
||||
|
||||
for (i = 0; i < 100; i ++)
|
||||
{
|
||||
sprintf(device, "/dev/ttyS%d", i);
|
||||
|
||||
if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
|
||||
{
|
||||
# ifdef TIOCGSERIAL
|
||||
/*
|
||||
* See if this port exists...
|
||||
*/
|
||||
|
||||
serinfo.reserved_char[0] = 0;
|
||||
|
||||
if (!ioctl(fd, TIOCGSERIAL, &serinfo))
|
||||
{
|
||||
if (serinfo.type == PORT_UNKNOWN)
|
||||
{
|
||||
/*
|
||||
* Nope...
|
||||
*/
|
||||
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
# endif /* TIOCGSERIAL */
|
||||
|
||||
close(fd);
|
||||
|
||||
# if defined(_ARCH_PPC) || defined(powerpc) || defined(__powerpc)
|
||||
printf("serial serial:%s?baud=230400 \"Unknown\" \"Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
@@ -578,6 +795,29 @@ list_devices(void)
|
||||
printf("serial serial:%s?baud=230400 \"Unknown\" \"USB Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
}
|
||||
|
||||
sprintf(device, "/dev/ttyUSB%d", i);
|
||||
if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
printf("serial serial:%s?baud=230400 \"Unknown\" \"USB Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 64; i ++)
|
||||
{
|
||||
for (j = 0; j < 8; j ++)
|
||||
{
|
||||
sprintf(device, "/dev/ttyQ%02de%d", i, j);
|
||||
if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" "
|
||||
"\"Equinox ESP %d Port #%d\"\n",
|
||||
device, i, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(__sgi)
|
||||
int i, j, n; /* Looping vars */
|
||||
@@ -690,13 +930,13 @@ list_devices(void)
|
||||
{
|
||||
sprintf(device, "/dev/cua/%c", 'a' + i);
|
||||
if (access(device, 0) == 0)
|
||||
#ifdef B115200
|
||||
# ifdef B115200
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" \"Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
#else
|
||||
# else
|
||||
printf("serial serial:%s?baud=38400 \"Unknown\" \"Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
#endif /* B115200 */
|
||||
# endif /* B115200 */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -792,7 +1032,7 @@ list_devices(void)
|
||||
printf("serial serial:%s?baud=38400 \"Unknown\" \"Serial Port #%d\"\n",
|
||||
device, i + 1);
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
int i, j; /* Looping vars */
|
||||
int fd; /* File descriptor */
|
||||
char device[255]; /* Device filename */
|
||||
@@ -827,6 +1067,14 @@ list_devices(void)
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" \"Cyclades #%d Serial Port #%d\"\n",
|
||||
device, i, j + 1);
|
||||
}
|
||||
|
||||
sprintf(device, "/dev/ttyC%d%c", i, funky_hex[j]);
|
||||
if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" \"Cyclades #%d Serial Port #%d\"\n",
|
||||
device, i, j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -921,7 +1169,6 @@ list_devices(void)
|
||||
CFMutableDictionaryRef classesToMatch;
|
||||
io_object_t serialService;
|
||||
|
||||
printf("serial serial \"Unknown\" \"Serial Printer (serial)\"\n");
|
||||
|
||||
kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
|
||||
if (KERN_SUCCESS != kernResult)
|
||||
@@ -975,8 +1222,8 @@ list_devices(void)
|
||||
CFRelease(bsdPathAsCFString);
|
||||
|
||||
if (result)
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" \"%s\"\n", bsdPath,
|
||||
serialName);
|
||||
printf("serial serial:%s?baud=115200 \"Unknown\" \"%s\"\n",
|
||||
bsdPath, serialName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,13 +1231,70 @@ list_devices(void)
|
||||
IOObjectRelease(serialService);
|
||||
}
|
||||
|
||||
IOObjectRelease(serialPortIterator); /* Release the iterator. */
|
||||
/*
|
||||
* Release the iterator.
|
||||
*/
|
||||
|
||||
IOObjectRelease(serialPortIterator);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'side_cb()' - Handle side-channel requests...
|
||||
*/
|
||||
|
||||
static void
|
||||
side_cb(int print_fd, /* I - Print file */
|
||||
int device_fd, /* I - Device file */
|
||||
int use_bc) /* I - Using back-channel? */
|
||||
{
|
||||
cups_sc_command_t command; /* Request command */
|
||||
cups_sc_status_t status; /* Request/response status */
|
||||
char data[2048]; /* Request/response data */
|
||||
int datalen; /* Request/response data size */
|
||||
|
||||
|
||||
datalen = sizeof(data);
|
||||
|
||||
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
|
||||
{
|
||||
_cupsLangPuts(stderr,
|
||||
_("WARNING: Failed to read side-channel request!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case CUPS_SC_CMD_DRAIN_OUTPUT :
|
||||
if (backendDrainOutput(print_fd, device_fd))
|
||||
status = CUPS_SC_STATUS_IO_ERROR;
|
||||
else if (tcdrain(device_fd))
|
||||
status = CUPS_SC_STATUS_IO_ERROR;
|
||||
else
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
|
||||
datalen = 0;
|
||||
break;
|
||||
|
||||
case CUPS_SC_CMD_GET_BIDI :
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
data[0] = use_bc;
|
||||
datalen = 1;
|
||||
break;
|
||||
|
||||
default :
|
||||
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
|
||||
datalen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
cupsSideChannelWrite(command, status, data, datalen, 1.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
+2276
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,172 @@
|
||||
snmp.txt - 2006-04-19
|
||||
---------------------
|
||||
|
||||
This file lists the "interesting" bits from the command:
|
||||
|
||||
snmpwalk -v 1 -c public HOST .1
|
||||
|
||||
for many network print servers and internal cards. It is mainly here
|
||||
for SNMP documentation and development purposes.
|
||||
|
||||
|
||||
AXIS 5600
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: HP ETHERNET MULTI-ENVIRONMENT,ROM J.sp.00,JETDIRECT EX,JD28,EEPROM 6.16.5
|
||||
SNMPv2-MIB::sysName.0 = STRING:
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceType.2 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceType.3 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: Hewlett-Packard hp LaserJet 3380
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.2 = STRING: Axis AXIS 5600
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.3 = STRING: Axis AXIS 5600
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.2 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.3 = OID: SNMPv2-SMI::zeroDotZero
|
||||
SNMPv2-SMI::enterprises.11.2.4.3.10.8.0 = STRING: "AXIS433AE8"
|
||||
SNMPv2-SMI::enterprises.368.2.3.2.601.0 = INTEGER: 9100
|
||||
SNMPv2-SMI::enterprises.368.2.3.2.602.0 = INTEGER: 9101
|
||||
SNMPv2-SMI::enterprises.368.2.3.2.603.0 = INTEGER: 9102
|
||||
SNMPv2-SMI::enterprises.368.2.3.10.901.0 = STRING: "AXIS433AE8"
|
||||
|
||||
|
||||
AXIS OfficeBasic
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: AXIS OfficeBasic Parallel Network Print Server V6.43 Sep 4 2003
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: EPSON Stylus Photo 870
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::zeroDotZero
|
||||
|
||||
|
||||
DLink DP-301P+
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: D-Link DP-301P+ Print Server
|
||||
|
||||
|
||||
Genicom ML280
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: GENICOM microLaser 280
|
||||
SNMPv2-MIB::sysName.0 = STRING: PRQ_004F75
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: MANUFACTURER:GENICOM;MODEL:microLaser 280;
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.3369.1.1.2.4
|
||||
|
||||
|
||||
EPSON Type-B Network Card
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: EPSON Type-B 10Base-T/100Base-TX Print Server
|
||||
SNMPv2-MIB::sysName.0 = STRING: StylusPro7600-BB87A8
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: EPSON Stylus Pro 7600
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.1248.1.2.1.22.69.109.117.108.97.116.101.83.116.121.108.117.115.32.80.114.111.32.55.54.48.48
|
||||
SNMPv2-SMI::enterprises.11.2.3.9.1.1.7.0 = STRING: "MFG:EPSON;CMD:ESCPL2,BDC;MDL:Stylus Pro 7600;CLS:PRINTER;DES:EPSON Stylus Pro 7600;"
|
||||
SNMPv2-SMI::enterprises.1248.1.2.2.1.1.1.1.1 = STRING: "MFG:EPSON;CMD:ESCPL2,BDC;MDL:Stylus Pro 7600;CLS:PRINTER;DES:EPSON Stylus Pro 7600;"
|
||||
|
||||
|
||||
EPSON Wireless 802.11b Print Server
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: EPSON Wireless LAN Print Interface compatible with an HP JETDIRECT EX
|
||||
SNMPv2-MIB::sysName.0 = STRING: EAI_0F550B
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING:
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::zeroDotZero
|
||||
|
||||
|
||||
HP JetDirect EX3plus
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: HP ETHERNET MULTI-ENVIRONMENT,ROM D.04.03,JETDIRECT EX,JD26,EEPROM D.05.22
|
||||
SNMPv2-MIB::sysName.0 = STRING: NPID1EC0F
|
||||
|
||||
|
||||
HP LJ4000
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: HP ETHERNET MULTI-ENVIRONMENT,ROM G.05.34,JETDIRECT,JD30,EEPROM G.08.32
|
||||
SNMPv2-MIB::sysName.0 = STRING:
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: HP LaserJet 4000 Series
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.11.2.3.9.1.2.5
|
||||
|
||||
|
||||
HP CLJ4550
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIRECT,JD84,EEPROM L.21.22,CIDATE 07/06/2001
|
||||
SNMPv2-MIB::sysName.0 = STRING: NPI02FDE7
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: HP Color LaserJet 4550
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.2 = STRING: Hewlett-Packard Dynamic RAM Disk
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.11.2.3.9.1.2.14
|
||||
|
||||
|
||||
Lexmark C522
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: Lexmark C522 version NS.NP.N212 kernel 2.6.6 All-N-1
|
||||
SNMPv2-MIB::sysName.0 = STRING: ET0004000D0CCA
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceType.2 = OID: HOST-RESOURCES-TYPES::hrDeviceNonVolatileMemory
|
||||
HOST-RESOURCES-MIB::hrDeviceType.3 = OID: HOST-RESOURCES-TYPES::hrDeviceProcessor
|
||||
HOST-RESOURCES-MIB::hrDeviceType.4 = OID: HOST-RESOURCES-TYPES::hrDeviceSerialPort
|
||||
HOST-RESOURCES-MIB::hrDeviceType.5 = OID: HOST-RESOURCES-TYPES::hrDeviceNetwork
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: Lexmark C522 9421TTV LS.FA.P129
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.2 = STRING: Nonvolatile RAM
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.3 = STRING: IBM 750 Rev CXr
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.4 = STRING: USB Interface
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.5 = STRING: Network Interface
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.2 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.3 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.4 = OID: SNMPv2-SMI::zeroDotZero
|
||||
HOST-RESOURCES-MIB::hrDeviceID.5 = OID: SNMPv2-SMI::enterprises.641.1
|
||||
SNMPv2-SMI::enterprises.641.2.1.2.1.2.1 = STRING: "Lexmark C522"
|
||||
SNMPv2-SMI::enterprises.641.2.1.2.1.3.1 = STRING: "MANUFACTURER:Lexmark International;COMMAND SET:;MODEL:Lexmark C522"
|
||||
|
||||
|
||||
Linksys EPSX3
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: ETHERNET MULTI-ENVIRONMENT.ROM, JETDIRECT EX, EEPROM 6016
|
||||
|
||||
|
||||
NetGear PS113
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: A SNMP proxy agent.
|
||||
|
||||
|
||||
Okidata C7200
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: OkiLAN 6200e
|
||||
SNMPv2-MIB::sysName.0 = STRING: OKI7009715
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceType.2 = OID: HOST-RESOURCES-TYPES::hrDeviceNonVolat
|
||||
ileMemory
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: C7200
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.2 = STRING: FLASH0
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.2001.1.1.1.1
|
||||
HOST-RESOURCES-MIB::hrDeviceID.2 = OID: SNMPv2-SMI::zeroDotZero
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.1 = STRING: "IEEE 1284"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.2 = STRING: "EtherTalk Phase 2"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.3 = STRING: "LPD"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.4 = STRING: "Netware Rprinter"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.5 = STRING: "Netware Bindery or NDS Pserver"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.6 = STRING: "Raw TCP Port 9100"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.7 = STRING: "FTP"
|
||||
SNMPv2-SMI::mib-2.43.14.1.1.3.1.8 = STRING: "DLC/LLC"
|
||||
SNMPv2-SMI::enterprises.2001.1.1.1.1.1.3530.0 = STRING: "C7200"
|
||||
|
||||
|
||||
Xerox N2025
|
||||
|
||||
SNMPv2-MIB::sysDescr.0 = STRING: Xerox DocuPrint N2025 Network Laser Printer - 2.12-02
|
||||
SNMPv2-MIB::sysName.0 = STRING:
|
||||
HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter
|
||||
HOST-RESOURCES-MIB::hrDeviceType.2 = OID: HOST-RESOURCES-TYPES::hrDeviceParallelPort
|
||||
HOST-RESOURCES-MIB::hrDeviceType.3 = OID: HOST-RESOURCES-TYPES::hrDeviceNetwork
|
||||
HOST-RESOURCES-MIB::hrDeviceType.6 = OID: HOST-RESOURCES-TYPES::hrDeviceProcessor
|
||||
HOST-RESOURCES-MIB::hrDeviceType.7 = OID: HOST-RESOURCES-TYPES::hrDeviceOther
|
||||
HOST-RESOURCES-MIB::hrDeviceType.9 = OID: HOST-RESOURCES-TYPES::hrDeviceVolatileMemory
|
||||
HOST-RESOURCES-MIB::hrDeviceType.10 = OID: HOST-RESOURCES-TYPES::hrDeviceNonVolatileMemory
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.1 = STRING: Xerox DocuPrint N2025 Network Laser Printer - 2.12-02
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.2 = STRING: IEEE 1284 port
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.3 = STRING: Ethernet port
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.6 = STRING: Motorola Power PC
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.7 = STRING: USB Port
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.9 = STRING: RAM Memory
|
||||
HOST-RESOURCES-MIB::hrDeviceDescr.10 = STRING: ROM Memory
|
||||
HOST-RESOURCES-MIB::hrDeviceID.1 = OID: SNMPv2-SMI::enterprises.253.8.62.1.3.2.17.1
|
||||
|
||||
+376
-251
@@ -3,45 +3,33 @@
|
||||
*
|
||||
* AppSocket backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* 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
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" 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-3142 USA
|
||||
*
|
||||
* Voice: (301) 373-9600
|
||||
* EMail: cups-info@cups.org
|
||||
* WWW: http://www.cups.org
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Send a file to the printer or server.
|
||||
* main() - Send a file to the printer or server.
|
||||
* side_cb() - Handle side-channel requests...
|
||||
* wait_bc() - Wait for back-channel data...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/cups.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <cups/http-private.h>
|
||||
#include <cups/string.h>
|
||||
#include <errno.h>
|
||||
#include "backend-private.h"
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock.h>
|
||||
@@ -59,7 +47,8 @@
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void print_backchannel(const unsigned char *buffer, int nbytes);
|
||||
static void side_cb(int print_fd, int device_fd, int use_bc);
|
||||
static int wait_bc(int device_fd, int secs);
|
||||
|
||||
|
||||
/*
|
||||
@@ -70,31 +59,37 @@ void print_backchannel(const unsigned char *buffer, int nbytes);
|
||||
* printer-uri job-id user title copies options [file]
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024]; /* Resource info (not used) */
|
||||
int fp; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
int port; /* Port number */
|
||||
int delay; /* Delay for retries... */
|
||||
int fd; /* AppSocket */
|
||||
int error; /* Error code (if any) */
|
||||
struct sockaddr_in addr; /* Socket address */
|
||||
struct hostent *hostaddr; /* Host address */
|
||||
int wbytes; /* Number of bytes written */
|
||||
int nbytes; /* Number of bytes read */
|
||||
size_t tbytes; /* Total number of bytes written */
|
||||
char buffer[8192], /* Output buffer */
|
||||
*bufptr; /* Pointer into buffer */
|
||||
struct timeval timeout; /* Timeout for select() */
|
||||
fd_set input; /* Input set for select() */
|
||||
char method[255], /* Method in URI */
|
||||
hostname[1024], /* Hostname */
|
||||
username[255], /* Username info (not used) */
|
||||
resource[1024], /* Resource info (not used) */
|
||||
*options, /* Pointer to options */
|
||||
*name, /* Name of option */
|
||||
*value, /* Value of option */
|
||||
sep; /* Option separator */
|
||||
int print_fd; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
time_t start_time, /* Time of first connect */
|
||||
current_time, /* Current time */
|
||||
wait_time; /* Time to wait before shutting down socket */
|
||||
int recoverable; /* Recoverable error shown? */
|
||||
int contimeout; /* Connection timeout */
|
||||
int waiteof; /* Wait for end-of-file? */
|
||||
int port; /* Port number */
|
||||
char portname[255]; /* Port name */
|
||||
int delay; /* Delay for retries... */
|
||||
int device_fd; /* AppSocket */
|
||||
int error; /* Error code (if any) */
|
||||
http_addrlist_t *addrlist, /* Address list */
|
||||
*addr; /* Connected address */
|
||||
char addrname[256]; /* Address name */
|
||||
ssize_t tbytes; /* Total number of bytes written */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
struct sigaction action; /* Actions for POSIX signals */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
@@ -125,13 +120,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if (argc == 1)
|
||||
{
|
||||
puts("network socket \"Unknown\" \"AppSocket/HP JetDirect\"");
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s job-id user title copies options [file]\n",
|
||||
argv[0]);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("Usage: %s job-id user title copies options [file]\n"),
|
||||
argv[0]);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -141,8 +137,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
|
||||
if (argc == 6)
|
||||
{
|
||||
fp = 0;
|
||||
copies = 1;
|
||||
print_fd = 0;
|
||||
copies = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -150,10 +146,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Try to open the print file...
|
||||
*/
|
||||
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
perror("ERROR: unable to open print file");
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
@@ -163,253 +159,382 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Extract the hostname and port number from the URI...
|
||||
*/
|
||||
|
||||
httpSeparate(argv[0], method, username, hostname, &port, resource);
|
||||
httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
|
||||
method, sizeof(method), username, sizeof(username),
|
||||
hostname, sizeof(hostname), &port,
|
||||
resource, sizeof(resource));
|
||||
|
||||
if (port == 0)
|
||||
port = 9100; /* Default to HP JetDirect/Tektronix PhaserShare */
|
||||
|
||||
/*
|
||||
* Get options, if any...
|
||||
*/
|
||||
|
||||
waiteof = 1;
|
||||
contimeout = 7 * 24 * 60 * 60;
|
||||
|
||||
if ((options = strchr(resource, '?')) != NULL)
|
||||
{
|
||||
/*
|
||||
* Yup, terminate the device name string and move to the first
|
||||
* character of the options...
|
||||
*/
|
||||
|
||||
*options++ = '\0';
|
||||
|
||||
/*
|
||||
* Parse options...
|
||||
*/
|
||||
|
||||
while (*options)
|
||||
{
|
||||
/*
|
||||
* Get the name...
|
||||
*/
|
||||
|
||||
name = options;
|
||||
|
||||
while (*options && *options != '=' && *options != '+' && *options != '&')
|
||||
options ++;
|
||||
|
||||
if ((sep = *options) != '\0')
|
||||
*options++ = '\0';
|
||||
|
||||
if (sep == '=')
|
||||
{
|
||||
/*
|
||||
* Get the value...
|
||||
*/
|
||||
|
||||
value = options;
|
||||
|
||||
while (*options && *options != '+' && *options != '&')
|
||||
options ++;
|
||||
|
||||
if (*options)
|
||||
*options++ = '\0';
|
||||
}
|
||||
else
|
||||
value = (char *)"";
|
||||
|
||||
/*
|
||||
* Process the option...
|
||||
*/
|
||||
|
||||
if (!strcasecmp(name, "waiteof"))
|
||||
{
|
||||
/*
|
||||
* Set the wait-for-eof value...
|
||||
*/
|
||||
|
||||
waiteof = !value[0] || !strcasecmp(value, "on") ||
|
||||
!strcasecmp(value, "yes") || !strcasecmp(value, "true");
|
||||
}
|
||||
else if (!strcasecmp(name, "contimeout"))
|
||||
{
|
||||
/*
|
||||
* Set the connection timeout...
|
||||
*/
|
||||
|
||||
if (atoi(value) > 0)
|
||||
contimeout = atoi(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Then try to connect to the remote host...
|
||||
*/
|
||||
|
||||
if ((hostaddr = httpGetHostByName(hostname)) == NULL)
|
||||
recoverable = 0;
|
||||
start_time = time(NULL);
|
||||
|
||||
sprintf(portname, "%d", port);
|
||||
|
||||
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s\n",
|
||||
hostname, hstrerror(h_errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
|
||||
hostname);
|
||||
return (CUPS_BACKEND_STOP);
|
||||
}
|
||||
|
||||
fprintf(stderr, "INFO: Attempting to connect to host %s on port %d\n",
|
||||
hostname, port);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("INFO: Attempting to connect to host %s on port %d\n"),
|
||||
hostname, port);
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
|
||||
addr.sin_family = hostaddr->h_addrtype;
|
||||
addr.sin_port = htons(port);
|
||||
fputs("STATE: +connecting-to-device\n", stderr);
|
||||
|
||||
wbytes = 0;
|
||||
|
||||
while (copies > 0)
|
||||
for (delay = 5;;)
|
||||
{
|
||||
for (delay = 5;;)
|
||||
if ((addr = httpAddrConnect(addrlist, &device_fd)) == NULL)
|
||||
{
|
||||
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
perror("ERROR: Unable to create socket");
|
||||
return (1);
|
||||
}
|
||||
error = errno;
|
||||
device_fd = -1;
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
error = errno;
|
||||
close(fd);
|
||||
fd = -1;
|
||||
|
||||
if (error == ECONNREFUSED || error == EHOSTDOWN ||
|
||||
error == EHOSTUNREACH)
|
||||
{
|
||||
fprintf(stderr, "INFO: Network host \'%s\' is busy; will retry in %d seconds...\n",
|
||||
hostname, delay);
|
||||
sleep(delay);
|
||||
|
||||
if (delay < 30)
|
||||
delay += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
perror("ERROR: Unable to connect to printer (retrying in 30 seconds)");
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that we are "connected" to the port, ignore SIGTERM so that we
|
||||
* can finish out any page data the driver sends (e.g. to eject the
|
||||
* current page... Only ignore SIGTERM if we are printing data from
|
||||
* stdin (otherwise you can't cancel raw jobs...)
|
||||
*/
|
||||
|
||||
if (argc < 7)
|
||||
{
|
||||
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
|
||||
sigset(SIGTERM, SIG_IGN);
|
||||
#elif defined(HAVE_SIGACTION)
|
||||
memset(&action, 0, sizeof(action));
|
||||
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
#else
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
#endif /* HAVE_SIGSET */
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, send the print file...
|
||||
*/
|
||||
|
||||
copies --;
|
||||
|
||||
if (fp != 0)
|
||||
{
|
||||
fputs("PAGE: 1 1\n", stderr);
|
||||
lseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
fputs("INFO: Connected to host, sending print job...\n", stderr);
|
||||
|
||||
tbytes = 0;
|
||||
while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0)
|
||||
{
|
||||
/*
|
||||
* Write the print data to the printer...
|
||||
*/
|
||||
|
||||
tbytes += nbytes;
|
||||
bufptr = buffer;
|
||||
|
||||
while (nbytes > 0)
|
||||
{
|
||||
if ((wbytes = send(fd, bufptr, nbytes, 0)) < 0)
|
||||
{
|
||||
perror("ERROR: Unable to send print file to printer");
|
||||
break;
|
||||
}
|
||||
|
||||
nbytes -= wbytes;
|
||||
bufptr += wbytes;
|
||||
}
|
||||
|
||||
if (wbytes < 0)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check for possible data coming back from the printer...
|
||||
*/
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&input);
|
||||
FD_SET(fd, &input);
|
||||
if (select(fd + 1, &input, NULL, NULL, &timeout) > 0)
|
||||
if (getenv("CLASS") != NULL)
|
||||
{
|
||||
/*
|
||||
* Grab the data coming back and spit it out to stderr...
|
||||
* If the CLASS environment variable is set, the job was submitted
|
||||
* to a class and not to a specific queue. In this case, we want
|
||||
* to abort immediately so that the job can be requeued on the next
|
||||
* available printer in the class.
|
||||
*/
|
||||
|
||||
if ((nbytes = recv(fd, buffer, sizeof(buffer), 0)) > 0)
|
||||
{
|
||||
fprintf(stderr, "INFO: Received %d bytes of back-channel data!\n",
|
||||
nbytes);
|
||||
print_backchannel((unsigned char *)buffer, nbytes);
|
||||
}
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Unable to contact printer, queuing on next "
|
||||
"printer in class...\n"));
|
||||
|
||||
/*
|
||||
* Sleep 5 seconds to keep the job from requeuing too rapidly...
|
||||
*/
|
||||
|
||||
sleep(5);
|
||||
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
else if (argc > 6)
|
||||
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
|
||||
(unsigned long)tbytes);
|
||||
|
||||
if (error == ECONNREFUSED || error == EHOSTDOWN ||
|
||||
error == EHOSTUNREACH)
|
||||
{
|
||||
if (contimeout && (time(NULL) - start_time) > contimeout)
|
||||
{
|
||||
_cupsLangPuts(stderr, _("ERROR: Printer not responding!\n"));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
recoverable = 1;
|
||||
|
||||
_cupsLangPrintf(stderr,
|
||||
_("WARNING: recoverable: Network host \'%s\' is busy; "
|
||||
"will retry in %d seconds...\n"),
|
||||
hostname, delay);
|
||||
|
||||
sleep(delay);
|
||||
|
||||
if (delay < 30)
|
||||
delay += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
recoverable = 1;
|
||||
|
||||
_cupsLangPrintf(stderr, "DEBUG: Connection error: %s\n",
|
||||
strerror(errno));
|
||||
_cupsLangPuts(stderr,
|
||||
_("ERROR: recoverable: Unable to connect to printer; "
|
||||
"will retry in 30 seconds...\n"));
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (recoverable)
|
||||
{
|
||||
/*
|
||||
* If we've shown a recoverable error make sure the printer proxies
|
||||
* have a chance to see the recovered message. Not pretty but
|
||||
* necessary for now...
|
||||
*/
|
||||
|
||||
fputs("INFO: recovered: \n", stderr);
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
fputs("STATE: -connecting-to-device\n", stderr);
|
||||
_cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
|
||||
|
||||
#ifdef AF_INET6
|
||||
if (addr->addr.addr.sa_family == AF_INET6)
|
||||
fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
|
||||
httpAddrString(&addr->addr, addrname, sizeof(addrname)),
|
||||
ntohs(addr->addr.ipv6.sin6_port));
|
||||
else
|
||||
#endif /* AF_INET6 */
|
||||
if (addr->addr.addr.sa_family == AF_INET)
|
||||
fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
|
||||
httpAddrString(&addr->addr, addrname, sizeof(addrname)),
|
||||
ntohs(addr->addr.ipv4.sin_port));
|
||||
|
||||
/*
|
||||
* Print everything...
|
||||
*/
|
||||
|
||||
tbytes = 0;
|
||||
|
||||
while (copies > 0 && tbytes >= 0)
|
||||
{
|
||||
copies --;
|
||||
|
||||
if (print_fd != 0)
|
||||
{
|
||||
fputs("PAGE: 1 1\n", stderr);
|
||||
lseek(print_fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
tbytes = backendRunLoop(print_fd, device_fd, 1, side_cb);
|
||||
|
||||
if (print_fd != 0 && tbytes >= 0)
|
||||
_cupsLangPrintf(stderr,
|
||||
#ifdef HAVE_LONG_LONG
|
||||
_("INFO: Sent print file, %lld bytes...\n"),
|
||||
#else
|
||||
_("INFO: Sent print file, %ld bytes...\n"),
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
CUPS_LLCAST tbytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait up to 5 seconds to get any pending back-channel data...
|
||||
*/
|
||||
|
||||
wait_time = time(NULL) + 5;
|
||||
while (wait_time >= time(¤t_time))
|
||||
if (wait_bc(device_fd, wait_time - current_time) <= 0)
|
||||
break;
|
||||
|
||||
if (waiteof)
|
||||
{
|
||||
/*
|
||||
* Shutdown the socket and wait for the other end to finish...
|
||||
*/
|
||||
|
||||
fputs("INFO: Print file sent, waiting for printer to finish...\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("INFO: Print file sent, waiting for printer to finish...\n"));
|
||||
|
||||
shutdown(fd, 1);
|
||||
shutdown(device_fd, 1);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/*
|
||||
* Wait a maximum of 90 seconds for backchannel data or a closed
|
||||
* connection...
|
||||
*/
|
||||
|
||||
timeout.tv_sec = 90;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&input);
|
||||
FD_SET(fd, &input);
|
||||
|
||||
#ifdef __hpux
|
||||
if (select(fd + 1, (int *)&input, NULL, NULL, &timeout) > 0)
|
||||
#else
|
||||
if (select(fd + 1, &input, NULL, NULL, &timeout) > 0)
|
||||
#endif /* __hpux */
|
||||
{
|
||||
/*
|
||||
* Grab the data coming back and spit it out to stderr...
|
||||
*/
|
||||
|
||||
if ((nbytes = recv(fd, buffer, sizeof(buffer), 0)) > 0)
|
||||
{
|
||||
fprintf(stderr, "INFO: Received %d bytes of back-channel data!\n",
|
||||
nbytes);
|
||||
print_backchannel((unsigned char *)buffer, nbytes);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the socket connection...
|
||||
*/
|
||||
|
||||
close(fd);
|
||||
while (wait_bc(device_fd, 90) > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the socket connection...
|
||||
*/
|
||||
|
||||
close(device_fd);
|
||||
|
||||
httpAddrFreeList(addrlist);
|
||||
|
||||
/*
|
||||
* Close the input file and return...
|
||||
*/
|
||||
|
||||
if (fp != 0)
|
||||
close(fp);
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (wbytes < 0);
|
||||
if (tbytes >= 0)
|
||||
_cupsLangPuts(stderr, _("INFO: Ready to print.\n"));
|
||||
|
||||
return (tbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'print_backchannel()' - Print the contents of a back-channel buffer.
|
||||
* 'side_cb()' - Handle side-channel requests...
|
||||
*/
|
||||
|
||||
void
|
||||
print_backchannel(const unsigned char *buffer, /* I - Data buffer */
|
||||
int nbytes) /* I - Number of bytes */
|
||||
static void
|
||||
side_cb(int print_fd, /* I - Print file */
|
||||
int device_fd, /* I - Device file */
|
||||
int use_bc) /* I - Using back-channel? */
|
||||
{
|
||||
char line[255], /* Formatted line */
|
||||
*lineptr; /* Pointer into line */
|
||||
cups_sc_command_t command; /* Request command */
|
||||
cups_sc_status_t status; /* Request/response status */
|
||||
char data[2048]; /* Request/response data */
|
||||
int datalen; /* Request/response data size */
|
||||
const char *device_id; /* 1284DEVICEID env var */
|
||||
|
||||
|
||||
for (lineptr = line; nbytes > 0; buffer ++, nbytes --)
|
||||
datalen = sizeof(data);
|
||||
|
||||
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
|
||||
{
|
||||
if (*buffer < 0x20 || *buffer >= 0x7f)
|
||||
{
|
||||
snprintf(lineptr, sizeof(line) - (lineptr - line), "<%02X>", *buffer);
|
||||
lineptr += strlen(lineptr);
|
||||
}
|
||||
else
|
||||
*lineptr++ = *buffer;
|
||||
|
||||
if ((lineptr - line) > 72)
|
||||
{
|
||||
*lineptr = '\0';
|
||||
fprintf(stderr, "DEBUG: DATA: %s\n", line);
|
||||
lineptr = line;
|
||||
}
|
||||
_cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lineptr > line)
|
||||
switch (command)
|
||||
{
|
||||
*lineptr = '\0';
|
||||
fprintf(stderr, "DEBUG: DATA: %s\n", line);
|
||||
case CUPS_SC_CMD_DRAIN_OUTPUT :
|
||||
/*
|
||||
* Our sockets disable the Nagle algorithm and data is sent immediately.
|
||||
*/
|
||||
|
||||
if (backendDrainOutput(print_fd, device_fd))
|
||||
status = CUPS_SC_STATUS_IO_ERROR;
|
||||
else
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
|
||||
datalen = 0;
|
||||
break;
|
||||
|
||||
case CUPS_SC_CMD_GET_BIDI :
|
||||
status = CUPS_SC_STATUS_OK;
|
||||
data[0] = use_bc;
|
||||
datalen = 1;
|
||||
break;
|
||||
|
||||
case CUPS_SC_CMD_GET_DEVICE_ID :
|
||||
if ((device_id = getenv("1284DEVICEID")) != NULL)
|
||||
{
|
||||
strlcpy(data, device_id, sizeof(data));
|
||||
datalen = (int)strlen(data);
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
|
||||
datalen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
cupsSideChannelWrite(command, status, data, datalen, 1.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'wait_bc()' - Wait for back-channel data...
|
||||
*/
|
||||
|
||||
static int /* O - # bytes read or -1 on error */
|
||||
wait_bc(int device_fd, /* I - Socket */
|
||||
int secs) /* I - Seconds to wait */
|
||||
{
|
||||
struct timeval timeout; /* Timeout for select() */
|
||||
fd_set input; /* Input set for select() */
|
||||
ssize_t bytes; /* Number of back-channel bytes read */
|
||||
char buffer[1024]; /* Back-channel buffer */
|
||||
|
||||
|
||||
/*
|
||||
* Wait up to "secs" seconds for backchannel data...
|
||||
*/
|
||||
|
||||
timeout.tv_sec = secs;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&input);
|
||||
FD_SET(device_fd, &input);
|
||||
|
||||
if (select(device_fd + 1, &input, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
/*
|
||||
* Grab the data coming back and spit it out to stderr...
|
||||
*/
|
||||
|
||||
if ((bytes = read(device_fd, buffer, sizeof(buffer))) > 0)
|
||||
{
|
||||
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
|
||||
(int)bytes);
|
||||
cupsBackChannelWrite(buffer, bytes, 1.0);
|
||||
}
|
||||
|
||||
return (bytes);
|
||||
}
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* IEEE-1284 support functions test program for the Common UNIX Printing
|
||||
* System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" which should have been included with this file. If this
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Test the device-ID functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers.
|
||||
*/
|
||||
|
||||
#include <cups/string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#define DEBUG
|
||||
#include "ieee1284.c"
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Test the device-ID functions.
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line args */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
int i, /* Looping var */
|
||||
fd; /* File descriptor */
|
||||
char device_id[1024], /* 1284 device ID string */
|
||||
make_model[1024], /* make-and-model string */
|
||||
uri[1024]; /* URI string */
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
puts("Usage: test1284 device-file [... device-file-N]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i ++)
|
||||
{
|
||||
if ((fd = open(argv[i], O_RDWR)) < 0)
|
||||
{
|
||||
perror(argv[i]);
|
||||
return (errno);
|
||||
}
|
||||
|
||||
printf("%s:\n", argv[i]);
|
||||
|
||||
backendGetDeviceID(fd, device_id, sizeof(device_id), make_model,
|
||||
sizeof(make_model), "test", uri, sizeof(uri));
|
||||
|
||||
printf(" device_id=\"%s\"\n", device_id);
|
||||
printf(" make_model=\"%s\"\n", make_model);
|
||||
printf(" uri=\"%s\"\n", uri);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+1912
-1780
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+364
-543
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+43
-43
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* USB port backend for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
*
|
||||
* 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
|
||||
* property of Apple Inc. and are protected by Federal copyright
|
||||
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
* "LICENSE" 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-3142 USA
|
||||
*
|
||||
* Voice: (301) 373-9600
|
||||
* EMail: cups-info@cups.org
|
||||
* WWW: http://www.cups.org
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* This file is subject to the Apple OS-Developed Software exception.
|
||||
*
|
||||
@@ -39,11 +30,13 @@
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#include <cups/backend.h>
|
||||
#include <cups/cups.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cups/string.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -61,8 +54,8 @@
|
||||
|
||||
void list_devices(void);
|
||||
int print_device(const char *uri, const char *hostname,
|
||||
const char *resource, const char *options,
|
||||
int fp, int copies);
|
||||
const char *resource, char *options,
|
||||
int print_fd, int copies, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
@@ -71,7 +64,7 @@ int print_device(const char *uri, const char *hostname,
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include "usb-darwin.c"
|
||||
#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
# include "usb-unix.c"
|
||||
#else
|
||||
/*
|
||||
@@ -106,9 +99,11 @@ int /* O - Exit status */
|
||||
print_device(const char *uri, /* I - Device URI */
|
||||
const char *hostname, /* I - Hostname/manufacturer */
|
||||
const char *resource, /* I - Resource/modelname */
|
||||
const char *options, /* I - Device options/serial number */
|
||||
int fp, /* I - File descriptor to print */
|
||||
int copies) /* I - Copies to print */
|
||||
char *options, /* I - Device options/serial number */
|
||||
int print_fd, /* I - File descriptor to print */
|
||||
int copies, /* I - Copies to print */
|
||||
int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
/*
|
||||
* Can't print, so just reference the arguments to eliminate compiler
|
||||
@@ -121,10 +116,12 @@ print_device(const char *uri, /* I - Device URI */
|
||||
(void)hostname;
|
||||
(void)resource;
|
||||
(void)options;
|
||||
(void)fp;
|
||||
(void)print_fd;
|
||||
(void)copies;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
return (1);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
@@ -141,7 +138,7 @@ int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
int fp; /* Print file */
|
||||
int print_fd; /* Print file */
|
||||
int copies; /* Number of copies to print */
|
||||
int status; /* Exit status */
|
||||
int port; /* Port number (not used) */
|
||||
@@ -183,31 +180,33 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
if (argc == 1)
|
||||
{
|
||||
list_devices();
|
||||
return (0);
|
||||
return (CUPS_BACKEND_OK);
|
||||
}
|
||||
else if (argc < 6 || argc > 7)
|
||||
{
|
||||
fputs("Usage: usb job-id user title copies options [file]\n", stderr);
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("Usage: %s job-id user title copies options [file]\n"),
|
||||
argv[0]);
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract the device name and options from the URI...
|
||||
*/
|
||||
|
||||
if (strncmp(argv[0], "usb:", 4))
|
||||
uri = getenv("DEVICE_URI");
|
||||
else
|
||||
uri = argv[0];
|
||||
uri = cupsBackendDeviceURI(argv);
|
||||
|
||||
if (!uri)
|
||||
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri,
|
||||
method, sizeof(method), username, sizeof(username),
|
||||
hostname, sizeof(hostname), &port,
|
||||
resource, sizeof(resource)) < HTTP_URI_OK)
|
||||
{
|
||||
fputs("ERROR: No device URI found in argv[0] or in DEVICE_URI environment variable!\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("ERROR: No device URI found in argv[0] or in DEVICE_URI "
|
||||
"environment variable!\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
httpSeparate(argv[0], method, username, hostname, &port, resource);
|
||||
|
||||
/*
|
||||
* See if there are any options...
|
||||
*/
|
||||
@@ -229,8 +228,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
|
||||
if (argc == 6)
|
||||
{
|
||||
fp = 0;
|
||||
copies = 1;
|
||||
print_fd = 0;
|
||||
copies = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -238,11 +237,11 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Try to open the print file...
|
||||
*/
|
||||
|
||||
if ((fp = open(argv[6], O_RDONLY)) < 0)
|
||||
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: unable to open print file %s - %s\n",
|
||||
argv[6], strerror(errno));
|
||||
return (1);
|
||||
_cupsLangPrintf(stderr, _("ERROR: Unable to open print file %s - %s\n"),
|
||||
argv[6], strerror(errno));
|
||||
return (CUPS_BACKEND_FAILED);
|
||||
}
|
||||
|
||||
copies = atoi(argv[4]);
|
||||
@@ -252,14 +251,15 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
|
||||
* Finally, send the print file...
|
||||
*/
|
||||
|
||||
status = print_device(uri, hostname, resource, options, fp, copies);
|
||||
status = print_device(uri, hostname, resource, options, print_fd, copies,
|
||||
argc, argv);
|
||||
|
||||
/*
|
||||
* Close the input file and return...
|
||||
*/
|
||||
|
||||
if (fp != 0)
|
||||
close(fp);
|
||||
if (print_fd != 0)
|
||||
close(print_fd);
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
lpc
|
||||
lpq
|
||||
lpr
|
||||
lprm
|
||||
+11
-9
@@ -1,12 +1,14 @@
|
||||
# DO NOT DELETE
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
lpc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
lpc.o: ../cups/ppd.h ../cups/language.h ../cups/debug.h ../cups/string.h
|
||||
lpc.o: ../config.h
|
||||
lpc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
lpc.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/i18n.h
|
||||
lpc.o: ../cups/transcode.h ../cups/debug.h ../cups/string.h ../config.h
|
||||
lpq.o: ../cups/string.h ../config.h ../cups/cups.h ../cups/ipp.h
|
||||
lpq.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h ../cups/language.h
|
||||
lpq.o: ../cups/debug.h
|
||||
lpq.o: ../cups/http.h ../cups/ppd.h ../cups/array.h ../cups/file.h
|
||||
lpq.o: ../cups/language.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h
|
||||
lpr.o: ../cups/string.h ../config.h ../cups/cups.h ../cups/ipp.h
|
||||
lpr.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h
|
||||
lprm.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
lprm.o: ../cups/ppd.h ../cups/language.h ../cups/string.h ../config.h
|
||||
lpr.o: ../cups/http.h ../cups/ppd.h ../cups/array.h ../cups/file.h
|
||||
lpr.o: ../cups/language.h ../cups/i18n.h ../cups/transcode.h
|
||||
lprm.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
lprm.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/i18n.h
|
||||
lprm.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
|
||||
+27
-17
@@ -3,23 +3,14 @@
|
||||
#
|
||||
# Berkeley commands makefile for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
# Copyright 2007 by Apple Inc.
|
||||
# Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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-3142 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
include ../Makedefs
|
||||
@@ -56,12 +47,31 @@ depend:
|
||||
#
|
||||
|
||||
install: all
|
||||
$(INSTALL_DIR) $(BINDIR)
|
||||
$(INSTALL_DIR) -m 755 $(BINDIR)
|
||||
$(INSTALL_BIN) lpq $(BINDIR)
|
||||
$(INSTALL_BIN) lpr $(BINDIR)
|
||||
$(INSTALL_BIN) lprm $(BINDIR)
|
||||
$(INSTALL_DIR) $(SBINDIR)
|
||||
$(INSTALL_DIR) -m 755 $(SBINDIR)
|
||||
$(INSTALL_BIN) lpc $(SBINDIR)
|
||||
if test "x$(SYMROOT)" != "x"; then \
|
||||
$(INSTALL_DIR) $(SYMROOT); \
|
||||
for file in $(TARGETS); do \
|
||||
cp $$file $(SYMROOT); \
|
||||
done \
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Uninstall all targets...
|
||||
#
|
||||
|
||||
uninstall:
|
||||
$(RM) $(BINDIR)/lpq
|
||||
$(RM) $(BINDIR)/lpr
|
||||
$(RM) $(BINDIR)/lprm
|
||||
$(RM) $(SBINDIR)/lpc
|
||||
-$(RMDIR) $(SBINDIR)
|
||||
-$(RMDIR) $(BINDIR)
|
||||
|
||||
|
||||
#
|
||||
|
||||
+138
-170
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* "lpc" command for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
@@ -36,9 +27,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <cups/cups.h>
|
||||
#include <cups/language.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <cups/debug.h>
|
||||
#include <cups/string.h>
|
||||
|
||||
@@ -47,10 +37,10 @@
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static int compare_strings(char *, char *, int);
|
||||
static void do_command(http_t *, char *, char *);
|
||||
static void show_help(char *);
|
||||
static void show_status(http_t *, char *);
|
||||
static int compare_strings(const char *, const char *, int);
|
||||
static void do_command(http_t *, const char *, const char *);
|
||||
static void show_help(const char *);
|
||||
static void show_status(http_t *, const char *);
|
||||
|
||||
|
||||
/*
|
||||
@@ -58,14 +48,16 @@ static void show_status(http_t *, char *);
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
http_t *http; /* Connection to server */
|
||||
char line[1024], /* Input line from user */
|
||||
*params; /* Pointer to parameters */
|
||||
http_t *http; /* Connection to server */
|
||||
char line[1024], /* Input line from user */
|
||||
*params; /* Pointer to parameters */
|
||||
|
||||
|
||||
_cupsSetLocale(argv);
|
||||
|
||||
/*
|
||||
* Connect to the scheduler...
|
||||
*/
|
||||
@@ -86,22 +78,42 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* Do the command prompt thing...
|
||||
*/
|
||||
|
||||
printf("lpc> ");
|
||||
_cupsLangPuts(stdout, _("lpc> "));
|
||||
while (fgets(line, sizeof(line), stdin) != NULL)
|
||||
{
|
||||
/*
|
||||
* Strip the trailing newline...
|
||||
* Strip trailing whitespace...
|
||||
*/
|
||||
|
||||
line[strlen(line) - 1] = '\0';
|
||||
for (params = line + strlen(line) - 1; params >= line;)
|
||||
if (!isspace(*params & 255))
|
||||
break;
|
||||
else
|
||||
*params-- = '\0';
|
||||
|
||||
/*
|
||||
* Strip leading whitespace...
|
||||
*/
|
||||
|
||||
for (params = line; isspace(*params & 255); params ++);
|
||||
|
||||
if (params > line)
|
||||
_cups_strcpy(line, params);
|
||||
|
||||
if (!line[0])
|
||||
{
|
||||
/*
|
||||
* Nothing left, just show a prompt...
|
||||
*/
|
||||
|
||||
_cupsLangPuts(stdout, _("lpc> "));
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find any options in the string...
|
||||
*/
|
||||
|
||||
while (isspace(line[0] & 255))
|
||||
cups_strcpy(line, line + 1);
|
||||
|
||||
for (params = line; *params != '\0'; params ++)
|
||||
if (isspace(*params & 255))
|
||||
break;
|
||||
@@ -117,8 +129,8 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* The "quit" and "exit" commands exit; otherwise, process as needed...
|
||||
*/
|
||||
|
||||
if (compare_strings(line, "quit", 1) == 0 ||
|
||||
compare_strings(line, "exit", 2) == 0)
|
||||
if (!compare_strings(line, "quit", 1) ||
|
||||
!compare_strings(line, "exit", 2))
|
||||
break;
|
||||
|
||||
if (*params == '\0')
|
||||
@@ -130,7 +142,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* Put another prompt out to the user...
|
||||
*/
|
||||
|
||||
printf("lpc> ");
|
||||
_cupsLangPuts(stdout, _("lpc> "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,12 +160,12 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* 'compare_strings()' - Compare two command-line strings.
|
||||
*/
|
||||
|
||||
static int /* O - -1 or 1 = no match, 0 = match */
|
||||
compare_strings(char *s, /* I - Command-line string */
|
||||
char *t, /* I - Option string */
|
||||
int tmin) /* I - Minimum number of unique chars in option */
|
||||
static int /* O - -1 or 1 = no match, 0 = match */
|
||||
compare_strings(const char *s, /* I - Command-line string */
|
||||
const char *t, /* I - Option string */
|
||||
int tmin) /* I - Minimum number of unique chars in option */
|
||||
{
|
||||
int slen; /* Length of command-line string */
|
||||
int slen; /* Length of command-line string */
|
||||
|
||||
|
||||
slen = strlen(s);
|
||||
@@ -169,17 +181,18 @@ compare_strings(char *s, /* I - Command-line string */
|
||||
*/
|
||||
|
||||
static void
|
||||
do_command(http_t *http, /* I - HTTP connection to server */
|
||||
char *command, /* I - Command string */
|
||||
char *params) /* I - Parameters for command */
|
||||
do_command(http_t *http, /* I - HTTP connection to server */
|
||||
const char *command, /* I - Command string */
|
||||
const char *params) /* I - Parameters for command */
|
||||
{
|
||||
if (compare_strings(command, "status", 4) == 0)
|
||||
if (!compare_strings(command, "status", 4))
|
||||
show_status(http, params);
|
||||
else if (compare_strings(command, "help", 1) == 0 ||
|
||||
strcmp(command, "?") == 0)
|
||||
else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
|
||||
show_help(params);
|
||||
else
|
||||
printf("%s is not implemented by the CUPS version of lpc.\n", command);
|
||||
_cupsLangPrintf(stdout,
|
||||
_("%s is not implemented by the CUPS version of lpc.\n"),
|
||||
command);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,21 +201,21 @@ do_command(http_t *http, /* I - HTTP connection to server */
|
||||
*/
|
||||
|
||||
static void
|
||||
show_help(char *command) /* I - Command to describe or NULL */
|
||||
show_help(const char *command) /* I - Command to describe or NULL */
|
||||
{
|
||||
if (command == NULL)
|
||||
if (!command)
|
||||
{
|
||||
puts("Commands may be abbreviated. Commands are:");
|
||||
puts("");
|
||||
puts("exit help quit status ?");
|
||||
_cupsLangPrintf(stdout,
|
||||
_("Commands may be abbreviated. Commands are:\n"
|
||||
"\n"
|
||||
"exit help quit status ?\n"));
|
||||
}
|
||||
else if (compare_strings(command, "help", 1) == 0 ||
|
||||
strcmp(command, "?") == 0)
|
||||
puts("help\t\tget help on commands");
|
||||
else if (compare_strings(command, "status", 4) == 0)
|
||||
puts("status\t\tshow status of daemon and queue");
|
||||
else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
|
||||
_cupsLangPrintf(stdout, _("help\t\tget help on commands\n"));
|
||||
else if (!compare_strings(command, "status", 4))
|
||||
_cupsLangPrintf(stdout, _("status\t\tshow status of daemon and queue\n"));
|
||||
else
|
||||
puts("?Invalid help command unknown");
|
||||
_cupsLangPrintf(stdout, _("?Invalid help command unknown\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -211,36 +224,32 @@ show_help(char *command) /* I - Command to describe or NULL */
|
||||
*/
|
||||
|
||||
static void
|
||||
show_status(http_t *http, /* I - HTTP connection to server */
|
||||
char *dests) /* I - Destinations */
|
||||
show_status(http_t *http, /* I - HTTP connection to server */
|
||||
const char *dests) /* I - Destinations */
|
||||
{
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response, /* IPP Response */
|
||||
*jobs; /* IPP Get Jobs response */
|
||||
ipp_attribute_t *attr, /* Current attribute */
|
||||
*jattr; /* Current job attribute */
|
||||
cups_lang_t *language; /* Default language */
|
||||
char *printer, /* Printer name */
|
||||
*device, /* Device URI */
|
||||
*delimiter; /* Char search result */
|
||||
ipp_pstate_t pstate; /* Printer state */
|
||||
int accepting; /* Is printer accepting jobs? */
|
||||
int jobcount; /* Count of current jobs */
|
||||
char *dptr, /* Pointer into destination list */
|
||||
*ptr; /* Pointer into printer name */
|
||||
int match; /* Non-zero if this job matches */
|
||||
char printer_uri[HTTP_MAX_URI];
|
||||
/* Printer URI */
|
||||
static const char *requested[] =
|
||||
{ /* Requested attributes */
|
||||
"printer-name",
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
char *printer, /* Printer name */
|
||||
*device, /* Device URI */
|
||||
*delimiter; /* Char search result */
|
||||
ipp_pstate_t pstate; /* Printer state */
|
||||
int accepting; /* Is printer accepting jobs? */
|
||||
int jobcount; /* Count of current jobs */
|
||||
const char *dptr, /* Pointer into destination list */
|
||||
*ptr; /* Pointer into printer name */
|
||||
int match; /* Non-zero if this job matches */
|
||||
static const char *requested[] = /* Requested attributes */
|
||||
{
|
||||
"device-uri",
|
||||
"printer-is-accepting-jobs",
|
||||
"printer-name",
|
||||
"printer-state",
|
||||
"printer-is-accepting-jobs"
|
||||
"queued-job-count"
|
||||
};
|
||||
|
||||
|
||||
DEBUG_printf(("show_status(%08x, %08x)\n", http, dests));
|
||||
DEBUG_printf(("show_status(http=%p, dests=\"%s\")\n", http, dests));
|
||||
|
||||
if (http == NULL)
|
||||
return;
|
||||
@@ -253,18 +262,7 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
* attributes-natural-language
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = CUPS_GET_PRINTERS;
|
||||
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(CUPS_GET_PRINTERS);
|
||||
|
||||
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
|
||||
"requested-attributes", sizeof(requested) / sizeof(requested[0]),
|
||||
@@ -274,7 +272,7 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/printers/")) != NULL)
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
DEBUG_puts("show_status: request succeeded...");
|
||||
|
||||
@@ -307,21 +305,21 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
|
||||
while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
|
||||
{
|
||||
if (strcmp(attr->name, "printer-name") == 0 &&
|
||||
attr->value_tag == IPP_TAG_NAME)
|
||||
printer = attr->values[0].string.text;
|
||||
|
||||
if (strcmp(attr->name, "device-uri") == 0 &&
|
||||
if (!strcmp(attr->name, "device-uri") &&
|
||||
attr->value_tag == IPP_TAG_URI)
|
||||
device = attr->values[0].string.text;
|
||||
|
||||
if (strcmp(attr->name, "printer-state") == 0 &&
|
||||
attr->value_tag == IPP_TAG_ENUM)
|
||||
pstate = (ipp_pstate_t)attr->values[0].integer;
|
||||
|
||||
if (strcmp(attr->name, "printer-is-accepting-jobs") == 0 &&
|
||||
attr->value_tag == IPP_TAG_BOOLEAN)
|
||||
else if (!strcmp(attr->name, "printer-is-accepting-jobs") &&
|
||||
attr->value_tag == IPP_TAG_BOOLEAN)
|
||||
accepting = attr->values[0].boolean;
|
||||
else if (!strcmp(attr->name, "printer-name") &&
|
||||
attr->value_tag == IPP_TAG_NAME)
|
||||
printer = attr->values[0].string.text;
|
||||
else if (!strcmp(attr->name, "printer-state") &&
|
||||
attr->value_tag == IPP_TAG_ENUM)
|
||||
pstate = (ipp_pstate_t)attr->values[0].integer;
|
||||
else if (!strcmp(attr->name, "queued-job-count") &&
|
||||
attr->value_tag == IPP_TAG_INTEGER)
|
||||
jobcount = attr->values[0].integer;
|
||||
|
||||
attr = attr->next;
|
||||
}
|
||||
@@ -338,6 +336,13 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* A single 'all' printer name is special, meaning all printers.
|
||||
*/
|
||||
|
||||
if (dests != NULL && !strcmp(dests, "all"))
|
||||
dests = NULL;
|
||||
|
||||
/*
|
||||
* See if this is a printer we're interested in...
|
||||
*/
|
||||
@@ -366,7 +371,8 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
*ptr != '\0' && *dptr != '\0' && *ptr == *dptr;
|
||||
ptr ++, dptr ++);
|
||||
|
||||
if (*ptr == '\0' && (*dptr == '\0' || *dptr == ',' || isspace(*dptr & 255)))
|
||||
if (*ptr == '\0' && (*dptr == '\0' || *dptr == ',' ||
|
||||
isspace(*dptr & 255)))
|
||||
{
|
||||
match = 1;
|
||||
break;
|
||||
@@ -392,84 +398,46 @@ show_status(http_t *http, /* I - HTTP connection to server */
|
||||
|
||||
if (match)
|
||||
{
|
||||
/*
|
||||
* If the printer state is "IPP_PRINTER_PROCESSING", then grab the
|
||||
* current job for the printer.
|
||||
*/
|
||||
|
||||
if (pstate == IPP_PRINTER_PROCESSING)
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_JOBS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
* limit
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = IPP_GET_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);
|
||||
|
||||
snprintf(printer_uri, sizeof(printer_uri),
|
||||
"ipp://localhost/printers/%s", printer);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
|
||||
"printer-uri", NULL, printer_uri);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
|
||||
"requested-attributes", NULL, "job-id");
|
||||
|
||||
if ((jobs = cupsDoRequest(http, request, "/jobs/")) != NULL)
|
||||
{
|
||||
for (jattr = jobs->attrs; jattr != NULL; jattr = jattr->next)
|
||||
if (jattr->name && strcmp(jattr->name, "job-id") == 0)
|
||||
jobcount ++;
|
||||
|
||||
ippDelete(jobs);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Display it...
|
||||
*/
|
||||
|
||||
printf("%s:\n", printer);
|
||||
if (strncmp(device, "file:", 5) == 0)
|
||||
printf("\tprinter is on device \'%s\' speed -1\n", device + 5);
|
||||
if (!strncmp(device, "file:", 5))
|
||||
_cupsLangPrintf(stdout,
|
||||
_("\tprinter is on device \'%s\' speed -1\n"),
|
||||
device + 5);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just show the method...
|
||||
* Just show the scheme...
|
||||
*/
|
||||
|
||||
if ((delimiter = strchr(device, ':')) != NULL )
|
||||
{
|
||||
*delimiter = '\0';
|
||||
printf("\tprinter is on device \'%s\' speed -1\n", device);
|
||||
*delimiter = '\0';
|
||||
_cupsLangPrintf(stdout,
|
||||
_("\tprinter is on device \'%s\' speed -1\n"),
|
||||
device);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\tqueuing is %sabled\n", accepting ? "en" : "dis");
|
||||
printf("\tprinting is %sabled\n",
|
||||
pstate == IPP_PRINTER_STOPPED ? "dis" : "en");
|
||||
if (jobcount == 0)
|
||||
puts("\tno entries");
|
||||
if (accepting)
|
||||
_cupsLangPuts(stdout, _("\tqueuing is enabled\n"));
|
||||
else
|
||||
printf("\t%d entries\n", jobcount);
|
||||
puts("\tdaemon present");
|
||||
_cupsLangPuts(stdout, _("\tqueuing is disabled\n"));
|
||||
|
||||
if (pstate != IPP_PRINTER_STOPPED)
|
||||
_cupsLangPuts(stdout, _("\tprinting is enabled\n"));
|
||||
else
|
||||
_cupsLangPuts(stdout, _("\tprinting is disabled\n"));
|
||||
|
||||
if (jobcount == 0)
|
||||
_cupsLangPuts(stdout, _("\tno entries\n"));
|
||||
else
|
||||
_cupsLangPrintf(stdout, _("\t%d entries\n"), jobcount);
|
||||
|
||||
_cupsLangPuts(stdout, _("\tdaemon present\n"));
|
||||
}
|
||||
|
||||
if (attr == NULL)
|
||||
|
||||
+211
-156
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* "lpq" command for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2009 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
@@ -41,7 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <cups/string.h>
|
||||
#include <cups/cups.h>
|
||||
#include <cups/language.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <cups/debug.h>
|
||||
|
||||
|
||||
@@ -49,9 +40,10 @@
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static int show_jobs(http_t *, const char *, const char *, const int,
|
||||
const int);
|
||||
static void show_printer(http_t *, const char *);
|
||||
static http_t *connect_server(const char *, http_t *);
|
||||
static int show_jobs(const char *, http_t *, const char *,
|
||||
const char *, const int, const int);
|
||||
static void show_printer(const char *, http_t *, const char *);
|
||||
static void usage(void);
|
||||
|
||||
|
||||
@@ -60,49 +52,38 @@ static void usage(void);
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
http_t *http; /* Connection to server */
|
||||
const char *dest, /* Desired printer */
|
||||
*user, /* Desired user */
|
||||
*val; /* Environment variable name */
|
||||
char *instance; /* Printer instance */
|
||||
int id, /* Desired job ID */
|
||||
all, /* All printers */
|
||||
interval, /* Reporting interval */
|
||||
longstatus; /* Show file details */
|
||||
int num_dests; /* Number of destinations */
|
||||
cups_dest_t *dests; /* Destinations */
|
||||
#ifdef HAVE_SSL
|
||||
http_encryption_t encryption; /* Encryption? */
|
||||
#endif /* HAVE_SSL */
|
||||
int i; /* Looping var */
|
||||
http_t *http; /* Connection to server */
|
||||
const char *dest, /* Desired printer */
|
||||
*user, /* Desired user */
|
||||
*val; /* Environment variable name */
|
||||
char *instance; /* Printer instance */
|
||||
int id, /* Desired job ID */
|
||||
all, /* All printers */
|
||||
interval, /* Reporting interval */
|
||||
longstatus; /* Show file details */
|
||||
int num_dests; /* Number of destinations */
|
||||
cups_dest_t *dests; /* Destinations */
|
||||
|
||||
|
||||
/*
|
||||
* Connect to the scheduler...
|
||||
*/
|
||||
|
||||
if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
|
||||
cupsEncryption())) == NULL)
|
||||
{
|
||||
fputs("lpq: Unable to contact server!\n", stderr);
|
||||
return (1);
|
||||
}
|
||||
_cupsSetLocale(argv);
|
||||
|
||||
/*
|
||||
* Check for command-line options...
|
||||
*/
|
||||
|
||||
http = NULL;
|
||||
dest = NULL;
|
||||
user = NULL;
|
||||
id = 0;
|
||||
interval = 0;
|
||||
longstatus = 0;
|
||||
all = 0;
|
||||
|
||||
num_dests = cupsGetDests(&dests);
|
||||
num_dests = 0;
|
||||
dests = NULL;
|
||||
|
||||
for (i = 1; i < argc; i ++)
|
||||
if (argv[i][0] == '+')
|
||||
@@ -113,16 +94,36 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
{
|
||||
case 'E' : /* Encrypt */
|
||||
#ifdef HAVE_SSL
|
||||
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]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Sorry, no encryption support compiled in!\n"),
|
||||
argv[0]);
|
||||
#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"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
cupsSetUser(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'P' : /* Printer */
|
||||
if (argv[i][2])
|
||||
dest = argv[i] + 2;
|
||||
@@ -144,13 +145,21 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
if ((instance = strchr(dest, '/')) != NULL)
|
||||
*instance++ = '\0';
|
||||
|
||||
http = connect_server(argv[0], http);
|
||||
|
||||
if (num_dests == 0)
|
||||
num_dests = cupsGetDests2(http, &dests);
|
||||
|
||||
if (cupsGetDest(dest, instance, num_dests, dests) == NULL)
|
||||
{
|
||||
if (instance)
|
||||
fprintf(stderr, "lpq: Unknown destination \"%s/%s\"!\n",
|
||||
dest, instance);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unknown destination \"%s/%s\"!\n"),
|
||||
argv[0], dest, instance);
|
||||
else
|
||||
fprintf(stderr, "lpq: Unknown destination \"%s\"!\n", dest);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Unknown destination \"%s\"!\n"),
|
||||
argv[0], dest);
|
||||
|
||||
return (1);
|
||||
}
|
||||
@@ -160,6 +169,32 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
all = 1;
|
||||
break;
|
||||
|
||||
case 'h' : /* Connect to host */
|
||||
if (http)
|
||||
{
|
||||
httpClose(http);
|
||||
http = NULL;
|
||||
}
|
||||
|
||||
if (argv[i][2] != '\0')
|
||||
cupsSetServer(argv[i] + 2);
|
||||
else
|
||||
{
|
||||
i ++;
|
||||
|
||||
if (i >= argc)
|
||||
{
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected hostname after "
|
||||
"\'-h\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
cupsSetServer(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l' : /* Long status */
|
||||
longstatus = 1;
|
||||
break;
|
||||
@@ -177,8 +212,13 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
else
|
||||
user = argv[i];
|
||||
|
||||
http = connect_server(argv[0], http);
|
||||
|
||||
if (dest == NULL && !all)
|
||||
{
|
||||
if (num_dests == 0)
|
||||
num_dests = cupsGetDests2(http, &dests);
|
||||
|
||||
for (i = 0; i < num_dests; i ++)
|
||||
if (dests[i].is_default)
|
||||
dest = dests[i].name;
|
||||
@@ -201,10 +241,14 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
val = "LPDEST";
|
||||
|
||||
if (dest && !cupsGetDest(dest, NULL, num_dests, dests))
|
||||
fprintf(stderr, "lp: error - %s environment variable names non-existent destination \"%s\"!\n",
|
||||
val, dest);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: error - %s environment variable names "
|
||||
"non-existent destination \"%s\"!\n"),
|
||||
argv[0], val, dest);
|
||||
else
|
||||
fputs("lpq: error - no default destination available.\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: error - no default destination available.\n"),
|
||||
argv[0]);
|
||||
httpClose(http);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
return (1);
|
||||
@@ -218,9 +262,9 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
for (;;)
|
||||
{
|
||||
if (dest)
|
||||
show_printer(http, dest);
|
||||
show_printer(argv[0], http, dest);
|
||||
|
||||
i = show_jobs(http, dest, user, id, longstatus);
|
||||
i = show_jobs(argv[0], http, dest, user, id, longstatus);
|
||||
|
||||
if (i && interval)
|
||||
{
|
||||
@@ -242,37 +286,61 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'connect_server()' - Connect to the server as necessary...
|
||||
*/
|
||||
|
||||
static http_t * /* O - New HTTP connection */
|
||||
connect_server(const char *command, /* I - Command name */
|
||||
http_t *http) /* I - Current HTTP connection */
|
||||
{
|
||||
if (!http)
|
||||
{
|
||||
http = httpConnectEncrypt(cupsServer(), ippPort(),
|
||||
cupsEncryption());
|
||||
|
||||
if (http == NULL)
|
||||
{
|
||||
_cupsLangPrintf(stderr, _("%s: Unable to connect to server\n"), command);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return (http);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_jobs()' - Show jobs.
|
||||
*/
|
||||
|
||||
static int /* O - Number of jobs in queue */
|
||||
show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
const char *dest, /* I - Destination */
|
||||
const char *user, /* I - User */
|
||||
const int id, /* I - Job ID */
|
||||
const int longstatus)/* I - 1 if long report desired */
|
||||
static int /* O - Number of jobs in queue */
|
||||
show_jobs(const char *command, /* I - Command name */
|
||||
http_t *http, /* I - HTTP connection to server */
|
||||
const char *dest, /* I - Destination */
|
||||
const char *user, /* I - User */
|
||||
const int id, /* I - Job ID */
|
||||
const int longstatus) /* I - 1 if long report desired */
|
||||
{
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
cups_lang_t *language; /* Default language */
|
||||
const char *jobdest, /* Pointer into job-printer-uri */
|
||||
*jobuser, /* Pointer to job-originating-user-name */
|
||||
*jobname; /* Pointer to job-name */
|
||||
ipp_jstate_t jobstate; /* job-state */
|
||||
int jobid, /* job-id */
|
||||
jobsize, /* job-k-octets */
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
const char *jobdest, /* Pointer into job-printer-uri */
|
||||
*jobuser, /* Pointer to job-originating-user-name */
|
||||
*jobname; /* Pointer to job-name */
|
||||
ipp_jstate_t jobstate; /* job-state */
|
||||
int jobid, /* job-id */
|
||||
jobsize, /* job-k-octets */
|
||||
#ifdef __osf__
|
||||
jobpriority, /* job-priority */
|
||||
jobpriority, /* job-priority */
|
||||
#endif /* __osf__ */
|
||||
jobcount, /* Number of jobs */
|
||||
jobcopies, /* Number of copies */
|
||||
rank; /* Rank of job */
|
||||
char resource[1024]; /* Resource string */
|
||||
char rankstr[255]; /* Rank string */
|
||||
char namestr[1024]; /* Job name string */
|
||||
static const char *ranks[10] =/* Ranking strings */
|
||||
jobcount, /* Number of jobs */
|
||||
jobcopies, /* Number of copies */
|
||||
rank; /* Rank of job */
|
||||
char resource[1024]; /* Resource string */
|
||||
char rankstr[255]; /* Rank string */
|
||||
char namestr[1024]; /* Job name string */
|
||||
static const char *ranks[10] = /* Ranking strings */
|
||||
{
|
||||
"th",
|
||||
"st",
|
||||
@@ -302,36 +370,25 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
* job-uri or printer-uri
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
request = ippNewRequest(id ? IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS);
|
||||
|
||||
request->request.op.operation_id = id ? IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
language = cupsLangDefault();
|
||||
|
||||
attr = ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
|
||||
"attributes-charset", NULL, cupsLangEncoding(language));
|
||||
|
||||
attr = ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
|
||||
"attributes-natural-language", NULL, language->language);
|
||||
|
||||
if (dest == NULL)
|
||||
if (id)
|
||||
{
|
||||
if (id)
|
||||
sprintf(resource, "ipp://localhost/jobs/%d", id);
|
||||
else
|
||||
strcpy(resource, "ipp://localhost/jobs");
|
||||
|
||||
snprintf(resource, sizeof(resource), "ipp://localhost/jobs/%d", id);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
|
||||
NULL, resource);
|
||||
}
|
||||
else
|
||||
else if (dest)
|
||||
{
|
||||
snprintf(resource, sizeof(resource), "ipp://localhost/printers/%s", dest);
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, resource, sizeof(resource), "ipp",
|
||||
NULL, "localhost", 0, "/printers/%s", dest);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
|
||||
NULL, resource);
|
||||
}
|
||||
else
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
|
||||
NULL, "ipp://localhost/");
|
||||
|
||||
if (user)
|
||||
{
|
||||
@@ -350,8 +407,7 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
{
|
||||
if (response->request.status.status_code > IPP_OK_CONFLICT)
|
||||
{
|
||||
fprintf(stderr, "lpq: get-jobs failed: %s\n",
|
||||
ippErrorString(response->request.status.status_code));
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
|
||||
ippDelete(response);
|
||||
return (0);
|
||||
}
|
||||
@@ -391,38 +447,38 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
|
||||
while (attr != NULL && attr->group_tag == IPP_TAG_JOB)
|
||||
{
|
||||
if (strcmp(attr->name, "job-id") == 0 &&
|
||||
if (!strcmp(attr->name, "job-id") &&
|
||||
attr->value_tag == IPP_TAG_INTEGER)
|
||||
jobid = attr->values[0].integer;
|
||||
|
||||
if (strcmp(attr->name, "job-k-octets") == 0 &&
|
||||
if (!strcmp(attr->name, "job-k-octets") &&
|
||||
attr->value_tag == IPP_TAG_INTEGER)
|
||||
jobsize = attr->values[0].integer * 1024;
|
||||
jobsize = attr->values[0].integer;
|
||||
|
||||
#ifdef __osf__
|
||||
if (strcmp(attr->name, "job-priority") == 0 &&
|
||||
if (!strcmp(attr->name, "job-priority") &&
|
||||
attr->value_tag == IPP_TAG_INTEGER)
|
||||
jobpriority = attr->values[0].integer;
|
||||
#endif /* __osf__ */
|
||||
|
||||
if (strcmp(attr->name, "job-state") == 0 &&
|
||||
if (!strcmp(attr->name, "job-state") &&
|
||||
attr->value_tag == IPP_TAG_ENUM)
|
||||
jobstate = (ipp_jstate_t)attr->values[0].integer;
|
||||
|
||||
if (strcmp(attr->name, "job-printer-uri") == 0 &&
|
||||
if (!strcmp(attr->name, "job-printer-uri") &&
|
||||
attr->value_tag == IPP_TAG_URI)
|
||||
if ((jobdest = strrchr(attr->values[0].string.text, '/')) != NULL)
|
||||
jobdest ++;
|
||||
|
||||
if (strcmp(attr->name, "job-originating-user-name") == 0 &&
|
||||
if (!strcmp(attr->name, "job-originating-user-name") &&
|
||||
attr->value_tag == IPP_TAG_NAME)
|
||||
jobuser = attr->values[0].string.text;
|
||||
|
||||
if (strcmp(attr->name, "job-name") == 0 &&
|
||||
if (!strcmp(attr->name, "job-name") &&
|
||||
attr->value_tag == IPP_TAG_NAME)
|
||||
jobname = attr->values[0].string.text;
|
||||
|
||||
if (strcmp(attr->name, "copies") == 0 &&
|
||||
if (!strcmp(attr->name, "copies") &&
|
||||
attr->value_tag == IPP_TAG_INTEGER)
|
||||
jobcopies = attr->values[0].integer;
|
||||
|
||||
@@ -443,9 +499,13 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
|
||||
if (!longstatus && jobcount == 0)
|
||||
#ifdef __osf__
|
||||
puts("Rank Owner Pri Job Files Total Size");
|
||||
_cupsLangPuts(stdout,
|
||||
_("Rank Owner Pri Job Files"
|
||||
" Total Size\n"));
|
||||
#else
|
||||
puts("Rank Owner Job File(s) Total Size");
|
||||
_cupsLangPuts(stdout,
|
||||
_("Rank Owner Job File(s)"
|
||||
" Total Size\n"));
|
||||
#endif /* __osf__ */
|
||||
|
||||
jobcount ++;
|
||||
@@ -473,7 +533,7 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
|
||||
if (longstatus)
|
||||
{
|
||||
puts("");
|
||||
_cupsLangPuts(stdout, "\n");
|
||||
|
||||
if (jobcopies > 1)
|
||||
snprintf(namestr, sizeof(namestr), "%d copies of %s", jobcopies,
|
||||
@@ -481,16 +541,21 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
else
|
||||
strlcpy(namestr, jobname, sizeof(namestr));
|
||||
|
||||
printf("%s: %-33.33s [job %d localhost]\n", jobuser, rankstr, jobid);
|
||||
printf(" %-39.39s %d bytes\n", namestr, jobsize);
|
||||
_cupsLangPrintf(stdout, _("%s: %-33.33s [job %d localhost]\n"),
|
||||
jobuser, rankstr, jobid);
|
||||
_cupsLangPrintf(stdout, _(" %-39.39s %.0f bytes\n"),
|
||||
namestr, 1024.0 * jobsize);
|
||||
}
|
||||
else
|
||||
#ifdef __osf__
|
||||
printf("%-6s %-10.10s %-4d %-10d %-27.27s %d bytes\n", rankstr, jobuser,
|
||||
jobpriority, jobid, jobname, jobsize);
|
||||
_cupsLangPrintf(stdout,
|
||||
_("%-6s %-10.10s %-4d %-10d %-27.27s %.0f bytes\n"),
|
||||
rankstr, jobuser, jobpriority, jobid, jobname,
|
||||
1024.0 * jobsize);
|
||||
#else
|
||||
printf("%-7s %-7.7s %-7d %-31.31s %d bytes\n", rankstr, jobuser,
|
||||
jobid, jobname, jobsize);
|
||||
_cupsLangPrintf(stdout,
|
||||
_("%-7s %-7.7s %-7d %-31.31s %.0f bytes\n"),
|
||||
rankstr, jobuser, jobid, jobname, 1024.0 * jobsize);
|
||||
#endif /* __osf */
|
||||
|
||||
if (attr == NULL)
|
||||
@@ -501,12 +566,12 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "lpq: get-jobs failed: %s\n", ippErrorString(cupsLastError()));
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (jobcount == 0)
|
||||
puts("no entries");
|
||||
_cupsLangPuts(stdout, _("no entries\n"));
|
||||
|
||||
return (jobcount);
|
||||
}
|
||||
@@ -517,16 +582,15 @@ show_jobs(http_t *http, /* I - HTTP connection to server */
|
||||
*/
|
||||
|
||||
static void
|
||||
show_printer(http_t *http, /* I - HTTP connection to server */
|
||||
const char *dest) /* I - Destination */
|
||||
show_printer(const char *command, /* I - Command name */
|
||||
http_t *http, /* I - HTTP connection to server */
|
||||
const char *dest) /* I - Destination */
|
||||
{
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
cups_lang_t *language; /* Default language */
|
||||
ipp_pstate_t state; /* Printer state */
|
||||
char uri[HTTP_MAX_URI];
|
||||
/* Printer URI */
|
||||
ipp_t *request, /* IPP Request */
|
||||
*response; /* IPP Response */
|
||||
ipp_attribute_t *attr; /* Current attribute */
|
||||
ipp_pstate_t state; /* Printer state */
|
||||
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||
|
||||
|
||||
if (http == NULL)
|
||||
@@ -541,20 +605,10 @@ show_printer(http_t *http, /* I - HTTP connection to server */
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
|
||||
|
||||
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
|
||||
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);
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", dest);
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
|
||||
"localhost", 0, "/printers/%s", dest);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
|
||||
"printer-uri", NULL, uri);
|
||||
|
||||
@@ -566,8 +620,7 @@ show_printer(http_t *http, /* I - HTTP connection to server */
|
||||
{
|
||||
if (response->request.status.status_code > IPP_OK_CONFLICT)
|
||||
{
|
||||
fprintf(stderr, "lpq: get-printer-attributes failed: %s\n",
|
||||
ippErrorString(response->request.status.status_code));
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
|
||||
ippDelete(response);
|
||||
return;
|
||||
}
|
||||
@@ -580,21 +633,21 @@ show_printer(http_t *http, /* I - HTTP connection to server */
|
||||
switch (state)
|
||||
{
|
||||
case IPP_PRINTER_IDLE :
|
||||
printf("%s is ready\n", dest);
|
||||
_cupsLangPrintf(stdout, _("%s is ready\n"), dest);
|
||||
break;
|
||||
case IPP_PRINTER_PROCESSING :
|
||||
printf("%s is ready and printing\n", dest);
|
||||
_cupsLangPrintf(stdout, _("%s is ready and printing\n"),
|
||||
dest);
|
||||
break;
|
||||
case IPP_PRINTER_STOPPED :
|
||||
printf("%s is not ready\n", dest);
|
||||
_cupsLangPrintf(stdout, _("%s is not ready\n"), dest);
|
||||
break;
|
||||
}
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "lpq: get-printer-attributes failed: %s\n",
|
||||
ippErrorString(cupsLastError()));
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
|
||||
}
|
||||
|
||||
|
||||
@@ -605,7 +658,9 @@ show_printer(http_t *http, /* I - HTTP connection to server */
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fputs("Usage: lpq [-P dest] [-l] [+interval]\n", stderr);
|
||||
_cupsLangPuts(stderr,
|
||||
_("Usage: lpq [-P dest] [-U username] [-h hostname[:port]] "
|
||||
"[-l] [+interval]\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
+155
-88
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* "lpr" command for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2007 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
@@ -37,7 +28,7 @@
|
||||
|
||||
#include <cups/string.h>
|
||||
#include <cups/cups.h>
|
||||
|
||||
#include <cups/i18n.h>
|
||||
|
||||
#ifndef WIN32
|
||||
# include <unistd.h>
|
||||
@@ -64,33 +55,37 @@ char tempfile[1024]; /* Temporary file for printing from stdin */
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
int i, j; /* Looping var */
|
||||
int job_id; /* Job ID */
|
||||
char ch; /* Option character */
|
||||
char *printer, /* Destination printer or class */
|
||||
*instance; /* Instance */
|
||||
const char *title, /* Job title */
|
||||
*val; /* Environment variable name */
|
||||
int num_copies; /* Number of copies per file */
|
||||
int num_files; /* Number of files to print */
|
||||
const char *files[1000]; /* Files to print */
|
||||
int num_dests; /* Number of destinations */
|
||||
cups_dest_t *dests, /* Destinations */
|
||||
*dest; /* Selected destination */
|
||||
int num_options; /* Number of options */
|
||||
cups_option_t *options; /* Options */
|
||||
int deletefile; /* Delete file after print? */
|
||||
char buffer[8192]; /* Copy buffer */
|
||||
int temp; /* Temporary file descriptor */
|
||||
int i, j; /* Looping var */
|
||||
int job_id; /* Job ID */
|
||||
char ch; /* Option character */
|
||||
char *printer, /* Destination printer or class */
|
||||
*instance; /* Instance */
|
||||
const char *title, /* Job title */
|
||||
*val; /* Environment variable name */
|
||||
int num_copies; /* Number of copies per file */
|
||||
int num_files; /* Number of files to print */
|
||||
const char *files[1000]; /* Files to print */
|
||||
int num_dests; /* Number of destinations */
|
||||
cups_dest_t *dests, /* Destinations */
|
||||
*dest; /* Selected destination */
|
||||
int num_options; /* Number of options */
|
||||
cups_option_t *options; /* Options */
|
||||
int deletefile; /* Delete file after print? */
|
||||
char buffer[8192]; /* Copy buffer */
|
||||
ssize_t bytes; /* Bytes copied */
|
||||
off_t filesize; /* Size of temp file */
|
||||
int temp; /* Temporary file descriptor */
|
||||
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
||||
struct sigaction action; /* Signal action */
|
||||
struct sigaction oldaction; /* Old signal action */
|
||||
struct sigaction action; /* Signal action */
|
||||
struct sigaction oldaction; /* Old signal action */
|
||||
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
||||
|
||||
|
||||
_cupsSetLocale(argv);
|
||||
|
||||
deletefile = 0;
|
||||
printer = NULL;
|
||||
num_dests = 0;
|
||||
@@ -108,11 +103,51 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
#ifdef HAVE_SSL
|
||||
cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
|
||||
#else
|
||||
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
|
||||
argv[0]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Sorry, no encryption support compiled in!\n"),
|
||||
argv[0]);
|
||||
#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"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
cupsSetUser(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'H' : /* Connect to host */
|
||||
if (argv[i][2] != '\0')
|
||||
cupsSetServer(argv[i] + 2);
|
||||
else
|
||||
{
|
||||
i ++;
|
||||
|
||||
if (i >= argc)
|
||||
{
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected hostname after "
|
||||
"\'-H\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
cupsSetServer(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case '1' : /* TROFF font set 1 */
|
||||
case '2' : /* TROFF font set 2 */
|
||||
case '3' : /* TROFF font set 3 */
|
||||
@@ -125,7 +160,9 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
if (i >= argc)
|
||||
{
|
||||
fprintf(stderr, "lpr: error - expected value after -%c option!\n", ch);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected value after \'-%c\' "
|
||||
"option!\n"), argv[0], ch);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@@ -137,8 +174,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
case 'n' : /* Ditroff */
|
||||
case 't' : /* Troff */
|
||||
case 'v' : /* Raster image */
|
||||
fprintf(stderr, "lpr: warning - \'%c\' format modifier not supported - output may not be correct!\n",
|
||||
ch);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Warning - \'%c\' format modifier not "
|
||||
"supported - output may not be correct!\n"),
|
||||
argv[0], ch);
|
||||
break;
|
||||
|
||||
case 'o' : /* Option */
|
||||
@@ -149,7 +188,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
i ++;
|
||||
if (i >= argc)
|
||||
{
|
||||
fputs("lpr: error - expected option=value after -o option!\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: error - expected option=value after "
|
||||
"\'-o\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -158,22 +200,32 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
break;
|
||||
|
||||
case 'l' : /* Literal/raw */
|
||||
num_options = cupsAddOption("raw", "", num_options, &options);
|
||||
num_options = cupsAddOption("raw", "true", num_options, &options);
|
||||
break;
|
||||
|
||||
case 'p' : /* Prettyprint */
|
||||
num_options = cupsAddOption("prettyprint", "", num_options, &options);
|
||||
num_options = cupsAddOption("prettyprint", "true", num_options,
|
||||
&options);
|
||||
break;
|
||||
|
||||
case 'h' : /* Suppress burst page */
|
||||
num_options = cupsAddOption("job-sheets", "none", num_options, &options);
|
||||
num_options = cupsAddOption("job-sheets", "none", num_options,
|
||||
&options);
|
||||
break;
|
||||
|
||||
case 's' : /* Don't use symlinks */
|
||||
break;
|
||||
|
||||
case 'm' : /* Mail on completion */
|
||||
fputs("lpr: warning - email notification is not currently supported!\n", stderr);
|
||||
{
|
||||
char email[1024]; /* EMail address */
|
||||
|
||||
|
||||
snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(),
|
||||
httpGetHostname(NULL, buffer, sizeof(buffer)));
|
||||
num_options = cupsAddOption("notify-recipient-uri", email,
|
||||
num_options, &options);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q' : /* Queue file but don't print */
|
||||
@@ -193,7 +245,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
i ++;
|
||||
if (i >= argc)
|
||||
{
|
||||
fputs("lpr: error - expected destination after -P option!\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected destination after "
|
||||
"\'-P\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -209,7 +264,8 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
if ((dest = cupsGetDest(printer, instance, num_dests, dests)) != NULL)
|
||||
{
|
||||
for (j = 0; j < dest->num_options; j ++)
|
||||
if (cupsGetOption(dest->options[j].name, num_options, options) == NULL)
|
||||
if (cupsGetOption(dest->options[j].name, num_options,
|
||||
options) == NULL)
|
||||
num_options = cupsAddOption(dest->options[j].name,
|
||||
dest->options[j].value,
|
||||
num_options, &options);
|
||||
@@ -224,7 +280,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
i ++;
|
||||
if (i >= argc)
|
||||
{
|
||||
fputs("lpr: error - expected copy count after -# option!\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected copy count after "
|
||||
"\'-#\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -245,7 +304,9 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
i ++;
|
||||
if (i >= argc)
|
||||
{
|
||||
fprintf(stderr, "lpr: error - expected name after -%c option!\n", ch);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected name after \'-%c\' "
|
||||
"option!\n"), argv[0], ch);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -253,24 +314,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
break;
|
||||
|
||||
case 'U' : /* User */
|
||||
if (argv[i][2] != '\0')
|
||||
cupsSetUser(argv[i] + 2);
|
||||
else
|
||||
{
|
||||
i ++;
|
||||
if (i >= argc)
|
||||
{
|
||||
fputs("lpr: error - expected username after -U option!\n", stderr);
|
||||
return (1);
|
||||
}
|
||||
|
||||
cupsSetUser(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
fprintf(stderr, "lpr: error - unknown option \'%c\'!\n", argv[i][1]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unknown option \'%c\'!\n"),
|
||||
argv[0], argv[i][1]);
|
||||
return (1);
|
||||
}
|
||||
else if (num_files < 1000)
|
||||
@@ -281,8 +328,9 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
if (access(argv[i], R_OK) != 0)
|
||||
{
|
||||
fprintf(stderr, "lpr: error - unable to access \"%s\" - %s\n", argv[i],
|
||||
strerror(errno));
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unable to access \"%s\" - %s\n"),
|
||||
argv[0], argv[i], strerror(errno));
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -298,7 +346,9 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "lpr: error - too many files - \"%s\"\n", argv[i]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - too many files - \"%s\"\n"),
|
||||
argv[0], argv[i]);
|
||||
/*
|
||||
* See if we have any files to print; if not, print from stdin...
|
||||
*/
|
||||
@@ -338,12 +388,18 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
val = "LPDEST";
|
||||
|
||||
if (printer && !cupsGetDest(printer, NULL, num_dests, dests))
|
||||
fprintf(stderr, "lpr: error - %s environment variable names non-existent destination \"%s\"!\n",
|
||||
val, printer);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - %s environment variable names "
|
||||
"non-existent destination \"%s\"!\n"),
|
||||
argv[0], val, printer);
|
||||
else if (cupsLastError() == IPP_NOT_FOUND)
|
||||
fputs("lpr: error - no default destination available.\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - no default destination available.\n"),
|
||||
argv[0]);
|
||||
else
|
||||
fputs("lpr: error - scheduler not responding!\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - scheduler not responding!\n"),
|
||||
argv[0]);
|
||||
|
||||
return (1);
|
||||
}
|
||||
@@ -364,8 +420,6 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
else
|
||||
{
|
||||
num_files = 1;
|
||||
|
||||
#ifndef WIN32
|
||||
# if defined(HAVE_SIGSET)
|
||||
sigset(SIGHUP, sighandler);
|
||||
@@ -391,20 +445,34 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
if ((temp = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
|
||||
{
|
||||
fprintf(stderr, "lpr: error - unable to create temporary file \"%s\" - %s\n",
|
||||
tempfile, strerror(errno));
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unable to create temporary file "
|
||||
"\"%s\" - %s\n"),
|
||||
argv[0], tempfile, strerror(errno));
|
||||
return (1);
|
||||
}
|
||||
|
||||
while ((i = read(0, buffer, sizeof(buffer))) > 0)
|
||||
write(temp, buffer, i);
|
||||
while ((bytes = read(0, buffer, sizeof(buffer))) > 0)
|
||||
if (write(temp, buffer, bytes) < 0)
|
||||
{
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unable to write to temporary file "
|
||||
"\"%s\" - %s\n"),
|
||||
argv[0], tempfile, strerror(errno));
|
||||
close(temp);
|
||||
unlink(tempfile);
|
||||
return (1);
|
||||
}
|
||||
|
||||
i = lseek(temp, 0, SEEK_CUR);
|
||||
filesize = lseek(temp, 0, SEEK_CUR);
|
||||
close(temp);
|
||||
|
||||
if (i == 0)
|
||||
if (filesize <= 0)
|
||||
{
|
||||
fputs("lpr: error - stdin is empty, so no job has been sent.\n", stderr);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - stdin is empty, so no job has been sent.\n"),
|
||||
argv[0]);
|
||||
unlink(tempfile);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -418,8 +486,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
if (job_id < 1)
|
||||
{
|
||||
fprintf(stderr, "lpr: error - unable to print file: %s\n",
|
||||
ippErrorString(cupsLastError()));
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -433,7 +500,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
*/
|
||||
|
||||
void
|
||||
sighandler(int s) /* I - Signal number */
|
||||
sighandler(int s) /* I - Signal number */
|
||||
{
|
||||
/*
|
||||
* Remove the temporary file we're using to print from stdin...
|
||||
|
||||
+89
-76
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* "lprm" command for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
@@ -34,7 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cups/cups.h>
|
||||
#include <cups/language.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <cups/string.h>
|
||||
|
||||
|
||||
@@ -55,12 +46,14 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
ipp_t *request; /* IPP request */
|
||||
ipp_t *response; /* IPP response */
|
||||
ipp_op_t op; /* Operation */
|
||||
cups_lang_t *language; /* Language */
|
||||
int num_dests; /* Number of destinations */
|
||||
cups_dest_t *dests; /* Destinations */
|
||||
cups_dest_t *dests, /* Destinations */
|
||||
*defdest; /* Default destination */
|
||||
http_encryption_t encryption; /* Encryption? */
|
||||
|
||||
|
||||
_cupsSetLocale(argv);
|
||||
|
||||
/*
|
||||
* Setup to cancel individual print jobs...
|
||||
*/
|
||||
@@ -72,23 +65,20 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
http = NULL;
|
||||
encryption = cupsEncryption();
|
||||
|
||||
num_dests = cupsGetDests(&dests);
|
||||
|
||||
for (i = 0; i < num_dests; i ++)
|
||||
if (dests[i].is_default)
|
||||
dest = dests[i].name;
|
||||
|
||||
/*
|
||||
* Open a connection to the server...
|
||||
*/
|
||||
|
||||
if ((http = httpConnectEncrypt(cupsServer(), ippPort(), encryption)) == NULL)
|
||||
{
|
||||
fputs("lprm: Unable to contact server!\n", stderr);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
_cupsLangPuts(stderr, _("lprm: Unable to contact server!\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
num_dests = cupsGetDests2(http, &dests);
|
||||
defdest = cupsGetDest(NULL, NULL, num_dests, dests);
|
||||
dest = defdest ? defdest->name : NULL;
|
||||
|
||||
/*
|
||||
* Process command-line arguments...
|
||||
*/
|
||||
@@ -102,9 +92,11 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
encryption = HTTP_ENCRYPT_REQUIRED;
|
||||
|
||||
httpEncryption(http, encryption);
|
||||
cupsSetEncryption(encryption);
|
||||
#else
|
||||
fprintf(stderr, "%s: Sorry, no encryption support compiled in!\n",
|
||||
argv[0]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Sorry, no encryption support compiled in!\n"),
|
||||
argv[0]);
|
||||
#endif /* HAVE_SSL */
|
||||
break;
|
||||
|
||||
@@ -122,15 +114,72 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
if (cupsGetDest(dest, NULL, num_dests, dests) == NULL)
|
||||
{
|
||||
fprintf(stderr, "lprm: Unknown destination \"%s\"!\n", dest);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unknown destination \"%s\"!\n"),
|
||||
argv[0], dest);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
httpClose(http);
|
||||
return(1);
|
||||
}
|
||||
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"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
cupsSetUser(argv[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h' : /* Connect to host */
|
||||
if (argv[i][2] != '\0')
|
||||
cupsSetServer(argv[i] + 2);
|
||||
else
|
||||
{
|
||||
i ++;
|
||||
|
||||
if (i >= argc)
|
||||
{
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - expected hostname after "
|
||||
"\'-h\' option!\n"),
|
||||
argv[0]);
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
cupsSetServer(argv[i]);
|
||||
}
|
||||
|
||||
httpClose(http);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
|
||||
if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
|
||||
encryption)) == NULL)
|
||||
{
|
||||
_cupsLangPuts(stderr, _("lprm: Unable to contact server!\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
num_dests = cupsGetDests2(http, &dests);
|
||||
defdest = cupsGetDest(NULL, NULL, num_dests, dests);
|
||||
dest = defdest ? defdest->name : NULL;
|
||||
break;
|
||||
|
||||
default :
|
||||
fprintf(stderr, "lprm: Unknown option \'%c\'!\n", argv[i][1]);
|
||||
_cupsLangPrintf(stderr,
|
||||
_("%s: Error - unknown option \'%c\'!\n"),
|
||||
argv[0], argv[i][1]);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
httpClose(http);
|
||||
return (1);
|
||||
@@ -148,7 +197,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
op = IPP_CANCEL_JOB;
|
||||
job_id = atoi(argv[i]);
|
||||
}
|
||||
else if (strcmp(argv[i], "-") == 0)
|
||||
else if (!strcmp(argv[i], "-"))
|
||||
{
|
||||
/*
|
||||
* Cancel all jobs
|
||||
@@ -172,22 +221,12 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
* [requesting-user-name]
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = op;
|
||||
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(op);
|
||||
|
||||
if (dest)
|
||||
{
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", dest);
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
|
||||
"localhost", 0, "/printers/%s", dest);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
|
||||
"printer-uri", NULL, uri);
|
||||
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
|
||||
@@ -212,38 +251,12 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
else
|
||||
response = cupsDoRequest(http, request, "/jobs/");
|
||||
|
||||
if (response != NULL)
|
||||
{
|
||||
switch (response->request.status.status_code)
|
||||
{
|
||||
case IPP_NOT_FOUND :
|
||||
fputs("lprm: Job or printer not found!\n", stderr);
|
||||
break;
|
||||
case IPP_NOT_AUTHORIZED :
|
||||
fputs("lprm: Not authorized to lprm job(s)!\n", stderr);
|
||||
break;
|
||||
case IPP_FORBIDDEN :
|
||||
fprintf(stderr, "lprm: You don't own job ID %d!\n", job_id);
|
||||
break;
|
||||
default :
|
||||
if (response->request.status.status_code > IPP_OK_CONFLICT)
|
||||
fputs("lprm: Unable to lprm job(s)!\n", stderr);
|
||||
break;
|
||||
}
|
||||
ippDelete(response);
|
||||
|
||||
if (response->request.status.status_code > IPP_OK_CONFLICT)
|
||||
{
|
||||
ippDelete(response);
|
||||
cupsFreeDests(num_dests, dests);
|
||||
httpClose(http);
|
||||
return (1);
|
||||
}
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
if (cupsLastError() > IPP_OK_CONFLICT)
|
||||
{
|
||||
fputs("lprm: Unable to cancel job(s)!\n", stderr);
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
|
||||
|
||||
cupsFreeDests(num_dests, dests);
|
||||
httpClose(http);
|
||||
return (1);
|
||||
@@ -251,14 +264,14 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
/*
|
||||
* If nothing has been cancelled yet, cancel the current job on the specified
|
||||
* If nothing has been canceled yet, cancel the current job on the specified
|
||||
* (or default) printer...
|
||||
*/
|
||||
|
||||
if (response == NULL)
|
||||
if (!cupsCancelJob(dest, 0))
|
||||
{
|
||||
fputs("lprm: Unable to cancel job(s)!\n", stderr);
|
||||
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
|
||||
cupsFreeDests(num_dests, dests);
|
||||
httpClose(http);
|
||||
return (1);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
admin.cgi
|
||||
classes.cgi
|
||||
jobs.cgi
|
||||
libcgi.a
|
||||
printers.cgi
|
||||
+55
-19
@@ -1,20 +1,56 @@
|
||||
# DO NOT DELETE
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
html.o: cgi.h ../cups/string.h ../config.h
|
||||
ipp-var.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
ipp-var.o: ../cups/md5.h ../cups/ppd.h ../cups/debug.h ../cups/language.h
|
||||
ipp-var.o: ../cups/string.h ../config.h cgi.h
|
||||
template.o: cgi.h ../cups/string.h ../config.h
|
||||
var.o: cgi.h ../cups/string.h ../config.h
|
||||
admin.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
admin.o: ../cups/ppd.h ../cups/debug.h ../cups/language.h ../cups/string.h
|
||||
admin.o: ../config.h cgi.h
|
||||
classes.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
classes.o: ../cups/md5.h ../cups/ppd.h ../cups/debug.h ../cups/language.h
|
||||
classes.o: ../cups/string.h ../config.h cgi.h
|
||||
jobs.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
|
||||
jobs.o: ../cups/ppd.h ../cups/debug.h ../cups/language.h ../cups/string.h
|
||||
jobs.o: ../config.h cgi.h
|
||||
printers.o: ipp-var.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
printers.o: ../cups/md5.h ../cups/ppd.h ../cups/debug.h ../cups/language.h
|
||||
printers.o: ../cups/string.h ../config.h cgi.h
|
||||
help-index.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
help-index.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
help-index.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
help-index.o: ../cups/transcode.h ../cups/string.h ../config.h ../cups/dir.h
|
||||
html.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
html.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
html.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
html.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
ipp-var.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
ipp-var.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
ipp-var.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
ipp-var.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
search.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
search.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
search.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
search.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
template.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
template.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
template.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
template.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
var.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
var.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
var.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
var.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
admin.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
admin.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
admin.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
admin.o: ../cups/transcode.h ../cups/string.h ../config.h ../cups/adminutil.h
|
||||
admin.o: ../cups/cups.h ../cups/file.h
|
||||
classes.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
classes.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
classes.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
classes.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
help.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
help.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
help.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
help.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
jobs.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
jobs.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
jobs.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
jobs.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
printers.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
printers.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
|
||||
printers.o: ../cups/array.h help-index.h ../cups/debug.h ../cups/i18n.h
|
||||
printers.o: ../cups/transcode.h ../cups/string.h ../config.h
|
||||
testcgi.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
testcgi.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/array.h
|
||||
testcgi.o: help-index.h
|
||||
testhi.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
|
||||
testhi.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/array.h
|
||||
testhi.o: help-index.h
|
||||
testtemplate.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
|
||||
testtemplate.o: ../cups/ppd.h ../cups/array.h ../cups/file.h
|
||||
testtemplate.o: ../cups/language.h ../cups/array.h help-index.h
|
||||
|
||||
+68
-20
@@ -3,31 +3,23 @@
|
||||
#
|
||||
# CGI makefile for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products.
|
||||
# Copyright 2007 by Apple Inc.
|
||||
# Copyright 1997-2006 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-3142 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
include ../Makedefs
|
||||
|
||||
CGIS = admin.cgi classes.cgi jobs.cgi printers.cgi
|
||||
TARGETS = libcgi.a $(CGIS)
|
||||
LIBOBJS = html.o ipp-var.o template.o var.o
|
||||
OBJS = $(LIBOBJS) admin.o classes.o jobs.o printers.o
|
||||
CGIS = admin.cgi classes.cgi help.cgi jobs.cgi printers.cgi
|
||||
TARGETS = libcgi.a $(CGIS) testcgi testhi testtemplate
|
||||
LIBOBJS = help-index.o html.o ipp-var.o search.o template.o var.o
|
||||
OBJS = $(LIBOBJS) admin.o classes.o help.o \
|
||||
jobs.o printers.o testcgi.o testhi.o testtemplate.o
|
||||
|
||||
|
||||
#
|
||||
@@ -58,10 +50,27 @@ depend:
|
||||
#
|
||||
|
||||
install: all
|
||||
$(INSTALL_DIR) $(SERVERBIN)/cgi-bin
|
||||
$(INSTALL_DIR) -m 755 $(SERVERBIN)/cgi-bin
|
||||
for file in $(CGIS); do \
|
||||
$(INSTALL_BIN) $$file $(SERVERBIN)/cgi-bin; \
|
||||
done
|
||||
if test "x$(SYMROOT)" != "x"; then \
|
||||
$(INSTALL_DIR) $(SYMROOT); \
|
||||
for file in $(TARGETS); do \
|
||||
cp $$file $(SYMROOT); \
|
||||
done \
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Uninstall all targets...
|
||||
#
|
||||
|
||||
uninstall:
|
||||
for file in $(CGIS); do \
|
||||
$(RM) $(SERVERBIN)/cgi-bin/$$file; \
|
||||
done
|
||||
-$(RMDIR) $(SERVERBIN)/cgi-bin
|
||||
|
||||
|
||||
#
|
||||
@@ -93,6 +102,15 @@ classes.cgi: classes.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
|
||||
$(CC) $(LDFLAGS) -o $@ classes.o libcgi.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# help.cgi
|
||||
#
|
||||
|
||||
help.cgi: help.o ../Makedefs libcgi.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o $@ help.o libcgi.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# jobs.cgi
|
||||
#
|
||||
@@ -111,6 +129,36 @@ printers.cgi: printers.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
|
||||
$(CC) $(LDFLAGS) -o $@ printers.o libcgi.a $(LIBS)
|
||||
|
||||
|
||||
#
|
||||
# testcgi
|
||||
#
|
||||
|
||||
testcgi: testcgi.o ../Makedefs libcgi.a ../cups/libcups.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o $@ testcgi.o libcgi.a ../cups/libcups.a \
|
||||
$(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI)
|
||||
|
||||
|
||||
#
|
||||
# testhi
|
||||
#
|
||||
|
||||
testhi: testhi.o ../Makedefs libcgi.a ../cups/libcups.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o $@ testhi.o libcgi.a ../cups/libcups.a \
|
||||
$(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI)
|
||||
|
||||
|
||||
#
|
||||
# testtemplate
|
||||
#
|
||||
|
||||
testtemplate: testtemplate.o ../Makedefs libcgi.a ../cups/libcups.a
|
||||
echo Linking $@...
|
||||
$(CC) $(LDFLAGS) -o $@ testtemplate.o libcgi.a ../cups/libcups.a \
|
||||
$(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI)
|
||||
|
||||
|
||||
#
|
||||
# Dependencies...
|
||||
#
|
||||
|
||||
+2731
-875
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Private CGI definitions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
#include <cups/debug.h>
|
||||
#include <cups/i18n.h>
|
||||
#include <cups/string.h>
|
||||
|
||||
|
||||
/*
|
||||
* Limits...
|
||||
*/
|
||||
|
||||
#define CUPS_PAGE_MAX 10 /* Maximum items per page */
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+59
-45
@@ -3,83 +3,97 @@
|
||||
*
|
||||
* CGI support library definitions.
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*/
|
||||
|
||||
#ifndef _CGI_H_
|
||||
# define _CGI_H_
|
||||
#ifndef _CUPS_CGI_H_
|
||||
# define _CUPS_CGI_H_
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
|
||||
# include <cups/string.h>
|
||||
# include <sys/stat.h>
|
||||
|
||||
# ifdef WIN32
|
||||
# include <direct.h>
|
||||
# include <io.h>
|
||||
# include <malloc.h>
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif /* WIN32 */
|
||||
|
||||
# include <cups/cups.h>
|
||||
# include <cups/array.h>
|
||||
# include "help-index.h"
|
||||
|
||||
|
||||
/*
|
||||
* Types...
|
||||
*/
|
||||
|
||||
typedef struct cgi_file_s /**** Uploaded file data ****/
|
||||
{
|
||||
char tempfile[1024], /* Temporary file containing data */
|
||||
*name, /* Variable name */
|
||||
*filename, /* Original filename */
|
||||
*mimetype; /* MIME media type */
|
||||
size_t filesize; /* Size of uploaded file */
|
||||
} cgi_file_t;
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes...
|
||||
*/
|
||||
|
||||
extern int cgiInitialize(void);
|
||||
extern void cgiAbort(const char *title, const char *stylesheet,
|
||||
const char *format, ...);
|
||||
extern int cgiCheckVariables(const char *names);
|
||||
extern void *cgiCompileSearch(const char *query);
|
||||
extern void cgiCopyTemplateFile(FILE *out, const char *tmpl);
|
||||
extern void cgiCopyTemplateLang(const char *tmpl);
|
||||
extern int cgiDoSearch(void *search, const char *text);
|
||||
extern void cgiEndHTML(void);
|
||||
extern char *cgiFormEncode(char *dst, const char *src, size_t dstsize);
|
||||
extern void cgiFreeSearch(void *search);
|
||||
extern const char *cgiGetArray(const char *name, int element);
|
||||
extern void cgiGetAttributes(ipp_t *request, const char *tmpl);
|
||||
extern char *cgiGetCookie(const char *name, char *buf, int buflen);
|
||||
extern const cgi_file_t *cgiGetFile(void);
|
||||
extern cups_array_t *cgiGetIPPObjects(ipp_t *response, void *search);
|
||||
extern int cgiGetSize(const char *name);
|
||||
extern void cgiSetSize(const char *name, int size);
|
||||
extern char *cgiGetTemplateDir(void);
|
||||
extern const char *cgiGetVariable(const char *name);
|
||||
extern int cgiInitialize(void);
|
||||
extern int cgiIsPOST(void);
|
||||
extern void cgiMoveJobs(http_t *http, const char *dest, int job_id);
|
||||
extern void cgiPrintTestPage(http_t *http, const char *dest);
|
||||
extern char *cgiRewriteURL(const char *uri, char *url, int urlsize,
|
||||
const char *newresource);
|
||||
extern void cgiSetArray(const char *name, int element,
|
||||
const char *value);
|
||||
extern void cgiSetVariable(const char *name, const char *value);
|
||||
extern void cgiCopyTemplateFile(FILE *out, const char *tmpl);
|
||||
extern void cgiCopyTemplateLang(FILE *out, const char *directory,
|
||||
const char *tmpl, const char *lang);
|
||||
|
||||
extern void cgiStartHTML(FILE *out, const char *author,
|
||||
const char *stylesheet,
|
||||
const char *keywords,
|
||||
const char *description,
|
||||
const char *title, ...);
|
||||
extern void cgiEndHTML(FILE *out);
|
||||
|
||||
extern FILE *cgiEMailOpen(const char *from, const char *to,
|
||||
const char *cc, const char *subject,
|
||||
int multipart);
|
||||
extern void cgiEMailPart(FILE *mail, const char *type,
|
||||
const char *charset, const char *encoding);
|
||||
extern void cgiEMailClose(FILE *mail);
|
||||
|
||||
extern char *cgiGetCookie(const char *name, char *buf, int buflen);
|
||||
extern void cgiSetCookie(const char *name, const char *value,
|
||||
const char *path, const char *domain,
|
||||
time_t expires, int secure);
|
||||
extern ipp_attribute_t *cgiSetIPPObjectVars(ipp_attribute_t *obj,
|
||||
const char *prefix, int element);
|
||||
extern int cgiSetIPPVars(ipp_t *response, const char *filter_name,
|
||||
const char *filter_value,
|
||||
const char *prefix, int parent_el);
|
||||
extern void cgiSetServerVersion(void);
|
||||
extern void cgiSetSize(const char *name, int size);
|
||||
extern void cgiSetVariable(const char *name, const char *value);
|
||||
extern void cgiShowIPPError(const char *message);
|
||||
extern void cgiShowJobs(http_t *http, const char *dest);
|
||||
extern void cgiStartHTML(const char *title);
|
||||
extern const char *cgiText(const char *message);
|
||||
|
||||
# define cgiGetUser() getenv("REMOTE_USER")
|
||||
# define cgiGetHost() (getenv("REMOTE_HOST") == NULL ? getenv("REMOTE_ADDR") : getenv("REMOTE_HOST"))
|
||||
|
||||
#endif /* !_CGI_H_ */
|
||||
#endif /* !_CUPS_CGI_H_ */
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
|
||||
+344
-232
@@ -3,34 +3,35 @@
|
||||
*
|
||||
* Class status CGI for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Main entry for CGI.
|
||||
* main() - Main entry for CGI.
|
||||
* show_all_classes() - Show all classes...
|
||||
* show_class() - Show a single class.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "ipp-var.h"
|
||||
#include "cgi-private.h"
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void show_all_classes(http_t *http, const char *username);
|
||||
void show_class(http_t *http, const char *printer);
|
||||
|
||||
|
||||
/*
|
||||
@@ -41,17 +42,14 @@ int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
cups_lang_t *language; /* Language information */
|
||||
char *pclass; /* Printer class name */
|
||||
const char *pclass; /* Class name */
|
||||
const char *user; /* Username */
|
||||
http_t *http; /* Connection to the server */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
ipp_attribute_t *attr; /* IPP attribute */
|
||||
ipp_status_t status; /* Operation status... */
|
||||
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||
const char *which_jobs; /* Which jobs to show */
|
||||
const char *op; /* Operation to perform, if any */
|
||||
static const char *def_attrs[] = /* Attributes for default printer */
|
||||
static const char *def_attrs[] = /* Attributes for default printer */
|
||||
{
|
||||
"printer-name",
|
||||
"printer-uri-supported"
|
||||
@@ -63,59 +61,50 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
*/
|
||||
|
||||
cgiInitialize();
|
||||
|
||||
op = cgiGetVariable("OP");
|
||||
|
||||
/*
|
||||
* Get the request language...
|
||||
* Set the web interface section...
|
||||
*/
|
||||
|
||||
language = cupsLangDefault();
|
||||
cgiSetVariable("SECTION", "classes");
|
||||
|
||||
/*
|
||||
* See if we are displaying a printer or all classes...
|
||||
*/
|
||||
|
||||
if ((pclass = getenv("PATH_INFO")) != NULL)
|
||||
{
|
||||
pclass ++;
|
||||
|
||||
if (!*pclass)
|
||||
pclass = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* See who is logged in...
|
||||
*/
|
||||
|
||||
user = getenv("REMOTE_USER");
|
||||
|
||||
/*
|
||||
* Connect to the HTTP server...
|
||||
*/
|
||||
|
||||
http = httpConnectEncrypt("localhost", ippPort(), cupsEncryption());
|
||||
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
|
||||
|
||||
/*
|
||||
* Tell the client to expect HTML...
|
||||
* Get the default printer...
|
||||
*/
|
||||
|
||||
printf("Content-Type: text/html;charset=%s\n\n", cupsLangEncoding(language));
|
||||
|
||||
/*
|
||||
* See if we need to show a list of printers or the status of a
|
||||
* single printer...
|
||||
*/
|
||||
|
||||
ippSetServerVersion();
|
||||
|
||||
pclass = argv[0];
|
||||
if (strcmp(pclass, "/") == 0 || strcmp(pclass, "classes.cgi") == 0)
|
||||
{
|
||||
pclass = NULL;
|
||||
cgiSetVariable("TITLE", cupsLangString(language, CUPS_MSG_CLASS));
|
||||
}
|
||||
else
|
||||
cgiSetVariable("TITLE", pclass);
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "header.tmpl", getenv("LANG"));
|
||||
|
||||
if (op == NULL || strcasecmp(op, "print-test-page") != 0)
|
||||
if (!op)
|
||||
{
|
||||
/*
|
||||
* Get the default destination...
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
request->request.op.operation_id = CUPS_GET_DEFAULT;
|
||||
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);
|
||||
request = ippNewRequest(CUPS_GET_DEFAULT);
|
||||
|
||||
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
|
||||
"requested-attributes",
|
||||
@@ -132,7 +121,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
|
||||
cgiSetVariable("DEFAULT_URI",
|
||||
ippRewriteURL(attr->values[0].string.text,
|
||||
cgiRewriteURL(attr->values[0].string.text,
|
||||
url, sizeof(url), NULL));
|
||||
}
|
||||
|
||||
@@ -140,198 +129,39 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the class info...
|
||||
* See if we need to show a list of classes or the status of a
|
||||
* single printer...
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
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);
|
||||
|
||||
if (pclass == NULL)
|
||||
{
|
||||
/*
|
||||
* Build a CUPS_GET_CLASSES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
*/
|
||||
|
||||
request->request.op.operation_id = CUPS_GET_CLASSES;
|
||||
request->request.op.request_id = 1;
|
||||
}
|
||||
if (!pclass)
|
||||
show_all_classes(http, user);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://%s/classes/%s", getenv("SERVER_NAME"),
|
||||
pclass);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
}
|
||||
|
||||
ippGetAttributes(request, TEMPLATES, "classes.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
ippDelete(response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the report...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "classes.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Get jobs for the specified class if a class has been chosen...
|
||||
*/
|
||||
|
||||
if (pclass != NULL)
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_JOBS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
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->request.op.operation_id = IPP_GET_JOBS;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://%s/classes/%s", getenv("SERVER_NAME"),
|
||||
pclass);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
|
||||
if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
|
||||
NULL, which_jobs);
|
||||
|
||||
ippGetAttributes(request, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
ippDelete(response);
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
}
|
||||
}
|
||||
show_class(http, pclass);
|
||||
}
|
||||
else if (!strcasecmp(op, "print-test-page") && pclass)
|
||||
cgiPrintTestPage(http, pclass);
|
||||
else if (!strcasecmp(op, "move-jobs") && pclass)
|
||||
cgiMoveJobs(http, pclass, 0);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Print a test page...
|
||||
* Unknown/bad operation...
|
||||
*/
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/classes/%s", pclass);
|
||||
|
||||
/*
|
||||
* Build an IPP_PRINT_JOB request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
* requesting-user-name
|
||||
* document-format
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = IPP_PRINT_JOB;
|
||||
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);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
|
||||
NULL, uri);
|
||||
|
||||
if (getenv("REMOTE_USER") != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, getenv("REMOTE_USER"));
|
||||
if (pclass)
|
||||
cgiStartHTML(pclass);
|
||||
else
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, "root");
|
||||
cgiStartHTML(cgiText(_("Classes")));
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
|
||||
NULL, "Test Page");
|
||||
|
||||
ippAddString(request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
|
||||
NULL, "application/postscript");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoFileRequest(http, request, uri + 15,
|
||||
CUPS_DATADIR "/data/testprint.ps")) != NULL)
|
||||
{
|
||||
status = response->request.status.status_code;
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
status = cupsLastError();
|
||||
|
||||
cgiSetVariable("PRINTER_NAME", pclass);
|
||||
|
||||
if (status > IPP_OK_CONFLICT)
|
||||
{
|
||||
cgiSetVariable("ERROR", ippErrorString(status));
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "error.tmpl", getenv("LANG"));
|
||||
}
|
||||
else
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "test-page.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("error-op.tmpl");
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "trailer.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Close the HTTP server connection...
|
||||
*/
|
||||
|
||||
httpClose(http);
|
||||
cupsLangFree(language);
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
@@ -341,6 +171,288 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_all_classes()' - Show all classes...
|
||||
*/
|
||||
|
||||
void
|
||||
show_all_classes(http_t *http, /* I - Connection to server */
|
||||
const char *user) /* I - Username */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
cups_array_t *classes; /* Array of class objects */
|
||||
ipp_attribute_t *pclass; /* Class object */
|
||||
int ascending, /* Order of classes (0 = descending) */
|
||||
first, /* First class to show */
|
||||
count; /* Number of classes */
|
||||
const char *var; /* Form variable */
|
||||
void *search; /* Search data */
|
||||
char url[1024], /* URL for prev/next/this */
|
||||
*urlptr, /* Position in URL */
|
||||
*urlend; /* End of URL */
|
||||
|
||||
|
||||
/*
|
||||
* Show the standard header...
|
||||
*/
|
||||
|
||||
cgiStartHTML(cgiText(_("Classes")));
|
||||
|
||||
/*
|
||||
* Build a CUPS_GET_CLASSES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* requesting-user-name
|
||||
*/
|
||||
|
||||
request = ippNewRequest(CUPS_GET_CLASSES);
|
||||
|
||||
if (user)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"requesting-user-name", NULL, user);
|
||||
|
||||
cgiGetAttributes(request, "classes.tmpl");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
/*
|
||||
* Get a list of matching job objects.
|
||||
*/
|
||||
|
||||
if ((var = cgiGetVariable("QUERY")) != NULL)
|
||||
search = cgiCompileSearch(var);
|
||||
else
|
||||
search = NULL;
|
||||
|
||||
classes = cgiGetIPPObjects(response, search);
|
||||
count = cupsArrayCount(classes);
|
||||
|
||||
if (search)
|
||||
cgiFreeSearch(search);
|
||||
|
||||
/*
|
||||
* Figure out which classes to display...
|
||||
*/
|
||||
|
||||
if ((var = cgiGetVariable("FIRST")) != NULL)
|
||||
first = atoi(var);
|
||||
else
|
||||
first = 0;
|
||||
|
||||
if (first >= count)
|
||||
first = count - CUPS_PAGE_MAX;
|
||||
|
||||
first = (first / CUPS_PAGE_MAX) * CUPS_PAGE_MAX;
|
||||
|
||||
if (first < 0)
|
||||
first = 0;
|
||||
|
||||
sprintf(url, "%d", count);
|
||||
cgiSetVariable("TOTAL", url);
|
||||
|
||||
if ((var = cgiGetVariable("ORDER")) != NULL)
|
||||
ascending = !strcasecmp(var, "asc");
|
||||
else
|
||||
ascending = 1;
|
||||
|
||||
if (ascending)
|
||||
{
|
||||
for (i = 0, pclass = (ipp_attribute_t *)cupsArrayIndex(classes, first);
|
||||
i < CUPS_PAGE_MAX && pclass;
|
||||
i ++, pclass = (ipp_attribute_t *)cupsArrayNext(classes))
|
||||
cgiSetIPPObjectVars(pclass, NULL, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0, pclass = (ipp_attribute_t *)cupsArrayIndex(classes, count - first - 1);
|
||||
i < CUPS_PAGE_MAX && pclass;
|
||||
i ++, pclass = (ipp_attribute_t *)cupsArrayPrev(classes))
|
||||
cgiSetIPPObjectVars(pclass, NULL, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save navigation URLs...
|
||||
*/
|
||||
|
||||
urlend = url + sizeof(url);
|
||||
|
||||
if ((var = cgiGetVariable("QUERY")) != NULL)
|
||||
{
|
||||
strlcpy(url, "/classes/?QUERY=", sizeof(url));
|
||||
urlptr = url + strlen(url);
|
||||
|
||||
cgiFormEncode(urlptr, var, urlend - urlptr);
|
||||
urlptr += strlen(urlptr);
|
||||
|
||||
strlcpy(urlptr, "&", urlend - urlptr);
|
||||
urlptr += strlen(urlptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(url, "/classes/?", sizeof(url));
|
||||
urlptr = url + strlen(url);
|
||||
}
|
||||
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d", first);
|
||||
cgiSetVariable("THISURL", url);
|
||||
|
||||
if (first > 0)
|
||||
{
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
|
||||
first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
|
||||
cgiSetVariable("PREVURL", url);
|
||||
}
|
||||
|
||||
if ((first + CUPS_PAGE_MAX) < count)
|
||||
{
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
|
||||
first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
|
||||
cgiSetVariable("NEXTURL", url);
|
||||
}
|
||||
|
||||
/*
|
||||
* Then show everything...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("search.tmpl");
|
||||
|
||||
cgiCopyTemplateLang("classes-header.tmpl");
|
||||
|
||||
if (count > 0)
|
||||
cgiCopyTemplateLang("pager.tmpl");
|
||||
|
||||
cgiCopyTemplateLang("classes.tmpl");
|
||||
|
||||
if (count > 0)
|
||||
cgiCopyTemplateLang("pager.tmpl");
|
||||
|
||||
/*
|
||||
* Delete the response...
|
||||
*/
|
||||
|
||||
cupsArrayDelete(classes);
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Show the error...
|
||||
*/
|
||||
|
||||
cgiShowIPPError(_("Unable to get class list:"));
|
||||
}
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_class()' - Show a single class.
|
||||
*/
|
||||
|
||||
void
|
||||
show_class(http_t *http, /* I - Connection to server */
|
||||
const char *pclass) /* I - Name of class */
|
||||
{
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
ipp_attribute_t *attr; /* IPP attribute */
|
||||
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||
char refresh[1024]; /* Refresh URL */
|
||||
|
||||
|
||||
/*
|
||||
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
|
||||
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
|
||||
"localhost", 0, "/classes/%s", pclass);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
|
||||
cgiGetAttributes(request, "classes.tmpl");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
/*
|
||||
* Got the result; set the CGI variables and check the status of a
|
||||
* single-queue request...
|
||||
*/
|
||||
|
||||
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
|
||||
|
||||
if (pclass && (attr = ippFindAttribute(response, "printer-state",
|
||||
IPP_TAG_ENUM)) != NULL &&
|
||||
attr->values[0].integer == IPP_PRINTER_PROCESSING)
|
||||
{
|
||||
/*
|
||||
* Class is processing - automatically refresh the page until we
|
||||
* are done printing...
|
||||
*/
|
||||
|
||||
cgiFormEncode(uri, pclass, sizeof(uri));
|
||||
snprintf(refresh, sizeof(refresh), "10;URL=/classes/%s", uri);
|
||||
cgiSetVariable("refresh_page", refresh);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the response...
|
||||
*/
|
||||
|
||||
ippDelete(response);
|
||||
|
||||
/*
|
||||
* Show the standard header...
|
||||
*/
|
||||
|
||||
cgiStartHTML(pclass);
|
||||
|
||||
/*
|
||||
* Show the class status...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("classes.tmpl");
|
||||
|
||||
/*
|
||||
* Show jobs for the specified class...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("class-jobs-header.tmpl");
|
||||
cgiShowJobs(http, pclass);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Show the IPP error...
|
||||
*/
|
||||
|
||||
cgiStartHTML(pclass);
|
||||
cgiShowIPPError(_("Unable to get class status:"));
|
||||
}
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* On-line help index definitions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*/
|
||||
|
||||
#ifndef _CUPS_HELP_INDEX_H_
|
||||
# define _CUPS_HELP_INDEX_H_
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
# include <cups/array.h>
|
||||
|
||||
|
||||
/*
|
||||
* Data structures...
|
||||
*/
|
||||
|
||||
typedef struct help_word_s /**** Help word structure... ****/
|
||||
{
|
||||
int count; /* Number of occurrences */
|
||||
char *text; /* Word text */
|
||||
} help_word_t;
|
||||
|
||||
typedef struct help_node_s /**** Help node structure... ****/
|
||||
{
|
||||
char *filename; /* Filename, relative to help dir */
|
||||
char *section; /* Section name (NULL if none) */
|
||||
char *anchor; /* Anchor name (NULL if none) */
|
||||
char *text; /* Text in anchor */
|
||||
cups_array_t *words; /* Words after this node */
|
||||
time_t mtime; /* Last modification time */
|
||||
off_t offset; /* Offset in file */
|
||||
size_t length; /* Length in bytes */
|
||||
int score; /* Search score */
|
||||
} help_node_t;
|
||||
|
||||
typedef struct help_index_s /**** Help index structure ****/
|
||||
{
|
||||
int search; /* 1 = search index, 0 = normal */
|
||||
cups_array_t *nodes; /* Nodes sorted by filename */
|
||||
cups_array_t *sorted; /* Nodes sorted by score + text */
|
||||
} help_index_t;
|
||||
|
||||
|
||||
/*
|
||||
* Functions...
|
||||
*/
|
||||
|
||||
extern void helpDeleteIndex(help_index_t *hi);
|
||||
extern help_node_t *helpFindNode(help_index_t *hi, const char *filename,
|
||||
const char *anchor);
|
||||
extern help_index_t *helpLoadIndex(const char *hifile, const char *directory);
|
||||
extern int helpSaveIndex(help_index_t *hi, const char *hifile);
|
||||
extern help_index_t *helpSearchIndex(help_index_t *hi, const char *query,
|
||||
const char *section,
|
||||
const char *filename);
|
||||
|
||||
|
||||
#endif /* !_CUPS_HELP_INDEX_H_ */
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,379 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* On-line help CGI for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Main entry for CGI.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi-private.h"
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Main entry for CGI.
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
help_index_t *hi, /* Help index */
|
||||
*si; /* Search index */
|
||||
help_node_t *n; /* Current help node */
|
||||
int i; /* Looping var */
|
||||
const char *query; /* Search query */
|
||||
const char *cache_dir; /* CUPS_CACHEDIR environment variable */
|
||||
const char *docroot; /* CUPS_DOCROOT environment variable */
|
||||
const char *helpfile; /* Current help file */
|
||||
const char *topic; /* Current topic */
|
||||
char topic_data[1024]; /* Topic form data */
|
||||
const char *section; /* Current section */
|
||||
char filename[1024], /* Filename */
|
||||
directory[1024]; /* Directory */
|
||||
cups_file_t *fp; /* Help file */
|
||||
char line[1024]; /* Line from file */
|
||||
int printable; /* Show printable version? */
|
||||
|
||||
|
||||
/*
|
||||
* Get any form variables...
|
||||
*/
|
||||
|
||||
cgiInitialize();
|
||||
|
||||
printable = cgiGetVariable("PRINTABLE") != NULL;
|
||||
|
||||
/*
|
||||
* Set the web interface section...
|
||||
*/
|
||||
|
||||
cgiSetVariable("SECTION", "help");
|
||||
|
||||
/*
|
||||
* Load the help index...
|
||||
*/
|
||||
|
||||
if ((cache_dir = getenv("CUPS_CACHEDIR")) == NULL)
|
||||
cache_dir = CUPS_CACHEDIR;
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s/help.index", cache_dir);
|
||||
|
||||
if ((docroot = getenv("CUPS_DOCROOT")) == NULL)
|
||||
docroot = CUPS_DOCROOT;
|
||||
|
||||
snprintf(directory, sizeof(directory), "%s/help", docroot);
|
||||
|
||||
fprintf(stderr, "DEBUG: helpLoadIndex(filename=\"%s\", directory=\"%s\")\n",
|
||||
filename, directory);
|
||||
|
||||
hi = helpLoadIndex(filename, directory);
|
||||
if (!hi)
|
||||
{
|
||||
perror(filename);
|
||||
|
||||
cgiStartHTML(cgiText(_("Help")));
|
||||
cgiSetVariable("ERROR", "Unable to load help index!");
|
||||
cgiCopyTemplateLang("error.tmpl");
|
||||
cgiEndHTML();
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG: %d nodes in help index...\n",
|
||||
cupsArrayCount(hi->nodes));
|
||||
|
||||
/*
|
||||
* See if we are viewing a file...
|
||||
*/
|
||||
|
||||
for (i = 0; i < argc; i ++)
|
||||
fprintf(stderr, "argv[%d]=\"%s\"\n", i, argv[i]);
|
||||
|
||||
if ((helpfile = getenv("PATH_INFO")) != NULL)
|
||||
{
|
||||
helpfile ++;
|
||||
|
||||
if (!*helpfile)
|
||||
helpfile = NULL;
|
||||
}
|
||||
|
||||
if (helpfile)
|
||||
{
|
||||
/*
|
||||
* Verify that the help file exists and is part of the index...
|
||||
*/
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s/help/%s", docroot, helpfile);
|
||||
|
||||
fprintf(stderr, "DEBUG: helpfile=\"%s\", filename=\"%s\"\n",
|
||||
helpfile, filename);
|
||||
|
||||
if (access(filename, R_OK))
|
||||
{
|
||||
perror(filename);
|
||||
|
||||
cgiStartHTML(cgiText(_("Help")));
|
||||
cgiSetVariable("ERROR", "Unable to access help file!");
|
||||
cgiCopyTemplateLang("error.tmpl");
|
||||
cgiEndHTML();
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((n = helpFindNode(hi, helpfile, NULL)) == NULL)
|
||||
{
|
||||
cgiStartHTML(cgiText(_("Help")));
|
||||
cgiSetVariable("ERROR", "Help file not in index!");
|
||||
cgiCopyTemplateLang("error.tmpl");
|
||||
cgiEndHTML();
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page title and save the help file...
|
||||
*/
|
||||
|
||||
cgiSetVariable("HELPFILE", helpfile);
|
||||
cgiSetVariable("HELPTITLE", n->text);
|
||||
cgiSetVariable("TOPIC", n->section);
|
||||
|
||||
/*
|
||||
* Send a standard page header...
|
||||
*/
|
||||
|
||||
if (printable)
|
||||
puts("Content-Type: text/html;charset=utf-8\n");
|
||||
else
|
||||
cgiStartHTML(n->text);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Send a standard page header...
|
||||
*/
|
||||
|
||||
cgiStartHTML(cgiText(_("Help")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Do a search as needed...
|
||||
*/
|
||||
|
||||
query = cgiGetVariable("QUERY");
|
||||
topic = cgiGetVariable("TOPIC");
|
||||
si = helpSearchIndex(hi, query, topic, helpfile);
|
||||
|
||||
fprintf(stderr, "DEBUG: query=\"%s\", topic=\"%s\"\n",
|
||||
query ? query : "(null)", topic ? topic : "(null)");
|
||||
|
||||
if (si)
|
||||
{
|
||||
help_node_t *nn; /* Parent node */
|
||||
|
||||
|
||||
fprintf(stderr,
|
||||
"DEBUG: si=%p, si->sorted=%p, cupsArrayCount(si->sorted)=%d\n", si,
|
||||
si->sorted, cupsArrayCount(si->sorted));
|
||||
|
||||
for (i = 0, n = (help_node_t *)cupsArrayFirst(si->sorted);
|
||||
n;
|
||||
i ++, n = (help_node_t *)cupsArrayNext(si->sorted))
|
||||
{
|
||||
if (helpfile && n->anchor)
|
||||
snprintf(line, sizeof(line), "#%s", n->anchor);
|
||||
else if (n->anchor)
|
||||
snprintf(line, sizeof(line), "/help/%s?QUERY=%s#%s", n->filename,
|
||||
query ? query : "", n->anchor);
|
||||
else
|
||||
snprintf(line, sizeof(line), "/help/%s?QUERY=%s", n->filename,
|
||||
query ? query : "");
|
||||
|
||||
cgiSetArray("QTEXT", i, n->text);
|
||||
cgiSetArray("QLINK", i, line);
|
||||
|
||||
if (!helpfile && n->anchor)
|
||||
{
|
||||
nn = helpFindNode(hi, n->filename, NULL);
|
||||
|
||||
snprintf(line, sizeof(line), "/help/%s?QUERY=%s", nn->filename,
|
||||
query ? query : "");
|
||||
|
||||
cgiSetArray("QPTEXT", i, nn->text);
|
||||
cgiSetArray("QPLINK", i, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
cgiSetArray("QPTEXT", i, "");
|
||||
cgiSetArray("QPLINK", i, "");
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG: [%d] = \"%s\" @ \"%s\"\n", i, n->text, line);
|
||||
}
|
||||
|
||||
helpDeleteIndex(si);
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, now list the bookmarks within the index...
|
||||
*/
|
||||
|
||||
for (i = 0, section = NULL, n = (help_node_t *)cupsArrayFirst(hi->sorted);
|
||||
n;
|
||||
n = (help_node_t *)cupsArrayNext(hi->sorted))
|
||||
{
|
||||
if (n->anchor)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Add a section link as needed...
|
||||
*/
|
||||
|
||||
if (n->section &&
|
||||
(!section || strcmp(n->section, section)))
|
||||
{
|
||||
/*
|
||||
* Add a link for this node...
|
||||
*/
|
||||
|
||||
snprintf(line, sizeof(line), "/help/?TOPIC=%s&QUERY=%s",
|
||||
cgiFormEncode(topic_data, n->section, sizeof(topic_data)),
|
||||
query ? query : "");
|
||||
cgiSetArray("BMLINK", i, line);
|
||||
cgiSetArray("BMTEXT", i, n->section);
|
||||
cgiSetArray("BMINDENT", i, "0");
|
||||
|
||||
i ++;
|
||||
section = n->section;
|
||||
}
|
||||
|
||||
if (!topic || strcmp(n->section, topic))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Add a link for this node...
|
||||
*/
|
||||
|
||||
snprintf(line, sizeof(line), "/help/%s?TOPIC=%s&QUERY=%s", n->filename,
|
||||
cgiFormEncode(topic_data, n->section, sizeof(topic_data)),
|
||||
query ? query : "");
|
||||
cgiSetArray("BMLINK", i, line);
|
||||
cgiSetArray("BMTEXT", i, n->text);
|
||||
cgiSetArray("BMINDENT", i, "1");
|
||||
|
||||
i ++;
|
||||
|
||||
if (helpfile && !strcmp(helpfile, n->filename))
|
||||
{
|
||||
help_node_t *nn; /* Pointer to sub-node */
|
||||
|
||||
|
||||
cupsArraySave(hi->sorted);
|
||||
|
||||
for (nn = (help_node_t *)cupsArrayFirst(hi->sorted);
|
||||
nn;
|
||||
nn = (help_node_t *)cupsArrayNext(hi->sorted))
|
||||
if (nn->anchor && !strcmp(helpfile, nn->filename))
|
||||
{
|
||||
/*
|
||||
* Add a link for this node...
|
||||
*/
|
||||
|
||||
snprintf(line, sizeof(line), "#%s", nn->anchor);
|
||||
cgiSetArray("BMLINK", i, line);
|
||||
cgiSetArray("BMTEXT", i, nn->text);
|
||||
cgiSetArray("BMINDENT", i, "2");
|
||||
|
||||
i ++;
|
||||
}
|
||||
|
||||
cupsArrayRestore(hi->sorted);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show the search and bookmark content...
|
||||
*/
|
||||
|
||||
if (!helpfile || !printable)
|
||||
cgiCopyTemplateLang("help-header.tmpl");
|
||||
else
|
||||
cgiCopyTemplateLang("help-printable.tmpl");
|
||||
|
||||
/*
|
||||
* If we are viewing a file, copy it in now...
|
||||
*/
|
||||
|
||||
if (helpfile)
|
||||
{
|
||||
if ((fp = cupsFileOpen(filename, "r")) != NULL)
|
||||
{
|
||||
int inbody; /* Are we inside the body? */
|
||||
|
||||
|
||||
inbody = 0;
|
||||
|
||||
while (cupsFileGets(fp, line, sizeof(line)))
|
||||
{
|
||||
if (inbody)
|
||||
{
|
||||
if (!strncasecmp(line, "</BODY>", 7))
|
||||
break;
|
||||
|
||||
printf("%s\n", line);
|
||||
}
|
||||
else if (!strncasecmp(line, "<BODY", 5))
|
||||
inbody = 1;
|
||||
}
|
||||
|
||||
cupsFileClose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
perror(filename);
|
||||
cgiSetVariable("ERROR", "Unable to open help file.");
|
||||
cgiCopyTemplateLang("error.tmpl");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a standard trailer...
|
||||
*/
|
||||
|
||||
if (!printable)
|
||||
cgiEndHTML();
|
||||
else
|
||||
puts("</BODY>\n</HTML>");
|
||||
|
||||
/*
|
||||
* Delete the index...
|
||||
*/
|
||||
|
||||
helpDeleteIndex(hi);
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+146
-57
@@ -1,86 +1,175 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* CGI HTML functions.
|
||||
* HTML support functions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* cgiStartHTML() - Start an HTML document stream.
|
||||
* cgiEndHTML() - End an HTML document stream.
|
||||
* cgiEndHTML() - End a HTML page.
|
||||
* cgiFormEncode() - Encode a string as a form variable...
|
||||
* cgiStartHTML() - Start a HTML page.
|
||||
* cgi_null_passwd() - Return a NULL password for authentication.
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
#include <stdarg.h>
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi-private.h"
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiStartHTML()' - Start an HTML document stream.
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static const char *cgi_null_passwd(const char *prompt);
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiEndHTML()' - End a HTML page.
|
||||
*/
|
||||
|
||||
void
|
||||
cgiStartHTML(FILE *out, /* I - Output file to use */
|
||||
const char *stylesheet, /* I - Stylesheet to use */
|
||||
const char *author, /* I - Author name */
|
||||
const char *keywords, /* I - Search keywords */
|
||||
const char *description, /* I - Description of document */
|
||||
const char *title, /* I - Title for page */
|
||||
...) /* I - Any addition args for title */
|
||||
cgiEndHTML(void)
|
||||
{
|
||||
va_list ap; /* Argument pointer */
|
||||
/*
|
||||
* Send the standard trailer...
|
||||
*/
|
||||
|
||||
|
||||
fputs("Content-type: text/html\n\n", out);
|
||||
fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n", out);
|
||||
fputs("<HTML>\n", out);
|
||||
fputs("<HEAD>\n", out);
|
||||
|
||||
fputs("\t<TITLE>\n", out);
|
||||
va_start(ap, title);
|
||||
vfprintf(out, title, ap);
|
||||
va_end(ap);
|
||||
fputs("</TITLE>\n", out);
|
||||
|
||||
if (stylesheet)
|
||||
fprintf(out, "\t<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" HREF=\"%s\">\n",
|
||||
stylesheet);
|
||||
if (author)
|
||||
fprintf(out, "\t<META NAME=\"AUTHOR\" CONTENT=\"%s\">\n", author);
|
||||
if (keywords)
|
||||
fprintf(out, "\t<META NAME=\"KEYWORDS\" CONTENT=\"%s\">\n", keywords);
|
||||
if (description)
|
||||
fprintf(out, "\t<META NAME=\"DESCRIPTION\" CONTENT=\"%s\">\n", description);
|
||||
|
||||
fputs("</HEAD>\n", out);
|
||||
fputs("<BODY>\n", out);
|
||||
cgiCopyTemplateLang("trailer.tmpl");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiEndHTML()' - End an HTML document stream.
|
||||
* 'cgiFormEncode()' - Encode a string as a form variable...
|
||||
*/
|
||||
|
||||
char * /* O - Destination string */
|
||||
cgiFormEncode(char *dst, /* I - Destination string */
|
||||
const char *src, /* I - Source string */
|
||||
size_t dstsize) /* I - Size of destination string */
|
||||
{
|
||||
char *dstptr, /* Pointer into destination */
|
||||
*dstend; /* End of destination */
|
||||
static const char *hex = /* Hexadecimal characters */
|
||||
"0123456789ABCDEF";
|
||||
|
||||
|
||||
/*
|
||||
* Mark the end of the string...
|
||||
*/
|
||||
|
||||
dstend = dst + dstsize - 1;
|
||||
|
||||
/*
|
||||
* Loop through the source string and copy...
|
||||
*/
|
||||
|
||||
for (dstptr = dst; *src && dstptr < dstend;)
|
||||
{
|
||||
switch (*src)
|
||||
{
|
||||
case ' ' :
|
||||
/*
|
||||
* Encode spaces with a "+"...
|
||||
*/
|
||||
|
||||
*dstptr++ = '+';
|
||||
src ++;
|
||||
break;
|
||||
|
||||
case '&' :
|
||||
case '%' :
|
||||
case '+' :
|
||||
/*
|
||||
* Encode special characters with %XX escape...
|
||||
*/
|
||||
|
||||
if (dstptr < (dstend - 2))
|
||||
{
|
||||
*dstptr++ = '%';
|
||||
*dstptr++ = hex[(*src & 255) >> 4];
|
||||
*dstptr++ = hex[*src & 15];
|
||||
src ++;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
/*
|
||||
* Copy other characters literally...
|
||||
*/
|
||||
|
||||
*dstptr++ = *src++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Nul-terminate the destination string...
|
||||
*/
|
||||
|
||||
*dstptr = '\0';
|
||||
|
||||
/*
|
||||
* Return the encoded string...
|
||||
*/
|
||||
|
||||
return (dst);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiStartHTML()' - Start a HTML page.
|
||||
*/
|
||||
|
||||
void
|
||||
cgiEndHTML(FILE *out) /* I - Output file to use */
|
||||
cgiStartHTML(const char *title) /* I - Title of page */
|
||||
{
|
||||
fputs("</BODY>\n", out);
|
||||
fputs("</HTML>\n", out);
|
||||
/*
|
||||
* Disable any further authentication attempts...
|
||||
*/
|
||||
|
||||
cupsSetPasswordCB(cgi_null_passwd);
|
||||
|
||||
/*
|
||||
* Tell the client to expect UTF-8 encoded HTML...
|
||||
*/
|
||||
|
||||
puts("Content-Type: text/html;charset=utf-8\n");
|
||||
|
||||
/*
|
||||
* Send a standard header...
|
||||
*/
|
||||
|
||||
cgiSetVariable("TITLE", title);
|
||||
cgiSetServerVersion();
|
||||
|
||||
cgiCopyTemplateLang("header.tmpl");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_null_passwd()' - Return a NULL password for authentication.
|
||||
*/
|
||||
|
||||
static const char * /* O - NULL */
|
||||
cgi_null_passwd(const char *prompt) /* I - Prompt string (unused) */
|
||||
{
|
||||
(void)prompt;
|
||||
|
||||
fprintf(stderr, "DEBUG: cgi_null_passwd(prompt=\"%s\") called!\n",
|
||||
prompt ? prompt : "(null)");
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1107
-254
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* IPP variable definitions for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 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 <cups/cups.h>
|
||||
#include <cups/debug.h>
|
||||
#include <cups/language.h>
|
||||
#include <cups/string.h>
|
||||
#include "cgi.h"
|
||||
|
||||
|
||||
/*
|
||||
* Definitions...
|
||||
*/
|
||||
|
||||
#define TEMPLATES ippGetTemplateDir()
|
||||
|
||||
|
||||
/*
|
||||
* Prototype...
|
||||
*/
|
||||
|
||||
extern void ippGetAttributes(ipp_t *request, const char *directory,
|
||||
const char *tmpl, const char *lang);
|
||||
extern char *ippGetTemplateDir(void);
|
||||
extern char *ippRewriteURL(const char *, char *, int, const char *);
|
||||
extern void ippSetServerVersion(void);
|
||||
extern void ippSetCGIVars(ipp_t *, const char *, const char *,
|
||||
const char *, int);
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+78
-126
@@ -3,23 +3,14 @@
|
||||
*
|
||||
* Job status CGI for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
@@ -31,14 +22,14 @@
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "ipp-var.h"
|
||||
#include "cgi-private.h"
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static void do_job_op(http_t *http, cups_lang_t *language, ipp_op_t op);
|
||||
static void do_job_op(http_t *http, int job_id, ipp_op_t op);
|
||||
|
||||
|
||||
/*
|
||||
@@ -49,12 +40,10 @@ int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
cups_lang_t *language; /* Language information */
|
||||
http_t *http; /* Connection to the server */
|
||||
const char *which_jobs; /* Which jobs to show */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
const char *op; /* Operation name */
|
||||
const char *op; /* Operation name */
|
||||
const char *job_id_var; /* Job ID form variable */
|
||||
int job_id; /* Job ID */
|
||||
|
||||
|
||||
/*
|
||||
@@ -64,104 +53,73 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
cgiInitialize();
|
||||
|
||||
/*
|
||||
* Get the request language...
|
||||
* Set the web interface section...
|
||||
*/
|
||||
|
||||
language = cupsLangDefault();
|
||||
cgiSetVariable("SECTION", "jobs");
|
||||
|
||||
/*
|
||||
* Connect to the HTTP server...
|
||||
*/
|
||||
|
||||
http = httpConnectEncrypt("localhost", ippPort(), cupsEncryption());
|
||||
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
|
||||
|
||||
/*
|
||||
* Tell the client to expect HTML...
|
||||
* Get the job ID, if any...
|
||||
*/
|
||||
|
||||
printf("Content-Type: text/html;charset=%s\n\n", cupsLangEncoding(language));
|
||||
if ((job_id_var = cgiGetVariable("JOB_ID")) != NULL)
|
||||
job_id = atoi(job_id_var);
|
||||
else
|
||||
job_id = 0;
|
||||
|
||||
cgiSetVariable("TITLE", "Jobs");
|
||||
/*
|
||||
* Do the operation...
|
||||
*/
|
||||
|
||||
ippSetServerVersion();
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "header.tmpl", getenv("LANG"));
|
||||
|
||||
if ((op = cgiGetVariable("OP")) != NULL)
|
||||
if ((op = cgiGetVariable("OP")) != NULL && job_id > 0)
|
||||
{
|
||||
/*
|
||||
* Do the operation...
|
||||
*/
|
||||
|
||||
if (strcmp(op, "cancel-job") == 0)
|
||||
do_job_op(http, language, IPP_CANCEL_JOB);
|
||||
else if (strcmp(op, "hold-job") == 0)
|
||||
do_job_op(http, language, IPP_HOLD_JOB);
|
||||
else if (strcmp(op, "release-job") == 0)
|
||||
do_job_op(http, language, IPP_RELEASE_JOB);
|
||||
else if (strcmp(op, "restart-job") == 0)
|
||||
do_job_op(http, language, IPP_RESTART_JOB);
|
||||
if (!strcmp(op, "cancel-job"))
|
||||
do_job_op(http, job_id, IPP_CANCEL_JOB);
|
||||
else if (!strcmp(op, "hold-job"))
|
||||
do_job_op(http, job_id, IPP_HOLD_JOB);
|
||||
else if (!strcmp(op, "move-job"))
|
||||
cgiMoveJobs(http, NULL, job_id);
|
||||
else if (!strcmp(op, "release-job"))
|
||||
do_job_op(http, job_id, IPP_RELEASE_JOB);
|
||||
else if (!strcmp(op, "restart-job"))
|
||||
do_job_op(http, job_id, IPP_RESTART_JOB);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Bad operation code... Display an error...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "job-op.tmpl", getenv("LANG"));
|
||||
cgiStartHTML(cgiText(_("Jobs")));
|
||||
cgiCopyTemplateLang("error-op.tmpl");
|
||||
cgiEndHTML();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_JOBS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
* Show a list of jobs...
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
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->request.op.operation_id = IPP_GET_JOBS;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
|
||||
"ipp://localhost/jobs");
|
||||
|
||||
if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
|
||||
NULL, which_jobs);
|
||||
|
||||
ippGetAttributes(request, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
ippDelete(response);
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
}
|
||||
cgiStartHTML(cgiText(_("Jobs")));
|
||||
cgiShowJobs(http, NULL);
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "trailer.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Close the HTTP server connection...
|
||||
*/
|
||||
|
||||
httpClose(http);
|
||||
cupsLangFree(language);
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
@@ -177,25 +135,14 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
static void
|
||||
do_job_op(http_t *http, /* I - HTTP connection */
|
||||
cups_lang_t *language, /* I - Client's language */
|
||||
int job_id, /* I - Job ID */
|
||||
ipp_op_t op) /* I - Operation to perform */
|
||||
{
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
ipp_t *request; /* IPP request */
|
||||
char uri[HTTP_MAX_URI]; /* Job URI */
|
||||
const char *job; /* Job ID */
|
||||
ipp_status_t status; /* Operation status... */
|
||||
const char *user; /* Username */
|
||||
|
||||
|
||||
if ((job = cgiGetVariable("JOB_ID")) != NULL)
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%s", job);
|
||||
else
|
||||
{
|
||||
cgiSetVariable("ERROR", ippErrorString(IPP_NOT_FOUND));
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "error.tmpl", getenv("LANG"));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a job request, which requires the following
|
||||
* attributes:
|
||||
@@ -206,53 +153,58 @@ do_job_op(http_t *http, /* I - HTTP connection */
|
||||
* requesting-user-name
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
request = ippNewRequest(op);
|
||||
|
||||
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));
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
|
||||
"attributes-natural-language", NULL, language->language);
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
|
||||
NULL, uri);
|
||||
|
||||
if (getenv("REMOTE_USER") != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, getenv("REMOTE_USER"));
|
||||
else
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, "unknown");
|
||||
if ((user = getenv("REMOTE_USER")) == NULL)
|
||||
user = "guest";
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"requesting-user-name", NULL, user);
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/jobs")) != NULL)
|
||||
{
|
||||
status = response->request.status.status_code;
|
||||
ippDelete(cupsDoRequest(http, request, "/jobs"));
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
status = cupsLastError();
|
||||
|
||||
if (status > IPP_OK_CONFLICT)
|
||||
if (cupsLastError() <= IPP_OK_CONFLICT && getenv("HTTP_REFERER"))
|
||||
{
|
||||
cgiSetVariable("ERROR", ippErrorString(status));
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "error.tmpl", getenv("LANG"));
|
||||
/*
|
||||
* Redirect successful updates back to the parent page...
|
||||
*/
|
||||
|
||||
char url[1024]; /* Encoded URL */
|
||||
|
||||
|
||||
strcpy(url, "5;URL=");
|
||||
cgiFormEncode(url + 6, getenv("HTTP_REFERER"), sizeof(url) - 6);
|
||||
cgiSetVariable("refresh_page", url);
|
||||
}
|
||||
else if (cupsLastError() == IPP_NOT_AUTHORIZED)
|
||||
{
|
||||
puts("Status: 401\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
cgiStartHTML(cgiText(_("Jobs")));
|
||||
|
||||
if (cupsLastError() > IPP_OK_CONFLICT)
|
||||
cgiShowIPPError(_("Job operation failed:"));
|
||||
else if (op == IPP_CANCEL_JOB)
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "job-cancel.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("job-cancel.tmpl");
|
||||
else if (op == IPP_HOLD_JOB)
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "job-hold.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("job-hold.tmpl");
|
||||
else if (op == IPP_RELEASE_JOB)
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "job-release.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("job-release.tmpl");
|
||||
else if (op == IPP_RESTART_JOB)
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "job-restart.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("job-restart.tmpl");
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Arquivo binário não exibido.
+524
-242
@@ -3,34 +3,38 @@
|
||||
*
|
||||
* Printer status CGI for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2006 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
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Main entry for CGI.
|
||||
* main() - Main entry for CGI.
|
||||
* print_command() - Send a print command to the printer.
|
||||
* show_all_printers() - Show all printers...
|
||||
* show_printer() - Show a single printer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "ipp-var.h"
|
||||
#include "cgi-private.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
void print_command(http_t *http, const char *printer, const char *command);
|
||||
void show_all_printers(http_t *http, const char *username);
|
||||
void show_printer(http_t *http, const char *printer);
|
||||
|
||||
|
||||
/*
|
||||
@@ -41,17 +45,14 @@ int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
cups_lang_t *language; /* Language information */
|
||||
char *printer; /* Printer name */
|
||||
const char *printer; /* Printer name */
|
||||
const char *user; /* Username */
|
||||
http_t *http; /* Connection to the server */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
ipp_attribute_t *attr; /* IPP attribute */
|
||||
ipp_status_t status; /* Operation status... */
|
||||
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||
const char *which_jobs; /* Which jobs to show */
|
||||
const char *op; /* Operation to perform, if any */
|
||||
static const char *def_attrs[] = /* Attributes for default printer */
|
||||
static const char *def_attrs[] = /* Attributes for default printer */
|
||||
{
|
||||
"printer-name",
|
||||
"printer-uri-supported"
|
||||
@@ -63,60 +64,50 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
*/
|
||||
|
||||
cgiInitialize();
|
||||
|
||||
op = cgiGetVariable("OP");
|
||||
|
||||
/*
|
||||
* Get the request language...
|
||||
* Set the web interface section...
|
||||
*/
|
||||
|
||||
language = cupsLangDefault();
|
||||
cgiSetVariable("SECTION", "printers");
|
||||
|
||||
/*
|
||||
* See if we are displaying a printer or all printers...
|
||||
*/
|
||||
|
||||
if ((printer = getenv("PATH_INFO")) != NULL)
|
||||
{
|
||||
printer ++;
|
||||
|
||||
if (!*printer)
|
||||
printer = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* See who is logged in...
|
||||
*/
|
||||
|
||||
user = getenv("REMOTE_USER");
|
||||
|
||||
/*
|
||||
* Connect to the HTTP server...
|
||||
*/
|
||||
|
||||
http = httpConnectEncrypt("localhost", ippPort(), cupsEncryption());
|
||||
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
|
||||
|
||||
/*
|
||||
* Tell the client to expect HTML...
|
||||
* Get the default printer...
|
||||
*/
|
||||
|
||||
printf("Content-Type: text/html;charset=%s\r\n\r\n",
|
||||
cupsLangEncoding(language));
|
||||
|
||||
/*
|
||||
* See if we need to show a list of printers or the status of a
|
||||
* single printer...
|
||||
*/
|
||||
|
||||
ippSetServerVersion();
|
||||
|
||||
printer = argv[0];
|
||||
if (strcmp(printer, "/") == 0 || strstr(printer, "printers.cgi") != NULL)
|
||||
{
|
||||
printer = NULL;
|
||||
cgiSetVariable("TITLE", cupsLangString(language, CUPS_MSG_PRINTER));
|
||||
}
|
||||
else
|
||||
cgiSetVariable("TITLE", printer);
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "header.tmpl", getenv("LANG"));
|
||||
|
||||
if (op == NULL || strcasecmp(op, "print-test-page") != 0)
|
||||
if (!op)
|
||||
{
|
||||
/*
|
||||
* Get the default destination...
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
request->request.op.operation_id = CUPS_GET_DEFAULT;
|
||||
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);
|
||||
request = ippNewRequest(CUPS_GET_DEFAULT);
|
||||
|
||||
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
|
||||
"requested-attributes",
|
||||
@@ -133,7 +124,7 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
|
||||
|
||||
cgiSetVariable("DEFAULT_URI",
|
||||
ippRewriteURL(attr->values[0].string.text,
|
||||
cgiRewriteURL(attr->values[0].string.text,
|
||||
url, sizeof(url), NULL));
|
||||
}
|
||||
|
||||
@@ -141,207 +132,43 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the printer info...
|
||||
* See if we need to show a list of printers or the status of a
|
||||
* single printer...
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
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);
|
||||
|
||||
if (printer == NULL)
|
||||
{
|
||||
/*
|
||||
* Build a CUPS_GET_PRINTERS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
*/
|
||||
|
||||
request->request.op.operation_id = CUPS_GET_PRINTERS;
|
||||
request->request.op.request_id = 1;
|
||||
}
|
||||
if (!printer)
|
||||
show_all_printers(http, user);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://%s/printers/%s", getenv("SERVER_NAME"),
|
||||
printer);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
}
|
||||
|
||||
ippGetAttributes(request, TEMPLATES, "printers.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
ippDelete(response);
|
||||
}
|
||||
else if (printer)
|
||||
fprintf(stderr, "ERROR: Get-Printer-Attributes request failed - %s (%x)\n",
|
||||
ippErrorString(cupsLastError()), cupsLastError());
|
||||
else
|
||||
fprintf(stderr, "ERROR: CUPS-Get-Printers request failed - %s (%x)\n",
|
||||
ippErrorString(cupsLastError()), cupsLastError());
|
||||
|
||||
/*
|
||||
* Write the report...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "printers.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Get jobs for the specified printer if a printer has been chosen...
|
||||
*/
|
||||
|
||||
if (printer != NULL)
|
||||
{
|
||||
/*
|
||||
* Build an IPP_GET_JOBS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
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->request.op.operation_id = IPP_GET_JOBS;
|
||||
request->request.op.request_id = 1;
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://%s/printers/%s", getenv("SERVER_NAME"),
|
||||
printer);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
|
||||
if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
|
||||
NULL, which_jobs);
|
||||
|
||||
ippGetAttributes(request, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
ippDelete(response);
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "jobs.tmpl", getenv("LANG"));
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "ERROR: Get-Jobs request failed - %s (%x)\n",
|
||||
ippErrorString(cupsLastError()), cupsLastError());
|
||||
}
|
||||
show_printer(http, printer);
|
||||
}
|
||||
else if (!strcasecmp(op, "print-self-test-page") && printer)
|
||||
print_command(http, printer, "PrintSelfTestPage");
|
||||
else if (!strcasecmp(op, "clean-print-heads") && printer)
|
||||
print_command(http, printer, "Clean all");
|
||||
else if (!strcasecmp(op, "print-test-page") && printer)
|
||||
cgiPrintTestPage(http, printer);
|
||||
else if (!strcasecmp(op, "move-jobs") && printer)
|
||||
cgiMoveJobs(http, printer, 0);
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Print a test page...
|
||||
* Unknown/bad operation...
|
||||
*/
|
||||
|
||||
snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", printer);
|
||||
|
||||
/*
|
||||
* Build an IPP_PRINT_JOB request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
* requesting-user-name
|
||||
* document-format
|
||||
*/
|
||||
|
||||
request = ippNew();
|
||||
|
||||
request->request.op.operation_id = IPP_PRINT_JOB;
|
||||
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);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
|
||||
NULL, uri);
|
||||
|
||||
if (getenv("REMOTE_USER") != NULL)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, getenv("REMOTE_USER"));
|
||||
if (printer)
|
||||
cgiStartHTML(printer);
|
||||
else
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
|
||||
NULL, "root");
|
||||
cgiStartHTML(cgiText(_("Printers")));
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
|
||||
NULL, "Test Page");
|
||||
|
||||
ippAddString(request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
|
||||
NULL, "application/postscript");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoFileRequest(http, request, uri + 15,
|
||||
CUPS_DATADIR "/data/testprint.ps")) != NULL)
|
||||
{
|
||||
status = response->request.status.status_code;
|
||||
ippSetCGIVars(response, NULL, NULL, NULL, 0);
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
status = cupsLastError();
|
||||
|
||||
cgiSetVariable("PRINTER_NAME", printer);
|
||||
|
||||
if (status > IPP_OK_CONFLICT)
|
||||
{
|
||||
cgiSetVariable("ERROR", ippErrorString(status));
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "error.tmpl", getenv("LANG"));
|
||||
}
|
||||
else
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "test-page.tmpl", getenv("LANG"));
|
||||
cgiCopyTemplateLang("error-op.tmpl");
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
cgiCopyTemplateLang(stdout, TEMPLATES, "trailer.tmpl", getenv("LANG"));
|
||||
|
||||
/*
|
||||
* Close the HTTP server connection...
|
||||
*/
|
||||
|
||||
httpClose(http);
|
||||
cupsLangFree(language);
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
@@ -351,6 +178,461 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'print_command()' - Send a print command to the printer.
|
||||
*/
|
||||
|
||||
void
|
||||
print_command(http_t *http, /* I - Connection to server */
|
||||
const char *printer, /* I - Printer */
|
||||
const char *command) /* I - Command to send */
|
||||
{
|
||||
cups_file_t *fp; /* File pointer */
|
||||
char filename[1024]; /* Temporary file */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
char uri[HTTP_MAX_URI], /* Printer URI */
|
||||
resource[1024], /* POST resource path */
|
||||
refresh[1024]; /* Refresh URL */
|
||||
const char *user; /* Username */
|
||||
|
||||
|
||||
/*
|
||||
* See who is logged in...
|
||||
*/
|
||||
|
||||
if ((user = getenv("REMOTE_USER")) == NULL)
|
||||
user = "guest";
|
||||
|
||||
/*
|
||||
* Create the CUPS command file to print...
|
||||
*/
|
||||
|
||||
if ((fp = cupsTempFile2(filename, sizeof(filename))) == NULL)
|
||||
{
|
||||
cgiStartHTML(cgiText(_("Printer Maintenance")));
|
||||
cgiSetVariable("MESSAGE", _("Unable to create temporary file:"));
|
||||
cgiSetVariable("ERROR", strerror(errno));
|
||||
cgiCopyTemplateLang("error.tmpl");
|
||||
cgiEndHTML();
|
||||
return;
|
||||
}
|
||||
|
||||
cupsFilePuts(fp, "#CUPS-COMMAND\n");
|
||||
cupsFilePrintf(fp, "%s\n", command);
|
||||
cupsFileClose(fp);
|
||||
|
||||
/*
|
||||
* Point to the printer...
|
||||
*/
|
||||
|
||||
snprintf(resource, sizeof(resource), "/printers/%s", printer);
|
||||
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
|
||||
"localhost", ippPort(), "/printers/%s", printer);
|
||||
|
||||
/*
|
||||
* Build an IPP_PRINT_JOB request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
* requesting-user-name
|
||||
* document-format
|
||||
*/
|
||||
|
||||
request = ippNewRequest(IPP_PRINT_JOB);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
|
||||
NULL, uri);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"requesting-user-name", NULL, user);
|
||||
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
|
||||
NULL, "Printer Maintenance");
|
||||
|
||||
ippAddString(request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
|
||||
NULL, "application/postscript");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoFileRequest(http, request, resource,
|
||||
filename)) != NULL)
|
||||
{
|
||||
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
|
||||
|
||||
ippDelete(response);
|
||||
}
|
||||
|
||||
unlink(filename);
|
||||
|
||||
if (cupsLastError() <= IPP_OK_CONFLICT)
|
||||
{
|
||||
/*
|
||||
* Automatically reload the printer status page...
|
||||
*/
|
||||
|
||||
cgiFormEncode(uri, resource, sizeof(uri));
|
||||
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
|
||||
cgiSetVariable("refresh_page", refresh);
|
||||
}
|
||||
else if (cupsLastError() == IPP_NOT_AUTHORIZED)
|
||||
{
|
||||
puts("Status: 401\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
cgiStartHTML(cgiText(_("Printer Maintenance")));
|
||||
|
||||
if (cupsLastError() > IPP_OK_CONFLICT)
|
||||
cgiShowIPPError(_("Unable to send maintenance job:"));
|
||||
else
|
||||
{
|
||||
cgiSetVariable("PRINTER_NAME", printer);
|
||||
|
||||
cgiCopyTemplateLang("maintenance.tmpl");
|
||||
}
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_all_printers()' - Show all printers...
|
||||
*/
|
||||
|
||||
void
|
||||
show_all_printers(http_t *http, /* I - Connection to server */
|
||||
const char *user) /* I - Username */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
cups_array_t *printers; /* Array of printer objects */
|
||||
ipp_attribute_t *printer, /* Printer object */
|
||||
*attr; /* Current attribute */
|
||||
int ascending, /* Order of printers (0 = descending) */
|
||||
first, /* First printer to show */
|
||||
count; /* Number of printers */
|
||||
const char *var; /* Form variable */
|
||||
void *search; /* Search data */
|
||||
char url[1024], /* URL for prev/next/this */
|
||||
*urlptr, /* Position in URL */
|
||||
*urlend; /* End of URL */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG: show_all_printers(http=%p, user=\"%s\")\n",
|
||||
http, user ? user : "(null)");
|
||||
|
||||
/*
|
||||
* Show the standard header...
|
||||
*/
|
||||
|
||||
cgiStartHTML(cgiText(_("Printers")));
|
||||
|
||||
/*
|
||||
* Build a CUPS_GET_PRINTERS request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-type
|
||||
* printer-type-mask
|
||||
* requesting-user-name
|
||||
*/
|
||||
|
||||
request = ippNewRequest(CUPS_GET_PRINTERS);
|
||||
|
||||
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM,
|
||||
"printer-type", 0);
|
||||
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM,
|
||||
"printer-type-mask", CUPS_PRINTER_CLASS);
|
||||
|
||||
if (user)
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
|
||||
"requesting-user-name", NULL, user);
|
||||
|
||||
cgiGetAttributes(request, "printers.tmpl");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
/*
|
||||
* Get a list of matching job objects.
|
||||
*/
|
||||
|
||||
if ((var = cgiGetVariable("QUERY")) != NULL)
|
||||
search = cgiCompileSearch(var);
|
||||
else
|
||||
search = NULL;
|
||||
|
||||
printers = cgiGetIPPObjects(response, search);
|
||||
count = cupsArrayCount(printers);
|
||||
|
||||
if (search)
|
||||
cgiFreeSearch(search);
|
||||
|
||||
/*
|
||||
* Figure out which printers to display...
|
||||
*/
|
||||
|
||||
if ((var = cgiGetVariable("FIRST")) != NULL)
|
||||
first = atoi(var);
|
||||
else
|
||||
first = 0;
|
||||
|
||||
if (first >= count)
|
||||
first = count - CUPS_PAGE_MAX;
|
||||
|
||||
first = (first / CUPS_PAGE_MAX) * CUPS_PAGE_MAX;
|
||||
|
||||
if (first < 0)
|
||||
first = 0;
|
||||
|
||||
sprintf(url, "%d", count);
|
||||
cgiSetVariable("TOTAL", url);
|
||||
|
||||
if ((var = cgiGetVariable("ORDER")) != NULL)
|
||||
ascending = !strcasecmp(var, "asc");
|
||||
else
|
||||
ascending = 1;
|
||||
|
||||
if (ascending)
|
||||
{
|
||||
for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, first);
|
||||
i < CUPS_PAGE_MAX && printer;
|
||||
i ++, printer = (ipp_attribute_t *)cupsArrayNext(printers))
|
||||
{
|
||||
cgiSetIPPObjectVars(printer, NULL, i);
|
||||
|
||||
cgiSetArray("cupscommand", i, "0");
|
||||
|
||||
for (attr = printer; attr; attr = attr->next)
|
||||
if (attr->group_tag != IPP_TAG_PRINTER || !attr->name)
|
||||
break;
|
||||
else if (!strcmp(attr->name, "printer-type"))
|
||||
{
|
||||
if (attr->values[0].integer & CUPS_PRINTER_COMMANDS)
|
||||
cgiSetArray("cupscommand", i, "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0, printer = (ipp_attribute_t *)cupsArrayIndex(printers, count - first - 1);
|
||||
i < CUPS_PAGE_MAX && printer;
|
||||
i ++, printer = (ipp_attribute_t *)cupsArrayPrev(printers))
|
||||
{
|
||||
cgiSetIPPObjectVars(printer, NULL, i);
|
||||
|
||||
cgiSetArray("cupscommand", i, "0");
|
||||
|
||||
for (attr = printer; attr; attr = attr->next)
|
||||
if (attr->group_tag == IPP_TAG_ZERO || !attr->name)
|
||||
break;
|
||||
else if (!strcmp(attr->name, "printer-type"))
|
||||
{
|
||||
if (attr->values[0].integer & CUPS_PRINTER_COMMANDS)
|
||||
cgiSetArray("cupscommand", i, "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Save navigation URLs...
|
||||
*/
|
||||
|
||||
urlend = url + sizeof(url);
|
||||
|
||||
if ((var = cgiGetVariable("QUERY")) != NULL)
|
||||
{
|
||||
strlcpy(url, "/printers/?QUERY=", sizeof(url));
|
||||
urlptr = url + strlen(url);
|
||||
|
||||
cgiFormEncode(urlptr, var, urlend - urlptr);
|
||||
urlptr += strlen(urlptr);
|
||||
|
||||
strlcpy(urlptr, "&", urlend - urlptr);
|
||||
urlptr += strlen(urlptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(url, "/printers/?", sizeof(url));
|
||||
urlptr = url + strlen(url);
|
||||
}
|
||||
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d", first);
|
||||
cgiSetVariable("THISURL", url);
|
||||
|
||||
if (first > 0)
|
||||
{
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
|
||||
first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
|
||||
cgiSetVariable("PREVURL", url);
|
||||
}
|
||||
|
||||
if ((first + CUPS_PAGE_MAX) < count)
|
||||
{
|
||||
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
|
||||
first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
|
||||
cgiSetVariable("NEXTURL", url);
|
||||
}
|
||||
|
||||
/*
|
||||
* Then show everything...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("search.tmpl");
|
||||
|
||||
cgiCopyTemplateLang("printers-header.tmpl");
|
||||
|
||||
if (count > 0)
|
||||
cgiCopyTemplateLang("pager.tmpl");
|
||||
|
||||
cgiCopyTemplateLang("printers.tmpl");
|
||||
|
||||
if (count > 0)
|
||||
cgiCopyTemplateLang("pager.tmpl");
|
||||
|
||||
/*
|
||||
* Delete the response...
|
||||
*/
|
||||
|
||||
cupsArrayDelete(printers);
|
||||
ippDelete(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Show the error...
|
||||
*/
|
||||
|
||||
cgiShowIPPError(_("Unable to get printer list:"));
|
||||
}
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'show_printer()' - Show a single printer.
|
||||
*/
|
||||
|
||||
void
|
||||
show_printer(http_t *http, /* I - Connection to server */
|
||||
const char *printer) /* I - Name of printer */
|
||||
{
|
||||
ipp_t *request, /* IPP request */
|
||||
*response; /* IPP response */
|
||||
ipp_attribute_t *attr; /* IPP attribute */
|
||||
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||
char refresh[1024]; /* Refresh URL */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG: show_printer(http=%p, printer=\"%s\")\n",
|
||||
http, printer ? printer : "(null)");
|
||||
|
||||
/*
|
||||
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
|
||||
* attributes:
|
||||
*
|
||||
* attributes-charset
|
||||
* attributes-natural-language
|
||||
* printer-uri
|
||||
*/
|
||||
|
||||
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
|
||||
|
||||
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
|
||||
"localhost", 0, "/printers/%s", printer);
|
||||
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
|
||||
uri);
|
||||
|
||||
cgiGetAttributes(request, "printers.tmpl");
|
||||
|
||||
/*
|
||||
* Do the request and get back a response...
|
||||
*/
|
||||
|
||||
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
||||
{
|
||||
/*
|
||||
* Got the result; set the CGI variables and check the status of a
|
||||
* single-queue request...
|
||||
*/
|
||||
|
||||
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
|
||||
|
||||
if ((attr = ippFindAttribute(response, "printer-type",
|
||||
IPP_TAG_ENUM)) != NULL)
|
||||
{
|
||||
cgiSetVariable("cupscommand",
|
||||
(attr->values[0].integer & CUPS_PRINTER_COMMANDS) ?
|
||||
"1" : "0");
|
||||
}
|
||||
|
||||
if (printer && (attr = ippFindAttribute(response, "printer-state",
|
||||
IPP_TAG_ENUM)) != NULL &&
|
||||
attr->values[0].integer == IPP_PRINTER_PROCESSING)
|
||||
{
|
||||
/*
|
||||
* Printer is processing - automatically refresh the page until we
|
||||
* are done printing...
|
||||
*/
|
||||
|
||||
cgiFormEncode(uri, printer, sizeof(uri));
|
||||
snprintf(refresh, sizeof(refresh), "10;URL=/printers/%s", uri);
|
||||
cgiSetVariable("refresh_page", refresh);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the response...
|
||||
*/
|
||||
|
||||
ippDelete(response);
|
||||
|
||||
/*
|
||||
* Show the standard header...
|
||||
*/
|
||||
|
||||
cgiStartHTML(printer);
|
||||
|
||||
/*
|
||||
* Show the printer status...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("printers.tmpl");
|
||||
|
||||
/*
|
||||
* Show jobs for the specified printer...
|
||||
*/
|
||||
|
||||
cgiCopyTemplateLang("printer-jobs-header.tmpl");
|
||||
cgiShowJobs(http, printer);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Show the IPP error...
|
||||
*/
|
||||
|
||||
cgiStartHTML(printer);
|
||||
cgiShowIPPError(_("Unable to get printer status:"));
|
||||
}
|
||||
|
||||
cgiEndHTML();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Search routines for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* cgiCompileSearch() - Compile a search string.
|
||||
* cgiDoSearch() - Do a search of some text.
|
||||
* cgiFreeSearch() - Free a compiled search context.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi-private.h"
|
||||
#include <regex.h>
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiCompileSearch()' - Compile a search string.
|
||||
*/
|
||||
|
||||
void * /* O - Search context */
|
||||
cgiCompileSearch(const char *query) /* I - Query string */
|
||||
{
|
||||
regex_t *re; /* Regular expression */
|
||||
char *s, /* Regular expression string */
|
||||
*sptr, /* Pointer into RE string */
|
||||
*sword; /* Pointer to start of word */
|
||||
int slen; /* Allocated size of RE string */
|
||||
const char *qptr, /* Pointer into query string */
|
||||
*qend; /* End of current word */
|
||||
const char *prefix; /* Prefix to add to next word */
|
||||
int quoted; /* Word is quoted */
|
||||
int wlen; /* Word length */
|
||||
char *lword; /* Last word in query */
|
||||
|
||||
|
||||
DEBUG_printf(("help_compile_search(query=\"%s\")\n", query ? query : "(nil)"));
|
||||
|
||||
/*
|
||||
* Allocate a regular expression storage structure...
|
||||
*/
|
||||
|
||||
if ((re = (regex_t *)calloc(1, sizeof(regex_t))) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Allocate a buffer to hold the regular expression string, starting
|
||||
* at 1024 bytes or 3 times the length of the query string, whichever
|
||||
* is greater. We'll expand the string as needed...
|
||||
*/
|
||||
|
||||
slen = strlen(query) * 3;
|
||||
if (slen < 1024)
|
||||
slen = 1024;
|
||||
|
||||
if ((s = (char *)malloc(slen)) == NULL)
|
||||
{
|
||||
free(re);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the query string to the regular expression, handling basic
|
||||
* AND and OR logic...
|
||||
*/
|
||||
|
||||
prefix = ".*";
|
||||
qptr = query;
|
||||
sptr = s;
|
||||
lword = NULL;
|
||||
|
||||
while (*qptr)
|
||||
{
|
||||
/*
|
||||
* Skip leading whitespace...
|
||||
*/
|
||||
|
||||
while (isspace(*qptr & 255))
|
||||
qptr ++;
|
||||
|
||||
if (!*qptr)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Find the end of the current word...
|
||||
*/
|
||||
|
||||
if (*qptr == '\"' || *qptr == '\'')
|
||||
{
|
||||
/*
|
||||
* Scan quoted string...
|
||||
*/
|
||||
|
||||
quoted = *qptr ++;
|
||||
for (qend = qptr; *qend && *qend != quoted; qend ++);
|
||||
|
||||
if (!*qend)
|
||||
{
|
||||
/*
|
||||
* No closing quote, error out!
|
||||
*/
|
||||
|
||||
free(s);
|
||||
free(re);
|
||||
|
||||
if (lword)
|
||||
free(lword);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Scan whitespace-delimited string...
|
||||
*/
|
||||
|
||||
quoted = 0;
|
||||
for (qend = qptr + 1; *qend && !isspace(*qend); qend ++);
|
||||
}
|
||||
|
||||
wlen = qend - qptr;
|
||||
|
||||
/*
|
||||
* Look for logic words: AND, OR
|
||||
*/
|
||||
|
||||
if (wlen == 3 && !strncasecmp(qptr, "AND", 3))
|
||||
{
|
||||
/*
|
||||
* Logical AND with the following text...
|
||||
*/
|
||||
|
||||
if (sptr > s)
|
||||
prefix = ".*";
|
||||
|
||||
qptr = qend;
|
||||
}
|
||||
else if (wlen == 2 && !strncasecmp(qptr, "OR", 2))
|
||||
{
|
||||
/*
|
||||
* Logical OR with the following text...
|
||||
*/
|
||||
|
||||
if (sptr > s)
|
||||
prefix = ".*|.*";
|
||||
|
||||
qptr = qend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Add a search word, making sure we have enough room for the
|
||||
* string + RE overhead...
|
||||
*/
|
||||
|
||||
wlen = (sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
|
||||
if (lword)
|
||||
wlen += strlen(lword);
|
||||
|
||||
if (wlen > slen)
|
||||
{
|
||||
/*
|
||||
* Expand the RE string buffer...
|
||||
*/
|
||||
|
||||
char *temp; /* Temporary string pointer */
|
||||
|
||||
|
||||
slen = wlen + 128;
|
||||
temp = (char *)realloc(s, slen);
|
||||
if (!temp)
|
||||
{
|
||||
free(s);
|
||||
free(re);
|
||||
|
||||
if (lword)
|
||||
free(lword);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
sptr = temp + (sptr - s);
|
||||
s = temp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the prefix string...
|
||||
*/
|
||||
|
||||
strcpy(sptr, prefix);
|
||||
sptr += strlen(sptr);
|
||||
|
||||
/*
|
||||
* Then quote the remaining word characters as needed for the
|
||||
* RE...
|
||||
*/
|
||||
|
||||
sword = sptr;
|
||||
|
||||
while (qptr < qend)
|
||||
{
|
||||
/*
|
||||
* Quote: ^ . [ $ ( ) | * + ? { \
|
||||
*/
|
||||
|
||||
if (strchr("^.[$()|*+?{\\", *qptr))
|
||||
*sptr++ = '\\';
|
||||
|
||||
*sptr++ = *qptr++;
|
||||
}
|
||||
|
||||
*sptr = '\0';
|
||||
|
||||
/*
|
||||
* For "word1 AND word2", add reciprocal "word2 AND word1"...
|
||||
*/
|
||||
|
||||
if (!strcmp(prefix, ".*") && lword)
|
||||
{
|
||||
char *lword2; /* New "last word" */
|
||||
|
||||
|
||||
if ((lword2 = strdup(sword)) == NULL)
|
||||
{
|
||||
free(lword);
|
||||
free(s);
|
||||
free(re);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
strcpy(sptr, ".*|.*");
|
||||
sptr += 5;
|
||||
|
||||
strcpy(sptr, lword2);
|
||||
sptr += strlen(sptr);
|
||||
|
||||
strcpy(sptr, ".*");
|
||||
sptr += 2;
|
||||
|
||||
strcpy(sptr, lword);
|
||||
sptr += strlen(sptr);
|
||||
|
||||
free(lword);
|
||||
lword = lword2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lword)
|
||||
free(lword);
|
||||
|
||||
lword = strdup(sword);
|
||||
}
|
||||
|
||||
prefix = ".*|.*";
|
||||
}
|
||||
|
||||
/*
|
||||
* Advance to the next string...
|
||||
*/
|
||||
|
||||
if (quoted)
|
||||
qptr ++;
|
||||
}
|
||||
|
||||
if (lword)
|
||||
free(lword);
|
||||
|
||||
if (sptr > s)
|
||||
strcpy(sptr, ".*");
|
||||
else
|
||||
{
|
||||
/*
|
||||
* No query data, return NULL...
|
||||
*/
|
||||
|
||||
free(s);
|
||||
free(re);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile the regular expression...
|
||||
*/
|
||||
|
||||
DEBUG_printf((" s=\"%s\"\n", s));
|
||||
|
||||
if (regcomp(re, s, REG_EXTENDED | REG_ICASE))
|
||||
{
|
||||
free(re);
|
||||
free(s);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the RE string and return the new regular expression we compiled...
|
||||
*/
|
||||
|
||||
free(s);
|
||||
|
||||
return ((void *)re);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiDoSearch()' - Do a search of some text.
|
||||
*/
|
||||
|
||||
int /* O - Number of matches */
|
||||
cgiDoSearch(void *search, /* I - Search context */
|
||||
const char *text) /* I - Text to search */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
regmatch_t matches[100]; /* RE matches */
|
||||
|
||||
|
||||
/*
|
||||
* Range check...
|
||||
*/
|
||||
|
||||
if (!search || !text)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Do a lookup...
|
||||
*/
|
||||
|
||||
if (!regexec((regex_t *)search, text, sizeof(matches) / sizeof(matches[0]),
|
||||
matches, 0))
|
||||
{
|
||||
/*
|
||||
* Figure out the number of matches in the string...
|
||||
*/
|
||||
|
||||
for (i = 0; i < (int)(sizeof(matches) / sizeof(matches[0])); i ++)
|
||||
if (matches[i].rm_so < 0)
|
||||
break;
|
||||
|
||||
return (i);
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiFreeSearch()' - Free a compiled search context.
|
||||
*/
|
||||
|
||||
void
|
||||
cgiFreeSearch(void *search) /* I - Search context */
|
||||
{
|
||||
regfree((regex_t *)search);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+260
-78
@@ -3,41 +3,39 @@
|
||||
*
|
||||
* CGI template function.
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2006 by Easy Software Products.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* cgiCopyTemplateFile() - Copy a template file and replace all the
|
||||
* '{variable}' strings with the variable value.
|
||||
* cgiCopyTemplateLang() - Copy a template file using a language...
|
||||
* cgiGetTemplateDir() - Get the templates directory...
|
||||
* cgiSetServerVersion() - Set the server name and CUPS version...
|
||||
* cgi_copy() - Copy the template file, substituting as needed...
|
||||
* cgi_puts() - Put a string to the output file, quoting as
|
||||
* needed...
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
#include "cgi-private.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static void cgi_copy(FILE *out, FILE *in, int element, char term);
|
||||
static void cgi_copy(FILE *out, FILE *in, int element, char term,
|
||||
int indent);
|
||||
static void cgi_puts(const char *s, FILE *out);
|
||||
static void cgi_puturi(const char *s, FILE *out);
|
||||
|
||||
|
||||
/*
|
||||
@@ -52,18 +50,32 @@ cgiCopyTemplateFile(FILE *out, /* I - Output file */
|
||||
FILE *in; /* Input file */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG2: cgiCopyTemplateFile(out=%p, tmpl=\"%s\")\n", out,
|
||||
tmpl ? tmpl : "(null)");
|
||||
|
||||
/*
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (!tmpl || !out)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Open the template file...
|
||||
*/
|
||||
|
||||
if ((in = fopen(tmpl, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open template file \"%s\" - %s\n",
|
||||
tmpl ? tmpl : "(null)", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the file to the end...
|
||||
*/
|
||||
|
||||
cgi_copy(out, in, 0, 0);
|
||||
cgi_copy(out, in, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* Close the template file and return...
|
||||
@@ -78,60 +90,74 @@ cgiCopyTemplateFile(FILE *out, /* I - Output file */
|
||||
*/
|
||||
|
||||
void
|
||||
cgiCopyTemplateLang(FILE *out, /* I - Output file */
|
||||
const char *directory, /* I - Directory */
|
||||
const char *tmpl, /* I - Base filename */
|
||||
const char *lang) /* I - Language */
|
||||
cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
char filename[1024], /* Filename */
|
||||
locale[16]; /* Locale name */
|
||||
FILE *in; /* Input file */
|
||||
char filename[1024], /* Filename */
|
||||
locale[16], /* Locale name */
|
||||
*locptr; /* Pointer into locale name */
|
||||
const char *directory, /* Directory for templates */
|
||||
*lang; /* Language */
|
||||
FILE *in; /* Input file */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG2: cgiCopyTemplateLang(tmpl=\"%s\")\n",
|
||||
tmpl ? tmpl : "(null)");
|
||||
|
||||
/*
|
||||
* Convert the language to a locale name...
|
||||
*/
|
||||
|
||||
if (lang != NULL)
|
||||
{
|
||||
for (i = 0; lang[i] && i < 15; i ++)
|
||||
if (isalnum(lang[i] & 255))
|
||||
locale[i] = tolower(lang[i]);
|
||||
else
|
||||
locale[i] = '_';
|
||||
locale[0] = '\0';
|
||||
|
||||
locale[i] = '\0';
|
||||
if ((lang = getenv("LANG")) != NULL)
|
||||
{
|
||||
locale[0] = '/';
|
||||
strlcpy(locale + 1, lang, sizeof(locale) - 1);
|
||||
|
||||
if ((locptr = strchr(locale, '.')) != NULL)
|
||||
*locptr = '\0'; /* Strip charset */
|
||||
}
|
||||
else
|
||||
locale[0] = '\0';
|
||||
|
||||
fprintf(stderr, "DEBUG: lang=\"%s\", locale=\"%s\"...\n",
|
||||
lang ? lang : "(null)", locale);
|
||||
|
||||
/*
|
||||
* See if we have a template file for this language...
|
||||
*/
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s/%s/%s", directory, locale, tmpl);
|
||||
if (access(filename, 0))
|
||||
{
|
||||
locale[2] = '\0';
|
||||
directory = cgiGetTemplateDir();
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s/%s/%s", directory, locale, tmpl);
|
||||
if (access(filename, 0))
|
||||
snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
|
||||
if ((in = fopen(filename, "r")) == NULL)
|
||||
{
|
||||
locale[3] = '\0';
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
|
||||
if ((in = fopen(filename, "r")) == NULL)
|
||||
{
|
||||
snprintf(filename, sizeof(filename), "%s/%s", directory, tmpl);
|
||||
in = fopen(filename, "r");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG2: Template file is \"%s\"...\n", filename);
|
||||
|
||||
/*
|
||||
* Open the template file...
|
||||
*/
|
||||
|
||||
if ((in = fopen(filename, "r")) == NULL)
|
||||
if (!in)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unable to open template file \"%s\" - %s\n",
|
||||
filename, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the file to the end...
|
||||
*/
|
||||
|
||||
cgi_copy(out, in, 0, 0);
|
||||
cgi_copy(stdout, in, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* Close the template file and return...
|
||||
@@ -141,31 +167,80 @@ cgiCopyTemplateLang(FILE *out, /* I - Output file */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiGetTemplateDir()' - Get the templates directory...
|
||||
*/
|
||||
|
||||
char * /* O - Template directory */
|
||||
cgiGetTemplateDir(void)
|
||||
{
|
||||
const char *datadir; /* CUPS_DATADIR env var */
|
||||
static char templates[1024] = ""; /* Template directory */
|
||||
|
||||
|
||||
if (!templates[0])
|
||||
{
|
||||
/*
|
||||
* Build the template directory pathname...
|
||||
*/
|
||||
|
||||
if ((datadir = getenv("CUPS_DATADIR")) == NULL)
|
||||
datadir = CUPS_DATADIR;
|
||||
|
||||
snprintf(templates, sizeof(templates), "%s/templates", datadir);
|
||||
}
|
||||
|
||||
return (templates);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiSetServerVersion()' - Set the server name and CUPS version...
|
||||
*/
|
||||
|
||||
void
|
||||
cgiSetServerVersion(void)
|
||||
{
|
||||
cgiSetVariable("SERVER_NAME", getenv("SERVER_NAME"));
|
||||
cgiSetVariable("REMOTE_USER", getenv("REMOTE_USER"));
|
||||
cgiSetVariable("CUPS_VERSION", CUPS_SVERSION);
|
||||
|
||||
#ifdef LC_TIME
|
||||
setlocale(LC_TIME, "");
|
||||
#endif /* LC_TIME */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_copy()' - Copy the template file, substituting as needed...
|
||||
*/
|
||||
|
||||
static void
|
||||
cgi_copy(FILE *out, /* I - Output file */
|
||||
FILE *in, /* I - Input file */
|
||||
int element, /* I - Element number (0 to N) */
|
||||
char term) /* I - Terminating character */
|
||||
cgi_copy(FILE *out, /* I - Output file */
|
||||
FILE *in, /* I - Input file */
|
||||
int element, /* I - Element number (0 to N) */
|
||||
char term, /* I - Terminating character */
|
||||
int indent) /* I - Debug info indentation */
|
||||
{
|
||||
int ch; /* Character from file */
|
||||
char op; /* Operation */
|
||||
char name[255], /* Name of variable */
|
||||
*nameptr, /* Pointer into name */
|
||||
innername[255], /* Inner comparison name */
|
||||
*innerptr, /* Pointer into inner name */
|
||||
*s; /* String pointer */
|
||||
const char *value; /* Value of variable */
|
||||
const char *innerval; /* Inner value */
|
||||
const char *outptr; /* Output string pointer */
|
||||
char outval[1024], /* Formatted output string */
|
||||
compare[1024]; /* Comparison string */
|
||||
int result; /* Result of comparison */
|
||||
int ch; /* Character from file */
|
||||
char op; /* Operation */
|
||||
char name[255], /* Name of variable */
|
||||
*nameptr, /* Pointer into name */
|
||||
innername[255], /* Inner comparison name */
|
||||
*innerptr, /* Pointer into inner name */
|
||||
*s; /* String pointer */
|
||||
const char *value; /* Value of variable */
|
||||
const char *innerval; /* Inner value */
|
||||
const char *outptr; /* Output string pointer */
|
||||
char outval[1024], /* Formatted output string */
|
||||
compare[1024]; /* Comparison string */
|
||||
int result; /* Result of comparison */
|
||||
int uriencode; /* Encode as URI */
|
||||
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sStarting at file position %ld...\n", indent, "",
|
||||
ftell(in));
|
||||
|
||||
/*
|
||||
* Parse the file to the end...
|
||||
*/
|
||||
@@ -179,9 +254,13 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
* Get a variable name...
|
||||
*/
|
||||
|
||||
uriencode = 0;
|
||||
|
||||
for (s = name; (ch = getc(in)) != EOF;)
|
||||
if (strchr("}]<>=! \t\n", ch))
|
||||
break;
|
||||
else if (s == name && ch == '%')
|
||||
uriencode = 1;
|
||||
else if (s > name && ch == '?')
|
||||
break;
|
||||
else if (s < (name + sizeof(name) - 1))
|
||||
@@ -191,6 +270,8 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
|
||||
if (s == name && isspace(ch & 255))
|
||||
{
|
||||
fprintf(stderr, "DEBUG2: %*sLone { at %ld...\n", indent, "", ftell(in));
|
||||
|
||||
if (out)
|
||||
{
|
||||
putc('{', out);
|
||||
@@ -200,6 +281,10 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '}')
|
||||
fprintf(stderr, "DEBUG2: %*s\"{%s}\" at %ld...\n", indent, "", name,
|
||||
ftell(in));
|
||||
|
||||
/*
|
||||
* See if it has a value...
|
||||
*/
|
||||
@@ -261,16 +346,24 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
|
||||
pos = ftell(in);
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sLooping on \"%s\" at %ld, count=%d...\n",
|
||||
indent, "", name + 1, pos, count);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
for (i = 0; i < count; i ++)
|
||||
{
|
||||
fseek(in, pos, SEEK_SET);
|
||||
cgi_copy(out, in, i, '}');
|
||||
if (i)
|
||||
fseek(in, pos, SEEK_SET);
|
||||
|
||||
cgi_copy(out, in, i, '}', indent + 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
cgi_copy(NULL, in, 0, '}');
|
||||
cgi_copy(NULL, in, 0, '}', indent + 2);
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sFinished looping on \"%s\"...\n", indent,
|
||||
"", name + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -311,7 +404,14 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
*/
|
||||
|
||||
if (out)
|
||||
cgi_puts(outptr, out);
|
||||
{
|
||||
if (uriencode)
|
||||
cgi_puturi(outptr, out);
|
||||
else if (!strcasecmp(name, "?cupsdconf_default"))
|
||||
fputs(outptr, stdout);
|
||||
else
|
||||
cgi_puts(outptr, out);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -326,13 +426,16 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
* {name!value?true:false} Not equal
|
||||
*/
|
||||
|
||||
op = ch;
|
||||
|
||||
if (ch == '?')
|
||||
{
|
||||
/*
|
||||
* Test for existance...
|
||||
*/
|
||||
|
||||
result = cgiGetArray(name, element) != NULL && outptr[0];
|
||||
result = cgiGetArray(name, element) != NULL && outptr[0];
|
||||
compare[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -340,8 +443,6 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
* Compare to a string...
|
||||
*/
|
||||
|
||||
op = ch;
|
||||
|
||||
for (s = compare; (ch = getc(in)) != EOF;)
|
||||
if (ch == '?')
|
||||
break;
|
||||
@@ -383,7 +484,7 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
strlcpy(s, innerval, sizeof(compare) - (s - compare));
|
||||
}
|
||||
else if ((innerval = cgiGetArray(innername, element)) == NULL)
|
||||
snprintf(s, sizeof(s), "{%s}", innername);
|
||||
snprintf(s, sizeof(compare) - (s - compare), "{%s}", innername);
|
||||
else
|
||||
strlcpy(s, innerval, sizeof(compare) - (s - compare));
|
||||
|
||||
@@ -397,7 +498,12 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
*s = '\0';
|
||||
|
||||
if (ch != '?')
|
||||
{
|
||||
fprintf(stderr,
|
||||
"DEBUG2: %*sBad terminator '%c' at file position %ld...\n",
|
||||
indent, "", ch, ftell(in));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the comparison...
|
||||
@@ -423,14 +529,21 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"DEBUG2: %*sStarting \"{%s%c%s\" at %ld, result=%d...\n",
|
||||
indent, "", name, op, compare, ftell(in), result);
|
||||
|
||||
if (result)
|
||||
{
|
||||
/*
|
||||
* Comparison true; output first part and ignore second...
|
||||
*/
|
||||
|
||||
cgi_copy(out, in, element, ':');
|
||||
cgi_copy(NULL, in, element, '}');
|
||||
fprintf(stderr, "DEBUG2: %*sOutput first part...\n", indent, "");
|
||||
cgi_copy(out, in, element, ':', indent + 2);
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sSkip second part...\n", indent, "");
|
||||
cgi_copy(NULL, in, element, '}', indent + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -438,9 +551,15 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
* Comparison false; ignore first part and output second...
|
||||
*/
|
||||
|
||||
cgi_copy(NULL, in, element, ':');
|
||||
cgi_copy(out, in, element, '}');
|
||||
fprintf(stderr, "DEBUG2: %*sSkip first part...\n", indent, "");
|
||||
cgi_copy(NULL, in, element, ':', indent + 2);
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sOutput second part...\n", indent, "");
|
||||
cgi_copy(out, in, element, '}', indent + 2);
|
||||
}
|
||||
|
||||
fprintf(stderr, "DEBUG2: %*sFinished \"{%s%c%s\", out=%p...\n", indent, "",
|
||||
name, op, compare, out);
|
||||
}
|
||||
else if (ch == '\\') /* Quoted char */
|
||||
{
|
||||
@@ -452,6 +571,17 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
else if (out)
|
||||
putc(ch, out);
|
||||
|
||||
if (ch == EOF)
|
||||
fprintf(stderr, "DEBUG2: %*sReturning at file position %ld on EOF...\n",
|
||||
indent, "", ftell(in));
|
||||
else
|
||||
fprintf(stderr,
|
||||
"DEBUG2: %*sReturning at file position %ld on character '%c'...\n",
|
||||
indent, "", ftell(in), ch);
|
||||
|
||||
if (ch == EOF && term)
|
||||
fprintf(stderr, "ERROR: %*sSaw EOF, expected '%c'!\n", indent, "", term);
|
||||
|
||||
/*
|
||||
* Flush any pending output...
|
||||
*/
|
||||
@@ -466,18 +596,50 @@ cgi_copy(FILE *out, /* I - Output file */
|
||||
*/
|
||||
|
||||
static void
|
||||
cgi_puts(const char *s,
|
||||
FILE *out)
|
||||
cgi_puts(const char *s, /* I - String to output */
|
||||
FILE *out) /* I - Output file */
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
if (s[0] == '<')
|
||||
fputs("<", out);
|
||||
else if (s[0] == '>')
|
||||
if (*s == '<')
|
||||
{
|
||||
/*
|
||||
* Pass <A HREF="url"> and </A>, otherwise quote it...
|
||||
*/
|
||||
|
||||
if (!strncasecmp(s, "<A HREF=\"", 9))
|
||||
{
|
||||
fputs("<A HREF=\"", out);
|
||||
s += 9;
|
||||
|
||||
while (*s && *s != '\"')
|
||||
{
|
||||
if (*s == '&')
|
||||
fputs("&", out);
|
||||
else
|
||||
putc(*s, out);
|
||||
|
||||
s ++;
|
||||
}
|
||||
|
||||
if (*s)
|
||||
s ++;
|
||||
|
||||
fputs("\">", out);
|
||||
}
|
||||
else if (!strncasecmp(s, "</A>", 4))
|
||||
{
|
||||
fputs("</A>", out);
|
||||
s += 3;
|
||||
}
|
||||
else
|
||||
fputs("<", out);
|
||||
}
|
||||
else if (*s == '>')
|
||||
fputs(">", out);
|
||||
else if (*s == '\"')
|
||||
fputs(""", out);
|
||||
else if (s[0] == '&')
|
||||
else if (*s == '&')
|
||||
fputs("&", out);
|
||||
else
|
||||
putc(*s, out);
|
||||
@@ -487,6 +649,26 @@ cgi_puts(const char *s,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_puturi()' - Put a URI string to the output file, quoting as needed...
|
||||
*/
|
||||
|
||||
static void
|
||||
cgi_puturi(const char *s, /* I - String to output */
|
||||
FILE *out) /* I - Output file */
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
if (strchr("%&+ <>#=", *s) || *s & 128)
|
||||
fprintf(out, "%%%02X", *s & 255);
|
||||
else
|
||||
putc(*s, out);
|
||||
|
||||
s ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* CGI test program for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2005 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Test the help index code.
|
||||
* list_nodes() - List nodes in an array...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Test the CGI code.
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
/*
|
||||
* Test file upload/multi-part submissions...
|
||||
*/
|
||||
|
||||
freopen("multipart.dat", "rb", stdin);
|
||||
|
||||
putenv("CONTENT_TYPE=multipart/form-data; "
|
||||
"boundary=---------------------------1977426492562745908748943111");
|
||||
putenv("REQUEST_METHOD=POST");
|
||||
|
||||
printf("cgiInitialize: ");
|
||||
if (cgiInitialize())
|
||||
{
|
||||
const cgi_file_t *file; /* Upload file */
|
||||
|
||||
if ((file = cgiGetFile()) != NULL)
|
||||
{
|
||||
puts("PASS");
|
||||
printf(" tempfile=\"%s\"\n", file->tempfile);
|
||||
printf(" name=\"%s\"\n", file->name);
|
||||
printf(" filename=\"%s\"\n", file->filename);
|
||||
printf(" mimetype=\"%s\"\n", file->mimetype);
|
||||
}
|
||||
else
|
||||
puts("FAIL (no file!)");
|
||||
}
|
||||
else
|
||||
puts("FAIL (init)");
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* Help index test program for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 1997-2007 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Test the help index code.
|
||||
* list_nodes() - List nodes in an array...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static void list_nodes(const char *title, cups_array_t *nodes);
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Test the help index code.
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
help_index_t *hi, /* Help index */
|
||||
*search; /* Search index */
|
||||
|
||||
|
||||
/*
|
||||
* Load the help index...
|
||||
*/
|
||||
|
||||
hi = helpLoadIndex("testhi.index", ".");
|
||||
|
||||
list_nodes("nodes", hi->nodes);
|
||||
list_nodes("sorted", hi->sorted);
|
||||
|
||||
/*
|
||||
* Do any searches...
|
||||
*/
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
search = helpSearchIndex(hi, argv[1], NULL, argv[2]);
|
||||
|
||||
if (search)
|
||||
{
|
||||
list_nodes(argv[1], search->sorted);
|
||||
helpDeleteIndex(search);
|
||||
}
|
||||
else
|
||||
printf("%s (0 nodes)\n", argv[1]);
|
||||
}
|
||||
|
||||
helpDeleteIndex(hi);
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'list_nodes()' - List nodes in an array...
|
||||
*/
|
||||
|
||||
static void
|
||||
list_nodes(const char *title, /* I - Title string */
|
||||
cups_array_t *nodes) /* I - Nodes */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
help_node_t *node; /* Current node */
|
||||
|
||||
|
||||
printf("%s (%d nodes):\n", title, cupsArrayCount(nodes));
|
||||
for (i = 1, node = (help_node_t *)cupsArrayFirst(nodes);
|
||||
node;
|
||||
i ++, node = (help_node_t *)cupsArrayNext(nodes))
|
||||
{
|
||||
if (node->anchor)
|
||||
printf(" %d: %s#%s \"%s\"", i, node->filename, node->anchor,
|
||||
node->text);
|
||||
else
|
||||
printf(" %d: %s \"%s\"", i, node->filename, node->text);
|
||||
|
||||
printf(" (%d words)\n", cupsArrayCount(node->words));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
@@ -0,0 +1,31 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Test File for Help Index Code</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<P>This is a test file for the help index code. The help index
|
||||
code reads plain HTML and indexes the title and any anchored
|
||||
text, ignoring all other markup. Anchor tags must be on a single
|
||||
line, although the text they wrap may cross multiple lines and be
|
||||
up to 1024 bytes in length.</P>
|
||||
|
||||
<H1><A NAME="FIRST">This is the First Anchor</A></H1>
|
||||
|
||||
<P>This is some text for the <em>first</em> anchor.</P>
|
||||
|
||||
|
||||
<H1><A NAME="2ND">This is the Second Anchor</A></H1>
|
||||
|
||||
<P>This is some text for the first anchor.</P>
|
||||
|
||||
<P>John asked Mary to the dance.</P>
|
||||
|
||||
|
||||
<H1><A NAME="THIRD">This is the Third Anchor</A></H1>
|
||||
|
||||
<P>This is some text for the third anchor. <A NAME="INLINE">This
|
||||
is an in-line anchor that crosses a line.</A></P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* "$Id$"
|
||||
*
|
||||
* CGI template test program for the Common UNIX Printing System (CUPS).
|
||||
*
|
||||
* Copyright 2007 by Apple Inc.
|
||||
* Copyright 2006 by Easy Software Products.
|
||||
*
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* main() - Test the template code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
#include "cgi.h"
|
||||
|
||||
|
||||
/*
|
||||
* 'main()' - Test the template code.
|
||||
*/
|
||||
|
||||
int /* O - Exit status */
|
||||
main(int argc, /* I - Number of command-line arguments */
|
||||
char *argv[]) /* I - Command-line arguments */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
char *value; /* Value in name=value */
|
||||
FILE *out; /* Where to send output */
|
||||
|
||||
|
||||
/*
|
||||
* Don't buffer stdout or stderr so that the mixed output is sane...
|
||||
*/
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/*
|
||||
* Loop through the command-line, assigning variables for any args with
|
||||
* "name=value"...
|
||||
*/
|
||||
|
||||
out = stdout;
|
||||
|
||||
for (i = 1; i < argc; i ++)
|
||||
{
|
||||
if (!strcmp(argv[i], "-o"))
|
||||
{
|
||||
i ++;
|
||||
if (i < argc)
|
||||
{
|
||||
out = fopen(argv[i], "w");
|
||||
if (!out)
|
||||
{
|
||||
perror(argv[i]);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[i], "-e"))
|
||||
{
|
||||
i ++;
|
||||
|
||||
if (i < argc)
|
||||
{
|
||||
if (!freopen(argv[i], "w", stderr))
|
||||
{
|
||||
perror(argv[i]);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[i], "-q"))
|
||||
freopen("/dev/null", "w", stderr);
|
||||
else if ((value = strchr(argv[i], '=')) != NULL)
|
||||
{
|
||||
*value++ = '\0';
|
||||
cgiSetVariable(argv[i], value);
|
||||
}
|
||||
else
|
||||
cgiCopyTemplateFile(out, argv[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return with no errors...
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
+518
-130
@@ -3,109 +3,85 @@
|
||||
*
|
||||
* CGI form variable and array functions.
|
||||
*
|
||||
* Copyright 1997-2004 by Easy Software Products.
|
||||
* Copyright 2007-2008 by Apple Inc.
|
||||
* Copyright 1997-2005 by Easy Software Products.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* These coded instructions, statements, and computer programs are the
|
||||
* property of Apple Inc. 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
|
||||
* file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
*
|
||||
* Contents:
|
||||
*
|
||||
* cgiInitialize() - Initialize the CGI variable "database"...
|
||||
* cgiCheckVariables() - Check for the presence of "required" variables.
|
||||
* cgiGetArray() - Get an element from a form array...
|
||||
* cgiGetSize() - Get the size of a form array value.
|
||||
* cgiGetVariable() - Get a CGI variable from the database...
|
||||
* cgiSetArray() - Set array element N to the specified string.
|
||||
* cgiSetVariable() - Set a CGI variable in the database...
|
||||
* cgi_add_variable() - Add a form variable.
|
||||
* cgi_compare_variables() - Compare two variables.
|
||||
* cgi_find_variable() - Find a variable...
|
||||
* cgi_initialize_get() - Initialize form variables using the GET method.
|
||||
* cgi_initialize_post() - Initialize variables using the POST method.
|
||||
* cgi_initialize_string() - Initialize form variables from a string.
|
||||
* cgi_sort_variables() - Sort all form variables for faster lookup.
|
||||
* cgiCheckVariables() - Check for the presence of "required" variables.
|
||||
* cgiGetArray() - Get an element from a form array...
|
||||
* cgiGetFile() - Get the file (if any) that was submitted in the form.
|
||||
* cgiGetSize() - Get the size of a form array value.
|
||||
* cgiGetVariable() - Get a CGI variable from the database...
|
||||
* cgiInitialize() - Initialize the CGI variable "database"...
|
||||
* cgiIsPOST() - Determine whether this page was POSTed.
|
||||
* cgiSetArray() - Set array element N to the specified string.
|
||||
* cgiSetSize() - Set the array size.
|
||||
* cgiSetVariable() - Set a CGI variable in the database...
|
||||
* cgi_add_variable() - Add a form variable.
|
||||
* cgi_compare_variables() - Compare two variables.
|
||||
* cgi_find_variable() - Find a variable...
|
||||
* cgi_initialize_get() - Initialize form variables using the GET method.
|
||||
* cgi_initialize_multipart() - Initialize variables and file using the POST method.
|
||||
* cgi_initialize_post() - Initialize variables using the POST method.
|
||||
* cgi_initialize_string() - Initialize form variables from a string.
|
||||
* cgi_passwd() - Catch authentication requests and notify the server.
|
||||
* cgi_sort_variables() - Sort all form variables for faster lookup.
|
||||
* cgi_unlink_file() - Remove the uploaded form.
|
||||
*/
|
||||
|
||||
/*#define DEBUG*/
|
||||
#include "cgi.h"
|
||||
#include "cgi-private.h"
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
|
||||
|
||||
/*
|
||||
* Data structure to hold all the CGI form variables and arrays...
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
typedef struct /**** Form variable structure ****/
|
||||
{
|
||||
const char *name; /* Name of variable */
|
||||
int nvalues, /* Number of values */
|
||||
avalues; /* Number of values allocated */
|
||||
const char **values; /* Value(s) of variable */
|
||||
} var_t;
|
||||
const char *name; /* Name of variable */
|
||||
int nvalues, /* Number of values */
|
||||
avalues; /* Number of values allocated */
|
||||
const char **values; /* Value(s) of variable */
|
||||
} _cgi_var_t;
|
||||
|
||||
|
||||
/*
|
||||
* Local globals...
|
||||
*/
|
||||
|
||||
static int form_count = 0, /* Form variable count */
|
||||
form_alloc = 0; /* Number of variables allocated */
|
||||
static var_t *form_vars = NULL; /* Form variables */
|
||||
static int form_count = 0, /* Form variable count */
|
||||
form_alloc = 0; /* Number of variables allocated */
|
||||
static _cgi_var_t *form_vars = NULL;
|
||||
/* Form variables */
|
||||
static cgi_file_t *form_file = NULL;
|
||||
/* Uploaded file */
|
||||
|
||||
|
||||
/*
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static void cgi_add_variable(const char *name, int element,
|
||||
const char *value);
|
||||
static int cgi_compare_variables(const var_t *v1, const var_t *v2);
|
||||
static var_t *cgi_find_variable(const char *name);
|
||||
static int cgi_initialize_get(void);
|
||||
static int cgi_initialize_post(void);
|
||||
static int cgi_initialize_string(const char *data);
|
||||
static void cgi_sort_variables(void);
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiInitialize()' - Initialize the CGI variable "database"...
|
||||
*/
|
||||
|
||||
int /* O - Non-zero if there was form data */
|
||||
cgiInitialize(void)
|
||||
{
|
||||
char *method; /* Form posting method */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
setbuf(stdout, NULL);
|
||||
puts("Content-type: text/plain\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
method = getenv("REQUEST_METHOD");
|
||||
|
||||
if (method == NULL)
|
||||
return (0);
|
||||
|
||||
if (strcasecmp(method, "GET") == 0)
|
||||
return (cgi_initialize_get());
|
||||
else if (strcasecmp(method, "POST") == 0)
|
||||
return (cgi_initialize_post());
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
static void cgi_add_variable(const char *name, int element,
|
||||
const char *value);
|
||||
static int cgi_compare_variables(const _cgi_var_t *v1,
|
||||
const _cgi_var_t *v2);
|
||||
static _cgi_var_t *cgi_find_variable(const char *name);
|
||||
static int cgi_initialize_get(void);
|
||||
static int cgi_initialize_multipart(const char *boundary);
|
||||
static int cgi_initialize_post(void);
|
||||
static int cgi_initialize_string(const char *data);
|
||||
static const char *cgi_passwd(const char *prompt);
|
||||
static void cgi_sort_variables(void);
|
||||
static void cgi_unlink_file(void);
|
||||
|
||||
|
||||
/*
|
||||
@@ -162,11 +138,11 @@ cgiCheckVariables(const char *names) /* I - Variables to look for */
|
||||
* 'cgiGetArray()' - Get an element from a form array...
|
||||
*/
|
||||
|
||||
const char * /* O - Element value or NULL */
|
||||
cgiGetArray(const char *name, /* I - Name of array variable */
|
||||
int element) /* I - Element number (0 to N) */
|
||||
const char * /* O - Element value or NULL */
|
||||
cgiGetArray(const char *name, /* I - Name of array variable */
|
||||
int element) /* I - Element number (0 to N) */
|
||||
{
|
||||
var_t *var; /* Pointer to variable */
|
||||
_cgi_var_t *var; /* Pointer to variable */
|
||||
|
||||
|
||||
if ((var = cgi_find_variable(name)) == NULL)
|
||||
@@ -182,14 +158,25 @@ cgiGetArray(const char *name, /* I - Name of array variable */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiGetFile()' - Get the file (if any) that was submitted in the form.
|
||||
*/
|
||||
|
||||
const cgi_file_t * /* O - Attached file or NULL */
|
||||
cgiGetFile(void)
|
||||
{
|
||||
return (form_file);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiGetSize()' - Get the size of a form array value.
|
||||
*/
|
||||
|
||||
int /* O - Number of elements */
|
||||
cgiGetSize(const char *name) /* I - Name of variable */
|
||||
int /* O - Number of elements */
|
||||
cgiGetSize(const char *name) /* I - Name of variable */
|
||||
{
|
||||
var_t *var; /* Pointer to variable */
|
||||
_cgi_var_t *var; /* Pointer to variable */
|
||||
|
||||
|
||||
if ((var = cgi_find_variable(name)) == NULL)
|
||||
@@ -202,14 +189,14 @@ cgiGetSize(const char *name) /* I - Name of variable */
|
||||
/*
|
||||
* 'cgiGetVariable()' - Get a CGI variable from the database...
|
||||
*
|
||||
* Returns NULL if the variable doesn't exist... If the variable is an
|
||||
* Returns NULL if the variable doesn't exist. If the variable is an
|
||||
* array of values, returns the last element...
|
||||
*/
|
||||
|
||||
const char * /* O - Value of variable */
|
||||
cgiGetVariable(const char *name)/* I - Name of variable */
|
||||
const char * /* O - Value of variable */
|
||||
cgiGetVariable(const char *name) /* I - Name of variable */
|
||||
{
|
||||
const var_t *var; /* Returned variable */
|
||||
const _cgi_var_t *var; /* Returned variable */
|
||||
|
||||
|
||||
var = cgi_find_variable(name);
|
||||
@@ -226,6 +213,87 @@ cgiGetVariable(const char *name)/* I - Name of variable */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiInitialize()' - Initialize the CGI variable "database"...
|
||||
*/
|
||||
|
||||
int /* O - Non-zero if there was form data */
|
||||
cgiInitialize(void)
|
||||
{
|
||||
const char *method; /* Form posting method */
|
||||
const char *content_type; /* Content-Type of post data */
|
||||
|
||||
|
||||
/*
|
||||
* Setup a password callback for authentication...
|
||||
*/
|
||||
|
||||
cupsSetPasswordCB(cgi_passwd);
|
||||
|
||||
/*
|
||||
* Set the locale so that times, etc. are formatted properly...
|
||||
*/
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* Disable output buffering to find bugs...
|
||||
*/
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
puts("Content-type: text/plain\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
* Get the request method (GET or POST)...
|
||||
*/
|
||||
|
||||
method = getenv("REQUEST_METHOD");
|
||||
content_type = getenv("CONTENT_TYPE");
|
||||
if (!method)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Grab form data from the corresponding location...
|
||||
*/
|
||||
|
||||
if (!strcasecmp(method, "GET"))
|
||||
return (cgi_initialize_get());
|
||||
else if (!strcasecmp(method, "POST") && content_type)
|
||||
{
|
||||
const char *boundary = strstr(content_type, "boundary=");
|
||||
|
||||
if (boundary)
|
||||
boundary += 9;
|
||||
|
||||
if (content_type && !strncmp(content_type, "multipart/form-data; ", 21))
|
||||
return (cgi_initialize_multipart(boundary));
|
||||
else
|
||||
return (cgi_initialize_post());
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiIsPOST()' - Determine whether this page was POSTed.
|
||||
*/
|
||||
|
||||
int /* O - 1 if POST, 0 if GET */
|
||||
cgiIsPOST(void)
|
||||
{
|
||||
const char *method; /* REQUEST_METHOD environment variable */
|
||||
|
||||
|
||||
if ((method = getenv("REQUEST_METHOD")) == NULL)
|
||||
return (0);
|
||||
else
|
||||
return (!strcmp(method, "POST"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgiSetArray()' - Set array element N to the specified string.
|
||||
*
|
||||
@@ -234,12 +302,12 @@ cgiGetVariable(const char *name)/* I - Name of variable */
|
||||
*/
|
||||
|
||||
void
|
||||
cgiSetArray(const char *name, /* I - Name of variable */
|
||||
int element, /* I - Element number (0 to N) */
|
||||
const char *value) /* I - Value of variable */
|
||||
cgiSetArray(const char *name, /* I - Name of variable */
|
||||
int element, /* I - Element number (0 to N) */
|
||||
const char *value) /* I - Value of variable */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
var_t *var; /* Returned variable */
|
||||
int i; /* Looping var */
|
||||
_cgi_var_t *var; /* Returned variable */
|
||||
|
||||
|
||||
if (name == NULL || value == NULL || element < 0 || element > 100000)
|
||||
@@ -254,9 +322,15 @@ cgiSetArray(const char *name, /* I - Name of variable */
|
||||
{
|
||||
if (element >= var->avalues)
|
||||
{
|
||||
const char **temp; /* Temporary pointer */
|
||||
|
||||
temp = (const char **)realloc((void *)(var->values),
|
||||
sizeof(char *) * (element + 16));
|
||||
if (!temp)
|
||||
return;
|
||||
|
||||
var->avalues = element + 16;
|
||||
var->values = (const char **)realloc((void *)(var->values),
|
||||
sizeof(char *) * var->avalues);
|
||||
var->values = temp;
|
||||
}
|
||||
|
||||
if (element >= var->nvalues)
|
||||
@@ -279,11 +353,11 @@ cgiSetArray(const char *name, /* I - Name of variable */
|
||||
*/
|
||||
|
||||
void
|
||||
cgiSetSize(const char *name, /* I - Name of variable */
|
||||
int size) /* I - Number of elements (0 to N) */
|
||||
cgiSetSize(const char *name, /* I - Name of variable */
|
||||
int size) /* I - Number of elements (0 to N) */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
var_t *var; /* Returned variable */
|
||||
int i; /* Looping var */
|
||||
_cgi_var_t *var; /* Returned variable */
|
||||
|
||||
|
||||
if (name == NULL || size < 0 || size > 100000)
|
||||
@@ -294,9 +368,15 @@ cgiSetSize(const char *name, /* I - Name of variable */
|
||||
|
||||
if (size >= var->avalues)
|
||||
{
|
||||
const char **temp; /* Temporary pointer */
|
||||
|
||||
temp = (const char **)realloc((void *)(var->values),
|
||||
sizeof(char *) * (size + 16));
|
||||
if (!temp)
|
||||
return;
|
||||
|
||||
var->avalues = size + 16;
|
||||
var->values = (const char **)realloc((void *)(var->values),
|
||||
sizeof(char *) * var->avalues);
|
||||
var->values = temp;
|
||||
}
|
||||
|
||||
if (size > var->nvalues)
|
||||
@@ -325,8 +405,8 @@ void
|
||||
cgiSetVariable(const char *name, /* I - Name of variable */
|
||||
const char *value) /* I - Value of variable */
|
||||
{
|
||||
int i; /* Looping var */
|
||||
var_t *var; /* Returned variable */
|
||||
int i; /* Looping var */
|
||||
_cgi_var_t *var; /* Returned variable */
|
||||
|
||||
|
||||
if (name == NULL || value == NULL)
|
||||
@@ -358,7 +438,7 @@ cgi_add_variable(const char *name, /* I - Variable name */
|
||||
int element, /* I - Array element number */
|
||||
const char *value) /* I - Variable value */
|
||||
{
|
||||
var_t *var; /* New variable */
|
||||
_cgi_var_t *var; /* New variable */
|
||||
|
||||
|
||||
if (name == NULL || value == NULL || element < 0 || element > 100000)
|
||||
@@ -370,19 +450,29 @@ cgi_add_variable(const char *name, /* I - Variable name */
|
||||
|
||||
if (form_count >= form_alloc)
|
||||
{
|
||||
if (form_alloc == 0)
|
||||
form_vars = malloc(sizeof(var_t) * 16);
|
||||
else
|
||||
form_vars = realloc(form_vars, (form_alloc + 16) * sizeof(var_t));
|
||||
_cgi_var_t *temp_vars; /* Temporary form pointer */
|
||||
|
||||
|
||||
if (form_alloc == 0)
|
||||
temp_vars = malloc(sizeof(_cgi_var_t) * 16);
|
||||
else
|
||||
temp_vars = realloc(form_vars, (form_alloc + 16) * sizeof(_cgi_var_t));
|
||||
|
||||
if (!temp_vars)
|
||||
return;
|
||||
|
||||
form_vars = temp_vars;
|
||||
form_alloc += 16;
|
||||
}
|
||||
|
||||
var = form_vars + form_count;
|
||||
var = form_vars + form_count;
|
||||
|
||||
if ((var->values = calloc(element + 1, sizeof(char *))) == NULL)
|
||||
return;
|
||||
|
||||
var->name = strdup(name);
|
||||
var->nvalues = element + 1;
|
||||
var->avalues = element + 1;
|
||||
var->values = calloc(element + 1, sizeof(char *));
|
||||
var->values[element] = strdup(value);
|
||||
|
||||
form_count ++;
|
||||
@@ -394,8 +484,9 @@ cgi_add_variable(const char *name, /* I - Variable name */
|
||||
*/
|
||||
|
||||
static int /* O - Result of comparison */
|
||||
cgi_compare_variables(const var_t *v1, /* I - First variable */
|
||||
const var_t *v2) /* I - Second variable */
|
||||
cgi_compare_variables(
|
||||
const _cgi_var_t *v1, /* I - First variable */
|
||||
const _cgi_var_t *v2) /* I - Second variable */
|
||||
{
|
||||
return (strcasecmp(v1->name, v2->name));
|
||||
}
|
||||
@@ -405,10 +496,10 @@ cgi_compare_variables(const var_t *v1, /* I - First variable */
|
||||
* 'cgi_find_variable()' - Find a variable...
|
||||
*/
|
||||
|
||||
static var_t * /* O - Variable pointer or NULL */
|
||||
static _cgi_var_t * /* O - Variable pointer or NULL */
|
||||
cgi_find_variable(const char *name) /* I - Name of variable */
|
||||
{
|
||||
var_t key; /* Search key */
|
||||
_cgi_var_t key; /* Search key */
|
||||
|
||||
|
||||
if (form_count < 1 || name == NULL)
|
||||
@@ -416,7 +507,7 @@ cgi_find_variable(const char *name) /* I - Name of variable */
|
||||
|
||||
key.name = name;
|
||||
|
||||
return ((var_t *)bsearch(&key, form_vars, form_count, sizeof(var_t),
|
||||
return ((_cgi_var_t *)bsearch(&key, form_vars, form_count, sizeof(_cgi_var_t),
|
||||
(int (*)(const void *, const void *))cgi_compare_variables));
|
||||
}
|
||||
|
||||
@@ -425,10 +516,10 @@ cgi_find_variable(const char *name) /* I - Name of variable */
|
||||
* 'cgi_initialize_get()' - Initialize form variables using the GET method.
|
||||
*/
|
||||
|
||||
static int /* O - 1 if form data read */
|
||||
static int /* O - 1 if form data read */
|
||||
cgi_initialize_get(void)
|
||||
{
|
||||
char *data; /* Pointer to form data string */
|
||||
char *data; /* Pointer to form data string */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -451,19 +542,240 @@ cgi_initialize_get(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_initialize_multipart()' - Initialize variables and file using the POST method.
|
||||
*
|
||||
* TODO: Update to support files > 2GB.
|
||||
*/
|
||||
|
||||
static int /* O - 1 if form data was read */
|
||||
cgi_initialize_multipart(
|
||||
const char *boundary) /* I - Boundary string */
|
||||
{
|
||||
char line[10240], /* MIME header line */
|
||||
name[1024], /* Form variable name */
|
||||
filename[1024], /* Form filename */
|
||||
mimetype[1024], /* MIME media type */
|
||||
bstring[256], /* Boundary string to look for */
|
||||
*ptr, /* Pointer into name/filename */
|
||||
*end; /* End of buffer */
|
||||
int ch, /* Character from file */
|
||||
fd, /* Temporary file descriptor */
|
||||
blen; /* Length of boundary string */
|
||||
|
||||
|
||||
DEBUG_printf(("cgi_initialize_multipart(boundary=\"%s\")\n", boundary));
|
||||
|
||||
/*
|
||||
* Read multipart form data until we run out...
|
||||
*/
|
||||
|
||||
name[0] = '\0';
|
||||
filename[0] = '\0';
|
||||
mimetype[0] = '\0';
|
||||
|
||||
snprintf(bstring, sizeof(bstring), "\r\n--%s", boundary);
|
||||
blen = strlen(bstring);
|
||||
|
||||
while (fgets(line, sizeof(line), stdin))
|
||||
{
|
||||
if (!strcmp(line, "\r\n"))
|
||||
{
|
||||
/*
|
||||
* End of headers, grab value...
|
||||
*/
|
||||
|
||||
if (filename[0])
|
||||
{
|
||||
/*
|
||||
* Read an embedded file...
|
||||
*/
|
||||
|
||||
if (form_file)
|
||||
{
|
||||
/*
|
||||
* Remove previous file...
|
||||
*/
|
||||
|
||||
cgi_unlink_file();
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate memory for the new file...
|
||||
*/
|
||||
|
||||
if ((form_file = calloc(1, sizeof(cgi_file_t))) == NULL)
|
||||
return (0);
|
||||
|
||||
form_file->name = strdup(name);
|
||||
form_file->filename = strdup(filename);
|
||||
form_file->mimetype = strdup(mimetype);
|
||||
|
||||
fd = cupsTempFd(form_file->tempfile, sizeof(form_file->tempfile));
|
||||
|
||||
if (fd < 0)
|
||||
return (0);
|
||||
|
||||
atexit(cgi_unlink_file);
|
||||
|
||||
/*
|
||||
* Copy file data to the temp file...
|
||||
*/
|
||||
|
||||
ptr = line;
|
||||
|
||||
while ((ch = getchar()) != EOF)
|
||||
{
|
||||
*ptr++ = ch;
|
||||
|
||||
if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
|
||||
{
|
||||
ptr -= blen;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ptr - line - blen) >= 8192)
|
||||
{
|
||||
/*
|
||||
* Write out the first 8k of the buffer...
|
||||
*/
|
||||
|
||||
write(fd, line, 8192);
|
||||
memmove(line, line + 8192, ptr - line - 8192);
|
||||
ptr -= 8192;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the rest of the data and close the temp file...
|
||||
*/
|
||||
|
||||
if (ptr > line)
|
||||
write(fd, line, ptr - line);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just get a form variable; the current code only handles
|
||||
* form values up to 10k in size...
|
||||
*/
|
||||
|
||||
ptr = line;
|
||||
end = line + sizeof(line) - 1;
|
||||
|
||||
while ((ch = getchar()) != EOF)
|
||||
{
|
||||
if (ptr < end)
|
||||
*ptr++ = ch;
|
||||
|
||||
if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
|
||||
{
|
||||
ptr -= blen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
|
||||
/*
|
||||
* Set the form variable...
|
||||
*/
|
||||
|
||||
if ((ptr = strrchr(name, '-')) != NULL && isdigit(ptr[1] & 255))
|
||||
{
|
||||
/*
|
||||
* Set a specific index in the array...
|
||||
*/
|
||||
|
||||
*ptr++ = '\0';
|
||||
if (line[0])
|
||||
cgiSetArray(name, atoi(ptr) - 1, line);
|
||||
}
|
||||
else if (cgiGetVariable(name))
|
||||
{
|
||||
/*
|
||||
* Add another element in the array...
|
||||
*/
|
||||
|
||||
cgiSetArray(name, cgiGetSize(name), line);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just set the line...
|
||||
*/
|
||||
|
||||
cgiSetVariable(name, line);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the rest of the current line...
|
||||
*/
|
||||
|
||||
fgets(line, sizeof(line), stdin);
|
||||
|
||||
/*
|
||||
* Clear the state vars...
|
||||
*/
|
||||
|
||||
name[0] = '\0';
|
||||
filename[0] = '\0';
|
||||
mimetype[0] = '\0';
|
||||
}
|
||||
else if (!strncasecmp(line, "Content-Disposition:", 20))
|
||||
{
|
||||
if ((ptr = strstr(line + 20, " name=\"")) != NULL)
|
||||
{
|
||||
strlcpy(name, ptr + 7, sizeof(name));
|
||||
|
||||
if ((ptr = strchr(name, '\"')) != NULL)
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
if ((ptr = strstr(line + 20, " filename=\"")) != NULL)
|
||||
{
|
||||
strlcpy(filename, ptr + 11, sizeof(filename));
|
||||
|
||||
if ((ptr = strchr(filename, '\"')) != NULL)
|
||||
*ptr = '\0';
|
||||
}
|
||||
}
|
||||
else if (!strncasecmp(line, "Content-Type:", 13))
|
||||
{
|
||||
for (ptr = line + 13; isspace(*ptr & 255); ptr ++);
|
||||
|
||||
strlcpy(mimetype, ptr, sizeof(mimetype));
|
||||
|
||||
for (ptr = mimetype + strlen(mimetype) - 1;
|
||||
ptr > mimetype && isspace(*ptr & 255);
|
||||
*ptr-- = '\0');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 for "form data found"...
|
||||
*/
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_initialize_post()' - Initialize variables using the POST method.
|
||||
*/
|
||||
|
||||
static int /* O - 1 if form data was read */
|
||||
static int /* O - 1 if form data was read */
|
||||
cgi_initialize_post(void)
|
||||
{
|
||||
char *content_length, /* Length of input data (string) */
|
||||
*data; /* Pointer to form data string */
|
||||
int length, /* Length of input data */
|
||||
nbytes, /* Number of bytes read this read() */
|
||||
tbytes, /* Total number of bytes read */
|
||||
status; /* Return status */
|
||||
char *content_length, /* Length of input data (string) */
|
||||
*data; /* Pointer to form data string */
|
||||
int length, /* Length of input data */
|
||||
nbytes, /* Number of bytes read this read() */
|
||||
tbytes, /* Total number of bytes read */
|
||||
status; /* Return status */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -494,11 +806,27 @@ cgi_initialize_post(void)
|
||||
|
||||
for (tbytes = 0; tbytes < length; tbytes += nbytes)
|
||||
if ((nbytes = read(0, data + tbytes, length - tbytes)) < 0)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
{
|
||||
free(data);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
nbytes = 0;
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
/*
|
||||
* CUPS STR #3176: OpenBSD: Early end-of-file on POST data causes 100% CPU
|
||||
*
|
||||
* This should never happen, but does on OpenBSD. If we see early end-of-
|
||||
* file, treat this as an error and process no data.
|
||||
*/
|
||||
|
||||
free(data);
|
||||
return (0);
|
||||
}
|
||||
|
||||
data[length] = '\0';
|
||||
|
||||
@@ -522,14 +850,14 @@ cgi_initialize_post(void)
|
||||
* 'cgi_initialize_string()' - Initialize form variables from a string.
|
||||
*/
|
||||
|
||||
static int
|
||||
static int /* O - 1 if form data was processed */
|
||||
cgi_initialize_string(const char *data) /* I - Form data string */
|
||||
{
|
||||
int done; /* True if we're done reading a form variable */
|
||||
char *s, /* Pointer to current form string */
|
||||
ch, /* Temporary character */
|
||||
name[255], /* Name of form variable */
|
||||
value[65536]; /* Variable value... */
|
||||
int done; /* True if we're done reading a form variable */
|
||||
char *s, /* Pointer to current form string */
|
||||
ch, /* Temporary character */
|
||||
name[255], /* Name of form variable */
|
||||
value[65536]; /* Variable value... */
|
||||
|
||||
|
||||
/*
|
||||
@@ -638,6 +966,37 @@ cgi_initialize_string(const char *data) /* I - Form data string */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_passwd()' - Catch authentication requests and notify the server.
|
||||
*
|
||||
* This function sends a Status header and exits, forcing authentication
|
||||
* for this request.
|
||||
*/
|
||||
|
||||
static const char * /* O - NULL (no return) */
|
||||
cgi_passwd(const char *prompt) /* I - Prompt (not used) */
|
||||
{
|
||||
(void)prompt;
|
||||
|
||||
fprintf(stderr, "DEBUG: cgi_passwd(prompt=\"%s\") called!\n",
|
||||
prompt ? prompt : "(null)");
|
||||
|
||||
/*
|
||||
* Send a 401 (unauthorized) status to the server, so it can notify
|
||||
* the client that authentication is required.
|
||||
*/
|
||||
|
||||
puts("Status: 401\n");
|
||||
exit(0);
|
||||
|
||||
/*
|
||||
* This code is never executed, but is present to satisfy the compiler.
|
||||
*/
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_sort_variables()' - Sort all form variables for faster lookup.
|
||||
*/
|
||||
@@ -655,7 +1014,7 @@ cgi_sort_variables(void)
|
||||
if (form_count < 2)
|
||||
return;
|
||||
|
||||
qsort(form_vars, form_count, sizeof(var_t),
|
||||
qsort(form_vars, form_count, sizeof(_cgi_var_t),
|
||||
(int (*)(const void *, const void *))cgi_compare_variables);
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -667,6 +1026,35 @@ cgi_sort_variables(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'cgi_unlink_file()' - Remove the uploaded form.
|
||||
*/
|
||||
|
||||
static void
|
||||
cgi_unlink_file(void)
|
||||
{
|
||||
if (form_file)
|
||||
{
|
||||
/*
|
||||
* Remove the temporary file...
|
||||
*/
|
||||
|
||||
unlink(form_file->tempfile);
|
||||
|
||||
/*
|
||||
* Free memory used...
|
||||
*/
|
||||
|
||||
free(form_file->name);
|
||||
free(form_file->filename);
|
||||
free(form_file->mimetype);
|
||||
free(form_file);
|
||||
|
||||
form_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
cupsd.conf
|
||||
pam.conf
|
||||
+43
-23
@@ -3,23 +3,14 @@
|
||||
#
|
||||
# Configuration file makefile for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1993-2004 by Easy Software Products.
|
||||
# Copyright 2007 by Apple Inc.
|
||||
# Copyright 1993-2006 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-3142 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
include ../Makedefs
|
||||
@@ -28,7 +19,7 @@ include ../Makedefs
|
||||
# Config files...
|
||||
#
|
||||
|
||||
KEEP = classes.conf client.conf cupsd.conf printers.conf
|
||||
KEEP = cupsd.conf snmp.conf
|
||||
REPLACE = mime.convs mime.types
|
||||
|
||||
|
||||
@@ -46,28 +37,57 @@ all:
|
||||
clean:
|
||||
|
||||
|
||||
#
|
||||
# Dummy depend...
|
||||
#
|
||||
|
||||
depend:
|
||||
|
||||
|
||||
#
|
||||
# Install files...
|
||||
#
|
||||
|
||||
install:
|
||||
$(INSTALL_DIR) $(SERVERROOT)
|
||||
install: all
|
||||
for file in $(KEEP); do \
|
||||
if test -r $(SERVERROOT)/$$file ; then \
|
||||
$(INSTALL_DATA) $$file $(SERVERROOT)/$$file.N ; \
|
||||
$(INSTALL_CONFIG) $$file $(SERVERROOT)/$$file.N ; \
|
||||
chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file.N || true; \
|
||||
else \
|
||||
$(INSTALL_DATA) $$file $(SERVERROOT) ; \
|
||||
$(INSTALL_CONFIG) $$file $(SERVERROOT) ; \
|
||||
chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file || true; \
|
||||
fi ; \
|
||||
done
|
||||
$(INSTALL_CONFIG) cupsd.conf $(SERVERROOT)/cupsd.conf.default
|
||||
-chgrp $(CUPS_GROUP) $(SERVERROOT)/cupsd.conf.default
|
||||
for file in $(REPLACE); do \
|
||||
if test -r $(SERVERROOT)/$$file ; then \
|
||||
$(MV) $(SERVERROOT)/$$file $(SERVERROOT)/$$file.O ; \
|
||||
fi ; \
|
||||
$(INSTALL_DATA) $$file $(SERVERROOT) ; \
|
||||
done
|
||||
-if test x$(PAMDIR) != x$(BUILDROOT); then \
|
||||
$(INSTALL_DIR) $(PAMDIR); \
|
||||
$(INSTALL_DATA) $(PAMFILE) $(PAMDIR)/cups; \
|
||||
-if test x$(PAMDIR) != x; then \
|
||||
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(PAMDIR); \
|
||||
if test -r $(BUILDROOT)$(PAMDIR)/cups/$(PAMFILE) ; then \
|
||||
$(INSTALL_DATA) $(PAMFILE) $(BUILDROOT)$(PAMDIR)/cups.N ; \
|
||||
else \
|
||||
$(INSTALL_DATA) $(PAMFILE) $(BUILDROOT)$(PAMDIR)/cups ; \
|
||||
fi ; \
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Uninstall files...
|
||||
#
|
||||
|
||||
uninstall:
|
||||
for file in $(KEEP) $(REPLACE) cupsd.conf.default; do \
|
||||
$(RM) $(SERVERROOT)/$$file; \
|
||||
done
|
||||
-$(RMDIR) $(SERVERROOT)
|
||||
-if test x$(PAMDIR) != x; then \
|
||||
$(RM) $(BUILDROOT)$(PAMDIR)/cups; \
|
||||
$(RMDIR) $(BUILDROOT)$(PAMDIR); \
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#
|
||||
# "$Id: classes.conf 4088 2004-02-25 20:15:27Z mike $"
|
||||
#
|
||||
# Sample class configuration file for the Common UNIX Printing System
|
||||
# (CUPS) scheduler.
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# This is a sample class configuration file. This file is included #
|
||||
# from the main configuration file (cups.conf) and lists all of the #
|
||||
# printer classes known to the system. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
#
|
||||
# Each class starts with a <Class name> definition. Class names
|
||||
# can be up to 128 characters in length and are *not* case sensitive.
|
||||
#
|
||||
# One <DefaultClass name> entry can appear in this file; if you don't
|
||||
# define a default destination, the first printer or class becomes
|
||||
# the default.
|
||||
#
|
||||
|
||||
#<Class sample>
|
||||
#
|
||||
# Info: the description for the class.
|
||||
#
|
||||
|
||||
#Info Acme LaserPrint 1000 Printers
|
||||
|
||||
#
|
||||
# Location: the location of the printer.
|
||||
#
|
||||
|
||||
#Location Room 101 in the activities building
|
||||
|
||||
#
|
||||
# State: sets the initial state of the class. Can be one of the
|
||||
# following:
|
||||
#
|
||||
# Idle - Class is available to print new jobs.
|
||||
# Stopped - Class is disabled but accepting new jobs.
|
||||
#
|
||||
|
||||
#State Idle
|
||||
|
||||
#
|
||||
# StateMessage: sets the printer-state-message attribute for the class.
|
||||
#
|
||||
|
||||
#StateMessage Class is idle.
|
||||
|
||||
#
|
||||
# Accepting: is the class accepting jobs?
|
||||
#
|
||||
#Accepting Yes
|
||||
#Accepting No
|
||||
#
|
||||
|
||||
#
|
||||
# Printer: adds a printer to the class.
|
||||
#
|
||||
|
||||
#Printer sample
|
||||
#Printer sample@host2
|
||||
#</Class>
|
||||
|
||||
#
|
||||
# End of "$Id: classes.conf 4088 2004-02-25 20:15:27Z mike $".
|
||||
#
|
||||
@@ -1,67 +0,0 @@
|
||||
#
|
||||
# "$Id: client.conf 4088 2004-02-25 20:15:27Z mike $"
|
||||
#
|
||||
# Sample client configuration file for the Common UNIX Printing System
|
||||
# (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# This is the CUPS client configuration file. This file is used to #
|
||||
# define client-specific parameters, such as the default server or #
|
||||
# default encryption settings. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
#
|
||||
# ServerName: the hostname of your server. By default CUPS will use the
|
||||
# hostname of the system or the value of the CUPS_SERVER environment
|
||||
# variable. ONLY ONE SERVER NAME MAY BE SPECIFIED AT A TIME. To use
|
||||
# more than one server you must use a local scheduler with browsing
|
||||
# and possibly polling.
|
||||
#
|
||||
|
||||
#ServerName myhost.domain.com
|
||||
|
||||
#
|
||||
# Encryption: whether or not to use encryption; this depends on having
|
||||
# the OpenSSL library linked into the CUPS library.
|
||||
#
|
||||
# Possible values:
|
||||
#
|
||||
# Always - Always use encryption (SSL)
|
||||
# Never - Never use encryption
|
||||
# Required - Use TLS encryption upgrade
|
||||
# IfRequested - Use encryption if the server requests it
|
||||
#
|
||||
# The default value is "IfRequested". This parameter can also be set
|
||||
# using the CUPS_ENCRYPTION environment variable.
|
||||
#
|
||||
|
||||
#Encryption Always
|
||||
#Encryption Never
|
||||
#Encryption Required
|
||||
#Encryption IfRequested
|
||||
|
||||
|
||||
#
|
||||
# End of "$Id: client.conf 4088 2004-02-25 20:15:27Z mike $".
|
||||
#
|
||||
+61
-824
@@ -2,844 +2,81 @@
|
||||
# "$Id$"
|
||||
#
|
||||
# Sample configuration file for the Common UNIX Printing System (CUPS)
|
||||
# scheduler.
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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 USA
|
||||
#
|
||||
# Voice: (301) 373-9600
|
||||
# EMail: cups-info@cups.org
|
||||
# WWW: http://www.cups.org
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# This is the CUPS configuration file. If you are familiar with #
|
||||
# Apache or any of the other popular web servers, we've followed the #
|
||||
# same format. Any configuration variable used here has the same #
|
||||
# semantics as the corresponding variable in Apache. If we need #
|
||||
# different functionality then a different name is used to avoid #
|
||||
# confusion... #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
########
|
||||
######## Server Identity
|
||||
########
|
||||
|
||||
#
|
||||
# ServerName: the hostname of your server, as advertised to the world.
|
||||
# By default CUPS will use the hostname of the system.
|
||||
#
|
||||
# To set the default server used by clients, see the client.conf file.
|
||||
#
|
||||
|
||||
#ServerName myhost.domain.com
|
||||
|
||||
#
|
||||
# ServerAdmin: the email address to send all complaints/problems to.
|
||||
# By default CUPS will use "root@hostname".
|
||||
#
|
||||
|
||||
#ServerAdmin root@your.domain.com
|
||||
|
||||
|
||||
########
|
||||
######## Server Options
|
||||
########
|
||||
|
||||
#
|
||||
# AccessLog: the access log file; if this does not start with a leading /
|
||||
# then it is assumed to be relative to ServerRoot. By default set to
|
||||
# "@CUPS_LOGDIR@/access_log"
|
||||
#
|
||||
# You can also use the special name "syslog" to send the output to the
|
||||
# syslog file or daemon.
|
||||
#
|
||||
|
||||
#AccessLog @CUPS_LOGDIR@/access_log
|
||||
|
||||
#
|
||||
# Classification: the classification level of the server. If set, this
|
||||
# classification is displayed on all pages, and raw printing is disabled.
|
||||
# The default is the empty string.
|
||||
#
|
||||
|
||||
#Classification classified
|
||||
#Classification confidential
|
||||
#Classification secret
|
||||
#Classification topsecret
|
||||
#Classification unclassified
|
||||
|
||||
#
|
||||
# ClassifyOverride: whether to allow users to override the classification
|
||||
# on printouts. If enabled, users can limit banner pages to before or
|
||||
# after the job, and can change the classification of a job, but cannot
|
||||
# completely eliminate the classification or banners.
|
||||
#
|
||||
# The default is off.
|
||||
#
|
||||
|
||||
#ClassifyOverride off
|
||||
|
||||
#
|
||||
# DataDir: the root directory for the CUPS data files.
|
||||
# By default "@CUPS_DATADIR@".
|
||||
#
|
||||
|
||||
#DataDir @CUPS_DATADIR@
|
||||
|
||||
#
|
||||
# DefaultCharset: the default character set to use. If not specified,
|
||||
# defaults to "utf-8". Note that this can also be overridden in
|
||||
# HTML documents...
|
||||
#
|
||||
|
||||
#DefaultCharset utf-8
|
||||
|
||||
#
|
||||
# DefaultLanguage: the default language if not specified by the browser.
|
||||
# If not specified, the current locale is used.
|
||||
#
|
||||
|
||||
#DefaultLanguage en
|
||||
|
||||
#
|
||||
# DocumentRoot: the root directory for HTTP documents that are served.
|
||||
# By default "@CUPS_DOCROOT@".
|
||||
#
|
||||
|
||||
#DocumentRoot @CUPS_DOCROOT@
|
||||
|
||||
#
|
||||
# ErrorLog: the error log file; if this does not start with a leading /
|
||||
# then it is assumed to be relative to ServerRoot. By default set to
|
||||
# "@CUPS_LOGDIR@/error_log"
|
||||
#
|
||||
# You can also use the special name "syslog" to send the output to the
|
||||
# syslog file or daemon.
|
||||
#
|
||||
|
||||
#ErrorLog @CUPS_LOGDIR@/error_log
|
||||
|
||||
#
|
||||
# FileDevice: determines whether the scheduler will allow new printers
|
||||
# to be added using device URIs of the form "file:/foo/bar". The default
|
||||
# is not to allow file devices due to the potential security vulnerability
|
||||
# and due to the fact that file devices do not support raw printing.
|
||||
#
|
||||
|
||||
#FileDevice No
|
||||
|
||||
|
||||
#
|
||||
# FontPath: the path to locate all font files (currently only for pstoraster)
|
||||
# By default "@CUPS_FONTPATH@".
|
||||
#
|
||||
|
||||
#FontPath @CUPS_FONTPATH@
|
||||
|
||||
#
|
||||
# LogLevel: controls the number of messages logged to the ErrorLog
|
||||
# file and can be one of the following:
|
||||
#
|
||||
# debug2 Log everything.
|
||||
# debug Log almost everything.
|
||||
# info Log all requests and state changes.
|
||||
# warn Log errors and warnings.
|
||||
# error Log only errors.
|
||||
# none Log nothing.
|
||||
# scheduler. See "man cupsd.conf" for a complete description of this
|
||||
# file.
|
||||
#
|
||||
|
||||
# Log general information in error_log - change "info" to "debug" for
|
||||
# troubleshooting...
|
||||
LogLevel info
|
||||
|
||||
#
|
||||
# MaxLogSize: controls the maximum size of each log file before they are
|
||||
# rotated. Defaults to 1048576 (1MB). Set to 0 to disable log rotating.
|
||||
#
|
||||
# Administrator user group...
|
||||
SystemGroup @CUPS_SYSTEM_GROUPS@
|
||||
@CUPS_SYSTEM_AUTHKEY@
|
||||
|
||||
#MaxLogSize 0
|
||||
# Only listen for connections from the local machine.
|
||||
Listen localhost:@DEFAULT_IPP_PORT@
|
||||
@CUPS_LISTEN_DOMAINSOCKET@
|
||||
|
||||
#
|
||||
# PageLog: the page log file; if this does not start with a leading /
|
||||
# then it is assumed to be relative to ServerRoot. By default set to
|
||||
# "@CUPS_LOGDIR@/page_log"
|
||||
#
|
||||
# You can also use the special name "syslog" to send the output to the
|
||||
# syslog file or daemon.
|
||||
#
|
||||
# Show shared printers on the local network.
|
||||
Browsing On
|
||||
BrowseOrder allow,deny
|
||||
BrowseAllow all
|
||||
|
||||
#PageLog @CUPS_LOGDIR@/page_log
|
||||
|
||||
#
|
||||
# PreserveJobHistory: whether or not to preserve the job history after a
|
||||
# job is completed, cancelled, or stopped. Default is Yes.
|
||||
#
|
||||
|
||||
#PreserveJobHistory Yes
|
||||
|
||||
#
|
||||
# PreserveJobFiles: whether or not to preserve the job files after a
|
||||
# job is completed, cancelled, or stopped. Default is No.
|
||||
#
|
||||
|
||||
#PreserveJobFiles No
|
||||
|
||||
#
|
||||
# AutoPurgeJobs: automatically purge jobs when not needed for quotas.
|
||||
# Default is No.
|
||||
#
|
||||
|
||||
#AutoPurgeJobs No
|
||||
|
||||
#
|
||||
# MaxCopies: maximum number of copies that a user can request. Default is
|
||||
# 100.
|
||||
#
|
||||
|
||||
#MaxCopies 100
|
||||
|
||||
#
|
||||
# MaxJobs: maximum number of jobs to keep in memory (active and completed.)
|
||||
# Default is 500; the value 0 is used for no limit.
|
||||
#
|
||||
|
||||
#MaxJobs 500
|
||||
|
||||
#
|
||||
# MaxJobsPerPrinter: maximum number of active jobs per printer. The default
|
||||
# is 0 for no limit.
|
||||
#
|
||||
|
||||
#MaxJobsPerPrinter 0
|
||||
|
||||
#
|
||||
# MaxJobsPerUser: maximum number of active jobs per user. The default
|
||||
# is 0 for no limit.
|
||||
#
|
||||
|
||||
#MaxJobsPerUser 0
|
||||
|
||||
#
|
||||
# MaxPrinterHistory: controls the maximum number of history collections
|
||||
# in the printer-state-history attribute. Set to 0 to disable history
|
||||
# data.
|
||||
#
|
||||
|
||||
#MaxPrinterHistory 10
|
||||
|
||||
#
|
||||
# Printcap: the name of the printcap file. Default is /etc/printcap.
|
||||
# Leave blank to disable printcap file generation.
|
||||
#
|
||||
|
||||
#Printcap /etc/printcap
|
||||
|
||||
#
|
||||
# PrintcapFormat: the format of the printcap file, currently either
|
||||
# BSD or Solaris. The default is "BSD".
|
||||
#
|
||||
|
||||
#PrintcapFormat BSD
|
||||
#PrintcapFormat Solaris
|
||||
|
||||
#
|
||||
# PrintcapGUI: the name of the GUI options panel program to associate
|
||||
# with print queues under IRIX. The default is "/usr/bin/glpoptions"
|
||||
# from ESP Print Pro.
|
||||
#
|
||||
# This option is only used under IRIX; the options panel program
|
||||
# must accept the "-d printer" and "-o options" options and write
|
||||
# the selected printer options back to stdout on completion.
|
||||
#
|
||||
|
||||
#PrintcapGUI /usr/bin/glpoptions
|
||||
|
||||
#
|
||||
# RequestRoot: the directory where request files are stored.
|
||||
# By default "@CUPS_REQUESTS@".
|
||||
#
|
||||
|
||||
#RequestRoot @CUPS_REQUESTS@
|
||||
|
||||
#
|
||||
# RemoteRoot: the name of the user assigned to unauthenticated accesses
|
||||
# from remote systems. By default "remroot".
|
||||
#
|
||||
|
||||
#RemoteRoot remroot
|
||||
|
||||
#
|
||||
# ServerBin: the root directory for the scheduler executables.
|
||||
# By default "@CUPS_SERVERBIN@".
|
||||
#
|
||||
|
||||
#ServerBin @CUPS_SERVERBIN@
|
||||
|
||||
#
|
||||
# ServerRoot: the root directory for the scheduler.
|
||||
# By default "@CUPS_SERVERROOT@".
|
||||
#
|
||||
|
||||
#ServerRoot @CUPS_SERVERROOT@
|
||||
|
||||
|
||||
#
|
||||
# ServerTokens: specifies what information in provided in the Server
|
||||
# header of HTTP responses. The default is Minor.
|
||||
#
|
||||
# ServerTokens None
|
||||
# ServerTokens ProductOnly CUPS
|
||||
# ServerTokens Major CUPS/1
|
||||
# ServerTokens Minor CUPS/1.1
|
||||
# ServerTokens Minimal CUPS/@CUPS_VERSION@
|
||||
# ServerTokens OS CUPS/@CUPS_VERSION@ (uname)
|
||||
# ServerTokens Full CUPS/@CUPS_VERSION@ (uname) IPP/1.1
|
||||
#
|
||||
|
||||
#ServerTokens Minor
|
||||
|
||||
|
||||
########
|
||||
######## Fax Support
|
||||
########
|
||||
|
||||
#
|
||||
# FaxRetryLimit: the number of times a fax job is retried.
|
||||
# The default is 5 times.
|
||||
#
|
||||
|
||||
#FaxRetryLimit 5
|
||||
|
||||
#
|
||||
# FaxRetryInterval: the number of seconds between fax job retries.
|
||||
# The default is 300 seconds/5 minutes.
|
||||
#
|
||||
|
||||
#FaxRetryInterval 300
|
||||
|
||||
|
||||
########
|
||||
######## Encryption Support
|
||||
########
|
||||
|
||||
#
|
||||
# ServerCertificate: the file to read containing the server's certificate.
|
||||
# Defaults to "@CUPS_SERVERROOT@/ssl/server.crt".
|
||||
#
|
||||
|
||||
#ServerCertificate @CUPS_SERVERROOT@/ssl/server.crt
|
||||
|
||||
#
|
||||
# ServerKey: the file to read containing the server's key.
|
||||
# Defaults to "@CUPS_SERVERROOT@/ssl/server.key".
|
||||
#
|
||||
|
||||
#ServerKey @CUPS_SERVERROOT@/ssl/server.key
|
||||
|
||||
|
||||
########
|
||||
######## Filter Options
|
||||
########
|
||||
|
||||
#
|
||||
# User/Group: the user and group the server runs under. Normally this
|
||||
# must be @CUPS_USER@ and @CUPS_GROUP@, however you can configure things for another
|
||||
# user or group as needed.
|
||||
#
|
||||
# Note: the server must be run initially as root to support the
|
||||
# default IPP port of 631. It changes users whenever an external
|
||||
# program is run, or if the RunAsUser directive is specified...
|
||||
#
|
||||
|
||||
#User @CUPS_USER@
|
||||
#Group @CUPS_GROUP@
|
||||
|
||||
#
|
||||
# RIPCache: the amount of memory that each RIP should use to cache
|
||||
# bitmaps. The value can be any real number followed by "k" for
|
||||
# kilobytes, "m" for megabytes, "g" for gigabytes, or "t" for tiles
|
||||
# (1 tile = 256x256 pixels.) Defaults to "8m" (8 megabytes).
|
||||
#
|
||||
|
||||
#RIPCache 8m
|
||||
|
||||
#
|
||||
# TempDir: the directory to put temporary files in. This directory must be
|
||||
# writable by the user defined above! Defaults to "@CUPS_REQUESTS@/tmp" or
|
||||
# the value of the TMPDIR environment variable.
|
||||
#
|
||||
|
||||
#TempDir @CUPS_REQUESTS@/tmp
|
||||
|
||||
#
|
||||
# FilterLimit: sets the maximum cost of all job filters that can be run
|
||||
# at the same time. A limit of 0 means no limit. A typical job may need
|
||||
# a filter limit of at least 200; limits less than the minimum required
|
||||
# by a job force a single job to be printed at any time.
|
||||
#
|
||||
# The default limit is 0 (unlimited).
|
||||
#
|
||||
|
||||
#FilterLimit 0
|
||||
|
||||
########
|
||||
######## Network Options
|
||||
########
|
||||
|
||||
#
|
||||
# Ports/addresses that we listen to. The default port 631 is reserved
|
||||
# for the Internet Printing Protocol (IPP) and is what we use here.
|
||||
#
|
||||
# You can have multiple Port/Listen lines to listen to more than one
|
||||
# port or address, or to restrict access:
|
||||
#
|
||||
# Port 80
|
||||
# Port 631
|
||||
# Listen hostname
|
||||
# Listen hostname:80
|
||||
# Listen hostname:631
|
||||
# Listen 1.2.3.4
|
||||
# Listen 1.2.3.4:631
|
||||
#
|
||||
# NOTE: Unfortunately, most web browsers don't support TLS or HTTP Upgrades
|
||||
# for encryption. If you want to support web-based encryption you'll
|
||||
# probably need to listen on port 443 (the "https" port...)
|
||||
#
|
||||
# NOTE 2: In order for the command-line and web interfaces to work, you
|
||||
# must have at least one Port or Listen line that allows access from the
|
||||
# local loopback address (localhost).
|
||||
#
|
||||
|
||||
#Port 80
|
||||
#Port 443
|
||||
Port 631
|
||||
|
||||
#
|
||||
# HostNameLookups: whether or not to do lookups on IP addresses to get a
|
||||
# fully-qualified hostname. This defaults to Off for performance reasons...
|
||||
#
|
||||
|
||||
#HostNameLookups On
|
||||
|
||||
#
|
||||
# KeepAlive: whether or not to support the Keep-Alive connection
|
||||
# option. Default is on.
|
||||
#
|
||||
|
||||
#KeepAlive On
|
||||
|
||||
#
|
||||
# KeepAliveTimeout: the timeout before Keep-Alive connections are
|
||||
# automatically closed. Default is 60 seconds.
|
||||
#
|
||||
|
||||
#KeepAliveTimeout 60
|
||||
|
||||
#
|
||||
# MaxClients: controls the maximum number of simultaneous clients that
|
||||
# will be handled. Defaults to 100.
|
||||
#
|
||||
|
||||
#MaxClients 100
|
||||
|
||||
#
|
||||
# MaxClientsPerHost: controls the maximum number of simultaneous clients that
|
||||
# will be handled from a specific host. Defaults to 10 or 1/10th of the
|
||||
# MaxClients setting, whichever is larger. A value of 0 specifies the
|
||||
# automatic (10 or 1/10th) setting.
|
||||
#
|
||||
|
||||
#MaxClientsPerHost 0
|
||||
|
||||
#
|
||||
# MaxRequestSize: controls the maximum size of HTTP requests and print files.
|
||||
# Set to 0 to disable this feature (defaults to 0.)
|
||||
#
|
||||
|
||||
#MaxRequestSize 0
|
||||
|
||||
#
|
||||
# Timeout: the timeout before requests time out. Default is 300 seconds.
|
||||
#
|
||||
|
||||
#Timeout 300
|
||||
|
||||
|
||||
########
|
||||
######## Browsing Options
|
||||
########
|
||||
|
||||
#
|
||||
# Browsing: whether or not to broadcast and/or listen for CUPS printer
|
||||
# information on the network. Enabled by default.
|
||||
#
|
||||
|
||||
#Browsing On
|
||||
|
||||
#
|
||||
# BrowseProtocols: which protocols to use for browsing. Can be
|
||||
# any of the following separated by whitespace and/or commas:
|
||||
#
|
||||
# all - Use all supported protocols.
|
||||
# cups - Use the CUPS browse protocol.
|
||||
# slp - Use the SLPv2 protocol.
|
||||
#
|
||||
# The default is "cups".
|
||||
#
|
||||
# NOTE: If you choose to use SLPv2, it is *strongly* recommended that
|
||||
# you have at least one SLP Directory Agent (DA) on your
|
||||
# network. Otherwise, browse updates can take several seconds,
|
||||
# during which the scheduler will not respond to client
|
||||
# requests.
|
||||
#
|
||||
|
||||
#BrowseProtocols cups
|
||||
|
||||
#
|
||||
# BrowseAddress: specifies a broadcast address to be used. By
|
||||
# default browsing information is not sent!
|
||||
#
|
||||
# Note: HP-UX does not properly handle broadcast unless you have a
|
||||
# Class A, B, C, or D netmask (i.e. no CIDR support).
|
||||
#
|
||||
# Note: Using the "global" broadcast address (255.255.255.255) will
|
||||
# activate a Linux demand-dial link with the default configuration.
|
||||
# If you have a LAN as well as the dial-up link, use the LAN's
|
||||
# broadcast address.
|
||||
#
|
||||
# The @LOCAL address broadcasts to all non point-to-point interfaces.
|
||||
# For example, if you have a LAN and a dial-up link, @LOCAL would
|
||||
# send printer updates to the LAN but not to the dial-up link.
|
||||
# Similarly, the @IF(name) address sends to the named network
|
||||
# interface, e.g. @IF(eth0) under Linux. Interfaces are refreshed
|
||||
# automatically (no more than once every 60 seconds), so they can
|
||||
# be used on dynamically-configured interfaces, e.g. PPP, 802.11, etc.
|
||||
#
|
||||
|
||||
#BrowseAddress x.y.z.255
|
||||
#BrowseAddress x.y.255.255
|
||||
#BrowseAddress x.255.255.255
|
||||
#BrowseAddress 255.255.255.255
|
||||
#BrowseAddress @LOCAL
|
||||
#BrowseAddress @IF(name)
|
||||
|
||||
#
|
||||
# BrowseShortNames: whether or not to use "short" names for remote printers
|
||||
# when possible (e.g. "printer" instead of "printer@host".) Enabled by
|
||||
# default.
|
||||
#
|
||||
|
||||
#BrowseShortNames Yes
|
||||
|
||||
#
|
||||
# BrowseAllow: specifies an address mask to allow for incoming browser
|
||||
# packets. The default is to allow packets from all addresses.
|
||||
#
|
||||
# BrowseDeny: specifies an address mask to deny for incoming browser
|
||||
# packets. The default is to deny packets from no addresses.
|
||||
#
|
||||
# Both "BrowseAllow" and "BrowseDeny" accept the following notations for
|
||||
# addresses:
|
||||
#
|
||||
# All
|
||||
# None
|
||||
# *.domain.com
|
||||
# .domain.com
|
||||
# host.domain.com
|
||||
# nnn.*
|
||||
# nnn.nnn.*
|
||||
# nnn.nnn.nnn.*
|
||||
# nnn.nnn.nnn.nnn
|
||||
# nnn.nnn.nnn.nnn/mm
|
||||
# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
|
||||
# @LOCAL
|
||||
# @IF(name)
|
||||
#
|
||||
# The hostname/domainname restrictions only work if you have turned hostname
|
||||
# lookups on!
|
||||
#
|
||||
|
||||
#BrowseAllow address
|
||||
#BrowseDeny address
|
||||
|
||||
#
|
||||
# BrowseInterval: the time between browsing updates in seconds. Default
|
||||
# is 30 seconds.
|
||||
#
|
||||
# Note that browsing information is sent whenever a printer's state changes
|
||||
# as well, so this represents the maximum time between updates.
|
||||
#
|
||||
# Set this to 0 to disable outgoing broadcasts so your local printers are
|
||||
# not advertised but you can still see printers on other hosts.
|
||||
#
|
||||
|
||||
#BrowseInterval 30
|
||||
|
||||
#
|
||||
# BrowseOrder: specifies the order of BrowseAllow/BrowseDeny comparisons.
|
||||
#
|
||||
|
||||
#BrowseOrder allow,deny
|
||||
#BrowseOrder deny,allow
|
||||
|
||||
#
|
||||
# BrowsePoll: poll the named server(s) for printers
|
||||
#
|
||||
|
||||
#BrowsePoll address:port
|
||||
|
||||
#
|
||||
# BrowsePort: the port used for UDP broadcasts. By default this is
|
||||
# the IPP port; if you change this you need to do it on all servers.
|
||||
# Only one BrowsePort is recognized.
|
||||
#
|
||||
|
||||
#BrowsePort 631
|
||||
|
||||
#
|
||||
# BrowseRelay: relay browser packets from one address/network to another.
|
||||
#
|
||||
|
||||
#BrowseRelay source-address destination-address
|
||||
#BrowseRelay @IF(src) @IF(dst)
|
||||
|
||||
#
|
||||
# BrowseTimeout: the timeout for network printers - if we don't
|
||||
# get an update within this time the printer will be removed
|
||||
# from the printer list. This number definitely should not be
|
||||
# less the BrowseInterval value for obvious reasons. Defaults
|
||||
# to 300 seconds.
|
||||
#
|
||||
|
||||
#BrowseTimeout 300
|
||||
|
||||
#
|
||||
# ImplicitClasses: whether or not to use implicit classes.
|
||||
#
|
||||
# Printer classes can be specified explicitly in the classes.conf
|
||||
# file, implicitly based upon the printers available on the LAN, or
|
||||
# both.
|
||||
#
|
||||
# When ImplicitClasses is On, printers on the LAN with the same name
|
||||
# (e.g. Acme-LaserPrint-1000) will be put into a class with the same
|
||||
# name. This allows you to setup multiple redundant queues on a LAN
|
||||
# without a lot of administrative difficulties. If a user sends a
|
||||
# job to Acme-LaserPrint-1000, the job will go to the first available
|
||||
# queue.
|
||||
#
|
||||
# Enabled by default.
|
||||
#
|
||||
|
||||
#ImplicitClasses On
|
||||
|
||||
#
|
||||
# ImplicitAnyClasses: whether or not to create "AnyPrinter" implicit
|
||||
# classes.
|
||||
#
|
||||
# When ImplicitAnyClasses is On and a local queue of the same name
|
||||
# exists, e.g. "printer", "printer@server1", "printer@server1", then
|
||||
# an implicit class called "Anyprinter" is created instead.
|
||||
#
|
||||
# When ImplicitAnyClasses is Off, implicit classes are not created
|
||||
# when there is a local queue of the same name.
|
||||
#
|
||||
# Disabled by default.
|
||||
#
|
||||
|
||||
#ImplicitAnyCLasses Off
|
||||
|
||||
#
|
||||
# HideImplicitMembers: whether or not to show the members of an
|
||||
# implicit class.
|
||||
#
|
||||
# When HideImplicitMembers is On, any remote printers that are
|
||||
# part of an implicit class are hidden from the user, who will
|
||||
# then only see a single queue even though many queues will be
|
||||
# supporting the implicit class.
|
||||
#
|
||||
# Enabled by default.
|
||||
#
|
||||
|
||||
#HideImplicitMembers On
|
||||
|
||||
|
||||
########
|
||||
######## Security Options
|
||||
########
|
||||
|
||||
#
|
||||
# SystemGroup: the group name for "System" (printer administration)
|
||||
# access. The default varies depending on the operating system, but
|
||||
# will be "sys", "system", or "root" (checked for in that order.)
|
||||
#
|
||||
|
||||
#SystemGroup @CUPS_GROUP@
|
||||
|
||||
#
|
||||
# RootCertDuration: How frequently the root certificate is regenerated.
|
||||
# Defaults to 300 seconds.
|
||||
#
|
||||
|
||||
#RootCertDuration 300
|
||||
|
||||
#
|
||||
# Access permissions for each directory served by the scheduler.
|
||||
# Locations are relative to DocumentRoot...
|
||||
#
|
||||
# AuthType: the authorization to use:
|
||||
#
|
||||
# None - Perform no authentication
|
||||
# Basic - Perform authentication using the HTTP Basic method.
|
||||
# Digest - Perform authentication using the HTTP Digest method.
|
||||
#
|
||||
# (Note: local certificate authentication can be substituted by
|
||||
# the client for Basic or Digest when connecting to the
|
||||
# localhost interface)
|
||||
#
|
||||
# AuthClass: the authorization class; currently only "Anonymous", "User",
|
||||
# "System" (valid user belonging to group SystemGroup), and "Group"
|
||||
# (valid user belonging to the specified group) are supported.
|
||||
#
|
||||
# AuthGroupName: the group name for "Group" authorization.
|
||||
#
|
||||
# Order: the order of Allow/Deny processing.
|
||||
#
|
||||
# Allow: allows access from the specified hostname, domain, IP address,
|
||||
# network, or interface.
|
||||
#
|
||||
# Deny: denies access from the specified hostname, domain, IP address,
|
||||
# network, or interface.
|
||||
#
|
||||
# Both "Allow" and "Deny" accept the following notations for addresses:
|
||||
#
|
||||
# All
|
||||
# None
|
||||
# *.domain.com
|
||||
# .domain.com
|
||||
# host.domain.com
|
||||
# nnn.*
|
||||
# nnn.nnn.*
|
||||
# nnn.nnn.nnn.*
|
||||
# nnn.nnn.nnn.nnn
|
||||
# nnn.nnn.nnn.nnn/mm
|
||||
# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
|
||||
# @LOCAL
|
||||
# @IF(name)
|
||||
#
|
||||
# The host and domain address require that you enable hostname lookups
|
||||
# with "HostNameLookups On" above.
|
||||
#
|
||||
# The @LOCAL address allows or denies from all non point-to-point
|
||||
# interfaces. For example, if you have a LAN and a dial-up link,
|
||||
# @LOCAL could allow connections from the LAN but not from the dial-up
|
||||
# link. Similarly, the @IF(name) address allows or denies from the
|
||||
# named network interface, e.g. @IF(eth0) under Linux. Interfaces are
|
||||
# refreshed automatically (no more than once every 60 seconds), so
|
||||
# they can be used on dynamically-configured interfaces, e.g. PPP,
|
||||
# 802.11, etc.
|
||||
#
|
||||
# Encryption: whether or not to use encryption; this depends on having
|
||||
# the OpenSSL library linked into the CUPS library and scheduler.
|
||||
#
|
||||
# Possible values:
|
||||
#
|
||||
# Always - Always use encryption (SSL)
|
||||
# Never - Never use encryption
|
||||
# Required - Use TLS encryption upgrade
|
||||
# IfRequested - Use encryption if the server requests it
|
||||
#
|
||||
# The default value is "IfRequested".
|
||||
#
|
||||
# Default authentication type, when authentication is required...
|
||||
DefaultAuthType Basic
|
||||
|
||||
# Restrict access to the server...
|
||||
<Location />
|
||||
Order Deny,Allow
|
||||
Deny From All
|
||||
Allow From 127.0.0.1
|
||||
Order allow,deny
|
||||
</Location>
|
||||
|
||||
#<Location /classes>
|
||||
#
|
||||
# You may wish to limit access to printers and classes, either with Allow
|
||||
# and Deny lines, or by requiring a username and password.
|
||||
#
|
||||
#</Location>
|
||||
|
||||
#<Location /classes/name>
|
||||
#
|
||||
# You may wish to limit access to printers and classes, either with Allow
|
||||
# and Deny lines, or by requiring a username and password.
|
||||
#
|
||||
#</Location>
|
||||
|
||||
#<Location /jobs>
|
||||
#
|
||||
# You may wish to limit access to job operations, either with Allow
|
||||
# and Deny lines, or by requiring a username and password.
|
||||
#
|
||||
#</Location>
|
||||
|
||||
#<Location /printers>
|
||||
#
|
||||
# You may wish to limit access to printers and classes, either with Allow
|
||||
# and Deny lines, or by requiring a username and password.
|
||||
#
|
||||
#</Location>
|
||||
|
||||
#<Location /printers/name>
|
||||
#
|
||||
# You may wish to limit access to printers and classes, either with Allow
|
||||
# and Deny lines, or by requiring a username and password.
|
||||
#
|
||||
|
||||
## Anonymous access (default)
|
||||
#AuthType None
|
||||
|
||||
## Require a username and password (Basic authentication)
|
||||
#AuthType Basic
|
||||
#AuthClass User
|
||||
|
||||
## Require a username and password (Digest/MD5 authentication)
|
||||
#AuthType Digest
|
||||
#AuthClass User
|
||||
|
||||
## Restrict access to local domain
|
||||
#Order Deny,Allow
|
||||
#Deny From All
|
||||
#Allow From .mydomain.com
|
||||
#</Location>
|
||||
|
||||
# Restrict access to the admin pages...
|
||||
<Location /admin>
|
||||
#
|
||||
# You definitely will want to limit access to the administration functions.
|
||||
# The default configuration requires a local connection from a user who
|
||||
# is a member of the system group to do any admin tasks. You can change
|
||||
# the group name using the SystemGroup directive.
|
||||
#
|
||||
|
||||
AuthType Basic
|
||||
AuthClass System
|
||||
|
||||
## Restrict access to local domain
|
||||
Order Deny,Allow
|
||||
Deny From All
|
||||
Allow From 127.0.0.1
|
||||
|
||||
#Encryption Required
|
||||
@ENCRYPTION_REQUIRED@
|
||||
Order allow,deny
|
||||
</Location>
|
||||
|
||||
# Restrict access to configuration files...
|
||||
<Location /admin/conf>
|
||||
AuthType Default
|
||||
Require user @SYSTEM
|
||||
Order allow,deny
|
||||
</Location>
|
||||
|
||||
# Set the default printer/job policies...
|
||||
<Policy default>
|
||||
# Job-related operations must be done by the owner or an administrator...
|
||||
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
|
||||
Require user @OWNER @SYSTEM
|
||||
Order deny,allow
|
||||
</Limit>
|
||||
|
||||
# All administration operations require an administrator to authenticate...
|
||||
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
|
||||
AuthType Default
|
||||
Require user @SYSTEM
|
||||
Order deny,allow
|
||||
</Limit>
|
||||
|
||||
# All printer operations require a printer operator to authenticate...
|
||||
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
|
||||
AuthType Default
|
||||
Require user @CUPS_DEFAULT_PRINTADMIN_AUTH@
|
||||
Order deny,allow
|
||||
</Limit>
|
||||
|
||||
# Only the owner or an administrator can cancel or authenticate a job...
|
||||
<Limit Cancel-Job CUPS-Authenticate-Job>
|
||||
Require user @OWNER @CUPS_DEFAULT_PRINTADMIN_AUTH@
|
||||
Order deny,allow
|
||||
</Limit>
|
||||
|
||||
<Limit All>
|
||||
Order deny,allow
|
||||
</Limit>
|
||||
</Policy>
|
||||
|
||||
#
|
||||
# End of "$Id$".
|
||||
#
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
#
|
||||
# "$Id: mime.convs 4087 2004-02-25 20:14:54Z mike $"
|
||||
# "$Id$"
|
||||
#
|
||||
# DO NOT EDIT THIS FILE, AS IT IS OVERWRITTEN WHEN YOU INSTALL NEW
|
||||
# VERSIONS OF CUPS. Instead, create a "local.convs" file that
|
||||
# reflects your local configuration changes.
|
||||
#
|
||||
# MIME converts file for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products.
|
||||
# Copyright 2007-2009 by Apple Inc.
|
||||
# Copyright 1997-2007 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
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
########################################################################
|
||||
@@ -43,10 +38,11 @@
|
||||
# PostScript filters
|
||||
#
|
||||
|
||||
application/pdf application/postscript 33 pdftops
|
||||
application/pdf application/vnd.cups-postscript 66 pdftops
|
||||
application/postscript application/vnd.cups-postscript 66 pstops
|
||||
application/vnd.hp-HPGL application/postscript 66 hpgltops
|
||||
application/x-cshell application/postscript 33 texttops
|
||||
application/x-csource application/postscript 33 texttops
|
||||
application/x-perl application/postscript 33 texttops
|
||||
application/x-shell application/postscript 33 texttops
|
||||
text/plain application/postscript 33 texttops
|
||||
@@ -99,20 +95,19 @@ image/x-xpixmap application/vnd.cups-raster 100 imagetoraster
|
||||
#image/x-xwindowdump application/vnd.cups-raster 100 imagetoraster
|
||||
image/x-sun-raster application/vnd.cups-raster 100 imagetoraster
|
||||
|
||||
# pstoraster is now part of ESP Ghostscript...
|
||||
#application/vnd.cups-postscript application/vnd.cups-raster 100 pstoraster
|
||||
# pstoraster is part of GPL Ghostscript...
|
||||
application/vnd.cups-postscript application/vnd.cups-raster 100 pstoraster
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Raw filter...
|
||||
#
|
||||
# Uncomment the following filter and the application/octet-stream type
|
||||
# in mime.types to allow printing of arbitrary files without the -oraw
|
||||
# option.
|
||||
# Uncomment the following filter to allow printing of arbitrary files
|
||||
# without the -oraw option.
|
||||
#
|
||||
|
||||
#application/octet-stream application/vnd.cups-raw 0 -
|
||||
@DEFAULT_RAW_PRINTING@application/octet-stream application/vnd.cups-raw 0 -
|
||||
|
||||
#
|
||||
# End of "$Id: mime.convs 4087 2004-02-25 20:14:54Z mike $".
|
||||
# End of "$Id$".
|
||||
#
|
||||
+46
-33
@@ -1,25 +1,20 @@
|
||||
#
|
||||
# "$Id: mime.types 4413 2004-09-23 14:30:19Z mike $"
|
||||
# "$Id: mime.types 6649 2007-07-11 21:46:42Z mike $"
|
||||
#
|
||||
# MIME types file for the Common UNIX Printing System (CUPS).
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products.
|
||||
# DO NOT EDIT THIS FILE, AS IT IS OVERWRITTEN WHEN YOU INSTALL NEW
|
||||
# VERSIONS OF CUPS. Instead, create a "local.types" file that
|
||||
# reflects your local configuration changes.
|
||||
#
|
||||
# Copyright 2007 by Apple Inc.
|
||||
# Copyright 1997-2007 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
|
||||
# property of Apple Inc. 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
|
||||
# file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
#
|
||||
|
||||
########################################################################
|
||||
@@ -74,18 +69,20 @@
|
||||
application/pdf pdf string(0,%PDF)
|
||||
application/postscript ai eps ps string(0,%!) string(0,<04>%!) \
|
||||
contains(0,128,<1B>%-12345X) + \
|
||||
(contains(0,1024,"LANGUAGE=POSTSCRIPT") \
|
||||
contains(0,1024,"LANGUAGE = Postscript") \
|
||||
contains(0,1024,"LANGUAGE = PostScript") \
|
||||
contains(0,1024,"LANGUAGE = POSTSCRIPT"))
|
||||
application/vnd.hp-HPGL hpgl string(0,<1B>&)\
|
||||
(contains(0,4096,"LANGUAGE=POSTSCRIPT") \
|
||||
contains(0,4096,"LANGUAGE = Postscript") \
|
||||
contains(0,4096,"LANGUAGE = PostScript") \
|
||||
contains(0,4096,"LANGUAGE = POSTSCRIPT") \
|
||||
(contains(0,4096,<0a>%!) + \
|
||||
!contains(0,4096,"ENTER LANGUAGE")))
|
||||
application/vnd.hp-HPGL hpgl \
|
||||
string(0,<1B>E<1B>%0B) \
|
||||
string(0,<1B>%-1B) string(0,<201B>)\
|
||||
string(0,BP;) string(0,IN;) string(0,DF;) \
|
||||
string(0,BPINPS;) \
|
||||
(contains(0,128,<1B>%-12345X) + \
|
||||
(contains(0,1024,"LANGUAGE=HPGL") \
|
||||
contains(0,1024,"LANGUAGE = HPGL")))
|
||||
(contains(0,4096,"LANGUAGE=HPGL") \
|
||||
contains(0,4096,"LANGUAGE = HPGL")))
|
||||
|
||||
########################################################################
|
||||
#
|
||||
@@ -99,7 +96,7 @@ image/jpeg jpeg jpg jpe string(0,<FFD8FF>) &&\
|
||||
char(3,0xe4) char(3,0xe5) char(3,0xe6) char(3,0xe7)\
|
||||
char(3,0xe8) char(3,0xe9) char(3,0xea) char(3,0xeb)\
|
||||
char(3,0xec) char(3,0xed) char(3,0xee) char(3,0xef))
|
||||
image/tiff tiff tif string(0,MM) string(0,II)
|
||||
image/tiff tiff tif string(0,MM<002A>) string(0,II<2A00>)
|
||||
image/x-photocd pcd string(2048,PCD_IPI)
|
||||
image/x-portable-anymap pnm
|
||||
image/x-portable-bitmap pbm string(0,P1) string(0,P4)
|
||||
@@ -114,14 +111,13 @@ image/x-sun-raster ras string(0,<59a66a95>)
|
||||
#image/fpx fpx
|
||||
image/x-alias pix short(8,8) short(8,24)
|
||||
image/x-bitmap bmp string(0,BM) && !printable(2,14)
|
||||
image/x-icon ico
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Text files...
|
||||
#
|
||||
|
||||
text/html html htm printable(0,1024) +\
|
||||
(istring(0,"<HTML>") istring(0,"<!DOCTYPE"))
|
||||
application/x-cshell csh printable(0,1024) + string(0,#!) +\
|
||||
(contains(2,80,/csh) contains(2,80,/tcsh))
|
||||
application/x-perl pl printable(0,1024) + string(0,#!) +\
|
||||
@@ -129,7 +125,24 @@ application/x-perl pl printable(0,1024) + string(0,#!) +\
|
||||
application/x-shell sh printable(0,1024) + string(0,#!) +\
|
||||
(contains(2,80,/bash) contains(2,80,/ksh)\
|
||||
contains(2,80,/sh) contains(2,80,/zsh))
|
||||
application/x-csource c cxx cpp cc C h hpp \
|
||||
printable(0,1024) + \
|
||||
(string(0,/*) string(0,//)
|
||||
string(0,#include) contains(0,1024,<0a>#include) \
|
||||
string(0,#define) contains(0,1024,<0a>#define))
|
||||
text/html html htm printable(0,1024) +\
|
||||
(istring(0,"<HTML>") istring(0,"<!DOCTYPE"))
|
||||
text/plain txt printable(0,1024)
|
||||
text/css css
|
||||
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# RSS feed type...
|
||||
#
|
||||
|
||||
application/rss+xml rss
|
||||
|
||||
|
||||
########################################################################
|
||||
#
|
||||
@@ -138,25 +151,25 @@ text/plain txt printable(0,1024)
|
||||
|
||||
application/vnd.cups-command string(0,'#CUPS-COMMAND')
|
||||
application/vnd.cups-form string(0,"<CUPSFORM>")
|
||||
application/vnd.cups-pdf
|
||||
application/vnd.cups-postscript
|
||||
application/vnd.cups-ppd ppd string(0,"*PPD-Adobe:")
|
||||
application/vnd.cups-raster string(0,"RaSt") string(0,"tSaR")
|
||||
application/vnd.cups-raw (string(0,<1B>E) + !string(2,<1B>%0B)) \
|
||||
string(0,<1B>@) \
|
||||
(contains(0,128,<1B>%-12345X) + \
|
||||
(contains(0,1024,"LANGUAGE=PCL") \
|
||||
contains(0,1024,"LANGUAGE = PCL")))
|
||||
(contains(0,4096,"LANGUAGE=PCL") \
|
||||
contains(0,4096,"LANGUAGE = PCL")))
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Raw print file support...
|
||||
#
|
||||
# Uncomment the following type and the application/octet-stream
|
||||
# filter line in mime.convs to allow raw file printing without the
|
||||
# -oraw option.
|
||||
# Comment the following type to prevent raw file printing.
|
||||
#
|
||||
|
||||
#application/octet-stream
|
||||
application/octet-stream
|
||||
|
||||
#
|
||||
# End of "$Id: mime.types 4413 2004-09-23 14:30:19Z mike $".
|
||||
# End of "$Id: mime.types 6649 2007-07-11 21:46:42Z mike $".
|
||||
#
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# This is a dummy printcap file that is automatically generated by the
|
||||
# CUPS software for old applications that rely on it.
|
||||
@@ -1,96 +0,0 @@
|
||||
#
|
||||
# "$Id: printers.conf 4088 2004-02-25 20:15:27Z mike $"
|
||||
#
|
||||
# Sample printer configuration file for the Common UNIX Printing System
|
||||
# (CUPS) scheduler.
|
||||
#
|
||||
# Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# This is a sample printer configuration file. This file is included #
|
||||
# from the main configuration file (cups.conf) and lists all of the #
|
||||
# printers known to the system. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
#
|
||||
# Each printer starts with a <Printer name> definition. Printer names
|
||||
# can be up to 128 characters in length and are *not* case sensitive.
|
||||
#
|
||||
# One <DefaultPrinter name> entry can appear in this file; if you don't
|
||||
# define a default destination, the first printer or class becomes the
|
||||
# default.
|
||||
#
|
||||
|
||||
#<Printer sample>
|
||||
#
|
||||
# Info: the description for the printer.
|
||||
#
|
||||
|
||||
#Info Acme LaserPrint 1000
|
||||
|
||||
#
|
||||
# Location: the location of the printer.
|
||||
#
|
||||
|
||||
#Location Room 101 in the activities building
|
||||
|
||||
#
|
||||
# DeviceURI: the device URI for this printer.
|
||||
#
|
||||
|
||||
#DeviceURI parallel:/dev/plp
|
||||
#DeviceURI serial:/dev/ttyd1?baud=38400+size=8+parity=none+flow=soft
|
||||
#DeviceURI scsi:/dev/scsi/sc1d6l0
|
||||
#DeviceURI socket://hostname:port
|
||||
#DeviceURI tftp://hostname/path
|
||||
#DeviceURI ftp://hostname/path
|
||||
#DeviceURI http://hostname[:port]/path
|
||||
#DeviceURI ipp://hostname/path
|
||||
#DeviceURI smb://hostname/printer
|
||||
|
||||
#
|
||||
# State: sets the initial state of the printer. Can be one of the
|
||||
# following:
|
||||
#
|
||||
# Idle - Printer is available to print new jobs.
|
||||
# Stopped - Printer is disabled but accepting new jobs.
|
||||
#
|
||||
|
||||
#State Idle
|
||||
|
||||
#
|
||||
# StateMessage: sets the printer-state-message attribute for the printer.
|
||||
#
|
||||
|
||||
#StateMessage Printer is idle.
|
||||
|
||||
#
|
||||
# Accepting: is the printer accepting jobs?
|
||||
#
|
||||
#Accepting Yes
|
||||
#Accepting No
|
||||
|
||||
#</Printer>
|
||||
|
||||
#
|
||||
# End of "$Id: printers.conf 4088 2004-02-25 20:15:27Z mike $".
|
||||
#
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# "$Id$"
|
||||
#
|
||||
# Sample SNMP configuration file for CUPS. See "man cups-smnp.conf" for a
|
||||
# complete description of this file.
|
||||
#
|
||||
|
||||
@CUPS_SNMP_ADDRESS@
|
||||
@CUPS_SNMP_COMMUNITY@
|
||||
|
||||
#
|
||||
# End of "$Id$".
|
||||
#
|
||||
@@ -0,0 +1,140 @@
|
||||
dnl
|
||||
dnl "$Id$"
|
||||
dnl
|
||||
dnl 32/64-bit library support stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Setup support for separate 32/64-bit library generation...
|
||||
AC_ARG_ENABLE(32bit, [ --enable-32bit generate 32-bit libraries on 32/64-bit systems, default=no])
|
||||
|
||||
INSTALL32=""
|
||||
LIB32CUPS=""
|
||||
LIB32CUPSIMAGE=""
|
||||
LIB32DIR=""
|
||||
UNINSTALL32=""
|
||||
|
||||
AC_SUBST(INSTALL32)
|
||||
AC_SUBST(LIB32CUPS)
|
||||
AC_SUBST(LIB32CUPSIMAGE)
|
||||
AC_SUBST(LIB32DIR)
|
||||
AC_SUBST(UNINSTALL32)
|
||||
|
||||
AC_ARG_ENABLE(64bit, [ --enable-64bit generate 64-bit libraries on 32/64-bit systems, default=no])
|
||||
|
||||
INSTALL64=""
|
||||
LIB64CUPS=""
|
||||
LIB64CUPSIMAGE=""
|
||||
LIB64DIR=""
|
||||
UNINSTALL64=""
|
||||
|
||||
AC_SUBST(INSTALL64)
|
||||
AC_SUBST(LIB64CUPS)
|
||||
AC_SUBST(LIB64CUPSIMAGE)
|
||||
AC_SUBST(LIB64DIR)
|
||||
AC_SUBST(UNINSTALL64)
|
||||
|
||||
case "$uname" in
|
||||
HP-UX*)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
INSTALL32="install32bit"
|
||||
LIB32CUPS="32bit/libcups.so.2"
|
||||
LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
|
||||
LIB32DIR="$exec_prefix/lib"
|
||||
if test -d /usr/lib/hpux32; then
|
||||
LIB32DIR="${LIB32DIR}/hpux32"
|
||||
fi
|
||||
UNINSTALL32="uninstall32bit"
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
INSTALL64="install64bit"
|
||||
LIB64CUPS="64bit/libcups.so.2"
|
||||
LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
|
||||
LIB64DIR="$exec_prefix/lib"
|
||||
if test -d /usr/lib/hpux64; then
|
||||
LIB64DIR="${LIB64DIR}/hpux64"
|
||||
fi
|
||||
UNINSTALL64="uninstall64bit"
|
||||
fi
|
||||
;;
|
||||
|
||||
IRIX)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
INSTALL32="install32bit"
|
||||
LIB32CUPS="32bit/libcups.so.2"
|
||||
LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
|
||||
LIB32DIR="$prefix/lib32"
|
||||
UNINSTALL32="uninstall32bit"
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
INSTALL64="install64bit"
|
||||
LIB64CUPS="64bit/libcups.so.2"
|
||||
LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
|
||||
LIB64DIR="$prefix/lib64"
|
||||
UNINSTALL64="uninstall64bit"
|
||||
fi
|
||||
;;
|
||||
|
||||
Linux*)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
INSTALL32="install32bit"
|
||||
LIB32CUPS="32bit/libcups.so.2"
|
||||
LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
|
||||
LIB32DIR="$exec_prefix/lib"
|
||||
if test -d /usr/lib32; then
|
||||
LIB32DIR="${LIB32DIR}32"
|
||||
fi
|
||||
UNINSTALL32="uninstall32bit"
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
INSTALL64="install64bit"
|
||||
LIB64CUPS="64bit/libcups.so.2"
|
||||
LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
|
||||
LIB64DIR="$exec_prefix/lib"
|
||||
if test -d /usr/lib64; then
|
||||
LIB64DIR="${LIB64DIR}64"
|
||||
fi
|
||||
UNINSTALL64="uninstall64bit"
|
||||
fi
|
||||
;;
|
||||
|
||||
SunOS*)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
INSTALL32="install32bit"
|
||||
LIB32CUPS="32bit/libcups.so.2"
|
||||
LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
|
||||
LIB32DIR="$exec_prefix/lib/32"
|
||||
UNINSTALL32="uninstall32bit"
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
INSTALL64="install64bit"
|
||||
LIB64CUPS="64bit/libcups.so.2"
|
||||
LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
|
||||
LIB64DIR="$exec_prefix/lib/64"
|
||||
UNINSTALL64="uninstall64bit"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl
|
||||
dnl End of "$Id$".
|
||||
dnl
|
||||
+141
-60
@@ -1,38 +1,32 @@
|
||||
dnl
|
||||
dnl "$Id: cups-common.m4 4437 2004-10-13 21:08:18Z mike $"
|
||||
dnl "$Id: cups-common.m4 8575 2009-04-29 16:29:01Z mike $"
|
||||
dnl
|
||||
dnl Common configuration stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007-2008 by Apple Inc.
|
||||
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl We need at least autoconf 2.50...
|
||||
AC_PREREQ(2.50)
|
||||
dnl We need at least autoconf 2.60...
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
dnl Set the name of the config header file...
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
dnl Version number information...
|
||||
CUPS_VERSION="1.1.22rc2"
|
||||
CUPS_VERSION="1.3.11"
|
||||
CUPS_REVISION=""
|
||||
|
||||
AC_SUBST(CUPS_VERSION)
|
||||
AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION")
|
||||
AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION")
|
||||
AC_SUBST(CUPS_REVISION)
|
||||
AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION$CUPS_REVISION")
|
||||
AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION$CUPS_REVISION")
|
||||
|
||||
dnl Default compiler flags...
|
||||
CFLAGS="${CFLAGS:=}"
|
||||
@@ -53,18 +47,11 @@ fi
|
||||
AC_PROG_RANLIB
|
||||
AC_PATH_PROG(AR,ar)
|
||||
AC_PATH_PROG(HTMLDOC,htmldoc)
|
||||
AC_PATH_PROG(LD,ld)
|
||||
AC_PATH_PROG(LN,ln)
|
||||
AC_PATH_PROG(MV,mv)
|
||||
AC_PATH_PROG(NROFF,nroff)
|
||||
if test "x$NROFF" = x; then
|
||||
AC_PATH_PROG(GROFF,groff)
|
||||
if test "x$GROFF" = x; then
|
||||
NROFF="echo"
|
||||
else
|
||||
NROFF="$GROFF -T ascii"
|
||||
fi
|
||||
fi
|
||||
AC_PATH_PROG(RM,rm)
|
||||
AC_PATH_PROG(RMDIR,rmdir)
|
||||
AC_PATH_PROG(SED,sed)
|
||||
AC_PATH_PROG(STRIP,strip)
|
||||
|
||||
@@ -78,8 +65,16 @@ if test "x$CXX" = x; then
|
||||
AC_MSG_ERROR([Unable to find required C++ compiler command.])
|
||||
fi
|
||||
|
||||
dnl Architecture checks...
|
||||
AC_C_BIGENDIAN
|
||||
dnl Static library option...
|
||||
INSTALLSTATIC=""
|
||||
AC_ARG_ENABLE(static, [ --enable-static install static libraries, default=no])
|
||||
|
||||
if test x$enable_static = xyes; then
|
||||
echo Installing static libraries...
|
||||
INSTALLSTATIC="installstatic"
|
||||
fi
|
||||
|
||||
AC_SUBST(INSTALLSTATIC)
|
||||
|
||||
dnl Check for libraries...
|
||||
AC_SEARCH_LIBS(crypt, crypt)
|
||||
@@ -116,7 +111,6 @@ AC_SUBST(LIBPAPER)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_DIRENT
|
||||
AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
|
||||
AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
|
||||
AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
|
||||
@@ -126,6 +120,9 @@ AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
|
||||
AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
|
||||
AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
|
||||
AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
|
||||
AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
|
||||
AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
|
||||
AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
|
||||
|
||||
dnl Checks for string functions.
|
||||
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strlcat strlcpy)
|
||||
@@ -135,22 +132,6 @@ else
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
fi
|
||||
|
||||
dnl Check OS version and use appropriate format string for strftime...
|
||||
AC_MSG_CHECKING(for correct format string to use with strftime)
|
||||
|
||||
case "$uname" in
|
||||
IRIX | SunOS*)
|
||||
# IRIX and SunOS
|
||||
AC_MSG_RESULT(NULL)
|
||||
AC_DEFINE(CUPS_STRFTIME_FORMAT, NULL)
|
||||
;;
|
||||
*)
|
||||
# All others
|
||||
AC_MSG_RESULT("%c")
|
||||
AC_DEFINE(CUPS_STRFTIME_FORMAT, "%c")
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Checks for mkstemp and mkstemps functions.
|
||||
AC_CHECK_FUNCS(mkstemp mkstemps)
|
||||
|
||||
@@ -174,8 +155,7 @@ esac
|
||||
AC_CHECK_FUNCS(sigaction)
|
||||
|
||||
dnl Checks for wait functions.
|
||||
AC_CHECK_FUNCS(waitpid)
|
||||
AC_CHECK_FUNCS(wait3)
|
||||
AC_CHECK_FUNCS(waitpid wait3)
|
||||
|
||||
dnl See if the tm structure has the tm_gmtoff member...
|
||||
AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
|
||||
@@ -185,6 +165,9 @@ AC_TRY_COMPILE([#include <time.h>],[struct tm t;
|
||||
AC_DEFINE(HAVE_TM_GMTOFF),
|
||||
AC_MSG_RESULT(no))
|
||||
|
||||
dnl See if we have the removefile(3) function for securely removing files
|
||||
AC_CHECK_FUNCS(removefile)
|
||||
|
||||
dnl Flags for "ar" command...
|
||||
case $uname in
|
||||
Darwin* | *BSD*)
|
||||
@@ -197,21 +180,119 @@ esac
|
||||
|
||||
AC_SUBST(ARFLAGS)
|
||||
|
||||
dnl Prep libraries specifically for cupsd and backends...
|
||||
BACKLIBS=""
|
||||
CUPSDLIBS=""
|
||||
AC_SUBST(BACKLIBS)
|
||||
AC_SUBST(CUPSDLIBS)
|
||||
|
||||
dnl See if we have POSIX ACL support...
|
||||
SAVELIBS="$LIBS"
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
|
||||
CUPSDLIBS="$CUPSDLIBS $LIBS"
|
||||
LIBS="$SAVELIBS"
|
||||
|
||||
dnl Check for DBUS support
|
||||
if test -d /etc/dbus-1; then
|
||||
DBUSDIR="/etc/dbus-1"
|
||||
else
|
||||
DBUSDIR=""
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(dbus, [ --enable-dbus enable DBUS support, default=auto])
|
||||
AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
|
||||
DBUSDIR="$withval")
|
||||
|
||||
if test "x$enable_dbus" != xno; then
|
||||
AC_PATH_PROG(PKGCONFIG, pkg-config)
|
||||
if test "x$PKGCONFIG" != x; then
|
||||
AC_MSG_CHECKING(for DBUS)
|
||||
if $PKGCONFIG --exists dbus-1; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_DBUS)
|
||||
CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
|
||||
CUPSDLIBS="$CUPSDLIBS `$PKGCONFIG --libs dbus-1`"
|
||||
AC_CHECK_LIB(dbus-1,
|
||||
dbus_message_iter_init_append,
|
||||
AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND),,
|
||||
`$PKGCONFIG --libs dbus-1`)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
DBUSDIR=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(DBUSDIR)
|
||||
|
||||
dnl Extra platform-specific libraries...
|
||||
CUPS_DEFAULT_PRINTADMIN_AUTH="@SYSTEM"
|
||||
CUPS_SYSTEM_AUTHKEY=""
|
||||
FONTS="fonts"
|
||||
LEGACY_BACKENDS="parallel scsi"
|
||||
|
||||
case $uname in
|
||||
Darwin*)
|
||||
BACKLIBS="-framework IOKit"
|
||||
COMMONLIBS="-framework CoreFoundation"
|
||||
;;
|
||||
*)
|
||||
BACKLIBS=""
|
||||
COMMONLIBS=""
|
||||
FONTS=""
|
||||
LEGACY_BACKENDS=""
|
||||
BACKLIBS="$BACKLIBS -framework IOKit"
|
||||
CUPSDLIBS="$CUPSDLIBS -sectorder __TEXT __text cupsd.order -e start -framework IOKit -framework SystemConfiguration"
|
||||
LIBS="-framework CoreFoundation $LIBS"
|
||||
|
||||
dnl Check for framework headers...
|
||||
AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
|
||||
AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
|
||||
AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
|
||||
|
||||
dnl Check for the new membership functions in MacOSX 10.4...
|
||||
AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
|
||||
AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
|
||||
AC_CHECK_FUNCS(mbr_uid_to_uuid)
|
||||
|
||||
dnl Need <dlfcn.h> header...
|
||||
AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
|
||||
|
||||
dnl Check for notify_post support
|
||||
AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
|
||||
AC_CHECK_FUNCS(notify_post)
|
||||
|
||||
dnl Check for Authorization Services support
|
||||
AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
|
||||
default_adminkey="$withval",
|
||||
default_adminkey="default")
|
||||
AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
|
||||
default_operkey="$withval",
|
||||
default_operkey="default")
|
||||
|
||||
AC_CHECK_HEADER(Security/Authorization.h, [
|
||||
AC_DEFINE(HAVE_AUTHORIZATION_H)
|
||||
|
||||
if test "x$default_adminkey" != xdefault; then
|
||||
CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
|
||||
elif grep -q system.print.admin /etc/authorization; then
|
||||
CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
|
||||
else
|
||||
CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
|
||||
fi
|
||||
|
||||
if test "x$default_operkey" != xdefault; then
|
||||
CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
|
||||
elif grep -q system.print.operator /etc/authorization; then
|
||||
CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
|
||||
else
|
||||
CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
|
||||
fi])
|
||||
AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(BACKLIBS)
|
||||
AC_SUBST(COMMONLIBS)
|
||||
AC_SUBST(CUPS_DEFAULT_PRINTADMIN_AUTH)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTADMIN_AUTH, "$CUPS_DEFAULT_PRINTADMIN_AUTH")
|
||||
AC_SUBST(CUPS_SYSTEM_AUTHKEY)
|
||||
AC_SUBST(FONTS)
|
||||
AC_SUBST(LEGACY_BACKENDS)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-common.m4 4437 2004-10-13 21:08:18Z mike $".
|
||||
dnl End of "$Id: cups-common.m4 8575 2009-04-29 16:29:01Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -1,95 +1,310 @@
|
||||
dnl
|
||||
dnl "$Id: cups-compiler.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-compiler.m4 7648 2008-06-16 17:41:11Z mike $"
|
||||
dnl
|
||||
dnl Common configuration stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl Compiler stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007-2008 by Apple Inc.
|
||||
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Clear the debugging and non-shared library options unless the user asks
|
||||
dnl for them...
|
||||
|
||||
OPTIM=""
|
||||
AC_SUBST(OPTIM)
|
||||
|
||||
AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
|
||||
[if test x$enable_debug = xyes; then
|
||||
OPTIM="-g"
|
||||
fi])
|
||||
|
||||
AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
|
||||
dnl Setup general architecture flags...
|
||||
AC_ARG_WITH(archflags, [ --with-archflags="flags"
|
||||
set default architecture flags ])
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
ARCHFLAGS=""
|
||||
LDARCHFLAGS=""
|
||||
else
|
||||
ARCHFLAGS="$with_archflags"
|
||||
if test "$uname" = Darwin; then
|
||||
# Only link 32-bit programs - 64-bit is for the shared
|
||||
# libraries...
|
||||
LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
|
||||
else
|
||||
LDARCHFLAGS="$ARCHFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(ARCHFLAGS)
|
||||
AC_SUBST(LDARCHFLAGS)
|
||||
|
||||
dnl Setup support for separate 32/64-bit library generation...
|
||||
AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
|
||||
specifies 32-bit architecture flags])
|
||||
ARCH32FLAGS=""
|
||||
AC_SUBST(ARCH32FLAGS)
|
||||
|
||||
AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
|
||||
specifies 64-bit architecture flags])
|
||||
ARCH64FLAGS=""
|
||||
AC_SUBST(ARCH64FLAGS)
|
||||
|
||||
dnl Position-Independent Executable support on Linux...
|
||||
AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
|
||||
|
||||
dnl Read-only data/program support on Linux...
|
||||
AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
|
||||
|
||||
dnl Update compiler options...
|
||||
CXXLIBS=""
|
||||
AC_SUBST(CXXLIBS)
|
||||
|
||||
PIEFLAGS=""
|
||||
AC_SUBST(PIEFLAGS)
|
||||
|
||||
RELROFLAGS=""
|
||||
AC_SUBST(RELROFLAGS)
|
||||
|
||||
LIBCUPSORDER="libcups.order"
|
||||
AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
|
||||
if test -f "$withval"; then
|
||||
LIBCUPSORDER="$withval"
|
||||
fi)
|
||||
AC_SUBST(LIBCUPSORDER)
|
||||
|
||||
LIBCUPSIMAGEORDER="libcupsimage.order"
|
||||
AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
|
||||
libcupsimage secorder file, default=libcupsimage.order],
|
||||
if test -f "$withval"; then
|
||||
LIBCUPSIMAGEORDER="$withval"
|
||||
fi)
|
||||
AC_SUBST(LIBCUPSIMAGEORDER)
|
||||
|
||||
if test -n "$GCC"; then
|
||||
# Starting with GCC 3.0, you must link C++ programs against either
|
||||
# libstdc++ (shared by default), or libsupc++ (always static). If
|
||||
# you care about binary portability between Linux distributions,
|
||||
# you need to either 1) build your own GCC with static C++ libraries
|
||||
# or 2) link using gcc and libsupc++. We choose the latter since
|
||||
# CUPS doesn't (currently) use any of the stdc++ library.
|
||||
#
|
||||
# Also, GCC 3.0.x still has problems compiling some code. You may
|
||||
# or may not have success with it. USE 3.0.x WITH EXTREME CAUTION!
|
||||
#
|
||||
# Previous versions of GCC do not have the reliance on the stdc++
|
||||
# or g++ libraries, so the extra supc++ library is not needed.
|
||||
|
||||
AC_MSG_CHECKING(if libsupc++ is required)
|
||||
|
||||
SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
|
||||
case "$SUPC" in
|
||||
libsupc++.a*)
|
||||
# Library not found, so this is and older GCC...
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
*)
|
||||
# This is gcc 3.x, and it knows of libsupc++, so we need it
|
||||
CXXLIBS="-lsupc++"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
esac
|
||||
|
||||
CXX="$CC"
|
||||
|
||||
# Add GCC-specific compiler options...
|
||||
if test -z "$OPTIM"; then
|
||||
if test "x$with_optim" = x; then
|
||||
if test $uname = HP-UX; then
|
||||
# GCC under HP-UX has bugs with -O2
|
||||
OPTIM="-O1"
|
||||
else
|
||||
OPTIM="-O2"
|
||||
fi
|
||||
# Default to optimize-for-size and debug
|
||||
OPTIM="-Os -g"
|
||||
else
|
||||
OPTIM="$with_optim $OPTIM"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generate position-independent code as needed...
|
||||
if test $PICFLAG = 1 -a $uname != AIX; then
|
||||
OPTIM="-fPIC $OPTIM"
|
||||
fi
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
OPTIM="-Wall $OPTIM"
|
||||
# The -fstack-protector option is available with some versions of
|
||||
# GCC and adds "stack canaries" which detect when the return address
|
||||
# has been overwritten, preventing many types of exploit attacks.
|
||||
AC_MSG_CHECKING(if GCC supports -fstack-protector)
|
||||
OLDCFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -fstack-protector"
|
||||
AC_TRY_COMPILE(,,
|
||||
OPTIM="$OPTIM -fstack-protector"
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
CFLAGS="$OLDCFLAGS"
|
||||
|
||||
# The -pie option is available with some versions of GCC and adds
|
||||
# randomization of addresses, which avoids another class of exploits
|
||||
# that depend on a fixed address for common functions.
|
||||
if test x$enable_pie = xyes; then
|
||||
AC_MSG_CHECKING(if GCC supports -pie)
|
||||
OLDCFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -pie -fPIE"
|
||||
AC_TRY_COMPILE(,,
|
||||
PIEFLAGS="-pie -fPIE"
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no, ignoring --enable-pie))
|
||||
CFLAGS="$OLDCFLAGS"
|
||||
fi
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
# Add useful warning options for tracking down problems...
|
||||
OPTIM="-Wall -Wno-format-y2k $OPTIM"
|
||||
# Additional warning options for development testing...
|
||||
if test -d .svn; then
|
||||
OPTIM="-Wshadow -Wunused $OPTIM"
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$uname" in
|
||||
Darwin*)
|
||||
# -D_FORTIFY_SOURCE=2 adds additional object size
|
||||
# checking, basically wrapping all string functions
|
||||
# with buffer-limited ones. Not strictly needed for
|
||||
# CUPS since we already use buffer-limited calls, but
|
||||
# this will catch any additions that are broken.
|
||||
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
|
||||
|
||||
if test x$enable_pie = xyes; then
|
||||
# GCC 4 on Mac OS X needs -Wl,-pie as well
|
||||
LDFLAGS="$LDFLAGS -Wl,-pie"
|
||||
fi
|
||||
;;
|
||||
|
||||
HP-UX*)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="-milp32"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-mlp64"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="-mlp64"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-milp32"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
IRIX)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="-n32 -mips3"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-64 -mips4"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="-64 -mips4"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-n32 -mips3"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
Linux*)
|
||||
# The -z relro option is provided by the Linux linker command to
|
||||
# make relocatable data read-only.
|
||||
if test x$enable_relro = xyes; then
|
||||
RELROFLAGS="-Wl,-z,relro"
|
||||
fi
|
||||
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="-m32"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-m64"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="-m64"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-m32"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
SunOS*)
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="-m32"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-m64"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="-m64"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-m32"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# Add vendor-specific compiler options...
|
||||
case $uname in
|
||||
AIX*)
|
||||
if test -z "$OPTIM"; then
|
||||
@@ -110,14 +325,47 @@ else
|
||||
fi
|
||||
|
||||
CFLAGS="-Ae $CFLAGS"
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
OPTIM="+DAportable $OPTIM"
|
||||
fi
|
||||
# Warning 336 is "empty translation unit"
|
||||
# Warning 829 is passing constant string as char *
|
||||
CXXFLAGS="+W336,829 $CXXFLAGS"
|
||||
|
||||
if test $PICFLAG = 1; then
|
||||
OPTIM="+z $OPTIM"
|
||||
fi
|
||||
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="+DD32"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="+DD64"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="+DD64"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="+DD32"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
IRIX)
|
||||
if test -z "$OPTIM"; then
|
||||
@@ -128,20 +376,51 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $uversion -ge 62 -a "x$with_optim" = x; then
|
||||
OPTIM="$OPTIM -n32 -mips3"
|
||||
if test "x$with_optim" = x; then
|
||||
OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
|
||||
fi
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
# Show most warnings, but suppress the
|
||||
# ones about arguments not being used,
|
||||
# string constants assigned to const
|
||||
# char *'s, etc. We only set the warning
|
||||
# options on IRIX 6.2 and higher because
|
||||
# of limitations in the older SGI compiler
|
||||
# tools.
|
||||
if test $uversion -ge 62; then
|
||||
OPTIM="-fullwarn -woff 1183,1209,1349,3201 $OPTIM"
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Build 32-bit libraries, 64-bit base...
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCH32FLAGS="-n32 -mips3"
|
||||
else
|
||||
ARCH32FLAGS="$with_arch32flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-64 -mips4"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries, 32-bit base...
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCH64FLAGS="-64 -mips4"
|
||||
else
|
||||
ARCH64FLAGS="$with_arch64flags"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-n32 -mips3"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
OSF*)
|
||||
# Tru64 UNIX aka Digital UNIX aka OSF/1
|
||||
if test -z "$OPTIM"; then
|
||||
if test "x$with_optim" = x; then
|
||||
OPTIM="-O"
|
||||
else
|
||||
OPTIM="$with_optim"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
@@ -149,21 +428,56 @@ else
|
||||
# Solaris
|
||||
if test -z "$OPTIM"; then
|
||||
if test "x$with_optim" = x; then
|
||||
OPTIM="-xO4"
|
||||
OPTIM="-xO2"
|
||||
else
|
||||
OPTIM="$with_optim $OPTIM"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
# Specify "generic" SPARC output and suppress
|
||||
# all of Sun's questionable warning messages...
|
||||
OPTIM="-w $OPTIM -xarch=generic"
|
||||
fi
|
||||
|
||||
if test $PICFLAG = 1; then
|
||||
OPTIM="-KPIC $OPTIM"
|
||||
fi
|
||||
|
||||
if test "x$enable_32bit" = xyes; then
|
||||
# Compiling on a Solaris system, build 64-bit
|
||||
# binaries with separate 32-bit libraries...
|
||||
ARCH32FLAGS="-xarch=generic"
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
# Suppress all of Sun's questionable
|
||||
# warning messages, and default to
|
||||
# 64-bit compiles of everything else...
|
||||
OPTIM="-w $OPTIM"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch64flags"; then
|
||||
ARCHFLAGS="-xarch=generic64"
|
||||
else
|
||||
ARCHFLAGS="$with_arch64flags"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if test "x$enable_64bit" = xyes; then
|
||||
# Build 64-bit libraries...
|
||||
ARCH64FLAGS="-xarch=generic64"
|
||||
fi
|
||||
|
||||
if test "x$with_optim" = x; then
|
||||
# Suppress all of Sun's questionable
|
||||
# warning messages, and default to
|
||||
# 32-bit compiles of everything else...
|
||||
OPTIM="-w $OPTIM"
|
||||
fi
|
||||
|
||||
if test -z "$with_archflags"; then
|
||||
if test -z "$with_arch32flags"; then
|
||||
ARCHFLAGS="-xarch=generic"
|
||||
else
|
||||
ARCHFLAGS="$with_arch32flags"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
UNIX_SVR*)
|
||||
# UnixWare
|
||||
@@ -185,22 +499,41 @@ else
|
||||
# cups-support@cups.org...
|
||||
echo "Building CUPS with default compiler optimizations; contact"
|
||||
echo "cups-bugs@cups.org with uname and compiler options needed"
|
||||
echo "for your platform, or set the CFLAGS and CXXFLAGS"
|
||||
echo "environment variable before running configure."
|
||||
echo "for your platform, or set the CFLAGS, CXXFLAGS, and LDFLAGS"
|
||||
echo "environment variables before running configure."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test $uname = HP-UX; then
|
||||
# HP-UX 10.20 (at least) needs this definition to get the
|
||||
# h_errno global...
|
||||
OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
|
||||
# Add general compiler options per platform...
|
||||
case $uname in
|
||||
HP-UX*)
|
||||
# HP-UX 10.20 (at least) needs this definition to get the
|
||||
# h_errno global...
|
||||
OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
|
||||
|
||||
# HP-UX 11.00 (at least) needs this definition to get the
|
||||
# u_short type used by the IP headers...
|
||||
OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
|
||||
fi
|
||||
# HP-UX 11.00 (at least) needs this definition to get the
|
||||
# u_short type used by the IP headers...
|
||||
OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
|
||||
|
||||
# HP-UX 11.23 (at least) needs this definition to get the
|
||||
# IPv6 header to work...
|
||||
OPTIM="$OPTIM -D_HPUX_SOURCE"
|
||||
;;
|
||||
|
||||
Linux*)
|
||||
# glibc 2.8 and higher breaks peer credentials unless you
|
||||
# define _GNU_SOURCE...
|
||||
OPTIM="$OPTIM -D_GNU_SOURCE"
|
||||
;;
|
||||
|
||||
OSF*)
|
||||
# Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
|
||||
# to be POSIX-compliant...
|
||||
OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-compiler.m4 4358 2004-08-11 14:39:26Z mike $".
|
||||
dnl End of "$Id: cups-compiler.m4 7648 2008-06-16 17:41:11Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
dnl
|
||||
dnl "$Id: cups-defaults.m4 7448 2008-04-14 18:10:27Z mike $"
|
||||
dnl
|
||||
dnl Default cupsd configuration settings for the Common UNIX Printing System
|
||||
dnl (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007-2008 by Apple Inc.
|
||||
dnl Copyright 2006-2007 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Default languages...
|
||||
LANGUAGES="`ls -1 locale/*.po | sed -e '1,$s/locale\/cups_//' -e '1,$s/\.po//' | tr '\n' ' '`"
|
||||
|
||||
AC_ARG_WITH(languages, [ --with-languages set installed languages, default=all ],[
|
||||
case "$withval" in
|
||||
none | no) LANGUAGES="" ;;
|
||||
all) ;;
|
||||
*) LANGUAGES="$withval" ;;
|
||||
esac])
|
||||
AC_SUBST(LANGUAGES)
|
||||
|
||||
dnl Default ConfigFilePerm
|
||||
AC_ARG_WITH(config_file_perm, [ --with-config-file-perm set default ConfigFilePerm value, default=0640],
|
||||
CUPS_CONFIG_FILE_PERM="$withval",
|
||||
if test "x$uname" = xDarwin; then
|
||||
CUPS_CONFIG_FILE_PERM="644"
|
||||
else
|
||||
CUPS_CONFIG_FILE_PERM="640"
|
||||
fi)
|
||||
AC_SUBST(CUPS_CONFIG_FILE_PERM)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, 0$CUPS_CONFIG_FILE_PERM)
|
||||
|
||||
dnl Default LogFilePerm
|
||||
AC_ARG_WITH(log_file_perm, [ --with-log-file-perm set default LogFilePerm value, default=0644],
|
||||
CUPS_LOG_FILE_PERM="$withval",
|
||||
CUPS_LOG_FILE_PERM="644")
|
||||
AC_SUBST(CUPS_LOG_FILE_PERM)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM)
|
||||
|
||||
dnl Default Browsing
|
||||
AC_ARG_ENABLE(browsing, [ --enable-browsing enable Browsing by default, default=yes])
|
||||
if test "x$enable_browsing" = xno; then
|
||||
CUPS_BROWSING="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSING, 0)
|
||||
else
|
||||
CUPS_BROWSING="Yes"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSING, 1)
|
||||
fi
|
||||
AC_SUBST(CUPS_BROWSING)
|
||||
|
||||
dnl Default BrowseLocalProtocols
|
||||
AC_ARG_WITH(local_protocols, [ --with-local-protocols set default BrowseLocalProtocols, default="CUPS"],
|
||||
default_local_protocols="$withval",
|
||||
default_local_protocols="default")
|
||||
|
||||
if test x$with_local_protocols != xno; then
|
||||
if test "x$default_local_protocols" = "xdefault"; then
|
||||
if test "x$DNSSDLIBS" != "x"; then
|
||||
CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS dnssd"
|
||||
else
|
||||
CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS"
|
||||
fi
|
||||
else
|
||||
CUPS_BROWSE_LOCAL_PROTOCOLS="$default_local_protocols"
|
||||
fi
|
||||
else
|
||||
CUPS_BROWSE_LOCAL_PROTOCOLS=""
|
||||
fi
|
||||
|
||||
AC_SUBST(CUPS_BROWSE_LOCAL_PROTOCOLS)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS,
|
||||
"$CUPS_BROWSE_LOCAL_PROTOCOLS")
|
||||
|
||||
dnl Default BrowseRemoteProtocols
|
||||
AC_ARG_WITH(remote_protocols, [ --with-remote-protocols set default BrowseRemoteProtocols, default="CUPS"],
|
||||
default_remote_protocols="$withval",
|
||||
default_remote_protocols="default")
|
||||
|
||||
if test x$with_remote_protocols != xno; then
|
||||
if test "x$default_remote_protocols" = "xdefault"; then
|
||||
if test "$uname" = "Darwin" -a $uversion -ge 90; then
|
||||
CUPS_BROWSE_REMOTE_PROTOCOLS=""
|
||||
else
|
||||
CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS"
|
||||
fi
|
||||
else
|
||||
CUPS_BROWSE_REMOTE_PROTOCOLS="$default_remote_protocols"
|
||||
fi
|
||||
else
|
||||
CUPS_BROWSE_REMOTE_PROTOCOLS=""
|
||||
fi
|
||||
|
||||
AC_SUBST(CUPS_BROWSE_REMOTE_PROTOCOLS)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS,
|
||||
"$CUPS_BROWSE_REMOTE_PROTOCOLS")
|
||||
|
||||
dnl Default BrowseShortNames
|
||||
AC_ARG_ENABLE(browse_short, [ --enable-browse-short-names
|
||||
enable BrowseShortNames by default, default=yes])
|
||||
if test "x$enable_browse_short" = xno; then
|
||||
CUPS_BROWSE_SHORT_NAMES="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_SHORT_NAMES, 0)
|
||||
else
|
||||
CUPS_BROWSE_SHORT_NAMES="Yes"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_SHORT_NAMES, 1)
|
||||
fi
|
||||
AC_SUBST(CUPS_BROWSE_SHORT_NAMES)
|
||||
|
||||
dnl Default DefaultShared
|
||||
AC_ARG_ENABLE(default_shared, [ --enable-default-shared enable DefaultShared by default, default=yes])
|
||||
if test "x$enable_default_shared" = xno; then
|
||||
CUPS_DEFAULT_SHARED="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DEFAULT_SHARED, 0)
|
||||
else
|
||||
CUPS_DEFAULT_SHARED="Yes"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DEFAULT_SHARED, 1)
|
||||
fi
|
||||
AC_SUBST(CUPS_DEFAULT_SHARED)
|
||||
|
||||
dnl Default ImplicitClasses
|
||||
AC_ARG_ENABLE(implicit, [ --enable-implicit-classes
|
||||
enable ImplicitClasses by default, default=yes])
|
||||
if test "x$enable_implicit" = xno; then
|
||||
CUPS_IMPLICIT_CLASSES="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IMPLICIT_CLASSES, 0)
|
||||
else
|
||||
CUPS_IMPLICIT_CLASSES="Yes"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IMPLICIT_CLASSES, 1)
|
||||
fi
|
||||
AC_SUBST(CUPS_IMPLICIT_CLASSES)
|
||||
|
||||
dnl Default UseNetworkDefault
|
||||
AC_ARG_ENABLE(use_network_default, [ --enable-use-network-default
|
||||
enable UseNetworkDefault by default, default=auto])
|
||||
if test "x$enable_use_network_default" != xno; then
|
||||
AC_MSG_CHECKING(whether to use network default printers)
|
||||
if test "x$enable_use_network_default" = xyes -o $uname != Darwin; then
|
||||
CUPS_USE_NETWORK_DEFAULT="Yes"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USE_NETWORK_DEFAULT, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
CUPS_USE_NETWORK_DEFAULT="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USE_NETWORK_DEFAULT, 0)
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
else
|
||||
CUPS_USE_NETWORK_DEFAULT="No"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USE_NETWORK_DEFAULT, 0)
|
||||
fi
|
||||
AC_SUBST(CUPS_USE_NETWORK_DEFAULT)
|
||||
|
||||
dnl Determine the correct username and group for this OS...
|
||||
AC_ARG_WITH(cups_user, [ --with-cups-user set default user for CUPS],
|
||||
CUPS_USER="$withval",
|
||||
AC_MSG_CHECKING(for default print user)
|
||||
if test x$uname = xDarwin; then
|
||||
if test x`id -u _lp 2>/dev/null` = x; then
|
||||
CUPS_USER="lp";
|
||||
else
|
||||
CUPS_USER="_lp";
|
||||
fi
|
||||
AC_MSG_RESULT($CUPS_USER)
|
||||
elif test -f /etc/passwd; then
|
||||
CUPS_USER=""
|
||||
for user in lp lpd guest daemon nobody; do
|
||||
if test "`grep \^${user}: /etc/passwd`" != ""; then
|
||||
CUPS_USER="$user"
|
||||
AC_MSG_RESULT($user)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if test x$CUPS_USER = x; then
|
||||
CUPS_USER="nobody"
|
||||
AC_MSG_RESULT(not found, using "$CUPS_USER")
|
||||
fi
|
||||
else
|
||||
CUPS_USER="nobody"
|
||||
AC_MSG_RESULT(no password file, using "$CUPS_USER")
|
||||
fi)
|
||||
|
||||
AC_ARG_WITH(cups_group, [ --with-cups-group set default group for CUPS],
|
||||
CUPS_GROUP="$withval",
|
||||
AC_MSG_CHECKING(for default print group)
|
||||
if test x$uname = xDarwin; then
|
||||
if test x`id -g _lp 2>/dev/null` = x; then
|
||||
CUPS_GROUP="lp";
|
||||
else
|
||||
CUPS_GROUP="_lp";
|
||||
fi
|
||||
AC_MSG_RESULT($CUPS_GROUP)
|
||||
elif test -f /etc/group; then
|
||||
GROUP_LIST="_lp lp nobody"
|
||||
CUPS_GROUP=""
|
||||
for group in $GROUP_LIST; do
|
||||
if test "`grep \^${group}: /etc/group`" != ""; then
|
||||
CUPS_GROUP="$group"
|
||||
AC_MSG_RESULT($group)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if test x$CUPS_GROUP = x; then
|
||||
CUPS_GROUP="nobody"
|
||||
AC_MSG_RESULT(not found, using "$CUPS_GROUP")
|
||||
fi
|
||||
else
|
||||
CUPS_GROUP="nobody"
|
||||
AC_MSG_RESULT(no group file, using "$CUPS_GROUP")
|
||||
fi)
|
||||
|
||||
AC_ARG_WITH(system_groups, [ --with-system-groups set default system groups for CUPS],
|
||||
CUPS_SYSTEM_GROUPS="$withval",
|
||||
if test x$uname = xDarwin; then
|
||||
CUPS_SYSTEM_GROUPS="admin"
|
||||
else
|
||||
AC_MSG_CHECKING(for default system groups)
|
||||
if test -f /etc/group; then
|
||||
CUPS_SYSTEM_GROUPS=""
|
||||
GROUP_LIST="lpadmin sys system root"
|
||||
for group in $GROUP_LIST; do
|
||||
if test "`grep \^${group}: /etc/group`" != ""; then
|
||||
if test "x$CUPS_SYSTEM_GROUPS" = x; then
|
||||
CUPS_SYSTEM_GROUPS="$group"
|
||||
else
|
||||
CUPS_SYSTEM_GROUPS="$CUPS_SYSTEM_GROUPS $group"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if test "x$CUPS_SYSTEM_GROUPS" = x; then
|
||||
CUPS_SYSTEM_GROUPS="$GROUP_LIST"
|
||||
AC_MSG_RESULT(no groups found, using "$CUPS_SYSTEM_GROUPS")
|
||||
else
|
||||
AC_MSG_RESULT("$CUPS_SYSTEM_GROUPS")
|
||||
fi
|
||||
else
|
||||
CUPS_SYSTEM_GROUPS="$GROUP_LIST"
|
||||
AC_MSG_RESULT(no group file, using "$CUPS_SYSTEM_GROUPS")
|
||||
fi
|
||||
fi)
|
||||
|
||||
|
||||
CUPS_PRIMARY_SYSTEM_GROUP="`echo $CUPS_SYSTEM_GROUPS | awk '{print $1}'`"
|
||||
|
||||
AC_SUBST(CUPS_USER)
|
||||
AC_SUBST(CUPS_GROUP)
|
||||
AC_SUBST(CUPS_SYSTEM_GROUPS)
|
||||
AC_SUBST(CUPS_PRIMARY_SYSTEM_GROUP)
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USER, "$CUPS_USER")
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GROUP, "$CUPS_GROUP")
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_GROUPS, "$CUPS_SYSTEM_GROUPS")
|
||||
|
||||
dnl Default printcap file...
|
||||
AC_ARG_WITH(printcap, [ --with-printcap set default printcap file],
|
||||
default_printcap="$withval",
|
||||
default_printcap="default")
|
||||
|
||||
if test x$default_printcap != xno; then
|
||||
if test "x$default_printcap" = "xdefault"; then
|
||||
case $uname in
|
||||
Darwin*)
|
||||
if test $uversion -ge 90; then
|
||||
CUPS_DEFAULT_PRINTCAP=""
|
||||
else
|
||||
CUPS_DEFAULT_PRINTCAP="/etc/printcap"
|
||||
fi
|
||||
;;
|
||||
SunOS*)
|
||||
CUPS_DEFAULT_PRINTCAP="/etc/printers.conf"
|
||||
;;
|
||||
*)
|
||||
CUPS_DEFAULT_PRINTCAP="/etc/printcap"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
CUPS_DEFAULT_PRINTCAP="$default_printcap"
|
||||
fi
|
||||
else
|
||||
CUPS_DEFAULT_PRINTCAP=""
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTCAP, "$CUPS_DEFAULT_PRINTCAP")
|
||||
|
||||
dnl Default MaxCopies value...
|
||||
AC_ARG_WITH(max-copies, [ --with-max-copies set default max copies value, default=auto ],
|
||||
CUPS_MAX_COPIES="$withval",
|
||||
if test "x$uname" = xDarwin; then
|
||||
CUPS_MAX_COPIES="9999"
|
||||
else
|
||||
CUPS_MAX_COPIES="100"
|
||||
fi)
|
||||
|
||||
AC_SUBST(CUPS_MAX_COPIES)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_MAX_COPIES, $CUPS_MAX_COPIES)
|
||||
|
||||
dnl Default raw printing state
|
||||
AC_ARG_ENABLE(raw_printing, [ --enable-raw-printing enable raw printing by default, default=auto])
|
||||
if test "x$enable_raw_printing" != xno; then
|
||||
AC_MSG_CHECKING(whether to enable raw printing)
|
||||
if test "x$enable_raw_printing" = xyes -o $uname = Darwin; then
|
||||
DEFAULT_RAW_PRINTING=""
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
DEFAULT_RAW_PRINTING="#"
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
else
|
||||
DEFAULT_RAW_PRINTING="#"
|
||||
fi
|
||||
AC_SUBST(DEFAULT_RAW_PRINTING)
|
||||
|
||||
dnl Default SNMP options...
|
||||
AC_ARG_WITH(snmp-address, [ --with-snmp-address set SNMP query address, default=auto ],
|
||||
if test "x$withval" = x; then
|
||||
CUPS_SNMP_ADDRESS=""
|
||||
else
|
||||
CUPS_SNMP_ADDRESS="Address $withval"
|
||||
fi,
|
||||
if test "x$uname" = xDarwin; then
|
||||
CUPS_SNMP_ADDRESS=""
|
||||
else
|
||||
CUPS_SNMP_ADDRESS="Address @LOCAL"
|
||||
fi)
|
||||
|
||||
AC_ARG_WITH(snmp-community, [ --with-snmp-community set SNMP community, default=public ],
|
||||
CUPS_SNMP_COMMUNITY="Community $withval",
|
||||
CUPS_SNMP_COMMUNITY="Community public")
|
||||
|
||||
AC_SUBST(CUPS_SNMP_ADDRESS)
|
||||
AC_SUBST(CUPS_SNMP_COMMUNITY)
|
||||
|
||||
dnl New default port definition for IPP...
|
||||
AC_ARG_WITH(ipp-port, [ --with-ipp-port set default port number for IPP ],
|
||||
DEFAULT_IPP_PORT="$withval",
|
||||
DEFAULT_IPP_PORT="631")
|
||||
|
||||
AC_SUBST(DEFAULT_IPP_PORT)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-defaults.m4 7448 2008-04-14 18:10:27Z mike $".
|
||||
dnl
|
||||
@@ -1,34 +1,20 @@
|
||||
dnl
|
||||
dnl "$Id: cups-directories.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-directories.m4 8077 2008-10-23 15:40:14Z mike $"
|
||||
dnl
|
||||
dnl Directory stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_PREFIX_DEFAULT(/)
|
||||
|
||||
AC_ARG_WITH(fontpath, [ --with-fontpath set font path for pstoraster],fontpath="$withval",fontpath="")
|
||||
AC_ARG_WITH(docdir, [ --with-docdir set path for documentation],docdir="$withval",docdir="")
|
||||
AC_ARG_WITH(logdir, [ --with-logdir set path for log files],logdir="$withval",logdir="")
|
||||
AC_ARG_WITH(rcdir, [ --with-rcdir set path for rc scripts],rcdir="$withval",rcdir="")
|
||||
|
||||
dnl Fix "prefix" variable if it hasn't been specified...
|
||||
if test "$prefix" = "NONE"; then
|
||||
prefix="/"
|
||||
@@ -43,11 +29,34 @@ if test "$exec_prefix" = "NONE"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Fix "bindir" variable...
|
||||
if test "$bindir" = "\${exec_prefix}/bin"; then
|
||||
bindir="$exec_prefix/bin"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_BINDIR, "$bindir")
|
||||
|
||||
dnl Fix "sbindir" variable...
|
||||
if test "$sbindir" = "\${exec_prefix}/sbin"; then
|
||||
sbindir="$exec_prefix/sbin"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_SBINDIR, "$sbindir")
|
||||
|
||||
dnl Fix "sharedstatedir" variable if it hasn't been specified...
|
||||
if test "$sharedstatedir" = "\${prefix}/com" -a "$prefix" = "/"; then
|
||||
sharedstatedir="/usr/com"
|
||||
fi
|
||||
|
||||
dnl Fix "datarootdir" variable if it hasn't been specified...
|
||||
if test "$datarootdir" = "\${prefix}/share"; then
|
||||
if test "$prefix" = "/"; then
|
||||
datarootdir="/usr/share"
|
||||
else
|
||||
datarootdir="$prefix/share"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Fix "datadir" variable if it hasn't been specified...
|
||||
if test "$datadir" = "\${prefix}/share"; then
|
||||
if test "$prefix" = "/"; then
|
||||
@@ -55,6 +64,8 @@ if test "$datadir" = "\${prefix}/share"; then
|
||||
else
|
||||
datadir="$prefix/share"
|
||||
fi
|
||||
elif test "$datadir" = "\${datarootdir}"; then
|
||||
datadir="$datarootdir"
|
||||
fi
|
||||
|
||||
dnl Fix "includedir" variable if it hasn't been specified...
|
||||
@@ -65,7 +76,11 @@ fi
|
||||
dnl Fix "localstatedir" variable if it hasn't been specified...
|
||||
if test "$localstatedir" = "\${prefix}/var"; then
|
||||
if test "$prefix" = "/"; then
|
||||
localstatedir="/var"
|
||||
if test "$uname" = Darwin; then
|
||||
localstatedir="/private/var"
|
||||
else
|
||||
localstatedir="/var"
|
||||
fi
|
||||
else
|
||||
localstatedir="$prefix/var"
|
||||
fi
|
||||
@@ -74,45 +89,78 @@ fi
|
||||
dnl Fix "sysconfdir" variable if it hasn't been specified...
|
||||
if test "$sysconfdir" = "\${prefix}/etc"; then
|
||||
if test "$prefix" = "/"; then
|
||||
sysconfdir="/etc"
|
||||
if test "$uname" = Darwin; then
|
||||
sysconfdir="/private/etc"
|
||||
else
|
||||
sysconfdir="/etc"
|
||||
fi
|
||||
else
|
||||
sysconfdir="$prefix/etc"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Fix "libdir" variable for IRIX 6.x...
|
||||
dnl Fix "libdir" variable...
|
||||
if test "$libdir" = "\${exec_prefix}/lib"; then
|
||||
libdir="$exec_prefix/lib"
|
||||
fi
|
||||
|
||||
if test "$uname" = "IRIX" -a $uversion -ge 62; then
|
||||
libdir="$exec_prefix/lib32"
|
||||
fi
|
||||
|
||||
dnl Fix "fontpath" variable...
|
||||
if test "x$fontpath" = "x"; then
|
||||
fontpath="$datadir/cups/fonts"
|
||||
case "$uname" in
|
||||
IRIX*)
|
||||
libdir="$exec_prefix/lib32"
|
||||
;;
|
||||
Linux*)
|
||||
if test -d /usr/lib64; then
|
||||
libdir="$exec_prefix/lib64"
|
||||
fi
|
||||
;;
|
||||
HP-UX*)
|
||||
if test -d /usr/lib/hpux32; then
|
||||
libdir="$exec_prefix/lib/hpux32"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
dnl Setup init.d locations...
|
||||
AC_ARG_WITH(rcdir, [ --with-rcdir set path for rc scripts],rcdir="$withval",rcdir="")
|
||||
AC_ARG_WITH(rclevels, [ --with-rclevels set run levels for rc scripts],rclevels="$withval",rclevels="2 3 5")
|
||||
AC_ARG_WITH(rcstart, [ --with-rcstart set start number for rc scripts],rcstart="$withval",rcstart="99")
|
||||
AC_ARG_WITH(rcstop, [ --with-rcstop set stop number for rc scripts],rcstop="$withval",rcstop="00")
|
||||
|
||||
INITDIR=""
|
||||
INITDDIR=""
|
||||
RCLEVELS="$rclevels"
|
||||
RCSTART="$rcstart"
|
||||
RCSTOP="$rcstop"
|
||||
|
||||
if test x$rcdir = x; then
|
||||
case "$uname" in
|
||||
FreeBSD* | OpenBSD*)
|
||||
# FreeBSD and OpenBSD
|
||||
INITDIR=""
|
||||
INITDDIR=""
|
||||
;;
|
||||
|
||||
NetBSD*)
|
||||
# NetBSD
|
||||
INITDIR=""
|
||||
INITDDIR="/etc/rc.d"
|
||||
AIX*)
|
||||
INITDIR="/etc/rc.d"
|
||||
;;
|
||||
|
||||
Darwin*)
|
||||
# Darwin and MacOS X...
|
||||
INITDIR=""
|
||||
INITDDIR="/System/Library/StartupItems/PrintingServices"
|
||||
if test -x /sbin/launchd; then
|
||||
INITDDIR="/System/Library/LaunchDaemons"
|
||||
else
|
||||
INITDDIR="/System/Library/StartupItems/PrintingServices"
|
||||
fi
|
||||
;;
|
||||
|
||||
FreeBSD* | OpenBSD* | MirBSD* | ekkoBSD*)
|
||||
# FreeBSD and OpenBSD
|
||||
;;
|
||||
|
||||
HP-UX*)
|
||||
INITDIR="/sbin"
|
||||
RCLEVELS="2"
|
||||
RCSTART="380"
|
||||
RCSTOP="620"
|
||||
;;
|
||||
|
||||
IRIX*)
|
||||
# IRIX
|
||||
INITDIR="/etc"
|
||||
RCSTART="60"
|
||||
RCSTOP="25"
|
||||
;;
|
||||
|
||||
Linux | GNU)
|
||||
@@ -120,108 +168,115 @@ if test x$rcdir = x; then
|
||||
if test -d /sbin/init.d; then
|
||||
# SuSE
|
||||
INITDIR="/sbin/init.d"
|
||||
INITDDIR=".."
|
||||
else
|
||||
if test -d /etc/rc.d; then
|
||||
# RedHat
|
||||
INITDIR="/etc/rc.d"
|
||||
INITDDIR="../init.d"
|
||||
else
|
||||
if test -d /etc/init.d; then
|
||||
# Others
|
||||
INITDIR="/etc"
|
||||
INITDDIR="../init.d"
|
||||
else
|
||||
# RedHat
|
||||
INITDIR="/etc/rc.d"
|
||||
fi
|
||||
fi
|
||||
RCSTART="81"
|
||||
RCSTOP="36"
|
||||
;;
|
||||
|
||||
OSF1* | HP-UX*)
|
||||
NetBSD*)
|
||||
# NetBSD
|
||||
INITDDIR="/etc/rc.d"
|
||||
;;
|
||||
|
||||
OSF1*)
|
||||
INITDIR="/sbin"
|
||||
INITDDIR="../init.d"
|
||||
;;
|
||||
|
||||
AIX*)
|
||||
INITDIR="/etc/rc.d"
|
||||
INITDDIR=".."
|
||||
SunOS*)
|
||||
# Solaris
|
||||
INITDIR="/etc"
|
||||
RCSTART="81"
|
||||
;;
|
||||
|
||||
*)
|
||||
INITDIR="/etc"
|
||||
INITDDIR="../init.d"
|
||||
;;
|
||||
|
||||
esac
|
||||
else
|
||||
INITDIR=""
|
||||
INITDDIR="$rcdir"
|
||||
elif test "x$rcdir" != xno; then
|
||||
if test "x$rclevels" = x; then
|
||||
INITDDIR="$rcdir"
|
||||
else
|
||||
INITDIR="$rcdir"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(INITDIR)
|
||||
AC_SUBST(INITDDIR)
|
||||
AC_SUBST(RCLEVELS)
|
||||
AC_SUBST(RCSTART)
|
||||
AC_SUBST(RCSTOP)
|
||||
|
||||
dnl Setup default locations...
|
||||
CUPS_SERVERROOT="$sysconfdir/cups"
|
||||
CUPS_REQUESTS="$localstatedir/spool/cups"
|
||||
dnl Xinetd support...
|
||||
AC_ARG_WITH(xinetd, [ --with-xinetd set path for xinetd config files],XINETD="$withval",XINETD="")
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups")
|
||||
AC_DEFINE_UNQUOTED(CUPS_REQUESTS, "$localstatedir/spool/cups")
|
||||
|
||||
if test x$logdir = x; then
|
||||
CUPS_LOGDIR="$localstatedir/log/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$localstatedir/log/cups")
|
||||
else
|
||||
CUPS_LOGDIR="$logdir"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$logdir")
|
||||
if test "x$XINETD" = x -a ! -x /sbin/launchd; then
|
||||
for dir in /private/etc/xinetd.d /etc/xinetd.d /usr/local/etc/xinetd.d; do
|
||||
if test -d $dir; then
|
||||
XINETD="$dir"
|
||||
break
|
||||
fi
|
||||
done
|
||||
elif test "x$XINETD" = xno; then
|
||||
XINETD=""
|
||||
fi
|
||||
|
||||
dnl See what directory to put server executables...
|
||||
case "$uname" in
|
||||
*BSD* | Darwin*)
|
||||
# *BSD and Darwin (MacOS X)
|
||||
INSTALL_SYSV=""
|
||||
CUPS_SERVERBIN="$exec_prefix/libexec/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$exec_prefix/libexec/cups")
|
||||
;;
|
||||
*)
|
||||
# All others
|
||||
INSTALL_SYSV="install-sysv"
|
||||
CUPS_SERVERBIN="$libdir/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$libdir/cups")
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(XINETD)
|
||||
|
||||
AC_SUBST(INSTALL_SYSV)
|
||||
AC_SUBST(CUPS_SERVERROOT)
|
||||
AC_SUBST(CUPS_SERVERBIN)
|
||||
AC_SUBST(CUPS_LOGDIR)
|
||||
AC_SUBST(CUPS_REQUESTS)
|
||||
dnl Setup default locations...
|
||||
# Cache data...
|
||||
AC_ARG_WITH(cachedir, [ --with-cachedir set path for cache files],cachedir="$withval",cachedir="")
|
||||
|
||||
dnl Set the CUPS_LOCALE directory...
|
||||
case "$uname" in
|
||||
Linux | GNU | *BSD* | Darwin*)
|
||||
CUPS_LOCALEDIR="$datadir/locale"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$datadir/locale")
|
||||
;;
|
||||
if test x$cachedir = x; then
|
||||
if test "x$uname" = xDarwin; then
|
||||
CUPS_CACHEDIR="$localstatedir/spool/cups/cache"
|
||||
else
|
||||
CUPS_CACHEDIR="$localstatedir/cache/cups"
|
||||
fi
|
||||
else
|
||||
CUPS_CACHEDIR="$cachedir"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(CUPS_CACHEDIR, "$CUPS_CACHEDIR")
|
||||
AC_SUBST(CUPS_CACHEDIR)
|
||||
|
||||
OSF1* | AIX*)
|
||||
CUPS_LOCALEDIR="$exec_prefix/lib/nls/msg"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$exec_prefix/lib/nls/msg")
|
||||
;;
|
||||
|
||||
*)
|
||||
# This is the standard System V location...
|
||||
CUPS_LOCALEDIR="$exec_prefix/lib/locale"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$exec_prefix/lib/locale")
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(CUPS_LOCALEDIR)
|
||||
|
||||
dnl Set the CUPS_DATADIR directory...
|
||||
# Data files
|
||||
CUPS_DATADIR="$datadir/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$datadir/cups")
|
||||
AC_SUBST(CUPS_DATADIR)
|
||||
|
||||
dnl Set the CUPS_DOCROOT directory...
|
||||
# Icon directory
|
||||
AC_ARG_WITH(icondir, [ --with-icondir set path for application icons],icondir="$withval",icondir="")
|
||||
|
||||
if test "x$icondir" = x -a -d /usr/share/icons; then
|
||||
ICONDIR="/usr/share/icons"
|
||||
else
|
||||
ICONDIR="$icondir"
|
||||
fi
|
||||
|
||||
AC_SUBST(ICONDIR)
|
||||
|
||||
# Menu directory
|
||||
AC_ARG_WITH(menudir, [ --with-menudir set path for application menus],menudir="$withval",menudir="")
|
||||
|
||||
if test "x$menudir" = x -a -d /usr/share/applications; then
|
||||
MENUDIR="/usr/share/applications"
|
||||
else
|
||||
MENUDIR="$menudir"
|
||||
fi
|
||||
|
||||
AC_SUBST(MENUDIR)
|
||||
|
||||
# Documentation files
|
||||
AC_ARG_WITH(docdir, [ --with-docdir set path for documentation],docdir="$withval",docdir="")
|
||||
|
||||
if test x$docdir = x; then
|
||||
CUPS_DOCROOT="$datadir/doc/cups"
|
||||
docdir="$datadir/doc/cups"
|
||||
@@ -232,11 +287,87 @@ fi
|
||||
AC_DEFINE_UNQUOTED(CUPS_DOCROOT, "$docdir")
|
||||
AC_SUBST(CUPS_DOCROOT)
|
||||
|
||||
dnl Set the CUPS_FONTPATH directory...
|
||||
CUPS_FONTPATH="$fontpath"
|
||||
# Fonts
|
||||
AC_ARG_WITH(fontpath, [ --with-fontpath set font path for pstoraster],fontpath="$withval",fontpath="")
|
||||
|
||||
if test "x$fontpath" = "x"; then
|
||||
CUPS_FONTPATH="$datadir/cups/fonts"
|
||||
else
|
||||
CUPS_FONTPATH="$fontpath"
|
||||
fi
|
||||
|
||||
AC_SUBST(CUPS_FONTPATH)
|
||||
AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$fontpath")
|
||||
AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH")
|
||||
|
||||
# Locale data (initial assignment allows us not to require autoconf 2.60)
|
||||
localedir="${localedir:=}"
|
||||
if test "$localedir" = "\${datarootdir}/locale" -o "$localedir" = ""; then
|
||||
case "$uname" in
|
||||
Linux | GNU | *BSD* | Darwin*)
|
||||
CUPS_LOCALEDIR="$datadir/locale"
|
||||
;;
|
||||
|
||||
OSF1* | AIX*)
|
||||
CUPS_LOCALEDIR="$exec_prefix/lib/nls/msg"
|
||||
;;
|
||||
|
||||
*)
|
||||
# This is the standard System V location...
|
||||
CUPS_LOCALEDIR="$exec_prefix/lib/locale"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
CUPS_LOCALEDIR="$localedir"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$CUPS_LOCALEDIR")
|
||||
AC_SUBST(CUPS_LOCALEDIR)
|
||||
|
||||
# Log files...
|
||||
AC_ARG_WITH(logdir, [ --with-logdir set path for log files],logdir="$withval",logdir="")
|
||||
|
||||
if test x$logdir = x; then
|
||||
CUPS_LOGDIR="$localstatedir/log/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$localstatedir/log/cups")
|
||||
else
|
||||
CUPS_LOGDIR="$logdir"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$CUPS_LOGDIR")
|
||||
AC_SUBST(CUPS_LOGDIR)
|
||||
|
||||
# Longer-term spool data
|
||||
CUPS_REQUESTS="$localstatedir/spool/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_REQUESTS, "$localstatedir/spool/cups")
|
||||
AC_SUBST(CUPS_REQUESTS)
|
||||
|
||||
# Server executables...
|
||||
case "$uname" in
|
||||
*BSD* | Darwin*)
|
||||
# *BSD and Darwin (MacOS X)
|
||||
INSTALL_SYSV=""
|
||||
CUPS_SERVERBIN="$exec_prefix/libexec/cups"
|
||||
;;
|
||||
*)
|
||||
# All others
|
||||
INSTALL_SYSV="install-sysv"
|
||||
CUPS_SERVERBIN="$exec_prefix/lib/cups"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN")
|
||||
AC_SUBST(CUPS_SERVERBIN)
|
||||
AC_SUBST(INSTALL_SYSV)
|
||||
|
||||
# Configuration files
|
||||
CUPS_SERVERROOT="$sysconfdir/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups")
|
||||
AC_SUBST(CUPS_SERVERROOT)
|
||||
|
||||
# Transient run-time state
|
||||
CUPS_STATEDIR="$localstatedir/run/cups"
|
||||
AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups")
|
||||
AC_SUBST(CUPS_STATEDIR)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-directories.m4 4358 2004-08-11 14:39:26Z mike $".
|
||||
dnl End of "$Id: cups-directories.m4 8077 2008-10-23 15:40:14Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
dnl
|
||||
dnl "$Id$"
|
||||
dnl
|
||||
dnl DNS Service Discovery (aka Bonjour) stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl http://www.dns-sd.org
|
||||
dnl http://www.multicastdns.org/
|
||||
dnl http://developer.apple.com/networking/bonjour/
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(dnssd, [ --enable-dnssd turn on DNS Service Discovery support, default=yes])
|
||||
AC_ARG_WITH(dnssd-libs, [ --with-dnssd-libs set directory for DNS Service Discovery library],
|
||||
LDFLAGS="-L$withval $LDFLAGS"
|
||||
DSOFLAGS="-L$withval $DSOFLAGS",)
|
||||
AC_ARG_WITH(dnssd-includes, [ --with-dnssd-includes set directory for DNS Service Discovery includes],
|
||||
CFLAGS="-I$withval $CFLAGS"
|
||||
CXXFLAGS="-I$withval $CXXFLAGS"
|
||||
CPPFLAGS="-I$withval $CPPFLAGS",)
|
||||
|
||||
DNSSDLIBS=""
|
||||
|
||||
if test x$enable_dnssd != xno; then
|
||||
AC_CHECK_HEADER(dns_sd.h, [
|
||||
case "$uname" in
|
||||
Darwin*)
|
||||
# Darwin and MacOS X...
|
||||
DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration"
|
||||
AC_DEFINE(HAVE_DNSSD)
|
||||
AC_DEFINE(HAVE_COREFOUNDATION)
|
||||
AC_DEFINE(HAVE_SYSTEMCONFIGURATION)
|
||||
;;
|
||||
*)
|
||||
# All others...
|
||||
AC_CHECK_LIB(dns_sd,DNSServiceProcessResult,
|
||||
AC_DEFINE(HAVE_DNSSD)
|
||||
DNSSDLIBS="-ldns_sd")
|
||||
;;
|
||||
esac
|
||||
])
|
||||
fi
|
||||
|
||||
AC_SUBST(DNSSDLIBS)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id$".
|
||||
dnl
|
||||
@@ -0,0 +1,123 @@
|
||||
dnl
|
||||
dnl "$Id$"
|
||||
dnl
|
||||
dnl GSSAPI/Kerberos library detection.
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 2006-2007 by Easy Software Products.
|
||||
dnl
|
||||
dnl This file contains Kerberos support code, copyright 2006 by
|
||||
dnl Jelmer Vernooij.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(gssapi, [ --enable-gssapi turn on GSSAPI support, default=yes])
|
||||
|
||||
LIBGSSAPI=""
|
||||
|
||||
if test x$enable_gssapi != xno; then
|
||||
AC_PATH_PROG(KRB5CONFIG, krb5-config)
|
||||
if test "x$KRB5CONFIG" != x; then
|
||||
case "$uname" in
|
||||
Darwin)
|
||||
# Mac OS X weak-links to the Kerberos framework...
|
||||
LIBGSSAPI="-weak_framework Kerberos"
|
||||
;;
|
||||
SunOS*)
|
||||
# Solaris has a non-standard krb5-config, don't use it!
|
||||
AC_CHECK_LIB(gss, gss_display_status,
|
||||
AC_DEFINE(HAVE_GSSAPI, 1, [Whether GSSAPI is available])
|
||||
CFLAGS="`$KRB5CONFIG --cflags` $CFLAGS"
|
||||
CPPFLAGS="`$KRB5CONFIG --cflags` $CPPFLAGS"
|
||||
LIBGSSAPI="-lgss `$KRB5CONFIG --libs`")
|
||||
;;
|
||||
*)
|
||||
# Other platforms just ask for GSSAPI
|
||||
CFLAGS="`$KRB5CONFIG --cflags gssapi` $CFLAGS"
|
||||
CPPFLAGS="`$KRB5CONFIG --cflags gssapi` $CPPFLAGS"
|
||||
LIBGSSAPI="`$KRB5CONFIG --libs gssapi`"
|
||||
;;
|
||||
esac
|
||||
AC_DEFINE(HAVE_GSSAPI, 1, [Whether GSSAPI is available])
|
||||
else
|
||||
# Check for vendor-specific implementations...
|
||||
case "$uname" in
|
||||
HP-UX*)
|
||||
AC_CHECK_LIB(gss, gss_display_status,
|
||||
AC_DEFINE(HAVE_GSSAPI, 1, [Whether GSSAPI is available])
|
||||
LIBGSSAPI="-lgss -lgssapi_krb5")
|
||||
;;
|
||||
SunOS*)
|
||||
AC_CHECK_LIB(gss, gss_display_status,
|
||||
AC_DEFINE(HAVE_GSSAPI, 1, [Whether GSSAPI is available])
|
||||
LIBGSSAPI="-lgss")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test "x$LIBGSSAPI" != x; then
|
||||
AC_CHECK_HEADER(krb5.h, AC_DEFINE(HAVE_KRB5_H))
|
||||
AC_CHECK_HEADER(gssapi.h, AC_DEFINE(HAVE_GSSAPI_H))
|
||||
AC_CHECK_HEADER(gssapi/gssapi.h, AC_DEFINE(HAVE_GSSAPI_GSSAPI_H))
|
||||
AC_CHECK_HEADER(gssapi/gssapi_generic.h, AC_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H))
|
||||
AC_CHECK_HEADER(gssapi/gssapi_krb5.h, AC_DEFINE(HAVE_GSSAPI_GSSAPI_KRB5_H))
|
||||
|
||||
SAVELIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBGSSAPI"
|
||||
|
||||
AC_CHECK_FUNC(gsskrb5_register_acceptor_identity,
|
||||
AC_DEFINE(HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY))
|
||||
AC_CHECK_FUNC(krb5_cc_new_unique, AC_DEFINE(HAVE_KRB5_CC_NEW_UNIQUE))
|
||||
|
||||
AC_MSG_CHECKING(for GSS_C_NT_HOSTBASED_SERVICE)
|
||||
if test $ac_cv_header_gssapi_gssapi_h = yes; then
|
||||
AC_TRY_COMPILE([ #include <gssapi/gssapi.h> ],
|
||||
[ gss_OID foo = GSS_C_NT_HOSTBASED_SERVICE; ],
|
||||
AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
else
|
||||
AC_TRY_COMPILE([ #include <gssapi.h> ],
|
||||
[ gss_OID foo = GSS_C_NT_HOSTBASED_SERVICE; ],
|
||||
AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE)
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
fi
|
||||
|
||||
LIBS="$SAVELIBS"
|
||||
|
||||
AC_MSG_CHECKING(for Heimdal Kerberos)
|
||||
AC_TRY_COMPILE([ #include <krb5.h> ],
|
||||
[ char *tmp = heimdal_version; ],
|
||||
AC_DEFINE(HAVE_HEIMDAL)
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Default GSS service name...
|
||||
AC_ARG_WITH(gssservicename, [ --with-gssservicename set default gss service name],
|
||||
default_gssservicename="$withval",
|
||||
default_gssservicename="default")
|
||||
|
||||
if test x$default_gssservicename != xno; then
|
||||
if test "x$default_gssservicename" = "xdefault"; then
|
||||
CUPS_DEFAULT_GSSSERVICENAME="ipp"
|
||||
else
|
||||
CUPS_DEFAULT_GSSSERVICENAME="$default_gssservicename"
|
||||
fi
|
||||
else
|
||||
CUPS_DEFAULT_GSSSERVICENAME=""
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBGSSAPI)
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GSSSERVICENAME, "$CUPS_DEFAULT_GSSSERVICENAME")
|
||||
|
||||
dnl
|
||||
dnl End of "$Id$".
|
||||
dnl
|
||||
@@ -1,32 +1,39 @@
|
||||
dnl
|
||||
dnl "$Id: cups-image.m4 4213 2004-06-29 03:44:53Z mike $"
|
||||
dnl "$Id: cups-image.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl Image library stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl Image library/filter stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Save the current libraries since we don't want the image libraries
|
||||
dnl included with every program...
|
||||
SAVELIBS="$LIBS"
|
||||
dnl See if we want the image filters included at all...
|
||||
AC_ARG_ENABLE(image, [ --enable-image turn on image filters, default=auto])
|
||||
|
||||
IMGFILTERS=""
|
||||
if test "x$enable_image" != xno; then
|
||||
AC_MSG_CHECKING(whether to build image filters)
|
||||
if test "x$enable_image" = xyes -o $uname != Darwin; then
|
||||
IMGFILTERS="imagetops imagetoraster"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(IMGFILTERS)
|
||||
|
||||
dnl Check for image libraries...
|
||||
AC_ARG_ENABLE(jpeg, [ --enable-jpeg turn on JPEG support, default=yes])
|
||||
AC_ARG_ENABLE(png, [ --enable-png turn on PNG support, default=yes])
|
||||
AC_ARG_ENABLE(tiff, [ --enable-tiff turn on TIFF support, default=yes])
|
||||
|
||||
LIBJPEG=""
|
||||
LIBPNG=""
|
||||
LIBTIFF=""
|
||||
@@ -37,30 +44,50 @@ AC_SUBST(LIBPNG)
|
||||
AC_SUBST(LIBTIFF)
|
||||
AC_SUBST(LIBZ)
|
||||
|
||||
AC_CHECK_HEADER(jpeglib.h,
|
||||
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
|
||||
AC_DEFINE(HAVE_LIBJPEG)
|
||||
LIBJPEG="-ljpeg"
|
||||
LIBS="$LIBS -ljpeg"))
|
||||
dnl Image libraries use math library functions...
|
||||
AC_SEARCH_LIBS(pow, m)
|
||||
|
||||
dnl Save the current libraries since we don't want the image libraries
|
||||
dnl included with every program...
|
||||
SAVELIBS="$LIBS"
|
||||
|
||||
dnl JPEG library...
|
||||
if test x$enable_jpeg != xno; then
|
||||
AC_CHECK_HEADER(jpeglib.h,
|
||||
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
|
||||
AC_DEFINE(HAVE_LIBJPEG)
|
||||
LIBJPEG="-ljpeg"
|
||||
LIBS="$LIBS -ljpeg"))
|
||||
else
|
||||
AC_MSG_NOTICE([JPEG support disabled with --disable-jpeg.])
|
||||
fi
|
||||
|
||||
dnl ZLIB library...
|
||||
AC_CHECK_HEADER(zlib.h,
|
||||
AC_CHECK_LIB(z, gzgets,
|
||||
AC_DEFINE(HAVE_LIBZ)
|
||||
LIBZ="-lz"
|
||||
LIBS="$LIBS -lz"))
|
||||
|
||||
dnl PNG library uses math library functions...
|
||||
AC_CHECK_LIB(m, pow)
|
||||
dnl PNG library...
|
||||
if test x$enable_png != xno; then
|
||||
AC_CHECK_HEADER(png.h,
|
||||
AC_CHECK_LIB(png, png_create_read_struct,
|
||||
AC_DEFINE(HAVE_LIBPNG)
|
||||
LIBPNG="-lpng"))
|
||||
else
|
||||
AC_MSG_NOTICE([PNG support disabled with --disable-png.])
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(png.h,
|
||||
AC_CHECK_LIB(png, png_set_tRNS_to_alpha,
|
||||
AC_DEFINE(HAVE_LIBPNG)
|
||||
LIBPNG="-lpng -lm"))
|
||||
|
||||
AC_CHECK_HEADER(tiff.h,
|
||||
AC_CHECK_LIB(tiff, TIFFReadScanline,
|
||||
dnl TIFF library...
|
||||
if test x$enable_tiff != xno; then
|
||||
AC_CHECK_HEADER(tiff.h,
|
||||
AC_CHECK_LIB(tiff, TIFFReadScanline,
|
||||
AC_DEFINE(HAVE_LIBTIFF)
|
||||
LIBTIFF="-ltiff"))
|
||||
else
|
||||
AC_MSG_NOTICE([TIFF support disabled with --disable-tiff.])
|
||||
fi
|
||||
|
||||
dnl Restore original LIBS settings...
|
||||
LIBS="$SAVELIBS"
|
||||
@@ -78,5 +105,5 @@ AC_SUBST(EXPORT_LIBZ)
|
||||
AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-image.m4 4213 2004-06-29 03:44:53Z mike $".
|
||||
dnl End of "$Id: cups-image.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
dnl
|
||||
dnl "$Id: cups-largefile.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl Large file support stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Check for largefile support...
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl Define largefile options as needed...
|
||||
LARGEFILE=""
|
||||
if test x$enable_largefile != xno; then
|
||||
LARGEFILE="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
|
||||
|
||||
if test x$ac_cv_sys_large_files = x1; then
|
||||
LARGEFILE="$LARGEFILE -D_LARGE_FILES"
|
||||
fi
|
||||
|
||||
if test x$ac_cv_sys_file_offset_bits = x64; then
|
||||
LARGEFILE="$LARGEFILE -D_FILE_OFFSET_BITS=64"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(LARGEFILE)
|
||||
|
||||
dnl Check for "long long" support...
|
||||
AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
|
||||
[if test "$GCC" = yes; then
|
||||
ac_cv_c_long_long=yes
|
||||
else
|
||||
AC_TRY_COMPILE(,[long long int i;],
|
||||
ac_cv_c_long_long=yes,
|
||||
ac_cv_c_long_long=no)
|
||||
fi])
|
||||
|
||||
if test $ac_cv_c_long_long = yes; then
|
||||
AC_DEFINE(HAVE_LONG_LONG)
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNC(strtoll, AC_DEFINE(HAVE_STRTOLL))
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-largefile.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
@@ -0,0 +1,44 @@
|
||||
dnl
|
||||
dnl "$Id: cups-launchd.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl launchd stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
|
||||
AC_ARG_ENABLE(launchd, [ --enable-launchd turn on launchd support, default=yes])
|
||||
|
||||
DEFAULT_LAUNCHD_CONF=""
|
||||
LAUNCHDLIBS=""
|
||||
|
||||
if test x$enable_launchd != xno; then
|
||||
AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
|
||||
AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
|
||||
|
||||
case "$uname" in
|
||||
Darwin*)
|
||||
# Darwin, MacOS X
|
||||
DEFAULT_LAUNCHD_CONF="/System/Library/LaunchDaemons/org.cups.cupsd.plist"
|
||||
# liblaunch is already part of libSystem
|
||||
;;
|
||||
*)
|
||||
# All others; this test will need to be updated
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LAUNCHD_CONF, "$DEFAULT_LAUNCHD_CONF")
|
||||
AC_SUBST(DEFAULT_LAUNCHD_CONF)
|
||||
AC_SUBST(LAUNCHDLIBS)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-launchd.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
@@ -0,0 +1,41 @@
|
||||
dnl
|
||||
dnl "$Id: cups-ldap.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl LDAP configuration stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 2003-2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(ldap, [ --enable-ldap turn on LDAP support, default=yes])
|
||||
AC_ARG_WITH(openldap-libs, [ --with-openldap-libs set directory for OpenLDAP library],
|
||||
LDFLAGS="-L$withval $LDFLAGS"
|
||||
DSOFLAGS="-L$withval $DSOFLAGS",)
|
||||
AC_ARG_WITH(openldap-includes, [ --with-openldap-includes
|
||||
set directory for OpenLDAP includes],
|
||||
CFLAGS="-I$withval $CFLAGS"
|
||||
CXXFLAGS="-I$withval $CXXFLAGS"
|
||||
CPPFLAGS="-I$withval $CPPFLAGS",)
|
||||
|
||||
LIBLDAP=""
|
||||
|
||||
if test x$enable_ldap != xno; then
|
||||
AC_CHECK_HEADER(ldap.h,
|
||||
AC_CHECK_LIB(ldap, ldap_initialize,
|
||||
AC_DEFINE(HAVE_LDAP)
|
||||
AC_DEFINE(HAVE_OPENLDAP)
|
||||
LIBLDAP="-lldap"))
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBLDAP)
|
||||
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-ldap.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
@@ -1,25 +1,16 @@
|
||||
dnl
|
||||
dnl "$Id: cups-libtool.m4 4213 2004-06-29 03:44:53Z mike $"
|
||||
dnl "$Id: cups-libtool.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl Libtool stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(libtool_unsupported, [ --enable-libtool-unsupported=LIBTOOL_PATH
|
||||
@@ -45,5 +36,5 @@ if test x$LIBTOOL != x; then
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-libtool.m4 4213 2004-06-29 03:44:53Z mike $".
|
||||
dnl End of "$Id: cups-libtool.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
dnl
|
||||
dnl "$Id: cups-manpages.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-manpages.m4 8231 2009-01-12 19:17:21Z mike $"
|
||||
dnl
|
||||
dnl Manpage stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Fix "mandir" variable...
|
||||
if test "$mandir" = "\${datarootdir}/man" -a "$prefix" = "/"; then
|
||||
# New GNU "standards" break previous ones, so make sure we use
|
||||
# the right default location for the operating system...
|
||||
mandir="\${prefix}/man"
|
||||
fi
|
||||
|
||||
if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/"; then
|
||||
case "$uname" in
|
||||
Darwin* | Linux | GNU | *BSD* | AIX*)
|
||||
@@ -54,51 +51,46 @@ AC_SUBST(PMANDIR)
|
||||
|
||||
dnl Setup manpage extensions...
|
||||
case "$uname" in
|
||||
*BSD* | Darwin*)
|
||||
# *BSD
|
||||
CAT1EXT=0
|
||||
CAT3EXT=0
|
||||
CAT5EXT=0
|
||||
CAT8EXT=0
|
||||
MAN8EXT=8
|
||||
MAN8DIR=8
|
||||
;;
|
||||
IRIX*)
|
||||
# SGI IRIX
|
||||
CAT1EXT=z
|
||||
CAT3EXT=z
|
||||
CAT5EXT=z
|
||||
CAT8EXT=z
|
||||
MAN1EXT=1
|
||||
MAN5EXT=5
|
||||
MAN7EXT=7
|
||||
MAN8EXT=1m
|
||||
MAN8DIR=1
|
||||
;;
|
||||
SunOS* | HP-UX*)
|
||||
# Solaris and HP-UX
|
||||
CAT1EXT=1
|
||||
CAT3EXT=3
|
||||
CAT5EXT=5
|
||||
CAT8EXT=1m
|
||||
MAN1EXT=1
|
||||
MAN5EXT=5
|
||||
MAN7EXT=7
|
||||
MAN8EXT=1m
|
||||
MAN8DIR=1m
|
||||
;;
|
||||
Linux* | GNU* | Darwin*)
|
||||
# Linux, GNU Hurd, and Mac OS X
|
||||
MAN1EXT=1.gz
|
||||
MAN5EXT=5.gz
|
||||
MAN7EXT=7.gz
|
||||
MAN8EXT=8.gz
|
||||
MAN8DIR=8
|
||||
;;
|
||||
*)
|
||||
# All others
|
||||
CAT1EXT=1
|
||||
CAT3EXT=3
|
||||
CAT5EXT=5
|
||||
CAT8EXT=8
|
||||
MAN1EXT=1
|
||||
MAN5EXT=5
|
||||
MAN7EXT=7
|
||||
MAN8EXT=8
|
||||
MAN8DIR=8
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(CAT1EXT)
|
||||
AC_SUBST(CAT3EXT)
|
||||
AC_SUBST(CAT5EXT)
|
||||
AC_SUBST(CAT8EXT)
|
||||
AC_SUBST(MAN1EXT)
|
||||
AC_SUBST(MAN5EXT)
|
||||
AC_SUBST(MAN7EXT)
|
||||
AC_SUBST(MAN8EXT)
|
||||
AC_SUBST(MAN8DIR)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-manpages.m4 4358 2004-08-11 14:39:26Z mike $".
|
||||
dnl End of "$Id: cups-manpages.m4 8231 2009-01-12 19:17:21Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -1,59 +1,74 @@
|
||||
dnl
|
||||
dnl "$Id: cups-network.m4 4213 2004-06-29 03:44:53Z mike $"
|
||||
dnl "$Id: cups-network.m4 7919 2008-09-09 22:03:27Z mike $"
|
||||
dnl
|
||||
dnl Networking stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007-2008 by Apple Inc.
|
||||
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
NETLIBS=""
|
||||
AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H))
|
||||
AC_SEARCH_LIBS(socket, socket)
|
||||
AC_SEARCH_LIBS(gethostbyaddr, nsl)
|
||||
AC_SEARCH_LIBS(getifaddrs, nsl, AC_DEFINE(HAVE_GETIFADDRS))
|
||||
AC_SEARCH_LIBS(hstrerror, nsl socket resolv, AC_DEFINE(HAVE_HSTRERROR))
|
||||
AC_SEARCH_LIBS(rresvport_af, nsl, AC_DEFINE(HAVE_RRESVPORT_AF))
|
||||
AC_SEARCH_LIBS(__res_init, resolv bind, AC_DEFINE(HAVE_RES_INIT),
|
||||
AC_SEARCH_LIBS(res_9_init, resolv bind, AC_DEFINE(HAVE_RES_INIT),
|
||||
AC_SEARCH_LIBS(res_init, resolv bind, AC_DEFINE(HAVE_RES_INIT))))
|
||||
|
||||
if test "$uname" != "IRIX"; then
|
||||
AC_CHECK_LIB(socket,socket,NETLIBS="-lsocket")
|
||||
AC_CHECK_LIB(nsl,gethostbyaddr,NETLIBS="$NETLIBS -lnsl")
|
||||
# Tru64 5.1b leaks file descriptors with these functions; disable until
|
||||
# we can come up with a test for this...
|
||||
if test "$uname" != "OSF1"; then
|
||||
AC_SEARCH_LIBS(getaddrinfo, nsl, AC_DEFINE(HAVE_GETADDRINFO))
|
||||
AC_SEARCH_LIBS(getnameinfo, nsl, AC_DEFINE(HAVE_GETNAMEINFO))
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(rresvport getifaddrs hstrerror)
|
||||
AC_CHECK_MEMBER(struct sockaddr.sa_len,,, [#include <sys/socket.h>])
|
||||
AC_CHECK_HEADER(sys/sockio.h, AC_DEFINE(HAVE_SYS_SOCKIO_H))
|
||||
|
||||
AC_CHECK_MEMBER(struct sockaddr.sa_len,,,[#include <sys/socket.h>])
|
||||
AC_CHECK_HEADER(sys/sockio.h,AC_DEFINE(HAVE_SYS_SOCKIO_H))
|
||||
CUPS_DEFAULT_DOMAINSOCKET=""
|
||||
|
||||
AC_SUBST(NETLIBS)
|
||||
dnl Domain socket support...
|
||||
AC_ARG_WITH(domainsocket, [ --with-domainsocket set unix domain socket name],
|
||||
default_domainsocket="$withval",
|
||||
default_domainsocket="")
|
||||
|
||||
if test "$uname" = "SunOS"; then
|
||||
case "$uversion" in
|
||||
55* | 56*)
|
||||
maxfiles=1024
|
||||
;;
|
||||
*)
|
||||
maxfiles=4096
|
||||
;;
|
||||
esac
|
||||
if test x$enable_domainsocket != xno -a x$default_domainsocket != xno; then
|
||||
if test "x$default_domainsocket" = x; then
|
||||
case "$uname" in
|
||||
Darwin*)
|
||||
# Darwin and MaxOS X do their own thing...
|
||||
CUPS_DEFAULT_DOMAINSOCKET="$localstatedir/run/cupsd"
|
||||
;;
|
||||
*)
|
||||
# All others use FHS standard...
|
||||
CUPS_DEFAULT_DOMAINSOCKET="$CUPS_STATEDIR/cups.sock"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
CUPS_DEFAULT_DOMAINSOCKET="$default_domainsocket"
|
||||
fi
|
||||
|
||||
CUPS_LISTEN_DOMAINSOCKET="Listen $CUPS_DEFAULT_DOMAINSOCKET"
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DOMAINSOCKET, "$CUPS_DEFAULT_DOMAINSOCKET")
|
||||
else
|
||||
maxfiles=4096
|
||||
CUPS_LISTEN_DOMAINSOCKET=""
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(maxfiles, [ --with-maxfiles=N set maximum number of file descriptors for scheduler ],
|
||||
maxfiles=$withval)
|
||||
AC_SUBST(CUPS_DEFAULT_DOMAINSOCKET)
|
||||
AC_SUBST(CUPS_LISTEN_DOMAINSOCKET)
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_MAX_FDS, $maxfiles)
|
||||
AC_CHECK_HEADERS(AppleTalk/at_proto.h,AC_DEFINE(HAVE_APPLETALK_AT_PROTO_H),,
|
||||
[#include <netat/appletalk.h>])
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-network.m4 4213 2004-06-29 03:44:53Z mike $".
|
||||
dnl End of "$Id: cups-network.m4 7919 2008-09-09 22:03:27Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
dnl
|
||||
dnl "$Id: cups-openssl.m4 4213 2004-06-29 03:44:53Z mike $"
|
||||
dnl
|
||||
dnl OpenSSL/GNUTLS stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(ssl, [ --enable-ssl turn on SSL/TLS support, default=yes])
|
||||
AC_ARG_ENABLE(openssl, [ --enable-openssl use OpenSSL for SSL/TLS support, default=yes])
|
||||
AC_ARG_ENABLE(gnutls, [ --enable-gnutls use GNU TLS for SSL/TLS support, default=yes])
|
||||
AC_ARG_ENABLE(cdsassl, [ --enable-cdsassl use CDSA for SSL/TLS support, default=yes])
|
||||
AC_ARG_WITH(openssl-libs, [ --with-openssl-libs set directory for OpenSSL library],
|
||||
LDFLAGS="-L$withval $LDFLAGS"
|
||||
DSOFLAGS="-L$withval $DSOFLAGS",)
|
||||
AC_ARG_WITH(openssl-includes, [ --with-openssl-includes set directory for OpenSSL includes],
|
||||
CFLAGS="-I$withval $CFLAGS"
|
||||
CXXFLAGS="-I$withval $CXXFLAGS"
|
||||
CPPFLAGS="-I$withval $CPPFLAGS",)
|
||||
|
||||
SSLFLAGS=""
|
||||
SSLLIBS=""
|
||||
|
||||
if test x$enable_ssl != xno; then
|
||||
dnl Check for the OpenSSL library first, which has precedence over
|
||||
dnl CDSA and GNUTLS...
|
||||
if test "x${SSLLIBS}" = "x" -a "x${enable_openssl}" != "xno"; then
|
||||
AC_CHECK_HEADER(openssl/ssl.h,
|
||||
dnl Save the current libraries so the crypto stuff isn't always
|
||||
dnl included...
|
||||
SAVELIBS="$LIBS"
|
||||
|
||||
dnl Some ELF systems can't resolve all the symbols in libcrypto
|
||||
dnl if libcrypto was linked against RSAREF, and fail to link the
|
||||
dnl test program correctly, even though a correct installation
|
||||
dnl of OpenSSL exists. So we test the linking three times in
|
||||
dnl case the RSAREF libraries are needed.
|
||||
|
||||
for libcrypto in \
|
||||
"-lcrypto" \
|
||||
"-lcrypto -lrsaref" \
|
||||
"-lcrypto -lRSAglue -lrsaref"
|
||||
do
|
||||
AC_CHECK_LIB(ssl,SSL_new,
|
||||
[SSLFLAGS="-DOPENSSL_DISABLE_OLD_DES_SUPPORT"
|
||||
SSLLIBS="-lssl $libcrypto"
|
||||
AC_DEFINE(HAVE_SSL)
|
||||
AC_DEFINE(HAVE_LIBSSL)],,
|
||||
$libcrypto)
|
||||
|
||||
if test "x${SSLLIBS}" != "x"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
LIBS="$SAVELIBS")
|
||||
fi
|
||||
|
||||
dnl If OpenSSL wasn't found, look for CDSA...
|
||||
if test "x${SSLLIBS}" = "x" -a "x${enable_cdsassl}" != "xno"; then
|
||||
if test $uname = Darwin; then
|
||||
AC_CHECK_HEADER(Security/SecureTransport.h,
|
||||
[SSLLIBS="-framework CoreFoundation -framework Security"
|
||||
AC_DEFINE(HAVE_SSL)
|
||||
AC_DEFINE(HAVE_CDSASSL)])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Then look for GNU TLS...
|
||||
if test "x${SSLLIBS}" = "x" -a "x${enable_gnutls}" != "xno"; then
|
||||
AC_CHECK_HEADER(gnutls/gnutls.h,
|
||||
dnl Save the current libraries so the crypto stuff isn't always
|
||||
dnl included...
|
||||
SAVELIBS="$LIBS"
|
||||
|
||||
TEST_GNUTLS_LIBS=`libgnutls-config --libs`
|
||||
AC_CHECK_LIB(gnutls, gnutls_init,
|
||||
[SSLLIBS=$TEST_GNUTLS_LIBS
|
||||
AC_DEFINE(HAVE_SSL)
|
||||
AC_DEFINE(HAVE_GNUTLS)],,
|
||||
$TEST_GNUTLS_LIBS)
|
||||
|
||||
LIBS="$SAVELIBS")
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(SSLFLAGS)
|
||||
AC_SUBST(SSLLIBS)
|
||||
|
||||
EXPORT_SSLLIBS="$SSLLIBS"
|
||||
AC_SUBST(EXPORT_SSLLIBS)
|
||||
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-openssl.m4 4213 2004-06-29 03:44:53Z mike $".
|
||||
dnl
|
||||
@@ -1,30 +1,23 @@
|
||||
dnl
|
||||
dnl "$Id: cups-opsys.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-opsys.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl Operating system stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
dnl Get the operating system and version number...
|
||||
dnl Get the operating system, version number, and architecture...
|
||||
uname=`uname`
|
||||
uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
|
||||
uversion=`uname -r | sed -e '1,$s/^[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\).*/\1\2/'`
|
||||
uarch=`uname -m`
|
||||
|
||||
case "$uname" in
|
||||
GNU* | GNU/*)
|
||||
uname="GNU"
|
||||
@@ -37,63 +30,6 @@ case "$uname" in
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Determine the correct username and group for this OS...
|
||||
AC_ARG_WITH(cups-user, [ --with-cups-user set default user for CUPS],
|
||||
CUPS_USER="$withval",
|
||||
AC_MSG_CHECKING(for default print user)
|
||||
if test -f /etc/passwd; then
|
||||
CUPS_USER=""
|
||||
for user in lp lpd guest daemon nobody; do
|
||||
if test "`grep \^${user}: /etc/passwd`" != ""; then
|
||||
CUPS_USER="$user"
|
||||
AC_MSG_RESULT($user)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if test x$CUPS_USER = x; then
|
||||
CUPS_USER="${USER:=nobody}"
|
||||
AC_MSG_RESULT(not found, using "$CUPS_USER")
|
||||
fi
|
||||
else
|
||||
CUPS_USER="${USER:=nobody}"
|
||||
AC_MSG_RESULT(no password file, using "$CUPS_USER")
|
||||
fi)
|
||||
|
||||
AC_ARG_WITH(cups-group, [ --with-cups-group set default group for CUPS],
|
||||
CUPS_GROUP="$withval",
|
||||
AC_MSG_CHECKING(for default print group)
|
||||
if test -f /etc/group; then
|
||||
if test x$uname = xDarwin; then
|
||||
GROUP_LIST="lp admin"
|
||||
else
|
||||
GROUP_LIST="sys system root"
|
||||
fi
|
||||
|
||||
CUPS_GROUP=""
|
||||
for group in $GROUP_LIST; do
|
||||
if test "`grep \^${group}: /etc/group`" != ""; then
|
||||
CUPS_GROUP="$group"
|
||||
AC_MSG_RESULT($group)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if test x$CUPS_GROUP = x; then
|
||||
CUPS_GROUP="${GROUP:=nobody}"
|
||||
AC_MSG_RESULT(not found, using "$CUPS_GROUP")
|
||||
fi
|
||||
else
|
||||
CUPS_GROUP="${GROUP:=nobody}"
|
||||
AC_MSG_RESULT(no group file, using "$CUPS_GROUP")
|
||||
fi)
|
||||
|
||||
AC_SUBST(CUPS_USER)
|
||||
AC_SUBST(CUPS_GROUP)
|
||||
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USER, "$CUPS_USER")
|
||||
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GROUP, "$CUPS_GROUP")
|
||||
|
||||
dnl
|
||||
dnl "$Id: cups-opsys.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-opsys.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
dnl
|
||||
dnl "$Id: cups-pam.m4 4358 2004-08-11 14:39:26Z mike $"
|
||||
dnl "$Id: cups-pam.m4 6649 2007-07-11 21:46:42Z mike $"
|
||||
dnl
|
||||
dnl PAM stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 1997-2004 by Easy Software Products, all rights reserved.
|
||||
dnl Copyright 2007 by Apple Inc.
|
||||
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Easy Software Products and are protected by Federal
|
||||
dnl copyright law. Distribution and use rights are outlined in the file
|
||||
dnl "LICENSE.txt" which should have been included with this file. If this
|
||||
dnl file is missing or damaged please contact Easy Software Products
|
||||
dnl at:
|
||||
dnl
|
||||
dnl Attn: CUPS Licensing Information
|
||||
dnl Easy Software Products
|
||||
dnl 44141 Airport View Drive, Suite 204
|
||||
dnl Hollywood, Maryland 20636-3142 USA
|
||||
dnl
|
||||
dnl Voice: (301) 373-9600
|
||||
dnl EMail: cups-info@cups.org
|
||||
dnl WWW: http://www.cups.org
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE(pam, [ --enable-pam turn on PAM support, default=yes])
|
||||
@@ -39,7 +30,11 @@ if test x$enable_pam != xno; then
|
||||
|
||||
AC_CHECK_LIB(dl,dlopen)
|
||||
AC_CHECK_LIB(pam,pam_start)
|
||||
AC_CHECK_HEADER(pam/pam_appl.h,AC_DEFINE(HAVE_PAM_PAM_APPL_H))
|
||||
AC_CHECK_HEADER(security/pam_appl.h)
|
||||
if test x$ac_cv_header_security_pam_appl_h != xyes; then
|
||||
AC_CHECK_HEADER(pam/pam_appl.h,
|
||||
AC_DEFINE(HAVE_PAM_PAM_APPL_H))
|
||||
fi
|
||||
|
||||
if test x$ac_cv_lib_pam_pam_start != xno; then
|
||||
# Set the necessary libraries for PAM...
|
||||
@@ -90,5 +85,5 @@ AC_SUBST(PAMLIBS)
|
||||
AC_SUBST(PAMMOD)
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-pam.m4 4358 2004-08-11 14:39:26Z mike $".
|
||||
dnl End of "$Id: cups-pam.m4 6649 2007-07-11 21:46:42Z mike $".
|
||||
dnl
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
dnl
|
||||
dnl "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $"
|
||||
dnl
|
||||
dnl PAP (AppleTalk) stuff for the Common UNIX Printing System (CUPS).
|
||||
dnl
|
||||
dnl Copyright 2007-2008 by Apple Inc.
|
||||
dnl Copyright 2006 by Easy Software Products, all rights reserved.
|
||||
dnl
|
||||
dnl These coded instructions, statements, and computer programs are the
|
||||
dnl property of Apple Inc. and are protected by Federal copyright
|
||||
dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
|
||||
dnl which should have been included with this file. If this file is
|
||||
dnl file is missing or damaged, see the license at "http://www.cups.org/".
|
||||
dnl
|
||||
|
||||
# Currently the PAP backend is only supported on MacOS X with the AppleTalk
|
||||
# SDK installed...
|
||||
AC_ARG_ENABLE(pap, [ --enable-pap build with AppleTalk support, default=auto])
|
||||
|
||||
PAP=""
|
||||
AC_SUBST(PAP)
|
||||
|
||||
if test x$enable_pap != xno -a $uname = Darwin; then
|
||||
AC_CHECK_HEADER(netat/appletalk.h,[
|
||||
PAP="pap"
|
||||
AC_CHECK_HEADER(AppleTalk/at_proto.h)])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $".
|
||||
dnl
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário