Comparar commits

..

1 Commits

Autor SHA1 Mensagem Data
msweet 5a48d6f43e Import cups.org releases
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/tags/release-1.2rc1@4306 a1ca3aef-8c08-0410-bb20-df032aa958be
2013-05-10 18:56:23 +00:00
2072 arquivos alterados com 479170 adições e 832610 exclusões
-5
Ver Arquivo
@@ -1,5 +0,0 @@
.git* export-ignore
.mailmap export-ignore
examples/testfile.pcl -text
exampels/testfile.txt -text
scripts export-ignore
-156
Ver Arquivo
@@ -1,156 +0,0 @@
*.a
*.bck
*.cgi
*.o
autom4te.cache
config.h
config.log
config.status
cups-config
Makedefs
backend/dnssd
backend/http
backend/https
backend/ipp
backend/ipps
backend/lpd
backend/mdns
backend/snmp
backend/socket
backend/test1284
backend/testbackend
backend/testsupplies
backend/usb
berkeley/lpc
berkeley/lpq
berkeley/lpr
berkeley/lprm
cgi-bin/testcgi
cgi-bin/testhi
cgi-bin/testhi.index
cgi-bin/testtemplate
conf/cups-files.conf
conf/cupsd.conf
conf/mime.convs
conf/pam.std
conf/snmp.conf
cups/libcups.dylib
cups/libcups.2.dylib
cups/libcups.so
cups/libcups.so.2
cups/libcupsimage.dylib
cups/libcupsimage.2.dylib
cups/libcupsimage.so
cups/libcupsimage.so.2
cups/locale/
cups/rasterbench
cups/test.pwg
cups/test.raster
cups/testadmin
cups/testarray
cups/testcache
cups/testclient
cups/testconflicts
cups/testcreds
cups/testcups
cups/testdest
cups/testfile
cups/testgetdests
cups/testhttp
cups/testi18n
cups/testipp
cups/testlang
cups/testoptions
cups/testppd
cups/testpwg
cups/testraster
cups/testsnmp
cups/testthreads
cups/tlscheck
desktop/cups.desktop
doc/index.html
doc/*/index.html
filter/commandtops
filter/gziptoany
filter/pstops
filter/rastertoepson
filter/rastertohp
filter/rastertolabel
filter/rastertopwg
locale/checkpo
locale/po2strings
locale/strings2po
man/mantohtml
monitor/bcp
monitor/tbcp
notifier/dbus
notifier/mailto
notifier/rss
notifier/testnotify
packaging/cups.list
ppdc/genstrings
ppdc/ppd/
ppdc/ppd2/
ppdc/ppdc
ppdc/ppdc-static
ppdc/ppdhtml
ppdc/ppdi
ppdc/ppdi-static
ppdc/ppdmerge
ppdc/ppdpo
ppdc/sample-import.drv
ppdc/sample.c
ppdc/testcatalog
scheduler/convert
scheduler/cups-deviced
scheduler/cups-driverd
scheduler/cups-exec
scheduler/cups-lpd
scheduler/cups-lpd.xinetd
scheduler/cups.sh
scheduler/cups.xml
scheduler/cupsd
scheduler/cupsfilter
scheduler/org.cups.cups-lpd.plist
scheduler/org.cups.cups-lpdAT.service
scheduler/org.cups.cupsd.path
scheduler/org.cups.cupsd.service
scheduler/org.cups.cupsd.socket
scheduler/testlpd
scheduler/testmime
scheduler/testspeed
scheduler/testsub
systemv/cancel
systemv/cupsaccept
systemv/cupsaddsmb
systemv/cupsctl
systemv/cupsdisable
systemv/cupsenable
systemv/cupsreject
systemv/cupstestdsc
systemv/cupstestppd
systemv/lp
systemv/lpadmin
systemv/lpinfo
systemv/lpmove
systemv/lpoptions
systemv/lpstat
templates/header.tmpl
templates/*/header.tmpl
test/cups-str-*.html
test/*_log-*
tools/ippevepcl
tools/ippeveprinter
tools/ippeveprinter-static
tools/ippeveps
tools/ippfind
tools/ippfind-static
tools/ipptool
tools/ipptool-static
vcnet/.vs
vcnet/packages
vcnet/Win32
vcnet/x64
xcode/CUPS.xcodeproj/project.xcworkspace/
xcode/CUPS.xcodeproj/xcuserdata/
-4
Ver Arquivo
@@ -1,4 +0,0 @@
queries:
- exclude: cpp/integer-multiplication-cast-to-long
- exclude: cpp/missing-header-guard
- exclude: cpp/short-global-name
-11
Ver Arquivo
@@ -1,11 +0,0 @@
# Prevent git from showing duplicate names with commands like "git shortlog"
# See the manpage of git-shortlog for details.
# The syntax is:
# Name that should be used <email that should be used> Bad name <bad email>
#
# You can skip Bad name if it is the same as the one that should be used, and is unique.
#
# This file is up-to-date if the command git log --format="%aN <%aE>" | sort -u
# gives no duplicates.
Michael R Sweet <michaelrsweet@gmail.com> msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Michael R Sweet <michaelrsweet@gmail.com> Michael Sweet <msweet@msweet-imac.local>
+217
Ver Arquivo
@@ -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
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-406
Ver Arquivo
@@ -1,406 +0,0 @@
CHANGES - 2.3.3 - 2020-04-24
============================
Changes in CUPS v2.3.3
----------------------
- CVE-2020-3898: The `ppdOpen` function did not handle invalid UI
constraint. `ppdcSource::get_resolution` function did not handle
invalid resolution strings.
- CVE-2019-8842: The `ippReadIO` function may under-read an extension
field.
- Fixed WARNING_OPTIONS support for GCC 9.x
Changes in CUPS v2.3.2
----------------------
- Localization updates.
Changes in CUPS v2.3.1
----------------------
- Documentation updates (Issue #5661, #5674, #5682)
- CVE-2019-2228: The `ippSetValuetag` function did not validate the default
language value.
- Fixed a crash bug in the web interface (Issue #5621)
- The PPD cache code now looks up page sizes using their dimensions
(Issue #5633)
- PPD files containing "custom" option keywords did not work (Issue #5639)
- Added a workaround for the scheduler's systemd support (Issue #5640)
- On Windows, TLS certificates generated on February 29 would likely fail
(Issue #5643)
- Added a DigestOptions directive for the `client.conf` file to control whether
MD5-based Digest authentication is allowed (Issue #5647)
- Fixed a bug in the handling of printer resource files (Issue #5652)
- The libusb-based USB backend now reports an error when the distribution
permissions are wrong (Issue #5658)
- Added paint can labels to Dymo driver (Issue #5662)
- The `ippeveprinter` program now supports authentication (Issue #5665)
- The `ippeveprinter` program now advertises DNS-SD services on the correct
interfaces, and provides a way to turn them off (Issue #5666)
- The `--with-dbusdir` option was ignored by the configure script (Issue #5671)
- Sandboxed applications were not able to get the default printer (Issue #5676)
- Log file access controls were not preserved by `cupsctl` (Issue #5677)
- Default printers set with `lpoptions` did not work in all cases (Issue #5681,
Issue #5683, Issue #5684)
- Fixed an error in the jobs web interface template (Issue #5694)
- Fixed an off-by-one error in `ippEnumString` (Issue #5695)
- Fixed some new compiler warnings (Issue #5700)
- Fixed a few issues with the Apple Raster support (rdar://55301114)
- The IPP backend did not detect all cases where a job should be retried using
a raster format (rdar://56021091)
- Fixed spelling of "fold-accordion".
- Fixed the default common name for TLS certificates used by `ippeveprinter`.
- Fixed the option names used for IPP Everywhere finishing options.
- Added support for the second roll of the DYMO Twin/DUO label printers.
Changes in CUPS v2.3.0
----------------------
- CVE-2019-8696 and CVE-2019-8675: Fixed SNMP buffer overflows (rdar://51685251)
- Added a GPL2/LGPL2 exception to the new CUPS license terms.
- Documentation updates (Issue #5604)
- Localization updates (Issue #5637)
- Fixed a bug in the scheduler job cleanup code (Issue #5588)
- Fixed builds when there is no TLS library (Issue #5590)
- Eliminated some new GCC compiler warnings (Issue #5591)
- Removed dead code from the scheduler (Issue #5593)
- "make" failed with GZIP options (Issue #5595)
- Fixed potential excess logging from the scheduler when removing job files
(Issue #5597)
- Fixed a NULL pointer dereference bug in `httpGetSubField2` (Issue #5598)
- Added FIPS-140 workarounds for GNU TLS (Issue #5601, Issue #5622)
- The scheduler no longer provides a default value for the description
(Issue #5603)
- The scheduler now logs jobs held for authentication using the error level so
it is clear what happened (Issue #5604)
- The `lpadmin` command did not always update the PPD file for changes to the
`cupsIPPSupplies` and `cupsSNMPSupplies` keywords (Issue #5610)
- The scheduler now uses both the group's membership list as well as the
various OS-specific membership functions to determine whether a user belongs
to a named group (Issue #5613)
- Added USB quirks rule for HP LaserJet 1015 (Issue #5617)
- Fixed some PPD parser issues (Issue #5623, Issue #5624)
- The IPP parser no longer allows invalid member attributes in collections
(Issue #5630)
- The configure script now treats the "wheel" group as a potential system
group (Issue #5638)
- Fixed a USB printing issue on macOS (rdar://31433931)
- Fixed IPP buffer overflow (rdar://50035411)
- Fixed memory disclosure issue in the scheduler (rdar://51373853)
- Fixed DoS issues in the scheduler (rdar://51373929)
- Fixed an issue with unsupported "sides" values in the IPP backend
(rdar://51775322)
- The scheduler would restart continuously when idle and printers were not
shared (rdar://52561199)
- Fixed an issue with `EXPECT !name WITH-VALUE ...` tests.
- Fixed a command ordering issue in the Zebra ZPL driver.
- Fixed a memory leak in `ppdOpen`.
Changes in CUPS v2.3rc1
-----------------------
- The `cups-config` script no longer adds extra libraries when linking against
shared libraries (Issue #5261)
- The supplied example print documents have been optimized for size
(Issue #5529)
- The `cupsctl` command now prevents setting "cups-files.conf" directives
(Issue #5530)
- The "forbidden" message in the web interface is now explained (Issue #5547)
- The footer in the web interface covered some content on small displays
(Issue #5574)
- The libusb-based USB backend now enforces read limits, improving print speed
in many cases (Issue #5583)
- The `ippeveprinter` command now looks for print commands in the "command"
subdirectory.
- The `ipptool` command now supports `$date-current` and `$date-start` variables
to insert the current and starting date and time values, as well as ISO-8601
relative time values such as "PT30S" for 30 seconds in the future.
Changes in CUPS v2.3b8
----------------------
- Media size matching now uses a tolerance of 0.5mm (rdar://33822024)
- The lpadmin command would hang with a bad PPD file (rdar://41495016)
- Fixed a potential crash bug in cups-driverd (rdar://46625579)
- Fixed a performance regression with large PPDs (rdar://47040759)
- Fixed a memory reallocation bug in HTTP header value expansion
(rdar://problem/50000749)
- Timed out job submission now yields an error (Issue #5570)
- Restored minimal support for the `Emulators` keyword in PPD files to allow
old Samsung printer drivers to continue to work (Issue #5562)
- The scheduler did not encode octetString values like "job-password" correctly
for the print filters (Issue #5558)
- The `cupsCheckDestSupported` function did not check octetString values
correctly (Issue #5557)
- Added support for `UserAgentTokens` directive in "client.conf" (Issue #5555)
- Updated the systemd service file for cupsd (Issue #5551)
- The `ippValidateAttribute` function did not catch all instances of invalid
UTF-8 strings (Issue #5509)
- Fixed an issue with the self-signed certificates generated by GNU TLS
(Issue #5506)
- Fixed a potential memory leak when reading at the end of a file (Issue #5473)
- Fixed potential unaligned accesses in the string pool (Issue #5474)
- Fixed a potential memory leak when loading a PPD file (Issue #5475)
- Added a USB quirks rule for the Lexmark E120n (Issue #5478)
- Updated the USB quirks rule for Zebra label printers (Issue #5395)
- Fixed a compile error on Linux (Issue #5483)
- The lpadmin command, web interface, and scheduler all queried an IPP
Everywhere printer differently, resulting in different PPDs for the same
printer (Issue #5484)
- The web interface no longer provides access to the log files (Issue #5513)
- Non-Kerberized printing to Windows via IPP was broken (Issue #5515)
- Eliminated use of private headers and some deprecated macOS APIs (Issue #5516)
- The scheduler no longer stops a printer if an error occurs when a job is
canceled or aborted (Issue #5517)
- Added a USB quirks rule for the DYMO 450 Turbo (Issue #5521)
- Added a USB quirks rule for Xerox printers (Issue #5523)
- The scheduler's self-signed certificate did not include all of the alternate
names for the server when using GNU TLS (Issue #5525)
- Fixed compiler warnings with newer versions of GCC (Issue #5532, Issue #5533)
- Fixed some PPD caching and IPP Everywhere PPD accounting/password bugs
(Issue #5535)
- Fixed `PreserveJobHistory` bug with time values (Issue #5538)
- The scheduler no longer advertises the HTTP methods it supports (Issue #5540)
- Localization updates (Issue #5461, Issues #5471, Issue #5481, Issue #5486,
Issue #5489, Issue #5491, Issue #5492, Issue #5493, Issue #5494, Issue #5495,
Issue #5497, Issue #5499, Issue #5500, Issue #5501, Issue #5504)
- The scheduler did not always idle exit as quickly as it could.
- Added a new `ippeveprinter` command based on the old ippserver sample code.
Changes in CUPS v2.3b7
----------------------
- Fixed some build failures (Issue #5451, Issue #5463)
- Running ppdmerge with the same input and output filenames did not work as
advertised (Issue #5455)
Changes in CUPS v2.3b6
----------------------
- Localization update (Issue #5339, Issue #5348, Issue #5362, Issue #5408,
Issue #5410)
- Documentation updates (Issue #5369, Issue #5402, Issue #5403, Issue #5404)
- CVE-2018-4300: Linux session cookies used a predictable random number seed.
- All user commands now support the `--help` option (Issue #5326)
- The `lpoptions` command now works with IPP Everywhere printers that have not
yet been added as local queues (Issue #5045)
- The lpadmin command would create a non-working printer in some error cases
(Issue #5305)
- The scheduler would crash if an empty `AccessLog` directive was specified
(Issue #5309)
- The scheduler did not idle-exit on some Linux distributions (Issue #5319)
- Fixed a regression in the changes to ippValidateAttribute (Issue #5322,
Issue #5330)
- Fixed a crash bug in the Epson dot matrix driver (Issue #5323)
- Automatic debug logging of job errors did not work with systemd (Issue #5337)
- The web interface did not list the IPP Everywhere "driver" (Issue #5338)
- The scheduler did not report all of the supported job options and values
(Issue #5340)
- The IPP Everywhere "driver" now properly supports face-up printers
(Issue #5345)
- Fixed some typos in the label printer drivers (Issue #5350)
- Setting the `Community` name to the empty string in `snmp.conf` now disables
SNMP supply level monitoring by all the standard network backends
(Issue #5354)
- Multi-file jobs could get stuck if the backend failed (Issue #5359,
Issue #5413)
- The IPP Everywhere "driver" no longer does local filtering when printing to
a shared CUPS printer (Issue #5361)
- The lpadmin command now correctly reports IPP errors when configuring an
IPP Everywhere printer (Issue #5370)
- Fixed some memory leaks discovered by Coverity (Issue #5375)
- The PPD compiler incorrectly terminated JCL options (Issue #5379)
- The cupstestppd utility did not generate errors for missing/mismatched
CloseUI/JCLCloseUI keywords (Issue #5381)
- The scheduler now reports the actual location of the log file (Issue #5398)
- Added USB quirk rules (Issue #5395, Issue #5420, Issue #5443)
- The generated PPD files for IPP Everywhere printers did not contain the
cupsManualCopies keyword (Issue #5433)
- Kerberos credentials might be truncated (Issue #5435)
- The handling of `MaxJobTime 0` did not match the documentation (Issue #5438)
- Fixed a bug adding a queue with the `-E` option (Issue #5440)
- The `cupsaddsmb` program has been removed (Issue #5449)
- The `cupstestdsc` program has been removed (Issue #5450)
- The scheduler was being backgrounded on macOS, causing applications to spin
(rdar://40436080)
- The scheduler did not validate that required initial request attributes were
in the operation group (rdar://41098178)
- Authentication in the web interface did not work on macOS (rdar://41444473)
- Fixed an issue with HTTP Digest authentication (rdar://41709086)
- The scheduler could crash when job history was purged (rdar://42198057)
- Fixed a crash bug when mapping PPD duplex options to IPP attributes
(rdar://46183976)
- Fixed a memory leak for some IPP (extension) syntaxes.
- The `cupscgi`, `cupsmime`, and `cupsppdc` support libraries are no longer
installed as shared libraries.
- The `snmp` backend is now deprecated.
Changes in CUPS v2.3b5
----------------------
- The `ipptool` program no longer checks for duplicate attributes when running
in list or CSV mode (Issue #5278)
- The `cupsCreateJob`, `cupsPrintFile2`, and `cupsPrintFiles2` APIs did not use
the supplied HTTP connection (Issue #5288)
- Fixed another crash in the scheduler when adding an IPP Everywhere printer
(Issue #5290)
- Added a workaround for certain web browsers that do not support multiple
authentication schemes in a single response header (Issue #5289)
- Fixed policy limits containing the `All` operation (Issue #5296)
- The scheduler was always restarted after idle-exit with systemd (Issue #5297)
- Added a USB quirks rule for the HP LaserJet P1102 (Issue #5310)
- The mailto notifier did not wait for the welcome message (Issue #5312)
- Fixed a parsing bug in the pstops filter (Issue #5321)
- Documentation updates (Issue #5299, Issue #5301, Issue #5306)
- Localization updates (Issue #5317)
- The scheduler allowed environment variables to be specified in the
`cupsd.conf` file (rdar://37836779, rdar://37836995, rdar://37837252,
rdar://37837581)
- Fax queues did not support pause (p) or wait-for-dialtone (w) characters
(rdar://39212256)
- The scheduler did not validate notify-recipient-uri values properly
(rdar://40068936)
- The IPP parser allowed invalid group tags (rdar://40442124)
- Fixed a parsing bug in the new authentication code.
Changes in CUPS v2.3b4
----------------------
- NOTICE: Printer drivers are now deprecated (Issue #5270)
- Kerberized printing to another CUPS server did not work correctly
(Issue #5233)
- Fixed printing to some IPP Everywhere printers (Issue #5238)
- Fixed installation of filters (Issue #5247)
- The scheduler now supports using temporary print queues for older IPP/1.1
print queues like those shared by CUPS 1.3 and earlier (Issue #5241)
- Star Micronics printers need the "unidir" USB quirk rule (Issue #5251)
- Documentation fixes (Issue #5252)
- Fixed a compile issue when PAM is not available (Issue #5253)
- Label printers supported by the rastertolabel driver don't support SNMP, so
don't delay printing to test it (Issue #5256)
- The scheduler could crash while adding an IPP Everywhere printer (Issue #5258)
- The Lexmark Optra E310 printer needs the "no-reattach" USB quirk rule
(Issue #5259)
- Systemd did not restart cupsd when configuration changes were made that
required a restart (Issue #5263)
- The IPP Everywhere PPD generator did not include the `cupsJobPassword`
keyword, when supported (Issue #5265)
- Fixed an Avahi crash bug in the scheduler (Issue #5268)
- Raw print queues are now deprecated (Issue #5269)
- Fixed an RPM packaging problem (Issue #5276)
- The IPP backend did not properly detect failed PDF prints (rdar://34055474)
- TLS connections now properly timeout (rdar://34938533)
- Temp files could not be created in some sandboxed applications
(rdar://37789645)
- The ipptool `--ippserver` option did not encode out-of-band attributes
correctly.
- Added public `cupsEncodeOption` API for encoding a single option as an IPP
attribute.
- Removed support for the `-D_PPD_DEPRECATED=""` developer cheat - the PPD API
should no longer be used.
- Removed support for `-D_IPP_PRIVATE_STRUCTURES=1` developer cheat - the IPP
accessor functions should be used instead.
Changes in CUPS v2.3b3
----------------------
- More fixes for printing to old CUPS servers (Issue #5211)
- The IPP Everywhere PPD generator did not support deep grayscale or 8-bit per
component AdobeRGB (Issue #5227)
- Additional changes for the scheduler to substitute default values for invalid
job attributes when running in "relaxed conformance" mode (Issue #5229)
- Localization changes (Issue #5232, rdar://37068158)
- The `cupsCopyDestInfo` function did not work with all print queues
(Issue #5235)
Changes in CUPS v2.3b2
----------------------
- Localization changes (Issue #5210)
- Build fixes (Issue #5217)
- IPP Everywhere PPDs were not localized to English (Issue #5205)
- The `cupsGetDests` and `cupsEnumDests` functions no longer filter out local
print services like IPP USB devices (Issue #5206)
- The `cupsCopyDest` function now correctly copies the `is_default` value
(Issue #5208)
- Printing to old CUPS servers has been fixed (Issue #5211)
- The `ppdInstallableConflict` tested too many constraints (Issue #5213)
- All HTTP field values can now be longer than `HTTP_MAX_VALUE` bytes
(Issue #5216)
- Added a USB quirk rule for Canon MP280 series printers (Issue #5221)
- The `cupsRasterWritePixels` function did not correctly swap bytes for some
formats (Issue #5225)
- Fixed an issue with mapping finishing options (rdar://34250727)
- The `ppdLocalizeIPPReason` function incorrectly returned a localized version
of "none" (rdar://36566269)
- The scheduler did not add ".local" to the default DNS-SD host name when
needed.
Changes in CUPS v2.3b1
----------------------
- CUPS is now provided under the Apache License, Version 2.0.
- Documentation updates (Issue #4580, Issue #5177, Issue #5192)
- The `cupsCopyDestConflicts` function now handles collection attribute
("media-col", "finishings-col", etc.) constraints (Issue #4096)
- The `lpoptions` command incorrectly saved default options (Issue #4717)
- The `lpstat` command now reports when new jobs are being held (Issue #4761)
- The `ippfind` command now supports finding printers whose name starts with an
underscore (Issue #4833)
- The CUPS library now supports the latest HTTP Digest authentication
specification including support for SHA-256 (Issue #4862)
- The scheduler now supports the "printer-id" attribute (Issue #4868)
- No longer support backslash, question mark, or quotes in printer names
(Issue #4966)
- The scheduler no longer logs pages as they are printed, instead just logging
a total of the pages printed at job completion (Issue #4991)
- Dropped RSS subscription management from the web interface (Issue #5012)
- Bonjour printer sharing now uses the DNS-SD hostname (or ServerName value if
none is defined) when registering shared printers on the network (Issue #5071)
- The `ipptool` command now supports writing `ippserver` attributes files
(Issue #5093)
- The `lp` and `lpr` commands now provide better error messages when the default
printer cannot be found (Issue #5096)
- The `lpadmin` command now provides a better error message when an unsupported
System V interface script is used (Issue #5111)
- The scheduler did not write out dirty configuration and state files if there
were open client connections (Issue #5118)
- The `SSLOptions` directive now supports `MinTLS` and `MaxTLS` options to
control the minimum and maximum TLS versions that will be allowed,
respectively (Issue #5119)
- Dropped hard-coded CGI scripting language support (Issue #5124)
- The `cupsEnumDests` function did not include options from the lpoptions
files (Issue #5144)
- Fixed the `ippserver` sample code when threading is disabled or unavailable
(Issue #5154)
- Added label markup to checkbox and radio button controls in the web interface
templates (Issue #5161)
- Fixed group validation on OpenBSD (Issue #5166)
- Improved IPP Everywhere media support, including a new
`cupsAddDestMediaOptions` function (Issue #5167)
- IPP Everywhere PPDs now include localizations of printer-specific media types,
when available (Issue #5168)
- The cups-driverd program incorrectly stopped scanning PPDs as soon as a loop
was seen (Issue #5170)
- IPP Everywhere PPDs now support IPP job presets (Issue #5179)
- IPP Everywhere PPDs now support finishing templates (Issue #5180)
- Fixed a journald support bug in the scheduler (Issue #5181)
- Fixed PAM module detection and added support for the common PAM definitions
(Issue #5185)
- The scheduler now substitutes default values for invalid job attributes when
running in "relaxed conformance" mode (Issue #5186)
- The scheduler did not work with older versions of uClibc (Issue #5188)
- The scheduler now generates a strings file for localizing PPD options
(Issue #5194)
+400
Ver Arquivo
@@ -0,0 +1,400 @@
CHANGES.txt - 2006-03-24
------------------------
CHANGES IN CUPS V1.2rc1
- Documentation updates (STR #1497, STR #1498)
- The scheduler now redirects browsers to https: URLs
when encryption is required.
- The scheduler would crash when printing with a banner
(STR #1500)
- cups-driverd did not use the LanguageEncoding attribute
in PPD files to convert the NickName to UTF-8 (STR
#1503)
- The lpadmin command could not set the
printer-error-policy attribute (STR #1504)
- The web interface did not show the time and date in the
correct format for the locale (STR #1505)
- CUPS no longer accepts print jobs if a printer does not
support the file format (STR #1501)
- Cleaned up the PostScript filter (pstops) so that it
properly supports %%IncludeFeature and page scaling
(STR #1453)
- Fixed the cupsFileRewind() and cupsFileSeek() functions
to work properly with uncompressed files.
- Added cupsFileGetLine(), cupsFileStderr(),
cupsFileStdin(), and cupsFileStdout() functions to the
CUPS library.
- Added a new cupstestdsc program to test the DSC
conformance of PostScript files.
- Added KDE/GNOME icons and a Manage Printers menu item.
- Added --enable-image and --enable-pdftops configure
options to control whether the image and PDF filters
are built and installed (default = yes for all
platforms but MacOS X)
- Fixed a minor memory leak in the PPD API.
- Fixed transcoding issues (STR #1493)
- The scheduler now enforces a minimum job cost of 100
when doing FilterLimit checks.
- The scheduler would leak file descriptors when printing
to raw queues (STR #1491)
- The IPv6 support did not compile on Tru64 UNIX (STR
#1488)
- ppdOpen2() now converts the NickName and all UI text to
UTF-8 (STR #1475)
- The Set Allows Users web page did not work (STR #1486)
- When the default policy was not set or set to a non-
existing policy, the scheduler did not set the default
policy name to "default" (STR #1484)
- The Zebra CPCL driver did not use the correct righthand
margin for the 4" wide label sizes.
- Fixed a problem with the parsing of fractional real
numbers in PPD files.
- Added Spanish localization files (STR #1480)
- Fixed localization of a few scheduler messages (STR
#1478)
- Fixed support for HEAD requests in the scheduler (STR
#1481)
CHANGES IN CUPS V1.2b2
- Updated the CUPS design description.
- Added --enable-32bit and --enable-64bit configure
options to allow building of separate 32/64-bit
libraries on systems that support both environments
(STR #1472)
- Various compiler warning fixes.
- Fixes for Solaris 10 builds against old GNU TLS and
LDAP libraries.
- Added a cupsArrayUserData() function to retrieve the
user data pointer for an array (useful for typing
arrays)
- The ppdEmitString() function did not compute the
required buffer size properly, leading to dropped
characters on the end of the printer commands in pstops
and imagetops (STR #1470)
CHANGES IN CUPS V1.2b1
- The serial backend now supports Equinox 8-port serial
hubs (STR #526)
- The IPP backend now supports a compression option to
compress print files as they are sent to the remote
server (STR #956)
- The CUPS browse protocol now supports passing of
default options and browse timeout values from the
server to the clients (STR #800)
- Implicit classes that timed out could cause the
scheduler to crash (STR #1439)
- Added DragonFly support in local device backends (STR
#1362)
- Added LDAP printer browsing support (STR #338)
- Added official support for printer maintenance commands
via the CUPS Command file format and hooks in the
printer-type and web interfaces (STR #932)
- The HP-GL/2 filter could get in an infinite loop trying
to convert HP-PCL files (STR #1415)
- CUPS now implements the HTTP/1.1 Expect header (STR
#1407)
- Options in PPD files are no longer automatically put in
an "Extra" group; rather, all options that are not
inside an Open/CloseGroup will be placed in the
"General" group (STR #1385)
- The scheduler now creates a job-uuid attribute that
uniquely identifies a job on a network (STR #1410)
- The init script now unsets the TMPDIR environment
variable to prevent user temporary directories from
being used by cupsd accidentally (STR #1424)
- Added support for launchd on MacOS X.
- Added support for notify_post on MacOS X.
- Added support for DBUS on Linux.
- All of the Berkeley (except for lpc) and System V
commands now support specification of user, host, and
port (STR #1028, STR #1029, STR #1087)
- The lpmove command now allows you to move all jobs for
a given queue (STR #56)
- The web interface now supports moving of a job or jobs
to another queue (STR #56)
- The web interface now provides searching, paging, and
changing of the sort/display order of classes, jobs,
and printers.
- cupsaddsmb now accepts a password on the command-line
and supports passwords with special characters (STR
#822, STR #1236)
- ppdLoad*() no longer tries to "fix" bad characters in
UI text (STR #1101)
- Printer names can now (reliably) contain Unicode
characters (STR #896)
- The lpstat command now shows the time and date of the
last printer state change instead of the hardcoded "Jan
01 00:00" (STR #659)
- The scheduler now adds a job-actual-printer-uri
attribute to job objects when printing to a class (STR
#116)
- The scheduler now logs log file open errors to the
system log (STR #1289)
- The scheduler now sets the job-originating-user-name to
the authenticated username, if available (STR #1318)
- The scheduler now only updates the permissions of SSL
keys and certificates when they are under the
ServerRoot directory (STR #1324)
- The rastertodymo driver has been renamed to
rastertolabel (a symlink is installed so that existing
queues continue to work) and now also supports Zebra's
CPCL language.
- The lpstat command could show the wrong active job for
a printer (STR #1301)
- Fixed a potential crash problem in the scheduler when
aborting a CGI program (STR #1290)
- Added a "cancel all jobs" button to the class and
printer web interfaces (STR #1140)
- The add-printer web page now shows the
set-printer-options page after the printer has been
added (STR #690)
- The classes web page now provides links to each of the
member printers (STR #307)
- CUPS now handles HTTP request/response lines up to 32k
in length; this is mainly for better cookie support
(STR #1274)
- Added support for the Apache PassEnv and SetEnv
directives to cupsd.conf (STR #853)
- Added large file (64-bit) support (STR #541)
- Fixed a performance issue with the ippReadIO()
implementation (STR #1284)
- Fixed a performance issue with the scheduler's implicit
class implementation (STR #1283)
- The pdftops filter now adds the Title and Creator
fields from the PDF file to the PostScript document
comments section (STR #539, STR #830)
- Added a new cups_array_t and cupsArray*() functions to
the CUPS API to support sorted lists of data.
- Made the CUPS API library thread-safe (STR #1276)
- Added "media" option support for EFI EFMediaType option
(STR #902)
- Added write buffering to the HTTP code to improve
performance (STR #547)
- The scheduler now uses the attributes-natural-language
attribute to localize banner pages (STR #386)
- The scheduler now returns the address that was used to
connect to it (STR #1076)
- Fixed a problem with N-up printing and OpenOffice (STR
#576)
- Added support for the GCC position independent
executable options (STR #1209)
- Added new BrowseLocalProtocols and
BrowseRemoteProtocols directives to cupsd.conf,
allowing for different browse protocols for local and
remote printers (STR #877)
- PPD files can now contain strings up to 256k in length
(STR #1215)
- The pstops filter now supports the IncludeFeature DSC
comment (STR #1212)
- The pstops filter now disables the setpagedevice
procedure when doing N-up printing (STR #1161)
- The serial backend now supports "stop=1", "stop=2",
"parity=space", and "parity=mark" options (STR #1155)
- "make install" no longer overwrites an existing PAM
configuration file (STR #1064)
- The scheduler now closes all files on startup when run
in daemon mode (STR #1009)
- Added a new RGBW colorspace to the CUPS raster format
(STR #1071)
- The pdftops filter now sets the page size based on the
media box when not scaling the output (STR #912)
- The pdftops filter now supports masked images (STR
#281)
- The pdftops filter produced large output when rendering
PDF files containing lot of repeated images (STR #327)
- The pdftops filter now minimizes print processing of
PDF files when using the page-ranges option (STR #273)
- Updated pdftops filter to Xpdf 3.01.
- Added new cupsBackchannelRead() and
cupsBackchannelWrite() functions, as well as
backchannel support to the parallel, serial, socket,
and USB backends (STR #1252)
- The parallel and USB backends now treat a "no space
available" error as an out-of-paper condition (STR
#1225)
- The "lpc" command now supports the "status all" command
(STR #1004)
- ippReadIO() did not read collections properly (STR
#1249)
- The "make test" script now creates the test files in
"/tmp/cups-$USER" instead of "/tmp/$USER" (STR #981)
- All backends now abort on error when printing a job to
a class - this allows the next printer in the class to
print the job (STR #1084)
- The scheduler now verifies that a printer supports
Letter or A4 media sizes before setting them as the
initial default (STR #1250)
- The cupstestppd program now flags bad Resolution
options (STR #1269)
- The USB backend now retries printing when the printer
is disconnected or turned off (STR #1267)
- Added new httpGetHostname() function to CUPS API, and
use it instead of gethostname() so that the web
interface will work correctly on systems whose hostname
is not the FQDN (STR #1266)
- The scheduler now stops printers if the backend for the
queue is missing on startup (STR #1265)
- The configure script now supports "--disable-library"
to disable particular image file format support
libraries, even if they are available on the build
system (STR #1248)
- The IPP backend did not always report on the total
number of pages that were printed (STR #1251)
- The lpstat program could display garbage date and time
values for locales whose date format exceeded 31
characters (STR #1263)
- The cupstestppd program would segfault when testing
certain broken PPD files (STR #1268)
- Dramatically reduced the overhead of implicit classes.
- Added new cupsDir*() functions to CUPS API.
- Printers can now be published individually for sharing.
- Fixed a bug in the scheduler's startup signalling code
which caused cupsd to send the SIGUSR1 signal to the
init process instead of the original parent process
(STR #1258)
- Added new on-line help CGI to web interface to provide
searchable help.
- Devices are now tracked dynamically, with each query
doing a new device scan. This eliminates a previous
startup delay caused by slow backends and allows new
printers to be seen without restarting the server,
however it limits the amount of device URI checking
that can be done (basically now the scheduler only
requires a URI with a method that is a listed backend)
- Added new printer auto-detection, server configuration,
and log file viewing to the administration web page.
- Added new "set allowed users" web interface to set the
list of allowed users for a printer or class.
- The scheduler, command-line, and web interfaces now
limit the list of printers and classes to those
accessible by a user.
- cupsMarkOptions() now handles more non-standard
duplexing options and choices (STR #915)
- cups-lpd now honors remote banner requests with the
"standard" banner whenever a printer does not have one
defined (STR #1220)
- The scheduler's denial-of-service checks did not work
properly with IPv6 addresses (STR #1134)
- The lp and lpr commands did not error out properly when
they were unable to write to a temporary file (STR
#1129)
- The pstops filter did not handle Adobe-specific
comments in Windows NT driver output (STR #1085)
- "lpstat -l -p" incorrectly reported the printer
interface (STR #936)
- The web interface now operates exclusively with the
UTF-8 encoding, and sends the appropriate character set
and header information to the web browser (STR #919,
STR #1007)
- Added a "set allowed users" interface to the web
interface so that you can set the list of allowed or
denied users/groups for a printer or class.
- Disallow the "#" character in printer names, since it
has special meaning in the shell, config files, and in
URIs (STR #917, STR #1202)
- Added a new application/x-csource MIME type, and
support for it to the texttops filter so that you can
pretty print plain text files without the C/C++
keywords being highlighted.
- The pdftops filter did not compile with GCC 4.0 (STR
#1226)
- The texttops filter did not highlight preprocessor
directives followed by a tab properly.
- HP PJL output now uses both JOB DISPLAY and RDYMSG
commands to show the current job on the printer's
display (STR #1218)
- Local authentication certificates are now stored in
/var/run/cups/certs by default instead of
/etc/cups/certs (STR #1211)
- Backends now use "&" to separate options in device
URIs; "+" is still recognized but is deprecated (STR
#842)
- The USB backend no longer supports the usb:/dev/foo
format on systems that support device ID queries.
- Forced classification markings did not work when the
job-sheets parameters were "none,none".
- "lpstat -l -p" incorrectly showed all users as allowed,
even if the queue was restricted to certain users (STR
#801)
- The scheduler now automatically detects SSL/TLS clients
without using the SSLPort/SSLListen directives.
- The CUPS API and scheduler no longer support SSLv2-
encrypted connections.
- Updated the cupsaddsmb utility to correctly export the
CUPS driver for Windows.
- Fixed a signal-handling bug in httpRead() which
ultimately caused the server to print multiple copies
when it was busy (STR #1184)
- The cupsFile API now uses the O_APPEND option when
opening files in append mode (STR #990)
- The md5.h header and md5_* functions are now officially
private and have been renamed to avoid conflicts with
other implementations with the same name.
- The pdftops filter incorrectly embedded some Type1
fonts (STR #1093)
- The scheduler didn't detect a closed connection in the
middle of an IPP request (STR #1153)
- The scheduler could block trying to read the job status
if there was input pending and the job was cancelled in
the same input cycle (STR #1157)
- The scheduler could crash when deleting a class due to
infinite recursion.
- Updated the Zebra ZPL label printer driver to use the
run-length encoding and support more options.
- Updated serial backend to scan for /dev/ttyC* as well
as /dev/ttyc* for Cyclades serial ports (STR #1049)
- The scheduler could hang reading the job status under
certain circumstances (STR #1068)
- The USB backend termination signal code was inverted
(STR #1046)
- Moved enable and disable commands to sbindir to be
consistent.
- Added new cupsRasterInterpretPPD() function for RIP
filters to setup the raster page header from
PostScript commands in a PPD file.
- The CUPS browsing protocol now offers a "delete" bit
to remove printers as soon as they are deleted on the
server or as soon as the server shuts down gracefully
(STR #793)
- The CUPS_SERVER and ServerName directives (client.conf
and ~/.cupsrc) may now contain names of the form
"server:port" and "/path/to/domain/socket".
- The "cancel -u user" command now works for ordinary
users (STR #751)
- Added test run support to "make test" target (STR #64)
- Added domain socket support (STR #656)
- Added BrowseLocalOptions directive to allow the
administrator to add printer URI options to the browse
URI, e.g. "encryption=required" (STR #732)
- Added BrowseRemoteOptions directive to allow the
administrator to add standard URI options to the
remote printer URI, e.g. "encryption=required" (STR
#732)
- Now put "-I.." compiler option in front of all others
to ensure that local CUPS headers are used before
installed headers (STR #437)
- New cupsLangPrintf() and cupsLangPuts() for localized
interfaces.
- Now support custom attributes and extended options in
PPD files.
- Now provide functions to save PPD files.
- New policy mechanism allows per-operation and
per-printer control over what users and groups are
allowed to do various IPP operations.
- New error policy mechanism to control how aborted
backend errors are handled by the scheduler
(abort-job, retry-job, requeue-job, stop-printer)
- Updated the printer test page with a better color
wheel and a separate grayscale ramp.
- A single backend process is now run to send all print
data for a job.
- Backends and filters can now send and receive
backchannel data over file descriptor 3.
- Updated the raster stream format to support more
user-defined attributes and to do compression of the
page data.
-15
Ver Arquivo
@@ -1,15 +0,0 @@
Contributing to CUPS
====================
CUPS is developed by Apple Inc. and distributed as open source software under
the Apache License, Version 2.0 with exceptions to allow linking to GPL2/LGPL2
code. Significant contributions to CUPS must be licensed to Apple using the
Apple Contributor Agreement:
https://www.cups.org/AppleContributorAgreement_2011-03-10.pdf
Contributions should be submitted as attachments to bug reports on the
[CUPS Github project](https://github.com/apple/cups). Changes to existing
source files should be submitted as unified diffs while new source files
should be provided as-is or in an archive. Github pull requests can also be
used to submit changes.
+11 -24
Ver Arquivo
@@ -1,13 +1,11 @@
CREDITS - 2019-08-21
====================
CREDITS.txt - 2006-02-23
------------------------
Few projects are completed by one person, and CUPS is no exception. We'd like
to thank the following individuals for their contributions:
Few projects are completed by one person, and CUPS is no exception. We'd
like to thank the following individuals for their contributions:
Niklas 'Nille' Åkerström - Swedish localization.
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.
@@ -18,37 +16,26 @@ to thank the following individuals for their contributions:
Wang Jian - CUPS RPM corrections.
Roderick Johnstone - Beta tester of the millenium.
Till Kamppeter - Bug fixes, beta testing, evangelism.
Tomohiro Kato - Japanese localization.
Kenshi Muto - Japanese localization, patches, and
testing.
Kiko - Bug fixes.
Sergey V. Kovalyov - ESP Print Pro and CUPS beta tester.
Marek Laane - Estonian translation.
Iñaki Larrañaga - Basque localization.
Mark Lawrence - Microsoft interoperability testing.
Jeff Licquia - Bug fixes, beta testing, evangelism.
Jason McMullan - Original CUPS RPM distributions.
Àngel Mompó - Catalan localization.
Wes Morgan - *BSD fixes.
Kenshi Muto - Japanese localization, patches, and
testing.
Brian Norris - Upstart support.
Daniel Nylander - Swedish localization.
Naruiko Ogasawara - Japanese localization.
Ulrich Oldendorf - German locale.
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.
Gilles QUERRET - French man pages.
Petter Reinholdtsen - HP-UX compiler stuff.
Juan Pablo González Riopedre - Spanish localization.
Giovanni Scafora - Italian localization.
Joachim Schwender - German localization.
Opher Shachar - Hebrew localization.
Juan Pablo González Riopedre - Spanish localization
Stuart Stevens - HP JetDirect IPP information.
Andrea Suatoni - IRIX desktop integration and testing.
Teppo Turliainen - Finnish localization.
Tomohiro Kato - Japanese 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
"msweet@apple.com".
"mike@easysw.com".
-626
Ver Arquivo
@@ -1,626 +0,0 @@
Developing for CUPS
===================
Please see the [Contributing to CUPS](CONTRIBUTING.md) file for information on
contributing to the CUPS project.
How To Contact The Developers
-----------------------------
The CUPS mailing lists are the primary means of asking questions and informally
discussing issues and feature requests with the CUPS developers and other
experienced CUPS users and developers. The "cups" mailing list is intended for
CUPS usage questions and new software announcements while the "cups-devel"
mailing list provides a forum for CUPS developers and monitoring new bugs.
Interfaces
----------
CUPS interfaces, including the C APIs and command-line arguments, environment
variables, configuration files, and output format, are stable across patch
versions and are generally backwards-compatible with interfaces used in prior
major and minor versions. However, program interfaces such as those used by
the scheduler to run filter, port monitor, and backend processes for job
processing should only be considered stable from the point of view of a
filter, port monitor, or backend. Software that simulates the scheduler in
order to run those programs outside of CUPS must necessarily be updated when
the corresponding interface is changed in a subsequent CUPS release, otherwise
undefined behavior can occur.
CUPS C APIs starting with an underscore (`_`) are considered to be private to
CUPS and are not subject to the normal guarantees of stability between CUPS
releases and must never be used in non-CUPS source code. Similarly,
configuration and state files written by CUPS are considered private if a
corresponding man page is not provided with the CUPS release. Never rely on
undocumented files or formats when developing software for CUPS. Always use a
published C API to access data stored in a file to avoid compatibility problems
in the future.
Build System
------------
The CUPS build system uses GNU autoconf to tailor the library to the local
operating system. Project files for the current release of Microsoft Visual
Studio are also provided for Microsoft Windows®. To improve portability,
makefiles must not make use of features unique to GNU make. See the MAKEFILE
GUIDELINES section for a description of the allowed make features and makefile
guidelines.
Additional GNU build programs such as GNU automake and GNU libtool must not be
used. GNU automake produces non-portable makefiles which depend on GNU-
specific extensions, and GNU libtool is not portable or reliable enough for
CUPS.
Version Numbering
-----------------
CUPS uses a three-part version number separated by periods to represent the
major, minor, and patch release numbers. Major release numbers indicate large
design changes or backwards-incompatible changes to the CUPS API or CUPS
Imaging API. Minor release numbers indicate new features and other smaller
changes which are backwards-compatible with previous CUPS releases. Patch
numbers indicate bug fixes to the previous feature or patch release. This
version numbering scheme is consistent with the
[Semantic Versioning](http://semver.org) specification.
> Note:
>
> When we talk about compatibility, we are talking about binary compatibility
> for public APIs and output format compatibility for program interfaces.
> Changes to configuration file formats or the default behavior of programs
> are not generally considered incompatible as the upgrade process can
> normally address such changes gracefully.
Production releases use the plain version numbers:
MAJOR.MINOR.PATCH
1.0.0
...
1.1.0
...
1.1.23
...
2.0.0
...
2.1.0
2.1.1
2.1.2
2.1.3
The first production release in a MAJOR.MINOR series (MAJOR.MINOR.0) is called
a feature release. Feature releases are the only releases that may contain new
features. Subsequent production releases in a MAJOR.MINOR series may only
contain bug fixes.
Beta-test releases are identified by appending the letter B to the major and
minor version numbers followed by the beta release number:
MAJOR.MINORbNUMBER
2.2b1
Release candidates are identified by appending the letters RC to the major and
minor version numbers followed by the release candidate number:
MAJOR.MINORrcNUMBER
2.2rc1
Coding Guidelines
-----------------
Contributed source code must follow the guidelines below. While the examples
are for C and C++ source files, source code for other languages should conform
to the same guidelines as allowed by the language.
Source code comments provide the reference portion of the CUPS Programming
Manual, which is generated using the [codedoc](https://www.msweet.org/codedoc)
software.
### Source Files
All source files names must be 16 characters or less in length to ensure
compatibility with older UNIX filesystems. Source files containing functions
have an extension of ".c" for C and ".cxx" for C++ source files. All other
"include" files have an extension of ".h". Tabs are set to 8 characters or
columns.
> Note:
>
> The ".cxx" extension is used because it is the only common C++ extension
> between Linux, macOS, UNIX, and Windows.
The top of each source file contains a header giving the purpose or nature of
the source file and the copyright and licensing notice:
/*
* Description of file contents.
*
* Copyright 2017 by Apple Inc.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
### Header Files
All public header files must include the "versioning.h" header file, or a header
that does so. Function declarations are then "decorated" with the correct
`_CUPS_API_major_minor` macro to define its availability based on the build
environment, for example:
extern int cupsDoThis(int foo, int bar) _CUPS_API_2_2;
Private API header files must be named with the suffix "-private", for example
the "cups.h" header file defines all of the public CUPS APIs while the
"cups-private.h" header file defines all of the private CUPS APIs as well.
Typically a private API header file will include the corresponding public API
header file.
### Comments
All source code utilizes block comments within functions to describe the
operations being performed by a group of statements; avoid putting a comment
per line unless absolutely necessary, and then consider refactoring the code
so that it is not necessary. C source files use the block comment format
("/* comment */") since many vendor C compilers still do not support C99/C++
comments ("// comment"):
/*
* Clear the state array before we begin...
*/
for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
array[i] = CUPS_STATE_IDLE;
/*
* Wait for state changes on another thread...
*/
do
{
for (i = 0; i < (sizeof(array) / sizeof(sizeof(array[0])); i ++)
if (array[i] != CUPS_STATE_IDLE)
break;
if (i == (sizeof(array) / sizeof(array[0])))
sleep(1);
} while (i == (sizeof(array) / sizeof(array[0])));
### Indentation
All code blocks enclosed by brackets begin with the opening brace on a new
line. The code then follows starting on a new line after the brace and is
indented 2 spaces. The closing brace is then placed on a new line following
the code at the original indentation:
{
int i; /* Looping var */
/*
* Process foobar values from 0 to 999...
*/
for (i = 0; i < 1000; i ++)
{
do_this(i);
do_that(i);
}
}
Single-line statements following "do", "else", "for", "if", and "while" are
indented 2 spaces as well. Blocks of code in a "switch" block are indented 4
spaces after each "case" and "default" case:
switch (array[i])
{
case CUPS_STATE_IDLE :
do_this(i);
do_that(i);
break;
default :
do_nothing(i);
break;
}
### Spacing
A space follows each reserved word such as `if`, `while`, etc. Spaces are not
inserted between a function name and the arguments in parenthesis.
### Return Values
Parenthesis surround values returned from a function:
return (CUPS_STATE_IDLE);
### Functions
Functions with a global scope have a lowercase prefix followed by capitalized
words, e.g., `cupsDoThis`, `cupsDoThat`, `cupsDoSomethingElse`, etc. Private
global functions begin with a leading underscore, e.g., `_cupsDoThis`,
`_cupsDoThat`, etc.
Functions with a local scope are declared static with lowercase names and
underscores between words, e.g., `do_this`, `do_that`, `do_something_else`, etc.
Each function begins with a comment header describing what the function does,
the possible input limits (if any), the possible output values (if any), and
any special information needed:
/*
* 'do_this()' - Compute y = this(x).
*
* Notes: none.
*/
static float /* O - Inverse power value, 0.0 <= y <= 1.1 */
do_this(float x) /* I - Power value (0.0 <= x <= 1.1) */
{
...
return (y);
}
Return/output values are indicated using an "O" prefix, input values are
indicated using the "I" prefix, and values that are both input and output use
the "IO" prefix for the corresponding in-line comment.
The [codedoc](https://www.msweet.org/codedoc) documentation generator also
understands the following special text in the function description comment:
@deprecated@ - Marks the function as deprecated: not recommended
for new development and scheduled for removal.
@link name@ - Provides a hyperlink to the corresponding function
or type definition.
@since CUPS version@ - Marks the function as new in the specified version
of CUPS.
@private@ - Marks the function as private so it will not be
included in the documentation.
### Variables
Variables with a global scope are capitalized, e.g., `ThisVariable`,
`ThatVariable`, `ThisStateVariable`, etc. Globals in CUPS libraries are either
part of the per-thread global values managed by the `_cupsGlobals` function
or are suitably protected for concurrent access. Global variables should be
replaced by function arguments whenever possible.
Variables with a local scope are lowercase with underscores between words,
e.g., `this_variable`, `that_variable`, etc. Any "local global" variables
shared by functions within a source file are declared static. As for global
variables, local static variables are suitably protected for concurrent access.
Each variable is declared on a separate line and is immediately followed by a
comment block describing the variable:
int ThisVariable; /* The current state of this */
static int that_variable; /* The current state of that */
### Types
All type names are lowercase with underscores between words and `_t` appended
to the end of the name, e.g., `cups_this_type_t`, `cups_that_type_t`, etc.
Type names start with a prefix, typically `cups` or the name of the program,
to avoid conflicts with system types. Private type names start with an
underscore, e.g., `_cups_this_t`, `_cups_that_t`, etc.
Each type has a comment block immediately after the typedef:
typedef int cups_this_type_t; /* This type is for CUPS foobar options. */
### Structures
All structure names are lowercase with underscores between words and `_s`
appended to the end of the name, e.g., `cups_this_s`, `cups_that_s`, etc.
Structure names start with a prefix, typically `cups` or the name of the
program, to avoid conflicts with system types. Private structure names start
with an underscore, e.g., `_cups_this_s`, `_cups_that_s`, etc.
Each structure has a comment block immediately after the struct and each member
is documented similar to the variable naming policy above:
struct cups_this_struct_s /* This structure is for CUPS foobar options. */
{
int this_member; /* Current state for this */
int that_member; /* Current state for that */
};
### Constants
All constant names are uppercase with underscores between words, e.g.,
`CUPS_THIS_CONSTANT`, `CUPS_THAT_CONSTANT`, etc. Constants begin with an
uppercase prefix, typically `CUPS_` or the program or type name. Private
constants start with an underscore, e.g., `_CUPS_THIS_CONSTANT`,
`_CUPS_THAT_CONSTANT`, etc.
Typed enumerations should be used whenever possible to allow for type checking
by the compiler.
Comment blocks immediately follow each constant:
typedef enum cups_tray_e /* Tray enumerations */
{
CUPS_TRAY_THIS, /* This tray */
CUPS_TRAY_THAT /* That tray */
} cups_tray_t;
## Makefile Guidelines
The following is a guide to the makefile-based build system used by CUPS.
These standards have been developed over the years to allow CUPS to be built on
as many systems and environments as possible.
### General Organization
The CUPS source code is organized functionally into a top-level makefile,
include file, and subdirectories each with their own makefile and dependencies
files. The ".in" files are template files for the autoconf software and are
used to generate a static version of the corresponding file.
### Makefile Documentation
Each makefile starts with the standard CUPS header containing the description
of the file, and CUPS copyright and license notice:
#
# Makefile for ...
#
# Copyright 2017 by Apple Inc.
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
#
### Portable Makefile Construction
CUPS uses a common subset of make program syntax to ensure that the software
can be compiled "out of the box" on as many systems as possible. The following
is a list of assumptions we follow when constructing makefiles:
- Targets; we assume that the make program supports the notion of simple
targets of the form "name:" that perform tab-indented commands that follow
the target, e.g.:
target:
TAB target commands
- Dependencies; we assume that the make program supports recursive dependencies
on targets, e.g.:
target: foo bar
TAB target commands
foo: bla
TAB foo commands
bar:
TAB bar commands
bla:
TAB bla commands
- Variable Definition; we assume that the make program supports variable
definition on the command-line or in the makefile using the following form:
name=value
- Variable Substitution; we assume that the make program supports variable
substitution using the following forms:
- `$(name)`; substitutes the value of "name",
- `$(name:.old=.new)`; substitutes the value of "name" with the filename
extension ".old" changed to ".new",
- `$(MAKEFLAGS)`; substitutes the command-line options passed to the
program without the leading hyphen (-),
- `$$`; substitutes a single $ character,
- `$<`; substitutes the current source file or dependency, and
- `$@`; substitutes the current target name.
- Suffixes; we assume that the make program supports filename suffixes with
assumed dependencies, e.g.:
.SUFFIXES: .c .o
.c.o:
TAB $(CC) $(CFLAGS) -o $@ -c $<
- Include Files; we assume that the make program supports the include
directive, e.g.:
include ../Makedefs
include Dependencies
- Comments; we assume that comments begin with a # character and proceed to the
end of the current line.
- Line Length; we assume that there is no practical limit to the length of
lines.
- Continuation of long lines; we assume that the `\` character may be placed at
the end of a line to concatenate two or more lines in a makefile to form a
single long line.
- Shell; we assume a POSIX-compatible shell is present on the build system.
### Standard Variables
The following variables are defined in the "Makedefs" file generated by the
autoconf software:
- `ALL_CFLAGS`; the combined C compiler options,
- `ALL_CXXFLAGS`; the combined C++ compiler options,
- `AMANDIR`; the administrative man page installation directory (section 8/1m
depending on the platform),
- `AR`; the library archiver command,
- `ARFLAGS`; options for the library archiver command,
- `AWK`; the local awk command,
- `BINDIR`; the binary installation directory,
- `BUILDROOT`; optional installation prefix (defaults to DSTROOT),
- `CC`; the C compiler command,
- `CFLAGS`; options for the C compiler command,
- `CHMOD`; the chmod command,
- `CXX`; the C++ compiler command,
- `CXXFLAGS`; options for the C++ compiler command,
- `DATADIR`; the data file installation directory,
- `DSO`; the C shared library building command,
- `DSOXX`; the C++ shared library building command,
- `DSOFLAGS`; options for the shared library building command,
- `INCLUDEDIR`; the public header file installation directory,
- `INSTALL`; the install command,
- `INSTALL_BIN`; the program installation command,
- `INSTALL_COMPDATA`; the compressed data file installation command,
- `INSTALL_CONFIG`; the configuration file installation command,
- `INSTALL_DATA`; the data file installation command,
- `INSTALL_DIR`; the directory installation command,
- `INSTALL_LIB`; the library installation command,
- `INSTALL_MAN`; the documentation installation command,
- `INSTALL_SCRIPT`; the shell script installation command,
- `LD`; the linker command,
- `LDFLAGS`; options for the linker,
- `LIBDIR`; the library installation directory,
- `LIBS`; libraries for all programs,
- `LN`; the ln command,
- `MAN1EXT`; extension for man pages in section 1,
- `MAN3EXT`; extension for man pages in section 3,
- `MAN5EXT`; extension for man pages in section 5,
- `MAN7EXT`; extension for man pages in section 7,
- `MAN8DIR`; subdirectory for man pages in section 8,
- `MAN8EXT`; extension for man pages in section 8,
- `MANDIR`; the man page installation directory,
- `OPTIM`; common compiler optimization options,
- `PRIVATEINCLUDE`; the private header file installation directory,
- `RM`; the rm command,
- `SHELL`; the sh (POSIX shell) command,
- `STRIP`; the strip command,
- `srcdir`; the source directory.
### Standard Targets
The following standard targets are defined in each makefile:
- `all`; creates all target programs, libraries, and documentation files,
- `clean`; removes all target programs libraries, documentation files, and object
files,
- `depend`; generates automatic dependencies for any C or C++ source files (also
see "DEPENDENCIES"),
- `distclean`; removes autoconf-generated files in addition to those removed by
the "clean" target,
- `install`; installs all distribution files in their corresponding locations
(also see "INSTALL/UNINSTALL SUPPORT"),
- `install-data`; installs all data files in their corresponding locations (also
see "INSTALL/UNINSTALL SUPPORT"),
- `install-exec`; installs all executable files in their corresponding locations
(also see "INSTALL/UNINSTALL SUPPORT"),
- `install-headers`; installs all include files in their corresponding locations
(also see "INSTALL/UNINSTALL SUPPORT"),
- `install-libs`; installs all library files in their corresponding locations
(also see "INSTALL/UNINSTALL SUPPORT"), and
- `uninstall`; removes all distribution files from their corresponding locations
(also see "INSTALL/UNINSTALL SUPPORT").
### Object Files
Object files (the result of compiling a C or C++ source file) have the
extension ".o".
### Programs
Program files are the result of linking object files and libraries together to
form an executable file. A typical program target looks like:
program: $(OBJS)
TAB echo Linking $@...
TAB $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
### Static Libraries
Static libraries have a prefix of "lib" and the extension ".a". A typical
static library target looks like:
libname.a: $(OBJECTS)
TAB echo Creating $@...
TAB $(RM) $@
TAB $(AR) $(ARFLAGS) $@ $(OBJECTS)
TAB $(RANLIB) $@
### Shared Libraries
Shared libraries have a prefix of "lib" and the extension ".dylib" or ".so"
depending on the operating system. A typical shared library is composed of
several targets that look like:
libname.so: $(OBJECTS)
TAB echo $(DSOCOMMAND) libname.so.$(DSOVERSION) ...
TAB $(DSOCOMMAND) libname.so.$(DSOVERSION) $(OBJECTS)
TAB $(RM) libname.so libname.so.$(DSOMAJOR)
TAB $(LN) libname.so.$(DSOVERSION) libname.so.$(DSOMAJOR)
TAB $(LN) libname.so.$(DSOVERSION) libname.so
libname.dylib: $(OBJECTS)
TAB echo $(DSOCOMMAND) libname.$(DSOVERSION).dylib ...
TAB $(DSOCOMMAND) libname.$(DSOVERSION).dylib \
TAB TAB -install_name $(libdir)/libname.$(DSOMAJOR).dylib \
TAB TAB -current_version libname.$(DSOVERSION).dylib \
TAB TAB -compatibility_version $(DSOMAJOR).0 \
TAB TAB $(OBJECTS) $(LIBS)
TAB $(RM) libname.dylib
TAB $(RM) libname.$(DSOMAJOR).dylib
TAB $(LN) libname.$(DSOVERSION).dylib libname.$(DSOMAJOR).dylib
TAB $(LN) libname.$(DSOVERSION).dylib libname.dylib
### Dependencies
Static dependencies are expressed in each makefile following the target, for
example:
foo: bar
Static dependencies are only used when it is not possible to automatically
generate them. Automatic dependencies are stored in a file named
"Dependencies" and included at the end of the makefile. The following "depend"
target rule is used to create the automatic dependencies:
depend:
TAB $(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
We regenerate the automatic dependencies on an macOS system and express any
non-macOS dependencies statically in the makefile.
### Install/Uninstall Support
All makefiles contains install and uninstall rules which install or remove the
corresponding software. These rules must use the $(BUILDROOT) variable as a
prefix to any installation directory so that CUPS can be installed in a
temporary location for packaging by programs like rpmbuild.
The `INSTALL_BIN`, `INSTALL_COMPDATA`, `INSTALL_CONFIG`, `INSTALL_DATA`,
`INSTALL_DIR`, `INSTALL_LIB`, `INSTALL_MAN`, and `INSTALL_SCRIPT` variables
must be used when installing files so that the proper ownership and permissions
are set on the installed files.
The `$(RANLIB)` command must be run on any static libraries after installation
since the symbol table is invalidated when the library is copied on some
platforms.
-227
Ver Arquivo
@@ -1,227 +0,0 @@
INSTALL - CUPS v2.3.3 - 2020-04-24
==================================
This file describes how to compile and install CUPS from source code. For more
information on CUPS see the file called "README.md". A complete change log can
be found in "CHANGES.md".
Using CUPS requires additional third-party support software and printer drivers.
These are typically included with your operating system distribution. Apple
does not endorse or support third-party support software for CUPS.
> Note: Current versions of macOS DO NOT allow installation to /usr with the
> default System Integrity Protection (SIP) settings. In addition, we do not
> recommend replacing the CUPS supplied with macOS because:
>
> a. not all versions of CUPS are compatible with every macOS release,
>
> b. code signing prevents replacement of system libraries and access to the
> system keychain (needed for encrypted printer sharing), and
>
> c. software updates will often replace parts of your local installation,
> potentially rendering your system unusable.
>
> Apple only supports using the Clang supplied with Xcode to build CUPS on
> macOS.
BEFORE YOU BEGIN
----------------
You'll need ANSI-compliant C and C++ compilers, plus a make program and POSIX-
compliant shell (/bin/sh). The GNU compiler tools and Bash work well and we
have tested the current CUPS code against several versions of GCC with excellent
results.
The makefiles used by the project should work with most 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) since BSD make does not
support "include".
Besides these tools you'll want ZLIB library for compression support, the GNU
TLS library for encryption support on platforms other than iOS, macOS, or
Windows, and either MIT (1.6.3 or higher) or Heimdal Kerberos for Kerberos
support. CUPS will compile and run without these, however you'll miss out on
many of the features provided by CUPS.
On a stock Ubuntu install, the following command will install the required
prerequisites:
sudo apt-get install autoconf build-essential libavahi-client-dev \
libgnutls28-dev libkrb5-dev libnss-mdns libpam-dev \
libsystemd-dev libusb-1.0-0-dev zlib1g-dev
Also, please note that CUPS does not include print filters to support PDF or
raster printing. You *must* download GPL Ghostscript and/or the Open Printing
CUPS filters package separately to print on operating systems other than macOS.
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:
./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:
./configure --prefix=/some/directory
> Note: Current versions of macOS DO NOT allow installation to /usr with the
> default System Integrity Protection (SIP) settings.
To see a complete list of configuration options, use the `--help` option:
./configure --help
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:
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 ...
or:
CFLAGS="-I/some/directory" \
CPPFLAGS="-I/some/directory" \
CXXFLAGS="-I/some/directory" \
DSOFLAGS="-L/some/directory" \
LDFLAGS="-L/some/directory" \
./configure ...
The `--enable-debug` option compiles CUPS with debugging information enabled.
Additional debug logging support can be enabled using the
`--enable-debug-printfs` option - these debug messages are enabled using the
`CUPS_DEBUG_xxx` environment variables at run-time.
CUPS also includes an extensive set of unit tests that can be used to find and
diagnose a variety of common problems - use the "--enable-unit-tests" configure
option to run them at build time.
On macOS, use the `--with-archflags` option to build with the correct set of
architectures:
./configure --with-archflags="-arch i386 -arch x86_64" ...
Once you have configured things, just type:
make ENTER
or if you have FreeBSD, NetBSD, or OpenBSD type:
gmake ENTER
to build the software.
TESTING THE SOFTWARE
--------------------
Aside from the built-in unit tests, CUPS includes an automated test framework
for testing the entire printing system. To run the tests, just type:
make check ENTER
or if you have FreeBSD, NetBSD, or OpenBSD type:
gmake check ENTER
The test framework runs a copy of the CUPS scheduler (cupsd) on port 8631 in
/tmp/cups-$USER and produces a nice HTML report of the results.
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:
make install ENTER
or for FreeBSD, NetBSD, or OpenBSD:
gmake install ENTER
Use the BUILDROOT variable to install to an alternate root directory:
make BUILDROOT=/some/other/root/directory install ENTER
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.
You can find the RPM software at:
http://www.rpm.org/
The EPM software is available at:
https://michaelrsweet.github.io/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:
make <format> ENTER
or
gmake <format> ENTER
for FreeBSD, NetBSD, and OpenBSD. The <format> target is one of the following:
- "epm": Builds a script + tarfile package
- "bsd": Builds a *BSD package
- "deb": Builds a Debian package
- "pkg": Builds a Solaris package
- "rpm": Builds a RPM package
- "slackware": Build a Slackware package
GETTING DEBUG LOGGING FROM CUPS
-------------------------------
When configured with the `--enable-debug-printfs` option, CUPS compiles in
additional debug logging support in the scheduler, CUPS API, and CUPS Imaging
API. The following environment variables are used to enable and control debug
logging:
- `CUPS_DEBUG_FILTER`: Specifies a POSIX regular expression to control which
messages are logged.
- `CUPS_DEBUG_LEVEL`: Specifies a number from 0 to 9 to control the verbosity of
the logging. The default level is 1.
- `CUPS_DEBUG_LOG`: Specifies a log file to use. Specify the name "-" to send
the messages to stderr. Prefix a filename with "+" to append to an existing
file. You can include a single "%d" in the filename to embed the current
process ID.
REPORTING PROBLEMS
------------------
If you have problems, *read the documentation first*! If the documentation does
not solve your problems, please post a message on the users forum at:
https://www.cups.org/
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.
+174
Ver Arquivo
@@ -0,0 +1,174 @@
INSTALL - CUPS v1.2rc1 - 2006-03-24
-----------------------------------
This file describes how to compile and install CUPS from source
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 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 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).
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.
Also, please note that CUPS no longer includes the
Ghostscript- based pstoraster filter. You *must* download
ESP Ghostscript separately from the CUPS web site if you want
to print PostScript files to non-PostScript printers.
COMPILING FROM SUBVERSION
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.52 or higher) before compiling the
software from Subversion:
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:
./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:
./configure --prefix=/some/directory
To see a complete list of configuration options, use the
--help option:
./configure --help
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:
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 ...
or:
CFLAGS="-I/some/directory" \
CPPFLAGS="-I/some/directory" \
CXXFLAGS="-I/some/directory" \
DSOFLAGS="-L/some/directory" \
LDFLAGS="-L/some/directory" \
./configure ...
Once you have configured things, just type:
make ENTER
or if you have FreeBSD, NetBSD, or OpenBSD type:
gmake ENTER
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:
make install ENTER
or for FreeBSD, NetBSD, or OpenBSD:
gmake install ENTER
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:
http://www.rpm.org/
The EPM software is available at:
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:
make <format> ENTER
or
gmake <format> ENTER
for FreeBSD, NetBSD, and OpenBSD. The <format> target is one of
the following:
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 post a
message on the "cups.general" forum at:
http://www.cups.org/newsgroups.php
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.
-202
Ver Arquivo
@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+964
Ver Arquivo
@@ -0,0 +1,964 @@
Common UNIX Printing System License Agreement
Copyright 1997-2006 by Easy Software Products
44141 AIRPORT VIEW DR STE 204
HOLLYWOOD, MARYLAND 20636 USA
Voice: +1.301.373.9600
Email: cups-info@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.
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.
For those not familiar with the GNU GPL, the license basically
allows you to:
- Use the CUPS software at no charge.
- Distribute verbatim copies of the software in source or
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.
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.
LICENSE EXCEPTIONS
In addition, as the copyright holder of CUPS, Easy Software
Products grants the following special exceptions:
1. Apple Operating System Development License Exception;
a. Software that is developed by any person or entity
for an Apple Operating System ("Apple OS-Developed
Software"), including but not limited to Apple and
third party printer drivers, filters, and backends
for an Apple Operating System, that is linked to the
CUPS imaging library or based on any sample filters
or backends provided with CUPS shall not be
considered to be a derivative work or collective work
based on the CUPS program and is exempt from the
mandatory source code release clauses of the GNU GPL.
You may therefore distribute linked combinations of
the CUPS imaging library with Apple OS-Developed
Software without releasing the source code of the
Apple OS-Developed Software. You may also use sample
filters and backends provided with CUPS to develop
Apple OS-Developed Software without releasing the
source code of the Apple OS-Developed Software.
b. An Apple Operating System means any operating system
software developed and/or marketed by Apple Computer,
Inc., including but not limited to all existing
releases and versions of Apple's Darwin, Mac OS X,
and Mac OS X Server products and all follow-on
releases and future versions thereof.
c. This exception is only available for Apple
OS-Developed Software and does not apply to software
that is distributed for use on other operating
systems.
d. All CUPS software that falls under this license
exception have the following text at the top of each
source file:
This file is subject to the Apple OS-Developed
Software exception.
2. OpenSSL Toolkit License Exception;
a. Easy Software Products 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.
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@glyphandcog.com
WWW: http://www.glyphandcog.com/
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/
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
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
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 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!
+112 -123
Ver Arquivo
@@ -1,19 +1,26 @@
#
# Common makefile definitions for CUPS.
# "$Id$"
#
# Copyright © 2007-2019 by Apple Inc.
# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
# Common makefile definitions for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
# 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:
#
# CUPS version...
# 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
#
CUPS_VERSION = @CUPS_VERSION@
#
# Programs...
@@ -21,38 +28,34 @@ CUPS_VERSION = @CUPS_VERSION@
AR = @AR@
AWK = @AWK@
CC = @LIBTOOL_CC@ @CC@
CHMOD = @CHMOD@
CXX = @LIBTOOL_CXX@ @CXX@
CC = @LIBTOOL@ @CC@
CXX = @LIBTOOL@ @CXX@
DSO = @DSO@
DSOXX = @DSOXX@
GZIPPROG = @GZIPPROG@
HTMLDOC = @HTMLDOC@
INSTALL = @INSTALL@
LD = @LD@
LD_CC = @LD_CC@
LD_CXX = @LD_CXX@
LIBTOOL = @LIBTOOL@
LN = @LN@ -sf
MKDIR = @MKDIR@ -p
MV = @MV@
PHPCONFIG = @PHPCONFIG@
RANLIB = @RANLIB@
RM = @RM@ -f
RMDIR = @RMDIR@
SED = @SED@
SHELL = /bin/sh
STRIP = @STRIP@
#
# Installation programs...
#
INSTALL_BIN = @LIBTOOL_INSTALL@ $(INSTALL) -c -m @CUPS_EXE_FILE_PERM@ @INSTALL_STRIP@
INSTALL_COMPDATA = $(INSTALL) -c -m 444 @INSTALL_GZIP@
INSTALL_CONFIG = $(INSTALL) -c -m @CUPS_CONFIG_FILE_PERM@
INSTALL_DATA = $(INSTALL) -c -m 444
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@ $(INSTALL) -c -m @CUPS_EXE_FILE_PERM@ @INSTALL_STRIP@
INSTALL_MAN = $(INSTALL) -c -m 444
INSTALL_SCRIPT = $(INSTALL) -c -m @CUPS_EXE_FILE_PERM@
INSTALL_LIB = $(LIBTOOL) $(INSTALL) -m 755
INSTALL_MAN = $(INSTALL) -m 644
INSTALL_SCRIPT = $(INSTALL) -m 755
#
# Default user, group, and system groups for the scheduler...
@@ -68,7 +71,6 @@ CUPS_PRIMARY_SYSTEM_GROUP = @CUPS_PRIMARY_SYSTEM_GROUP@
#
CUPS_CONFIG_FILE_PERM = @CUPS_CONFIG_FILE_PERM@
CUPS_CUPSD_FILE_PERM = @CUPS_CUPSD_FILE_PERM@
CUPS_LOG_FILE_PERM = @CUPS_LOG_FILE_PERM@
#
@@ -76,16 +78,6 @@ CUPS_LOG_FILE_PERM = @CUPS_LOG_FILE_PERM@
#
LANGUAGES = @LANGUAGES@
INSTALL_LANGUAGES = @INSTALL_LANGUAGES@
UNINSTALL_LANGUAGES = @UNINSTALL_LANGUAGES@
#
# Cross-compilation support: "local" target is used for any tools that are
# built and run locally.
#
LOCALTARGET = @LOCALTARGET@
#
# Libraries...
@@ -93,15 +85,13 @@ LOCALTARGET = @LOCALTARGET@
LIBCUPS = @LIBCUPS@
LIBCUPSIMAGE = @LIBCUPSIMAGE@
LIBCUPSOBJS = @LIBCUPSOBJS@
LIBCUPSSTATIC = @LIBCUPSSTATIC@
LIBGSSAPI = @LIBGSSAPI@
LIBHEADERS = @LIBHEADERS@
LIBHEADERSPRIV = @LIBHEADERSPRIV@
LIBJPEG = @LIBJPEG@
LIBLDAP = @LIBLDAP@
LIBMALLOC = @LIBMALLOC@
LIBPAPER = @LIBPAPER@
LIBUSB = @LIBUSB@
LIBWRAP = @LIBWRAP@
LIBPNG = @LIBPNG@
LIBSLP = @LIBSLP@
LIBTIFF = @LIBTIFF@
LIBZ = @LIBZ@
#
@@ -110,81 +100,66 @@ LIBZ = @LIBZ@
INSTALLSTATIC = @INSTALLSTATIC@
#
# IPP backend aliases...
#
IPPALIASES = @IPPALIASES@
#
# ippeveprinter commands...
#
IPPEVECOMMANDS = @IPPEVECOMMANDS@
#
# Install XPC backends?
#
INSTALLXPC = @INSTALLXPC@
#
# Code signing...
#
CODE_SIGN = @CODE_SIGN@
CODE_SIGN_IDENTITY = -
#
# Program options...
#
# ARCHFLAGS Defines the default architecture build options.
# ARCHFLAGS Defines the default architecture build options, used
# when compiling separate 32/64-bit libraries.
# 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@ \
$(ONDEMANDFLAGS) $(OPTIONS)
ALL_CXXFLAGS = -I.. -D_CUPS_SOURCE $(CXXFLAGS) \
$(SSLFLAGS) @LARGEFILE@ @PTHREAD_FLAGS@ \
$(ONDEMANDFLAGS) $(OPTIONS)
ALL_DSOFLAGS = -L../cups @ARCHFLAGS@ @RELROFLAGS@ $(DSOFLAGS) $(OPTIM)
ALL_LDFLAGS = -L../cups @LDARCHFLAGS@ @RELROFLAGS@ $(LDFLAGS) \
@PIEFLAGS@ $(OPTIM)
ARCHFLAGS = @ARCHFLAGS@
ARFLAGS = @ARFLAGS@
BACKLIBS = @BACKLIBS@
BUILDDIRS = @BUILDDIRS@
CFLAGS = @CPPFLAGS@ @CFLAGS@
CFLAGS = -I.. $(RC_CFLAGS) $(SSLFLAGS) @CPPFLAGS@ @CFLAGS@ \
@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
COMMONLIBS = @LIBS@
CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@
CUPSDLIBS = @CUPSDLIBS@
CXXFLAGS = -I.. $(RC_CFLAGS) $(SSLFLAGS) @CPPFLAGS@ @CXXFLAGS@ \
@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
CXXLIBS = @CXXLIBS@
DBUS_NOTIFIER = @DBUS_NOTIFIER@
DBUS_NOTIFIERLIBS = @DBUS_NOTIFIERLIBS@
DNSSD_BACKEND = @DNSSD_BACKEND@
DSOFLAGS = @DSOFLAGS@
DNSSDLIBS = @DNSSDLIBS@
IPPFIND_BIN = @IPPFIND_BIN@
IPPFIND_MAN = @IPPFIND_MAN@
LDFLAGS = @LDFLAGS@
LINKCUPS = @LINKCUPS@
LINKCUPSSTATIC = ../cups/$(LIBCUPSSTATIC) $(LIBS)
LIBS = $(LIBGSSAPI) $(DNSSDLIBS) $(SSLLIBS) $(LIBZ) $(COMMONLIBS)
ONDEMANDFLAGS = @ONDEMANDFLAGS@
ONDEMANDLIBS = @ONDEMANDLIBS@
DSOLIBS = @DSOLIBS@ $(COMMONLIBS)
IMGLIBS = @IMGLIBS@ -lm
IMGFILTERS = @IMGFILTERS@
LDFLAGS = -L../cups -L../filter $(RC_CFLAGS) $(ARCHFLAGS) \
@LDFLAGS@ $(OPTIM)
LINKCUPS = @LINKCUPS@ $(SSLLIBS)
LINKCUPSIMAGE = @LINKCUPSIMAGE@
LIBS = $(LINKCUPS) $(COMMONLIBS)
OPTIM = @OPTIM@
OPTIONS = @WARNING_OPTIONS@
OPTIONS =
PAMLIBS = @PAMLIBS@
SERVERLIBS = @SERVERLIBS@
PDFTOPS = @PDFTOPS@
PHPDIR = @PHPDIR@
SSLFLAGS = @SSLFLAGS@
SSLLIBS = @SSLLIBS@
UNITTESTS = @UNITTESTS@
LAUNCHDLIBS = @LAUNCHDLIBS@
#
# Separate 32/64-bit library support...
#
ARCH32FLAGS = @ARCH32FLAGS@
INSTALL32 = @INSTALL32@
LIB32CUPS = @LIB32CUPS@
LIB32CUPSIMAGE = @LIB32CUPSIMAGE@
LIB32DIR = $(BUILDROOT)@LIB32DIR@
UNINSTALL32 = @UNINSTALL32@
ARCH64FLAGS = @ARCH64FLAGS@
INSTALL64 = @INSTALL64@
LIB64CUPS = @LIB64CUPS@
LIB64CUPSIMAGE = @LIB64CUPSIMAGE@
LIB64DIR = $(BUILDROOT)@LIB64DIR@
UNINSTALL64 = @UNINSTALL64@
#
# Directories...
@@ -194,16 +169,12 @@ UNITTESTS = @UNITTESTS@
# 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@
@@ -213,50 +184,45 @@ localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
privateinclude = @privateinclude@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
top_srcdir = @top_srcdir@
BUILDROOT = $(DSTROOT)$(DESTDIR)
BUILDROOT = $(DSTROOT)
AMANDIR = $(BUILDROOT)@AMANDIR@
BINDIR = $(BUILDROOT)@bindir@
BUNDLEDIR = @CUPS_BUNDLEDIR@
CACHEDIR = $(BUILDROOT)@CUPS_CACHEDIR@
DATADIR = $(BUILDROOT)@CUPS_DATADIR@
DOCDIR = $(BUILDROOT)@CUPS_DOCROOT@
ICONDIR = @ICONDIR@
INCLUDEDIR = $(BUILDROOT)$(includedir)
INITDIR = @INITDIR@
INITDDIR = @INITDDIR@
LIBDIR = $(BUILDROOT)$(libdir)
LOCALEDIR = $(BUILDROOT)@CUPS_LOCALEDIR@
LOGDIR = $(BUILDROOT)@CUPS_LOGDIR@
MANDIR = $(BUILDROOT)@mandir@
MENUDIR = @MENUDIR@
PRIVATEINCLUDE = $(BUILDROOT)@PRIVATEINCLUDE@
RCLEVELS = @RCLEVELS@
RCSTART = @RCSTART@
RCSTOP = @RCSTOP@
PMANDIR = $(BUILDROOT)@PMANDIR@
REQUESTS = $(BUILDROOT)@CUPS_REQUESTS@
RESOURCEDIR = @CUPS_RESOURCEDIR@
SBINDIR = $(BUILDROOT)@sbindir@
SERVERBIN = $(BUILDROOT)@CUPS_SERVERBIN@
SERVERROOT = $(BUILDROOT)@CUPS_SERVERROOT@
STATEDIR = $(BUILDROOT)@CUPS_STATEDIR@
XINETD = @XINETD@
MAN1EXT = @MAN1EXT@
MAN5EXT = @MAN5EXT@
MAN7EXT = @MAN7EXT@
MAN8EXT = @MAN8EXT@
MAN8DIR = @MAN8DIR@
PAMDIR = @PAMDIR@
PAMFILE = @PAMFILE@
DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@
DBUSDIR = @DBUSDIR@
INITDIR = @INITDIR@
INITDDIR = @INITDDIR@
LAUNCHD_DIR = @LAUNCHD_DIR@
SMFMANIFESTDIR = @SMFMANIFESTDIR@
SYSTEMD_DIR = @SYSTEMD_DIR@
XINETD = @XINETD@
USBQUIRKS = @USBQUIRKS@
#
@@ -264,12 +230,35 @@ USBQUIRKS = @USBQUIRKS@
#
.SILENT:
.SUFFIXES: .a .c .cxx .h .o
.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) $(ARCHFLAGS) $(OPTIM) $(ALL_CFLAGS) -c -o $@ $<
$(CC) $(ARCHFLAGS) $(OPTIM) $(CFLAGS) -c $<
.c.32.o:
echo Compiling 32-bit $<...
$(CC) $(ARCH32FLAGS) $(OPTIM) $(CFLAGS) -c -o $@ $<
.c.64.o:
echo Compiling 64-bit $<...
$(CC) $(ARCH64FLAGS) $(OPTIM) $(CFLAGS) -c -o $@ $<
.cxx.o:
echo Compiling $<...
$(CXX) $(ARCHFLAGS) $(OPTIM) $(ALL_CXXFLAGS) -c -o $@ $<
$(CXX) $(ARCHFLAGS) $(OPTIM) $(CXXFLAGS) -c $<
.man.1 .man.1m .man.5 .man.7 .man.8:
echo Linking $<...
$(RM) $@
$(LN) $< $@
.man.1.gz .man.1m.gz .man.5.gz .man.7.gz .man.8.gz .man.gz:
echo -n Compressing $<...
$(RM) $@
gzip -v9 <$< >$@
#
# End of "$Id$"
#
+127 -198
Ver Arquivo
@@ -1,28 +1,37 @@
#
# Top-level Makefile for CUPS.
# "$Id$"
#
# Copyright © 2007-2019 by Apple Inc.
# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
# Top-level Makefile for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
# 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
#
include Makedefs
#
# Directories to make...
#
DIRS = cups $(BUILDDIRS)
#
# Test suite options - normally blank, override with make command...
#
TESTOPTIONS =
DIRS = cups backend berkeley cgi-bin filter locale man monitor \
notifier $(PDFTOPS) scheduler systemv test \
$(PHPDIR) \
conf data doc fonts ppd templates
#
@@ -31,55 +40,9 @@ TESTOPTIONS =
all:
chmod +x cups-config
echo Using ARCHFLAGS="$(ARCHFLAGS)"
echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
echo Using CC="$(CC)"
echo Using CXX="$(CC)"
echo Using DSOFLAGS="$(DSOFLAGS)"
echo Using LDFLAGS="$(LDFLAGS)"
echo Using LIBS="$(LIBS)"
for dir in $(DIRS); do\
echo Making all in $$dir... ;\
(cd $$dir ; $(MAKE) $(MFLAGS) all $(UNITTESTS)) || exit 1;\
done
#
# Make library targets...
#
libs:
echo Using ARCHFLAGS="$(ARCHFLAGS)"
echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
echo Using CC="$(CC)"
echo Using CXX="$(CC)"
echo Using DSOFLAGS="$(DSOFLAGS)"
echo Using LDFLAGS="$(LDFLAGS)"
echo Using LIBS="$(LIBS)"
for dir in $(DIRS); do\
echo Making libraries in $$dir... ;\
(cd $$dir ; $(MAKE) $(MFLAGS) libs) || exit 1;\
done
#
# Make unit test targets...
#
unittests:
echo Using ARCHFLAGS="$(ARCHFLAGS)"
echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
echo Using CC="$(CC)"
echo Using CXX="$(CC)"
echo Using DSOFLAGS="$(DSOFLAGS)"
echo Using LDFLAGS="$(LDFLAGS)"
echo Using LIBS="$(LIBS)"
for dir in $(DIRS); do\
echo Making all in $$dir... ;\
(cd $$dir ; $(MAKE) $(MFLAGS) unittests) || exit 1;\
(cd $$dir ; $(MAKE) $(MFLAGS)) || exit 1;\
done
@@ -94,24 +57,6 @@ clean:
done
#
# Remove all non-distribution files...
#
distclean: clean
$(RM) Makedefs config.h config.log config.status
$(RM) conf/cups-files.conf conf/cupsd.conf conf/mime.convs conf/pam.std conf/snmp.conf
$(RM) cups-config
$(RM) desktop/cups.desktop
$(RM) doc/index.html
$(RM) packaging/cups.list
$(RM) scheduler/cups-lpd.xinetd scheduler/cups.sh scheduler/cups.xml scheduler/org.cups.cups-lpd.plist scheduler/org.cups.cups-lpdAT.service scheduler/org.cups.cupsd.path scheduler/org.cups.cupsd.service scheduler/org.cups.cupsd.socket
$(RM) templates/header.tmpl
-$(RM) doc/*/index.html
-$(RM) templates/*/header.tmpl
-$(RM) -r autom4te*.cache cups/charmaps cups/locale
#
# Make dependencies
#
@@ -124,92 +69,78 @@ depend:
#
# Run the STACK tool on the sources, available here:
#
# http://css.csail.mit.edu/stack/
#
# Do the following to pass options to configure:
#
# make CONFIGFLAGS="--foo --bar" stack
# Install object and target files...
#
.PHONY: stack
stack:
stack-build ./configure $(CONFIGFLAGS)
stack-build $(MAKE) $(MFLAGS) clean all
poptck
$(MAKE) $(MFLAGS) distclean
$(RM) */*.ll
$(RM) */*.ll.out
#
# Generate a ctags file...
#
ctags:
ctags -R .
#
# Install everything...
#
install: install-data install-headers install-libs install-exec
#
# Install data files...
#
install-data:
echo Making all in cups...
(cd cups; $(MAKE) $(MFLAGS) all)
install: installhdrs
for dir in $(DIRS); do\
echo Installing data files in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install-data) || exit 1;\
echo Installing in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install) || exit 1;\
done
echo Installing cups-config script...
$(INSTALL_DIR) -m 755 $(BINDIR)
$(INSTALL_SCRIPT) cups-config $(BINDIR)/cups-config
#
# Install header files...
#
install-headers:
for dir in $(DIRS); do\
echo Installing header files in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install-headers) || exit 1;\
done
if test "x$(privateinclude)" != x; then \
echo Installing config.h into $(PRIVATEINCLUDE)...; \
$(INSTALL_DIR) -m 755 $(PRIVATEINCLUDE); \
$(INSTALL_DATA) config.h $(PRIVATEINCLUDE)/config.h; \
echo Installing startup script...
if test "x$(INITDIR)" != x; then \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/init.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc0.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc2.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc3.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc5.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
fi
if test "x$(INITDIR)" = x -a "x$(INITDDIR)" != x; then \
$(INSTALL_DIR) $(BUILDROOT)$(INITDDIR); \
if test "$(INITDDIR)" = "/System/Library/StartupItems/PrintingServices"; then \
$(INSTALL_SCRIPT) init/PrintingServices $(BUILDROOT)$(INITDDIR)/PrintingServices; \
$(INSTALL_DATA) init/StartupParameters.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
$(INSTALL_DATA) init/Localizable.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
$(INSTALL_DATA) init/org.cups.cupsd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \
else \
$(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); \
$(INSTALL_DATA) packaging/cups-dbus.conf $(BUILDROOT)$(DBUSDIR)/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 -d /usr/share/applications; then \
echo Installing desktop icons...; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)/usr/share/applications; \
$(INSTALL_DATA) desktop/cups.desktop $(BUILDROOT)/usr/share/applications; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)/usr/share/icons/hicolor/16x16/apps; \
$(INSTALL_DATA) desktop/cups-16.png $(BUILDROOT)/usr/share/icons/hicolor/16x16/apps/cups.png; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)/usr/share/icons/hicolor/32x32/apps; \
$(INSTALL_DATA) desktop/cups-32.png $(BUILDROOT)/usr/share/icons/hicolor/32x32/apps/cups.png; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)/usr/share/icons/hicolor/64x64/apps; \
$(INSTALL_DATA) desktop/cups-64.png $(BUILDROOT)/usr/share/icons/hicolor/64x64/apps/cups.png; \
$(INSTALL_DIR) -m 755 $(BUILDROOT)/usr/share/icons/hicolor/128x128/apps; \
$(INSTALL_DATA) desktop/cups-128.png $(BUILDROOT)/usr/share/icons/hicolor/128x128/apps/cups.png; \
fi
#
# Install programs...
# Install source and header files...
#
install-exec: all
for dir in $(DIRS); do\
echo Installing programs in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install-exec) || exit 1;\
done
installsrc:
gnutar --dereference --exclude=.svn -cf - . | gnutar -C $(SRCROOT) -xf -
#
# Install libraries...
#
install-libs: libs
for dir in $(DIRS); do\
echo Installing libraries in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install-libs) || exit 1;\
done
installhdrs:
(cd cups ; $(MAKE) $(MFLAGS) installhdrs) || exit 1;\
(cd filter ; $(MAKE) $(MFLAGS) installhdrs) || exit 1;
#
@@ -224,69 +155,67 @@ uninstall:
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)$(DEFAULT_LAUNCHD_CONF); \
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...
#
test: all unittests
check test: all
echo Running CUPS test suite...
cd test; ./run-stp-tests.sh $(TESTOPTIONS)
check: all unittests
echo Running CUPS test suite with defaults...
cd test; ./run-stp-tests.sh 1 0 n n
debugcheck: all unittests
echo Running CUPS test suite with debug printfs...
cd test; ./run-stp-tests.sh 1 0 n y
cd test; ./run-stp-tests.sh
#
# Create HTML documentation using codedoc (http://www.msweet.org/codedoc)...
# Make software distributions using EPM (http://www.easysw.com/epm/)...
#
apihelp:
for dir in cups filter; do\
echo Generating API help in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) apihelp) || exit 1;\
done
EPMFLAGS = -v
#
# Lines of code computation...
#
sloc:
for dir in cups scheduler; do \
(cd $$dir; $(MAKE) $(MFLAGS) sloc) || exit 1;\
done
#
# Make software distributions using EPM (http://www.msweet.org/)...
#
EPMFLAGS = -v --output-dir dist $(EPMARCH)
bsd deb epm pkg rpm slackware:
aix bsd deb depot inst osx pkg rpm setld slackware swinstall tardist:
epm $(EPMFLAGS) -f $@ cups packaging/cups.list
.PHONY: dist
dist: all
$(RM) -r dist
$(MAKE) $(MFLAGS) epm
case `uname` in \
*BSD*) $(MAKE) $(MFLAGS) bsd;; \
Linux*) test ! -x /usr/bin/rpm || $(MAKE) $(MFLAGS) rpm;; \
SunOS*) $(MAKE) $(MFLAGS) pkg;; \
esac
epm:
epm $(EPMFLAGS) cups packaging/cups.list
#
# Don't run top-level build targets in parallel...
# End of "$Id$".
#
.NOTPARALLEL:
-51
Ver Arquivo
@@ -1,51 +0,0 @@
CUPS
Copyright © 2007-2019 by Apple Inc.
Copyright © 1997-2007 by Easy Software Products.
CUPS and the CUPS logo are trademarks of Apple Inc.
The MD5 Digest code is Copyright 1999 Aladdin Enterprises.
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.
-- CUPS Exceptions to the Apache 2.0 License --
As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into an Object form of such source code, you
may redistribute such embedded portions in such Object form without complying
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
In addition, if you combine or link compiled forms of this Software with
software that is licensed under the GPLv2 ("Combined Software") and if a
court of competent jurisdiction determines that the patent provision (Section
3), the indemnity provision (Section 9) or other Section of the License
conflicts with the conditions of the GPLv2, you may retroactively and
prospectively choose to deem waived or otherwise exclude such Section(s) of
the License, but only in their entirety and only with respect to the Combined
Software.
-170
Ver Arquivo
@@ -1,170 +0,0 @@
README - CUPS v2.3.3 - 2020-04-24
=================================
INTRODUCTION
------------
CUPS is a standards-based, open source printing system developed by Apple Inc.
for macOS® and other UNIX®-like operating systems. CUPS uses the Internet
Printing Protocol ("IPP") and provides System V and Berkeley command-line
interfaces, a web interface, and a C API to manage printers and print jobs. It
supports printing to both local (parallel, serial, USB) and networked printers,
and printers can be shared from one computer to another, even over the Internet!
Internally, CUPS uses PostScript Printer Description ("PPD") files to describe
printer capabilities and features and a wide variety of generic and device-
specific programs to convert and print many types of files. Sample drivers are
included with CUPS to support many Dymo, EPSON, HP, Intellitech, OKIDATA, and
Zebra printers. Many more drivers are available online and (in some cases) on
the driver CD-ROM that came with your printer.
CUPS is licensed under the Apache License Version 2.0. See the file
"LICENSE" for more information.
READING THE DOCUMENTATION
-------------------------
Initial documentation to get you started is provided in the root directory of
the CUPS sources:
- `CHANGES.md`: A list of changes in the current major release of CUPS.
- `CONTRIBUTING.md`: Guidelines for contributing to the CUPS project.
- `CREDITS.md`: A list of past contributors to the CUPS project.
- `DEVELOPING.md`: Guidelines for developing code for the CUPS project.
- `INSTALL.md`: Instructions for building and installing CUPS.
- `LICENSE`: The CUPS license agreement (Apache 2.0).
- `NOTICE`: Copyright notices and exceptions to the CUPS license agreement.
- `README.md`: This file.
Once you have installed the software you can access the documentation (and a
bunch of other stuff) online at <http://localhost:631/> and using the `man`
command, for example `man cups`.
If you're having trouble getting that far, the documentation is located under
the `doc/help` and `man` directories.
Please read the documentation before asking questions.
GETTING SUPPORT AND OTHER RESOURCES
-----------------------------------
If you have problems, *read the documentation first!* We also provide two
mailing lists which are available at <https://lists.cups.org/mailman/listinfo>.
See the CUPS web site at <https://www.cups.org/> for other resources.
SETTING UP PRINTER QUEUES USING YOUR WEB BROWSER
------------------------------------------------
CUPS includes a web-based administration tool that allows you to manage
printers, classes, and jobs on your server. Open <http://localhost:631/admin/>
in your browser to access the printer administration tools:
*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.
You will be asked for the administration password (root or any other user in the
"sys", "system", "root", "admin", or "lpadmin" group on your system) when
performing any administrative function.
SETTING UP PRINTER QUEUES FROM THE COMMAND-LINE
-----------------------------------------------
CUPS currently uses PPD (PostScript Printer Description) files that describe
printer capabilities and driver programs needed for each printer. The
`everywhere` PPD is used for nearly all modern networks printers sold since
about 2009. For example, the following command creates a print queue for a
printer at address "11.22.33.44":
lpadmin -p printername -E -v ipp://11.22.33.44/ipp/print -m everywhere
CUPS also includes several sample PPD files you can use for "legacy" printers:
Driver | PPD Name
----------------------------- | ------------------------------
Dymo Label Printers | drv:///sample.drv/dymo.ppd
Intellitech Intellibar | drv:///sample.drv/intelbar.ppd
EPSON 9-pin Series | drv:///sample.drv/epson9.ppd
EPSON 24-pin Series | drv:///sample.drv/epson24.ppd
Generic PCL Laser Printer | drv:///sample.drv/generpcl.ppd
Generic PostScript Printer | drv:///sample.drv/generic.ppd
HP DeskJet Series | drv:///sample.drv/deskjet.ppd
HP LaserJet Series | drv:///sample.drv/laserjet.ppd
OKIDATA 9-Pin Series | drv:///sample.drv/okidata9.ppd
OKIDATA 24-Pin Series | drv:///sample.drv/okidat24.ppd
Zebra CPCL Label Printer | drv:///sample.drv/zebracpl.ppd
Zebra EPL1 Label Printer | drv:///sample.drv/zebraep1.ppd
Zebra EPL2 Label Printer | drv:///sample.drv/zebraep2.ppd
Zebra ZPL Label Printer | drv:///sample.drv/zebra.ppd
You can run the `lpinfo -m` command to list all of the available drivers:
lpinfo -m
Run the `lpinfo -v` command to list the available printers:
lpinfo -v
Then use the correct URI to add the printer using the `lpadmin` command:
lpadmin -p printername -E -v device-uri -m ppd-name
Current network printers typically use `ipp` or `ipps` URIS:
lpadmin -p printername -E -v ipp://11.22.33.44/ipp/print -m everywhere
lpadmin -p printername -E -v ipps://11.22.33.44/ipp/print -m everywhere
Older network printers typically use `socket` or `lpd` URIs:
lpadmin -p printername -E -v socket://11.22.33.44 -m ppd-name
lpadmin -p printername -E -v lpd://11.22.33.44/ -m ppd-name
The sample drivers provide basic printing capabilities, but generally do not
exercise the full potential of the printers or CUPS. Other drivers provide
greater printing capabilities.
PRINTING FILES
--------------
CUPS provides both the System V `lp` and Berkeley `lpr` commands for printing:
lp filename
lpr filename
Both the `lp` and `lpr` commands support printing options for the driver:
lp -o media=A4 -o resolution=600dpi filename
lpr -o media=A4 -o resolution=600dpi filename
CUPS recognizes many types of images files as well as PDF, PostScript, 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:
lp -o raw filename
lpr -l filename
This will prevent the filters from misinterpreting your print file.
LEGAL STUFF
-----------
Copyright © 2007-2019 by Apple Inc.
Copyright © 1997-2007 by Easy Software Products.
CUPS is provided under the terms of the Apache License, Version 2.0 with
exceptions for GPL2/LGPL2 software. A copy of this license can be found in the
file `LICENSE`. Additional legal information is provided in the file `NOTICE`.
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
+206
Ver Arquivo
@@ -0,0 +1,206 @@
README - CUPS v1.2rc1 - 2006-03-24
----------------------------------
Looking for compile instructions? Read the file "INSTALL.txt"
instead...
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 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 GPL Ghostscript 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, 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.
READING THE DOCUMENTATION
Once you have installed the software you can access the
documentation (and a bunch of other stuff) on-line at:
http://localhost:631/
If you're having trouble getting that far, the documentation
is located under the "doc/help" directory.
Please read the documentation before asking questions.
GETTING SUPPORT AND OTHER RESOURCES
If you have problems, READ THE DOCUMENTATION FIRST! We also
provide many discussion forums which are available at:
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.
SETTING UP PRINTER QUEUES USING YOUR WEB BROWSER
CUPS 1.2 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/
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.
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 includes several sample PPD files 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
Zebra CPCL Label Printer zebracpl.ppd
Zebra EPL1 Label Printer zebraep1.ppd
Zebra EPL2 Label Printer zebraep2.ppd
Zebra ZPL Label Printer zebra.ppd
Run the "lpinfo" command to list the available printers:
lpinfo -v
Then use the correct URI to add the printer using the
"lpadmin" command:
lpadmin -p printername -E -v URI -m filename.ppd
Network printers typically use "socket" or "lpd" URIs:
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
The sample drivers provide basic printing capabilities, but
generally do not exercise the full potential of the printers
or CUPS. For fully-functional commercial printer drivers
check out our ESP Print Pro software at:
http://www.easysw.com/printpro/
PRINTING FILES
CUPS provides both the System V "lp" and Berkeley "lpr"
commands for printing:
lp filename
lpr filename
Both the "lp" and "lpr" commands support printing options for
the driver:
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.
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
This will prevent the filters from misinterpreting your print
file.
LEGAL STUFF
CUPS is Copyright 1993-2006 by Easy Software Products. CUPS,
the CUPS logo, and the Common UNIX Printing System are the
trademark property of Easy Software Products.
The MD5 Digest code is Copyright 1999 Aladdin Enterprises.
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.
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.
For commercial licensing information, please contact:
Attn: CUPS Licensing Information
Easy Software Products
44141 Airport View Drive, Suite 204
Hollywood, Maryland 20636 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.
+29 -72
Ver Arquivo
@@ -1,72 +1,29 @@
ipp.o: ipp.c backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/versioning.h \
../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h ../cups/ppd-private.h ../cups/ppd.h \
../cups/raster.h
lpd.o: lpd.c ../cups/http-private.h ../config.h ../cups/language.h \
../cups/array.h ../cups/versioning.h ../cups/http.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/pwg.h backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../cups/array-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h
dnssd.o: dnssd.c backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/versioning.h \
../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h
snmp.o: snmp.c backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/versioning.h \
../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h
socket.o: socket.c ../cups/http-private.h ../config.h ../cups/language.h \
../cups/array.h ../cups/versioning.h ../cups/http.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/pwg.h backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../cups/array-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h
test1284.o: test1284.c ../cups/string-private.h ../config.h \
../cups/versioning.h ieee1284.c backend-private.h \
../cups/cups-private.h ../cups/array-private.h ../cups/array.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h ../cups/ppd-private.h ../cups/ppd.h \
../cups/raster.h
testbackend.o: testbackend.c ../cups/string-private.h ../config.h \
../cups/versioning.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/sidechannel.h
testsupplies.o: testsupplies.c backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/versioning.h \
../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h
usb.o: usb.c backend-private.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/versioning.h \
../cups/array-private.h ../cups/array.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h ../cups/snmp-private.h ../cups/backend.h \
../cups/sidechannel.h usb-darwin.c ../cups/debug-private.h \
../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
../cups/raster.h
# DO NOT DELETE
betest.o: ../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/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/string.h
parallel.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
parallel.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
parallel.o: ../cups/language.h ../cups/string.h ../config.h ieee1284.c
parallel.o: ../cups/debug.h
scsi.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
scsi.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
scsi.o: ../cups/language.h ../cups/string.h ../config.h
serial.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
serial.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
serial.o: ../cups/language.h ../cups/string.h ../config.h
socket.o: ../cups/backend.h ../cups/http-private.h ../config.h ../cups/http.h
socket.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h
socket.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
socket.o: ../cups/string.h
test1284.o: ../cups/string.h ../config.h ieee1284.c ../cups/debug.h
usb.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
usb.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
usb.o: ../cups/language.h ../cups/string.h ../config.h
+90 -214
Ver Arquivo
@@ -1,57 +1,36 @@
#
# Backend makefile for CUPS.
# "$Id$"
#
# Copyright 2007-2019 by Apple Inc.
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
# Backend makefile for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more information.
# 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 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
# This file is subject to the Apple OS-Developed Software exception.
#
include ../Makedefs
#
# Object files...
#
# RBACKENDS are installed mode 0700 so cupsd will run them as root...
#
# UBACKENDS and ULBACKENDS are installed mode 0755 so cupsd will run them as
# an unprivileged user...
#
# See http://www.cups.org/doc/api-filter.html for more info...
RBACKENDS = \
ipp \
lpd \
$(DNSSD_BACKEND)
UBACKENDS = \
snmp \
socket
ULBACKENDS = \
usb
UNITTESTS = \
test1284 \
testbackend \
testsupplies
TARGETS = \
libbackend.a \
$(RBACKENDS) \
$(UBACKENDS) \
$(ULBACKENDS)
LIBOBJS = \
ieee1284.o \
network.o \
runloop.o \
snmp-supplies.o
OBJS = \
ipp.o \
lpd.o \
dnssd.o \
snmp.o \
socket.o \
test1284.o \
testbackend.o \
testsupplies.o \
usb.o
RBACKENDS = ipp lpd
UBACKENDS = parallel scsi serial socket usb
TARGETS = betest test1284 $(RBACKENDS) $(UBACKENDS)
OBJS = betest.o ipp.o lpd.o parallel.o scsi.o \
serial.o socket.o test1284.o usb.o
#
@@ -61,26 +40,12 @@ OBJS = \
all: $(TARGETS)
#
# Make library targets...
#
libs: $(ULBACKENDS)
#
# Make unit tests...
#
unittests: $(UNITTESTS)
#
# Clean all object files...
#
clean:
$(RM) $(OBJS) $(TARGETS) $(UNITTESTS) $(LIBOBJS) http https ipps mdns socket-static
$(RM) $(OBJS) $(TARGETS) http
#
@@ -88,91 +53,23 @@ clean:
#
depend:
$(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
makedepend -Y -I.. -fDependencies $(OBJS:.o=.c) >/dev/null 2>&1
#
# Install all targets...
#
install: all install-data install-headers install-libs install-exec
#
# Install data files...
#
install-data:
if test "x$(USBQUIRKS)" != x; then \
echo Installing USB quirks in $(USBQUIRKS); \
$(INSTALL_DIR) -m 755 $(USBQUIRKS); \
$(INSTALL_DATA) org.cups.usb-quirks $(USBQUIRKS); \
fi
#
# Install programs...
#
install-exec: $(INSTALLXPC)
echo Installing backends in $(SERVERBIN)/backend
install: all
$(INSTALL_DIR) -m 755 $(SERVERBIN)/backend
for file in $(RBACKENDS); do \
$(LIBTOOL) $(INSTALL_BIN) -m 700 $$file $(SERVERBIN)/backend; \
$(LIBTOOL) $(INSTALL) -m 700 $$file $(SERVERBIN)/backend; \
done
for file in $(UBACKENDS); do \
$(INSTALL_BIN) $$file $(SERVERBIN)/backend; \
done
for file in $(IPPALIASES); do \
$(RM) $(SERVERBIN)/backend/$$file; \
$(LN) ipp $(SERVERBIN)/backend/$$file; \
done
if test "x$(DNSSD_BACKEND)" != x -a `uname` = Darwin; then \
$(RM) $(SERVERBIN)/backend/mdns; \
$(LN) $(DNSSD_BACKEND) $(SERVERBIN)/backend/mdns; \
fi
if test "x$(SYMROOT)" != "x"; then \
$(INSTALL_DIR) $(SYMROOT); \
for file in $(RBACKENDS) $(UBACKENDS); do \
cp $$file $(SYMROOT); \
dsymutil $(SYMROOT)/$$file; \
done \
fi
install-xpc: ipp
echo Installing XPC backends in $(SERVERBIN)/apple
$(INSTALL_DIR) -m 755 $(SERVERBIN)/apple
$(LIBTOOL) $(INSTALL_BIN) ipp $(SERVERBIN)/apple
for file in $(IPPALIASES); do \
$(RM) $(SERVERBIN)/apple/$$file; \
$(LN) ipp $(SERVERBIN)/apple/$$file; \
done
#
# Install headers...
#
install-headers:
#
# Install libraries...
#
install-libs:
echo Installing backends in $(SERVERBIN)/backend
$(INSTALL_DIR) -m 755 $(SERVERBIN)/backend
for file in $(ULBACKENDS); do \
$(INSTALL_BIN) $$file $(SERVERBIN)/backend; \
done
if test "x$(SYMROOT)" != "x"; then \
$(INSTALL_DIR) $(SYMROOT); \
for file in $(ULBACKENDS); do \
cp $$file $(SYMROOT); \
dsymutil $(SYMROOT)/$$file; \
done \
fi
$(RM) $(SERVERBIN)/backend/http
$(LN) ipp $(SERVERBIN)/backend/http
#
@@ -180,137 +77,111 @@ install-libs:
#
uninstall:
$(RM) $(SERVERBIN)/apple/ipp
for file in $(IPPALIASES); do \
$(RM) $(SERVERBIN)/apple/$$file; \
done
-$(RMDIR) $(SERVERBIN)/apple
for file in $(RBACKENDS) $(UBACKENDS) $(ULBACKENDS); do \
$(RM) $(SERVERBIN)/backend/$$file; \
done
for file in $(IPPALIASES); do \
for file in $(RBACKENDS) $(UBACKENDS); do \
$(RM) $(SERVERBIN)/backend/$$file; \
done
$(RM) $(SERVERBIN)/backend/http
-$(RMDIR) $(SERVERBIN)/backend
-$(RMDIR) $(SERVERBIN)
#
# betest
#
betest: betest.o ../cups/$(LIBCUPS)
echo Linking $@...
$(CC) $(LDFLAGS) -o betest betest.o $(LIBS)
#
# test1284
#
test1284: test1284.o ../cups/$(LIBCUPSSTATIC)
test1284: test1284.o ../cups/libcups.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o test1284 test1284.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o test1284 test1284.o ../cups/libcups.a \
$(SSLLIBS) $(COMMONLIBS) $(LIBZ)
#
# testbackend
# ieee1394
#
testbackend: testbackend.o ../cups/$(LIBCUPSSTATIC)
ieee1394: ieee1394.o ieee1394-linux.o
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o testbackend testbackend.o $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o ieee1394 ieee1394.o ieee1394-linux.o -lraw1394 $(LIBS)
#
# testsupplies
#
testsupplies: testsupplies.o libbackend.a ../cups/$(LIBCUPSSTATIC)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o testsupplies testsupplies.o libbackend.a \
$(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
#
# libbackend.a
#
libbackend.a: $(LIBOBJS)
echo Archiving $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
#
# dnssd
#
dnssd: dnssd.o ../cups/$(LIBCUPS) libbackend.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o dnssd dnssd.o libbackend.a $(DNSSDLIBS) $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
if test `uname` = Darwin; then \
$(RM) mdns; \
$(LN) dnssd mdns; \
fi
ieee1394.o: ieee1394.h
ieee1394-linux.o: ieee1394.h
#
# ipp
#
ipp: ipp.o ../cups/$(LIBCUPS) libbackend.a
ipp: ipp.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o ipp ipp.o libbackend.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(RM) http https ipps
for file in $(IPPALIASES); do \
$(LN) ipp $$file; \
done
$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS)
$(RM) http
$(LN) ipp http
#
# lpd
#
lpd: lpd.o ../cups/$(LIBCUPS) libbackend.a
lpd: lpd.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o lpd lpd.o libbackend.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o lpd lpd.o $(LIBS)
#
# snmp
# parallel
#
snmp: snmp.o ../cups/$(LIBCUPS) libbackend.a
parallel: parallel.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o snmp snmp.o libbackend.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o parallel parallel.o $(LIBS)
#
# scsi
#
scsi: scsi.o ../cups/$(LIBCUPS)
echo Linking $@...
$(CC) $(LDFLAGS) -o scsi scsi.o $(LIBS)
scsi.o: scsi.c scsi-irix.c scsi-linux.c
#
# serial
#
serial: serial.o ../cups/$(LIBCUPS)
echo Linking $@...
$(CC) $(LDFLAGS) -o serial serial.o $(BACKLIBS) $(LIBS)
#
# socket
#
socket: socket.o ../cups/$(LIBCUPS) libbackend.a
socket: socket.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o socket socket.o libbackend.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
socket-static: socket.o ../cups/$(LIBCUPSSTATIC) libbackend.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o socket-static socket.o libbackend.a \
$(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o socket socket.o $(LIBS)
#
# usb
#
usb: usb.o ../cups/$(LIBCUPS) libbackend.a
usb: usb.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o usb usb.o libbackend.a $(LIBUSB) \
$(BACKLIBS) $(COMMONLIBS) $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
usb.o: usb.c usb-darwin.c usb-libusb.c usb-unix.c
$(CC) $(LDFLAGS) -o usb usb.o $(BACKLIBS) $(LIBS)
usb.o: usb.c usb-darwin.c usb-unix.c ieee1284.c
#
@@ -318,3 +189,8 @@ usb.o: usb.c usb-darwin.c usb-libusb.c usb-unix.c
#
include Dependencies
#
# End of "$Id$".
#
-327
Ver Arquivo
@@ -1,327 +0,0 @@
/*
* Backend support definitions for CUPS.
*
* Copyright © 2007-2014 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
#ifndef _CUPS_BACKEND_PRIVATE_H_
# define _CUPS_BACKEND_PRIVATE_H_
/*
* Include necessary headers.
*/
# include <cups/cups-private.h>
# include <cups/snmp-private.h>
# include <cups/backend.h>
# include <cups/sidechannel.h>
# include <signal.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 */
/*
* C++ magic...
*/
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
/*
* OID constants...
*/
/* Host MIB */
#define CUPS_OID_mib2 1,3,6,1,2,1
#define CUPS_OID_system CUPS_OID_mib2,1
#define CUPS_OID_sysLocation CUPS_OID_system,6
#define CUPS_OID_host CUPS_OID_mib2,25
#define CUPS_OID_hrSystem CUPS_OID_host,1
#define CUPS_OID_hrStorage CUPS_OID_host,2
#define CUPS_OID_hrDevice CUPS_OID_host,3
#define CUPS_OID_hrDeviceTable CUPS_OID_hrDevice,2
#define CUPS_OID_hrDeviceEntry CUPS_OID_hrDeviceTable,1
#define CUPS_OID_hrDeviceIndex CUPS_OID_hrDeviceEntry,1
#define CUPS_OID_hrDeviceType CUPS_OID_hrDeviceEntry,2
#define CUPS_OID_hrDeviceDescr CUPS_OID_hrDeviceEntry,3
#define CUPS_OID_hrPrinterTable CUPS_OID_hrDevice,5
#define CUPS_OID_hrPrinterEntry CUPS_OID_hrPrinterTable,1
#define CUPS_OID_hrPrinterStatus CUPS_OID_hrPrinterEntry,1
#define CUPS_OID_hrPrinterDetectedErrorState CUPS_OID_hrPrinterEntry,2
/* Printer MIB */
#define CUPS_OID_printmib CUPS_OID_mib2,43
#define CUPS_OID_prtGeneral CUPS_OID_printmib,5
#define CUPS_OID_prtGeneralTable CUPS_OID_prtGeneral,1
#define CUPS_OID_prtGeneralEntry CUPS_OID_prtGeneralTable,1
#define CUPS_OID_prtGeneralCurrentLocalization CUPS_OID_prtGeneralEntry,2
#define CUPS_OID_prtGeneralPrinterName CUPS_OID_prtGeneralEntry,16
#define CUPS_OID_prtGeneralSerialNumber CUPS_OID_prtGeneralEntry,17
#define CUPS_OID_prtCover CUPS_OID_printmib,6
#define CUPS_OID_prtCoverTable CUPS_OID_prtCover,1
#define CUPS_OID_prtCoverEntry CUPS_OID_prtCoverTable,1
#define CUPS_OID_prtCoverDescription CUPS_OID_prtCoverEntry,2
#define CUPS_OID_prtCoverStatus CUPS_OID_prtCoverEntry,3
#define CUPS_OID_prtLocalization CUPS_OID_printmib,7
#define CUPS_OID_prtLocalizationTable CUPS_OID_prtLocalization,1
#define CUPS_OID_prtLocalizationEntry CUPS_OID_prtLocalizationTable,1
#define CUPS_OID_prtLocalizationCharacterSet CUPS_OID_prtLocalizationEntry,4
#define CUPS_OID_prtMarker CUPS_OID_printmib,10
#define CUPS_OID_prtMarkerTable CUPS_OID_prtMarker,2
#define CUPS_OID_prtMarkerEntry CUPS_OID_prtMarkerTable,1
#define CUPS_OID_prtMarkerLifeCount CUPS_OID_prtMarkerEntry,4
#define CUPS_OID_prtMarkerSupplies CUPS_OID_printmib,11
#define CUPS_OID_prtMarkerSuppliesTable CUPS_OID_prtMarkerSupplies,1
#define CUPS_OID_prtMarkerSuppliesEntry CUPS_OID_prtMarkerSuppliesTable,1
#define CUPS_OID_prtMarkerSuppliesIndex CUPS_OID_prtMarkerSuppliesEntry,1
#define CUPS_OID_prtMarkerSuppliesMarkerIndex CUPS_OID_prtMarkerSuppliesEntry,2
#define CUPS_OID_prtMarkerSuppliesColorantIndex CUPS_OID_prtMarkerSuppliesEntry,3
#define CUPS_OID_prtMarkerSuppliesClass CUPS_OID_prtMarkerSuppliesEntry,4
#define CUPS_OID_prtMarkerSuppliesType CUPS_OID_prtMarkerSuppliesEntry,5
#define CUPS_OID_prtMarkerSuppliesDescription CUPS_OID_prtMarkerSuppliesEntry,6
#define CUPS_OID_prtMarkerSuppliesSupplyUnit CUPS_OID_prtMarkerSuppliesEntry,7
#define CUPS_OID_prtMarkerSuppliesMaxCapacity CUPS_OID_prtMarkerSuppliesEntry,8
#define CUPS_OID_prtMarkerSuppliesLevel CUPS_OID_prtMarkerSuppliesEntry,9
#define CUPS_OID_prtMarkerColorant CUPS_OID_printmib,12
#define CUPS_OID_prtMarkerColorantTable CUPS_OID_prtMarkerColorant,1
#define CUPS_OID_prtMarkerColorantEntry CUPS_OID_prtMarkerColorantTable,1
#define CUPS_OID_prtMarkerColorantIndex CUPS_OID_prtMarkerColorantEntry,1
#define CUPS_OID_prtMarkerColorantMarkerIndex CUPS_OID_prtMarkerColorantEntry,2
#define CUPS_OID_prtMarkerColorantRole CUPS_OID_prtMarkerColorantEntry,3
#define CUPS_OID_prtMarkerColorantValue CUPS_OID_prtMarkerColorantEntry,4
#define CUPS_OID_prtMarkerColorantTonality CUPS_OID_prtMarkerColorantEntry,5
#define CUPS_OID_prtInterpreter CUPS_OID_printmib,15
#define CUPS_OID_prtInterpreterTable CUPS_OID_prtInterpreter,1
#define CUPS_OID_prtInterpreterEntry CUPS_OID_prtInterpreterTable,1
#define CUPS_OID_prtInterpreterLangFamily CUPS_OID_prtInterpreterEntry,2
#define CUPS_OID_prtInterpreterLangLevel CUPS_OID_prtInterpreterEntry,3
/* Printer Port Monitor MIB */
#define CUPS_OID_enterprises 1,3,6,1,4,1
#define CUPS_OID_pwg CUPS_OID_enterprises,2699,1
#define CUPS_OID_ppmMIB CUPS_OID_pwg,2
#define CUPS_OID_ppmMIBObjects CUPS_OID_ppmMIB,1
#define CUPS_OID_ppmGeneral CUPS_OID_ppmMIBObjects,1
#define CUPS_OID_ppmPrinter CUPS_OID_ppmMIBObjects,2
#define CUPS_OID_ppmPrinterTable CUPS_OID_ppmPrinter,1
#define CUPS_OID_ppmPrinterEntry CUPS_OID_ppmPrinterTable,1
#define CUPS_OID_ppmPrinterIndex CUPS_OID_ppmPrinterEntry,1
#define CUPS_OID_ppmPrinterName CUPS_OID_ppmPrinterEntry,2
#define CUPS_OID_ppmPrinterIEEE1284DeviceId CUPS_OID_ppmPrinterEntry,3
#define CUPS_OID_ppmPrinterNumberOfPorts CUPS_OID_ppmPrinterEntry,4
#define CUPS_OID_ppmPrinterPreferredPortIndex CUPS_OID_ppmPrinterEntry,5
#define CUPS_OID_ppmPrinterHrDeviceIndex CUPS_OID_ppmPrinterEntry,6
#define CUPS_OID_ppmPrinterSnmpCommunityName CUPS_OID_ppmPrinterEntry,7
#define CUPS_OID_ppmPrinterSnmpQueryEnabled CUPS_OID_ppmPrinterEntry,8
#define CUPS_OID_ppmPort CUPS_OID_ppmMIBObjects,3
#define CUPS_OID_ppmPortTable CUPS_OID_ppmPort,1
#define CUPS_OID_ppmPortEntry CUPS_OID_ppmPortTable,1
#define CUPS_OID_ppmPortIndex CUPS_OID_ppmPortEntry,1
#define CUPS_OID_ppmPortEnabled CUPS_OID_ppmPortEntry,2
#define CUPS_OID_ppmPortName CUPS_OID_ppmPortEntry,3
#define CUPS_OID_ppmPortServiceNameOrURI CUPS_OID_ppmPortEntry,4
#define CUPS_OID_ppmPortProtocolType CUPS_OID_ppmPortEntry,5
#define CUPS_OID_ppmPortProtocolTargetPort CUPS_OID_ppmPortEntry,6
#define CUPS_OID_ppmPortProtocolAltSourceEnabled CUPS_OID_ppmPortEntry,7
#define CUPS_OID_ppmPortPrtChannelIndex CUPS_OID_ppmPortEntry,8
#define CUPS_OID_ppmPortLprByteCountEnabled CUPS_OID_ppmPortEntry,9
/*
* State constants...
*/
#define CUPS_TC_other 1
#define CUPS_TC_unknown 2
#define CUPS_TC_idle 3
#define CUPS_TC_printing 4
#define CUPS_TC_warmup 5
/* These come from the hrPrinterDetectedErrorState OCTET-STRING */
#define CUPS_TC_lowPaper 0x8000
#define CUPS_TC_noPaper 0x4000
#define CUPS_TC_lowToner 0x2000
#define CUPS_TC_noToner 0x1000
#define CUPS_TC_doorOpen 0x0800
#define CUPS_TC_jammed 0x0400
#define CUPS_TC_offline 0x0200
#define CUPS_TC_serviceRequested 0x0100
#define CUPS_TC_inputTrayMissing 0x0080
#define CUPS_TC_outputTrayMissing 0x0040
#define CUPS_TC_markerSupplyMissing 0x0020
#define CUPS_TC_outputNearFull 0x0010
#define CUPS_TC_outputFull 0x0008
#define CUPS_TC_inputTrayEmpty 0x0004
#define CUPS_TC_overduePreventMaint 0x0002
#define CUPS_TC_prtCoverStatus_coverOpen 3
#define CUPS_TC_prtCoverStatus_coverClosed 4
#define CUPS_TC_prtCoverStatus_interlockOpen 5
#define CUPS_TC_prtCoverStatus_interlockClosed 6
#define CUPS_TC_langPCL 3
#define CUPS_TC_langHPGL 4
#define CUPS_TC_langPJL 5
#define CUPS_TC_langPS 6
#define CUPS_TC_langEscapeP 9
#define CUPS_TC_langCCITT 26
#define CUPS_TC_langLIPS 39
#define CUPS_TC_langTIFF 40
#define CUPS_TC_langPCLXL 47
#define CUPS_TC_langPDF 54
#define CUPS_TC_langJPEG 61
#define CUPS_TC_supplyThatIsConsumed 3
#define CUPS_TC_receptacleThatIsFilled 4
#define CUPS_TC_process 3
#define CUPS_TC_spot 4
#define CUPS_TC_toner 3
#define CUPS_TC_wasteToner 4
#define CUPS_TC_ink 5
#define CUPS_TC_inkCartridge 6
#define CUPS_TC_inkRibbon 7
#define CUPS_TC_wasteInk 8
#define CUPS_TC_opc 9
#define CUPS_TC_developer 10
#define CUPS_TC_fuserOil 11
#define CUPS_TC_solidWax 12
#define CUPS_TC_ribbonWax 13
#define CUPS_TC_wasteWax 14
#define CUPS_TC_fuser 15
#define CUPS_TC_coronaWire 16
#define CUPS_TC_fuserOilWick 17
#define CUPS_TC_cleanerUnit 18
#define CUPS_TC_fuserCleaningPad 19
#define CUPS_TC_transferUnit 20
#define CUPS_TC_tonerCartridge 21
#define CUPS_TC_fuserOiler 22
#define CUPS_TC_water 23
#define CUPS_TC_wasteWater 24
#define CUPS_TC_glueWaterAdditive 25
#define CUPS_TC_wastePaper 26
#define CUPS_TC_bindingSupply 27
#define CUPS_TC_bandingSupply 28
#define CUPS_TC_stitchingWire 29
#define CUPS_TC_shrinkWrap 30
#define CUPS_TC_paperWrap 31
#define CUPS_TC_staples 32
#define CUPS_TC_inserts 33
#define CUPS_TC_covers 34
#define CUPS_TC_tenThousandthsOfInches 3
#define CUPS_TC_micrometers 4
#define CUPS_TC_impressions 7
#define CUPS_TC_sheets 8
#define CUPS_TC_hours 11
#define CUPS_TC_thousandthsOfOunces 12
#define CUPS_TC_tenthsOfGrams 13
#define CUPS_TC_hundrethsOfFluidOunces 14
#define CUPS_TC_tenthsOfMilliliters 15
#define CUPS_TC_feet 16
#define CUPS_TC_meters 17
#define CUPS_TC_items 18
#define CUPS_TC_percent 19
/* These come from RFC 3808 to define character sets we support */
/* Also see http://www.iana.org/assignments/character-sets */
#define CUPS_TC_csASCII 3
#define CUPS_TC_csISOLatin1 4
#define CUPS_TC_csShiftJIS 17
#define CUPS_TC_csUTF8 106
#define CUPS_TC_csUnicode 1000 /* UCS2 BE */
#define CUPS_TC_csUCS4 1001 /* UCS4 BE */
#define CUPS_TC_csUnicodeASCII 1002
#define CUPS_TC_csUnicodeLatin1 1003
#define CUPS_TC_csUTF16BE 1013
#define CUPS_TC_csUTF16LE 1014
#define CUPS_TC_csUTF32 1017
#define CUPS_TC_csUTF32BE 1018
#define CUPS_TC_csUTF32LE 1019
#define CUPS_TC_csWindows31J 2024
/*
* Types...
*/
typedef int (*_cups_sccb_t)(int print_fd, int device_fd, int snmp_fd,
http_addr_t *addr, int use_bc);
/*
* Prototypes...
*/
extern void backendCheckSideChannel(int snmp_fd, http_addr_t *addr);
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,
size_t make_model_size);
extern http_addrlist_t *backendLookup(const char *hostname, int port, int *cancel);
extern int backendNetworkSideCB(int print_fd, int device_fd,
int snmp_fd, http_addr_t *addr,
int use_bc);
extern ssize_t backendRunLoop(int print_fd, int device_fd, int snmp_fd,
http_addr_t *addr, int use_bc,
int update_state, _cups_sccb_t side_cb);
extern int backendSNMPSupplies(int snmp_fd, http_addr_t *addr,
int *page_count,
int *printer_state);
extern int backendWaitLoop(int snmp_fd, http_addr_t *addr,
int use_bc, _cups_sccb_t side_cb);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !_CUPS_BACKEND_PRIVATE_H_ */
+87
Ver Arquivo
@@ -0,0 +1,87 @@
/*
* "$Id$"
*
* Backend test program for the Common UNIX Printing System (CUPS).
*
* 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
* "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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* This file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* main() - Run the named backend.
*/
/*
* Include necessary headers.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cups/string.h>
#include <unistd.h>
/*
* 'main()' - Run the named backend.
*
* Usage:
*
* betest device-uri job-id user title copies options [file]
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments (7 or 8) */
char *argv[]) /* I - Command-line arguments */
{
char backend[255]; /* Method in URI */
if (argc < 7 || argc > 8)
{
fputs("Usage: betest device-uri job-id user title copies options [file]\n",
stderr);
return (1);
}
/*
* Extract the method from the device-uri - that's the program we want to
* execute.
*/
if (sscanf(argv[1], "%254[^:]", backend) != 1)
{
fputs("betest: Bad device-uri - no colon!\n", stderr);
return (1);
}
/*
* Execute and return
*/
execl(backend, argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7],
NULL);
return (1);
}
/*
* End of "$Id$".
*/
-1289
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+71
Ver Arquivo
@@ -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.
+35
Ver Arquivo
@@ -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.
+287 -359
Ver Arquivo
@@ -1,28 +1,63 @@
/*
* IEEE-1284 support functions for CUPS.
* "$Id$"
*
* Copyright © 2007-2015 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
* IEEE-1284 support functions for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* get_device_id() - Get the IEEE-1284 device ID string and corresponding
* URI.
*/
/*
* Include necessary headers.
*/
#include "backend-private.h"
#include <cups/ppd-private.h>
#include <cups/debug.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)
#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.
* 'get_device_id()' - Get the IEEE-1284 device ID string and
* corresponding URI.
*/
int /* O - 0 on success, -1 on failure */
backendGetDeviceID(
get_device_id(
int fd, /* I - File descriptor */
char *device_id, /* O - 1284 device ID */
int device_id_size, /* I - Size of buffer */
@@ -32,371 +67,123 @@ backendGetDeviceID(
char *uri, /* O - Device URI */
int uri_size) /* I - Size of buffer */
{
#ifdef __APPLE__ /* This function is a no-op */
(void)fd;
(void)device_id;
(void)device_id_size;
(void)make_model;
(void)make_model_size;
(void)scheme;
(void)uri;
(void)uri_size;
return (-1);
#else /* Get the device ID from the specified file descriptor... */
# ifdef __linux
char *attr, /* 1284 attribute */
*delim, /* 1284 delimiter */
*uriptr, /* Pointer into URI */
*mfg, /* Manufacturer string */
*mdl, /* Model string */
serial_number[1024]; /* Serial number string */
#ifdef __linux
int length; /* Length of device ID info */
int got_id = 0;
# endif /* __linux */
# if defined(__sun) && defined(ECPPIOC_GETDEVID)
#endif /* __linux */
#if defined(__sun) && defined(ECPPIOC_GETDEVID)
struct ecpp_device_id did; /* Device ID buffer */
# endif /* __sun && ECPPIOC_GETDEVID */
char *ptr; /* Pointer into device ID */
#endif /* __sun && ECPPIOC_GETDEVID */
DEBUG_printf(("get_device_id(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)
if (fd < 0 ||
!device_id || device_id_size < 32 ||
!make_model || make_model_size < 32)
{
DEBUG_puts("get_device_id: Bad args!");
return (-1);
}
if (make_model)
*make_model = '\0';
*device_id = '\0';
*make_model = '\0';
if (fd >= 0)
{
/*
* Get the device ID string...
*/
*device_id = '\0';
# ifdef __linux
if (ioctl(fd, LPIOC_GET_DEVICE_ID((unsigned)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, (size_t)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 = (int)((((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 || length < 14)
length = (int)((((unsigned)device_id[1] & 255) << 8) + ((unsigned)device_id[0] & 255));
if (length > device_id_size)
length = device_id_size;
/*
* The length field counts the number of bytes in the string
* including the length field itself (2 bytes). The minimum
* length for a valid/usable device ID is 14 bytes:
*
* <LENGTH> MFG: <MFG> ;MDL: <MDL> ;
* 2 + 4 + 1 + 5 + 1 + 1
*/
if (length < 14)
{
/*
* Can't use this device ID, so don't try to copy it...
*/
device_id[0] = '\0';
got_id = 0;
}
else
{
/*
* Copy the device ID text to the beginning of the buffer and
* nul-terminate.
*/
length -= 2;
memmove(device_id, device_id + 2, (size_t)length);
device_id[length] = '\0';
}
}
else
{
*device_id = '\0';
}
# 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';
}
# endif /* __sun && ECPPIOC_GETDEVID */
}
if (uri)
*uri = '\0';
/*
* Check whether device ID is valid. Turn line breaks and tabs to spaces and
* reject device IDs with non-printable characters.
* Get the device ID string...
*/
for (ptr = device_id; *ptr; ptr ++)
if (_cups_isspace(*ptr))
*ptr = ' ';
else if ((*ptr & 255) < ' ' || *ptr == 127)
{
*device_id = '\0';
break;
}
#ifdef __linux
if (!ioctl(fd, LPIOC_GET_DEVICE_ID(device_id_size), device_id))
{
/*
* Extract the length of the device ID string from the first two
* bytes. The 1284 spec says the length is stored MSB first...
*/
if (scheme && uri)
*uri = '\0';
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("get_device_id: 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("get_device_id: ioctl failed - %s\n", strerror(errno));
# endif /* DEBUG */
#endif /* __sun && ECPPIOC_GETDEVID */
DEBUG_printf(("get_device_id: device_id=\"%s\"\n", device_id));
if (!*device_id)
return (-1);
/*
* Get the make and model...
*/
if (make_model)
backendGetMakeModel(device_id, make_model, (size_t)make_model_size);
/*
* Then generate a device URI...
*/
if (scheme && uri && uri_size > 32)
{
int num_values; /* Number of keys and values */
cups_option_t *values; /* Keys and values in device ID */
const char *mfg, /* Manufacturer */
*mdl, /* Model */
*sern; /* Serial number */
char temp[256], /* Temporary manufacturer string */
*tempptr; /* Pointer into temp string */
/*
* Get the make, model, and serial numbers...
*/
num_values = _cupsGet1284Values(device_id, &values);
if ((sern = cupsGetOption("SERIALNUMBER", num_values, values)) == NULL)
if ((sern = cupsGetOption("SERN", num_values, values)) == NULL)
sern = cupsGetOption("SN", num_values, values);
if ((mfg = cupsGetOption("MANUFACTURER", num_values, values)) == NULL)
mfg = cupsGetOption("MFG", num_values, values);
if ((mdl = cupsGetOption("MODEL", num_values, values)) == NULL)
mdl = cupsGetOption("MDL", num_values, values);
if (mfg)
{
if (!_cups_strcasecmp(mfg, "Hewlett-Packard"))
mfg = "HP";
else if (!_cups_strcasecmp(mfg, "Lexmark International"))
mfg = "Lexmark";
}
else
{
strlcpy(temp, make_model, sizeof(temp));
if ((tempptr = strchr(temp, ' ')) != NULL)
*tempptr = '\0';
mfg = temp;
}
if (!mdl)
mdl = "";
if (!_cups_strncasecmp(mdl, mfg, strlen(mfg)))
{
mdl += strlen(mfg);
while (isspace(*mdl & 255))
mdl ++;
}
/*
* Generate the device URI from the manufacturer, make_model, and
* serial number strings.
*/
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, uri_size, scheme, NULL, mfg, 0,
"/%s%s%s", mdl, sern ? "?serial=" : "", sern ? sern : "");
cupsFreeOptions(num_values, values);
}
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 */
size_t make_model_size) /* I - Size of buffer */
{
int num_values; /* Number of keys and values */
cups_option_t *values; /* Keys and values */
const char *mfg, /* Manufacturer string */
*mdl, /* Model string */
*des; /* Description string */
/*
* Range check input...
*/
if (!device_id || !*device_id || !make_model || make_model_size < 32)
return (-1);
*make_model = '\0';
/*
* Look for the description field...
*/
num_values = _cupsGet1284Values(device_id, &values);
if ((attr = strstr(device_id, "DES:")) != NULL)
attr += 4;
else if ((attr = strstr(device_id, "DESCRIPTION:")) != NULL)
attr += 12;
if ((mdl = cupsGetOption("MODEL", num_values, values)) == NULL)
mdl = cupsGetOption("MDL", num_values, values);
if (mdl)
{
/*
* Build a make-model string from the manufacturer and model attributes...
*/
if ((mfg = cupsGetOption("MANUFACTURER", num_values, values)) == NULL)
mfg = cupsGetOption("MFG", num_values, values);
if (!mfg || !_cups_strncasecmp(mdl, mfg, strlen(mfg)))
{
/*
* Just copy the model string, since it has the manufacturer...
*/
_ppdNormalizeMakeAndModel(mdl, make_model, make_model_size);
}
else
{
/*
* Concatenate the make and model...
*/
char temp[1024]; /* Temporary make and model */
snprintf(temp, sizeof(temp), "%s %s", mfg, mdl);
_ppdNormalizeMakeAndModel(temp, make_model, make_model_size);
}
}
else if ((des = cupsGetOption("DESCRIPTION", num_values, values)) != NULL ||
(des = cupsGetOption("DES", num_values, values)) != NULL)
if (attr)
{
/*
* Make sure the description contains something useful, since some
@@ -407,30 +194,102 @@ backendGetMakeModel(
* containing at least one space and one letter.
*/
if (strlen(des) >= 8)
if ((delim = strchr(attr, ';')) == NULL)
delim = attr + strlen(attr);
if ((delim - attr) < 8)
attr = NULL;
else
{
const char *ptr; /* Pointer into description */
int letters, /* Number of letters seen */
spaces; /* Number of spaces seen */
char *ptr; /* Pointer into description */
int letters, /* Number of letters seen */
spaces; /* Number of spaces seen */
for (ptr = des, letters = 0, spaces = 0; *ptr; ptr ++)
for (ptr = attr, letters = 0, spaces = 0; ptr < delim; ptr ++)
{
if (isspace(*ptr & 255))
if (isspace(*ptr & 255))
spaces ++;
else if (isalpha(*ptr & 255))
letters ++;
if (spaces && letters)
if (spaces && letters)
break;
}
if (spaces && letters)
_ppdNormalizeMakeAndModel(des, make_model, make_model_size);
if (!spaces || !letters)
attr = NULL;
}
}
if (!make_model[0])
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, "MDL:")) != NULL)
mdl += 4;
if (attr)
{
/*
* Use description...
*/
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 if (mfg && mdl)
{
/*
* Build a make-model string from the manufacturer and model attributes...
*/
if (!strncasecmp(mfg, "Hewlett-Packard", 15))
strlcpy(make_model, "HP", make_model_size);
else
strlcpy(make_model, mfg, make_model_size);
if ((delim = strchr(make_model, ';')) != NULL)
*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...
*/
strlcat(make_model, " ", make_model_size);
strlcat(make_model, mdl, make_model_size);
}
}
else
{
/*
* Use "Unknown" as the printer make and model...
@@ -439,7 +298,76 @@ backendGetMakeModel(
strlcpy(make_model, "Unknown", make_model_size);
}
cupsFreeOptions(num_values, values);
if ((delim = strchr(make_model, ';')) != NULL)
*delim = '\0';
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 make_model and serial number strings.
*/
snprintf(uri, uri_size, "%s://", scheme);
for (uriptr = uri + strlen(uri), delim = make_model;
*delim && uriptr < (uri + uri_size - 1);
delim ++)
if (*delim == ' ')
{
delim ++;
*uriptr++ = '/';
break;
}
else
*uriptr++ = *delim;
for (; *delim && uriptr < (uri + uri_size - 3); delim ++)
if (*delim == ' ')
{
*uriptr++ = '%';
*uriptr++ = '2';
*uriptr++ = '0';
}
else
*uriptr++ = *delim;
*uriptr = '\0';
if (serial_number[0])
{
/*
* Add the serial number to the URI...
*/
strlcat(uri, "?serial=", uri_size);
strlcat(uri, serial_number, uri_size);
}
}
return (0);
}
/*
* End of "$Id$".
*/
+877
Ver Arquivo
@@ -0,0 +1,877 @@
/*
* "$Id$"
*
* Linux IEEE-1394 glue for the Common UNIX Printing System (CUPS).
*
* 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$".
*/
+267
Ver Arquivo
@@ -0,0 +1,267 @@
/*
* "$Id$"
*
* IEEE-1394 backend for the Common UNIX Printing System (CUPS).
*
* 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$".
*/
+103
Ver Arquivo
@@ -0,0 +1,103 @@
/*
* "$Id$"
*
* IEEE-1394 header for the Common UNIX Printing System (CUPS).
*
* 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$".
*/
+851 -2860
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+534 -593
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-354
Ver Arquivo
@@ -1,354 +0,0 @@
/*
* Common backend network APIs for CUPS.
*
* Copyright © 2007-2016 by Apple Inc.
* Copyright © 2006-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers.
*/
#include "backend-private.h"
#include <limits.h>
#include <sys/select.h>
/*
* 'backendCheckSideChannel()' - Check the side-channel for pending requests.
*/
void
backendCheckSideChannel(
int snmp_fd, /* I - SNMP socket */
http_addr_t *addr) /* I - Address of device */
{
fd_set input; /* Select input set */
struct timeval timeout; /* Select timeout */
FD_ZERO(&input);
FD_SET(CUPS_SC_FD, &input);
timeout.tv_sec = timeout.tv_usec = 0;
if (select(CUPS_SC_FD + 1, &input, NULL, NULL, &timeout) > 0)
backendNetworkSideCB(-1, -1, snmp_fd, addr, 0);
}
/*
* 'backendLookup()' - Lookup the given host and log addresses.
*/
http_addrlist_t * /* O - List of addresses or NULL */
backendLookup(const char *hostname, /* I - Hostname */
int port, /* I - Port number */
int *cancel) /* I - Variable to watch for job cancel */
{
char portname[32], /* Port number as string */
addrname[256]; /* Address as string */
http_addrlist_t *addrlist, /* List of addresses */
*current; /* Current address */
/*
* Lookup the address for the named host...
*/
snprintf(portname, sizeof(portname), "%d", port);
fputs("STATE: +connecting-to-device\n", stderr);
fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
{
_cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname);
sleep(10);
if (getenv("CLASS") != NULL)
{
fputs("STATE: -connecting-to-device\n", stderr);
exit(CUPS_BACKEND_STOP);
}
if (cancel && *cancel)
{
fputs("STATE: -connecting-to-device\n", stderr);
exit(CUPS_BACKEND_OK);
}
}
fputs("STATE: -connecting-to-device\n", stderr);
/*
* Log the addresses we got...
*/
for (current = addrlist; current; current = current->next)
fprintf(stderr, "DEBUG: %s=%s\n", hostname, httpAddrString(&current->addr, addrname, sizeof(addrname)));
/*
* Return...
*/
return (addrlist);
}
/*
* 'backendNetworkSideCB()' - Handle common network side-channel commands.
*/
int /* O - -1 on error, 0 on success */
backendNetworkSideCB(
int print_fd, /* I - Print file or -1 */
int device_fd, /* I - Device file or -1 */
int snmp_fd, /* I - SNMP socket */
http_addr_t *addr, /* I - Address of device */
int use_bc) /* I - Use back-channel data? */
{
cups_sc_command_t command; /* Request command */
cups_sc_status_t status; /* Request/response status */
char data[65536]; /* Request/response data */
int datalen; /* Request/response data size */
const char *device_id; /* 1284DEVICEID env var */
datalen = sizeof(data);
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
return (-1);
switch (command)
{
case CUPS_SC_CMD_DRAIN_OUTPUT :
/*
* Our sockets disable the Nagle algorithm and data is sent immediately.
*/
if (device_fd < 0)
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
else 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] = (char)use_bc;
datalen = 1;
break;
case CUPS_SC_CMD_SNMP_GET :
case CUPS_SC_CMD_SNMP_GET_NEXT :
fprintf(stderr, "DEBUG: CUPS_SC_CMD_SNMP_%s: %d (%s)\n",
command == CUPS_SC_CMD_SNMP_GET ? "GET" : "GET_NEXT", datalen,
data);
if (datalen < 2)
{
status = CUPS_SC_STATUS_BAD_MESSAGE;
datalen = 0;
break;
}
if (snmp_fd >= 0)
{
char *dataptr; /* Pointer into data */
cups_snmp_t packet; /* Packet from printer */
const char *snmp_value; /* CUPS_SNMP_VALUE env var */
if ((snmp_value = getenv("CUPS_SNMP_VALUE")) != NULL)
{
const char *snmp_count; /* CUPS_SNMP_COUNT env var */
int count; /* Repetition count */
if ((snmp_count = getenv("CUPS_SNMP_COUNT")) != NULL)
{
if ((count = atoi(snmp_count)) <= 0)
count = 1;
}
else
count = 1;
for (dataptr = data + strlen(data) + 1;
count > 0 && dataptr < (data + sizeof(data) - 1);
count --, dataptr += strlen(dataptr))
strlcpy(dataptr, snmp_value, sizeof(data) - (size_t)(dataptr - data));
fprintf(stderr, "DEBUG: Returning %s %s\n", data,
data + strlen(data) + 1);
status = CUPS_SC_STATUS_OK;
datalen = (int)(dataptr - data);
break;
}
if (!_cupsSNMPStringToOID(data, packet.object_name, CUPS_SNMP_MAX_OID))
{
status = CUPS_SC_STATUS_BAD_MESSAGE;
datalen = 0;
break;
}
status = CUPS_SC_STATUS_IO_ERROR;
datalen = 0;
if (_cupsSNMPWrite(snmp_fd, addr, CUPS_SNMP_VERSION_1,
_cupsSNMPDefaultCommunity(),
command == CUPS_SC_CMD_SNMP_GET ?
CUPS_ASN1_GET_REQUEST :
CUPS_ASN1_GET_NEXT_REQUEST, 1,
packet.object_name))
{
if (_cupsSNMPRead(snmp_fd, &packet, 1.0))
{
size_t i; /* Looping var */
if (!_cupsSNMPOIDToString(packet.object_name, data, sizeof(data)))
{
fputs("DEBUG: Bad OID returned!\n", stderr);
break;
}
datalen = (int)strlen(data) + 1;
dataptr = data + datalen;
switch (packet.object_type)
{
case CUPS_ASN1_BOOLEAN :
snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%d", packet.object_value.boolean);
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_INTEGER :
snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%d",
packet.object_value.integer);
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_BIT_STRING :
case CUPS_ASN1_OCTET_STRING :
if (packet.object_value.string.num_bytes < (sizeof(data) - (size_t)(dataptr - data)))
i = packet.object_value.string.num_bytes;
else
i = sizeof(data) - (size_t)(dataptr - data);
memcpy(dataptr, packet.object_value.string.bytes, i);
datalen += (int)i;
break;
case CUPS_ASN1_OID :
_cupsSNMPOIDToString(packet.object_value.oid, dataptr,
sizeof(data) - (size_t)(dataptr - data));
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_HEX_STRING :
for (i = 0;
i < packet.object_value.string.num_bytes &&
dataptr < (data + sizeof(data) - 3);
i ++, dataptr += 2)
sprintf(dataptr, "%02X", packet.object_value.string.bytes[i]);
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_COUNTER :
snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.counter);
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_GAUGE :
snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.gauge);
datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_TIMETICKS :
snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.timeticks);
datalen += (int)strlen(dataptr);
break;
default :
fprintf(stderr, "DEBUG: Unknown OID value type %02X.\n", packet.object_type);
case CUPS_ASN1_NULL_VALUE :
dataptr[0] = '\0';
break;
}
fprintf(stderr, "DEBUG: Returning %s %s\n", data, data + datalen);
status = CUPS_SC_STATUS_OK;
}
else
fputs("DEBUG: SNMP read error...\n", stderr);
}
else
fputs("DEBUG: SNMP write error...\n", stderr);
break;
}
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
datalen = 0;
break;
case CUPS_SC_CMD_GET_CONNECTED :
status = CUPS_SC_STATUS_OK;
data[0] = device_fd != -1;
datalen = 1;
break;
case CUPS_SC_CMD_GET_DEVICE_ID :
if (snmp_fd >= 0)
{
cups_snmp_t packet; /* Packet from printer */
static const int ppmPrinterIEEE1284DeviceId[] =
{ CUPS_OID_ppmPrinterIEEE1284DeviceId,1,-1 };
status = CUPS_SC_STATUS_IO_ERROR;
datalen = 0;
if (_cupsSNMPWrite(snmp_fd, addr, CUPS_SNMP_VERSION_1,
_cupsSNMPDefaultCommunity(),
CUPS_ASN1_GET_REQUEST, 1,
ppmPrinterIEEE1284DeviceId))
{
if (_cupsSNMPRead(snmp_fd, &packet, 1.0) &&
packet.object_type == CUPS_ASN1_OCTET_STRING)
{
strlcpy(data, (char *)packet.object_value.string.bytes,
sizeof(data));
datalen = (int)strlen(data);
status = CUPS_SC_STATUS_OK;
}
}
break;
}
if ((device_id = getenv("1284DEVICEID")) != NULL)
{
strlcpy(data, device_id, sizeof(data));
datalen = (int)strlen(data);
status = CUPS_SC_STATUS_OK;
break;
}
default :
status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
datalen = 0;
break;
}
return (cupsSideChannelWrite(command, status, data, datalen, 1.0));
}
-304
Ver Arquivo
@@ -1,304 +0,0 @@
# USB backend 'quirks' file.
#
# This file lists known issues with various vendors or printers. Each
# line contains either a comment (starting with #) or the USB vendor ID,
# product ID (omit for all vendor products), and a list of known issues:
#
# blacklist The printer is not functional with the USB backend.
# delay-close Delay close/reset of selected interface
# no-reattach Do no re-attach usblp kernel module after printing.
# soft-reset Do a soft reset after printing for cleanup.
# unidir Only supports unidirectional I/O
# usb-init Needs vendor USB initialization string.
# vendor-class Uses vendor-specific class or subclass.
# whitelist The printer is functional with the USB backend.
#
# To get the USB vendor and product IDs for a given printer, run the "lsusb"
# command, which will show something like the following:
#
# Bus 002 Device 003: ID ab21:34dc Acme Example Printer
#
# The "ab21:34dc" is the vendor and product ID, separated by a colon.
# HP DeskJet 895C
0x03f0 0x0004 unidir
# HP DeskJet 880C
0x03f0 0x0104 unidir
# HP DeskJet 815C
0x03f0 0x0204 unidir
# HP DeskJet 810C/812C
0x03f0 0x0304 unidir
# HP DeskJet 830C
0x03f0 0x0404 unidir
# HP DeskJet 885C
0x03f0 0x0504 unidir
# HP DeskJet 840C
0x03f0 0x0604 unidir
# HP DeskJet 816C
0x03f0 0x0804 unidir
# HP Deskjet 959C
0x03f0 0x1104 unidir
# NEC Picty900 (HP OEM)
0x0409 0xefbe unidir
# NEC Picty760 (HP OEM)
0x0409 0xbef4 unidir
# NEC Picty920 (HP OEM)
0x0409 0xf0be unidir
# NEC Picty800 (HP OEM)
0x0409 0xf1be unidir
# Lexmark International, Inc. (e250d) (https://bugs.launchpad.net/bugs/1084164)
0x043d 0x00f3 no-reattach
# Kyocera Mita FS 820, by zut <kernel@zut.de>
0x0482 0x0010 unidir
# Canon, Inc. PIXMA iP6000D Printer (https://bugs.launchpad.net/bugs/1160638)
0x04a9 0x1095 unidir
# Canon, Inc. PIXMA iP4200 Printer (Issue #4155)
0x04a9 0x10a2 unidir
# Canon, Inc. PIXMA iP4300 Printer (https://bugs.launchpad.net/bugs/1032385)
0x04a9 0x10b6 unidir
# Canon, Inc. MP210 (https://bugzilla.redhat.com/show_bug.cgi?id=847923#c53)
0x04a9 0x1721 unidir
# Canon, Inc. MP500 Printer (https://bugs.launchpad.net/bugs/1032456)
0x04a9 0x170c unidir
# Canon, Inc. MP510 Printer (https://bugs.launchpad.net/bugs/1050009)
0x04a9 0x1717 unidir
# Canon, Inc. MP540 Printer, https://bugzilla.redhat.com/967873
0x04a9 0x1730 unidir
# Canon, Inc. MP550 Printer (Issue #4155)
0x04a9 0x173d unidir
# Canon, Inc. MP560 Printer (Issue #4155)
0x04a9 0x173e unidir
# Canon, Inc. MF4150 Printer (https://bugs.launchpad.net/bugs/1160638)
0x04a9 0x26a3 no-reattach
# Brother Industries, Ltd HL-1250 Laser Printer (https://bugs.debian.org/712512)
0x04f9 0x0007 no-reattach
# Brother Industries, Ltd HL-1430 Laser Printer (https://bugs.launchpad.net/bugs/1038695)
0x04f9 0x001a no-reattach
# Brother Industries, Ltd HL-1440 Laser Printer (https://bugs.launchpad.net/bugs/1000253)
0x04f9 0x000d no-reattach unidir
# Brother Industries, Ltd HL-1450 Laser Printer (https://bugs.launchpad.net/bugs/1000253)
0x04f9 0x000e no-reattach unidir
# Oki Data Corp. Okipage 14ex Printer (https://bugs.launchpad.net/bugs/872483)
0x06bc 0x000b no-reattach
# Oki Data Corp. B410d (https://bugs.launchpad.net/bugs/872483)
0x06bc 0x01c7 no-reattach
# Seiko Epson Corp. Stylus Color 740 / Photo 750 (http://bugs.debian.org/697970)
0x04b8 0x0001 no-reattach unidir
# Seiko Epson Corp. Stylus Color 670 (https://bugs.launchpad.net/bugs/872483)
0x04b8 0x0005 no-reattach
# Seiko Epson Receipt Printer M129C
0x04b8 0x0202 vendor-class
# Prolific Technology, Inc. PL2305 Parallel Port (USB -> Parallel adapter) (https://bugs.launchpad.net/bugs/987485)
0x067b 0x2305 no-reattach soft-reset unidir
# Xerox Phaser 3124 https://bugzilla.redhat.com/show_bug.cgi?id=867392
0x0924 0x3ce9 no-reattach
# Xerox WorkCentre 3210 https://bugs.launchpad.net/bugs/1102470
0x0924 0x4293 no-reattach
# QinHeng Electronics CH340S (USB -> Parallel adapter) (https://bugs.launchpad.net/bugs/1000253)
0x1a86 0x7584 no-reattach
# All Samsung devices (https://bugs.launchpad.net/bugs/1032456)
0x04e8 soft-reset
# Samsung ML-2160 Series (https://bugzilla.redhat.com/show_bug.cgi?id=873123)
0x04e8 0x330f unidir
# All Zebra devices (https://bugs.launchpad.net/bugs/1001028) (Issue #5395)
0x0a5f unidir no-reattach
# Canon CP-10
0x04a9 0x304a blacklist
# Canon CP-100
0x04a9 0x3063 blacklist
# Canon CP-200
0x04a9 0x307c blacklist
# Canon CP-300
0x04a9 0x307d blacklist
# Canon CP-220
0x04a9 0x30bd blacklist
# Canon CP-330
0x04a9 0x30be blacklist
# Canon SELPHY CP400
0x04a9 0x30f6 blacklist
# Canon SELPHY CP600
0x04a9 0x310b blacklist
# Canon SELPHY CP710
0x04a9 0x3127 blacklist
# Canon SELPHY CP510
0x04a9 0x3128 blacklist
# Canon SELPHY ES1
0x04a9 0x3141 blacklist
# Canon SELPHY CP730
0x04a9 0x3142 blacklist
# Canon SELPHY CP720
0x04a9 0x3143 blacklist
# Canon SELPHY CP750
0x04a9 0x3170 blacklist
# Canon SELPHY CP740
0x04a9 0x3171 blacklist
# Canon SELPHY ES2
0x04a9 0x3185 blacklist
# Canon SELPHY ES20
0x04a9 0x3186 blacklist
# Canon SELPHY CP770
0x04a9 0x31aa blacklist
# Canon SELPHY CP760
0x04a9 0x31ab blacklist
# Canon SELPHY ES30
0x04a9 0x31b0 blacklist
# Canon SELPHY CP780
0x04a9 0x31dd blacklist
# Canon SELPHY ES40
0x04a9 0x31ee blacklist
# Canon SELPHY CP800
0x04a9 0x3214 blacklist
# Canon SELPHY CP900
0x04a9 0x3255 blacklist
# Canon SELPHY CP810
0x04a9 0x3256 blacklist
# Canon SELPHY CP500
0x04a9 0x30f5 blacklist
# Canon SELPHY ES3
0x04a9 0x31af blacklist
# Canon SELPHY CP780
0x04a9 0x31dd blacklist
# Lexmark E238 (<rdar://problem/14493054>)
0x043d 0x00d7 no-reattach
# Lexmark E238 (Issue #4448)
0x043d 0x009a no-reattach
# Canon MX310 (Issue #4482)
0x04a9 0x1728 unidir
# Canon MX320 (Issue #4482)
0x04A9 0x1736 unidir
# All Intermec devices (Issue #4553)
0x067e no-reattach
# HP LaserJet 1015 (Issue #5617)
0x03f0 0x0e17 delay-close
# HP LaserJet 1150 (Issue #4549)
0x03f0 0x0f17 delay-close
# HP LaserJet 1300 (Issue #4549)
0x03f0 0x1017 delay-close
0x03f0 0x1117 delay-close
# HP LaserJet 1320 (Issue #4549)
0x03f0 0x1d17 delay-close
# Canon, Inc. MP530 Printer
0x04a9 0x1712 unidir
# Xerox WorkCentre 3220 (https://bugs.launchpad.net/bugs/1406203, Issue #4789)
0x0924 0x4294 no-reattach
# Lexmark C540n (Issue #4778)
0x043d 0x0139 no-reattach
# Kyocera Ecosys P6026cdn (Issue #4900)
0x0482 0x063f no-reattach
# Kyocera Ecosys P6130cdn (Issue #5102)
0x0482 0x0677 no-reattach
# Lexmark E260dn (Issue #4994)
0x043d 0x0123 no-reattach
# HP LaserJet 1160 (Issue #5121)
0x03f0 0x1e17 delay-close
# Canon, Inc. MP280 series (Issue #5221)
0x04a9 0x1746 unidir
# Star Micronics printers (Issue #5251)
0x0519 unidir
# Lexmark Optra E310 (Issue #5259)
0x043d 0x000c no-reattach
# HP LaserJet P1102 (Issue #5310)
0x03F0 0x002A no-reattach
# Lexmark MS317dn
0x043d 0x0226 no-reattach
# Star TSP743 (Issue #5443)
0x0519 0x0001 delay-close
# Lexmark E120n (Issue #5478)
0x043d 0x00cc no-reattach
# All Xerox printers (Issue #5523)
0x0924 no-reattach
# Dymo 450 Turbo (Issue #5521)
0x0922 0x0021 unidir
+741
Ver Arquivo
@@ -0,0 +1,741 @@
/*
* "$Id$"
*
* Parallel port backend for the Common UNIX Printing System (CUPS).
*
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* main() - Send a file to the specified parallel port.
* list_devices() - List all parallel devices.
*/
/*
* Include necessary headers.
*/
#include <cups/backend.h>
#include <cups/cups.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <cups/string.h>
#include <signal.h>
#include "ieee1284.c"
#ifdef __hpux
# include <sys/time.h>
#else
# include <sys/select.h>
#endif /* __hpux */
#ifdef WIN32
# include <io.h>
#else
# include <unistd.h>
# include <fcntl.h>
# include <termios.h>
# include <sys/socket.h>
#endif /* WIN32 */
#ifdef __sgi
# include <invent.h>
# ifndef INV_EPP_ECP_PLP
# define INV_EPP_ECP_PLP 6 /* From 6.3/6.4/6.5 sys/invent.h */
# define INV_ASO_SERIAL 14 /* serial portion of SGI ASO board */
# define INV_IOC3_DMA 16 /* DMA mode IOC3 serial */
# define INV_IOC3_PIO 17 /* PIO mode IOC3 serial */
# define INV_ISA_DMA 19 /* DMA mode ISA serial -- O2 */
# endif /* !INV_EPP_ECP_PLP */
#endif /* __sgi */
/*
* Local functions...
*/
void list_devices(void);
/*
* 'main()' - Send a file to the specified parallel port.
*
* 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 */
{
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 rbytes; /* Number of bytes read */
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 */
fd_set input, /* Input set for select() */
output; /* Output set for select() */
int paperout; /* Paper out? */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
#ifdef __linux
unsigned int status; /* Port status (off-line, out-of-paper, etc.) */
#endif /* __linux */
/*
* Make sure status messages are not buffered...
*/
setbuf(stderr, NULL);
/*
* Ignore SIGPIPE signals...
*/
#ifdef HAVE_SIGSET
sigset(SIGPIPE, SIG_IGN);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
#else
signal(SIGPIPE, SIG_IGN);
#endif /* HAVE_SIGSET */
/*
* Check command-line...
*/
if (argc == 1)
{
list_devices();
return (CUPS_BACKEND_OK);
}
else if (argc < 6 || argc > 7)
{
fputs("Usage: parallel job-id user title copies options [file]\n", stderr);
return (CUPS_BACKEND_FAILED);
}
/*
* 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 (CUPS_BACKEND_FAILED);
}
copies = atoi(argv[4]);
}
/*
* Extract the device name and options from the URI...
*/
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...
*/
if ((options = strchr(resource, '?')) != NULL)
{
/*
* Yup, terminate the device name string and move to the first
* character of the options...
*/
*options++ = '\0';
}
/*
* Open the parallel port device...
*/
fputs("STATE: +connecting-to-device\n", stderr);
do
{
if ((fd = open(resource, O_WRONLY | 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.
*/
fputs("INFO: Unable to open parallel port, queuing on next printer in class...\n",
stderr);
/*
* 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);
sleep(30);
}
else if (errno == ENXIO || errno == EIO || errno == ENOENT)
{
fputs("INFO: Printer not connected; will retry in 30 seconds...\n", stderr);
sleep(30);
}
else
{
fprintf(stderr, "ERROR: Unable to open parallel port device file \"%s\": %s\n",
resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
}
while (fd < 0);
fputs("STATE: -connecting-to-device\n", stderr);
/*
* Set any options provided...
*/
tcgetattr(fd, &opts);
opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */
/**** No options supported yet ****/
tcsetattr(fd, TCSANOW, &opts);
/*
* Check printer status...
*/
paperout = 0;
#if defined(__linux) && defined(LP_POUTPA)
/*
* Show the printer status before we send the file...
*/
while (!ioctl(fd, LPGETSTATUS, &status))
{
fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status);
if (status & LP_POUTPA)
{
fputs("WARNING: Media tray empty!\n", stderr);
fputs("STATUS: +media-tray-empty-error\n", stderr);
paperout = 1;
}
if (!(status & LP_PERRORP))
fputs("WARNING: Printer fault!\n", stderr);
else if (!(status & LP_PSELECD))
fputs("WARNING: Printer off-line.\n", stderr);
else
break;
sleep(5);
}
#endif /* __linux && LP_POUTPA */
/*
* 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...
*/
wbytes = 0;
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;
bufptr = buffer;
while (nbytes > 0)
{
/*
* See if we are ready to read or write...
*/
do
{
FD_ZERO(&input);
FD_SET(fd, &input);
FD_ZERO(&output);
FD_SET(fd, &output);
}
while (select(fd + 1, &input, &output, NULL, NULL) < 0);
if (FD_ISSET(fd, &input))
{
/*
* Read backchannel data...
*/
if ((rbytes = read(fd, resource, sizeof(resource))) > 0)
{
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
rbytes);
cupsBackChannelWrite(resource, rbytes, 1.0);
}
}
if (FD_ISSET(fd, &output))
{
/*
* Write print data...
*/
if ((wbytes = write(fd, bufptr, nbytes)) < 0)
if (errno == ENOTTY)
wbytes = write(fd, bufptr, nbytes);
if (wbytes < 0)
{
/*
* Check for retryable errors...
*/
if (errno == ENOSPC)
{
paperout = 1;
fputs("ERROR: Out of paper!\n", stderr);
fputs("STATUS: +media-tray-empty-error\n", stderr);
}
else if (errno != EAGAIN && errno != EINTR)
{
perror("ERROR: Unable to send print file to printer");
break;
}
}
else
{
/*
* Update count and pointer...
*/
if (paperout)
{
fputs("STATUS: -media-tray-empty-error\n", stderr);
paperout = 0;
}
nbytes -= wbytes;
bufptr += wbytes;
}
}
}
if (wbytes < 0)
break;
if (argc > 6)
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
(unsigned long)tbytes);
}
}
/*
* Close the socket connection and input file and return...
*/
close(fd);
if (fp != 0)
close(fp);
return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
}
/*
* 'list_devices()' - List all parallel devices.
*/
void
list_devices(void)
{
#if defined(__hpux) || defined(__sgi) || defined(__sun)
static char *funky_hex = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Funky hex numbering used for some devices */
#endif /* __hpux || __sgi || __sun */
#ifdef __linux
int i; /* Looping var */
int fd; /* File descriptor */
char device[255], /* Device filename */
basedevice[255], /* Base device filename for ports */
device_id[1024], /* Device ID string */
make_model[1024]; /* Make and model */
if (!access("/dev/parallel/", 0))
strcpy(basedevice, "/dev/parallel/");
else if (!access("/dev/printers/", 0))
strcpy(basedevice, "/dev/printers/");
else if (!access("/dev/par0", 0))
strcpy(basedevice, "/dev/par");
else
strcpy(basedevice, "/dev/lp");
for (i = 0; i < 4; i ++)
{
/*
* Open the port, if available...
*/
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...
*/
if (!get_device_id(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
NULL, NULL, 0))
printf("direct parallel:%s \"%s\" \"%s LPT #%d\" \"%s\"\n", device,
make_model, make_model, i + 1, device_id);
else
printf("direct parallel:%s \"Unknown\" \"LPT #%d\"\n", device, i + 1);
close(fd);
}
}
#elif defined(__sgi)
int i, j, n; /* Looping vars */
char device[255]; /* Device filename */
inventory_t *inv; /* Hardware inventory info */
/*
* IRIX maintains a hardware inventory of most devices...
*/
setinvent();
while ((inv = getinvent()) != NULL)
{
if (inv->inv_class == INV_PARALLEL &&
(inv->inv_type == INV_ONBOARD_PLP ||
inv->inv_type == INV_EPP_ECP_PLP))
{
/*
* Standard parallel port...
*/
puts("direct parallel:/dev/plp \"Unknown\" \"Onboard Parallel Port\"");
}
else if (inv->inv_class == INV_PARALLEL &&
inv->inv_type == INV_EPC_PLP)
{
/*
* EPC parallel port...
*/
printf("direct parallel:/dev/plp%d \"Unknown\" \"Integral EPC parallel port, Ebus slot %d\"\n",
inv->inv_controller, inv->inv_controller);
}
}
endinvent();
/*
* Central Data makes serial and parallel "servers" that can be
* connected in a number of ways. Look for ports...
*/
for (i = 0; i < 10; i ++)
for (j = 0; j < 8; j ++)
for (n = 0; n < 32; n ++)
{
if (i == 8) /* EtherLite */
sprintf(device, "/dev/lpn%d%c", j, funky_hex[n]);
else if (i == 9) /* PCI */
sprintf(device, "/dev/lpp%d%c", j, funky_hex[n]);
else /* SCSI */
sprintf(device, "/dev/lp%d%d%c", i, j, funky_hex[n]);
if (access(device, 0) == 0)
{
if (i == 8)
printf("direct parallel:%s \"Unknown\" \"Central Data EtherLite Parallel Port, ID %d, port %d\"\n",
device, j, n);
else if (i == 9)
printf("direct parallel:%s \"Unknown\" \"Central Data PCI Parallel Port, ID %d, port %d\"\n",
device, j, n);
else
printf("direct parallel:%s \"Unknown\" \"Central Data SCSI Parallel Port, logical bus %d, ID %d, port %d\"\n",
device, i, j, n);
}
}
#elif defined(__sun)
int i, j, n; /* Looping vars */
char device[255]; /* Device filename */
/*
* Standard parallel ports...
*/
for (i = 0; i < 10; i ++)
{
sprintf(device, "/dev/ecpp%d", i);
if (access(device, 0) == 0)
printf("direct parallel:%s \"Unknown\" \"Sun IEEE-1284 Parallel Port #%d\"\n",
device, i + 1);
}
for (i = 0; i < 10; i ++)
{
sprintf(device, "/dev/bpp%d", i);
if (access(device, 0) == 0)
printf("direct parallel:%s \"Unknown\" \"Sun Standard Parallel Port #%d\"\n",
device, i + 1);
}
for (i = 0; i < 3; i ++)
{
sprintf(device, "/dev/lp%d", i);
if (access(device, 0) == 0)
printf("direct parallel:%s \"Unknown\" \"PC Parallel Port #%d\"\n",
device, i + 1);
}
/*
* MAGMA parallel ports...
*/
for (i = 0; i < 40; i ++)
{
sprintf(device, "/dev/pm%02d", i);
if (access(device, 0) == 0)
printf("direct parallel:%s \"Unknown\" \"MAGMA Parallel Board #%d Port #%d\"\n",
device, (i / 10) + 1, (i % 10) + 1);
}
/*
* Central Data parallel ports...
*/
for (i = 0; i < 9; i ++)
for (j = 0; j < 8; j ++)
for (n = 0; n < 32; n ++)
{
if (i == 8) /* EtherLite */
sprintf(device, "/dev/sts/lpN%d%c", j, funky_hex[n]);
else
sprintf(device, "/dev/sts/lp%c%d%c", i + 'C', j,
funky_hex[n]);
if (access(device, 0) == 0)
{
if (i == 8)
printf("direct parallel:%s \"Unknown\" \"Central Data EtherLite Parallel Port, ID %d, port %d\"\n",
device, j, n);
else
printf("direct parallel:%s \"Unknown\" \"Central Data SCSI Parallel Port, logical bus %d, ID %d, port %d\"\n",
device, i, j, n);
}
}
#elif defined(__hpux)
int i, j, n; /* Looping vars */
char device[255]; /* Device filename */
/*
* Standard parallel ports...
*/
if (access("/dev/rlp", 0) == 0)
puts("direct parallel:/dev/rlp \"Unknown\" \"Standard Parallel Port (/dev/rlp)\"");
for (i = 0; i < 7; i ++)
for (j = 0; j < 7; j ++)
{
sprintf(device, "/dev/c%dt%dd0_lp", i, j);
if (access(device, 0) == 0)
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d,%d\"\n",
device, i, j);
}
/*
* Central Data parallel ports...
*/
for (i = 0; i < 9; i ++)
for (j = 0; j < 8; j ++)
for (n = 0; n < 32; n ++)
{
if (i == 8) /* EtherLite */
sprintf(device, "/dev/lpN%d%c", j, funky_hex[n]);
else
sprintf(device, "/dev/lp%c%d%c", i + 'C', j,
funky_hex[n]);
if (access(device, 0) == 0)
{
if (i == 8)
printf("direct parallel:%s \"Unknown\" \"Central Data EtherLite Parallel Port, ID %d, port %d\"\n",
device, j, n);
else
printf("direct parallel:%s \"Unknown\" \"Central Data SCSI Parallel Port, logical bus %d, ID %d, port %d\"\n",
device, i, j, n);
}
}
#elif defined(__osf__)
int i; /* Looping var */
int fd; /* File descriptor */
char device[255]; /* Device filename */
for (i = 0; i < 3; i ++)
{
sprintf(device, "/dev/lp%d", i);
if ((fd = open(device, O_WRONLY)) >= 0)
{
close(fd);
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
}
}
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
int i; /* Looping var */
int fd; /* File descriptor */
char device[255]; /* Device filename */
for (i = 0; i < 3; i ++)
{
sprintf(device, "/dev/lpt%d", i);
if ((fd = open(device, O_WRONLY)) >= 0)
{
close(fd);
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d (interrupt-driven)\"\n", device, i + 1);
}
sprintf(device, "/dev/lpa%d", i);
if ((fd = open(device, O_WRONLY)) >= 0)
{
close(fd);
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d (polled)\"\n", device, i + 1);
}
}
#elif defined(_AIX)
int i; /* Looping var */
int fd; /* File descriptor */
char device[255]; /* Device filename */
for (i = 0; i < 8; i ++)
{
sprintf(device, "/dev/lp%d", i);
if ((fd = open(device, O_WRONLY)) >= 0)
{
close(fd);
printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
}
}
#endif
}
/*
* End of "$Id$".
*/
-24
Ver Arquivo
@@ -1,24 +0,0 @@
#!/bin/sh
#
# Psuedo-backend for CUPS testing purposes.
#
# Copyright 2011 by Apple Inc.
#
# 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/".
#
# This file is subject to the Apple OS-Developed Software exception.
#
if test $# = 0; then
echo 'direct pseudo:///deskjet "HP DeskJet" "HP DeskJet (pseudo)" "MFG:HP;MDL:DeskJet;CMD:PCL;" "Nowhere"'
echo 'direct pseudo:///laserjet "HP LaserJet" "HP LaserJet (pseudo)" "MFG:HP;MDL:LaserJet;CMD:PCL;" "Nowhere"'
exit 0
fi
cat $6 >/dev/null
sleep 5
exit 0
-520
Ver Arquivo
@@ -1,520 +0,0 @@
/*
* Common run loop APIs for CUPS backends.
*
* Copyright © 2007-2014 by Apple Inc.
* Copyright © 2006-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers.
*/
#include "backend-private.h"
#include <limits.h>
#include <sys/select.h>
/*
* '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)
{
fprintf(stderr, "DEBUG: Read failed: %s\n", strerror(errno));
_cupsLangPrintFilter(stderr, "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, (size_t)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)
{
_cupsLangPrintError("ERROR", _("Unable to write print data"));
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 snmp_fd, /* I - SNMP socket or -1 if none */
http_addr_t *addr, /* I - Address of device */
int use_bc, /* I - Use back-channel? */
int update_state, /* I - Update printer-state-reasons? */
_cups_sccb_t side_cb) /* 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 */
struct timeval timeout; /* Timeout for select() */
time_t curtime, /* Current time */
snmp_update = 0;
#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, snmp_fd=%d, "
"addr=%p, use_bc=%d, side_cb=%p)\n",
print_fd, device_fd, snmp_fd, addr, 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 */
}
else if (print_fd < 0)
{
/*
* Copy print data from stdin, but don't mess with the signal handlers...
*/
print_fd = 0;
}
/*
* 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)
{
timeout.tv_sec = 5;
timeout.tv_usec = 0;
if (select(nfds, &input, &output, NULL, &timeout) < 0)
{
/*
* Pause printing to clear any pending errors...
*/
if (errno == ENXIO && offline != 1 && update_state)
{
fputs("STATE: +offline-report\n", stderr);
_cupsLangPrintFilter(stderr, "INFO",
_("The printer is not connected."));
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...
*/
if ((*side_cb)(print_fd, device_fd, snmp_fd, addr, use_bc))
side_cb = NULL;
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, (size_t)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;
}
else if (bc_bytes == 0)
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)
{
fprintf(stderr, "DEBUG: Read failed: %s\n", strerror(errno));
_cupsLangPrintFilter(stderr, "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, (size_t)print_bytes)) < 0)
{
/*
* Write error - bail if we don't see an error we can retry...
*/
if (errno == ENOSPC)
{
if (paperout != 1 && update_state)
{
fputs("STATE: +media-empty-warning\n", stderr);
fputs("DEBUG: Out of paper\n", stderr);
paperout = 1;
}
}
else if (errno == ENXIO)
{
if (offline != 1 && update_state)
{
fputs("STATE: +offline-report\n", stderr);
_cupsLangPrintFilter(stderr, "INFO",
_("The printer is not connected."));
offline = 1;
}
}
else if (errno != EAGAIN && errno != EINTR && errno != ENOTTY)
{
_cupsLangPrintError("ERROR", _("Unable to write print data"));
return (-1);
}
}
else
{
if (paperout && update_state)
{
fputs("STATE: -media-empty-warning\n", stderr);
paperout = 0;
}
if (offline && update_state)
{
fputs("STATE: -offline-report\n", stderr);
_cupsLangPrintFilter(stderr, "INFO",
_("The printer is now connected."));
offline = 0;
}
fprintf(stderr, "DEBUG: Wrote %d bytes of print data...\n", (int)bytes);
print_bytes -= bytes;
print_ptr += bytes;
total_bytes += bytes;
}
}
/*
* Do SNMP updates periodically...
*/
if (snmp_fd >= 0 && time(&curtime) >= snmp_update)
{
if (backendSNMPSupplies(snmp_fd, addr, NULL, NULL))
snmp_update = INT_MAX;
else
snmp_update = curtime + 5;
}
}
/*
* Return with success...
*/
return (total_bytes);
}
/*
* 'backendWaitLoop()' - Wait for input from stdin while handling side-channel
* queries.
*/
int /* O - 1 if data is ready, 0 if not */
backendWaitLoop(
int snmp_fd, /* I - SNMP socket or -1 if none */
http_addr_t *addr, /* I - Address of device */
int use_bc, /* I - Use back-channel? */
_cups_sccb_t side_cb) /* I - Side-channel callback */
{
int nfds; /* Number of file descriptors */
fd_set input; /* Input set for reading */
time_t curtime = 0, /* Current time */
snmp_update = 0;/* Last SNMP status update */
struct timeval timeout; /* Timeout for select() */
fprintf(stderr, "DEBUG: backendWaitLoop(snmp_fd=%d, addr=%p, side_cb=%p)\n",
snmp_fd, addr, side_cb);
/*
* Now loop until we receive data from stdin...
*/
if (snmp_fd >= 0)
snmp_update = time(NULL) + 5;
for (;;)
{
/*
* Use select() to determine whether we have data to copy around...
*/
FD_ZERO(&input);
FD_SET(0, &input);
if (side_cb)
FD_SET(CUPS_SC_FD, &input);
if (snmp_fd >= 0)
{
curtime = time(NULL);
timeout.tv_sec = curtime >= snmp_update ? 0 : snmp_update - curtime;
timeout.tv_usec = 0;
nfds = select(CUPS_SC_FD + 1, &input, NULL, NULL, &timeout);
}
else
nfds = select(CUPS_SC_FD + 1, &input, NULL, NULL, NULL);
if (nfds < 0)
{
/*
* Pause printing to clear any pending errors...
*/
if (errno == EINTR)
{
fputs("DEBUG: Received an interrupt before any bytes were "
"written, aborting.\n", stderr);
return (0);
}
sleep(1);
continue;
}
/*
* Check for input on stdin...
*/
if (FD_ISSET(0, &input))
break;
/*
* 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...
*/
if ((*side_cb)(0, -1, snmp_fd, addr, use_bc))
side_cb = NULL;
continue;
}
/*
* Do SNMP updates periodically...
*/
if (snmp_fd >= 0 && curtime >= snmp_update)
{
if (backendSNMPSupplies(snmp_fd, addr, NULL, NULL))
snmp_fd = -1;
else
snmp_update = curtime + 5;
}
}
/*
* Return with success...
*/
return (1);
}
+235
Ver Arquivo
@@ -0,0 +1,235 @@
/*
* "$Id$"
*
* IRIX SCSI printer support for the Common UNIX Printing System (CUPS).
*
* 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
* 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:
*
* list_devices() - List the available SCSI printer devices.
* print_device() - Print a file to a SCSI device.
*/
/*
* Include necessary headers.
*/
#include <bstring.h> /* memcpy() and friends */
#include <sys/dsreq.h> /* SCSI interface stuff */
/*
* 'list_devices()' - List the available SCSI printer devices.
*/
void
list_devices(void)
{
puts("direct scsi \"Unknown\" \"SCSI Printer\"");
}
/*
* 'print_device()' - Print a file to a SCSI device.
*/
int /* O - Print status */
print_device(const char *resource, /* I - SCSI device */
int fd, /* I - File to print */
int copies) /* I - Number of copies to print */
{
int scsi_fd; /* SCSI file descriptor */
char buffer[8192]; /* Data buffer */
int bytes; /* Number of bytes */
int try; /* Current try */
dsreq_t scsi_req; /* SCSI request */
char scsi_cmd[6]; /* SCSI command data */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
/*
* Make sure we have a valid resource name...
*/
if (strncmp(resource, "/dev/scsi/", 10) != 0)
{
fprintf(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.
*/
fputs("INFO: Unable to open SCSI device, queuing on next printer in class...\n",
stderr);
/*
* 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 (CUPS_BACKEND_FAILED);
}
else
{
fprintf(stderr, "INFO: SCSI device \"%s\" busy; retrying...\n",
resource);
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
* current page... Only ignore SIGTERM if we are printing data from
* stdin (otherwise you can't cancel raw jobs...)
*/
if (fd != 0)
{
#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 */
}
/*
* Copy the print file to the device...
*/
while (copies > 0)
{
if (fd != 0)
lseek(fd, 0, SEEK_SET);
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
{
memset(&scsi_req, 0, sizeof(scsi_req));
scsi_req.ds_flags = DSRQ_WRITE;
scsi_req.ds_time = 60 * 1000;
scsi_req.ds_cmdbuf = scsi_cmd;
scsi_req.ds_cmdlen = 6;
scsi_req.ds_databuf = buffer;
scsi_req.ds_datalen = bytes;
scsi_cmd[0] = 0x0a; /* Group 0 print command */
scsi_cmd[1] = 0x00;
scsi_cmd[2] = bytes / 65536;
scsi_cmd[3] = bytes / 256;
scsi_cmd[4] = bytes;
scsi_cmd[5] = 0x00;
for (try = 0; try < 10; try ++)
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);
sleep(try + 1);
}
else
break;
if (try >= 10)
{
fprintf(stderr, "ERROR: Unable to send print data (%d)\n",
scsi_req.ds_status);
close(scsi_fd);
return (CUPS_BACKEND_FAILED);
}
}
copies --;
}
/*
* Close the device and return...
*/
close(fd);
return (CUPS_BACKEND_OK);
}
/*
* End of "$Id$".
*/
+253
Ver Arquivo
@@ -0,0 +1,253 @@
/*
* "$Id$"
*
* Linux SCSI printer support for the Common UNIX Printing System (CUPS).
*
* 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
* 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:
*
* list_devices() - List the available SCSI printer devices.
* print_device() - Print a file to a SCSI device.
*/
/*
* Include necessary headers.
*/
#include <scsi/sg.h>
/*
* We currently only support the Linux 2.4 generic SCSI interface.
*/
#ifndef SG_DXFER_TO_DEV
/*
* Dummy functions that do nothing on unsupported platforms...
*/
void list_devices(void) {}
int print_device(const char *resource, int fd, int copies) { return (1); }
#else
/*
* 'list_devices()' - List the available SCSI printer devices.
*/
void
list_devices(void)
{
puts("direct scsi \"Unknown\" \"SCSI Printer\"");
}
/*
* 'print_device()' - Print a file to a SCSI device.
*/
int /* O - Print status */
print_device(const char *resource, /* I - SCSI device */
int fd, /* I - File to print */
int copies) /* I - Number of copies to print */
{
int scsi_fd; /* SCSI file descriptor */
char buffer[8192]; /* Data buffer */
int bytes; /* Number of bytes */
int try; /* Current try */
sg_io_hdr_t scsi_req; /* SCSI request */
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 */
# endif /* HAVE_SIGACTION && !HAVE_SIGSET */
/*
* Make sure we have a valid resource name...
*/
if (strncmp(resource, "/dev/sg", 7) != 0)
{
fprintf(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.
*/
fputs("INFO: Unable to open SCSI device, queuing on next printer in class...\n",
stderr);
/*
* 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 (CUPS_BACKEND_FAILED);
}
else
{
fprintf(stderr, "INFO: SCSI device \"%s\" busy; retrying...\n",
resource);
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
* current page... Only ignore SIGTERM if we are printing data from
* stdin (otherwise you can't cancel raw jobs...)
*/
if (fd != 0)
{
# 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 */
}
/*
* Copy the print file to the device...
*/
while (copies > 0)
{
if (fd != 0)
lseek(fd, 0, SEEK_SET);
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
{
memset(&scsi_req, 0, sizeof(scsi_req));
scsi_req.interface_id = 'S';
scsi_req.dxfer_direction = SG_DXFER_TO_DEV;
scsi_req.cmd_len = 6;
scsi_req.mx_sb_len = sizeof(scsi_sense);
scsi_req.iovec_count = 0;
scsi_req.dxfer_len = bytes;
scsi_req.dxferp = buffer;
scsi_req.cmdp = scsi_cmd;
scsi_req.sbp = scsi_sense;
scsi_req.timeout = 60 * 1000;
scsi_cmd[0] = 0x0a; /* Group 0 print command */
scsi_cmd[1] = 0x00;
scsi_cmd[2] = bytes / 65536;
scsi_cmd[3] = bytes / 256;
scsi_cmd[4] = bytes;
scsi_cmd[5] = 0x00;
for (try = 0; try < 10; try ++)
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);
sleep(try + 1);
}
else
break;
if (try >= 10)
{
fprintf(stderr, "ERROR: Unable to send print data (%d)\n",
scsi_req.status);
close(scsi_fd);
return (CUPS_BACKEND_FAILED);
}
}
copies --;
}
/*
* Close the device and return...
*/
close(fd);
return (CUPS_BACKEND_OK);
}
#endif /* !SG_DXFER_TO_DEV */
/*
* End of "$Id$".
*/
+224
Ver Arquivo
@@ -0,0 +1,224 @@
/*
* "$Id$"
*
* SCSI printer backend for the Common UNIX Printing System (CUPS).
*
* 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
* 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 specified SCSI printer.
*/
/*
* Include necessary headers.
*/
#include <cups/backend.h>
#include <cups/cups.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <cups/string.h>
#include <signal.h>
#ifdef WIN32
# include <io.h>
#else
# include <unistd.h>
# include <fcntl.h>
# ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
# endif /* HAVE_SYS_IOCTL_H */
#endif /* WIN32 */
/*
* Local functions...
*/
void list_devices(void);
int print_device(const char *resource, int fd, int copies);
#ifdef __linux__
# include "scsi-linux.c"
#elif defined(__sgi)
# include "scsi-irix.c"
#else
/*
* Dummy functions that do nothing on unsupported platforms...
*/
void list_devices(void) {}
int print_device(const char *resource, int fd, int copies) { return (CUPS_BACKEND_FAILED); }
#endif /* __linux */
/*
* 'main()' - Send a file to the specified SCSI 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 */
{
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 status; /* Exit status */
#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);
/*
* Ignore SIGPIPE signals...
*/
#ifdef HAVE_SIGSET
sigset(SIGPIPE, SIG_IGN);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
#else
signal(SIGPIPE, SIG_IGN);
#endif /* HAVE_SIGSET */
/*
* Check command-line...
*/
if (argc == 1)
{
list_devices();
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 (CUPS_BACKEND_FAILED);
}
/*
* 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 (CUPS_BACKEND_FAILED);
}
copies = atoi(argv[4]);
}
/*
* Extract the device name and options from the URI...
*/
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...
*/
if ((options = strchr(resource, '?')) != NULL)
{
/*
* Yup, terminate the device name string and move to the first
* character of the options...
*/
*options++ = '\0';
}
/*
* Finally, send the print file...
*/
status = print_device(resource, fp, copies);
/*
* Close input file and return...
*/
if (fp != 0)
close(fp);
return (status);
}
/*
* End of "$Id$".
*/
+1138
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-1356
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-172
Ver Arquivo
@@ -1,172 +0,0 @@
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
+293 -290
Ver Arquivo
@@ -1,24 +1,50 @@
/*
* AppSocket backend for CUPS.
* "$Id$"
*
* Copyright © 2007-2018 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
* AppSocket backend for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* main() - Send a file to the printer or server.
*/
/*
* Include necessary headers.
*/
#include <cups/backend.h>
#include <cups/http-private.h>
#include "backend-private.h"
#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
#ifdef WIN32
# include <winsock.h>
#else
# include <unistd.h>
@@ -27,14 +53,7 @@
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
#endif /* _WIN32 */
/*
* Local functions...
*/
static ssize_t wait_bc(int device_fd, int secs);
#endif /* WIN32 */
/*
@@ -49,35 +68,32 @@ int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
const char *device_uri; /* Device URI */
char scheme[255], /* Scheme in URI */
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 */
name[255], /* Name of option */
value[255], /* Value of option */
*ptr; /* Pointer into name or value */
int fp; /* Print file */
int copies; /* Number of copies to print */
time_t start_time; /* Time of first connect */
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 fd; /* AppSocket */
int error; /* Error code (if any) */
http_addrlist_t *addrlist, /* Address list */
*addr; /* Connected address */
char addrname[256]; /* Address name */
int snmp_enabled = 1; /* Is SNMP enabled? */
int snmp_fd, /* SNMP socket */
start_count, /* Page count via SNMP at start */
page_count, /* Page count via SNMP */
have_supplies; /* Printer supports supply levels? */
ssize_t bytes = 0, /* Initial bytes read */
tbytes; /* Total number of bytes written */
char buffer[1024]; /* Initial print buffer */
http_addrlist_t *addrlist; /* Address list */
int rbytes; /* Number of bytes read */
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() */
output; /* Output set for select() */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
@@ -109,15 +125,13 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
if (argc == 1)
{
printf("network socket \"Unknown\" \"%s\"\n",
_cupsLangString(cupsLangDefault(), _("AppSocket/HP JetDirect")));
puts("network socket \"Unknown\" \"AppSocket/HP JetDirect\"");
return (CUPS_BACKEND_OK);
}
else if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
_("Usage: %s job-id user title copies options [file]"),
argv[0]);
fprintf(stderr, "Usage: %s job-id user title copies options [file]\n",
argv[0]);
return (CUPS_BACKEND_FAILED);
}
@@ -128,8 +142,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
if (argc == 6)
{
print_fd = 0;
copies = 1;
fp = 0;
copies = 1;
}
else
{
@@ -137,9 +151,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Try to open the print file...
*/
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
if ((fp = open(argv[6], O_RDONLY)) < 0)
{
_cupsLangPrintError("ERROR", _("Unable to open print file"));
perror("ERROR: unable to open print file");
return (CUPS_BACKEND_FAILED);
}
@@ -150,17 +164,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Extract the hostname and port number from the URI...
*/
while ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
{
_cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer."));
sleep(10);
if (getenv("CLASS") != NULL)
return (CUPS_BACKEND_FAILED);
}
httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme),
username, sizeof(username), hostname, sizeof(hostname), &port,
httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
method, sizeof(method), username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
if (port == 0)
@@ -170,8 +176,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Get options, if any...
*/
waiteof = 1;
contimeout = 7 * 24 * 60 * 60;
waiteof = 1;
if ((options = strchr(resource, '?')) != NULL)
{
@@ -192,302 +197,300 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Get the name...
*/
name = options;
for (ptr = name; *options && *options != '=';)
if (ptr < (name + sizeof(name) - 1))
*ptr++ = *options++;
*ptr = '\0';
while (*options && *options != '=' && *options != '+' && *options != '&')
options ++;
if ((sep = *options) != '\0')
*options++ = '\0';
if (sep == '=')
if (*options == '=')
{
/*
* Get the value...
*/
value = options;
options ++;
while (*options && *options != '+' && *options != '&')
for (ptr = value; *options && *options != '+' && *options != '&';)
if (ptr < (value + sizeof(value) - 1))
*ptr++ = *options++;
*ptr = '\0';
if (*options == '+' || *options == '&')
options ++;
if (*options)
*options++ = '\0';
}
else
value = (char *)"";
value[0] = '\0';
/*
* Process the option...
*/
if (!_cups_strcasecmp(name, "waiteof"))
if (!strcasecmp(name, "waiteof"))
{
/*
* Set the wait-for-eof value...
*/
waiteof = !value[0] || !_cups_strcasecmp(value, "on") ||
!_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true");
}
else if (!_cups_strcasecmp(name, "snmp"))
{
/*
* Enable/disable SNMP stuff...
*/
snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
!_cups_strcasecmp(value, "yes") ||
!_cups_strcasecmp(value, "true");
}
else if (!_cups_strcasecmp(name, "contimeout"))
{
/*
* Set the connection timeout...
*/
if (atoi(value) > 0)
contimeout = atoi(value);
waiteof = !value[0] || !strcasecmp(value, "on") ||
!strcasecmp(value, "yes") || !strcasecmp(value, "true");
}
}
}
/*
* Then try finding the remote host...
* Then try to connect to the remote host...
*/
start_time = time(NULL);
sprintf(portname, "%d", port);
addrlist = backendLookup(hostname, port, NULL);
/*
* See if the printer supports SNMP...
*/
if (snmp_enabled)
snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);
else
snmp_fd = -1;
if (snmp_fd >= 0)
have_supplies = !backendSNMPSupplies(snmp_fd, &(addrlist->addr),
&start_count, NULL);
else
have_supplies = start_count = 0;
/*
* Wait for data from the filter...
*/
if (print_fd == 0)
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
{
if (!backendWaitLoop(snmp_fd, &(addrlist->addr), 1, backendNetworkSideCB))
return (CUPS_BACKEND_OK);
else if ((bytes = read(0, buffer, sizeof(buffer))) <= 0)
return (CUPS_BACKEND_OK);
fprintf(stderr, "ERROR: Unable to locate printer \'%s\'!\n", hostname);
return (CUPS_BACKEND_STOP);
}
/*
* Connect to the printer...
*/
fprintf(stderr, "INFO: Attempting to connect to host %s on port %d\n",
hostname, port);
fprintf(stderr, "DEBUG: Connecting to %s:%d\n", hostname, port);
_cupsLangPrintFilter(stderr, "INFO", _("Connecting to printer."));
wbytes = 0;
for (delay = 5;;)
while (copies > 0)
{
if ((addr = httpAddrConnect(addrlist, &device_fd)) == NULL)
fputs("STATE: +connecting-to-device\n", stderr);
for (delay = 5;;)
{
error = errno;
device_fd = -1;
if (getenv("CLASS") != NULL)
if (!httpAddrConnect(addrlist, &fd))
{
/*
* 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.
*/
error = errno;
fd = -1;
_cupsLangPrintFilter(stderr, "INFO",
_("Unable to contact printer, queuing on next "
"printer in class."));
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
*/
sleep(5);
return (CUPS_BACKEND_FAILED);
}
fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(error));
if (errno == ECONNREFUSED || errno == EHOSTDOWN || errno == EHOSTUNREACH || errno == ETIMEDOUT || errno == ENOTCONN)
{
if (contimeout && (time(NULL) - start_time) > contimeout)
if (getenv("CLASS") != NULL)
{
_cupsLangPrintFilter(stderr, "ERROR",
_("The printer is not responding."));
return (CUPS_BACKEND_FAILED);
/*
* 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.
*/
fprintf(stderr, "INFO: Unable to connect to \"%s\", queuing on next printer in class...\n",
hostname);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
*/
sleep(5);
return (CUPS_BACKEND_FAILED);
}
switch (error)
if (error == ECONNREFUSED || error == EHOSTDOWN ||
error == EHOSTUNREACH)
{
case EHOSTDOWN :
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer may not exist or "
"is unavailable at this time."));
break;
fprintf(stderr, "INFO: Network host \'%s\' is busy; will retry in %d seconds...\n",
hostname, delay);
sleep(delay);
case EHOSTUNREACH :
default :
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer is unreachable at this "
"time."));
break;
case ECONNREFUSED :
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer is in use."));
break;
}
sleep((unsigned)delay);
if (delay < 30)
delay += 5;
if (delay < 30)
delay += 5;
}
else
{
perror("ERROR: Unable to connect to printer (retrying in 30 seconds)");
sleep(30);
}
}
else
{
_cupsLangPrintFilter(stderr, "ERROR",
_("The printer is not responding."));
sleep(30);
}
}
else
break;
}
fputs("STATE: -connecting-to-device\n", stderr);
_cupsLangPrintFilter(stderr, "INFO", _("Connected to printer."));
fprintf(stderr, "DEBUG: Connected to %s:%d...\n",
httpAddrString(&(addr->addr), addrname, sizeof(addrname)),
httpAddrPort(&(addr->addr)));
/*
* Print everything...
*/
tbytes = 0;
if (bytes > 0)
tbytes += write(device_fd, buffer, (size_t)bytes);
while (copies > 0 && tbytes >= 0)
{
copies --;
if (print_fd != 0)
{
fputs("PAGE: 1 1\n", stderr);
lseek(print_fd, 0, SEEK_SET);
break;
}
if ((bytes = backendRunLoop(print_fd, device_fd, snmp_fd, &(addrlist->addr), 1, 0, backendNetworkSideCB)) < 0)
tbytes = -1;
else
tbytes = bytes;
fputs("STATE: -connecting-to-device\n", stderr);
if (print_fd != 0 && tbytes >= 0)
_cupsLangPrintFilter(stderr, "INFO", _("Print file sent."));
}
fputs("STATE: +cups-waiting-for-job-completed\n", stderr);
if (waiteof && tbytes >= 0)
{
/*
* Shutdown the socket and wait for the other end to finish...
* 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...)
*/
_cupsLangPrintFilter(stderr, "INFO", _("Waiting for printer to finish."));
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));
shutdown(device_fd, 1);
sigemptyset(&action.sa_mask);
action.sa_handler = SIG_IGN;
sigaction(SIGTERM, &action, NULL);
#else
signal(SIGTERM, SIG_IGN);
#endif /* HAVE_SIGSET */
}
while (wait_bc(device_fd, 90) > 0);
/*
* 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)
{
/*
* See if we are ready to read or write...
*/
do
{
FD_ZERO(&input);
FD_SET(fd, &input);
FD_ZERO(&output);
FD_SET(fd, &output);
}
while (select(fd + 1, &input, &output, NULL, NULL) < 0);
if (FD_ISSET(fd, &input))
{
/*
* Read backchannel data...
*/
if ((rbytes = recv(fd, resource, sizeof(resource), 0)) > 0)
{
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
rbytes);
cupsBackChannelWrite(resource, rbytes, 1.0);
}
}
if (FD_ISSET(fd, &output))
{
/*
* Write print data...
*/
if ((wbytes = send(fd, bufptr, nbytes, 0)) < 0)
{
/*
* Check for retryable errors...
*/
if (errno != EAGAIN && errno != EINTR)
{
perror("ERROR: Unable to send print file to printer");
break;
}
}
else
{
/*
* Update count and pointer...
*/
nbytes -= wbytes;
bufptr += wbytes;
}
}
}
if (wbytes < 0)
break;
if (argc > 6)
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
(unsigned long)tbytes);
}
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);
shutdown(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 ((rbytes = recv(fd, resource, sizeof(resource), 0)) > 0)
{
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
rbytes);
cupsBackChannelWrite(resource, rbytes, 1.0);
}
else
break;
}
else
break;
}
}
/*
* Close the socket connection...
*/
close(fd);
}
/*
* Collect the final page count as needed...
*/
if (have_supplies &&
!backendSNMPSupplies(snmp_fd, &(addrlist->addr), &page_count, NULL) &&
page_count > start_count)
fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
/*
* Close the socket connection...
*/
close(device_fd);
httpAddrFreeList(addrlist);
/*
* Close the input file and return...
*/
if (print_fd != 0)
close(print_fd);
if (fp != 0)
close(fp);
return (tbytes >= 0 ? CUPS_BACKEND_OK : CUPS_BACKEND_FAILED);
if (wbytes >= 0)
fputs("INFO: Ready to print.\n", stderr);
return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
}
/*
* 'wait_bc()' - Wait for back-channel data...
* End of "$Id$".
*/
static ssize_t /* 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, (size_t)bytes, 1.0);
}
return (bytes);
}
else
return (-1);
}
+38 -11
Ver Arquivo
@@ -1,25 +1,47 @@
/*
* IEEE-1284 support functions test program for CUPS.
* "$Id$"
*
* Copyright © 2007-2010 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products, all rights reserved.
* IEEE-1284 support functions test program for the Common UNIX Printing
* System (CUPS).
*
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers.
*/
#include <cups/string-private.h>
#ifdef _WIN32
#include <cups/string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef WIN32
# include <io.h>
#else
# include <unistd.h>
# include <fcntl.h>
#endif /* _WIN32 */
#endif /* WIN32 */
#define DEBUG
#include "ieee1284.c"
@@ -54,8 +76,8 @@ main(int argc, /* I - Number of command-line args */
printf("%s:\n", argv[i]);
backendGetDeviceID(fd, device_id, sizeof(device_id), make_model,
sizeof(make_model), "test", uri, sizeof(uri));
get_device_id(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);
@@ -66,3 +88,8 @@ main(int argc, /* I - Number of command-line args */
return (0);
}
/*
* End of "$Id$".
*/
-672
Ver Arquivo
@@ -1,672 +0,0 @@
/*
* Backend test program for CUPS.
*
* Copyright © 2007-2014 by Apple Inc.
* Copyright © 1997-2005 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers.
*/
#include <cups/string-private.h>
#include <cups/cups.h>
#include <cups/sidechannel.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>
/*
* Local globals...
*/
static int job_canceled = 0;
/*
* Local functions...
*/
static void sigterm_handler(int sig);
static void usage(void) _CUPS_NORETURN;
static void walk_cb(const char *oid, const char *data, int datalen,
void *context);
/*
* 'main()' - Run the named backend.
*
* Usage:
*
* testbackend [-s] [-t] device-uri job-id user title copies options [file]
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
int first_arg, /* First argument for backend */
do_cancel = 0, /* Simulate a cancel-job via SIGTERM */
do_ps = 0, /* Do PostScript query+test? */
do_pcl = 0, /* Do PCL query+test? */
do_side_tests = 0, /* Test side-channel ops? */
do_trickle = 0, /* Trickle data to backend */
do_walk = 0, /* Do OID lookup (0) or walking (1) */
show_log = 0; /* Show log messages from backends? */
const char *oid = ".1.3.6.1.2.1.43.10.2.1.4.1.1";
/* OID to lookup or walk */
char scheme[255], /* Scheme in URI == backend */
backend[1024], /* Backend path */
libpath[1024], /* Path for libcups */
*ptr; /* Pointer into path */
const char *serverbin; /* CUPS_SERVERBIN environment variable */
int fd, /* Temporary file descriptor */
back_fds[2], /* Back-channel pipe */
side_fds[2], /* Side-channel socket */
data_fds[2], /* Data pipe */
back_pid = -1, /* Backend process ID */
data_pid = -1, /* Trickle process ID */
pid, /* Process ID */
status; /* Exit status */
/*
* Get the current directory and point the run-time linker at the "cups"
* subdirectory...
*/
if (getcwd(libpath, sizeof(libpath)) &&
(ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend"))
{
strlcpy(ptr, "/cups", sizeof(libpath) - (size_t)(ptr - libpath));
if (!access(libpath, 0))
{
#ifdef __APPLE__
fprintf(stderr, "Setting DYLD_LIBRARY_PATH to \"%s\".\n", libpath);
setenv("DYLD_LIBRARY_PATH", libpath, 1);
#else
fprintf(stderr, "Setting LD_LIBRARY_PATH to \"%s\".\n", libpath);
setenv("LD_LIBRARY_PATH", libpath, 1);
#endif /* __APPLE__ */
}
else
perror(libpath);
}
/*
* See if we have side-channel tests to do...
*/
for (first_arg = 1;
argv[first_arg] && argv[first_arg][0] == '-';
first_arg ++)
if (!strcmp(argv[first_arg], "-d"))
show_log = 1;
else if (!strcmp(argv[first_arg], "-cancel"))
do_cancel = 1;
else if (!strcmp(argv[first_arg], "-pcl"))
do_pcl = 1;
else if (!strcmp(argv[first_arg], "-ps"))
do_ps = 1;
else if (!strcmp(argv[first_arg], "-s"))
do_side_tests = 1;
else if (!strcmp(argv[first_arg], "-t"))
do_trickle = 1;
else if (!strcmp(argv[first_arg], "-get") && (first_arg + 1) < argc)
{
first_arg ++;
do_side_tests = 1;
oid = argv[first_arg];
}
else if (!strcmp(argv[first_arg], "-walk") && (first_arg + 1) < argc)
{
first_arg ++;
do_side_tests = 1;
do_walk = 1;
oid = argv[first_arg];
}
else
usage();
argc -= first_arg;
if (argc < 6 || argc > 7 || (argc == 7 && do_trickle))
usage();
/*
* Extract the scheme from the device-uri - that's the program we want to
* execute.
*/
if (sscanf(argv[first_arg], "%254[^:]", scheme) != 1)
{
fputs("testbackend: Bad device-uri - no colon!\n", stderr);
return (1);
}
if (!access(scheme, X_OK))
strlcpy(backend, scheme, sizeof(backend));
else
{
if ((serverbin = getenv("CUPS_SERVERBIN")) == NULL)
serverbin = CUPS_SERVERBIN;
snprintf(backend, sizeof(backend), "%s/backend/%s", serverbin, scheme);
if (access(backend, X_OK))
{
fprintf(stderr, "testbackend: Unknown device scheme \"%s\"!\n", scheme);
return (1);
}
}
/*
* Create the back-channel pipe and side-channel socket...
*/
open("/dev/null", O_WRONLY); /* Make sure fd 3 and 4 are used */
open("/dev/null", O_WRONLY);
pipe(back_fds);
fcntl(back_fds[0], F_SETFL, fcntl(back_fds[0], F_GETFL) | O_NONBLOCK);
fcntl(back_fds[1], F_SETFL, fcntl(back_fds[1], F_GETFL) | O_NONBLOCK);
socketpair(AF_LOCAL, SOCK_STREAM, 0, side_fds);
fcntl(side_fds[0], F_SETFL, fcntl(side_fds[0], F_GETFL) | O_NONBLOCK);
fcntl(side_fds[1], F_SETFL, fcntl(side_fds[1], F_GETFL) | O_NONBLOCK);
/*
* Execute the trickle process as needed...
*/
if (do_trickle || do_pcl || do_ps || do_cancel)
{
pipe(data_fds);
signal(SIGTERM, sigterm_handler);
if ((data_pid = fork()) == 0)
{
/*
* Trickle/query child comes here. Rearrange file descriptors so that
* FD 1, 3, and 4 point to the backend...
*/
if ((fd = open("/dev/null", O_RDONLY)) != 0)
{
dup2(fd, 0);
close(fd);
}
if (data_fds[1] != 1)
{
dup2(data_fds[1], 1);
close(data_fds[1]);
}
close(data_fds[0]);
if (back_fds[0] != 3)
{
dup2(back_fds[0], 3);
close(back_fds[0]);
}
close(back_fds[1]);
if (side_fds[0] != 4)
{
dup2(side_fds[0], 4);
close(side_fds[0]);
}
close(side_fds[1]);
if (do_trickle)
{
/*
* Write 10 spaces, 1 per second...
*/
int i; /* Looping var */
for (i = 0; i < 10; i ++)
{
write(1, " ", 1);
sleep(1);
}
}
else if (do_cancel)
{
/*
* Write PS or PCL lines until we see SIGTERM...
*/
int line = 0, page = 0; /* Current line and page */
ssize_t bytes; /* Number of bytes of response data */
char buffer[1024]; /* Output buffer */
if (do_pcl)
write(1, "\033E", 2);
else
write(1, "%!\n/Courier findfont 12 scalefont setfont 0 setgray\n", 52);
while (!job_canceled)
{
if (line == 0)
{
page ++;
if (do_pcl)
snprintf(buffer, sizeof(buffer), "PCL Page %d\r\n\r\n", page);
else
snprintf(buffer, sizeof(buffer),
"18 732 moveto (PS Page %d) show\n", page);
write(1, buffer, strlen(buffer));
}
line ++;
if (do_pcl)
snprintf(buffer, sizeof(buffer), "Line %d\r\n", line);
else
snprintf(buffer, sizeof(buffer), "18 %d moveto (Line %d) show\n",
720 - line * 12, line);
write(1, buffer, strlen(buffer));
if (line >= 55)
{
/*
* Eject after 55 lines...
*/
line = 0;
if (do_pcl)
write(1, "\014", 1);
else
write(1, "showpage\n", 9);
}
/*
* Check for back-channel data...
*/
if ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0)) > 0)
write(2, buffer, (size_t)bytes);
/*
* Throttle output to ~100hz...
*/
usleep(10000);
}
/*
* Eject current page with info...
*/
if (do_pcl)
snprintf(buffer, sizeof(buffer),
"Canceled on line %d of page %d\r\n\014\033E", line, page);
else
snprintf(buffer, sizeof(buffer),
"\n18 %d moveto (Canceled on line %d of page %d)\nshowpage\n",
720 - line * 12, line, page);
write(1, buffer, strlen(buffer));
/*
* See if we get any back-channel data...
*/
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 5.0)) > 0)
write(2, buffer, (size_t)bytes);
exit(0);
}
else
{
/*
* Do PS or PCL query + test pages.
*/
char buffer[1024]; /* Buffer for response data */
ssize_t bytes; /* Number of bytes of response data */
double timeout; /* Timeout */
const char *data; /* Data to send */
static const char *pcl_data = /* PCL data */
"\033%-12345X@PJL\r\n"
"@PJL JOB NAME = \"Hello, World!\"\r\n"
"@PJL INFO USTATUS\r\n"
"@PJL ENTER LANGUAGE = PCL\r\n"
"\033E"
"Hello, World!\n"
"\014"
"\033%-12345X@PJL\r\n"
"@PJL EOJ NAME=\"Hello, World!\"\r\n"
"\033%-12345X";
static const char *ps_data = /* PostScript data */
"%!\n"
"save\n"
"product = flush\n"
"currentpagedevice /PageSize get aload pop\n"
"2 copy gt {exch} if\n"
"(Unknown)\n"
"19 dict\n"
"dup [612 792] (Letter) put\n"
"dup [612 1008] (Legal) put\n"
"dup [612 935] (w612h935) put\n"
"dup [522 756] (Executive) put\n"
"dup [595 842] (A4) put\n"
"dup [420 595] (A5) put\n"
"dup [499 709] (ISOB5) put\n"
"dup [516 728] (B5) put\n"
"dup [612 936] (w612h936) put\n"
"dup [284 419] (Postcard) put\n"
"dup [419.5 567] (DoublePostcard) put\n"
"dup [558 774] (w558h774) put\n"
"dup [553 765] (w553h765) put\n"
"dup [522 737] (w522h737) put\n"
"dup [499 709] (EnvISOB5) put\n"
"dup [297 684] (Env10) put\n"
"dup [459 649] (EnvC5) put\n"
"dup [312 624] (EnvDL) put\n"
"dup [279 540] (EnvMonarch) put\n"
"{ exch aload pop 4 index sub abs 5 le exch\n"
" 5 index sub abs 5 le and\n"
" {exch pop exit} {pop} ifelse\n"
"} bind forall\n"
"= flush pop pop\n"
"/Courier findfont 12 scalefont setfont\n"
"0 setgray 36 720 moveto (Hello, ) show product show (!) show\n"
"showpage\n"
"restore\n"
"\004";
if (do_pcl)
data = pcl_data;
else
data = ps_data;
write(1, data, strlen(data));
write(2, "DEBUG: START\n", 13);
timeout = 60.0;
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
{
write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
write(2, "\nDEBUG: END\n", 12);
}
exit(0);
}
else if (data_pid < 0)
{
perror("testbackend: Unable to fork");
return (1);
}
}
else
data_fds[0] = data_fds[1] = -1;
/*
* Execute the backend...
*/
if ((back_pid = fork()) == 0)
{
/*
* Child comes here...
*/
if (do_trickle || do_ps || do_pcl || do_cancel)
{
if (data_fds[0] != 0)
{
dup2(data_fds[0], 0);
close(data_fds[0]);
}
close(data_fds[1]);
}
if (!show_log)
{
if ((fd = open("/dev/null", O_WRONLY)) != 2)
{
dup2(fd, 2);
close(fd);
}
}
if (back_fds[1] != 3)
{
dup2(back_fds[1], 3);
close(back_fds[0]);
}
close(back_fds[1]);
if (side_fds[1] != 4)
{
dup2(side_fds[1], 4);
close(side_fds[0]);
}
close(side_fds[1]);
execv(backend, argv + first_arg);
fprintf(stderr, "testbackend: Unable to execute \"%s\": %s\n", backend,
strerror(errno));
return (errno);
}
else if (back_pid < 0)
{
perror("testbackend: Unable to fork");
return (1);
}
/*
* Parent comes here, setup back and side channel file descriptors...
*/
if (do_trickle || do_ps || do_pcl || do_cancel)
{
close(data_fds[0]);
close(data_fds[1]);
}
if (back_fds[0] != 3)
{
dup2(back_fds[0], 3);
close(back_fds[0]);
}
close(back_fds[1]);
if (side_fds[0] != 4)
{
dup2(side_fds[0], 4);
close(side_fds[0]);
}
close(side_fds[1]);
/*
* Do side-channel tests as needed, then wait for the backend...
*/
if (do_side_tests)
{
int length; /* Length of buffer */
char buffer[2049]; /* Buffer for reponse */
cups_sc_status_t scstatus; /* Status of side-channel command */
static const char * const statuses[] =
{
"CUPS_SC_STATUS_NONE", /* No status */
"CUPS_SC_STATUS_OK", /* Operation succeeded */
"CUPS_SC_STATUS_IO_ERROR", /* An I/O error occurred */
"CUPS_SC_STATUS_TIMEOUT", /* The backend did not respond */
"CUPS_SC_STATUS_NO_RESPONSE", /* The device did not respond */
"CUPS_SC_STATUS_BAD_MESSAGE", /* The command/response message was invalid */
"CUPS_SC_STATUS_TOO_BIG", /* Response too big */
"CUPS_SC_STATUS_NOT_IMPLEMENTED" /* Command not implemented */
};
sleep(2);
length = 0;
scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, buffer,
&length, 60.0);
printf("CUPS_SC_CMD_DRAIN_OUTPUT returned %s\n", statuses[scstatus]);
length = 1;
scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_BIDI, buffer,
&length, 5.0);
printf("CUPS_SC_CMD_GET_BIDI returned %s, %d\n", statuses[scstatus], buffer[0]);
length = sizeof(buffer) - 1;
scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_DEVICE_ID, buffer,
&length, 5.0);
buffer[length] = '\0';
printf("CUPS_SC_CMD_GET_DEVICE_ID returned %s, \"%s\"\n",
statuses[scstatus], buffer);
length = 1;
scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_STATE, buffer,
&length, 5.0);
printf("CUPS_SC_CMD_GET_STATE returned %s, %02X\n", statuses[scstatus],
buffer[0] & 255);
if (do_walk)
{
/*
* Walk the OID tree...
*/
scstatus = cupsSideChannelSNMPWalk(oid, 5.0, walk_cb, NULL);
printf("CUPS_SC_CMD_SNMP_WALK returned %s\n", statuses[scstatus]);
}
else
{
/*
* Lookup the same OID twice...
*/
length = sizeof(buffer);
scstatus = cupsSideChannelSNMPGet(oid, buffer, &length, 5.0);
printf("CUPS_SC_CMD_SNMP_GET %s returned %s, %d bytes (%s)\n", oid,
statuses[scstatus], (int)length, buffer);
length = sizeof(buffer);
scstatus = cupsSideChannelSNMPGet(oid, buffer, &length, 5.0);
printf("CUPS_SC_CMD_SNMP_GET %s returned %s, %d bytes (%s)\n", oid,
statuses[scstatus], (int)length, buffer);
}
length = 0;
scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_SOFT_RESET, buffer,
&length, 5.0);
printf("CUPS_SC_CMD_SOFT_RESET returned %s\n", statuses[scstatus]);
}
if (do_cancel)
{
sleep(1);
kill(data_pid, SIGTERM);
kill(back_pid, SIGTERM);
}
while ((pid = wait(&status)) > 0)
{
if (status)
{
if (WIFEXITED(status))
printf("%s exited with status %d!\n",
pid == back_pid ? backend : "test",
WEXITSTATUS(status));
else
printf("%s crashed with signal %d!\n",
pid == back_pid ? backend : "test",
WTERMSIG(status));
}
}
/*
* Exit accordingly...
*/
return (status != 0);
}
/*
* 'sigterm_handler()' - Flag when we get SIGTERM.
*/
static void
sigterm_handler(int sig) /* I - Signal */
{
(void)sig;
job_canceled = 1;
}
/*
* 'usage()' - Show usage information.
*/
static void
usage(void)
{
puts("Usage: testbackend [-cancel] [-d] [-ps | -pcl] [-s [-get OID] "
"[-walk OID]] [-t] device-uri job-id user title copies options [file]");
puts("");
puts("Options:");
puts(" -cancel Simulate a canceled print job after 2 seconds.");
puts(" -d Show log messages from backend.");
puts(" -get OID Lookup the specified SNMP OID.");
puts(" (.1.3.6.1.2.1.43.10.2.1.4.1.1 is a good one for printers)");
puts(" -pcl Send PCL+PJL query and test page to backend.");
puts(" -ps Send PostScript query and test page to backend.");
puts(" -s Do side-channel + SNMP tests.");
puts(" -t Send spaces slowly to backend ('trickle').");
puts(" -walk OID Walk the specified SNMP OID.");
puts(" (.1.3.6.1.2.1.43 is a good one for printers)");
exit(1);
}
/*
* 'walk_cb()' - Show results of cupsSideChannelSNMPWalk...
*/
static void
walk_cb(const char *oid, /* I - OID */
const char *data, /* I - Data */
int datalen, /* I - Length of data */
void *context) /* I - Context (unused) */
{
char temp[80];
(void)context;
if ((size_t)datalen > (sizeof(temp) - 1))
{
memcpy(temp, data, sizeof(temp) - 1);
temp[sizeof(temp) - 1] = '\0';
}
else
{
memcpy(temp, data, (size_t)datalen);
temp[datalen] = '\0';
}
printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, temp);
}
-67
Ver Arquivo
@@ -1,67 +0,0 @@
/*
* SNMP supplies test program for CUPS.
*
* Copyright © 2008-2011 by Apple Inc.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers.
*/
#include "backend-private.h"
/*
* 'main()' - Show the supplies state of a printer.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
http_addrlist_t *host; /* Host addresses */
int snmp_fd; /* SNMP socket */
int page_count, /* Current page count */
printer_state; /* Current printer state */
if (argc != 2)
{
puts("Usage: testsupplies ip-or-hostname");
return (1);
}
if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL)
{
perror(argv[1]);
return (1);
}
if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
{
perror(argv[1]);
return (1);
}
for (;;)
{
fputs("backendSNMPSupplies: ", stdout);
if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count,
&printer_state))
{
puts("FAIL");
return (1);
}
printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
page_count < 0 || printer_state < CUPS_TC_other ||
printer_state > CUPS_TC_warmup ? "FAIL" : "PASS",
page_count, printer_state);
sleep(5);
}
}
+1787 -2352
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+296 -269
Ver Arquivo
@@ -1,19 +1,41 @@
/*
* USB port backend for CUPS.
* "$Id$"
*
* This file is included from "usb.c" when compiled on UNIX/Linux.
* USB port backend for the Common UNIX Printing System (CUPS).
*
* Copyright © 2007-2013 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
* This file is included from "usb.c" when compiled on UNIX/Linux.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* main() - Send a file to the specified USB port.
* list_devices() - List all USB devices.
*/
/*
* Include necessary headers.
*/
#include "ieee1284.c"
#include <sys/select.h>
@@ -21,9 +43,7 @@
* Local functions...
*/
static int open_device(const char *uri, int *use_bc);
static int side_cb(int print_fd, int device_fd, int snmp_fd,
http_addr_t *addr, int use_bc);
int open_device(const char *uri);
/*
@@ -34,21 +54,30 @@ int /* O - Exit status */
print_device(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
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 */
const char *options, /* I - Device options/serial number */
int fp, /* I - File descriptor to print */
int copies) /* I - Copies to print */
{
int use_bc; /* Use backchannel path? */
int device_fd; /* USB device */
ssize_t tbytes; /* Total number of bytes written */
int fd; /* USB device */
int rbytes; /* Number of bytes read */
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 */
backbuf[1024]; /* Backchannel buffer */
struct termios opts; /* Parallel port options */
fd_set input, /* Input set for select() */
output; /* Output set for select() */
int paperout; /* Paper out? */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
#ifdef __linux
unsigned int status; /* Port status (off-line, out-of-paper, etc.) */
#endif /* __linux */
(void)argc;
(void)argv;
/*
* Open the USB port device...
*/
@@ -57,38 +86,7 @@ print_device(const char *uri, /* I - Device URI */
do
{
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
/*
* *BSD's ulpt driver currently does not support the
* back-channel, incorrectly returns data ready on a select(),
* and locks up on read()...
*/
use_bc = 0;
#elif defined(__sun)
/*
* CUPS STR #3028: Solaris' usbprn driver apparently does not support
* select() or poll(), so we can't support backchannel...
*/
use_bc = 0;
#else
/*
* Disable backchannel data when printing to Brother, Canon, or
* Minolta USB printers - apparently these printers will return
* the IEEE-1284 device ID over and over and over when they get
* a read request...
*/
use_bc = _cups_strcasecmp(hostname, "Brother") &&
_cups_strcasecmp(hostname, "Canon") &&
_cups_strncasecmp(hostname, "Konica", 6) &&
_cups_strncasecmp(hostname, "Minolta", 7);
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
if ((device_fd = open_device(uri, &use_bc)) == -1)
if ((fd = open_device(uri)) == -1)
{
if (getenv("CLASS") != NULL)
{
@@ -99,9 +97,8 @@ print_device(const char *uri, /* I - Device URI */
* available printer in the class.
*/
_cupsLangPrintFilter(stderr, "INFO",
_("Unable to contact printer, queuing on next "
"printer in class."));
fputs("INFO: Unable to open USB device, queuing on next printer in class...\n",
stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
@@ -114,22 +111,23 @@ print_device(const char *uri, /* I - Device URI */
if (errno == EBUSY)
{
_cupsLangPrintFilter(stderr, "INFO", _("The printer is in use."));
sleep(10);
fputs("INFO: USB port busy; will retry in 30 seconds...\n", stderr);
sleep(30);
}
else if (errno == ENXIO || errno == EIO || errno == ENOENT ||
errno == ENODEV)
else if (errno == ENXIO || errno == EIO || errno == ENOENT || errno == ENODEV)
{
fputs("INFO: Printer not connected; will retry in 30 seconds...\n", stderr);
sleep(30);
}
else
{
_cupsLangPrintError("ERROR", _("Unable to open device file"));
fprintf(stderr, "ERROR: Unable to open USB device \"%s\": %s\n",
uri, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
}
while (device_fd < 0);
while (fd < 0);
fputs("STATE: -connecting-to-device\n", stderr);
@@ -137,53 +135,187 @@ print_device(const char *uri, /* I - Device URI */
* Set any options provided...
*/
tcgetattr(device_fd, &opts);
tcgetattr(fd, &opts);
opts.c_lflag &= ~(unsigned)(ICANON | ECHO | ISIG); /* Raw mode */
opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */
/**** No options supported yet ****/
tcsetattr(device_fd, TCSANOW, &opts);
tcsetattr(fd, TCSANOW, &opts);
/*
* Check printer status...
*/
paperout = 0;
#if defined(__linux) && defined(LP_POUTPA)
/*
* Show the printer status before we send the file...
*/
while (!ioctl(fd, LPGETSTATUS, &status))
{
fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status);
if (status & LP_POUTPA)
{
fputs("WARNING: Media tray empty!\n", stderr);
fputs("STATUS: +media-tray-empty-error\n", stderr);
paperout = 1;
}
if (!(status & LP_PERRORP))
fputs("WARNING: Printer fault!\n", stderr);
else if (!(status & LP_PSELECD))
fputs("WARNING: Printer off-line.\n", stderr);
else
break;
sleep(5);
}
#endif /* __linux && LP_POUTPA */
/*
* 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 (!fp)
{
#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...
*/
tbytes = 0;
wbytes = 0;
while (copies > 0 && tbytes >= 0)
while (copies > 0)
{
copies --;
if (print_fd != 0)
if (fp != 0)
{
fputs("PAGE: 1 1\n", stderr);
lseek(print_fd, 0, SEEK_SET);
lseek(fp, 0, SEEK_SET);
}
#ifdef __sun
/*
* CUPS STR #3028: Solaris' usbprn driver apparently does not support
* select() or poll(), so we can't support the sidechannel either...
*/
tbytes = 0;
while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0)
{
/*
* Write the print data to the printer...
*/
tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, NULL);
tbytes += nbytes;
bufptr = buffer;
#else
tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, side_cb);
#endif /* __sun */
while (nbytes > 0)
{
/*
* See if we are ready to read or write...
*/
if (print_fd != 0 && tbytes >= 0)
_cupsLangPrintFilter(stderr, "INFO", _("Print file sent."));
do
{
FD_ZERO(&input);
FD_SET(fd, &input);
FD_ZERO(&output);
FD_SET(fd, &output);
}
while (select(fd + 1, &input, &output, NULL, NULL) < 0);
if (FD_ISSET(fd, &input))
{
/*
* Read backchannel data...
*/
if ((rbytes = read(fd, backbuf, sizeof(backbuf))) > 0)
{
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
rbytes);
cupsBackChannelWrite(backbuf, rbytes, 1.0);
}
}
if (FD_ISSET(fd, &output))
{
/*
* Write print data...
*/
if ((wbytes = write(fd, bufptr, nbytes)) < 0)
if (errno == ENOTTY)
wbytes = write(fd, bufptr, nbytes);
if (wbytes < 0)
{
/*
* Check for retryable errors...
*/
if (errno == ENOSPC)
{
paperout = 1;
fputs("ERROR: Out of paper!\n", stderr);
fputs("STATUS: +media-tray-empty-error\n", stderr);
}
else if (errno != EAGAIN && errno != EINTR)
{
perror("ERROR: Unable to send print file to printer");
break;
}
}
else
{
/*
* Update count and pointer...
*/
if (paperout)
{
fputs("STATUS: -media-tray-empty-error\n", stderr);
paperout = 0;
}
nbytes -= wbytes;
bufptr += wbytes;
}
}
}
if (wbytes < 0)
break;
if (fp)
fprintf(stderr, "INFO: Sending print file, %lu bytes...\n",
(unsigned long)tbytes);
}
}
/*
* Close the USB port and return...
*/
close(device_fd);
close(fd);
return (CUPS_BACKEND_OK);
return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
}
@@ -195,54 +327,46 @@ void
list_devices(void)
{
#ifdef __linux
int i; /* Looping var */
int fd; /* File descriptor */
char device[255], /* Device filename */
device_id[1024], /* Device ID string */
device_uri[1024], /* Device URI string */
make_model[1024]; /* Make and model */
int i; /* Looping var */
int fd; /* File descriptor */
char format[255], /* Format for device filename */
device[255], /* Device filename */
device_id[1024], /* Device ID string */
device_uri[1024], /* Device URI string */
make_model[1024]; /* Make and model */
/*
* Try to open each USB device...
* First figure out which USB printer filename to use...
*/
if (!access("/dev/usblp0", 0))
strcpy(format, "/dev/usblp%d");
else if (!access("/dev/usb/usblp0", 0))
strcpy(format, "/dev/usb/usblp%d");
else
strcpy(format, "/dev/usb/lp%d");
/*
* Then open each USB device...
*/
for (i = 0; i < 16; i ++)
{
/*
* Linux has a long history of changing the standard filenames used
* for USB printer devices. We get the honor of trying them all...
*/
sprintf(device, format, i);
sprintf(device, "/dev/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
if ((fd = open(device, O_RDWR | O_EXCL)) >= 0)
{
if (errno != ENOENT)
continue;
if (!get_device_id(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri)))
printf("direct %s \"%s\" \"%s USB #%d\" \"%s\"\n", device_uri,
make_model, make_model, i + 1, device_id);
sprintf(device, "/dev/usb/lp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
{
if (errno != ENOENT)
continue;
sprintf(device, "/dev/usb/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
continue;
}
close(fd);
}
if (!backendGetDeviceID(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri)))
cupsBackendReport("direct", device_uri, make_model, make_model,
device_id, NULL);
close(fd);
}
#elif defined(__sgi)
#elif defined(__sun) && defined(ECPPIOC_GETDEVID)
int i; /* Looping var */
int fd; /* File descriptor */
@@ -260,18 +384,20 @@ list_devices(void)
{
sprintf(device, "/dev/usb/printer%d", i);
if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0)
if ((fd = open(device, O_RDWR | O_EXCL)) >= 0)
{
if (!backendGetDeviceID(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri)))
cupsBackendReport("direct", device_uri, make_model, make_model,
device_id, NULL);
if (!get_device_id(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri)))
printf("direct %s \"%s\" \"%s USB #%d\" \"%s\"\n", device_uri,
make_model, make_model, i + 1, device_id);
close(fd);
}
}
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
#elif defined(__hpux)
#elif defined(__osf)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
int i; /* Looping var */
char device[255]; /* Device filename */
@@ -294,13 +420,9 @@ list_devices(void)
* 'open_device()' - Open a USB device...
*/
static int /* O - File descriptor or -1 on error */
open_device(const char *uri, /* I - Device URI */
int *use_bc) /* O - Set to 0 for unidirectional */
int /* O - File descriptor or -1 on error */
open_device(const char *uri) /* I - Device URI */
{
int fd; /* File descriptor */
/*
* The generic implementation just treats the URI as a device filename...
* Specific operating systems may also support using the device serial
@@ -309,14 +431,7 @@ open_device(const char *uri, /* I - Device URI */
if (!strncmp(uri, "usb:/dev/", 9))
#ifdef __linux
{
/*
* Do not allow direct devices anymore...
*/
errno = ENODEV;
return (-1);
}
return (-1); /* Do not allow direct devices anymore */
else if (!strncmp(uri, "usb://", 6))
{
/*
@@ -325,45 +440,40 @@ open_device(const char *uri, /* I - Device URI */
int i; /* Looping var */
int busy; /* Are any ports busy? */
char device[255], /* Device filename */
int fd; /* File descriptor */
char format[255], /* Format for device filename */
device[255], /* Device filename */
device_id[1024], /* Device ID string */
make_model[1024], /* Make and model */
device_uri[1024]; /* Device URI string */
/*
* Find the correct USB device...
* First figure out which USB printer filename to use...
*/
for (;;)
if (!access("/dev/usblp0", 0))
strcpy(format, "/dev/usblp%d");
else if (!access("/dev/usb/usblp0", 0))
strcpy(format, "/dev/usb/usblp%d");
else
strcpy(format, "/dev/usb/lp%d");
/*
* Then find the correct USB device...
*/
do
{
for (busy = 0, i = 0; i < 16; i ++)
{
/*
* Linux has a long history of changing the standard filenames used
* for USB printer devices. We get the honor of trying them all...
*/
sprintf(device, format, i);
sprintf(device, "/dev/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
if ((fd = open(device, O_RDWR | O_EXCL)) >= 0)
{
sprintf(device, "/dev/usb/lp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
{
sprintf(device, "/dev/usb/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
continue;
}
}
if (fd >= 0)
{
backendGetDeviceID(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri));
get_device_id(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri));
}
else
{
@@ -384,8 +494,7 @@ open_device(const char *uri, /* I - Device URI */
* Yes, return this file descriptor...
*/
fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",
device);
fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n", device);
return (fd);
}
@@ -404,20 +513,24 @@ open_device(const char *uri, /* I - Device URI */
*/
if (busy)
_cupsLangPrintFilter(stderr, "INFO", _("The printer is in use."));
sleep(5);
{
fputs("INFO: USB printer is busy; will retry in 5 seconds...\n",
stderr);
sleep(5);
}
}
}
#elif defined(__sun) && defined(ECPPIOC_GETDEVID)
{
while (busy);
/*
* Do not allow direct devices anymore...
* Couldn't find the printer, return "no such device or address"...
*/
errno = ENODEV;
return (-1);
}
#elif defined(__sun) && defined(ECPPIOC_GETDEVID)
return (-1); /* Do not allow direct devices anymore */
else if (!strncmp(uri, "usb://", 6))
{
/*
@@ -426,6 +539,7 @@ open_device(const char *uri, /* I - Device URI */
int i; /* Looping var */
int busy; /* Are any ports busy? */
int fd; /* File descriptor */
char device[255], /* Device filename */
device_id[1024], /* Device ID string */
make_model[1024], /* Make and model */
@@ -442,10 +556,10 @@ open_device(const char *uri, /* I - Device URI */
{
sprintf(device, "/dev/usb/printer%d", i);
if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0)
backendGetDeviceID(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri));
if ((fd = open(device, O_RDWR | O_EXCL)) >= 0)
get_device_id(fd, device_id, sizeof(device_id),
make_model, sizeof(make_model),
"usb", device_uri, sizeof(device_uri));
else
{
/*
@@ -460,17 +574,7 @@ open_device(const char *uri, /* I - Device URI */
}
if (!strcmp(uri, device_uri))
{
/*
* Yes, return this file descriptor...
*/
fputs("DEBUG: Setting use_bc to 0!\n", stderr);
*use_bc = 0;
return (fd);
}
return (fd); /* Yes, return this file descriptor... */
/*
* This wasn't the one...
@@ -487,7 +591,8 @@ open_device(const char *uri, /* I - Device URI */
if (busy)
{
_cupsLangPrintFilter(stderr, "INFO", _("The printer is in use."));
fputs("INFO: USB printer is busy; will retry in 5 seconds...\n",
stderr);
sleep(5);
}
}
@@ -502,20 +607,7 @@ open_device(const char *uri, /* I - Device URI */
return (-1);
}
#else
{
if (*use_bc)
fd = open(uri + 4, O_RDWR | O_EXCL);
else
fd = -1;
if (fd < 0)
{
fd = open(uri + 4, O_WRONLY | O_EXCL);
*use_bc = 0;
}
return (fd);
}
return (open(uri + 4, O_RDWR | O_EXCL));
#endif /* __linux */
else
{
@@ -526,70 +618,5 @@ open_device(const char *uri, /* I - Device URI */
/*
* 'side_cb()' - Handle side-channel requests...
* End of "$Id$".
*/
static int /* O - 0 on success, -1 on error */
side_cb(int print_fd, /* I - Print file */
int device_fd, /* I - Device file */
int snmp_fd, /* I - SNMP socket (unused) */
http_addr_t *addr, /* I - Device address (unused) */
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 */
(void)snmp_fd;
(void)addr;
datalen = sizeof(data);
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
return (-1);
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;
}
return (cupsSideChannelWrite(command, status, data, datalen, 1.0));
}
+61 -38
Ver Arquivo
@@ -1,11 +1,33 @@
/*
* USB printer backend for CUPS.
* "$Id$"
*
* Copyright © 2007-2012 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
* USB port backend for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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" 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 file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* list_devices() - List all available USB devices to stdout.
* print_device() - Print a file to a USB device.
* main() - Send a file to the specified USB port.
*/
/*
@@ -17,15 +39,21 @@
# include <ApplicationServices/ApplicationServices.h>
#endif /* __APPLE__ */
#include "backend-private.h"
#include <cups/backend.h>
#include <cups/cups.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <cups/string.h>
#include <signal.h>
#ifdef _WIN32
#ifdef WIN32
# include <io.h>
#else
# include <unistd.h>
# include <fcntl.h>
# include <termios.h>
#endif /* _WIN32 */
#endif /* WIN32 */
/*
@@ -34,19 +62,17 @@
void list_devices(void);
int print_device(const char *uri, const char *hostname,
const char *resource, char *options,
int print_fd, int copies, int argc, char *argv[]);
const char *resource, const char *options,
int fp, int copies);
/*
* Include the vendor-specific USB implementation...
*/
#ifdef HAVE_LIBUSB
# include "usb-libusb.c"
#elif defined(__APPLE__)
#ifdef __APPLE__
# include "usb-darwin.c"
#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
# include "usb-unix.c"
#else
/*
@@ -81,11 +107,9 @@ int /* O - Exit status */
print_device(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
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 */
const char *options, /* I - Device options/serial number */
int fp, /* I - File descriptor to print */
int copies) /* I - Copies to print */
{
/*
* Can't print, so just reference the arguments to eliminate compiler
@@ -98,14 +122,12 @@ print_device(const char *uri, /* I - Device URI */
(void)hostname;
(void)resource;
(void)options;
(void)print_fd;
(void)fp;
(void)copies;
(void)argc;
(void)argv;
return (CUPS_BACKEND_FAILED);
}
#endif /* HAVE_LIBUSB */
#endif /* __APPLE__ */
/*
@@ -120,7 +142,7 @@ int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
int print_fd; /* Print file */
int fp; /* Print file */
int copies; /* Number of copies to print */
int status; /* Exit status */
int port; /* Port number (not used) */
@@ -166,9 +188,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
else if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
_("Usage: %s job-id user title copies options [file]"),
argv[0]);
fputs("Usage: usb job-id user title copies options [file]\n", stderr);
return (CUPS_BACKEND_FAILED);
}
@@ -183,9 +203,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
hostname, sizeof(hostname), &port,
resource, sizeof(resource)) < HTTP_URI_OK)
{
_cupsLangPrintFilter(stderr, "ERROR",
_("No device URI found in argv[0] or in DEVICE_URI "
"environment variable."));
fputs("ERROR: No device URI found in argv[0] or in DEVICE_URI environment variable!\n", stderr);
return (1);
}
@@ -210,8 +228,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
if (argc == 6)
{
print_fd = 0;
copies = 1;
fp = 0;
copies = 1;
}
else
{
@@ -219,9 +237,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Try to open the print file...
*/
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
if ((fp = open(argv[6], O_RDONLY)) < 0)
{
_cupsLangPrintError("ERROR", _("Unable to open print file"));
fprintf(stderr, "ERROR: unable to open print file %s - %s\n",
argv[6], strerror(errno));
return (CUPS_BACKEND_FAILED);
}
@@ -232,15 +251,19 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Finally, send the print file...
*/
status = print_device(uri, hostname, resource, options, print_fd, copies,
argc, argv);
status = print_device(uri, hostname, resource, options, fp, copies);
/*
* Close the input file and return...
*/
if (print_fd != 0)
close(print_fd);
if (fp != 0)
close(fp);
return (status);
}
/*
* End of "$Id$".
*/
+14 -24
Ver Arquivo
@@ -1,24 +1,14 @@
lpc.o: lpc.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
../cups/versioning.h ../cups/array-private.h ../cups/array.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h
lpq.o: lpq.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
../cups/versioning.h ../cups/array-private.h ../cups/array.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h
lpr.o: lpr.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
../cups/versioning.h ../cups/array-private.h ../cups/array.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread-private.h
lprm.o: lprm.c ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/versioning.h ../cups/array-private.h \
../cups/array.h ../cups/ipp-private.h ../cups/cups.h ../cups/file.h \
../cups/ipp.h ../cups/http.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h ../cups/language-private.h ../cups/transcode.h \
../cups/pwg-private.h ../cups/thread-private.h
# DO NOT DELETE
lpc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
lpc.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
lpc.o: ../cups/i18n.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/array.h
lpq.o: ../cups/file.h ../cups/language.h ../cups/i18n.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 ../cups/array.h
lpr.o: ../cups/file.h ../cups/language.h ../cups/i18n.h
lprm.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
lprm.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
lprm.o: ../cups/i18n.h ../cups/string.h ../config.h
+30 -66
Ver Arquivo
@@ -1,15 +1,29 @@
#
# Berkeley commands makefile for CUPS.
# "$Id$"
#
# Copyright 2007-2019 by Apple Inc.
# Copyright 1997-2006 by Easy Software Products, all rights reserved.
# Berkeley commands makefile for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more information.
# 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 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
include ../Makedefs
TARGETS = lpc lpq lpr lprm
OBJS = lpc.o lpq.o lpr.o lprm.o
@@ -21,20 +35,6 @@ OBJS = lpc.o lpq.o lpr.o lprm.o
all: $(TARGETS)
#
# Make library targets...
#
libs:
#
# Make unit tests...
#
unittests:
#
# Clean all object files...
#
@@ -48,57 +48,20 @@ clean:
#
depend:
$(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
makedepend -Y -I.. -fDependencies $(OBJS:.o=.c) >/dev/null 2>&1
#
# Install all targets...
#
install: all install-data install-headers install-libs install-exec
#
# Install data files...
#
install-data:
#
# Install programs...
#
install-exec:
echo Installing Berkeley user printing commands in $(BINDIR)...
install: all
$(INSTALL_DIR) -m 755 $(BINDIR)
$(INSTALL_BIN) lpq $(BINDIR)
$(INSTALL_BIN) lpr $(BINDIR)
$(INSTALL_BIN) lprm $(BINDIR)
echo Installing Berkeley admin printing commands in $(BINDIR)...
$(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); \
dsymutil $(SYMROOT)/$$file; \
done \
fi
#
# Install headers...
#
install-headers:
#
# Install libraries...
#
install-libs:
#
@@ -120,8 +83,7 @@ uninstall:
lpc: lpc.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o lpc lpc.o $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o lpc lpc.o $(LIBS)
#
@@ -130,8 +92,7 @@ lpc: lpc.o ../cups/$(LIBCUPS)
lpq: lpq.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o lpq lpq.o $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o lpq lpq.o $(LIBS)
#
@@ -140,8 +101,7 @@ lpq: lpq.o ../cups/$(LIBCUPS)
lpr: lpr.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o lpr lpr.o $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o lpr lpr.o $(LIBS)
#
@@ -150,8 +110,7 @@ lpr: lpr.o ../cups/$(LIBCUPS)
lprm: lprm.o ../cups/$(LIBCUPS)
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o lprm lprm.o $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o lprm lprm.o $(LIBS)
#
@@ -159,3 +118,8 @@ lprm: lprm.o ../cups/$(LIBCUPS)
#
include Dependencies
#
# End of "$Id$".
#
+143 -48
Ver Arquivo
@@ -1,24 +1,52 @@
/*
* "lpc" command for CUPS.
* "$Id$"
*
* Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* "lpc" command for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Parse options and commands.
* compare_strings() - Compare two command-line strings.
* do_command() - Do an lpc command...
* show_help() - Show help messages.
* show_status() - Show printers.
*/
/*
* Include necessary headers...
*/
#include <cups/cups-private.h>
#include <stdio.h>
#include <stdlib.h>
#include <cups/cups.h>
#include <cups/i18n.h>
#include <cups/debug.h>
#include <cups/string.h>
/*
* Local functions...
*/
static int compare_strings(const char *, const char *, size_t);
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 *);
@@ -37,8 +65,6 @@ main(int argc, /* I - Number of command-line arguments */
*params; /* Pointer to parameters */
_cupsSetLocale(argv);
/*
* Connect to the scheduler...
*/
@@ -59,7 +85,7 @@ main(int argc, /* I - Number of command-line arguments */
* Do the command prompt thing...
*/
_cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no-newline version */
_cupsLangPuts(stdout, _("lpc> "));
while (fgets(line, sizeof(line), stdin) != NULL)
{
/*
@@ -87,7 +113,7 @@ main(int argc, /* I - Number of command-line arguments */
* Nothing left, just show a prompt...
*/
_cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */
_cupsLangPuts(stdout, _("lpc> "));
continue;
}
@@ -123,7 +149,7 @@ main(int argc, /* I - Number of command-line arguments */
* Put another prompt out to the user...
*/
_cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */
_cupsLangPuts(stdout, _("lpc> "));
}
}
@@ -144,9 +170,9 @@ main(int argc, /* I - Number of command-line arguments */
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 */
size_t tmin) /* I - Minimum number of unique chars in option */
int tmin) /* I - Minimum number of unique chars in option */
{
size_t slen; /* Length of command-line string */
int slen; /* Length of command-line string */
slen = strlen(s);
@@ -172,7 +198,7 @@ do_command(http_t *http, /* I - HTTP connection to server */
show_help(params);
else
_cupsLangPrintf(stdout,
_("%s is not implemented by the CUPS version of lpc."),
_("%s is not implemented by the CUPS version of lpc.\n"),
command);
}
@@ -189,14 +215,14 @@ show_help(const char *command) /* I - Command to describe or NULL */
_cupsLangPrintf(stdout,
_("Commands may be abbreviated. Commands are:\n"
"\n"
"exit help quit status ?"));
"exit help quit status ?\n"));
}
else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
_cupsLangPrintf(stdout, _("help\t\tGet help on commands."));
_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."));
_cupsLangPrintf(stdout, _("status\t\tshow status of daemon and queue\n"));
else
_cupsLangPrintf(stdout, _("?Invalid help command unknown."));
_cupsLangPrintf(stdout, _("?Invalid help command unknown\n"));
}
@@ -209,8 +235,11 @@ show_status(http_t *http, /* I - HTTP connection to server */
const char *dests) /* I - Destinations */
{
ipp_t *request, /* IPP Request */
*response; /* IPP Response */
ipp_attribute_t *attr; /* Current attribute */
*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 */
@@ -220,16 +249,19 @@ show_status(http_t *http, /* I - HTTP connection to server */
const 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 */
{
"device-uri",
"printer-is-accepting-jobs",
"printer-name",
"device-uri",
"printer-state",
"queued-job-count"
"printer-is-accepting-jobs"
};
DEBUG_printf(("show_status(http=%p, dests=\"%s\")\n", http, dests));
if (http == NULL)
return;
@@ -241,7 +273,18 @@ show_status(http_t *http, /* I - HTTP connection to server */
* attributes-natural-language
*/
request = ippNewRequest(CUPS_GET_PRINTERS);
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);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(requested) / sizeof(requested[0]),
@@ -253,6 +296,8 @@ show_status(http_t *http, /* I - HTTP connection to server */
if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
DEBUG_puts("show_status: request succeeded...");
/*
* Loop through the printers returned in the list and display
* their status...
@@ -282,21 +327,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") &&
attr->value_tag == IPP_TAG_NAME)
printer = attr->values[0].string.text;
if (!strcmp(attr->name, "device-uri") &&
attr->value_tag == IPP_TAG_URI)
device = attr->values[0].string.text;
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)
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;
if (!strcmp(attr->name, "printer-is-accepting-jobs") &&
attr->value_tag == IPP_TAG_BOOLEAN)
accepting = attr->values[0].boolean;
attr = attr->next;
}
@@ -346,11 +391,9 @@ show_status(http_t *http, /* I - HTTP connection to server */
for (ptr = printer;
*ptr != '\0' && *dptr != '\0' && *ptr == *dptr;
ptr ++, dptr ++)
/* do nothing */;
ptr ++, dptr ++);
if (*ptr == '\0' && (*dptr == '\0' || *dptr == ',' ||
isspace(*dptr & 255)))
if (*ptr == '\0' && (*dptr == '\0' || *dptr == ',' || isspace(*dptr & 255)))
{
match = 1;
break;
@@ -376,6 +419,53 @@ show_status(http_t *http, /* I - HTTP connection to server */
if (match)
{
/*
* 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);
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
"ipp", NULL, "localhost", 631, "/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, "/")) != NULL)
{
/*
* Grab the number of jobs for the printer.
*/
for (jattr = jobs->attrs; jattr != NULL; jattr = jattr->next)
if (jattr->name && !strcmp(jattr->name, "job-id"))
jobcount ++;
ippDelete(jobs);
}
/*
* Display it...
*/
@@ -383,7 +473,7 @@ show_status(http_t *http, /* I - HTTP connection to server */
printf("%s:\n", printer);
if (!strncmp(device, "file:", 5))
_cupsLangPrintf(stdout,
_("\tprinter is on device \'%s\' speed -1"),
_("\tprinter is on device \'%s\' speed -1\n"),
device + 5);
else
{
@@ -395,27 +485,27 @@ show_status(http_t *http, /* I - HTTP connection to server */
{
*delimiter = '\0';
_cupsLangPrintf(stdout,
_("\tprinter is on device \'%s\' speed -1"),
_("\tprinter is on device \'%s\' speed -1\n"),
device);
}
}
if (accepting)
_cupsLangPuts(stdout, _("\tqueuing is enabled"));
_cupsLangPuts(stdout, _("\tqueuing is enabled\n"));
else
_cupsLangPuts(stdout, _("\tqueuing is disabled"));
_cupsLangPuts(stdout, _("\tqueuing is disabled\n"));
if (pstate != IPP_PRINTER_STOPPED)
_cupsLangPuts(stdout, _("\tprinting is enabled"));
_cupsLangPuts(stdout, _("\tprinting is enabled\n"));
else
_cupsLangPuts(stdout, _("\tprinting is disabled"));
_cupsLangPuts(stdout, _("\tprinting is disabled\n"));
if (jobcount == 0)
_cupsLangPuts(stdout, _("\tno entries"));
_cupsLangPuts(stdout, _("\tno entries\n"));
else
_cupsLangPrintf(stdout, _("\t%d entries"), jobcount);
_cupsLangPrintf(stdout, _("\t%d entries\n"), jobcount);
_cupsLangPuts(stdout, _("\tdaemon present"));
_cupsLangPuts(stdout, _("\tdaemon present\n"));
}
if (attr == NULL)
@@ -425,3 +515,8 @@ show_status(http_t *http, /* I - HTTP connection to server */
ippDelete(response);
}
}
/*
* End of "$Id$".
*/
+217 -213
Ver Arquivo
@@ -1,29 +1,58 @@
/*
* "lpq" command for CUPS.
* "$Id$"
*
* Copyright © 2007-2018 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
* "lpq" command for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Parse options and commands.
* show_jobs() - Show jobs.
* show_printer() - Show printer status.
* usage() - Show program usage.
*/
/*
* Include necessary headers...
*/
#include <cups/cups-private.h>
/*
* Include necessary headers...
*/
#include <stdio.h>
#include <stdlib.h>
#include <cups/string.h>
#include <cups/cups.h>
#include <cups/i18n.h>
#include <cups/debug.h>
/*
* Local functions...
*/
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) _CUPS_NORETURN;
static void usage(void);
/*
@@ -36,8 +65,7 @@ main(int argc, /* I - Number of command-line arguments */
{
int i; /* Looping var */
http_t *http; /* Connection to server */
const char *opt, /* Option pointer */
*dest, /* Desired printer */
const char *dest, /* Desired printer */
*user, /* Desired user */
*val; /* Environment variable name */
char *instance; /* Printer instance */
@@ -45,174 +73,166 @@ main(int argc, /* I - Number of command-line arguments */
all, /* All printers */
interval, /* Reporting interval */
longstatus; /* Show file details */
cups_dest_t *named_dest; /* Named destination */
int num_dests; /* Number of destinations */
cups_dest_t *dests; /* Destinations */
cups_lang_t *language; /* Language */
#ifdef HAVE_SSL
http_encryption_t encryption; /* Encryption? */
#endif /* HAVE_SSL */
_cupsSetLocale(argv);
language = cupsLangDefault();
/*
* Connect to the scheduler...
*/
if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
cupsEncryption())) == NULL)
{
_cupsLangPrintf(stderr, _("%s: Unable to contact server!\n"), argv[0]);
return (1);
}
/*
* Check for command-line options...
*/
http = NULL;
dest = NULL;
user = NULL;
id = 0;
interval = 0;
longstatus = 0;
all = 0;
num_dests = cupsGetDests(&dests);
for (i = 1; i < argc; i ++)
{
if (argv[i][0] == '+')
{
interval = atoi(argv[i] + 1);
}
else if (!strcmp(argv[i], "--help"))
usage();
else if (argv[i][0] == '-')
{
for (opt = argv[i] + 1; *opt; opt ++)
switch (argv[i][1])
{
switch (*opt)
{
case 'E' : /* Encrypt */
case 'E' : /* Encrypt */
#ifdef HAVE_SSL
cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
encryption = HTTP_ENCRYPT_REQUIRED;
if (http)
httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
if (http)
httpEncryption(http, encryption);
#else
_cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]);
_cupsLangPrintf(stderr,
_("%s: Sorry, no encryption support compiled in!\n"),
argv[0]);
#endif /* HAVE_SSL */
break;
break;
case 'U' : /* Username */
if (opt[1] != '\0')
case 'U' : /* Username */
if (argv[i][2] != '\0')
cupsSetUser(argv[i] + 2);
else
{
i ++;
if (i >= argc)
{
cupsSetUser(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]);
return (1);
}
cupsSetUser(argv[i]);
}
break;
case 'P' : /* Printer */
if (opt[1] != '\0')
{
dest = opt + 1;
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
httpClose(http);
usage();
}
dest = argv[i];
_cupsLangPrintf(stderr,
_("%s: Error - expected username after "
"\'-U\' option!\n"),
argv[0]);
return (1);
}
if ((instance = strchr(dest, '/')) != NULL)
*instance++ = '\0';
cupsSetUser(argv[i]);
}
break;
case 'P' : /* Printer */
if (argv[i][2])
dest = argv[i] + 2;
else
{
i ++;
http = connect_server(argv[0], http);
if ((named_dest = cupsGetNamedDest(http, dest, instance)) == NULL)
{
if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
else if (instance)
_cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s/%s\"."), argv[0], dest, instance);
else
_cupsLangPrintf(stderr, _("%s: Unknown destination \"%s\"."), argv[0], dest);
return (1);
}
cupsFreeDests(1, named_dest);
break;
case 'a' : /* All printers */
all = 1;
break;
case 'h' : /* Connect to host */
if (http)
if (i >= argc)
{
httpClose(http);
http = NULL;
cupsFreeDests(num_dests, dests);
usage();
}
if (opt[1] != '\0')
{
cupsSetServer(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
dest = argv[i];
}
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]);
return (1);
}
else
cupsSetServer(argv[i]);
}
break;
if ((instance = strchr(dest, '/')) != NULL)
*instance++ = '\0';
case 'l' : /* Long status */
longstatus = 1;
break;
if (cupsGetDest(dest, instance, num_dests, dests) == NULL)
{
if (instance)
_cupsLangPrintf(stderr,
_("%s: Error - unknown destination \"%s/%s\"!\n"),
argv[0], dest, instance);
else
_cupsLangPrintf(stderr,
_("%s: Unknown destination \"%s\"!\n"),
argv[0], dest);
default :
return (1);
}
break;
case 'a' : /* All printers */
all = 1;
break;
case 'h' : /* Connect to host */
if (http != NULL)
httpClose(http);
usage();
}
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;
default :
httpClose(http);
cupsFreeDests(num_dests, dests);
usage();
break;
}
}
else if (isdigit(argv[i][0] & 255))
{
id = atoi(argv[i]);
}
else
{
user = argv[i];
}
}
http = connect_server(argv[0], http);
if (dest == NULL && !all)
{
if ((named_dest = cupsGetNamedDest(http, NULL, NULL)) == NULL)
{
if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
argv[0]);
return (1);
}
for (i = 0; i < num_dests; i ++)
if (dests[i].is_default)
dest = dests[i].name;
if (dest == NULL)
{
val = NULL;
if ((dest = getenv("LPDEST")) == NULL)
@@ -228,20 +248,19 @@ main(int argc, /* I - Number of command-line arguments */
else
val = "LPDEST";
if (dest && val)
if (dest && !cupsGetDest(dest, NULL, num_dests, dests))
_cupsLangPrintf(stderr,
_("%s: Error - %s environment variable names "
"non-existent destination \"%s\"."), argv[0], val,
dest);
_("%s: error - %s environment variable names "
"non-existent destination \"%s\"!\n"),
argv[0], val, dest);
else
_cupsLangPrintf(stderr,
_("%s: Error - no default destination available."),
_("%s: error - no default destination available.\n"),
argv[0]);
httpClose(http);
cupsFreeDests(num_dests, dests);
return (1);
}
dest = named_dest->name;
}
/*
@@ -258,7 +277,7 @@ main(int argc, /* I - Number of command-line arguments */
if (i && interval)
{
fflush(stdout);
sleep((unsigned)interval);
sleep(interval);
}
else
break;
@@ -268,36 +287,13 @@ main(int argc, /* I - Number of command-line arguments */
* Close the connection to the server and return...
*/
cupsFreeDests(num_dests, dests);
httpClose(http);
return (0);
}
/*
* '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."), command);
exit(1);
}
}
return (http);
}
/*
* 'show_jobs()' - Show jobs.
*/
@@ -319,24 +315,16 @@ show_jobs(const char *command, /* I - Command name */
ipp_jstate_t jobstate; /* job-state */
int jobid, /* job-id */
jobsize, /* job-k-octets */
#ifdef __osf__
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 * const jobattrs[] =/* Job attributes we want to see */
{
"copies",
"job-id",
"job-k-octets",
"job-name",
"job-originating-user-name",
"job-printer-uri",
"job-priority",
"job-state"
};
static const char * const ranks[10] = /* Ranking strings */
static const char *ranks[10] = /* Ranking strings */
{
"th",
"st",
@@ -351,6 +339,9 @@ show_jobs(const char *command, /* I - Command name */
};
DEBUG_printf(("show_jobs(%08x, %08x, %08x, %d, %d)\n", http, dest, user, id,
longstatus));
if (http == NULL)
return (0);
@@ -361,19 +352,21 @@ show_jobs(const char *command, /* I - Command name */
* attributes-charset
* attributes-natural-language
* job-uri or printer-uri
* requested-attributes
* requesting-user-name
*/
request = ippNewRequest(id ? IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS);
if (id)
if (dest == NULL)
{
snprintf(resource, sizeof(resource), "ipp://localhost/jobs/%d", id);
if (id)
sprintf(resource, "ipp://localhost/jobs/%d", id);
else
strcpy(resource, "ipp://localhost/jobs");
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
NULL, resource);
}
else if (dest)
else
{
httpAssembleURIf(HTTP_URI_CODING_ALL, resource, sizeof(resource), "ipp",
NULL, "localhost", 0, "/printers/%s", dest);
@@ -381,9 +374,6 @@ show_jobs(const char *command, /* I - Command name */
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)
{
@@ -391,13 +381,6 @@ show_jobs(const char *command, /* I - Command name */
"requesting-user-name", NULL, user);
ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
(int)(sizeof(jobattrs) / sizeof(jobattrs[0])), NULL, jobattrs);
/*
* Do the request and get back a response...
@@ -409,7 +392,7 @@ show_jobs(const char *command, /* I - Command name */
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
ippDelete(response);
return (0);
}
@@ -438,9 +421,12 @@ show_jobs(const char *command, /* I - Command name */
jobid = 0;
jobsize = 0;
#ifdef __osf__
jobpriority = 50;
#endif /* __osf__ */
jobstate = IPP_JOB_PENDING;
jobname = "unknown";
jobuser = "unknown";
jobname = "untitled";
jobuser = NULL;
jobdest = NULL;
jobcopies = 1;
@@ -454,6 +440,12 @@ show_jobs(const char *command, /* I - Command name */
attr->value_tag == IPP_TAG_INTEGER)
jobsize = attr->values[0].integer;
#ifdef __osf__
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") &&
attr->value_tag == IPP_TAG_ENUM)
jobstate = (ipp_jstate_t)attr->values[0].integer;
@@ -491,9 +483,15 @@ show_jobs(const char *command, /* I - Command name */
}
if (!longstatus && jobcount == 0)
#ifdef __osf__
_cupsLangPuts(stdout,
_("Rank Owner Pri Job Files"
" Total Size\n"));
#else
_cupsLangPuts(stdout,
_("Rank Owner Job File(s)"
" Total Size"));
" Total Size\n"));
#endif /* __osf__ */
jobcount ++;
@@ -502,7 +500,7 @@ show_jobs(const char *command, /* I - Command name */
*/
if (jobstate == IPP_JOB_PROCESSING)
strlcpy(rankstr, "active", sizeof(rankstr));
strcpy(rankstr, "active");
else
{
/*
@@ -528,15 +526,22 @@ show_jobs(const char *command, /* I - Command name */
else
strlcpy(namestr, jobname, sizeof(namestr));
_cupsLangPrintf(stdout, _("%s: %-33.33s [job %d localhost]"),
_cupsLangPrintf(stdout, _("%s: %-33.33s [job %d localhost]\n"),
jobuser, rankstr, jobid);
_cupsLangPrintf(stdout, _(" %-39.39s %.0f bytes"),
_cupsLangPrintf(stdout, _(" %-39.39s %.0f bytes\n"),
namestr, 1024.0 * jobsize);
}
else
#ifdef __osf__
_cupsLangPrintf(stdout,
_("%-7s %-7.7s %-7d %-31.31s %.0f bytes"),
_("%-6s %-10.10s %-4d %-10d %-27.27s %.0f bytes\n"),
rankstr, jobuser, jobpriority, jobid, jobname,
1024.0 * jobsize);
#else
_cupsLangPrintf(stdout,
_("%-7s %-7.7s %-7d %-31.31s %.0f bytes\n"),
rankstr, jobuser, jobid, jobname, 1024.0 * jobsize);
#endif /* __osf */
if (attr == NULL)
break;
@@ -546,12 +551,12 @@ show_jobs(const char *command, /* I - Command name */
}
else
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
return (0);
}
if (jobcount == 0)
_cupsLangPuts(stdout, _("no entries"));
_cupsLangPuts(stdout, _("no entries\n"));
return (jobcount);
}
@@ -600,7 +605,7 @@ show_printer(const char *command, /* I - Command name */
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
ippDelete(response);
return;
}
@@ -613,21 +618,21 @@ show_printer(const char *command, /* I - Command name */
switch (state)
{
case IPP_PRINTER_IDLE :
_cupsLangPrintf(stdout, _("%s is ready"), dest);
_cupsLangPrintf(stdout, _("%s is ready\n"), dest);
break;
case IPP_PRINTER_PROCESSING :
_cupsLangPrintf(stdout, _("%s is ready and printing"),
_cupsLangPrintf(stdout, _("%s is ready and printing\n"),
dest);
break;
case IPP_PRINTER_STOPPED :
_cupsLangPrintf(stdout, _("%s is not ready"), dest);
_cupsLangPrintf(stdout, _("%s is not ready\n"), dest);
break;
}
ippDelete(response);
}
else
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
_cupsLangPrintf(stderr, "%s: %s\n", command, cupsLastErrorString());
}
@@ -638,14 +643,13 @@ show_printer(const char *command, /* I - Command name */
static void
usage(void)
{
_cupsLangPuts(stderr, _("Usage: lpq [options] [+interval]"));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _("-a Show jobs on all destinations"));
_cupsLangPuts(stdout, _("-E Encrypt the connection to the server"));
_cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port"));
_cupsLangPuts(stdout, _("-l Show verbose (long) output"));
_cupsLangPuts(stdout, _("-P destination Show status for the specified destination"));
_cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
_cupsLangPuts(stderr,
_("Usage: lpq [-P dest] [-U username] [-h hostname[:port]] "
"[-l] [+interval]\n"));
exit(1);
}
/*
* End of "$Id$".
*/
+373 -295
Ver Arquivo
@@ -1,25 +1,62 @@
/*
* "lpr" command for CUPS.
* "$Id$"
*
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products.
* "lpr" command for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Parse options and send files for printing.
* sighandler() - Signal catcher for when we print from stdin...
*/
/*
* Include necessary headers...
*/
#include <cups/cups-private.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <cups/string.h>
#include <cups/cups.h>
#include <cups/i18n.h>
#ifndef WIN32
# include <unistd.h>
# include <signal.h>
/*
* Local functions...
* Local functions.
*/
static void usage(void) _CUPS_NORETURN;
void sighandler(int);
#endif /* !WIN32 */
/*
* Globals...
*/
char tempfile[1024]; /* Temporary file for printing from stdin */
/*
@@ -34,263 +71,264 @@ main(int argc, /* I - Number of command-line arguments */
int job_id; /* Job ID */
char ch; /* Option character */
char *printer, /* Destination printer or class */
*instance, /* Instance */
*opt; /* Option pointer */
const char *title; /* Job title */
*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 */
cups_dest_t *dest; /* Selected destination */
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 */
cups_lang_t *language; /* Language information */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Signal action */
struct sigaction oldaction; /* Old signal action */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
_cupsSetLocale(argv);
deletefile = 0;
printer = NULL;
dest = NULL;
num_dests = 0;
dests = NULL;
num_options = 0;
options = NULL;
num_files = 0;
title = NULL;
language = cupsLangDefault();
for (i = 1; i < argc; i ++)
{
if (!strcmp(argv[i], "--help"))
usage();
else if (argv[i][0] == '-')
{
for (opt = argv[i] + 1; *opt; opt ++)
if (argv[i][0] == '-')
switch (ch = argv[i][1])
{
switch (ch = *opt)
{
case 'E' : /* Encrypt */
case 'E' : /* Encrypt */
#ifdef HAVE_SSL
cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
#else
_cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]);
_cupsLangPrintf(stderr,
_("%s: Sorry, no encryption support compiled in!\n"),
argv[0]);
#endif /* HAVE_SSL */
break;
break;
case 'U' : /* Username */
if (opt[1] != '\0')
case 'U' : /* Username */
if (argv[i][2] != '\0')
cupsSetUser(argv[i] + 2);
else
{
i ++;
if (i >= argc)
{
cupsSetUser(opt + 1);
opt += strlen(opt) - 1;
_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 */
case '4' : /* TROFF font set 4 */
case 'i' : /* indent */
case 'w' : /* width */
if (argv[i][2] == '\0')
{
i ++;
if (i >= argc)
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]);
usage();
}
cupsSetUser(argv[i]);
}
break;
case 'H' : /* Connect to host */
if (opt[1] != '\0')
{
cupsSetServer(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-H\" option."), argv[0]);
usage();
}
else
cupsSetServer(argv[i]);
}
break;
case '1' : /* TROFF font set 1 */
case '2' : /* TROFF font set 2 */
case '3' : /* TROFF font set 3 */
case '4' : /* TROFF font set 4 */
case 'i' : /* indent */
case 'w' : /* width */
if (opt[1] != '\0')
{
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr,
_("%s: Error - expected value after \"-%c\" "
"option."), argv[0], ch);
usage();
}
}
case 'c' : /* CIFPLOT */
case 'd' : /* DVI */
case 'f' : /* FORTRAN */
case 'g' : /* plot */
case 'n' : /* Ditroff */
case 't' : /* Troff */
case 'v' : /* Raster image */
_cupsLangPrintf(stderr, _("%s: Warning - \"%c\" format modifier not supported - output may not be correct."), argv[0], ch);
break;
case 'o' : /* Option */
if (opt[1] != '\0')
{
num_options = cupsParseOptions(opt + 1, num_options, &options);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected option=value after \"-o\" option."), argv[0]);
usage();
}
num_options = cupsParseOptions(argv[i], num_options, &options);
}
break;
case 'l' : /* Literal/raw */
num_options = cupsAddOption("raw", "true", num_options, &options);
break;
case 'p' : /* Prettyprint */
num_options = cupsAddOption("prettyprint", "true", num_options, &options);
break;
case 'h' : /* Suppress burst page */
num_options = cupsAddOption("job-sheets", "none", num_options, &options);
break;
case 's' : /* Don't use symlinks */
break;
case 'm' : /* Mail on completion */
{
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 */
num_options = cupsAddOption("job-hold-until", "indefinite", num_options, &options);
break;
case 'r' : /* Remove file after printing */
deletefile = 1;
break;
case 'P' : /* Destination printer or class */
if (opt[1] != '\0')
{
printer = opt + 1;
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected destination after \"-P\" option."), argv[0]);
usage();
}
printer = argv[i];
}
if ((instance = strrchr(printer, '/')) != NULL)
*instance++ = '\0';
if ((dest = cupsGetNamedDest(NULL, printer, instance)) != NULL)
{
for (j = 0; j < dest->num_options; j ++)
if (cupsGetOption(dest->options[j].name, num_options,
options) == NULL)
num_options = cupsAddOption(dest->options[j].name,
dest->options[j].value,
num_options, &options);
}
else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
_cupsLangPrintf(stderr,
_("%s: Error - expected value after \'-%c\' "
"option!\n"), argv[0], ch);
return (1);
}
break;
}
case '#' : /* Number of copies */
if (opt[1] != '\0')
{
num_copies = atoi(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected copies after \"-#\" option."), argv[0]);
usage();
}
case 'c' : /* CIFPLOT */
case 'd' : /* DVI */
case 'f' : /* FORTRAN */
case 'g' : /* plot */
case 'n' : /* Ditroff */
case 't' : /* Troff */
case 'v' : /* Raster image */
_cupsLangPrintf(stderr,
_("%s: Warning - \'%c\' format modifier not "
"supported - output may not be correct!\n"),
argv[0], ch);
break;
num_copies = atoi(argv[i]);
}
if (num_copies < 1)
case 'o' : /* Option */
if (argv[i][2] != '\0')
num_options = cupsParseOptions(argv[i] + 2, num_options, &options);
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - copies must be 1 or more."), argv[0]);
_cupsLangPrintf(stderr,
_("%s: error - expected option=value after "
"\'-o\' option!\n"),
argv[0]);
return (1);
}
sprintf(buffer, "%d", num_copies);
num_options = cupsAddOption("copies", buffer, num_options, &options);
break;
num_options = cupsParseOptions(argv[i], num_options, &options);
}
break;
case 'C' : /* Class */
case 'J' : /* Job name */
case 'T' : /* Title */
if (opt[1] != '\0')
case 'l' : /* Literal/raw */
num_options = cupsAddOption("raw", "", num_options, &options);
break;
case 'p' : /* Prettyprint */
num_options = cupsAddOption("prettyprint", "", num_options,
&options);
break;
case 'h' : /* Suppress burst page */
num_options = cupsAddOption("job-sheets", "none", num_options,
&options);
break;
case 's' : /* Don't use symlinks */
break;
case 'm' : /* Mail on completion */
{
char email[1024]; /* EMail address */
snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(),
httpGetHostname(NULL, buffer, sizeof(buffer)));
num_options = cupsAddOption("notify-recipient", email,
num_options, &options);
}
break;
case 'q' : /* Queue file but don't print */
num_options = cupsAddOption("job-hold-until", "indefinite",
num_options, &options);
break;
case 'r' : /* Remove file after printing */
deletefile = 1;
break;
case 'P' : /* Destination printer or class */
if (argv[i][2] != '\0')
printer = argv[i] + 2;
else
{
i ++;
if (i >= argc)
{
title = opt + 1;
opt += strlen(opt) - 1;
_cupsLangPrintf(stderr,
_("%s: Error - expected destination after "
"\'-P\' option!\n"),
argv[0]);
return (1);
}
else
printer = argv[i];
}
if ((instance = strrchr(printer, '/')) != NULL)
*instance++ = '\0';
if (num_dests == 0)
num_dests = cupsGetDests(&dests);
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)
num_options = cupsAddOption(dest->options[j].name,
dest->options[j].value,
num_options, &options);
}
break;
case '#' : /* Number of copies */
if (argv[i][2] != '\0')
num_copies = atoi(argv[i] + 2);
else
{
i ++;
if (i >= argc)
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected name after \"-%c\" option."), argv[0], ch);
usage();
}
title = argv[i];
_cupsLangPrintf(stderr,
_("%s: Error - expected copy count after "
"\'-#\' option!\n"),
argv[0]);
return (1);
}
break;
default :
_cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt);
return (1);
}
num_copies = atoi(argv[i]);
}
sprintf(buffer, "%d", num_copies);
num_options = cupsAddOption("copies", buffer, num_options, &options);
break;
case 'C' : /* Class */
case 'J' : /* Job name */
case 'T' : /* Title */
if (argv[i][2] != '\0')
title = argv[i] + 2;
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr,
_("%s: Error - expected name after \'-%c\' "
"option!\n"), argv[0], ch);
return (1);
}
title = argv[i];
}
break;
default :
_cupsLangPrintf(stderr,
_("%s: Error - unknown option \'%c\'!\n"),
argv[0], argv[i][1]);
return (1);
}
}
else if (num_files < 1000)
{
/*
@@ -300,7 +338,7 @@ main(int argc, /* I - Number of command-line arguments */
if (access(argv[i], R_OK) != 0)
{
_cupsLangPrintf(stderr,
_("%s: Error - unable to access \"%s\" - %s"),
_("%s: Error - unable to access \"%s\" - %s\n"),
argv[0], argv[i], strerror(errno));
return (1);
}
@@ -317,18 +355,19 @@ main(int argc, /* I - Number of command-line arguments */
}
}
else
{
_cupsLangPrintf(stderr, _("%s: Error - too many files - \"%s\"."), argv[0], 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...
*/
if (printer == NULL)
{
if ((dest = cupsGetNamedDest(NULL, NULL, NULL)) != NULL)
if (num_dests == 0)
num_dests = cupsGetDests(&dests);
if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) != NULL)
{
printer = dest->name;
@@ -338,22 +377,38 @@ main(int argc, /* I - Number of command-line arguments */
dest->options[j].value,
num_options, &options);
}
else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
"name."), argv[0]);
return (1);
}
}
if (printer == NULL)
{
if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
_cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsLastErrorString());
val = NULL;
if ((printer = getenv("LPDEST")) == NULL)
{
if ((printer = getenv("PRINTER")) != NULL)
{
if (!strcmp(printer, "lp"))
printer = NULL;
else
val = "PRINTER";
}
}
else
_cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), argv[0]);
val = "LPDEST";
if (printer && !cupsGetDest(printer, NULL, num_dests, dests))
_cupsLangPrintf(stderr,
_("%s: Error - %s environment variable names "
"non-existent destination \"%s\"!\n"),
argv[0], val, printer);
else if (cupsLastError() == IPP_NOT_FOUND)
_cupsLangPrintf(stderr,
_("%s: Error - no default destination available.\n"),
argv[0]);
else
_cupsLangPrintf(stderr,
_("%s: Error - scheduler not responding!\n"),
argv[0]);
return (1);
}
@@ -372,47 +427,77 @@ main(int argc, /* I - Number of command-line arguments */
unlink(files[i]);
}
}
else if ((job_id = cupsCreateJob(CUPS_HTTP_DEFAULT, printer,
title ? title : "(stdin)",
num_options, options)) > 0)
else
{
http_status_t status; /* Write status */
const char *format; /* Document format */
ssize_t bytes; /* Bytes read */
num_files = 1;
if (cupsGetOption("raw", num_options, options))
format = CUPS_FORMAT_RAW;
else if ((format = cupsGetOption("document-format", num_options,
options)) == NULL)
format = CUPS_FORMAT_AUTO;
#ifndef WIN32
# if defined(HAVE_SIGSET)
sigset(SIGHUP, sighandler);
if (sigset(SIGINT, sighandler) == SIG_IGN)
sigset(SIGINT, SIG_IGN);
sigset(SIGTERM, sighandler);
# elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
action.sa_handler = sighandler;
status = cupsStartDocument(CUPS_HTTP_DEFAULT, printer, job_id, NULL,
format, 1);
sigaction(SIGHUP, &action, NULL);
sigaction(SIGINT, NULL, &oldaction);
if (oldaction.sa_handler != SIG_IGN)
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
# else
signal(SIGHUP, sighandler);
if (signal(SIGINT, sighandler) == SIG_IGN)
signal(SIGINT, SIG_IGN);
signal(SIGTERM, sighandler);
# endif
#endif /* !WIN32 */
while (status == HTTP_CONTINUE &&
(bytes = read(0, buffer, sizeof(buffer))) > 0)
status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
if (status != HTTP_CONTINUE)
if ((temp = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
_cupsLangPrintf(stderr, _("%s: Error - unable to queue from stdin - %s."),
argv[0], httpStatus(status));
cupsFinishDocument(CUPS_HTTP_DEFAULT, printer);
cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
_cupsLangPrintf(stderr,
_("%s: Error - unable to create temporary file "
"\"%s\" - %s\n"),
argv[0], tempfile, strerror(errno));
return (1);
}
if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_OK)
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);
}
filesize = lseek(temp, 0, SEEK_CUR);
close(temp);
if (filesize <= 0)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
_cupsLangPrintf(stderr,
_("%s: Error - stdin is empty, so no job has been sent.\n"),
argv[0]);
unlink(tempfile);
return (1);
}
if (title)
job_id = cupsPrintFile(printer, tempfile, title, num_options, options);
else
job_id = cupsPrintFile(printer, tempfile, "(stdin)", num_options, options);
unlink(tempfile);
}
if (job_id < 1)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
return (1);
}
@@ -420,36 +505,29 @@ main(int argc, /* I - Number of command-line arguments */
}
#ifndef WIN32
/*
* 'usage()' - Show program usage and exit.
* 'sighandler()' - Signal catcher for when we print from stdin...
*/
static void
usage(void)
void
sighandler(int s) /* I - Signal number */
{
_cupsLangPuts(stdout, _("Usage: lpr [options] [file(s)]"));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _("-# num-copies Specify the number of copies to print"));
_cupsLangPuts(stdout, _("-E Encrypt the connection to the server"));
_cupsLangPuts(stdout, _("-H server[:port] Connect to the named server and port"));
_cupsLangPuts(stdout, _("-m Send an email notification when the job completes"));
_cupsLangPuts(stdout, _("-o option[=value] Specify a printer-specific option"));
_cupsLangPuts(stdout, _("-o job-sheets=standard Print a banner page with the job"));
_cupsLangPuts(stdout, _("-o media=size Specify the media size to use"));
_cupsLangPuts(stdout, _("-o number-up=N Specify that input pages should be printed N-up (1, 2, 4, 6, 9, and 16 are supported)"));
_cupsLangPuts(stdout, _("-o orientation-requested=N\n"
" Specify portrait (3) or landscape (4) orientation"));
_cupsLangPuts(stdout, _("-o print-quality=N Specify the print quality - draft (3), normal (4), or best (5)"));
_cupsLangPuts(stdout, _("-o sides=one-sided Specify 1-sided printing"));
_cupsLangPuts(stdout, _("-o sides=two-sided-long-edge\n"
" Specify 2-sided portrait printing"));
_cupsLangPuts(stdout, _("-o sides=two-sided-short-edge\n"
" Specify 2-sided landscape printing"));
_cupsLangPuts(stdout, _("-P destination Specify the destination"));
_cupsLangPuts(stdout, _("-q Specify the job should be held for printing"));
_cupsLangPuts(stdout, _("-r Remove the file(s) after submission"));
_cupsLangPuts(stdout, _("-T title Specify the job title"));
_cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
/*
* Remove the temporary file we're using to print from stdin...
*/
exit(1);
unlink(tempfile);
/*
* Exit...
*/
exit(s);
}
#endif /* !WIN32 */
/*
* End of "$Id$".
*/
+204 -157
Ver Arquivo
@@ -1,25 +1,41 @@
/*
* "lprm" command for CUPS.
* "$Id$"
*
* Copyright © 2007-2018 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
* "lprm" command for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Parse options and cancel jobs.
*/
/*
* Include necessary headers...
*/
#include <cups/cups-private.h>
#include <stdio.h>
#include <stdlib.h>
/*
* Local functions...
*/
static void usage(void) _CUPS_NORETURN;
#include <cups/cups.h>
#include <cups/i18n.h>
#include <cups/string.h>
/*
@@ -30,140 +46,153 @@ int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
http_t *http; /* HTTP connection to server */
int i; /* Looping var */
int job_id; /* Job ID */
const char *name; /* Destination printer */
char *instance, /* Pointer to instance name */
*opt; /* Option pointer */
cups_dest_t *dest, /* Destination */
*defdest; /* Default destination */
int did_cancel; /* Did we cancel something? */
const char *dest; /* Destination printer */
char *instance; /* Pointer to instance name */
char uri[1024]; /* Printer or job URI */
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 */
http_encryption_t encryption; /* Encryption? */
_cupsSetLocale(argv);
/*
* Setup to cancel individual print jobs...
*/
did_cancel = 0;
defdest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL);
name = defdest ? defdest->name : NULL;
op = IPP_CANCEL_JOB;
job_id = 0;
dest = NULL;
response = NULL;
http = NULL;
encryption = cupsEncryption();
language = cupsLangDefault();
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)
{
_cupsLangPuts(stderr, _("lprm: Unable to contact server!\n"));
cupsFreeDests(num_dests, dests);
return (1);
}
/*
* Process command-line arguments...
*/
for (i = 1; i < argc; i ++)
{
if (!strcmp(argv[i], "--help"))
usage();
else if (argv[i][0] == '-' && argv[i][1] != '\0')
{
for (opt = argv[i] + 1; *opt; opt ++)
if (argv[i][0] == '-' && argv[i][1] != '\0')
switch (argv[i][1])
{
switch (*opt)
{
case 'E' : /* Encrypt */
case 'E' : /* Encrypt */
#ifdef HAVE_SSL
cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
encryption = HTTP_ENCRYPT_REQUIRED;
httpEncryption(http, encryption);
#else
_cupsLangPrintf(stderr, _("%s: Sorry, no encryption support."), argv[0]);
_cupsLangPrintf(stderr,
_("%s: Sorry, no encryption support compiled in!\n"),
argv[0]);
#endif /* HAVE_SSL */
break;
break;
case 'P' : /* Cancel jobs on a printer */
if (opt[1] != '\0')
case 'P' : /* Cancel jobs on a printer */
if (argv[i][2])
dest = argv[i] + 2;
else
{
i ++;
dest = argv[i];
}
if ((instance = strchr(dest, '/')) != NULL)
*instance = '\0';
if (cupsGetDest(dest, NULL, num_dests, dests) == NULL)
{
_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)
{
name = opt + 1;
opt += strlen(opt) - 1;
_cupsLangPrintf(stderr,
_("%s: Error - expected username after "
"\'-U\' option!\n"),
argv[0]);
return (1);
}
cupsSetUser(argv[i]);
}
break;
case 'h' : /* Connect to host */
if (http != NULL)
httpClose(http);
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
{
i ++;
name = argv[i];
}
cupsSetServer(argv[i]);
}
break;
if ((instance = strchr(name, '/')) != NULL)
*instance = '\0';
if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, name, NULL)) == NULL)
{
_cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s\"."), argv[0], name);
goto error;
}
cupsFreeDests(1, dest);
break;
case 'U' : /* Username */
if (opt[1] != '\0')
{
cupsSetUser(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]);
usage();
}
cupsSetUser(argv[i]);
}
break;
case 'h' : /* Connect to host */
if (opt[1] != '\0')
{
cupsSetServer(opt + 1);
opt += strlen(opt) - 1;
}
else
{
i ++;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]);
usage();
}
else
cupsSetServer(argv[i]);
}
if (defdest)
cupsFreeDests(1, defdest);
defdest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL);
name = defdest ? defdest->name : NULL;
break;
default :
_cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt);
usage();
}
default :
_cupsLangPrintf(stderr,
_("%s: Error - unknown option \'%c\'!\n"),
argv[0], argv[i][1]);
cupsFreeDests(num_dests, dests);
httpClose(http);
return (1);
}
}
else
{
/*
* Cancel a job or printer...
*/
if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, argv[i], NULL)) != NULL)
cupsFreeDests(1, dest);
if (dest)
if (isdigit(argv[i][0] & 255) &&
cupsGetDest(argv[i], NULL, num_dests, dests) == NULL)
{
name = argv[i];
job_id = 0;
}
else if (isdigit(argv[i][0] & 255))
{
name = NULL;
dest = NULL;
op = IPP_CANCEL_JOB;
job_id = atoi(argv[i]);
}
else if (!strcmp(argv[i], "-"))
@@ -172,69 +201,87 @@ main(int argc, /* I - Number of command-line arguments */
* Cancel all jobs
*/
job_id = -1;
op = IPP_PURGE_JOBS;
}
else
{
_cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s\"."),
argv[0], argv[i]);
goto error;
dest = argv[i];
job_id = 0;
}
if (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) != IPP_OK)
/*
* Build an IPP request, which requires the following
* attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri + job-id *or* job-uri
* [requesting-user-name]
*/
request = ippNewRequest(op);
if (dest)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
goto error;
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",
job_id);
}
else
{
sprintf(uri, "ipp://localhost/jobs/%d", job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
uri);
}
did_cancel = 1;
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
/*
* Do the request and get back a response...
*/
if (op == IPP_PURGE_JOBS)
response = cupsDoRequest(http, request, "/admin/");
else
response = cupsDoRequest(http, request, "/jobs/");
ippDelete(response);
if (cupsLastError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
cupsFreeDests(num_dests, dests);
httpClose(http);
return (1);
}
}
}
/*
* If nothing has been canceled yet, cancel the current job on the specified
* If nothing has been cancelled yet, cancel the current job on the specified
* (or default) printer...
*/
if (!did_cancel && cupsCancelJob2(CUPS_HTTP_DEFAULT, name, 0, 0) != IPP_OK)
if (response == NULL)
if (!cupsCancelJob(dest, 0))
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
goto error;
_cupsLangPrintf(stderr, "%s: %s\n", argv[0], cupsLastErrorString());
cupsFreeDests(num_dests, dests);
httpClose(http);
return (1);
}
if (defdest)
cupsFreeDests(1, defdest);
cupsFreeDests(num_dests, dests);
httpClose(http);
return (0);
/*
* If we get here there was an error, so clean up...
*/
error:
if (defdest)
cupsFreeDests(1, defdest);
return (1);
}
/*
* 'usage()' - Show program usage and exit.
* End of "$Id$".
*/
static void
usage(void)
{
_cupsLangPuts(stdout, _("Usage: lprm [options] [id]\n"
" lprm [options] -"));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _("- Cancel all jobs"));
_cupsLangPuts(stdout, _("-E Encrypt the connection to the server"));
_cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port"));
_cupsLangPuts(stdout, _("-P destination Specify the destination"));
_cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
exit(1);
}
+55 -72
Ver Arquivo
@@ -1,72 +1,55 @@
help-index.o: help-index.c cgi-private.h cgi.h ../cups/cups.h \
../cups/file.h ../cups/versioning.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h help-index.h \
../cups/debug-private.h ../cups/language-private.h ../config.h \
../cups/transcode.h ../cups/string-private.h ../cups/ipp-private.h \
../cups/dir.h
html.o: html.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
ipp-var.o: ipp-var.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
search.o: search.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
template.o: template.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
var.o: var.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
admin.o: admin.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h ../cups/http-private.h \
../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h \
../cups/pwg-private.h ../cups/adminutil.h
classes.o: classes.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
help.o: help.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
jobs.o: jobs.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
makedocset.o: makedocset.c cgi-private.h cgi.h ../cups/cups.h \
../cups/file.h ../cups/versioning.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h help-index.h \
../cups/debug-private.h ../cups/language-private.h ../config.h \
../cups/transcode.h ../cups/string-private.h ../cups/ipp-private.h
printers.o: printers.c cgi-private.h cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h ../cups/debug-private.h \
../cups/language-private.h ../config.h ../cups/transcode.h \
../cups/string-private.h ../cups/ipp-private.h
testcgi.o: testcgi.c cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h
testhi.o: testhi.c cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h
testtemplate.o: testtemplate.c cgi.h ../cups/cups.h ../cups/file.h \
../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h
# DO NOT DELETE
help-index.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
help-index.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
help-index.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
help-index.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
html.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
html.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
ipp-var.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
ipp-var.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
search.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
search.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
template.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
template.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
var.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
var.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
admin.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
admin.o: ../cups/i18n.h ../cups/string.h ../config.h ../cups/file.h
classes.o: cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
classes.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
classes.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
classes.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
help.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
help.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
jobs.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
jobs.o: ../cups/i18n.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/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
printers.o: ../cups/language.h ../cups/array.h help-index.h ../cups/debug.h
printers.o: ../cups/i18n.h ../cups/string.h ../config.h
testcgi.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
testcgi.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
testcgi.o: ../cups/array.h help-index.h
testhi.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
testhi.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
testhi.o: ../cups/array.h help-index.h
testtemplate.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
testtemplate.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
testtemplate.o: ../cups/language.h ../cups/array.h help-index.h
+53 -124
Ver Arquivo
@@ -1,50 +1,34 @@
#
# CGI makefile for CUPS.
# "$Id$"
#
# Copyright © 2007-2019 by Apple Inc.
# Copyright © 1997-2006 by Easy Software Products.
# CGI makefile for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
# 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 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
include ../Makedefs
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 \
makedocset.o \
printers.o \
testcgi.o \
testhi.o \
testtemplate.o
CGIS = \
admin.cgi \
classes.cgi \
help.cgi \
jobs.cgi \
printers.cgi
LIBTARGETS = \
libcupscgi.a
UNITTARGETS = \
testcgi \
testhi \
testtemplate
TARGETS = \
$(LIBTARGETS) \
$(CGIS)
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
#
@@ -54,26 +38,12 @@ TARGETS = \
all: $(TARGETS)
#
# Make library targets...
#
libs:
#
# Make unit tests...
#
unittests: $(UNITTARGETS)
#
# Clean all object files...
#
clean:
$(RM) $(OBJS) $(TARGETS) $(UNITTARGETS) makedocset
$(RM) $(OBJS) $(TARGETS)
#
@@ -81,53 +51,18 @@ clean:
#
depend:
$(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
makedepend -Y -I.. -fDependencies $(OBJS:.o=.c) >/dev/null 2>&1
#
# Install all targets...
#
install: all install-data install-headers install-libs install-exec
#
# Install data files...
#
install-data:
#
# Install programs...
#
install-exec:
install: all
$(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 $(CGIS); do \
cp $$file $(SYMROOT); \
dsymutil $(SYMROOT)/$$file; \
done \
fi
#
# Install headers...
#
install-headers:
#
# Install libraries...
#
install-libs:
#
@@ -142,10 +77,10 @@ uninstall:
#
# libcupscgi.a
# libcgi.a
#
libcupscgi.a: $(LIBOBJS)
libcgi.a: $(LIBOBJS)
echo Archiving $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
@@ -156,86 +91,75 @@ libcupscgi.a: $(LIBOBJS)
# admin.cgi
#
admin.cgi: admin.o ../Makedefs ../cups/$(LIBCUPS) libcupscgi.a
admin.cgi: admin.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ admin.o libcupscgi.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ admin.o libcgi.a $(LIBS)
#
# classes.cgi
#
classes.cgi: classes.o ../Makedefs ../cups/$(LIBCUPS) libcupscgi.a
classes.cgi: classes.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ classes.o libcupscgi.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ classes.o libcgi.a $(LIBS)
#
# help.cgi
#
help.cgi: help.o ../Makedefs ../cups/$(LIBCUPS) libcupscgi.a
help.cgi: help.o ../Makedefs libcgi.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ help.o libcupscgi.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ help.o libcgi.a $(LIBS)
#
# jobs.cgi
#
jobs.cgi: jobs.o ../Makedefs ../cups/$(LIBCUPS) libcupscgi.a
jobs.cgi: jobs.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ jobs.o libcupscgi.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ jobs.o libcgi.a $(LIBS)
#
# printers.cgi
#
printers.cgi: printers.o ../Makedefs ../cups/$(LIBCUPS) libcupscgi.a
printers.cgi: printers.o ../Makedefs ../cups/$(LIBCUPS) libcgi.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ printers.o libcupscgi.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ printers.o libcgi.a $(LIBS)
#
# testcgi
#
testcgi: testcgi.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
testcgi: testcgi.o ../Makedefs libcgi.a ../cups/libcups.a
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testcgi.o libcupscgi.a \
$(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
echo Testing CGI API...
./testcgi
$(CC) $(LDFLAGS) -o $@ testcgi.o libcgi.a ../cups/libcups.a \
$(COMMONLIBS) $(SSLLIBS) $(LIBZ)
#
# testhi
#
testhi: testhi.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
testhi: testhi.o ../Makedefs libcgi.a ../cups/libcups.a
echo Linking $@...
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testhi.o libcupscgi.a \
$(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
echo Testing help index API...
./testhi
$(CC) $(LDFLAGS) -o $@ testhi.o libcgi.a ../cups/libcups.a \
$(COMMONLIBS) $(SSLLIBS) $(LIBZ)
#
# testtemplate
#
testtemplate: testtemplate.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
testtemplate: testtemplate.o ../Makedefs libcgi.a ../cups/libcups.a
echo Linking $@...
$(LD_CC) $(ALL_LDFLAGS) -o $@ testtemplate.o libcupscgi.a $(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(CC) $(LDFLAGS) -o $@ testtemplate.o libcgi.a ../cups/libcups.a \
$(COMMONLIBS) $(SSLLIBS) $(LIBZ)
#
@@ -243,3 +167,8 @@ testtemplate: testtemplate.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
#
include Dependencies
#
# End of "$Id$".
#
+1240 -2186
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+28 -9
Ver Arquivo
@@ -1,10 +1,25 @@
/*
* Private CGI definitions for CUPS.
* "$Id$"
*
* Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* Private CGI definitions for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* Copyright 1997-2005 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*/
/*
@@ -12,14 +27,18 @@
*/
#include "cgi.h"
#include <cups/debug-private.h>
#include <cups/language-private.h>
#include <cups/string-private.h>
#include <cups/ipp-private.h> /* TODO: Update so we don't need this */
#include <cups/debug.h>
#include <cups/i18n.h>
#include <cups/string.h>
/*
* Limits...
*/
#define CUPS_PAGE_MAX 100 /* Maximum items per page */
#define CUPS_PAGE_MAX 10 /* Maximum items per page */
/*
* End of "$Id$".
*/
+29 -30
Ver Arquivo
@@ -1,11 +1,25 @@
/*
* CGI support library definitions for CUPS.
* "$Id$"
*
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
* CGI support library definitions.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*/
#ifndef _CUPS_CGI_H_
@@ -16,26 +30,18 @@
# include <time.h>
# include <sys/stat.h>
# ifdef _WIN32
# ifdef WIN32
# include <direct.h>
# include <io.h>
# else
# include <unistd.h>
# endif /* _WIN32 */
# endif /* WIN32 */
# include <cups/cups.h>
# include <cups/array.h>
# include "help-index.h"
/*
* C++ magic...
*/
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
/*
* Types...
*/
@@ -57,29 +63,24 @@ typedef struct cgi_file_s /**** Uploaded file data ****/
extern void cgiAbort(const char *title, const char *stylesheet,
const char *format, ...);
extern int cgiCheckVariables(const char *names);
extern void cgiClearVariables(void);
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 void cgiEndMultipart(void);
extern char *cgiFormEncode(char *dst, const char *src,
size_t dstsize);
extern char *cgiFormEncode(char *dst, const char *src, size_t dstsize);
extern void cgiFreeSearch(void *search);
extern char *cgiGetArray(const char *name, int element);
extern const char *cgiGetArray(const char *name, int element);
extern void cgiGetAttributes(ipp_t *request, const char *tmpl);
extern const char *cgiGetCookie(const char *name);
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 char *cgiGetTemplateDir(void);
extern char *cgiGetVariable(const char *name);
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 cgiPrintCommand(http_t *http, const char *dest,
const char *command, const char *title);
extern void cgiPrintTestPage(http_t *http, const char *dest);
extern char *cgiRewriteURL(const char *uri, char *url, int urlsize,
const char *newresource);
@@ -99,12 +100,10 @@ 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 void cgiStartMultipart(void);
extern int cgiSupportsMultipart(void);
extern const char *cgiText(const char *message);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !_CUPS_CGI_H_ */
/*
* End of "$Id$".
*/
+112 -174
Ver Arquivo
@@ -1,10 +1,31 @@
/*
* Class status CGI for CUPS.
* "$Id$"
*
* Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* Class status CGI for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Main entry for CGI.
* show_all_classes() - Show all classes...
* show_class() - Show a single class.
*/
/*
@@ -18,10 +39,8 @@
* Local functions...
*/
static void do_class_op(http_t *http, const char *printer, ipp_op_t op,
const char *title);
static void show_all_classes(http_t *http, const char *username);
static void show_class(http_t *http, const char *printer);
void show_all_classes(http_t *http, const char *username);
void show_class(http_t *http, const char *printer);
/*
@@ -29,7 +48,8 @@ static void show_class(http_t *http, const char *printer);
*/
int /* O - Exit status */
main(void)
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
const char *pclass; /* Class name */
const char *user; /* Username */
@@ -58,7 +78,6 @@ main(void)
*/
cgiSetVariable("SECTION", "classes");
cgiSetVariable("REFRESH_PAGE", "");
/*
* See if we are displaying a printer or all classes...
@@ -70,16 +89,14 @@ main(void)
if (!*pclass)
pclass = NULL;
if (pclass)
cgiSetVariable("PRINTER_NAME", pclass);
}
/*
* See who is logged in...
*/
user = getenv("REMOTE_USER");
if ((user = getenv("REMOTE_USER")) == NULL)
user = "guest";
/*
* Connect to the HTTP server...
@@ -91,7 +108,7 @@ main(void)
* Get the default printer...
*/
if (!op || !cgiIsPOST())
if (!op)
{
/*
* Get the default destination...
@@ -131,54 +148,21 @@ main(void)
else
show_class(http, pclass);
}
else if (pclass)
{
if (!*op)
{
const char *server_port = getenv("SERVER_PORT");
/* Port number string */
int port = atoi(server_port ? server_port : "0");
/* Port number */
char uri[1024]; /* URL */
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri),
getenv("HTTPS") ? "https" : "http", NULL,
getenv("SERVER_NAME"), port, "/classes/%s", pclass);
printf("Location: %s\n\n", uri);
}
else if (!strcmp(op, "start-class"))
do_class_op(http, pclass, IPP_RESUME_PRINTER, cgiText(_("Resume Class")));
else if (!strcmp(op, "stop-class"))
do_class_op(http, pclass, IPP_PAUSE_PRINTER, cgiText(_("Pause Class")));
else if (!strcmp(op, "accept-jobs"))
do_class_op(http, pclass, CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
else if (!strcmp(op, "reject-jobs"))
do_class_op(http, pclass, CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
else if (!strcmp(op, "cancel-jobs"))
do_class_op(http, pclass, IPP_OP_CANCEL_JOBS, cgiText(_("Cancel Jobs")));
else if (!_cups_strcasecmp(op, "print-test-page"))
cgiPrintTestPage(http, pclass);
else if (!_cups_strcasecmp(op, "move-jobs"))
cgiMoveJobs(http, pclass, 0);
else
{
/*
* Unknown/bad operation...
*/
cgiStartHTML(pclass);
cgiCopyTemplateLang("error-op.tmpl");
cgiEndHTML();
}
}
else if (!strcasecmp(op, "print-test-page") && pclass)
cgiPrintTestPage(http, pclass);
else if (!strcasecmp(op, "move-jobs") && pclass)
cgiMoveJobs(http, pclass, 0);
else
{
/*
* Unknown/bad operation...
*/
cgiStartHTML(cgiText(_("Classes")));
if (pclass)
cgiStartHTML(pclass);
else
cgiStartHTML(cgiText(_("Classes")));
cgiCopyTemplateLang("error-op.tmpl");
cgiEndHTML();
}
@@ -197,107 +181,27 @@ main(void)
}
/*
* 'do_class_op()' - Do a class operation.
*/
static void
do_class_op(http_t *http, /* I - HTTP connection */
const char *printer, /* I - Printer name */
ipp_op_t op, /* I - Operation to perform */
const char *title) /* I - Title of page */
{
ipp_t *request; /* IPP request */
char uri[HTTP_MAX_URI], /* Printer URI */
resource[HTTP_MAX_URI]; /* Path for request */
/*
* Build a printer request, which requires the following
* attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri
*/
request = ippNewRequest(op);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, "/classes/%s", printer);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
/*
* Do the request and get back a response...
*/
snprintf(resource, sizeof(resource), "/classes/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
if (cupsLastError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
else if (cupsLastError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
}
else
{
/*
* Redirect successful updates back to the printer page...
*/
char url[1024], /* Printer/class URL */
refresh[1024]; /* Refresh URL */
cgiRewriteURL(uri, url, sizeof(url), NULL);
cgiFormEncode(uri, url, sizeof(uri));
snprintf(refresh, sizeof(refresh), "5;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
cgiStartHTML(title);
cgiSetVariable("IS_CLASS", "YES");
if (op == IPP_PAUSE_PRINTER)
cgiCopyTemplateLang("printer-stop.tmpl");
else if (op == IPP_RESUME_PRINTER)
cgiCopyTemplateLang("printer-start.tmpl");
else if (op == CUPS_ACCEPT_JOBS)
cgiCopyTemplateLang("printer-accept.tmpl");
else if (op == CUPS_REJECT_JOBS)
cgiCopyTemplateLang("printer-reject.tmpl");
else if (op == IPP_OP_CANCEL_JOBS)
cgiCopyTemplateLang("printer-cancel-jobs.tmpl");
}
cgiEndHTML();
}
/*
* 'show_all_classes()' - Show all classes...
*/
static void
void
show_all_classes(http_t *http, /* I - Connection to server */
const char *user) /* I - Username */
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 first, /* First class to show */
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 val[1024]; /* Form variable */
char url[1024], /* URL for prev/next/this */
*urlptr, /* Position in URL */
*urlend; /* End of URL */
/*
@@ -317,9 +221,8 @@ show_all_classes(http_t *http, /* I - Connection to server */
request = ippNewRequest(CUPS_GET_CLASSES);
if (user)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
cgiGetAttributes(request, "classes.tmpl");
@@ -333,8 +236,7 @@ show_all_classes(http_t *http, /* I - Connection to server */
* Get a list of matching job objects.
*/
if ((var = cgiGetVariable("QUERY")) != NULL &&
!cgiGetVariable("CLEAR"))
if ((var = cgiGetVariable("QUERY")) != NULL)
search = cgiCompileSearch(var);
else
search = NULL;
@@ -362,36 +264,67 @@ show_all_classes(http_t *http, /* I - Connection to server */
if (first < 0)
first = 0;
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);
sprintf(url, "%d", count);
cgiSetVariable("TOTAL", url);
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);
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...
*/
cgiSetVariable("THISURL", "/classes/");
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)
{
sprintf(val, "%d", first - CUPS_PAGE_MAX);
cgiSetVariable("PREV", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("PREVURL", url);
}
if ((first + CUPS_PAGE_MAX) < count)
{
sprintf(val, "%d", first + CUPS_PAGE_MAX);
cgiSetVariable("NEXT", val);
}
if (count > CUPS_PAGE_MAX)
{
snprintf(val, sizeof(val), "%d", CUPS_PAGE_MAX * (count / CUPS_PAGE_MAX));
cgiSetVariable("LAST", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("NEXTURL", url);
}
/*
@@ -402,12 +335,12 @@ show_all_classes(http_t *http, /* I - Connection to server */
cgiCopyTemplateLang("classes-header.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
cgiCopyTemplateLang("classes.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
/*
@@ -423,7 +356,7 @@ show_all_classes(http_t *http, /* I - Connection to server */
* Show the error...
*/
cgiShowIPPError(_("Unable to get class list"));
cgiShowIPPError(_("Unable to get class list:"));
}
cgiEndHTML();
@@ -434,7 +367,7 @@ show_all_classes(http_t *http, /* I - Connection to server */
* 'show_class()' - Show a single class.
*/
static void
void
show_class(http_t *http, /* I - Connection to server */
const char *pclass) /* I - Name of class */
{
@@ -461,7 +394,7 @@ show_class(http_t *http, /* I - Connection to server */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
uri);
cgiGetAttributes(request, "class.tmpl");
cgiGetAttributes(request, "classes.tmpl");
/*
* Do the request and get back a response...
@@ -486,7 +419,7 @@ show_class(http_t *http, /* I - Connection to server */
*/
cgiFormEncode(uri, pclass, sizeof(uri));
snprintf(refresh, sizeof(refresh), "10;URL=/classes/%s", uri);
snprintf(refresh, sizeof(refresh), "10;/classes/%s", uri);
cgiSetVariable("refresh_page", refresh);
}
@@ -506,7 +439,7 @@ show_class(http_t *http, /* I - Connection to server */
* Show the class status...
*/
cgiCopyTemplateLang("class.tmpl");
cgiCopyTemplateLang("classes.tmpl");
/*
* Show jobs for the specified class...
@@ -522,8 +455,13 @@ show_class(http_t *http, /* I - Connection to server */
*/
cgiStartHTML(pclass);
cgiShowIPPError(_("Unable to get class status"));
cgiShowIPPError(_("Unable to get class status:"));
}
cgiEndHTML();
}
/*
* End of "$Id$".
*/
+155 -436
Ver Arquivo
@@ -1,11 +1,40 @@
/*
* Online help index routines for CUPS.
* "$Id$"
*
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products.
* On-line help index routines for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* helpDeleteIndex() - Delete an index, freeing all memory used.
* helpFindNode() - Find a node in an index.
* helpLoadIndex() - Load a help index from disk.
* helpSaveIndex() - Save a help index to disk.
* helpSearchIndex() - Search an index.
* help_compile_search() - Convert a search string into a regular expression.
* help_delete_node() - Free all memory used by a node.
* help_load_directory() - Load a directory of files into an index.
* help_load_file() - Load a HTML files into an index.
* help_new_node() - Create a new node and add it to an index.
* help_sort_nodes_by_name() - Sort nodes by section, filename, and anchor.
* help_sort_nodes_by_score() - Sort nodes by score and text.
*/
/*
@@ -16,118 +45,11 @@
#include <cups/dir.h>
/*
* List of common English words that should not be indexed...
*/
static char help_common_words[][6] =
{
"about",
"all",
"an",
"and",
"are",
"as",
"at",
"be",
"been",
"but",
"by",
"call",
"can",
"come",
"could",
"day",
"did",
"do",
"down",
"each",
"find",
"first",
"for",
"from",
"go",
"had",
"has",
"have",
"he",
"her",
"him",
"his",
"hot",
"how",
"if",
"in",
"is",
"it",
"know",
"like",
"long",
"look",
"make",
"many",
"may",
"more",
"most",
"my",
"no",
"now",
"of",
"on",
"one",
"or",
"other",
"out",
"over",
"said",
"see",
"she",
"side",
"so",
"some",
"sound",
"than",
"that",
"the",
"their",
"them",
"then",
"there",
"these",
"they",
"thing",
"this",
"time",
"to",
"two",
"up",
"use",
"was",
"water",
"way",
"we",
"were",
"what",
"when",
"which",
"who",
"will",
"with",
"word",
"would",
"write",
"you",
"your"
};
/*
* Local functions...
*/
static help_word_t *help_add_word(help_node_t *n, const char *text);
static void help_delete_node(help_node_t *n);
static void help_delete_word(help_word_t *w);
static int help_load_directory(help_index_t *hi,
const char *directory,
const char *relative);
@@ -135,10 +57,12 @@ static int help_load_file(help_index_t *hi,
const char *filename,
const char *relative,
time_t mtime);
static help_node_t *help_new_node(const char *filename, const char *anchor, const char *section, const char *text, time_t mtime, off_t offset, size_t length) _CUPS_NONNULL(1,3,4);
static help_node_t *help_new_node(const char *filename, const char *anchor,
const char *section, const char *text,
time_t mtime, off_t offset,
size_t length);
static int help_sort_by_name(help_node_t *p1, help_node_t *p2);
static int help_sort_by_score(help_node_t *p1, help_node_t *p2);
static int help_sort_words(help_word_t *w1, help_word_t *w2);
/*
@@ -151,6 +75,8 @@ helpDeleteIndex(help_index_t *hi) /* I - Help index */
help_node_t *node; /* Current node */
DEBUG_printf(("helpDeleteIndex(hi=%p)\n", hi));
if (!hi)
return;
@@ -158,6 +84,9 @@ helpDeleteIndex(help_index_t *hi) /* I - Help index */
node;
node = (help_node_t *)cupsArrayNext(hi->nodes))
{
cupsArrayRemove(hi->nodes, node);
cupsArrayRemove(hi->sorted, node);
if (!hi->search)
help_delete_node(node);
}
@@ -181,6 +110,9 @@ helpFindNode(help_index_t *hi, /* I - Index */
help_node_t key; /* Search key */
DEBUG_printf(("helpFindNode(hi=%p, filename=\"%s\", anchor=\"%s\")\n",
hi, filename ? filename : "(nil)", anchor ? anchor : "(nil)"));
/*
* Range check input...
*/
@@ -225,9 +157,11 @@ helpLoadIndex(const char *hifile, /* I - Index filename */
size_t length; /* Length in bytes */
int update; /* Update? */
help_node_t *node; /* Current node */
help_word_t *word; /* Current word */
DEBUG_printf(("helpLoadIndex(hifile=\"%s\", directory=\"%s\")\n",
hifile, directory));
/*
* Create a new, empty index.
*/
@@ -258,14 +192,12 @@ helpLoadIndex(const char *hifile, /* I - Index filename */
cupsFileLock(fp, 1);
if (cupsFileGets(fp, line, sizeof(line)) && !strcmp(line, "HELPV2"))
if (cupsFileGets(fp, line, sizeof(line)) && !strcmp(line, "HELPV1"))
{
/*
* Got a valid header line, now read the data lines...
*/
node = NULL;
while (cupsFileGets(fp, line, sizeof(line)))
{
/*
@@ -273,82 +205,41 @@ helpLoadIndex(const char *hifile, /* I - Index filename */
*
* filename mtime offset length "section" "text"
* filename#anchor offset length "text"
* SP count word
*/
if (line[0] == ' ')
filename = line;
if ((ptr = strchr(line, ' ')) == NULL)
break;
while (isspace(*ptr & 255))
*ptr++ = '\0';
if ((anchor = strrchr(filename, '#')) != NULL)
{
/*
* Read a word in the current node...
*/
if (!node || (ptr = strrchr(line, ' ')) == NULL)
continue;
if ((word = help_add_word(node, ptr + 1)) != NULL)
word->count = atoi(line + 1);
}
*anchor++ = '\0';
mtime = 0;
}
else
mtime = strtol(ptr, &ptr, 10);
offset = strtoll(ptr, &ptr, 10);
length = strtoll(ptr, &ptr, 10);
while (isspace(*ptr & 255))
ptr ++;
if (!anchor)
{
/*
* Add a node...
* Get section...
*/
filename = line;
if ((ptr = strchr(line, ' ')) == NULL)
break;
while (isspace(*ptr & 255))
*ptr++ = '\0';
if ((anchor = strrchr(filename, '#')) != NULL)
{
*anchor++ = '\0';
mtime = 0;
}
else
mtime = strtol(ptr, &ptr, 10);
offset = strtoll(ptr, &ptr, 10);
length = (size_t)strtoll(ptr, &ptr, 10);
while (isspace(*ptr & 255))
ptr ++;
if (!anchor)
{
/*
* Get section...
*/
if (*ptr != '\"')
break;
ptr ++;
sectptr = ptr;
while (*ptr && *ptr != '\"')
ptr ++;
if (*ptr != '\"')
break;
*ptr++ = '\0';
strlcpy(section, sectptr, sizeof(section));
while (isspace(*ptr & 255))
ptr ++;
}
else
section[0] = '\0';
if (*ptr != '\"')
break;
ptr ++;
text = ptr;
sectptr = ptr;
while (*ptr && *ptr != '\"')
ptr ++;
@@ -358,14 +249,33 @@ helpLoadIndex(const char *hifile, /* I - Index filename */
*ptr++ = '\0';
if ((node = help_new_node(filename, anchor, section, text,
mtime, offset, length)) == NULL)
break;
strlcpy(section, sectptr, sizeof(section));
node->score = -1;
cupsArrayAdd(hi->nodes, node);
while (isspace(*ptr & 255))
ptr ++;
}
if (*ptr != '\"')
break;
ptr ++;
text = ptr;
while (*ptr && *ptr != '\"')
ptr ++;
if (*ptr != '\"')
break;
*ptr++ = '\0';
if ((node = help_new_node(filename, anchor, section, text,
mtime, offset, length)) == NULL)
break;
node->score = -1;
cupsArrayAdd(hi->nodes, node);
}
}
@@ -429,9 +339,10 @@ helpSaveIndex(help_index_t *hi, /* I - Index */
{
cups_file_t *fp; /* Index file */
help_node_t *node; /* Current node */
help_word_t *word; /* Current word */
DEBUG_printf(("helpSaveIndex(hi=%p, hifile=\"%s\")\n", hi, hifile));
/*
* Try creating a new index file...
*/
@@ -445,7 +356,7 @@ helpSaveIndex(help_index_t *hi, /* I - Index */
cupsFileLock(fp, 1);
cupsFilePuts(fp, "HELPV2\n");
cupsFilePuts(fp, "HELPV1\n");
for (node = (help_node_t *)cupsArrayFirst(hi->nodes);
node;
@@ -466,21 +377,11 @@ helpSaveIndex(help_index_t *hi, /* I - Index */
else
{
if (cupsFilePrintf(fp, "%s %d " CUPS_LLFMT " " CUPS_LLFMT " \"%s\" \"%s\"\n",
node->filename, (int)node->mtime,
node->filename, node->mtime,
CUPS_LLCAST node->offset, CUPS_LLCAST node->length,
node->section ? node->section : "", node->text) < 0)
break;
}
/*
* Then write the words associated with the node...
*/
for (word = (help_word_t *)cupsArrayFirst(node->words);
word;
word = (help_word_t *)cupsArrayNext(node->words))
if (cupsFilePrintf(fp, " %d %s\n", word->count, word->text) < 0)
break;
}
cupsFileFlush(fp);
@@ -506,11 +407,14 @@ helpSearchIndex(help_index_t *hi, /* I - Index */
{
help_index_t *search; /* Search index */
help_node_t *node; /* Current node */
help_word_t *word; /* Current word */
void *sc; /* Search context */
int matches; /* Number of matches */
DEBUG_printf(("helpSearchIndex(hi=%p, query=\"%s\", filename=\"%s\")\n",
hi, query ? query : "(nil)",
filename ? filename : "(nil)"));
/*
* Range check...
*/
@@ -561,7 +465,7 @@ helpSearchIndex(help_index_t *hi, /* I - Index */
search->nodes = cupsArrayNew((cups_array_func_t)help_sort_by_name, NULL);
search->sorted = cupsArrayNew((cups_array_func_t)help_sort_by_score, NULL);
if (!search->nodes || !search->sorted)
{
cupsArrayDelete(search->nodes);
@@ -583,27 +487,16 @@ helpSearchIndex(help_index_t *hi, /* I - Index */
continue;
else if (filename && strcmp(node->filename, filename))
continue;
else
else if ((matches = cgiDoSearch(sc, node->text)) > 0)
{
matches = cgiDoSearch(sc, node->text);
/*
* Found a match, add the node to the search index...
*/
for (word = (help_word_t *)cupsArrayFirst(node->words);
word;
word = (help_word_t *)cupsArrayNext(node->words))
if (cgiDoSearch(sc, word->text) > 0)
matches += word->count;
node->score = matches;
if (matches > 0)
{
/*
* Found a match, add the node to the search index...
*/
node->score = matches;
cupsArrayAdd(search->nodes, node);
cupsArrayAdd(search->sorted, node);
}
cupsArrayAdd(search->nodes, node);
cupsArrayAdd(search->sorted, node);
}
/*
@@ -620,59 +513,6 @@ helpSearchIndex(help_index_t *hi, /* I - Index */
}
/*
* 'help_add_word()' - Add a word to a node.
*/
static help_word_t * /* O - New word */
help_add_word(help_node_t *n, /* I - Node */
const char *text) /* I - Word text */
{
help_word_t *w, /* New word */
key; /* Search key */
/*
* Create the words array as needed...
*/
if (!n->words)
n->words = cupsArrayNew((cups_array_func_t)help_sort_words, NULL);
/*
* See if the word is already added...
*/
key.text = (char *)text;
if ((w = (help_word_t *)cupsArrayFind(n->words, &key)) == NULL)
{
/*
* Create a new word...
*/
if ((w = calloc(1, sizeof(help_word_t))) == NULL)
return (NULL);
if ((w->text = strdup(text)) == NULL)
{
free(w);
return (NULL);
}
cupsArrayAdd(n->words, w);
}
/*
* Bump the counter for this word and return it...
*/
w->count ++;
return (w);
}
/*
* 'help_delete_node()' - Free all memory used by a node.
*/
@@ -680,8 +520,7 @@ help_add_word(help_node_t *n, /* I - Node */
static void
help_delete_node(help_node_t *n) /* I - Node */
{
help_word_t *w; /* Current word */
DEBUG_printf(("help_delete_node(n=%p)\n", n));
if (!n)
return;
@@ -698,34 +537,10 @@ help_delete_node(help_node_t *n) /* I - Node */
if (n->text)
free(n->text);
for (w = (help_word_t *)cupsArrayFirst(n->words);
w;
w = (help_word_t *)cupsArrayNext(n->words))
help_delete_word(w);
cupsArrayDelete(n->words);
free(n);
}
/*
* 'help_delete_word()' - Free all memory used by a word.
*/
static void
help_delete_word(help_word_t *w) /* I - Word */
{
if (!w)
return;
if (w->text)
free(w->text);
free(w);
}
/*
* 'help_load_directory()' - Load a directory of files into an index.
*/
@@ -745,6 +560,9 @@ help_load_directory(
help_node_t *node; /* Current node */
DEBUG_printf(("help_load_directory(hi=%p, directory=\"%s\", relative=\"%s\")\n",
hi, directory ? directory : "(nil)", relative ? relative : "(nil)"));
/*
* Open the directory and scan it...
*/
@@ -843,24 +661,25 @@ help_load_file(
cups_file_t *fp; /* HTML file */
help_node_t *node; /* Current node */
char line[1024], /* Line from file */
temp[1024], /* Temporary word */
section[1024], /* Section */
*ptr, /* Pointer into line */
*anchor, /* Anchor name */
*text; /* Text for anchor */
off_t offset; /* File offset */
char quote; /* Quote character */
help_word_t *word; /* Current word */
int wordlen; /* Length of word */
DEBUG_printf(("help_load_file(hi=%p, filename=\"%s\", relative=\"%s\", mtime=%ld)\n",
hi, filename ? filename : "(nil)",
relative ? relative : "(nil)", mtime));
if ((fp = cupsFileOpen(filename, "r")) == NULL)
return (-1);
node = NULL;
offset = 0;
strlcpy(section, "Other", sizeof(section));
strcpy(section, "Other");
while (cupsFileGets(fp, line, sizeof(line)))
{
@@ -868,13 +687,13 @@ help_load_file(
* Look for "<TITLE>", "<A NAME", or "<!-- SECTION:" prefix...
*/
if ((ptr = strstr(line, "<!-- SECTION:")) != NULL)
if (!strncasecmp(line, "<!-- SECTION:", 13))
{
/*
* Got section line, copy it!
*/
for (ptr += 13; isspace(*ptr & 255); ptr ++);
for (ptr = line + 13; isspace(*ptr & 255); ptr ++);
strlcpy(section, ptr, sizeof(section));
if ((ptr = strstr(section, "-->")) != NULL)
@@ -895,7 +714,7 @@ help_load_file(
{
ptr ++;
if (!_cups_strncasecmp(ptr, "TITLE>", 6))
if (!strncasecmp(ptr, "TITLE>", 6))
{
/*
* Found the title...
@@ -904,23 +723,14 @@ help_load_file(
anchor = NULL;
ptr += 6;
}
else
else if (!strncasecmp(ptr, "A NAME=", 7))
{
char *idptr; /* Pointer to ID */
if (!_cups_strncasecmp(ptr, "A NAME=", 7))
ptr += 7;
else if ((idptr = strstr(ptr, " ID=")) != NULL)
ptr = idptr + 4;
else if ((idptr = strstr(ptr, " id=")) != NULL)
ptr = idptr + 4;
else
continue;
/*
* Found an anchor...
*/
ptr += 7;
if (*ptr == '\"' || *ptr == '\'')
{
/*
@@ -944,7 +754,7 @@ help_load_file(
for (ptr = anchor; *ptr && *ptr != '>' && !isspace(*ptr & 255); ptr ++);
if (*ptr != '>')
if (*ptr)
*ptr++ = '\0';
else
break;
@@ -960,8 +770,10 @@ help_load_file(
if (*ptr != '>')
break;
*ptr++ = '\0';
ptr ++;
}
else
continue;
/*
* Now collect text for the link...
@@ -976,14 +788,14 @@ help_load_file(
*ptr++ = ' ';
if (!cupsFileGets(fp, ptr, sizeof(line) - (size_t)(ptr - line) - 1))
if (!cupsFileGets(fp, ptr, sizeof(line) - (ptr - line) - 1))
break;
}
*ptr = '\0';
if (node)
node->length = (size_t)(offset - node->offset);
node->length = offset - node->offset;
if (!*text)
{
@@ -1006,17 +818,6 @@ help_load_file(
if (node->text)
free(node->text);
if (node->words)
{
for (word = (help_word_t *)cupsArrayFirst(node->words);
word;
word = (help_word_t *)cupsArrayNext(node->words))
help_delete_word(word);
cupsArrayDelete(node->words);
node->words = NULL;
}
node->section = section[0] ? strdup(section) : NULL;
node->text = strdup(text);
node->mtime = mtime;
@@ -1041,7 +842,7 @@ help_load_file(
if (isspace(*ptr & 255))
{
while (isspace(*ptr & 255))
ptr ++;
*ptr ++;
*text++ = ' ';
}
@@ -1060,99 +861,9 @@ help_load_file(
*/
cupsArrayAdd(hi->nodes, node);
if (!anchor)
node = NULL;
break;
}
if (node)
{
/*
* Scan this line for words...
*/
for (ptr = line; *ptr; ptr ++)
{
/*
* Skip HTML stuff...
*/
if (*ptr == '<')
{
if (!strncmp(ptr, "<!--", 4))
{
/*
* Skip HTML comment...
*/
if ((text = strstr(ptr + 4, "-->")) == NULL)
ptr += strlen(ptr) - 1;
else
ptr = text + 2;
}
else
{
/*
* Skip HTML element...
*/
for (ptr ++; *ptr && *ptr != '>'; ptr ++)
{
if (*ptr == '\"' || *ptr == '\'')
{
for (quote = *ptr++; *ptr && *ptr != quote; ptr ++);
if (!*ptr)
ptr --;
}
}
if (!*ptr)
ptr --;
}
continue;
}
else if (*ptr == '&')
{
/*
* Skip HTML entity...
*/
for (ptr ++; *ptr && *ptr != ';'; ptr ++);
if (!*ptr)
ptr --;
continue;
}
else if (!isalnum(*ptr & 255))
continue;
/*
* Found the start of a word, search until we find the end...
*/
for (text = ptr, ptr ++; *ptr && isalnum(*ptr & 255); ptr ++);
wordlen = (int)(ptr - text);
memcpy(temp, text, (size_t)wordlen);
temp[wordlen] = '\0';
ptr --;
if (wordlen > 1 && !bsearch(temp, help_common_words,
(sizeof(help_common_words) /
sizeof(help_common_words[0])),
sizeof(help_common_words[0]),
(int (*)(const void *, const void *))
_cups_strcasecmp))
help_add_word(node, temp);
}
}
/*
* Get the offset of the next line...
*/
@@ -1163,7 +874,7 @@ help_load_file(
cupsFileClose(fp);
if (node)
node->length = (size_t)(offset - node->offset);
node->length = offset - node->offset;
return (0);
}
@@ -1185,6 +896,12 @@ help_new_node(const char *filename, /* I - Filename */
help_node_t *n; /* Node */
DEBUG_printf(("help_new_node(filename=\"%s\", anchor=\"%s\", text=\"%s\", "
"mtime=%ld, offset=%ld, length=%ld)\n",
filename ? filename : "(nil)", anchor ? anchor : "(nil)",
text ? text : "(nil)", (long)mtime, (long)offset,
(long)length));
n = (help_node_t *)calloc(1, sizeof(help_node_t));
if (!n)
return (NULL);
@@ -1212,6 +929,10 @@ help_sort_by_name(help_node_t *n1, /* I - First node */
int diff; /* Difference */
DEBUG_printf(("help_sort_by_name(n1=%p(%s#%s), n2=%p(%s#%s)\n",
n1, n1->filename, n1->anchor ? n1->anchor : "",
n2, n2->filename, n2->anchor ? n2->anchor : ""));
if ((diff = strcmp(n1->filename, n2->filename)) != 0)
return (diff);
@@ -1237,8 +958,13 @@ help_sort_by_score(help_node_t *n1, /* I - First node */
int diff; /* Difference */
DEBUG_printf(("help_sort_by_score(n1=%p(%d \"%s\" \"%s\"), "
"n2=%p(%d \"%s\" \"%s\")\n",
n1, n1->score, n1->section ? n1->section : "", n1->text,
n2, n2->score, n2->section ? n2->section : "", n2->text));
if (n1->score != n2->score)
return (n2->score - n1->score);
return (n1->score - n2->score);
if (n1->section && !n2->section)
return (1);
@@ -1248,17 +974,10 @@ help_sort_by_score(help_node_t *n1, /* I - First node */
(diff = strcmp(n1->section, n2->section)) != 0)
return (diff);
return (_cups_strcasecmp(n1->text, n2->text));
return (strcasecmp(n1->text, n2->text));
}
/*
* 'help_sort_words()' - Sort words alphabetically.
* End of "$Id$".
*/
static int /* O - Difference */
help_sort_words(help_word_t *w1, /* I - Second word */
help_word_t *w2) /* I - Second word */
{
return (_cups_strcasecmp(w1->text, w2->text));
}
+25 -25
Ver Arquivo
@@ -1,10 +1,25 @@
/*
* Online help index definitions for CUPS.
* "$Id$"
*
* Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
* On-line help index definitions for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*/
#ifndef _CUPS_HELP_INDEX_H_
@@ -17,38 +32,23 @@
# include <cups/array.h>
/*
* C++ magic...
*/
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
/*
* 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... ****/
typedef struct /**** 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 ****/
typedef struct /**** Help index structure ****/
{
int search; /* 1 = search index, 0 = normal */
cups_array_t *nodes; /* Nodes sorted by filename */
@@ -70,8 +70,8 @@ extern help_index_t *helpSearchIndex(help_index_t *hi, const char *query,
const char *filename);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !_CUPS_HELP_INDEX_H_ */
/*
* End of "$Id$".
*/
+47 -45
Ver Arquivo
@@ -1,10 +1,29 @@
/*
* Online help CGI for CUPS.
* "$Id$"
*
* Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* On-line help CGI for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Main entry for CGI.
*/
/*
@@ -29,8 +48,7 @@ main(int argc, /* I - Number of command-line arguments */
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 */
*helptitle = NULL; /* Current help title */
const char *helpfile; /* Current help file */
const char *topic; /* Current topic */
char topic_data[1024]; /* Topic form data */
const char *section; /* Current section */
@@ -54,7 +72,6 @@ main(int argc, /* I - Number of command-line arguments */
*/
cgiSetVariable("SECTION", "help");
cgiSetVariable("REFRESH_PAGE", "");
/*
* Load the help index...
@@ -78,8 +95,8 @@ main(int argc, /* I - Number of command-line arguments */
{
perror(filename);
cgiStartHTML(cgiText(_("Online Help")));
cgiSetVariable("ERROR", cgiText(_("Unable to load help index.")));
cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Unable to load help index!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
@@ -94,7 +111,7 @@ main(int argc, /* I - Number of command-line arguments */
*/
for (i = 0; i < argc; i ++)
fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]);
fprintf(stderr, "argv[%d]=\"%s\"\n", i, argv[i]);
if ((helpfile = getenv("PATH_INFO")) != NULL)
{
@@ -119,8 +136,8 @@ main(int argc, /* I - Number of command-line arguments */
{
perror(filename);
cgiStartHTML(cgiText(_("Online Help")));
cgiSetVariable("ERROR", cgiText(_("Unable to access help file.")));
cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Unable to access help file!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
@@ -129,8 +146,8 @@ main(int argc, /* I - Number of command-line arguments */
if ((n = helpFindNode(hi, helpfile, NULL)) == NULL)
{
cgiStartHTML(cgiText(_("Online Help")));
cgiSetVariable("ERROR", cgiText(_("Help file not in index.")));
cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Help file not in index!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
@@ -138,11 +155,11 @@ main(int argc, /* I - Number of command-line arguments */
}
/*
* Save the page title and help file...
* Set the page title and save the help file...
*/
helptitle = n->text;
topic = n->section;
cgiSetVariable("HELPFILE", helpfile);
cgiSetVariable("HELPTITLE", n->text);
/*
* Send a standard page header...
@@ -159,33 +176,18 @@ main(int argc, /* I - Number of command-line arguments */
* Send a standard page header...
*/
cgiStartHTML(cgiText(_("Online Help")));
topic = cgiGetVariable("TOPIC");
cgiStartHTML(cgiText(_("Help")));
}
/*
* Do a search as needed...
*/
if (cgiGetVariable("CLEAR"))
cgiSetVariable("QUERY", "");
query = cgiGetVariable("QUERY");
topic = cgiGetVariable("TOPIC");
si = helpSearchIndex(hi, query, topic, helpfile);
cgiClearVariables();
if (query)
cgiSetVariable("QUERY", query);
if (topic)
cgiSetVariable("TOPIC", topic);
if (helpfile)
cgiSetVariable("HELPFILE", helpfile);
if (helptitle)
cgiSetVariable("HELPTITLE", helptitle);
fprintf(stderr, "DEBUG: query=\"%s\", topic=\"%s\"\n",
query ? query : "(null)", topic ? topic : "(null)");
fprintf(stderr, "DEBUG: query=\"%s\", topic=\"%s\"\n", query, topic);
if (si)
{
@@ -267,7 +269,7 @@ main(int argc, /* I - Number of command-line arguments */
section = n->section;
}
if (!topic || !n->section || strcmp(n->section, topic))
if (!topic || strcmp(n->section, topic))
continue;
/*
@@ -329,22 +331,20 @@ main(int argc, /* I - Number of command-line arguments */
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
int inbody; /* Are we inside the body? */
char *lineptr; /* Pointer into line */
inbody = 0;
while (cupsFileGets(fp, line, sizeof(line)))
{
for (lineptr = line; *lineptr && isspace(*lineptr & 255); lineptr ++);
if (inbody)
{
if (!_cups_strncasecmp(lineptr, "</BODY>", 7))
if (!strncasecmp(line, "</BODY>", 7))
break;
printf("%s\n", line);
}
else if (!_cups_strncasecmp(lineptr, "<BODY", 5))
else if (!strncasecmp(line, "<BODY", 5))
inbody = 1;
}
@@ -353,7 +353,7 @@ main(int argc, /* I - Number of command-line arguments */
else
{
perror(filename);
cgiSetVariable("ERROR", cgiText(_("Unable to open help file.")));
cgiSetVariable("ERROR", "Unable to open help file.");
cgiCopyTemplateLang("error.tmpl");
}
}
@@ -363,10 +363,7 @@ main(int argc, /* I - Number of command-line arguments */
*/
if (!printable)
{
cgiCopyTemplateLang("help-trailer.tmpl");
cgiEndHTML();
}
else
puts("</BODY>\n</HTML>");
@@ -382,3 +379,8 @@ main(int argc, /* I - Number of command-line arguments */
return (0);
}
/*
* End of "$Id$".
*/
+34 -66
Ver Arquivo
@@ -1,10 +1,32 @@
/*
* HTML support functions for CUPS.
* "$Id$"
*
* Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* HTML support functions for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* 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.
*/
/*
@@ -14,14 +36,6 @@
#include "cgi-private.h"
/*
* Local globals...
*/
static const char *cgi_multipart = NULL;
/* Multipart separator, if any */
/*
* Local functions...
*/
@@ -45,22 +59,7 @@ cgiEndHTML(void)
/*
* 'cgiEndMultipart()' - End the delivery of a multipart web page.
*/
void
cgiEndMultipart(void)
{
if (cgi_multipart)
{
printf("\n%s--\n", cgi_multipart);
fflush(stdout);
}
}
/*
* 'cgiFormEncode()' - Encode a string as a form variable.
* 'cgiFormEncode()' - Encode a string as a form variable...
*/
char * /* O - Destination string */
@@ -87,7 +86,7 @@ cgiFormEncode(char *dst, /* I - Destination string */
for (dstptr = dst; *src && dstptr < dstend;)
{
switch (*src)
{
{
case ' ' :
/*
* Encode spaces with a "+"...
@@ -154,9 +153,6 @@ cgiStartHTML(const char *title) /* I - Title of page */
* Tell the client to expect UTF-8 encoded HTML...
*/
if (cgi_multipart)
puts(cgi_multipart);
puts("Content-Type: text/html;charset=utf-8\n");
/*
@@ -170,38 +166,6 @@ cgiStartHTML(const char *title) /* I - Title of page */
}
/*
* 'cgiStartMultipart()' - Start a multipart delivery of a web page.
*/
void
cgiStartMultipart(void)
{
puts("MIME-Version: 1.0\n"
"Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
fflush(stdout);
cgi_multipart = "--CUPS-MULTIPART";
}
/*
* 'cgiSupportsMultipart()' - Does the browser support multi-part documents?
*/
int /* O - 1 if multi-part supported, 0 otherwise */
cgiSupportsMultipart(void)
{
/*
* Too many bug reports for browsers that don't support it, and too much pain
* to whitelist known-good browsers, so for now we just punt on multi-part
* support... :(
*/
return (0);
}
/*
* 'cgi_null_passwd()' - Return a NULL password for authentication.
*/
@@ -211,8 +175,12 @@ 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)");
fprintf(stderr, "DEBUG: cgi_null_passwd(prompt=\"%s\") called!\n", prompt);
return (NULL);
}
/*
* End of "$Id$".
*/
+211 -458
Ver Arquivo
@@ -1,10 +1,39 @@
/*
* CGI <-> IPP variable routines for CUPS.
* "$Id$"
*
* Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
* CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* cgiGetAttributes() - Get the list of attributes that are needed
* by the template file.
* cgiGetIPPObjects() - Get the objects in an IPP response.
* cgiMoveJobs() - Move one or more jobs.
* cgiPrintTestPage() - Print a test page.
* cgiRewriteURL() - Rewrite a printer URI into a web browser URL...
* cgiSetIPPObjectVars() - Set CGI variables from an IPP object.
* cgiSetIPPVars() - Set CGI variables from an IPP response.
* cgiShowIPPError() - Show the last IPP error message.
* cgiShowJobs() - Show print jobs.
* cgiText() - Return localized text.
*/
/*
@@ -44,7 +73,7 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
{
for (i = 0; lang[i] && i < 15; i ++)
if (isalnum(lang[i] & 255))
locale[i] = (char)tolower(lang[i]);
locale[i] = tolower(lang[i]);
else
locale[i] = '_';
@@ -81,19 +110,18 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
*/
num_attrs = 0;
attrs[0] = NULL; /* Eliminate compiler warning */
while ((ch = getc(in)) != EOF)
if (ch == '\\')
getc(in);
else if (ch == '{' && num_attrs < (int)(sizeof(attrs) / sizeof(attrs[0])))
else if (ch == '{' && num_attrs < (sizeof(attrs) / sizeof(attrs[0])))
{
/*
* Grab the name...
*/
for (nameptr = name; (ch = getc(in)) != EOF;)
if (strchr("}]<>=!~ \t\n", ch))
if (strchr("}]<>=! \t\n", ch))
break;
else if (nameptr > name && ch == '?')
break;
@@ -102,13 +130,13 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
if (ch == '_')
*nameptr++ = '-';
else
*nameptr++ = (char)ch;
*nameptr++ = ch;
}
*nameptr = '\0';
if (!strncmp(name, "printer_state_history", 21))
strlcpy(name, "printer_state_history", sizeof(name));
strcpy(name, "printer_state_history");
/*
* Possibly add it to the list of attributes...
@@ -138,8 +166,6 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
for (i = 0; i < num_attrs; i ++)
free(attrs[i]);
}
fclose(in);
}
@@ -216,9 +242,6 @@ cgiGetIPPObjects(ipp_t *response, /* I - IPP response */
break;
case IPP_TAG_INTEGER :
if (!strncmp(ippGetName(attr), "time-at-", 8))
break; /* Ignore time-at-xxx */
for (i = 0; !add && i < attr->num_values; i ++)
{
char buf[255]; /* Number buffer */
@@ -267,14 +290,11 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
/*
* Make sure we have a username...
* See who is logged in...
*/
if ((user = getenv("REMOTE_USER")) == NULL)
{
puts("Status: 401\n");
exit(0);
}
user = "guest";
/*
* See if the user has already selected a new destination...
@@ -319,7 +339,7 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
NULL, job_uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "job-printer-uri");
if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
if ((attr = ippFindAttribute(response, "job-printer-uri",
@@ -344,7 +364,7 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
*/
cgiStartHTML(cgiText(_("Move Job")));
cgiShowIPPError(_("Unable to find destination for job"));
cgiShowIPPError(_("Unable to find destination for job!"));
cgiEndHTML();
return;
}
@@ -359,14 +379,8 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "printer-uri-supported");
if (user)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type",
CUPS_PRINTER_LOCAL);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type-mask",
CUPS_PRINTER_SCANNER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
@@ -386,7 +400,7 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
* If the name is not the same as the current destination, add it!
*/
if (_cups_strcasecmp(name, dest))
if (strcasecmp(name, dest))
{
cgiSetArray("JOB_PRINTER_URI", i, attr->values[0].string.text);
cgiSetArray("JOB_PRINTER_NAME", i, name);
@@ -406,18 +420,7 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
else
cgiStartHTML(cgiText(_("Move All Jobs")));
if (cgiGetSize("JOB_PRINTER_NAME") > 0)
cgiCopyTemplateLang("job-move.tmpl");
else
{
if (job_id)
cgiSetVariable("MESSAGE", cgiText(_("Unable to move job")));
else
cgiSetVariable("MESSAGE", cgiText(_("Unable to move jobs")));
cgiSetVariable("ERROR", cgiText(_("No destinations added.")));
cgiCopyTemplateLang("error.tmpl");
}
cgiCopyTemplateLang("job-move.tmpl");
}
else
{
@@ -477,19 +480,10 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
if (cupsLastError() <= IPP_OK_CONFLICT)
{
const char *path = strstr(job_printer_uri, "/printers/");
if (!path)
{
path = strstr(job_printer_uri, "/classes/");
cgiSetVariable("IS_CLASS", "YES");
}
if (path)
{
cgiFormEncode(uri, path, sizeof(uri));
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
}
cgiRewriteURL(job_printer_uri, resource, sizeof(resource), NULL);
cgiFormEncode(uri, resource, sizeof(uri));
snprintf(refresh, sizeof(refresh), "2;%s", uri);
cgiSetVariable("refresh_page", refresh);
}
if (job_id)
@@ -515,168 +509,6 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */
}
/*
* 'cgiPrintCommand()' - Print a CUPS command job.
*/
void
cgiPrintCommand(http_t *http, /* I - Connection to server */
const char *dest, /* I - Destination printer */
const char *command, /* I - Command to send */
const char *title) /* I - Page/job title */
{
int job_id; /* Command file job */
char uri[HTTP_MAX_URI], /* Job URI */
resource[1024], /* Printer resource path */
refresh[1024], /* Refresh URL */
command_file[1024]; /* Command "file" */
http_status_t status; /* Document status */
cups_option_t hold_option; /* job-hold-until option */
const char *user; /* User name */
ipp_t *request, /* Get-Job-Attributes request */
*response; /* Get-Job-Attributes response */
ipp_attribute_t *attr; /* Current job attribute */
static const char * const job_attrs[] =/* Job attributes we want */
{
"job-state",
"job-printer-state-message"
};
/*
* Create the CUPS command file...
*/
snprintf(command_file, sizeof(command_file), "#CUPS-COMMAND\n%s\n", command);
/*
* Show status...
*/
if (cgiSupportsMultipart())
{
cgiStartMultipart();
cgiStartHTML(title);
cgiCopyTemplateLang("command.tmpl");
cgiEndHTML();
fflush(stdout);
}
/*
* Send the command file job...
*/
hold_option.name = "job-hold-until";
hold_option.value = "no-hold";
if ((user = getenv("REMOTE_USER")) != NULL)
cupsSetUser(user);
else
cupsSetUser("anonymous");
if ((job_id = cupsCreateJob(http, dest, title,
1, &hold_option)) < 1)
{
cgiSetVariable("MESSAGE", cgiText(_("Unable to send command to printer driver")));
cgiSetVariable("ERROR", cupsLastErrorString());
cgiStartHTML(title);
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
if (cgiSupportsMultipart())
cgiEndMultipart();
return;
}
status = cupsStartDocument(http, dest, job_id, NULL, CUPS_FORMAT_COMMAND, 1);
if (status == HTTP_CONTINUE)
status = cupsWriteRequestData(http, command_file,
strlen(command_file));
if (status == HTTP_CONTINUE)
cupsFinishDocument(http, dest);
if (cupsLastError() >= IPP_REDIRECTION_OTHER_SITE)
{
cgiSetVariable("MESSAGE", cgiText(_("Unable to send command to printer driver")));
cgiSetVariable("ERROR", cupsLastErrorString());
cgiStartHTML(title);
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
if (cgiSupportsMultipart())
cgiEndMultipart();
cupsCancelJob(dest, job_id);
return;
}
/*
* Wait for the job to complete...
*/
if (cgiSupportsMultipart())
{
for (;;)
{
/*
* Get the current job state...
*/
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
NULL, uri);
if (user)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", 2, NULL, job_attrs);
if ((response = cupsDoRequest(http, request, "/")) != NULL)
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
attr = ippFindAttribute(response, "job-state", IPP_TAG_ENUM);
if (!attr || attr->values[0].integer >= IPP_JOB_STOPPED ||
attr->values[0].integer == IPP_JOB_HELD)
{
ippDelete(response);
break;
}
/*
* Job not complete, so update the status...
*/
ippDelete(response);
cgiStartHTML(title);
cgiCopyTemplateLang("command.tmpl");
cgiEndHTML();
fflush(stdout);
sleep(5);
}
}
/*
* Send the final page that reloads the printer's page...
*/
snprintf(resource, sizeof(resource), "/printers/%s", dest);
cgiFormEncode(uri, resource, sizeof(uri));
snprintf(refresh, sizeof(refresh), "5;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
cgiStartHTML(title);
cgiCopyTemplateLang("command.tmpl");
cgiEndHTML();
if (cgiSupportsMultipart())
cgiEndMultipart();
}
/*
* 'cgiPrintTestPage()' - Print a test page.
*/
@@ -699,7 +531,8 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */
* See who is logged in...
*/
user = getenv("REMOTE_USER");
if ((user = getenv("REMOTE_USER")) == NULL)
user = "guest";
/*
* Locate the test page file...
@@ -708,7 +541,7 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */
if ((datadir = getenv("CUPS_DATADIR")) == NULL)
datadir = CUPS_DATADIR;
snprintf(filename, sizeof(filename), "%s/data/testprint", datadir);
snprintf(filename, sizeof(filename), "%s/data/testprint.ps", datadir);
/*
* Point to the printer/class...
@@ -729,6 +562,7 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */
* attributes-natural-language
* printer-uri
* requesting-user-name
* document-format
*/
request = ippNewRequest(IPP_PRINT_JOB);
@@ -736,13 +570,15 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
if (user)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
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...
*/
@@ -762,19 +598,14 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */
*/
cgiFormEncode(uri, resource, sizeof(uri));
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
snprintf(refresh, sizeof(refresh), "2;%s", uri);
cgiSetVariable("refresh_page", refresh);
}
else if (cupsLastError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
cgiStartHTML(cgiText(_("Print Test Page")));
if (cupsLastError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to print test page"));
cgiShowIPPError(_("Unable to print test page:"));
else
{
cgiSetVariable("PRINTER_NAME", dest);
@@ -796,7 +627,7 @@ cgiRewriteURL(const char *uri, /* I - Current URI */
int urlsize, /* I - Size of URL buffer */
const char *newresource) /* I - Replacement resource */
{
char scheme[HTTP_MAX_URI],
char method[HTTP_MAX_URI],
userpass[HTTP_MAX_URI],
hostname[HTTP_MAX_URI],
rawresource[HTTP_MAX_URI],
@@ -843,13 +674,13 @@ cgiRewriteURL(const char *uri, /* I - Current URI */
* Convert the URI to a URL...
*/
httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass,
httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
sizeof(userpass), hostname, sizeof(hostname), &port,
rawresource, sizeof(rawresource));
if (!strcmp(scheme, "ipp") ||
!strcmp(scheme, "http") ||
!strcmp(scheme, "https"))
if (!strcmp(method, "ipp") ||
!strcmp(method, "http") ||
!strcmp(method, "https"))
{
if (newresource)
{
@@ -888,18 +719,16 @@ cgiRewriteURL(const char *uri, /* I - Current URI */
* Map local access to a local URI...
*/
if (!_cups_strcasecmp(hostname, "127.0.0.1") ||
!_cups_strcasecmp(hostname, "[::1]") ||
!_cups_strcasecmp(hostname, "localhost") ||
!_cups_strncasecmp(hostname, "localhost.", 10) ||
!_cups_strcasecmp(hostname, server) ||
!_cups_strcasecmp(hostname, servername))
if (!strcasecmp(hostname, "localhost") ||
!strncasecmp(hostname, "localhost.", 10) ||
!strcasecmp(hostname, server) ||
!strcasecmp(hostname, servername))
{
/*
* Make URI relative to the current server...
*/
strlcpy(url, resource, (size_t)urlsize);
strlcpy(url, resource, urlsize);
}
else
{
@@ -908,13 +737,17 @@ cgiRewriteURL(const char *uri, /* I - Current URI */
*/
if (userpass[0])
snprintf(url, (size_t)urlsize, "%s://%s@%s:%d%s", ishttps ? "https" : "http", userpass, hostname, port, resource);
snprintf(url, urlsize, "%s://%s@%s:%d%s",
ishttps ? "https" : "http",
userpass, hostname, port, resource);
else
snprintf(url, (size_t)urlsize, "%s://%s:%d%s", ishttps ? "https" : "http", hostname, port, resource);
snprintf(url, urlsize, "%s://%s:%d%s",
ishttps ? "https" : "http",
hostname, port, resource);
}
}
else
strlcpy(url, uri, (size_t)urlsize);
strlcpy(url, uri, urlsize);
return (url);
}
@@ -936,11 +769,12 @@ cgiSetIPPObjectVars(
*nameptr, /* Pointer into name */
value[16384], /* Value(s) */
*valptr; /* Pointer into value */
struct tm *date; /* Date information */
fprintf(stderr, "DEBUG2: cgiSetIPPObjectVars(obj=%p, prefix=\"%s\", "
"element=%d)\n",
obj, prefix ? prefix : "(null)", element);
obj, prefix, element);
/*
* Set common CGI template variables...
@@ -993,144 +827,6 @@ cgiSetIPPObjectVars(
cgiSetArray("job_printer_name", element, valptr);
}
/*
* Localize event names in "notify_events" variable...
*/
if (!strcmp(name, "notify_events"))
{
size_t remaining; /* Remaining bytes in buffer */
value[0] = '\0';
valptr = value;
for (i = 0; i < attr->num_values; i ++)
{
if (valptr >= (value + sizeof(value) - 3))
break;
if (i)
{
*valptr++ = ',';
*valptr++ = ' ';
}
remaining = sizeof(value) - (size_t)(valptr - value);
if (!strcmp(attr->values[i].string.text, "printer-stopped"))
strlcpy(valptr, _("Printer Paused"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-added"))
strlcpy(valptr, _("Printer Added"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-modified"))
strlcpy(valptr, _("Printer Modified"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-deleted"))
strlcpy(valptr, _("Printer Deleted"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-created"))
strlcpy(valptr, _("Job Created"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-completed"))
strlcpy(valptr, _("Job Completed"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-stopped"))
strlcpy(valptr, _("Job Stopped"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-config-changed"))
strlcpy(valptr, _("Job Options Changed"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-restarted"))
strlcpy(valptr, _("Server Restarted"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-started"))
strlcpy(valptr, _("Server Started"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-stopped"))
strlcpy(valptr, _("Server Stopped"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-audit"))
strlcpy(valptr, _("Server Security Auditing"), remaining);
else
strlcpy(valptr, attr->values[i].string.text, remaining);
valptr += strlen(valptr);
}
cgiSetArray("notify_events", element, value);
continue;
}
/*
* Add "notify_printer_name" variable if we have a "notify_printer_uri"
* attribute...
*/
if (!strcmp(name, "notify_printer_uri"))
{
if ((valptr = strrchr(attr->values[0].string.text, '/')) == NULL)
valptr = "unknown";
else
valptr ++;
cgiSetArray("notify_printer_name", element, valptr);
}
/*
* Add "notify_recipient_name" variable if we have a "notify_recipient_uri"
* attribute, and rewrite recipient URI...
*/
if (!strcmp(name, "notify_recipient_uri"))
{
char uri[1024], /* New URI */
scheme[32], /* Scheme portion of URI */
userpass[256], /* Username/password portion of URI */
host[1024], /* Hostname portion of URI */
resource[1024], /* Resource portion of URI */
*options; /* Options in URI */
int port; /* Port number */
httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text,
scheme, sizeof(scheme), userpass, sizeof(userpass),
host, sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(scheme, "rss"))
{
/*
* RSS notification...
*/
if ((options = strchr(resource, '?')) != NULL)
*options = '\0';
if (host[0])
{
/*
* Link to remote feed...
*/
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), "http",
userpass, host, port, resource);
strlcpy(name, uri, sizeof(name));
}
else
{
/*
* Link to local feed...
*/
snprintf(uri, sizeof(uri), "/rss%s", resource);
strlcpy(name, resource + 1, sizeof(name));
}
}
else
{
/*
* Other...
*/
strlcpy(uri, attr->values[0].string.text, sizeof(uri));
strlcpy(name, resource, sizeof(name));
}
cgiSetArray("notify_recipient_uri", element, uri);
cgiSetArray("notify_recipient_name", element, name);
continue;
}
/*
* Add "admin_uri" variable if we have a "printer_uri_supported"
* attribute...
@@ -1154,7 +850,7 @@ cgiSetIPPObjectVars(
for (i = 0; i < attr->num_values; i ++)
{
if (i)
strlcat(valptr, ", ", sizeof(value) - (size_t)(valptr - value));
strlcat(valptr, ",", sizeof(value) - (valptr - value));
valptr += strlen(valptr);
@@ -1163,32 +859,40 @@ cgiSetIPPObjectVars(
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
if (strncmp(name, "time_at_", 8) == 0)
_cupsStrDate(valptr, sizeof(value) - (size_t)(valptr - value), (time_t)ippGetInteger(attr, i));
{
time_t t; /* Temporary time value */
t = (time_t)attr->values[i].integer;
date = localtime(&t);
strftime(valptr, sizeof(value) - (valptr - value), "%c", date);
}
else
snprintf(valptr, sizeof(value) - (size_t)(valptr - value), "%d", ippGetInteger(attr, i));
snprintf(valptr, sizeof(value) - (valptr - value),
"%d", attr->values[i].integer);
break;
case IPP_TAG_BOOLEAN :
snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
snprintf(valptr, sizeof(value) - (valptr - value),
"%d", attr->values[i].boolean);
break;
case IPP_TAG_NOVALUE :
strlcat(valptr, "novalue", sizeof(value) - (size_t)(valptr - value));
strlcat(valptr, "novalue", sizeof(value) - (valptr - value));
break;
case IPP_TAG_RANGE :
snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
snprintf(valptr, sizeof(value) - (valptr - value),
"%d-%d", attr->values[i].range.lower,
attr->values[i].range.upper);
break;
case IPP_TAG_RESOLUTION :
snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
snprintf(valptr, sizeof(value) - (valptr - value),
"%dx%d%s", attr->values[i].resolution.xres,
attr->values[i].resolution.yres,
attr->values[i].resolution.units == IPP_RES_PER_INCH ?
"dpi" : "dpcm");
"dpi" : "dpc");
break;
case IPP_TAG_URI :
@@ -1199,7 +903,21 @@ cgiSetIPPObjectVars(
* Rewrite URIs...
*/
cgiRewriteURL(attr->values[i].string.text, valptr, (int)(sizeof(value) - (size_t)(valptr - value)), NULL);
if (!strcmp(name, "member_uris"))
{
char url[1024]; /* URL for class member... */
cgiRewriteURL(attr->values[i].string.text, url,
sizeof(url), NULL);
snprintf(valptr, sizeof(value) - (valptr - value),
"<A HREF=\"%s\">%s</A>", url,
strrchr(url, '/') + 1);
}
else
cgiRewriteURL(attr->values[i].string.text, valptr,
sizeof(value) - (valptr - value), NULL);
break;
}
@@ -1211,7 +929,7 @@ cgiSetIPPObjectVars(
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
strlcat(valptr, attr->values[i].string.text,
sizeof(value) - (size_t)(valptr - value));
sizeof(value) - (valptr - value));
break;
case IPP_TAG_BEGIN_COLLECTION :
@@ -1259,9 +977,7 @@ cgiSetIPPVars(ipp_t *response, /* I - Response data to be copied... */
fprintf(stderr, "DEBUG2: cgiSetIPPVars(response=%p, filter_name=\"%s\", "
"filter_value=\"%s\", prefix=\"%s\", parent_el=%d)\n",
response, filter_name ? filter_name : "(null)",
filter_value ? filter_value : "(null)",
prefix ? prefix : "(null)", parent_el);
response, filter_name, filter_value, prefix, parent_el);
/*
* Set common CGI template variables...
@@ -1302,7 +1018,7 @@ cgiSetIPPVars(ipp_t *response, /* I - Response data to be copied... */
(filter->value_tag >= IPP_TAG_TEXTLANG &&
filter->value_tag <= IPP_TAG_MIMETYPE)) &&
filter->values[0].string.text != NULL &&
!_cups_strcasecmp(filter->values[0].string.text, filter_value))
!strcasecmp(filter->values[0].string.text, filter_value))
break;
if (!filter)
@@ -1319,9 +1035,9 @@ cgiSetIPPVars(ipp_t *response, /* I - Response data to be copied... */
attr = cgiSetIPPObjectVars(attr, prefix, element);
}
fprintf(stderr, "DEBUG2: Returning %d from cgiSetIPPVars()...\n", element);
fprintf(stderr, "DEBUG2: Returing %d from cgiSetIPPVars()...\n", element + 1);
return (element);
return (element + 1);
}
@@ -1354,14 +1070,14 @@ cgiShowJobs(http_t *http, /* I - Connection to server */
*response; /* IPP response */
cups_array_t *jobs; /* Array of job objects */
ipp_attribute_t *job; /* Job object */
int first, /* First job to show */
int ascending, /* Order of jobs (0 = descending) */
first, /* First job to show */
count; /* Number of jobs */
const char *var, /* Form variable */
*query, /* Query string */
*section; /* Section in web interface */
const char *var; /* Form variable */
void *search; /* Search data */
char url[1024], /* Printer URI */
val[1024]; /* Form variable */
char url[1024], /* URL for prev/next/this */
*urlptr, /* Position in URL */
*urlend; /* End of URL */
/*
@@ -1383,24 +1099,13 @@ cgiShowJobs(http_t *http, /* I - Connection to server */
NULL, url);
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
"ipp://localhost/");
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
"ipp://localhost/jobs");
if ((which_jobs = cgiGetVariable("which_jobs")) != NULL && *which_jobs)
if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
NULL, which_jobs);
if ((var = cgiGetVariable("FIRST")) != NULL)
{
if ((first = atoi(var)) < 0)
first = 0;
}
else
first = 0;
if (first > 0)
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "first-index", first + 1);
cgiGetAttributes(request, "jobs.tmpl");
/*
@@ -1413,17 +1118,13 @@ cgiShowJobs(http_t *http, /* I - Connection to server */
* Get a list of matching job objects.
*/
if ((query = cgiGetVariable("QUERY")) != NULL &&
!cgiGetVariable("CLEAR"))
search = cgiCompileSearch(query);
if ((var = cgiGetVariable("QUERY")) != NULL)
search = cgiCompileSearch(var);
else
{
query = NULL;
search = NULL;
}
jobs = cgiGetIPPObjects(response, search);
count = cupsArrayCount(jobs) + first;
count = cupsArrayCount(jobs);
if (search)
cgiFreeSearch(search);
@@ -1432,57 +1133,104 @@ cgiShowJobs(http_t *http, /* I - Connection to server */
* Figure out which jobs to display...
*/
section = cgiGetVariable("SECTION");
if ((var = cgiGetVariable("FIRST")) != NULL)
first = atoi(var);
else
first = 0;
cgiClearVariables();
if (first >= count)
first = count - CUPS_PAGE_MAX;
if (query)
cgiSetVariable("QUERY", query);
first = (first / CUPS_PAGE_MAX) * CUPS_PAGE_MAX;
cgiSetVariable("SECTION", section);
if (first < 0)
first = 0;
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);
sprintf(url, "%d", count);
cgiSetVariable("TOTAL", url);
if (which_jobs)
cgiSetVariable("WHICH_JOBS", which_jobs);
if ((var = cgiGetVariable("ORDER")) != NULL)
ascending = !strcasecmp(var, "asc");
else
{
ascending = !which_jobs || !strcasecmp(which_jobs, "not-completed");
cgiSetVariable("ORDER", ascending ? "asc" : "dec");
}
for (i = 0, job = (ipp_attribute_t *)cupsArrayFirst(jobs);
i < CUPS_PAGE_MAX && job;
i ++, job = (ipp_attribute_t *)cupsArrayNext(jobs))
cgiSetIPPObjectVars(job, NULL, i);
if (ascending)
{
for (i = 0, job = (ipp_attribute_t *)cupsArrayIndex(jobs, first);
i < CUPS_PAGE_MAX && job;
i ++, job = (ipp_attribute_t *)cupsArrayNext(jobs))
cgiSetIPPObjectVars(job, NULL, i);
}
else
{
for (i = 0, job = (ipp_attribute_t *)cupsArrayIndex(jobs, count - first - 1);
i < CUPS_PAGE_MAX && job;
i ++, job = (ipp_attribute_t *)cupsArrayPrev(jobs))
cgiSetIPPObjectVars(job, NULL, i);
}
/*
* Save navigation URLs...
*/
if (dest)
urlend = url + sizeof(url);
if ((var = cgiGetVariable("QUERY")) != NULL)
{
snprintf(val, sizeof(val), "/%s/%s", section, dest);
cgiSetVariable("PRINTER_NAME", dest);
cgiSetVariable("PRINTER_URI_SUPPORTED", val);
if (dest)
snprintf(url, sizeof(url), "/%s/%s?QUERY=", cgiGetVariable("SECTION"),
dest);
else
strlcpy(url, "/jobs/?QUERY=", sizeof(url));
urlptr = url + strlen(url);
cgiFormEncode(urlptr, var, urlend - urlptr);
urlptr += strlen(urlptr);
strlcpy(urlptr, "&", urlend - urlptr);
urlptr += strlen(urlptr);
}
else
strlcpy(val, "/jobs/", sizeof(val));
{
if (dest)
snprintf(url, sizeof(url), "/%s/%s?", cgiGetVariable("SECTION"), dest);
else
strlcpy(url, "/jobs/?", sizeof(url));
cgiSetVariable("THISURL", val);
urlptr = url + strlen(url);
}
if (which_jobs)
{
strlcpy(urlptr, "WHICH_JOBS=", urlend - urlptr);
urlptr += strlen(urlptr);
cgiFormEncode(urlptr, which_jobs, urlend - urlptr);
urlptr += strlen(urlptr);
strlcpy(urlptr, "&", urlend - urlptr);
urlptr += strlen(urlptr);
}
snprintf(urlptr, urlend - urlptr, "FIRST=%d", first);
cgiSetVariable("THISURL", url);
if (first > 0)
{
sprintf(val, "%d", first - CUPS_PAGE_MAX);
cgiSetVariable("PREV", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("PREVURL", url);
}
if ((first + CUPS_PAGE_MAX) < count)
{
sprintf(val, "%d", first + CUPS_PAGE_MAX);
cgiSetVariable("NEXT", val);
}
if (count > CUPS_PAGE_MAX)
{
snprintf(val, sizeof(val), "%d", CUPS_PAGE_MAX * (count / CUPS_PAGE_MAX));
cgiSetVariable("LAST", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("NEXTURL", url);
}
/*
@@ -1496,12 +1244,12 @@ cgiShowJobs(http_t *http, /* I - Connection to server */
cgiCopyTemplateLang("jobs-header.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
cgiCopyTemplateLang("jobs.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
cupsArrayDelete(jobs);
@@ -1526,3 +1274,8 @@ cgiText(const char *message) /* I - Message */
return (_cupsLangString(language, message));
}
/*
* End of "$Id$".
*/
+33 -27
Ver Arquivo
@@ -1,10 +1,30 @@
/*
* Job status CGI for CUPS.
* "$Id$"
*
* Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* Job status CGI for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Main entry for CGI.
* do_job_op() - Do a job operation.
*/
/*
@@ -26,7 +46,8 @@ static void do_job_op(http_t *http, int job_id, ipp_op_t op);
*/
int /* O - Exit status */
main(void)
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
http_t *http; /* Connection to the server */
const char *op; /* Operation name */
@@ -45,7 +66,6 @@ main(void)
*/
cgiSetVariable("SECTION", "jobs");
cgiSetVariable("REFRESH_PAGE", "");
/*
* Connect to the HTTP server...
@@ -66,7 +86,7 @@ main(void)
* Do the operation...
*/
if ((op = cgiGetVariable("OP")) != NULL && job_id > 0 && cgiIsPOST())
if ((op = cgiGetVariable("OP")) != NULL && job_id > 0)
{
/*
* Do the operation...
@@ -161,29 +181,10 @@ do_job_op(http_t *http, /* I - HTTP connection */
ippDelete(cupsDoRequest(http, request, "/jobs"));
if (cupsLastError() <= IPP_OK_CONFLICT && getenv("HTTP_REFERER"))
{
/*
* Redirect successful updates back to the parent page...
*/
char url[1024]; /* Encoded URL */
strlcpy(url, "5;URL=", sizeof(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"));
cgiShowIPPError(_("Job operation failed:"));
else if (op == IPP_CANCEL_JOB)
cgiCopyTemplateLang("job-cancel.tmpl");
else if (op == IPP_HOLD_JOB)
@@ -195,3 +196,8 @@ do_job_op(http_t *http, /* I - HTTP connection */
cgiEndHTML();
}
/*
* End of "$Id$".
*/
-42
Ver Arquivo
@@ -1,42 +0,0 @@
_cgiCheckVariables
_cgiClearVariables
_cgiCompileSearch
_cgiCopyTemplateFile
_cgiCopyTemplateLang
_cgiDoSearch
_cgiEndHTML
_cgiEndMultipart
_cgiFormEncode
_cgiFreeSearch
_cgiGetArray
_cgiGetAttributes
_cgiGetCookie
_cgiGetFile
_cgiGetIPPObjects
_cgiGetSize
_cgiGetTemplateDir
_cgiGetVariable
_cgiInitialize
_cgiIsPOST
_cgiMoveJobs
_cgiPrintCommand
_cgiPrintTestPage
_cgiRewriteURL
_cgiSetArray
_cgiSetIPPObjectVars
_cgiSetIPPVars
_cgiSetCookie
_cgiSetServerVersion
_cgiSetSize
_cgiSetVariable
_cgiShowIPPError
_cgiShowJobs
_cgiStartHTML
_cgiStartMultipart
_cgiSupportsMultipart
_cgiText
_helpDeleteIndex
_helpFindNode
_helpLoadIndex
_helpSaveIndex
_helpSearchIndex
-465
Ver Arquivo
@@ -1,465 +0,0 @@
/*
* Xcode documentation set generator.
*
* Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*
* Usage:
*
* makedocset directory *.tokens
*/
/*
* Include necessary headers...
*/
#include "cgi-private.h"
#include <errno.h>
/*
* Local structures...
*/
typedef struct _cups_html_s /**** Help file ****/
{
char *path; /* Path to help file */
char *title; /* Title of help file */
} _cups_html_t;
typedef struct _cups_section_s /**** Help section ****/
{
char *name; /* Section name */
cups_array_t *files; /* Files in this section */
} _cups_section_t;
/*
* Local functions...
*/
static int compare_html(_cups_html_t *a, _cups_html_t *b);
static int compare_sections(_cups_section_t *a, _cups_section_t *b);
static int compare_sections_files(_cups_section_t *a, _cups_section_t *b);
static void write_index(const char *path, help_index_t *hi);
static void write_info(const char *path, const char *revision);
static void write_nodes(const char *path, help_index_t *hi);
/*
* 'main()' - Test the help index code.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
char path[1024], /* Path to documentation */
line[1024]; /* Line from file */
help_index_t *hi; /* Help index */
cups_file_t *tokens, /* Tokens.xml file */
*fp; /* Current file */
if (argc < 4)
{
puts("Usage: makedocset directory revision *.tokens");
return (1);
}
/*
* Index the help documents...
*/
snprintf(path, sizeof(path), "%s/Contents/Resources/Documentation", argv[1]);
if ((hi = helpLoadIndex(NULL, path)) == NULL)
{
fputs("makedocset: Unable to index help files!\n", stderr);
return (1);
}
snprintf(path, sizeof(path), "%s/Contents/Resources/Documentation/index.html",
argv[1]);
write_index(path, hi);
snprintf(path, sizeof(path), "%s/Contents/Resources/Nodes.xml", argv[1]);
write_nodes(path, hi);
/*
* Write the Info.plist file...
*/
snprintf(path, sizeof(path), "%s/Contents/Info.plist", argv[1]);
write_info(path, argv[2]);
/*
* Merge the Tokens.xml files...
*/
snprintf(path, sizeof(path), "%s/Contents/Resources/Tokens.xml", argv[1]);
if ((tokens = cupsFileOpen(path, "w")) == NULL)
{
fprintf(stderr, "makedocset: Unable to create \"%s\": %s\n", path,
strerror(errno));
return (1);
}
cupsFilePuts(tokens, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
cupsFilePuts(tokens, "<Tokens version=\"1.0\">\n");
for (i = 3; i < argc; i ++)
{
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
fprintf(stderr, "makedocset: Unable to open \"%s\": %s\n", argv[i],
strerror(errno));
return (1);
}
if (!cupsFileGets(fp, line, sizeof(line)) || strncmp(line, "<?xml ", 6) ||
!cupsFileGets(fp, line, sizeof(line)) || strncmp(line, "<Tokens ", 8))
{
fprintf(stderr, "makedocset: Bad Tokens.xml file \"%s\"!\n", argv[i]);
return (1);
}
while (cupsFileGets(fp, line, sizeof(line)))
{
if (strcmp(line, "</Tokens>"))
cupsFilePrintf(tokens, "%s\n", line);
}
cupsFileClose(fp);
}
cupsFilePuts(tokens, "</Tokens>\n");
cupsFileClose(tokens);
/*
* Return with no errors...
*/
return (0);
}
/*
* 'compare_html()' - Compare the titles of two HTML files.
*/
static int /* O - Result of comparison */
compare_html(_cups_html_t *a, /* I - First file */
_cups_html_t *b) /* I - Second file */
{
return (_cups_strcasecmp(a->title, b->title));
}
/*
* 'compare_sections()' - Compare the names of two help sections.
*/
static int /* O - Result of comparison */
compare_sections(_cups_section_t *a, /* I - First section */
_cups_section_t *b) /* I - Second section */
{
return (_cups_strcasecmp(a->name, b->name));
}
/*
* 'compare_sections_files()' - Compare the number of files and section names.
*/
static int /* O - Result of comparison */
compare_sections_files(
_cups_section_t *a, /* I - First section */
_cups_section_t *b) /* I - Second section */
{
int ret = cupsArrayCount(b->files) - cupsArrayCount(a->files);
if (ret)
return (ret);
else
return (_cups_strcasecmp(a->name, b->name));
}
/*
* 'write_index()' - Write an index file for the CUPS help.
*/
static void
write_index(const char *path, /* I - File to write */
help_index_t *hi) /* I - Index of files */
{
cups_file_t *fp; /* Output file */
help_node_t *node; /* Current help node */
_cups_section_t *section, /* Current section */
key; /* Section search key */
_cups_html_t *html; /* Current HTML file */
cups_array_t *sections, /* Sections in index */
*sections_files,/* Sections sorted by size */
*columns[3]; /* Columns in final HTML file */
int column, /* Current column */
lines[3], /* Number of lines in each column */
min_column, /* Smallest column */
min_lines; /* Smallest number of lines */
/*
* Build an array of sections and their files.
*/
sections = cupsArrayNew((cups_array_func_t)compare_sections, NULL);
for (node = (help_node_t *)cupsArrayFirst(hi->nodes);
node;
node = (help_node_t *)cupsArrayNext(hi->nodes))
{
if (node->anchor)
continue;
key.name = node->section ? node->section : "Miscellaneous";
if ((section = (_cups_section_t *)cupsArrayFind(sections, &key)) == NULL)
{
section = (_cups_section_t *)calloc(1, sizeof(_cups_section_t));
section->name = key.name;
section->files = cupsArrayNew((cups_array_func_t)compare_html, NULL);
cupsArrayAdd(sections, section);
}
html = (_cups_html_t *)calloc(1, sizeof(_cups_html_t));
html->path = node->filename;
html->title = node->text;
cupsArrayAdd(section->files, html);
}
/*
* Build a sorted list of sections based on the number of files in each section
* and the section name...
*/
sections_files = cupsArrayNew((cups_array_func_t)compare_sections_files,
NULL);
for (section = (_cups_section_t *)cupsArrayFirst(sections);
section;
section = (_cups_section_t *)cupsArrayNext(sections))
cupsArrayAdd(sections_files, section);
/*
* Then build three columns to hold everything, trying to balance the number of
* lines in each column...
*/
for (column = 0; column < 3; column ++)
{
columns[column] = cupsArrayNew((cups_array_func_t)compare_sections, NULL);
lines[column] = 0;
}
for (section = (_cups_section_t *)cupsArrayFirst(sections_files);
section;
section = (_cups_section_t *)cupsArrayNext(sections_files))
{
for (min_column = 0, min_lines = lines[0], column = 1;
column < 3;
column ++)
{
if (lines[column] < min_lines)
{
min_column = column;
min_lines = lines[column];
}
}
cupsArrayAdd(columns[min_column], section);
lines[min_column] += cupsArrayCount(section->files) + 2;
}
/*
* Write the HTML file...
*/
if ((fp = cupsFileOpen(path, "w")) == NULL)
{
fprintf(stderr, "makedocset: Unable to create %s: %s\n", path,
strerror(errno));
exit(1);
}
cupsFilePuts(fp, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
"Transitional//EN\" "
"\"http://www.w3.org/TR/html4/loose.dtd\">\n"
"<html>\n"
"<head>\n"
"<title>CUPS Documentation</title>\n"
"<link rel='stylesheet' type='text/css' "
"href='cups-printable.css'>\n"
"</head>\n"
"<body>\n"
"<h1 class='title'>CUPS Documentation</h1>\n"
"<table width='100%' summary=''>\n"
"<tr>\n");
for (column = 0; column < 3; column ++)
{
if (column)
cupsFilePuts(fp, "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n");
cupsFilePuts(fp, "<td valign='top' width='33%'>");
for (section = (_cups_section_t *)cupsArrayFirst(columns[column]);
section;
section = (_cups_section_t *)cupsArrayNext(columns[column]))
{
cupsFilePrintf(fp, "<h2 class='title'>%s</h2>\n", section->name);
for (html = (_cups_html_t *)cupsArrayFirst(section->files);
html;
html = (_cups_html_t *)cupsArrayNext(section->files))
cupsFilePrintf(fp, "<p class='compact'><a href='%s'>%s</a></p>\n",
html->path, html->title);
}
cupsFilePuts(fp, "</td>\n");
}
cupsFilePuts(fp, "</tr>\n"
"</table>\n"
"</body>\n"
"</html>\n");
cupsFileClose(fp);
}
/*
* 'write_info()' - Write the Info.plist file.
*/
static void
write_info(const char *path, /* I - File to write */
const char *revision) /* I - Subversion revision number */
{
cups_file_t *fp; /* File */
if ((fp = cupsFileOpen(path, "w")) == NULL)
{
fprintf(stderr, "makedocset: Unable to create %s: %s\n", path,
strerror(errno));
exit(1);
}
cupsFilePrintf(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
"<plist version=\"1.0\">\n"
"<dict>\n"
"\t<key>CFBundleIdentifier</key>\n"
"\t<string>org.cups.docset</string>\n"
"\t<key>CFBundleName</key>\n"
"\t<string>CUPS Documentation</string>\n"
"\t<key>CFBundleVersion</key>\n"
"\t<string>%d.%d.%s</string>\n"
"\t<key>CFBundleShortVersionString</key>\n"
"\t<string>%d.%d.%d</string>\n"
"\t<key>DocSetFeedName</key>\n"
"\t<string>cups.org</string>\n"
"\t<key>DocSetFeedURL</key>\n"
"\t<string>http://www.cups.org/org.cups.docset.atom"
"</string>\n"
"\t<key>DocSetPublisherIdentifier</key>\n"
"\t<string>org.cups</string>\n"
"\t<key>DocSetPublisherName</key>\n"
"\t<string>CUPS</string>\n"
"</dict>\n"
"</plist>\n",
CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR, revision,
CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR, CUPS_VERSION_PATCH);
cupsFileClose(fp);
}
/*
* 'write_nodes()' - Write the Nodes.xml file.
*/
static void
write_nodes(const char *path, /* I - File to write */
help_index_t *hi) /* I - Index of files */
{
cups_file_t *fp; /* Output file */
int id; /* Current node ID */
help_node_t *node; /* Current help node */
int subnodes; /* Currently in Subnodes for file? */
int needclose; /* Need to close the current node? */
if ((fp = cupsFileOpen(path, "w")) == NULL)
{
fprintf(stderr, "makedocset: Unable to create %s: %s\n", path,
strerror(errno));
exit(1);
}
cupsFilePuts(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<DocSetNodes version=\"1.0\">\n"
"<TOC>\n"
"<Node id=\"0\">\n"
"<Name>CUPS Documentation</Name>\n"
"<Path>Documentation/index.html</Path>\n"
"</Node>\n");
for (node = (help_node_t *)cupsArrayFirst(hi->nodes), id = 1, subnodes = 0,
needclose = 0;
node;
node = (help_node_t *)cupsArrayNext(hi->nodes), id ++)
{
if (node->anchor)
{
if (!subnodes)
{
cupsFilePuts(fp, "<Subnodes>\n");
subnodes = 1;
}
cupsFilePrintf(fp, "<Node id=\"%d\">\n"
"<Path>Documentation/%s</Path>\n"
"<Anchor>%s</Anchor>\n"
"<Name>%s</Name>\n"
"</Node>\n", id, node->filename, node->anchor,
node->text);
}
else
{
if (subnodes)
{
cupsFilePuts(fp, "</Subnodes>\n");
subnodes = 0;
}
if (needclose)
cupsFilePuts(fp, "</Node>\n");
cupsFilePrintf(fp, "<Node id=\"%d\">\n"
"<Path>Documentation/%s</Path>\n"
"<Name>%s</Name>\n", id, node->filename, node->text);
needclose = 1;
}
}
if (subnodes)
cupsFilePuts(fp, "</Subnodes>\n");
if (needclose)
cupsFilePuts(fp, "</Node>\n");
cupsFilePuts(fp, "</TOC>\n"
"</DocSetNodes>\n");
cupsFileClose(fp);
}
+237 -144
Ver Arquivo
@@ -1,10 +1,32 @@
/*
* Printer status CGI for CUPS.
* "$Id$"
*
* Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* Printer status CGI for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* 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.
*/
/*
@@ -19,10 +41,9 @@
* Local functions...
*/
static void do_printer_op(http_t *http, const char *printer, ipp_op_t op,
const char *title);
static void show_all_printers(http_t *http, const char *username);
static void show_printer(http_t *http, const char *printer);
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);
/*
@@ -30,7 +51,8 @@ static void show_printer(http_t *http, const char *printer);
*/
int /* O - Exit status */
main(void)
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
const char *printer; /* Printer name */
const char *user; /* Username */
@@ -59,7 +81,6 @@ main(void)
*/
cgiSetVariable("SECTION", "printers");
cgiSetVariable("REFRESH_PAGE", "");
/*
* See if we are displaying a printer or all printers...
@@ -71,16 +92,14 @@ main(void)
if (!*printer)
printer = NULL;
if (printer)
cgiSetVariable("PRINTER_NAME", printer);
}
/*
* See who is logged in...
*/
user = getenv("REMOTE_USER");
if ((user = getenv("REMOTE_USER")) == NULL)
user = "guest";
/*
* Connect to the HTTP server...
@@ -92,7 +111,7 @@ main(void)
* Get the default printer...
*/
if (!op || !cgiIsPOST())
if (!op)
{
/*
* Get the default destination...
@@ -132,62 +151,25 @@ main(void)
else
show_printer(http, printer);
}
else if (printer)
{
if (!*op)
{
const char *server_port = getenv("SERVER_PORT");
/* Port number string */
int port = atoi(server_port ? server_port : "0");
/* Port number */
char uri[1024]; /* URL */
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri),
getenv("HTTPS") ? "https" : "http", NULL,
getenv("SERVER_NAME"), port, "/printers/%s", printer);
printf("Location: %s\n\n", uri);
}
else if (!strcmp(op, "start-printer"))
do_printer_op(http, printer, IPP_RESUME_PRINTER,
cgiText(_("Resume Printer")));
else if (!strcmp(op, "stop-printer"))
do_printer_op(http, printer, IPP_PAUSE_PRINTER,
cgiText(_("Pause Printer")));
else if (!strcmp(op, "accept-jobs"))
do_printer_op(http, printer, CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
else if (!strcmp(op, "reject-jobs"))
do_printer_op(http, printer, CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
else if (!strcmp(op, "cancel-jobs"))
do_printer_op(http, printer, IPP_OP_CANCEL_JOBS, cgiText(_("Cancel Jobs")));
else if (!_cups_strcasecmp(op, "print-self-test-page"))
cgiPrintCommand(http, printer, "PrintSelfTestPage",
cgiText(_("Print Self-Test Page")));
else if (!_cups_strcasecmp(op, "clean-print-heads"))
cgiPrintCommand(http, printer, "Clean all",
cgiText(_("Clean Print Heads")));
else if (!_cups_strcasecmp(op, "print-test-page"))
cgiPrintTestPage(http, printer);
else if (!_cups_strcasecmp(op, "move-jobs"))
cgiMoveJobs(http, printer, 0);
else
{
/*
* Unknown/bad operation...
*/
cgiStartHTML(printer);
cgiCopyTemplateLang("error-op.tmpl");
cgiEndHTML();
}
}
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
{
/*
* Unknown/bad operation...
*/
cgiStartHTML(cgiText(_("Printers")));
if (printer)
cgiStartHTML(printer);
else
cgiStartHTML(cgiText(_("Printers")));
cgiCopyTemplateLang("error-op.tmpl");
cgiEndHTML();
}
@@ -207,80 +189,117 @@ main(void)
/*
* 'do_printer_op()' - Do a printer operation.
* 'print_command()' - Send a print command to the printer.
*/
static void
do_printer_op(http_t *http, /* I - HTTP connection */
const char *printer, /* I - Printer name */
ipp_op_t op, /* I - Operation to perform */
const char *title) /* I - Title of page */
void
print_command(http_t *http, /* I - Connection to server */
const char *printer, /* I - Printer */
const char *command) /* I - Command to send */
{
ipp_t *request; /* IPP request */
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[HTTP_MAX_URI]; /* Path for request */
resource[1024], /* POST resource path */
refresh[1024]; /* Refresh URL */
const char *user; /* Username */
/*
* Build a printer request, which requires the following
* 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(op);
request = ippNewRequest(IPP_PRINT_JOB);
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);
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...
*/
snprintf(resource, sizeof(resource), "/printers/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
if ((response = cupsDoFileRequest(http, request, resource,
filename)) != NULL)
{
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
if (cupsLastError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
ippDelete(response);
}
else if (cupsLastError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
}
else
unlink(filename);
if (cupsLastError() <= IPP_OK_CONFLICT)
{
/*
* Redirect successful updates back to the printer page...
* Automatically reload the printer status page...
*/
char url[1024], /* Printer/class URL */
refresh[1024]; /* Refresh URL */
cgiRewriteURL(uri, url, sizeof(url), NULL);
cgiFormEncode(uri, url, sizeof(uri));
snprintf(refresh, sizeof(refresh), "5;URL=%s", uri);
cgiFormEncode(uri, resource, sizeof(uri));
snprintf(refresh, sizeof(refresh), "2;%s", uri);
cgiSetVariable("refresh_page", refresh);
}
cgiStartHTML(title);
cgiStartHTML(cgiText(_("Printer Maintenance")));
if (op == IPP_PAUSE_PRINTER)
cgiCopyTemplateLang("printer-stop.tmpl");
else if (op == IPP_RESUME_PRINTER)
cgiCopyTemplateLang("printer-start.tmpl");
else if (op == CUPS_ACCEPT_JOBS)
cgiCopyTemplateLang("printer-accept.tmpl");
else if (op == CUPS_REJECT_JOBS)
cgiCopyTemplateLang("printer-reject.tmpl");
else if (op == IPP_OP_CANCEL_JOBS)
cgiCopyTemplateLang("printer-cancel-jobs.tmpl");
if (cupsLastError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to send maintenance job:"));
else
{
cgiSetVariable("PRINTER_NAME", printer);
cgiCopyTemplateLang("maintenance.tmpl");
}
cgiEndHTML();
@@ -291,7 +310,7 @@ do_printer_op(http_t *http, /* I - HTTP connection */
* 'show_all_printers()' - Show all printers...
*/
static void
void
show_all_printers(http_t *http, /* I - Connection to server */
const char *user) /* I - Username */
{
@@ -299,16 +318,20 @@ show_all_printers(http_t *http, /* I - Connection to server */
ipp_t *request, /* IPP request */
*response; /* IPP response */
cups_array_t *printers; /* Array of printer objects */
ipp_attribute_t *printer; /* Printer object */
int first, /* First printer to show */
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 val[1024]; /* Form variable */
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)");
http, user);
/*
* Show the standard header...
@@ -334,9 +357,8 @@ show_all_printers(http_t *http, /* I - Connection to server */
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);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
cgiGetAttributes(request, "printers.tmpl");
@@ -350,8 +372,7 @@ show_all_printers(http_t *http, /* I - Connection to server */
* Get a list of matching job objects.
*/
if ((var = cgiGetVariable("QUERY")) != NULL &&
!cgiGetVariable("CLEAR"))
if ((var = cgiGetVariable("QUERY")) != NULL)
search = cgiCompileSearch(var);
else
search = NULL;
@@ -379,36 +400,95 @@ show_all_printers(http_t *http, /* I - Connection to server */
if (first < 0)
first = 0;
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);
sprintf(url, "%d", count);
cgiSetVariable("TOTAL", url);
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);
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...
*/
cgiSetVariable("THISURL", "/printers/");
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)
{
sprintf(val, "%d", first - CUPS_PAGE_MAX);
cgiSetVariable("PREV", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first - CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("PREVURL", url);
}
if ((first + CUPS_PAGE_MAX) < count)
{
sprintf(val, "%d", first + CUPS_PAGE_MAX);
cgiSetVariable("NEXT", val);
}
if (count > CUPS_PAGE_MAX)
{
snprintf(val, sizeof(val), "%d", CUPS_PAGE_MAX * (count / CUPS_PAGE_MAX));
cgiSetVariable("LAST", val);
snprintf(urlptr, urlend - urlptr, "FIRST=%d&ORDER=%s",
first + CUPS_PAGE_MAX, ascending ? "asc" : "dec");
cgiSetVariable("NEXTURL", url);
}
/*
@@ -419,12 +499,12 @@ show_all_printers(http_t *http, /* I - Connection to server */
cgiCopyTemplateLang("printers-header.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
cgiCopyTemplateLang("printers.tmpl");
if (count > CUPS_PAGE_MAX)
if (count > 0)
cgiCopyTemplateLang("pager.tmpl");
/*
@@ -440,7 +520,7 @@ show_all_printers(http_t *http, /* I - Connection to server */
* Show the error...
*/
cgiShowIPPError(_("Unable to get printer list"));
cgiShowIPPError(_("Unable to get printer list:"));
}
cgiEndHTML();
@@ -451,7 +531,7 @@ show_all_printers(http_t *http, /* I - Connection to server */
* 'show_printer()' - Show a single printer.
*/
static void
void
show_printer(http_t *http, /* I - Connection to server */
const char *printer) /* I - Name of printer */
{
@@ -463,7 +543,7 @@ show_printer(http_t *http, /* I - Connection to server */
fprintf(stderr, "DEBUG: show_printer(http=%p, printer=\"%s\")\n",
http, printer ? printer : "(null)");
http, printer);
/*
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
@@ -481,7 +561,7 @@ show_printer(http_t *http, /* I - Connection to server */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
uri);
cgiGetAttributes(request, "printer.tmpl");
cgiGetAttributes(request, "printers.tmpl");
/*
* Do the request and get back a response...
@@ -496,6 +576,14 @@ show_printer(http_t *http, /* I - Connection to server */
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)
@@ -506,7 +594,7 @@ show_printer(http_t *http, /* I - Connection to server */
*/
cgiFormEncode(uri, printer, sizeof(uri));
snprintf(refresh, sizeof(refresh), "10;URL=/printers/%s", uri);
snprintf(refresh, sizeof(refresh), "10;/printers/%s", uri);
cgiSetVariable("refresh_page", refresh);
}
@@ -526,7 +614,7 @@ show_printer(http_t *http, /* I - Connection to server */
* Show the printer status...
*/
cgiCopyTemplateLang("printer.tmpl");
cgiCopyTemplateLang("printers.tmpl");
/*
* Show jobs for the specified printer...
@@ -542,8 +630,13 @@ show_printer(http_t *http, /* I - Connection to server */
*/
cgiStartHTML(printer);
cgiShowIPPError(_("Unable to get printer status"));
cgiShowIPPError(_("Unable to get printer status:"));
}
cgiEndHTML();
}
/*
* End of "$Id$".
*/
+48 -42
Ver Arquivo
@@ -1,11 +1,31 @@
/*
* Search routines for CUPS.
* "$Id$"
*
* Copyright 2007-2018 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* Search routines for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
* Copyright 1997-2005 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* cgiCompileSearch() - Compile a search string.
* cgiDoSearch() - Do a search of some text.
* cgiFreeSearch() - Free a compiled search context.
*/
/*
@@ -27,28 +47,22 @@ cgiCompileSearch(const char *query) /* I - Query string */
char *s, /* Regular expression string */
*sptr, /* Pointer into RE string */
*sword; /* Pointer to start of word */
size_t slen; /* Allocated size of RE string */
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 */
size_t wlen; /* Word length */
int wlen; /* Word length */
char *lword; /* Last word in query */
/*
* Range check input...
*/
if (!query)
return (NULL);
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);
re = (regex_t *)calloc(1, sizeof(regex_t));
/*
* Allocate a buffer to hold the regular expression string, starting
@@ -60,11 +74,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
if (slen < 1024)
slen = 1024;
if ((s = (char *)malloc(slen)) == NULL)
{
free(re);
return (NULL);
}
s = (char *)malloc(slen);
/*
* Copy the query string to the regular expression, handling basic
@@ -126,13 +136,13 @@ cgiCompileSearch(const char *query) /* I - Query string */
for (qend = qptr + 1; *qend && !isspace(*qend); qend ++);
}
wlen = (size_t)(qend - qptr);
wlen = qend - qptr;
/*
* Look for logic words: AND, OR
*/
if (wlen == 3 && !_cups_strncasecmp(qptr, "AND", 3))
if (wlen == 3 && !strncasecmp(qptr, "AND", 3))
{
/*
* Logical AND with the following text...
@@ -143,7 +153,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
qptr = qend;
}
else if (wlen == 2 && !_cups_strncasecmp(qptr, "OR", 2))
else if (wlen == 2 && !strncasecmp(qptr, "OR", 2))
{
/*
* Logical OR with the following text...
@@ -161,9 +171,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
* string + RE overhead...
*/
wlen = (size_t)(sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
if (lword)
wlen += strlen(lword);
wlen = (sptr - s) + 4 * wlen + 2 * strlen(prefix) + 4;
if (wlen > slen)
{
@@ -195,7 +203,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
* Add the prefix string...
*/
memcpy(sptr, prefix, strlen(prefix) + 1);
strcpy(sptr, prefix);
sptr += strlen(sptr);
/*
@@ -217,8 +225,6 @@ cgiCompileSearch(const char *query) /* I - Query string */
*sptr++ = *qptr++;
}
*sptr = '\0';
/*
* For "word1 AND word2", add reciprocal "word2 AND word1"...
*/
@@ -228,24 +234,18 @@ cgiCompileSearch(const char *query) /* I - Query string */
char *lword2; /* New "last word" */
if ((lword2 = strdup(sword)) == NULL)
{
free(lword);
free(s);
free(re);
return (NULL);
}
lword2 = strdup(sword);
memcpy(sptr, ".*|.*", 6);
strcpy(sptr, ".*|.*");
sptr += 5;
memcpy(sptr, lword2, strlen(lword2) + 1);
strcpy(sptr, lword2);
sptr += strlen(sptr);
memcpy(sptr, ".*", 3);
strcpy(sptr, ".*");
sptr += 2;
memcpy(sptr, lword, strlen(lword) + 1);
strcpy(sptr, lword);
sptr += strlen(sptr);
free(lword);
@@ -274,7 +274,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
free(lword);
if (sptr > s)
memcpy(sptr, ".*", 3);
strcpy(sptr, ".*");
else
{
/*
@@ -291,6 +291,8 @@ cgiCompileSearch(const char *query) /* I - Query string */
* Compile the regular expression...
*/
DEBUG_printf((" s=\"%s\"\n", s));
if (regcomp(re, s, REG_EXTENDED | REG_ICASE))
{
free(re);
@@ -358,5 +360,9 @@ void
cgiFreeSearch(void *search) /* I - Search context */
{
regfree((regex_t *)search);
free(search);
}
/*
* End of "$Id$".
*/
+118 -155
Ver Arquivo
@@ -1,15 +1,40 @@
/*
* CGI template function.
* "$Id$"
*
* Copyright 2007-2015 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
* CGI template function.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: 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-private.h"
#include <errno.h>
#include <regex.h>
/*
@@ -19,7 +44,6 @@
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);
/*
@@ -34,15 +58,8 @@ 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;
fprintf(stderr, "DEBUG: cgiCopyTemplateFile(out=%p, tmpl=\"%s\")\n", out,
tmpl);
/*
* Open the template file...
@@ -51,7 +68,7 @@ cgiCopyTemplateFile(FILE *out, /* I - Output file */
if ((in = fopen(tmpl, "r")) == NULL)
{
fprintf(stderr, "ERROR: Unable to open template file \"%s\" - %s\n",
tmpl ? tmpl : "(null)", strerror(errno));
tmpl, strerror(errno));
return;
}
@@ -76,34 +93,36 @@ cgiCopyTemplateFile(FILE *out, /* I - Output file */
void
cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */
{
int i; /* Looping var */
char filename[1024], /* Filename */
locale[16], /* Locale name */
*locptr; /* Pointer into locale name */
locale[16]; /* Locale name */
const char *directory, /* Directory for templates */
*lang; /* Language */
FILE *in; /* Input file */
fprintf(stderr, "DEBUG2: cgiCopyTemplateLang(tmpl=\"%s\")\n",
tmpl ? tmpl : "(null)");
fprintf(stderr, "DEBUG: cgiCopyTemplateLang(tmpl=\"%s\")\n", tmpl);
/*
* Convert the language to a locale name...
*/
locale[0] = '\0';
if ((lang = getenv("LANG")) != NULL)
{
locale[0] = '/';
strlcpy(locale + 1, lang, sizeof(locale) - 1);
for (i = 0; lang[i] && i < 15; i ++)
if (isalnum(lang[i] & 255))
locale[i] = tolower(lang[i]);
else if (lang[i] == '-')
locale[i] = '_';
else
break;
if ((locptr = strchr(locale, '.')) != NULL)
*locptr = '\0'; /* Strip charset */
locale[i] = '\0';
}
else
locale[0] = '\0';
fprintf(stderr, "DEBUG2: lang=\"%s\", locale=\"%s\"...\n",
lang ? lang : "(null)", locale);
fprintf(stderr, "DEBUG: locale=\"%s\"...\n", locale);
/*
* See if we have a template file for this language...
@@ -111,26 +130,23 @@ cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */
directory = cgiGetTemplateDir();
snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
if ((in = fopen(filename, "r")) == NULL)
snprintf(filename, sizeof(filename), "%s/%s/%s", directory, locale, tmpl);
if (access(filename, 0))
{
locale[3] = '\0';
locale[2] = '\0';
snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl);
if ((in = fopen(filename, "r")) == NULL)
{
snprintf(filename, sizeof(filename), "%s/%s/%s", directory, locale, tmpl);
if (access(filename, 0))
snprintf(filename, sizeof(filename), "%s/%s", directory, tmpl);
in = fopen(filename, "r");
}
}
fprintf(stderr, "DEBUG2: Template file is \"%s\"...\n", filename);
fprintf(stderr, "DEBUG: Template file is \"%s\"...\n", filename);
/*
* Open the template file...
*/
if (!in)
if ((in = fopen(filename, "r")) == NULL)
{
fprintf(stderr, "ERROR: Unable to open template file \"%s\" - %s\n",
filename, strerror(errno));
@@ -219,11 +235,9 @@ cgi_copy(FILE *out, /* I - Output file */
char outval[1024], /* Formatted output string */
compare[1024]; /* Comparison string */
int result; /* Result of comparison */
int uriencode; /* Encode as URI */
regex_t re; /* Regular expression to match */
fprintf(stderr, "DEBUG2: %*sStarting at file position %ld...\n", indent, "",
fprintf(stderr, "DEBUG: %*sStarting at file position %ld...\n", indent, "",
ftell(in));
/*
@@ -239,23 +253,19 @@ 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))
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))
*s++ = (char)ch;
*s++ = ch;
*s = '\0';
if (s == name && isspace(ch & 255))
{
fprintf(stderr, "DEBUG2: %*sLone { at %ld...\n", indent, "", ftell(in));
fprintf(stderr, "DEBUG: %*sLone { at %ld...\n", indent, "", ftell(in));
if (out)
{
@@ -267,7 +277,7 @@ cgi_copy(FILE *out, /* I - Output file */
}
if (ch == '}')
fprintf(stderr, "DEBUG2: %*s\"{%s}\" at %ld...\n", indent, "", name,
fprintf(stderr, "DEBUG: %*s\"{%s}\" at %ld...\n", indent, "", name,
ftell(in));
/*
@@ -331,7 +341,7 @@ cgi_copy(FILE *out, /* I - Output file */
pos = ftell(in);
fprintf(stderr, "DEBUG2: %*sLooping on \"%s\" at %ld, count=%d...\n",
fprintf(stderr, "DEBUG: %*sLooping on \"%s\" at %ld, count=%d...\n",
indent, "", name + 1, pos, count);
if (count > 0)
@@ -347,25 +357,11 @@ cgi_copy(FILE *out, /* I - Output file */
else
cgi_copy(NULL, in, 0, '}', indent + 2);
fprintf(stderr, "DEBUG2: %*sFinished looping on \"%s\"...\n", indent,
fprintf(stderr, "DEBUG: %*sFinished looping on \"%s\"...\n", indent,
"", name + 1);
continue;
}
else if (name[0] == '$')
{
/*
* Insert cookie value or nothing if not defined.
*/
if ((value = cgiGetCookie(name + 1)) != NULL)
outptr = value;
else
{
outval[0] = '\0';
outptr = outval;
}
}
else
{
/*
@@ -403,14 +399,7 @@ cgi_copy(FILE *out, /* I - Output file */
*/
if (out)
{
if (uriencode)
cgi_puturi(outptr, out);
else if (!_cups_strcasecmp(name, "?cupsdconf_default"))
fputs(outptr, stdout);
else
cgi_puts(outptr, out);
}
cgi_puts(outptr, out);
continue;
}
@@ -423,10 +412,9 @@ cgi_copy(FILE *out, /* I - Output file */
* {name<value?true:false} Less than
* {name>value?true:false} Greater than
* {name!value?true:false} Not equal
* {name~refex?true:false} Regex match
*/
op = (char)ch;
op = ch;
if (ch == '?')
{
@@ -434,14 +422,7 @@ cgi_copy(FILE *out, /* I - Output file */
* Test for existance...
*/
if (name[0] == '?')
result = cgiGetArray(name + 1, element) != NULL;
else if (name[0] == '#')
result = cgiGetVariable(name + 1) != NULL;
else
result = cgiGetArray(name, element) != NULL;
result = result && outptr[0];
result = cgiGetArray(name, element) != NULL && outptr[0];
compare[0] = '\0';
}
else
@@ -469,7 +450,7 @@ cgi_copy(FILE *out, /* I - Output file */
innerptr = innername;
while ((ch = getc(in)) != EOF && ch != '}')
if (innerptr < (innername + sizeof(innername) - 1))
*innerptr++ = (char)ch;
*innerptr++ = ch;
*innerptr = '\0';
if (innername[0] == '#')
@@ -481,33 +462,33 @@ cgi_copy(FILE *out, /* I - Output file */
if ((innerval = cgiGetArray(innername, atoi(innerptr) - 1)) == NULL)
*s = '\0';
else
strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
strlcpy(s, innerval, sizeof(compare) - (s - compare));
}
else if (innername[0] == '?')
{
if ((innerval = cgiGetArray(innername + 1, element)) == NULL)
*s = '\0';
else
strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
strlcpy(s, innerval, sizeof(compare) - (s - compare));
}
else if ((innerval = cgiGetArray(innername, element)) == NULL)
snprintf(s, sizeof(compare) - (size_t)(s - compare), "{%s}", innername);
snprintf(s, sizeof(compare) - (s - compare), "{%s}", innername);
else
strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
strlcpy(s, innerval, sizeof(compare) - (s - compare));
s += strlen(s);
}
else if (ch == '\\')
*s++ = (char)getc(in);
*s++ = getc(in);
else
*s++ = (char)ch;
*s++ = ch;
*s = '\0';
if (ch != '?')
{
fprintf(stderr,
"DEBUG2: %*sBad terminator '%c' at file position %ld...\n",
"DEBUG: %*sBad terminator '%c' at file position %ld...\n",
indent, "", ch, ftell(in));
return;
}
@@ -519,49 +500,16 @@ cgi_copy(FILE *out, /* I - Output file */
switch (op)
{
case '<' :
result = _cups_strcasecmp(outptr, compare) < 0;
result = strcasecmp(outptr, compare) < 0;
break;
case '>' :
result = _cups_strcasecmp(outptr, compare) > 0;
result = strcasecmp(outptr, compare) > 0;
break;
case '=' :
result = _cups_strcasecmp(outptr, compare) == 0;
result = strcasecmp(outptr, compare) == 0;
break;
case '!' :
result = _cups_strcasecmp(outptr, compare) != 0;
break;
case '~' :
fprintf(stderr, "DEBUG: Regular expression \"%s\"\n", compare);
if (regcomp(&re, compare, REG_EXTENDED | REG_ICASE))
{
fprintf(stderr,
"ERROR: Unable to compile regular expression \"%s\"!\n",
compare);
result = 0;
}
else
{
regmatch_t matches[10];
result = 0;
if (!regexec(&re, outptr, 10, matches, 0))
{
int i;
for (i = 0; i < 10; i ++)
{
fprintf(stderr, "DEBUG: matches[%d].rm_so=%d\n", i,
(int)matches[i].rm_so);
if (matches[i].rm_so < 0)
break;
result ++;
}
}
regfree(&re);
}
result = strcasecmp(outptr, compare) != 0;
break;
default :
result = 1;
@@ -570,7 +518,7 @@ cgi_copy(FILE *out, /* I - Output file */
}
fprintf(stderr,
"DEBUG2: %*sStarting \"{%s%c%s\" at %ld, result=%d...\n",
"DEBUG: %*sStarting \"{%s%c%s\" at %ld, result=%d...\n",
indent, "", name, op, compare, ftell(in), result);
if (result)
@@ -579,10 +527,10 @@ cgi_copy(FILE *out, /* I - Output file */
* Comparison true; output first part and ignore second...
*/
fprintf(stderr, "DEBUG2: %*sOutput first part...\n", indent, "");
fprintf(stderr, "DEBUG: %*sOutput first part...\n", indent, "");
cgi_copy(out, in, element, ':', indent + 2);
fprintf(stderr, "DEBUG2: %*sSkip second part...\n", indent, "");
fprintf(stderr, "DEBUG: %*sSkip second part...\n", indent, "");
cgi_copy(NULL, in, element, '}', indent + 2);
}
else
@@ -591,14 +539,14 @@ cgi_copy(FILE *out, /* I - Output file */
* Comparison false; ignore first part and output second...
*/
fprintf(stderr, "DEBUG2: %*sSkip first part...\n", indent, "");
fprintf(stderr, "DEBUG: %*sSkip first part...\n", indent, "");
cgi_copy(NULL, in, element, ':', indent + 2);
fprintf(stderr, "DEBUG2: %*sOutput second part...\n", indent, "");
fprintf(stderr, "DEBUG: %*sOutput second part...\n", indent, "");
cgi_copy(out, in, element, '}', indent + 2);
}
fprintf(stderr, "DEBUG2: %*sFinished \"{%s%c%s\", out=%p...\n", indent, "",
fprintf(stderr, "DEBUG: %*sFinished \"{%s%c%s\", out=%p...\n", indent, "",
name, op, compare, out);
}
else if (ch == '\\') /* Quoted char */
@@ -612,11 +560,11 @@ cgi_copy(FILE *out, /* I - Output file */
putc(ch, out);
if (ch == EOF)
fprintf(stderr, "DEBUG2: %*sReturning at file position %ld on EOF...\n",
fprintf(stderr, "DEBUG: %*sReturning at file position %ld on EOF...\n",
indent, "", ftell(in));
else
fprintf(stderr,
"DEBUG2: %*sReturning at file position %ld on character '%c'...\n",
"DEBUG: %*sReturning at file position %ld on character '%c'...\n",
indent, "", ftell(in), ch);
if (ch == EOF && term)
@@ -642,13 +590,43 @@ cgi_puts(const char *s, /* I - String to output */
while (*s)
{
if (*s == '<')
fputs("&lt;", out);
{
/*
* 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("&amp;", out);
else
putc(*s, out);
s ++;
}
if (*s)
s ++;
fputs("\">", out);
}
else if (!strncasecmp(s, "</A>", 4))
{
fputs("</A>", out);
s += 3;
}
else
fputs("&lt;", out);
}
else if (*s == '>')
fputs("&gt;", out);
else if (*s == '\"')
fputs("&quot;", out);
else if (*s == '\'')
fputs("&#39;", out);
else if (*s == '&')
fputs("&amp;", out);
else
@@ -660,20 +638,5 @@ cgi_puts(const char *s, /* I - String to output */
/*
* 'cgi_puturi()' - Put a URI string to the output file, quoting as needed...
* End of "$Id$".
*/
static void
cgi_puturi(const char *s, /* I - String to output */
FILE *out) /* I - Output file */
{
while (*s)
{
if (strchr("%@&+ <>#=", *s) || *s < ' ' || *s & 128)
fprintf(out, "%%%02X", *s & 255);
else
putc(*s, out);
s ++;
}
}
+32 -6
Ver Arquivo
@@ -1,10 +1,30 @@
/*
* CGI test program for CUPS.
* "$Id$"
*
* Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2005 by Easy Software Products.
* CGI test program for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* Copyright 1997-2005 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Test the help index code.
* list_nodes() - List nodes in an array...
*/
/*
@@ -19,7 +39,8 @@
*/
int /* O - Exit status */
main(void)
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
/*
* Test file upload/multi-part submissions...
@@ -49,10 +70,15 @@ main(void)
}
else
puts("FAIL (init)");
/*
* Return with no errors...
*/
return (0);
}
/*
* End of "$Id$".
*/
+31 -94
Ver Arquivo
@@ -1,10 +1,30 @@
/*
* Help index test program for CUPS.
* "$Id$"
*
* Copyright 2007-2017 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
* Help index test program for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* Copyright 1997-2005 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Test the help index code.
* list_nodes() - List nodes in an array...
*/
/*
@@ -19,7 +39,6 @@
*/
static void list_nodes(const char *title, cups_array_t *nodes);
static int usage(void);
/*
@@ -30,82 +49,15 @@ int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
help_index_t *hi, /* Help index */
*search; /* Search index */
const char *opt, /* Current option character */
*dir = ".", /* Directory to index */
*q = NULL, /* Query string */
*section = NULL, /* Section string */
*filename = NULL; /* Filename string */
/*
* Parse the command-line...
*/
for (i = 1; i < argc; i ++)
{
if (argv[i][0] == '-')
{
if (!strcmp(argv[i], "--help"))
{
usage();
return (0);
}
for (opt = argv[i] + 1; *opt; opt ++)
{
switch (*opt)
{
case 'd' : /* -d directory */
i ++;
if (i < argc)
{
dir = argv[i];
}
else
{
fputs("testhi: Missing directory for \"-d\" option.\n", stderr);
return (usage());
}
break;
case 's' : /* -s section */
i ++;
if (i < argc)
{
section = argv[i];
}
else
{
fputs("testhi: Missing section name for \"-s\" option.\n", stderr);
return (usage());
}
break;
default :
fprintf(stderr, "testhi: Unknown option \"-%c\".\n", *opt);
return (usage());
}
}
}
else if (!q)
q = argv[i];
else if (!filename)
filename = argv[i];
else
{
fprintf(stderr, "testhi: Unknown argument \"%s\".\n", argv[i]);
return (usage());
}
}
/*
* Load the help index...
*/
hi = helpLoadIndex("testhi.index", dir);
hi = helpLoadIndex("testhi.index", ".");
list_nodes("nodes", hi->nodes);
list_nodes("sorted", hi->sorted);
@@ -114,9 +66,9 @@ main(int argc, /* I - Number of command-line arguments */
* Do any searches...
*/
if (q)
if (argc > 1)
{
search = helpSearchIndex(hi, q, section, filename);
search = helpSearchIndex(hi, argv[1], NULL, argv[2]);
if (search)
{
@@ -124,7 +76,7 @@ main(int argc, /* I - Number of command-line arguments */
helpDeleteIndex(search);
}
else
printf("%s (0 nodes)\n", q);
printf("%s (0 nodes)\n", argv[1]);
}
helpDeleteIndex(hi);
@@ -153,29 +105,14 @@ list_nodes(const char *title, /* I - Title string */
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,
printf(" %d: %s#%s \"%s\"\n", i, node->filename, node->anchor,
node->text);
else
printf(" %d: %s \"%s\"", i, node->filename, node->text);
printf(" (%d words)\n", cupsArrayCount(node->words));
}
printf(" %d: %s \"%s\"\n", i, node->filename, node->text);
}
/*
* 'usage()' - Show program usage.
* End of "$Id$".
*/
static int /* O - Exit status */
usage(void)
{
puts("Usage: ./testhi [options] [\"query\"] [filename]");
puts("Options:");
puts("-d directory Specify index directory.");
puts("-s section Specify search section.");
return (1);
}
+1 -3
Ver Arquivo
@@ -12,15 +12,13 @@ up to 1024 bytes in length.</P>
<H1><A NAME="FIRST">This is the First Anchor</A></H1>
<P>This&nbsp;is some text for the <em>first</em> anchor.</P>
<P>This is some text for the first 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>
+28 -4
Ver Arquivo
@@ -1,10 +1,29 @@
/*
* CGI template test program for CUPS.
* "$Id$"
*
* Copyright 2007-2011 by Apple Inc.
* Copyright 2006 by Easy Software Products.
* CGI template test program for the Common UNIX Printing System (CUPS).
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
* Copyright 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* main() - Test the template code.
*/
/*
@@ -86,3 +105,8 @@ main(int argc, /* I - Number of command-line arguments */
return (0);
}
/*
* End of "$Id$".
*/
+148 -393
Ver Arquivo
@@ -1,27 +1,53 @@
/*
* CGI form variable and array functions for CUPS.
* "$Id$"
*
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2005 by Easy Software Products.
* CGI form variable and array functions.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers...
* Copyright 1997-2005 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 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
* Contents:
*
* 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-private.h"
#include <cups/http.h>
/*
* Session ID name
*/
#define CUPS_SID "org.cups.sid"
#include <errno.h>
/*
@@ -30,10 +56,10 @@
typedef struct /**** Form variable structure ****/
{
char *name; /* Name of variable */
const char *name; /* Name of variable */
int nvalues, /* Number of values */
avalues; /* Number of values allocated */
char **values; /* Value(s) of variable */
const char **values; /* Value(s) of variable */
} _cgi_var_t;
@@ -41,8 +67,6 @@ typedef struct /**** Form variable structure ****/
* Local globals...
*/
static int num_cookies = 0;/* Number of cookies */
static cups_option_t *cookies = NULL;/* Cookies */
static int form_count = 0, /* Form variable count */
form_alloc = 0; /* Number of variables allocated */
static _cgi_var_t *form_vars = NULL;
@@ -60,13 +84,11 @@ static void cgi_add_variable(const char *name, int element,
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 void cgi_initialize_cookies(void);
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 const char *cgi_set_sid(void);
static void cgi_sort_variables(void);
static void cgi_unlink_file(void);
@@ -114,12 +136,7 @@ cgiCheckVariables(const char *names) /* I - Variables to look for */
return (0);
if (*val == '\0')
{
free((void *)val);
return (0); /* Can't be blank, either! */
}
free((void *)val);
}
return (1);
@@ -127,37 +144,10 @@ cgiCheckVariables(const char *names) /* I - Variables to look for */
/*
* 'cgiClearVariables()' - Clear all form variables.
* 'cgiGetArray()' - Get an element from a form array...
*/
void
cgiClearVariables(void)
{
int i, j; /* Looping vars */
_cgi_var_t *v; /* Current variable */
fputs("DEBUG: cgiClearVariables called.\n", stderr);
for (v = form_vars, i = form_count; i > 0; v ++, i --)
{
free(v->name);
for (j = 0; j < v->nvalues; j ++)
if (v->values[j])
free(v->values[j]);
}
form_count = 0;
cgi_unlink_file();
}
/*
* 'cgiGetArray()' - Get an element from a form array.
*/
char * /* O - Element value or NULL */
const char * /* O - Element value or NULL */
cgiGetArray(const char *name, /* I - Name of array variable */
int element) /* I - Element number (0 to N) */
{
@@ -167,24 +157,13 @@ cgiGetArray(const char *name, /* I - Name of array variable */
if ((var = cgi_find_variable(name)) == NULL)
return (NULL);
if (var->nvalues == 1)
return (var->values[0]);
if (element < 0 || element >= var->nvalues)
return (NULL);
if (var->values[element] == NULL)
return (NULL);
return (strdup(var->values[element]));
}
/*
* 'cgiGetCookie()' - Get a cookie value.
*/
const char * /* O - Value or NULL */
cgiGetCookie(const char *name) /* I - Name of cookie */
{
return (cupsGetOption(name, num_cookies, cookies));
return (var->values[element]);
}
@@ -217,13 +196,13 @@ cgiGetSize(const char *name) /* I - Name of variable */
/*
* 'cgiGetVariable()' - Get a CGI variable from the database.
* 'cgiGetVariable()' - Get a CGI variable from the database...
*
* Returns NULL if the variable doesn't exist. If the variable is an
* array of values, returns the last element.
* array of values, returns the last element...
*/
char * /* O - Value of variable */
const char * /* O - Value of variable */
cgiGetVariable(const char *name) /* I - Name of variable */
{
const _cgi_var_t *var; /* Returned variable */
@@ -231,21 +210,27 @@ cgiGetVariable(const char *name) /* I - Name of variable */
var = cgi_find_variable(name);
return ((var == NULL) ? NULL : strdup(var->values[var->nvalues - 1]));
#ifdef DEBUG
if (var == NULL)
printf("cgiGetVariable(\"%s\") is returning NULL...\n", name);
else
printf("cgiGetVariable(\"%s\") is returning \"%s\"...\n", name,
var->values[var->nvalues - 1]);
#endif /* DEBUG */
return ((var == NULL) ? NULL : var->values[var->nvalues - 1]);
}
/*
* 'cgiInitialize()' - Initialize the CGI variable "database".
* 'cgiInitialize()' - Initialize the CGI variable "database"...
*/
int /* O - Non-zero if there was form data */
cgiInitialize(void)
{
const char *method, /* Form posting method */
*content_type, /* Content-Type of post data */
*cups_sid_cookie, /* SID cookie */
*cups_sid_form; /* SID form variable */
const char *method; /* Form posting method */
const char *content_type; /* Content-Type of post data */
/*
@@ -266,22 +251,9 @@ cgiInitialize(void)
*/
setbuf(stdout, NULL);
puts("Content-type: text/plain\n");
#endif /* DEBUG */
/*
* Get cookies...
*/
cgi_initialize_cookies();
if ((cups_sid_cookie = cgiGetCookie(CUPS_SID)) == NULL)
{
fputs("DEBUG: " CUPS_SID " cookie not found, initializing!\n", stderr);
cups_sid_cookie = cgi_set_sid();
}
fprintf(stderr, "DEBUG: " CUPS_SID " cookie is \"%s\"\n", cups_sid_cookie);
/*
* Get the request method (GET or POST)...
*/
@@ -295,9 +267,9 @@ cgiInitialize(void)
* Grab form data from the corresponding location...
*/
if (!_cups_strcasecmp(method, "GET"))
if (!strcasecmp(method, "GET"))
return (cgi_initialize_get());
else if (!_cups_strcasecmp(method, "POST") && content_type)
else if (!strcasecmp(method, "POST") && content_type)
{
const char *boundary = strstr(content_type, "boundary=");
@@ -305,34 +277,9 @@ cgiInitialize(void)
boundary += 9;
if (content_type && !strncmp(content_type, "multipart/form-data; ", 21))
{
if (!cgi_initialize_multipart(boundary))
return (0);
}
else if (!cgi_initialize_post())
return (0);
if ((cups_sid_form = cgiGetVariable(CUPS_SID)) == NULL ||
strcmp(cups_sid_cookie, cups_sid_form))
{
if (cups_sid_form)
fprintf(stderr, "DEBUG: " CUPS_SID " form variable is \"%s\"\n",
cups_sid_form);
else
fputs("DEBUG: " CUPS_SID " form variable is not present.\n", stderr);
free((void *)cups_sid_form);
cgiClearVariables();
return (0);
}
return (cgi_initialize_multipart(boundary));
else
{
free((void *)cups_sid_form);
return (1);
}
return (cgi_initialize_post());
}
else
return (0);
@@ -375,8 +322,6 @@ cgiSetArray(const char *name, /* I - Name of variable */
if (name == NULL || value == NULL || element < 0 || element > 100000)
return;
fprintf(stderr, "DEBUG: cgiSetArray: %s[%d]=\"%s\"\n", name, element, value);
if ((var = cgi_find_variable(name)) == NULL)
{
cgi_add_variable(name, element, value);
@@ -386,14 +331,9 @@ cgiSetArray(const char *name, /* I - Name of variable */
{
if (element >= var->avalues)
{
char **temp; /* Temporary pointer */
temp = (char **)realloc((void *)(var->values), sizeof(char *) * (size_t)(element + 16));
if (!temp)
return;
var->avalues = element + 16;
var->values = temp;
var->values = (const char **)realloc((void *)(var->values),
sizeof(char *) * var->avalues);
}
if (element >= var->nvalues)
@@ -411,38 +351,6 @@ cgiSetArray(const char *name, /* I - Name of variable */
}
/*
* 'cgiSetCookie()' - Set a cookie value.
*/
void
cgiSetCookie(const char *name, /* I - Name */
const char *value, /* I - Value */
const char *path, /* I - Path (typically "/") */
const char *domain, /* I - Domain name */
time_t expires, /* I - Expiration date (0 for session) */
int secure) /* I - Require SSL */
{
num_cookies = cupsAddOption(name, value, num_cookies, &cookies);
printf("Set-Cookie: %s=%s;", name, value);
if (path)
printf(" path=%s;", path);
if (domain)
printf(" domain=%s;", domain);
if (expires)
{
char date[256]; /* Date string */
printf(" expires=%s;", httpGetDateString2(expires, date, sizeof(date)));
}
if (secure)
puts(" httponly; secure;");
else
puts(" httponly;");
}
/*
* 'cgiSetSize()' - Set the array size.
*/
@@ -463,14 +371,9 @@ cgiSetSize(const char *name, /* I - Name of variable */
if (size >= var->avalues)
{
char **temp; /* Temporary pointer */
temp = (char **)realloc((void *)(var->values), sizeof(char *) * (size_t)(size + 16));
if (!temp)
return;
var->avalues = size + 16;
var->values = temp;
var->values = (const char **)realloc((void *)(var->values),
sizeof(char *) * var->avalues);
}
if (size > var->nvalues)
@@ -490,7 +393,7 @@ cgiSetSize(const char *name, /* I - Name of variable */
/*
* 'cgiSetVariable()' - Set a CGI variable in the database.
* 'cgiSetVariable()' - Set a CGI variable in the database...
*
* If the variable is an array, this truncates the array to a single element.
*/
@@ -506,8 +409,6 @@ cgiSetVariable(const char *name, /* I - Name of variable */
if (name == NULL || value == NULL)
return;
fprintf(stderr, "cgiSetVariable: %s=\"%s\"\n", name, value);
if ((var = cgi_find_variable(name)) == NULL)
{
cgi_add_variable(name, 0, value);
@@ -534,37 +435,31 @@ cgi_add_variable(const char *name, /* I - Variable name */
int element, /* I - Array element number */
const char *value) /* I - Variable value */
{
_cgi_var_t *var; /* New variable */
_cgi_var_t *var; /* New variable */
if (name == NULL || value == NULL || element < 0 || element > 100000)
return;
#ifdef DEBUG
printf("Adding variable \'%s\' with value \'%s\'...\n", name, value);
#endif /* DEBUG */
if (form_count >= form_alloc)
{
_cgi_var_t *temp_vars; /* Temporary form pointer */
if (form_alloc == 0)
temp_vars = malloc(sizeof(_cgi_var_t) * 16);
form_vars = malloc(sizeof(_cgi_var_t) * 16);
else
temp_vars = realloc(form_vars, (size_t)(form_alloc + 16) * sizeof(_cgi_var_t));
form_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;
if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
return;
var = form_vars + form_count;
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 ++;
@@ -580,12 +475,12 @@ cgi_compare_variables(
const _cgi_var_t *v1, /* I - First variable */
const _cgi_var_t *v2) /* I - Second variable */
{
return (_cups_strcasecmp(v1->name, v2->name));
return (strcasecmp(v1->name, v2->name));
}
/*
* 'cgi_find_variable()' - Find a variable.
* 'cgi_find_variable()' - Find a variable...
*/
static _cgi_var_t * /* O - Variable pointer or NULL */
@@ -597,117 +492,13 @@ cgi_find_variable(const char *name) /* I - Name of variable */
if (form_count < 1 || name == NULL)
return (NULL);
key.name = (char *)name;
key.name = name;
return ((_cgi_var_t *)bsearch(&key, form_vars, (size_t)form_count, sizeof(_cgi_var_t),
return ((_cgi_var_t *)bsearch(&key, form_vars, form_count, sizeof(_cgi_var_t),
(int (*)(const void *, const void *))cgi_compare_variables));
}
/*
* 'cgi_initialize_cookies()' - Initialize cookies.
*/
static void
cgi_initialize_cookies(void)
{
const char *cookie; /* HTTP_COOKIE environment variable */
char name[128], /* Name string */
value[512], /* Value string */
*ptr; /* Pointer into name/value */
if ((cookie = getenv("HTTP_COOKIE")) == NULL)
return;
while (*cookie)
{
int skip = 0; /* Skip this cookie? */
/*
* Skip leading whitespace...
*/
while (isspace(*cookie & 255))
cookie ++;
if (!*cookie)
break;
/*
* Copy the name...
*/
for (ptr = name; *cookie && *cookie != '=';)
if (ptr < (name + sizeof(name) - 1))
{
*ptr++ = *cookie++;
}
else
{
skip = 1;
cookie ++;
}
if (*cookie != '=')
break;
*ptr = '\0';
cookie ++;
/*
* Then the value...
*/
if (*cookie == '\"')
{
for (cookie ++, ptr = value; *cookie && *cookie != '\"';)
if (ptr < (value + sizeof(value) - 1))
{
*ptr++ = *cookie++;
}
else
{
skip = 1;
cookie ++;
}
if (*cookie == '\"')
cookie ++;
else
skip = 1;
}
else
{
for (ptr = value; *cookie && *cookie != ';';)
if (ptr < (value + sizeof(value) - 1))
{
*ptr++ = *cookie++;
}
else
{
skip = 1;
cookie ++;
}
}
if (*cookie == ';')
cookie ++;
else if (*cookie)
skip = 1;
*ptr = '\0';
/*
* Then add the cookie to an array as long as the name doesn't start with
* "$"...
*/
if (name[0] != '$' && !skip)
num_cookies = cupsAddOption(name, value, num_cookies, &cookies);
}
}
/*
* 'cgi_initialize_get()' - Initialize form variables using the GET method.
*/
@@ -718,6 +509,10 @@ cgi_initialize_get(void)
char *data; /* Pointer to form data string */
#ifdef DEBUG
puts("Initializing variables using GET method...");
#endif /* DEBUG */
/*
* Check to see if there is anything for us to read...
*/
@@ -735,8 +530,7 @@ cgi_initialize_get(void)
/*
* 'cgi_initialize_multipart()' - Initialize variables and file using the POST
* method.
* 'cgi_initialize_multipart()' - Initialize variables and file using the POST method.
*
* TODO: Update to support files > 2GB.
*/
@@ -753,10 +547,12 @@ cgi_initialize_multipart(
*ptr, /* Pointer into name/filename */
*end; /* End of buffer */
int ch, /* Character from file */
fd; /* Temporary file descriptor */
size_t blen; /* Length of boundary string */
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...
*/
@@ -812,27 +608,27 @@ cgi_initialize_multipart(
/*
* Copy file data to the temp file...
*/
ptr = line;
while ((ch = getchar()) != EOF)
{
*ptr++ = (char)ch;
*ptr++ = ch;
if ((size_t)(ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
{
ptr -= blen;
break;
}
if ((ptr - line - (int)blen) >= 8192)
if ((ptr - line - blen) >= 8192)
{
/*
* Write out the first 8k of the buffer...
*/
write(fd, line, 8192);
memmove(line, line + 8192, (size_t)(ptr - line - 8192));
memmove(line, line + 8192, ptr - line - 8192);
ptr -= 8192;
}
}
@@ -842,7 +638,7 @@ cgi_initialize_multipart(
*/
if (ptr > line)
write(fd, line, (size_t)(ptr - line));
write(fd, line, ptr - line);
close(fd);
}
@@ -859,9 +655,9 @@ cgi_initialize_multipart(
while ((ch = getchar()) != EOF)
{
if (ptr < end)
*ptr++ = (char)ch;
*ptr++ = ch;
if ((size_t)(ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
{
ptr -= blen;
break;
@@ -884,13 +680,12 @@ cgi_initialize_multipart(
if (line[0])
cgiSetArray(name, atoi(ptr) - 1, line);
}
else if ((ptr = cgiGetVariable(name)) != NULL)
else if (cgiGetVariable(name))
{
/*
* Add another element in the array...
*/
free(ptr);
cgiSetArray(name, cgiGetSize(name), line);
}
else
@@ -917,7 +712,7 @@ cgi_initialize_multipart(
filename[0] = '\0';
mimetype[0] = '\0';
}
else if (!_cups_strncasecmp(line, "Content-Disposition:", 20))
else if (!strncasecmp(line, "Content-Disposition:", 20))
{
if ((ptr = strstr(line + 20, " name=\"")) != NULL)
{
@@ -935,7 +730,7 @@ cgi_initialize_multipart(
*ptr = '\0';
}
}
else if (!_cups_strncasecmp(line, "Content-Type:", 13))
else if (!strncasecmp(line, "Content-Type:", 13))
{
for (ptr = line + 13; isspace(*ptr & 255); ptr ++);
@@ -962,14 +757,18 @@ cgi_initialize_multipart(
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 */
size_t length, /* Length of input data */
tbytes; /* Total number of bytes read */
ssize_t nbytes; /* Number of bytes read this read() */
int 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
puts("Initializing variables using POST method...");
#endif /* DEBUG */
/*
* Check to see if there is anything for us to read...
*/
@@ -982,8 +781,8 @@ cgi_initialize_post(void)
* Get the length of the input stream and allocate a buffer for it...
*/
length = (size_t)strtol(content_length, NULL, 10);
data = malloc(length + 1); // lgtm [cpp/uncontrolled-allocation-size]
length = atoi(content_length);
data = malloc(length + 1);
if (data == NULL)
return (0);
@@ -992,29 +791,13 @@ cgi_initialize_post(void)
* Read the data into the buffer...
*/
for (tbytes = 0; tbytes < length; tbytes += (size_t)nbytes)
if ((nbytes = read(0, data + tbytes, (size_t)(length - tbytes))) < 0)
{
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';
@@ -1045,8 +828,7 @@ cgi_initialize_string(const char *data) /* I - Form data string */
char *s, /* Pointer to current form string */
ch, /* Temporary character */
name[255], /* Name of form variable */
value[65536], /* Variable value */
*temp; /* Temporary pointer */
value[65536]; /* Variable value... */
/*
@@ -1099,16 +881,13 @@ cgi_initialize_string(const char *data) /* I - Form data string */
* Read the hex code...
*/
if (!isxdigit(data[1] & 255) || !isxdigit(data[2] & 255))
return (0);
if (s < (value + sizeof(value) - 1))
{
data ++;
ch = *data - '0';
if (ch > 9)
ch -= 7;
*s = (char)(ch << 4);
*s = ch << 4;
data ++;
ch = *data - '0';
@@ -1135,7 +914,7 @@ cgi_initialize_string(const char *data) /* I - Form data string */
if (s > value)
s --;
while (s >= value && isspace(*s & 255))
while (s >= value && *s == ' ')
*s-- = '\0';
/*
@@ -1148,11 +927,8 @@ cgi_initialize_string(const char *data) /* I - Form data string */
if (value[0])
cgiSetArray(name, atoi(s) - 1, value);
}
else if ((temp = cgiGetVariable(name)) != NULL)
{
free(temp);
else if (cgiGetVariable(name) != NULL)
cgiSetArray(name, cgiGetSize(name), value);
}
else
cgiSetVariable(name, value);
}
@@ -1173,8 +949,7 @@ cgi_passwd(const char *prompt) /* I - Prompt (not used) */
{
(void)prompt;
fprintf(stderr, "DEBUG: cgi_passwd(prompt=\"%s\") called!\n",
prompt ? prompt : "(null)");
fprintf(stderr, "DEBUG: cgi_passwd(prompt=\"%s\") called!\n", prompt);
/*
* Send a 401 (unauthorized) status to the server, so it can notify
@@ -1192,45 +967,6 @@ cgi_passwd(const char *prompt) /* I - Prompt (not used) */
}
/*
* 'cgi_set_sid()' - Set the CUPS session ID.
*/
static const char * /* O - New session ID */
cgi_set_sid(void)
{
char buffer[512], /* SID data */
sid[33]; /* SID string */
unsigned char sum[16]; /* MD5 sum */
const char *remote_addr, /* REMOTE_ADDR */
*server_name, /* SERVER_NAME */
*server_port; /* SERVER_PORT */
struct timeval curtime; /* Current time */
if ((remote_addr = getenv("REMOTE_ADDR")) == NULL)
remote_addr = "REMOTE_ADDR";
if ((server_name = getenv("SERVER_NAME")) == NULL)
server_name = "SERVER_NAME";
if ((server_port = getenv("SERVER_PORT")) == NULL)
server_port = "SERVER_PORT";
gettimeofday(&curtime, NULL);
CUPS_SRAND(curtime.tv_sec + curtime.tv_usec);
snprintf(buffer, sizeof(buffer), "%s:%s:%s:%02X%02X%02X%02X%02X%02X%02X%02X",
remote_addr, server_name, server_port,
(unsigned)CUPS_RAND() & 255, (unsigned)CUPS_RAND() & 255,
(unsigned)CUPS_RAND() & 255, (unsigned)CUPS_RAND() & 255,
(unsigned)CUPS_RAND() & 255, (unsigned)CUPS_RAND() & 255,
(unsigned)CUPS_RAND() & 255, (unsigned)CUPS_RAND() & 255);
cupsHashData("md5", (unsigned char *)buffer, strlen(buffer), sum, sizeof(sum));
cgiSetCookie(CUPS_SID, cupsHashString(sum, sizeof(sum), sid, sizeof(sid)), "/", NULL, 0, 0);
return (cupsGetOption(CUPS_SID, num_cookies, cookies));
}
/*
* 'cgi_sort_variables()' - Sort all form variables for faster lookup.
*/
@@ -1238,11 +974,25 @@ cgi_set_sid(void)
static void
cgi_sort_variables(void)
{
#ifdef DEBUG
int i;
puts("Sorting variables...");
#endif /* DEBUG */
if (form_count < 2)
return;
qsort(form_vars, (size_t)form_count, sizeof(_cgi_var_t),
qsort(form_vars, form_count, sizeof(_cgi_var_t),
(int (*)(const void *, const void *))cgi_compare_variables);
#ifdef DEBUG
puts("Sorted variable list is:");
for (i = 0; i < form_count; i ++)
printf("%d: %s (%d) = \"%s\" ...\n", i, form_vars[i].name,
form_vars[i].nvalues, form_vars[i].values[0]);
#endif /* DEBUG */
}
@@ -1273,3 +1023,8 @@ cgi_unlink_file(void)
form_file = NULL;
}
}
/*
* End of "$Id$".
*/
+38 -63
Ver Arquivo
@@ -1,10 +1,25 @@
#
# Configuration file makefile for CUPS.
# "$Id$"
#
# Copyright 2007-2015 by Apple Inc.
# Copyright 1993-2006 by Easy Software Products.
# Configuration file makefile for the Common UNIX Printing System (CUPS).
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more information.
# 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 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
include ../Makedefs
@@ -13,7 +28,7 @@ include ../Makedefs
# Config files...
#
KEEP = cups-files.conf cupsd.conf snmp.conf
KEEP = cupsd.conf
REPLACE = mime.convs mime.types
@@ -24,20 +39,6 @@ REPLACE = mime.convs mime.types
all:
#
# Make library targets...
#
libs:
#
# Make unit tests...
#
unittests:
#
# Clean all config and object files...
#
@@ -53,38 +54,32 @@ depend:
#
# Install all targets...
# Install files...
#
install: all install-data install-headers install-libs install-exec
#
# Install data files...
#
install-data:
install: all
$(INSTALL_DIR) -m 755 $(SERVERROOT)
for file in $(KEEP); do \
if test -r $(SERVERROOT)/$$file ; then \
$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT)/$$file.N ; \
$(INSTALL_CONFIG) $$file $(SERVERROOT)/$$file.N ; \
chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file.N || true; \
else \
$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT) ; \
$(INSTALL_CONFIG) $$file $(SERVERROOT) ; \
chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file || true; \
fi ; \
$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT)/$$file.default; \
done
$(INSTALL_DIR) -m 755 $(DATADIR)/mime
$(INSTALL_CONFIG) cupsd.conf $(SERVERROOT)/cupsd.conf.default
-chgrp $(CUPS_GROUP) $(SERVERROOT)/cupsd.conf.default
for file in $(REPLACE); do \
if test -r $(DATADIR)/mime/$$file ; then \
$(MV) $(DATADIR)/mime/$$file $(DATADIR)/mime/$$file.O ; \
fi ; \
if test -r $(SERVERROOT)/$$file ; then \
$(MV) $(SERVERROOT)/$$file $(DATADIR)/mime/$$file.O ; \
$(MV) $(SERVERROOT)/$$file $(SERVERROOT)/$$file.O ; \
fi ; \
$(INSTALL_DATA) $$file $(DATADIR)/mime ; \
$(INSTALL_CONFIG) $$file $(SERVERROOT) ; \
chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file || true; \
done
-if test x$(PAMDIR) != x; then \
$(INSTALL_DIR) -m 755 $(BUILDROOT)$(PAMDIR); \
if test -r $(BUILDROOT)$(PAMDIR)/cups ; then \
if test -r $(BUILDROOT)$(PAMDIR)/cups/$(PAMFILE) ; then \
$(INSTALL_DATA) $(PAMFILE) $(BUILDROOT)$(PAMDIR)/cups.N ; \
else \
$(INSTALL_DATA) $(PAMFILE) $(BUILDROOT)$(PAMDIR)/cups ; \
@@ -92,27 +87,6 @@ install-data:
fi
#
# Install programs...
#
install-exec:
#
# Install headers...
#
install-headers:
#
# Install libraries...
#
install-libs:
#
# Uninstall files...
#
@@ -122,11 +96,12 @@ uninstall:
$(RM) $(SERVERROOT)/$$file; \
done
-$(RMDIR) $(SERVERROOT)
for file in $(REPLACE); do \
$(RM) $(DATADIR)/mime/$$file; \
done
-$(RMDIR) $(DATADIR)/mime
-if test x$(PAMDIR) != x; then \
$(RM) $(BUILDROOT)$(PAMDIR)/cups; \
$(RMDIR) $(BUILDROOT)$(PAMDIR); \
fi
#
# End of "$Id$".
#
-93
Ver Arquivo
@@ -1,93 +0,0 @@
#
# File/directory/user/group configuration file for the CUPS scheduler.
# See "man cups-files.conf" for a complete description of this file.
#
# List of events that are considered fatal errors for the scheduler...
#FatalErrors @CUPS_FATAL_ERRORS@
# Do we call fsync() after writing configuration or status files?
#SyncOnClose No
# Default user and group for filters/backends/helper programs; this cannot be
# any user or group that resolves to ID 0 for security reasons...
#User @CUPS_USER@
#Group @CUPS_GROUP@
# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules...
# This cannot contain the Group value for security reasons...
SystemGroup @CUPS_SYSTEM_GROUPS@
@CUPS_SYSTEM_AUTHKEY@
# User that is substituted for unauthenticated (remote) root accesses...
#RemoteRoot remroot
# Do we allow file: device URIs other than to /dev/null?
#FileDevice No
# Permissions for configuration and log files...
#ConfigFilePerm 0@CUPS_CONFIG_FILE_PERM@
#LogFilePerm 0@CUPS_LOG_FILE_PERM@
# Location of the file logging all access to the scheduler; may be the name
# "syslog". If not an absolute path, the value of ServerRoot is used as the
# root directory. Also see the "AccessLogLevel" directive in cupsd.conf.
AccessLog @CUPS_LOGDIR@/access_log
# Location of cache files used by the scheduler...
#CacheDir @CUPS_CACHEDIR@
# Location of data files used by the scheduler...
#DataDir @CUPS_DATADIR@
# Location of the static web content served by the scheduler...
#DocumentRoot @CUPS_DOCROOT@
# Location of the file logging all messages produced by the scheduler and any
# helper programs; may be the name "syslog". If not an absolute path, the value
# of ServerRoot is used as the root directory. Also see the "LogLevel"
# directive in cupsd.conf.
ErrorLog @CUPS_LOGDIR@/error_log
# Location of fonts used by older print filters...
#FontPath @CUPS_FONTPATH@
# Location of LPD configuration
#LPDConfigFile @CUPS_DEFAULT_LPD_CONFIG_FILE@
# Location of the file logging all pages printed by the scheduler and any
# helper programs; may be the name "syslog". If not an absolute path, the value
# of ServerRoot is used as the root directory. Also see the "PageLogFormat"
# directive in cupsd.conf.
PageLog @CUPS_LOGDIR@/page_log
# Location of the file listing all of the local printers...
#Printcap @CUPS_DEFAULT_PRINTCAP@
# Format of the Printcap file...
#PrintcapFormat bsd
#PrintcapFormat plist
#PrintcapFormat solaris
# Location of all spool files...
#RequestRoot @CUPS_REQUESTS@
# Location of helper programs...
#ServerBin @CUPS_SERVERBIN@
# SSL/TLS keychain for the scheduler...
#ServerKeychain @CUPS_SERVERKEYCHAIN@
# Location of other configuration files...
#ServerRoot @CUPS_SERVERROOT@
# Location of Samba configuration file...
#SMBConfigFile @CUPS_DEFAULT_SMB_CONFIG_FILE@
# Location of scheduler state files...
#StateDir @CUPS_STATEDIR@
# Location of scheduler/helper temporary files. This directory is emptied on
# scheduler startup and cannot be one of the standard (public) temporary
# directory locations for security reasons...
#TempDir @CUPS_REQUESTS@/tmp
+26 -132
Ver Arquivo
@@ -1,12 +1,17 @@
#
# Configuration file for the CUPS scheduler. See "man cupsd.conf" for a
# complete description of this file.
# "$Id$"
#
# Sample configuration file for the Common UNIX Printing System (CUPS)
# scheduler. See "man cupsd.conf" for a complete description of this
# file.
#
# Log general information in error_log - change "@CUPS_LOG_LEVEL@" to "debug"
# for troubleshooting...
LogLevel @CUPS_LOG_LEVEL@
@CUPS_PAGE_LOG_FORMAT@
# Log general information in error_log - change "info" to "debug" for
# troubleshooting...
LogLevel info
# Administrator user group...
SystemGroup @CUPS_SYSTEM_GROUPS@
# Only listen for connections from the local machine.
Listen localhost:@DEFAULT_IPP_PORT@
@@ -14,73 +19,50 @@ Listen localhost:@DEFAULT_IPP_PORT@
# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols @CUPS_BROWSE_LOCAL_PROTOCOLS@
BrowseOrder allow,deny
BrowseAllow @LOCAL
# Default authentication type, when authentication is required...
DefaultAuthType Basic
# Web interface setting...
WebInterface @CUPS_WEBIF@
# Restrict access to the server...
<Location />
Order allow,deny
Allow localhost
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow localhost
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
</Location>
# Restrict access to log files...
<Location /admin/log>
AuthType Default
AuthType Basic
Require user @SYSTEM
Order allow,deny
Allow localhost
</Location>
# Set the default printer/job policies...
<Policy default>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
Order deny,allow
</Limit>
<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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
# Job-related operations must be done by the owner or an adminstrator...
<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 CUPS-Get-Devices>
AuthType Default
# All administration operations require an adminstrator to authenticate...
<Limit Pause-Printer Resume-Printer Set-Printer-Attributes 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-Add-Printer CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>
AuthType Basic
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 Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @CUPS_DEFAULT_PRINTOPERATOR_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_PRINTOPERATOR_AUTH@
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>
@@ -89,94 +71,6 @@ WebInterface @CUPS_WEBIF@
</Limit>
</Policy>
# Set the authenticated printer/job policies...
<Policy authenticated>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
AuthType Default
Order deny,allow
</Limit>
<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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
AuthType Default
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 Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @CUPS_DEFAULT_PRINTOPERATOR_AUTH@
Order deny,allow
</Limit>
# Only the owner or an administrator can cancel or authenticate a job...
<Limit Cancel-Job CUPS-Authenticate-Job>
AuthType Default
Require user @OWNER @CUPS_DEFAULT_PRINTOPERATOR_AUTH@
Order deny,allow
</Limit>
<Limit All>
Order deny,allow
</Limit>
</Policy>
# Set the kerberized printer/job policies...
<Policy kerberos>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
AuthType Negotiate
Order deny,allow
</Limit>
<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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
AuthType Negotiate
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 Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @CUPS_DEFAULT_PRINTOPERATOR_AUTH@
Order deny,allow
</Limit>
# Only the owner or an administrator can cancel or authenticate a job...
<Limit Cancel-Job CUPS-Authenticate-Job>
AuthType Negotiate
Require user @OWNER @CUPS_DEFAULT_PRINTOPERATOR_AUTH@
Order deny,allow
</Limit>
<Limit All>
Order deny,allow
</Limit>
</Policy>
#
# End of "$Id$".
#
+119
Ver Arquivo
@@ -0,0 +1,119 @@
#
# "$Id: mime.convs 4559 2005-08-04 18:40:13Z mike $"
#
# MIME converts file for the Common UNIX Printing System (CUPS).
#
# Copyright 1997-2005 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 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
########################################################################
#
# Format of Lines:
#
# source/type destination/type cost filter
#
# General Notes:
#
# The "cost" field is used to find the least costly filters to run
# when converting a job file to a printable format.
#
# All filters *must* accept the standard command-line arguments
# (job-id, user, title, copies, options, [filename or stdin]) to
# work with CUPS.
#
########################################################################
#
# PostScript filters
#
application/pdf application/postscript 33 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
text/html application/postscript 33 texttops
image/gif application/vnd.cups-postscript 66 imagetops
image/png application/vnd.cups-postscript 66 imagetops
image/jpeg application/vnd.cups-postscript 66 imagetops
image/tiff application/vnd.cups-postscript 66 imagetops
image/x-bitmap application/vnd.cups-postscript 66 imagetops
image/x-photocd application/vnd.cups-postscript 66 imagetops
image/x-portable-anymap application/vnd.cups-postscript 66 imagetops
image/x-portable-bitmap application/vnd.cups-postscript 66 imagetops
image/x-portable-graymap application/vnd.cups-postscript 66 imagetops
image/x-portable-pixmap application/vnd.cups-postscript 66 imagetops
image/x-sgi-rgb application/vnd.cups-postscript 66 imagetops
image/x-xbitmap application/vnd.cups-postscript 66 imagetops
image/x-xpixmap application/vnd.cups-postscript 66 imagetops
#image/x-xwindowdump application/vnd.cups-postscript 66 imagetops
image/x-sun-raster application/vnd.cups-postscript 66 imagetops
########################################################################
#
# Form filter...
#
# This filter does not currently exist, but the file format is defined
# in the IDD and registered with the IANA for future use...
#
#application/vnd.cups-form application/vnd.cups-postscript 33 formtops
########################################################################
#
# Raster filters...
#
image/gif application/vnd.cups-raster 100 imagetoraster
image/png application/vnd.cups-raster 100 imagetoraster
image/jpeg application/vnd.cups-raster 100 imagetoraster
image/tiff application/vnd.cups-raster 100 imagetoraster
image/x-bitmap application/vnd.cups-raster 100 imagetoraster
image/x-photocd application/vnd.cups-raster 100 imagetoraster
image/x-portable-anymap application/vnd.cups-raster 100 imagetoraster
image/x-portable-bitmap application/vnd.cups-raster 100 imagetoraster
image/x-portable-graymap application/vnd.cups-raster 100 imagetoraster
image/x-portable-pixmap application/vnd.cups-raster 100 imagetoraster
image/x-sgi-rgb application/vnd.cups-raster 100 imagetoraster
image/x-xbitmap application/vnd.cups-raster 100 imagetoraster
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
########################################################################
#
# 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.
#
#application/octet-stream application/vnd.cups-raw 0 -
#
# End of "$Id: mime.convs 4559 2005-08-04 18:40:13Z mike $".
#
-55
Ver Arquivo
@@ -1,55 +0,0 @@
#
# 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.
#
# Base MIME conversions file for CUPS.
#
# Copyright © 2007-2016 by Apple Inc.
# Copyright © 1997-2007 by Easy Software Products.
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
#
########################################################################
#
# Format of Lines:
#
# source/type destination/type cost filter
#
# General Notes:
#
# The "cost" field is used to find the least costly filters to run
# when converting a job file to a printable format.
#
# All filters *must* accept the standard command-line arguments
# (job-id, user, title, copies, options, [filename or stdin]) to
# work with CUPS.
#
########################################################################
#
# PostScript filters
#
application/postscript application/vnd.cups-postscript 66 pstops
########################################################################
#
# Raster filters...
#
# PWG Raster filter for IPP Everywhere...
application/vnd.cups-raster image/pwg-raster 100 rastertopwg
application/vnd.cups-raster image/urf 100 rastertopwg
########################################################################
#
# Raw filter...
#
# Uncomment the following filter to allow printing of arbitrary files
# without the -oraw option.
#
@DEFAULT_RAW_PRINTING@application/octet-stream application/vnd.cups-raw 0 -
+52 -51
Ver Arquivo
@@ -1,15 +1,25 @@
#
# Base MIME types file for CUPS.
# "$Id: mime.types 4590 2005-08-24 19:25:49Z mike $"
#
# 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.
# MIME types file for the Common UNIX Printing System (CUPS).
#
# Copyright © 2007-2017 by Apple Inc.
# Copyright © 1997-2007 by Easy Software Products.
# Copyright 1997-2005 by Easy Software Products.
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
# 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
#
########################################################################
@@ -28,11 +38,8 @@
# extension Pattern match on "*.extension"
# ascii(offset,length) True if bytes are valid printable ASCII
# (CR, NL, TAB, BS, 32-126)
# priority(number) Sets priority of type (0=lowest,
# 100=default, 200=highest)
# printable(offset,length) True if bytes are printable 8-bit chars
# (CR, NL, TAB, BS, 32-126, 128-254)
# regex(offset,"regex") True if bytes match regular expression
# string(offset,"string") True if bytes are identical to string
# istring(offset,"string") True if bytes are identical to
# case-insensitive string
@@ -46,12 +53,10 @@
#
# MIME type names are case-insensitive. Internally they are converted
# to lowercase. Multiple occurrences of a type will cause the provided
# rules to be appended to the existing definition. If two types use the same
# rules to resolve a type and have the same priority, e.g. "doc" extension for
# "text/bar" and "text/foo", the returned type will be the first type as
# sorted in alphanumerically ascending order without regard to case. Thus,
# the "text/bar" type will match the "doc" extension first unless the
# "text/foo" type has specified a higher priority.
# rules to be appended to the existing definition. Type names are sorted
# in ascending order, so if two types use the same rules to resolve a type
# (e.g. doc extension for two types), the returned type will be the first
# type in the sorted list.
#
# The "printable" rule differs from the "ascii" rule in that it also
# accepts 8-bit characters in the range 128-255.
@@ -66,16 +71,21 @@
#
#application/msword doc string(0,<D0CF11E0A1B11AE1>)
application/pdf pdf regex(0,^[\n\r]*%PDF)
application/pdf pdf string(0,%PDF)
application/postscript ai eps ps string(0,%!) string(0,<04>%!) \
contains(0,128,<1B>%-12345X) + \
(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")))
(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>&)\
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")))
########################################################################
#
@@ -84,13 +94,12 @@ application/postscript ai eps ps string(0,%!) string(0,<04>%!) \
image/gif gif string(0,GIF87a) string(0,GIF89a)
image/png png string(0,<89>PNG)
image/jpeg jpeg jpg jpe string(0,<FFD8FF>) +\
image/jpeg jpeg jpg jpe string(0,<FFD8FF>) &&\
(char(3,0xe0) char(3,0xe1) char(3,0xe2) char(3,0xe3)\
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/pwg-raster string(0,"RaS2") + string(4,PwgRaster<00>) priority(150)
image/tiff tiff tif string(0,MM<002A>) string(0,II<2A00>)
image/tiff tiff tif string(0,MM) string(0,II)
image/x-photocd pcd string(2048,PCD_IPI)
image/x-portable-anymap pnm
image/x-portable-bitmap pbm string(0,P1) string(0,P4)
@@ -103,9 +112,8 @@ image/x-xpixmap xpm ascii(0,1024) + string(3,"XPM")
image/x-sun-raster ras string(0,<59a66a95>)
#image/fpx fpx
image/urf urf string(0,UNIRAST<00>)
image/x-alias pix short(8,8) short(8,24)
image/x-bitmap bmp string(0,BM) + !printable(2,14)
image/x-bitmap bmp string(0,BM) && !printable(2,14)
image/x-icon ico
########################################################################
@@ -121,8 +129,8 @@ 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) + ! css + \
(string(0,/*) string(0,//) \
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) +\
@@ -130,39 +138,32 @@ text/html html htm printable(0,1024) +\
text/plain txt printable(0,1024)
text/css css
########################################################################
#
# RSS feed type...
#
application/rss+xml rss
########################################################################
#
# CUPS-specific types...
#
application/vnd.cups-banner string(0,'#CUPS-BANNER')
application/vnd.cups-command string(0,'#CUPS-COMMAND')
application/vnd.cups-pdf
application/vnd.cups-form string(0,"<CUPSFORM>")
application/vnd.cups-postscript
application/vnd.cups-ppd ppd string(0,"*PPD-Adobe:")
application/vnd.cups-raster string(0,"RaSt") string(0,"tSaR") \
(string(0,"RaS2") + !string(4,PwgRaster<00>)) string(0,"2SaR") \
string(0,"RaS3") string(0,"3SaR")
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,4096,"LANGUAGE=PCL") \
contains(0,4096,"LANGUAGE = PCL")))
(contains(0,1024,"LANGUAGE=PCL") \
contains(0,1024,"LANGUAGE = PCL")))
########################################################################
#
# Raw print file support...
#
# Comment the following type to prevent raw file printing.
# Uncomment the following type and the application/octet-stream
# filter line in mime.convs to allow raw file printing without the
# -oraw option.
#
application/octet-stream
#application/octet-stream
#
# End of "$Id: mime.types 4590 2005-08-24 19:25:49Z mike $".
#
-3
Ver Arquivo
@@ -1,3 +0,0 @@
@include common-auth
@include common-account
@include common-session
+3
Ver Arquivo
@@ -0,0 +1,3 @@
#%PAM-1.0
auth required pam_unix.so shadow nodelay nullok
account required pam_unix.so
-5
Ver Arquivo
@@ -1,5 +0,0 @@
# cups: auth account password session
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
+1 -1
Ver Arquivo
@@ -1,2 +1,2 @@
auth required @PAMMODAUTH@
auth required @PAMMOD@ nullok shadow
account required @PAMMOD@
-7
Ver Arquivo
@@ -1,7 +0,0 @@
#
# SNMP configuration file for CUPS. See "man cups-snmp.conf" for a complete
# description of this file.
#
@CUPS_SNMP_ADDRESS@
@CUPS_SNMP_COMMUNITY@
+127 -335
Ver Arquivo
@@ -1,29 +1,44 @@
dnl
dnl Common configuration stuff for CUPS.
dnl "$Id: cups-common.m4 5288 2006-03-14 02:38:07Z mike $"
dnl
dnl Copyright © 2007-2019 by Apple Inc.
dnl Copyright © 1997-2007 by Easy Software Products, all rights reserved.
dnl Common configuration stuff for the Common UNIX Printing System (CUPS).
dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
dnl information.
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 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
dnl We need at least autoconf 2.50...
AC_PREREQ(2.50)
dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h)
dnl Version number information...
CUPS_VERSION="AC_PACKAGE_VERSION"
dnl Versio number information...
CUPS_VERSION="1.2svn"
CUPS_REVISION=""
CUPS_BUILD="cups-$CUPS_VERSION"
AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
CUPS_BUILD="$withval")
if test -z "$CUPS_REVISION" -a -d .svn; then
CUPS_REVISION="-r`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[[a-zA-Z]]*//g'`"
fi
AC_SUBST(CUPS_VERSION)
AC_SUBST(CUPS_REVISION)
AC_SUBST(CUPS_BUILD)
AC_DEFINE_UNQUOTED(CUPS_SVERSION, "AC_PACKAGE_NAME v$CUPS_VERSION$CUPS_REVISION")
AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "AC_PACKAGE_NAME/$CUPS_VERSION$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:=}"
@@ -33,32 +48,24 @@ LDFLAGS="${LDFLAGS:=}"
dnl Checks for programs...
AC_PROG_AWK
AC_PROG_CC(clang cc gcc)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXX(clang++ c++ g++)
AC_PROG_INSTALL
if test "$INSTALL" = "$ac_install_sh"; then
# Use full path to install-sh script...
INSTALL="`pwd`/install-sh -c"
fi
AC_PROG_RANLIB
AC_PATH_PROG(AR,ar)
AC_PATH_PROG(CHMOD,chmod)
AC_PATH_PROG(GZIPPROG,gzip)
AC_MSG_CHECKING(for install-sh script)
INSTALL="`pwd`/install-sh"
AC_SUBST(INSTALL)
AC_MSG_RESULT(using $INSTALL)
AC_PATH_PROG(HTMLDOC,htmldoc)
AC_PATH_PROG(LD,ld)
AC_PATH_PROG(LN,ln)
AC_PATH_PROG(MKDIR,mkdir)
AC_PATH_PROG(MV,mv)
AC_PATH_PROG(RM,rm)
AC_PATH_PROG(RMDIR,rmdir)
AC_PATH_PROG(SED,sed)
AC_PATH_PROG(XDGOPEN,xdg-open)
if test "x$XDGOPEN" = x; then
CUPS_HTMLVIEW="htmlview"
else
CUPS_HTMLVIEW="$XDGOPEN"
fi
AC_SUBST(CUPS_HTMLVIEW)
AC_PATH_PROG(STRIP,strip)
if test "x$AR" = x; then
AC_MSG_ERROR([Unable to find required library archive command.])
@@ -66,42 +73,42 @@ fi
if test "x$CC" = x; then
AC_MSG_ERROR([Unable to find required C compiler command.])
fi
if test "x$CXX" = x; then
AC_MSG_ERROR([Unable to find required C++ compiler command.])
fi
dnl Static library option...
INSTALLSTATIC=""
AC_ARG_ENABLE(static, [ --enable-static install static libraries])
AC_ARG_ENABLE(install_static, [ --enable-static install static libraries, default=no])
if test x$enable_static = xyes; then
echo Installing static libraries...
if test x$enable_install_static = xyes; then
INSTALLSTATIC="installstatic"
fi
AC_SUBST(INSTALLSTATIC)
dnl Check for pkg-config, which is used for some other tests later on...
AC_PATH_TOOL(PKGCONFIG, pkg-config)
dnl Check for libraries...
AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
AC_SEARCH_LIBS(crypt, crypt)
AC_SEARCH_LIBS(fmod, m)
AC_SEARCH_LIBS(getspent, sec gen)
LIBMALLOC=""
AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo turn on malloc debug information, default=no])
if test x$enable_mallinfo = xyes; then
SAVELIBS="$LIBS"
LIBS=""
AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
LIBMALLOC="$LIBS"
LIBS="$SAVELIBS"
AC_CHECK_LIB(c,mallinfo,LIBS="$LIBS"; AC_DEFINE(HAVE_MALLINFO),LIBS="$LIBS")
if test "$ac_cv_lib_c_mallinfo" = "no"; then
AC_CHECK_LIB(malloc,mallinfo,
LIBS="$LIBS"
LIBMALLOC="-lmalloc"
AC_DEFINE(HAVE_MALLINFO),
LIBS="$LIBS")
fi
fi
AC_SUBST(LIBMALLOC)
dnl Check for libpaper support...
AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
AC_ARG_ENABLE(libpaper, [ --enable-libpaper turn on libpaper support, default=no])
if test x$enable_libpaper = xyes; then
AC_CHECK_LIB(paper,systempapername,
@@ -115,61 +122,36 @@ AC_SUBST(LIBPAPER)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
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))
AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_H))
AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
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))
dnl Checks for iconv.h and iconv_open
AC_CHECK_HEADER(iconv.h,
SAVELIBS="$LIBS"
LIBS=""
AC_SEARCH_LIBS(iconv_open,iconv,
AC_DEFINE(HAVE_ICONV_H)
SAVELIBS="$SAVELIBS $LIBS")
AC_SEARCH_LIBS(libiconv_open,iconv,
AC_DEFINE(HAVE_ICONV_H)
SAVELIBS="$SAVELIBS $LIBS")
LIBS="$SAVELIBS")
dnl Checks for statfs and its many headers...
AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
AC_CHECK_FUNCS(statfs statvfs)
dnl Checks for string functions.
AC_CHECK_FUNCS(strdup strlcat strlcpy)
if test "$host_os_name" = "hp-ux" -a "$host_os_version" = "1020"; then
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strlcat strlcpy)
if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
echo Forcing snprintf emulation for HP-UX.
else
AC_CHECK_FUNCS(snprintf vsnprintf)
fi
dnl Check for random number functions...
AC_CHECK_FUNCS(random lrand48 arc4random)
dnl Checks for mkstemp and mkstemps functions.
AC_CHECK_FUNCS(mkstemp mkstemps)
dnl Check for geteuid function.
AC_CHECK_FUNCS(geteuid)
dnl Check for setpgid function.
AC_CHECK_FUNCS(setpgid)
dnl Check for vsyslog function.
AC_CHECK_FUNCS(vsyslog)
dnl Checks for signal functions.
case "$host_os_name" in
linux* | gnu*)
case "$uname" in
Linux | GNU)
# Do not use sigset on Linux or GNU HURD
;;
*)
@@ -181,13 +163,8 @@ esac
AC_CHECK_FUNCS(sigaction)
dnl Checks for wait functions.
AC_CHECK_FUNCS(waitpid wait3)
dnl Check for posix_spawn
AC_CHECK_FUNCS(posix_spawn)
dnl Check for getgrouplist
AC_CHECK_FUNCS(getgrouplist)
AC_CHECK_FUNCS(waitpid)
AC_CHECK_FUNCS(wait3)
dnl See if the tm structure has the tm_gmtoff member...
AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
@@ -197,76 +174,9 @@ AC_TRY_COMPILE([#include <time.h>],[struct tm t;
AC_DEFINE(HAVE_TM_GMTOFF),
AC_MSG_RESULT(no))
dnl See if the stat structure has the st_gen member...
AC_MSG_CHECKING(for st_gen member in stat structure)
AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
int o = t.st_gen;],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ST_GEN),
AC_MSG_RESULT(no))
dnl See if we have the removefile(3) function for securely removing files
AC_CHECK_FUNCS(removefile)
dnl See if we have libusb...
AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
LIBUSB=""
USBQUIRKS=""
AC_SUBST(LIBUSB)
AC_SUBST(USBQUIRKS)
if test "x$PKGCONFIG" != x; then
if test x$enable_libusb != xno -a $host_os_name != darwin; then
AC_MSG_CHECKING(for libusb-1.0)
if $PKGCONFIG --exists libusb-1.0; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LIBUSB)
CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
USBQUIRKS="\$(DATADIR)/usb"
else
AC_MSG_RESULT(no)
if test x$enable_libusb = xyes; then
AC_MSG_ERROR(libusb required for --enable-libusb.)
fi
fi
fi
elif test x$enable_libusb = xyes; then
AC_MSG_ERROR(Need pkg-config to enable libusb support.)
fi
dnl See if we have libwrap for TCP wrappers support...
AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
LIBWRAP=""
AC_SUBST(LIBWRAP)
if test x$enable_tcp_wrappers = xyes; then
AC_CHECK_LIB(wrap, hosts_access,[
AC_CHECK_HEADER(tcpd.h,
AC_DEFINE(HAVE_TCPD_H)
LIBWRAP="-lwrap")])
fi
dnl ZLIB
INSTALL_GZIP=""
LIBZ=""
AC_CHECK_HEADER(zlib.h,
AC_CHECK_LIB(z, gzgets,[
AC_DEFINE(HAVE_LIBZ)
LIBZ="-lz"
LIBS="$LIBS -lz"
AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
if test "x$GZIPPROG" != x; then
INSTALL_GZIP="-z"
fi]))
AC_SUBST(INSTALL_GZIP)
AC_SUBST(LIBZ)
dnl Flags for "ar" command...
case $host_os_name in
darwin* | *bsd*)
case $uname in
Darwin* | *BSD*)
ARFLAGS="-rcv"
;;
*)
@@ -276,201 +186,83 @@ esac
AC_SUBST(ARFLAGS)
dnl Prep libraries specifically for cupsd and backends...
BACKLIBS=""
SERVERLIBS=""
AC_SUBST(BACKLIBS)
AC_SUBST(SERVERLIBS)
dnl See if we have POSIX ACL support...
SAVELIBS="$LIBS"
LIBS=""
AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
if test "x$enable_acl" != xno; then
AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
SERVERLIBS="$SERVERLIBS $LIBS"
fi
LIBS="$SAVELIBS"
dnl Check for DBUS support
DBUSDIR=""
DBUS_NOTIFIER=""
DBUS_NOTIFIERLIBS=""
AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
DBUSDIR="$withval")
if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$host_os_name" != xdarwin; 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"
SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
DBUS_NOTIFIER="dbus"
DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
SAVELIBS="$LIBS"
LIBS="$LIBS $DBUS_NOTIFIERLIBS"
AC_CHECK_FUNC(dbus_message_iter_init_append,
AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
AC_CHECK_FUNC(dbus_threads_init,
AC_DEFINE(HAVE_DBUS_THREADS_INIT))
LIBS="$SAVELIBS"
if test -d /etc/dbus-1 -a "x$DBUSDIR" = x; then
DBUSDIR="/etc/dbus-1"
fi
else
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(DBUSDIR)
AC_SUBST(DBUS_NOTIFIER)
AC_SUBST(DBUS_NOTIFIERLIBS)
dnl Extra platform-specific libraries...
CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
CUPS_DEFAULT_SYSTEM_AUTHKEY=""
CUPS_SYSTEM_AUTHKEY=""
INSTALLXPC=""
BACKLIBS=""
CUPSDLIBS=""
DBUSDIR=""
case $host_os_name in
darwin*)
BACKLIBS="$BACKLIBS -framework IOKit"
SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
LIBS="-framework CoreFoundation -framework Security $LIBS"
AC_ARG_ENABLE(dbus, [ --enable-dbus enable DBUS support, default=auto])
case $uname in
Darwin*)
BACKLIBS="-framework IOKit"
CUPSDLIBS="-framework IOKit -framework SystemConfiguration"
LIBS="-framework CoreFoundation $LIBS"
dnl Check for CFLocaleCreateCanonicalLocaleIdentifierFromString...
AC_MSG_CHECKING(for CFLocaleCreateCanonicalLocaleIdentifierFromString)
if test "$uname" = "Darwin" -a $uversion -ge 70; then
AC_DEFINE(HAVE_CF_LOCALE_ID)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl Check for framework headers...
AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
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 dynamic store function...
SAVELIBS="$LIBS"
LIBS="-framework SystemConfiguration $LIBS"
AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName,[
AC_DEFINE(HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME)],[
LIBS="$SAVELIBS"])
dnl Check for the new membership functions in MacOSX 10.4...
dnl Check for the new membership functions in MacOSX 10.4 (Tiger)...
AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_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"
CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
else
CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
fi
if test "x$default_operkey" != xdefault; then
CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
else
CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
fi])
dnl Check for sandbox/Seatbelt support
if test $host_os_version -ge 100; then
AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
fi
if test $host_os_version -ge 110 -a $host_os_version -lt 120; then
# Broken public headers in 10.7.x...
AC_MSG_CHECKING(for sandbox/private.h presence)
if test -f /usr/local/include/sandbox/private.h; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
fi
fi
dnl Check for XPC support
AC_CHECK_HEADER(xpc/xpc.h,
AC_DEFINE(HAVE_XPC)
INSTALLXPC="install-xpc")
;;
esac
AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
AC_SUBST(CUPS_SYSTEM_AUTHKEY)
AC_SUBST(INSTALLXPC)
dnl Check for build components
COMPONENTS="all"
AC_ARG_WITH(components, [ --with-components set components to build:
- "all" (default) builds everything
- "core" builds libcups and ipptool
- "libcups" builds just libcups
- "libcupslite" builds just libcups without driver support],
COMPONENTS="$withval")
cupsimagebase="cupsimage"
IPPEVECOMMANDS="ippevepcl ippeveps"
LIBCUPSOBJS="\$(COREOBJS) \$(DRIVEROBJS)"
LIBHEADERS="\$(COREHEADERS) \$(DRIVERHEADERS)"
LIBHEADERSPRIV="\$(COREHEADERSPRIV) \$(DRIVERHEADERSPRIV)"
case "$COMPONENTS" in
all)
BUILDDIRS="tools filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
;;
core)
BUILDDIRS="tools examples locale"
;;
corelite)
AC_DEFINE(CUPS_LITE)
BUILDDIRS="tools examples locale"
cupsimagebase=""
LIBCUPSOBJS="\$(COREOBJS)"
LIBHEADERS="\$(COREHEADERS)"
LIBHEADERSPRIV="\$(COREHEADERSPRIV)"
;;
libcups)
BUILDDIRS="locale"
cupsimagebase=""
;;
libcupslite)
AC_DEFINE(CUPS_LITE)
BUILDDIRS="locale"
cupsimagebase=""
LIBCUPSOBJS="\$(COREOBJS)"
LIBHEADERS="\$(COREHEADERS)"
LIBHEADERSPRIV="\$(COREHEADERSPRIV)"
;;
*)
AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
Linux*)
dnl Check for DBUS support
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_CHECK_LIB(dbus-1,
dbus_message_iter_init_append,
AC_DEFINE(HAVE_DBUS)
CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
CUPSDLIBS="`$PKGCONFIG --libs dbus-1`"
DBUSDIR="/etc/dbus-1/system.d")
else
AC_MSG_RESULT(no)
fi
fi
fi
;;
esac
AC_SUBST(BUILDDIRS)
AC_SUBST(IPPEVECOMMANDS)
AC_SUBST(LIBCUPSOBJS)
AC_SUBST(LIBHEADERS)
AC_SUBST(LIBHEADERSPRIV)
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"
AC_SUBST(BACKLIBS)
AC_SUBST(CUPSDLIBS)
AC_SUBST(DBUSDIR)
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-common.m4 5288 2006-03-14 02:38:07Z mike $".
dnl
+424 -178
Ver Arquivo
@@ -1,196 +1,443 @@
dnl
dnl Compiler stuff for CUPS.
dnl "$Id: cups-compiler.m4 5288 2006-03-14 02:38:07Z mike $"
dnl
dnl Copyright 2007-2018 by Apple Inc.
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
dnl Compiler stuff for the Common UNIX Printing System (CUPS).
dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
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 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
dnl Clear the debugging and non-shared library options unless the user asks
dnl for them...
INSTALL_STRIP=""
AC_SUBST(INSTALL_STRIP)
AC_ARG_WITH(optim, [ --with-optim set optimization flags ],
OPTIM="$withval",
OPTIM="")
ARCHFLAGS=""
OPTIM=""
AC_SUBST(ARCHFLAGS)
AC_SUBST(OPTIM)
AC_ARG_ENABLE(debug, [ --enable-debug build with debugging symbols])
AC_ARG_ENABLE(debug_guards, [ --enable-debug-guards build with memory allocation guards])
AC_ARG_ENABLE(debug_printfs, [ --enable-debug-printfs build with CUPS_DEBUG_LOG support])
AC_ARG_ENABLE(unit_tests, [ --enable-unit-tests build and run unit tests])
AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
AC_ARG_WITH(archflags, [ --with-arch="flags" set default architecture flags ])
dnl For debugging, keep symbols, otherwise strip them...
if test x$enable_debug = xyes -a "x$OPTIM" = x; then
OPTIM="-g"
else
INSTALL_STRIP="-s"
fi
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
[if test x$enable_debug = xyes; then
OPTIM="-g"
fi])
dnl Debug printfs can slow things down, so provide a separate option for that
if test x$enable_debug_printfs = xyes; then
CFLAGS="$CFLAGS -DDEBUG"
CXXFLAGS="$CXXFLAGS -DDEBUG"
fi
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])
AC_ARG_WITH(arch32flags, [ --with-arch32="flags" specifies 32-bit architecture flags])
dnl Debug guards use an extra 4 bytes for some structures like strings in the
dnl string pool, so provide a separate option for that
if test x$enable_debug_guards = xyes; then
CFLAGS="$CFLAGS -DDEBUG_GUARDS"
CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS"
fi
ARCH32FLAGS=""
INSTALL32=""
LIB32CUPS=""
LIB32CUPSIMAGE=""
LIB32DIR=""
UNINSTALL32=""
dnl Unit tests take up time during a compile...
if test x$enable_unit_tests = xyes; then
if test "$build" != "$host"; then
AC_MSG_ERROR([Sorry, cannot build unit tests when cross-compiling.])
fi
AC_SUBST(ARCH32FLAGS)
AC_SUBST(INSTALL32)
AC_SUBST(LIB32CUPS)
AC_SUBST(LIB32CUPSIMAGE)
AC_SUBST(LIB32DIR)
AC_SUBST(UNINSTALL32)
UNITTESTS="unittests"
else
UNITTESTS=""
fi
AC_SUBST(UNITTESTS)
AC_ARG_ENABLE(64bit, [ --enable-64bit generate 64-bit libraries on 32/64-bit systems, default=no])
AC_ARG_WITH(arch64flags, [ --with-arch64="flags" specifies 64-bit architecture flags])
dnl Setup general architecture flags...
AC_ARG_WITH(archflags, [ --with-archflags set default architecture flags ])
AC_ARG_WITH(ldarchflags, [ --with-ldarchflags set program architecture flags ])
ARCH64FLAGS=""
INSTALL64=""
LIB64CUPS=""
LIB64CUPSIMAGE=""
LIB64DIR=""
UNINSTALL64=""
if test -z "$with_archflags"; then
ARCHFLAGS=""
else
ARCHFLAGS="$with_archflags"
fi
AC_SUBST(ARCH64FLAGS)
AC_SUBST(INSTALL64)
AC_SUBST(LIB64CUPS)
AC_SUBST(LIB64CUPSIMAGE)
AC_SUBST(LIB64DIR)
AC_SUBST(UNINSTALL64)
if test -z "$with_ldarchflags"; then
if test "$host_os_name" = darwin; then
# Only create Intel programs by default
LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch ppc64//'`"
else
LDARCHFLAGS="$ARCHFLAGS"
fi
else
LDARCHFLAGS="$with_ldarchflags"
fi
AC_SUBST(ARCHFLAGS)
AC_SUBST(LDARCHFLAGS)
dnl Read-only data/program support on Linux...
AC_ARG_ENABLE(relro, [ --enable-relro build with the GCC relro option])
dnl Clang/GCC address sanitizer...
AC_ARG_ENABLE(sanitizer, [ --enable-sanitizer build with AddressSanitizer])
dnl Position-Independent Executable support on Linux and *BSD...
AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fpie option, default=no])
dnl Update compiler options...
CXXLIBS="${CXXLIBS:=}"
CXXLIBS=""
AC_SUBST(CXXLIBS)
PIEFLAGS=""
AC_SUBST(PIEFLAGS)
RELROFLAGS=""
AC_SUBST(RELROFLAGS)
WARNING_OPTIONS=""
AC_SUBST(WARNING_OPTIONS)
if test -n "$GCC"; then
# Add GCC-specific compiler options...
# Address sanitizer is a useful tool to use when developing/debugging
# code but adds about 2x overhead...
if test x$enable_sanitizer = xyes; then
# Use -fsanitize=address with debugging...
OPTIM="$OPTIM -g -fsanitize=address"
else
# Otherwise use the Fortify enhancements to catch any unbounded
# string operations...
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
fi
# Default optimization options...
if test -z "$OPTIM"; then
# Default to optimize-for-size and debug
OPTIM="-Os -g"
if test "x$with_optim" = x; then
# 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; then
if test $PICFLAG = 1 -a $uname != AIX; then
OPTIM="-fPIC $OPTIM"
fi
# 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(whether compiler supports -fstack-protector)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector"
AC_TRY_LINK(,,
if test "x$LSB_BUILD" = xy; then
# Can't use stack-protector with LSB binaries...
OPTIM="$OPTIM -fno-stack-protector"
else
OPTIM="$OPTIM -fstack-protector"
fi
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
if test "x$LSB_BUILD" != xy; then
# The -fPIE 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.
#
# Not available to LSB binaries...
AC_MSG_CHECKING(whether compiler supports -fPIE)
OLDCFLAGS="$CFLAGS"
case "$host_os_name" in
darwin*)
CFLAGS="$CFLAGS -fPIE -Wl,-pie"
AC_TRY_COMPILE(,,[
PIEFLAGS="-fPIE -Wl,-pie"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
;;
*)
CFLAGS="$CFLAGS -fPIE -pie"
AC_TRY_COMPILE(,,[
PIEFLAGS="-fPIE -pie"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
;;
esac
CFLAGS="$OLDCFLAGS"
fi
# Add useful warning options for tracking down problems...
WARNING_OPTIONS="-Wall -Wno-format-y2k -Wunused -Wno-unused-result -Wsign-conversion"
# Test GCC version for certain warning flags since -Werror
# doesn't trigger...
gccversion=`$CC --version | head -1 | awk '{print $NF}'`
case "$gccversion" in
7.* | 8.*)
WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-tautological-compare"
case $uname in
Linux*)
if test x$enable_pie = xyes; then
OPTIM="$OPTIM -fpie"
LDFLAGS="$LDFLAGS -pie"
fi
;;
esac
# Additional warning options for development testing...
if test -d .git; then
WARNING_OPTIONS="-Werror -Wno-error=deprecated-declarations $WARNING_OPTIONS"
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 alpha testing...
OPTIM="-Wshadow -Wunused $OPTIM"
fi
case "$uname" in
Darwin*)
if test -z "$with_archflags"; then
if test "x`uname -m`" = xi386; then
# Build universal binaries for OSX on Intel...
ARCHFLAGS="-arch i386 -arch ppc"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL32="install32bit"
LIB32CUPS="libcups.32.so.2"
LIB32CUPSIMAGE="libcupsimage.32.so.2"
LIB32DIR="$prefix/lib32"
UNINSTALL32="uninstall32bit"
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-64 -mips4"
else
ARCHFLAGS="$with_arch64flags"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL64="install64bit"
LIB64CUPS="libcups.64.so.2"
LIB64CUPSIMAGE="libcupsimage.64.so.2"
LIB64DIR="$prefix/lib64"
UNINSTALL64="uninstall64bit"
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-n32 -mips3"
else
ARCHFLAGS="$with_arch32flags"
fi
else
ARCHFLAGS="$with_archflags"
fi
fi
;;
Linux*)
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
INSTALL32="install32bit"
LIB32CUPS="libcups.32.so.2"
LIB32CUPSIMAGE="libcupsimage.32.so.2"
LIB32DIR="$exec_prefix/lib"
if test -d /usr/lib32; then
LIB32DIR="${LIB32DIR}32"
fi
UNINSTALL32="uninstall32bit"
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-m64"
else
ARCHFLAGS="$with_arch64flags"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL64="install64bit"
LIB64CUPS="libcups.64.so.2"
LIB64CUPSIMAGE="libcupsimage.64.so.2"
LIB64DIR="$exec_prefix/lib"
if test -d /usr/lib64; then
LIB64DIR="${LIB64DIR}64"
fi
UNINSTALL64="uninstall64bit"
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-m32"
else
ARCHFLAGS="$with_arch32flags"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL32="install32bit"
LIB32CUPS="libcups.32.so.2"
LIB32CUPSIMAGE="libcupsimage.32.so.2"
LIB32DIR="$exec_prefix/lib/32"
UNINSTALL32="uninstall32bit"
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-m64"
else
ARCHFLAGS="$with_arch64flags"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL64="install64bit"
LIB64CUPS="libcups.64.so.2"
LIB64CUPSIMAGE="libcupsimage.64.so.2"
LIB64DIR="$exec_prefix/lib/64"
UNINSTALL64="uninstall64bit"
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-m32"
else
ARCHFLAGS="$with_arch32flags"
fi
else
ARCHFLAGS="$with_archflags"
fi
fi
;;
esac
else
# Add vendor-specific compiler options...
case $host_os_name in
sunos*)
case $uname in
AIX*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O2 -qmaxmem=6000"
else
OPTIM="$with_optim $OPTIM"
fi
fi
;;
HP-UX*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="+O2"
else
OPTIM="$with_optim $OPTIM"
fi
fi
CFLAGS="-Ae $CFLAGS"
# Warning 336 is "empty translation unit"
# Warning 829 is passing constant string as char *
CXXFLAGS="+W336,829 $CXXFLAGS"
if test "x$with_optim" = x; then
OPTIM="+DAportable $OPTIM"
fi
if test $PICFLAG = 1; then
OPTIM="+z $OPTIM"
fi
;;
IRIX)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O2"
else
OPTIM="$with_optim $OPTIM"
fi
fi
if test "x$with_optim" = x; then
OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
fi
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
INSTALL32="install32bit"
LIB32CUPS="libcups.32.so.2"
LIB32CUPSIMAGE="libcupsimage.32.so.2"
LIB32DIR="$prefix/lib32"
UNINSTALL32="uninstall32bit"
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-64 -mips4"
else
ARCHFLAGS="$with_arch64flags"
fi
else
ARCHFLAGS="$with_archflags"
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
INSTALL64="install64bit"
LIB64CUPS="libcups.64.so.2"
LIB64CUPSIMAGE="libcupsimage.64.so.2"
LIB64DIR="$prefix/lib64"
UNINSTALL64="uninstall64bit"
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-n32 -mips3"
else
ARCHFLAGS="$with_arch32flags"
fi
else
ARCHFLAGS="$with_archflags"
fi
fi
;;
SunOS*)
# Solaris
if test -z "$OPTIM"; then
OPTIM="-xO2"
if test "x$with_optim" = x; then
OPTIM="-xO4"
else
OPTIM="$with_optim $OPTIM"
fi
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"
INSTALL32="install32bit"
LIB32CUPS="libcups.32.so.2"
LIB32CUPSIMAGE="libcupsimage.32.so.2"
LIB32DIR="$exec_prefix/lib/32"
UNINSTALL32="uninstall32bit"
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"
CFLAGS="-xarch=generic64 $CFLAGS"
fi
else
if test "x$enable_64bit" = xyes; then
# Build 64-bit libraries...
ARCH64FLAGS="-xarch=generic64"
INSTALL64="install64bit"
LIB64CUPS="libcups.64.so.2"
LIB64CUPSIMAGE="libcupsimage.64.so.2"
LIB64DIR="$exec_prefix/lib/64"
UNINSTALL64="uninstall64bit"
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"
CFLAGS="-xarch=generic $CFLAGS"
fi
else
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"
CFLAGS="-xarch=generic $CFLAGS"
fi
fi
fi
;;
UNIX_SVR*)
# UnixWare
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O"
else
OPTIM="$with_optim $OPTIM"
fi
fi
if test $PICFLAG = 1; then
@@ -198,28 +445,27 @@ else
fi
;;
*)
# Running some other operating system; inform the user
# they should contribute the necessary options via
# Github...
echo "Building CUPS with default compiler optimizations; contact the CUPS developers on Github"
echo "(https://github.com/apple/cups/issues) with the uname and compiler options needed for"
echo "your platform, or set the CFLAGS and LDFLAGS environment variables before running"
echo "configure."
# Running some other operating system; inform the user they
# should contribute the necessary options to
# 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."
;;
esac
fi
# Add general compiler options per platform...
case $host_os_name in
linux*)
# glibc 2.8 and higher breaks peer credentials unless you
# define _GNU_SOURCE...
OPTIM="$OPTIM -D_GNU_SOURCE"
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"
# 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,-z,now"
fi
;;
esac
# 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
dnl
dnl End of "$Id: cups-compiler.m4 5288 2006-03-14 02:38:07Z mike $".
dnl
+112 -330
Ver Arquivo
@@ -1,130 +1,54 @@
dnl
dnl Default cupsd configuration settings for CUPS.
dnl "$Id$"
dnl
dnl Copyright © 2007-2018 by Apple Inc.
dnl Copyright © 2006-2007 by Easy Software Products, all rights reserved.
dnl Default cupsd configuration settings for the Common UNIX Printing System
dnl (CUPS).
dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
dnl information.
dnl Copyright 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 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
dnl Default languages...
LANGUAGES="`ls -1 locale/cups_*.po 2>/dev/null | 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])
dnl Default langugages...
AC_ARG_WITH(languages, [ --with-languages set installed languages, default="es ja" ],
LANGUAGES="$withval",
LANGUAGES="es ja")
AC_SUBST(LANGUAGES)
dnl macOS bundle-based localization support
AC_ARG_WITH(bundledir, [ --with-bundledir set localization bundle directory ],
CUPS_BUNDLEDIR="$withval",[
if test "x$host_os_name" = xdarwin -a $host_os_version -ge 100; then
CUPS_BUNDLEDIR="/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A"
LANGUAGES=""
else
CUPS_BUNDLEDIR=""
fi])
AC_SUBST(CUPS_BUNDLEDIR)
if test "x$CUPS_BUNDLEDIR" != x; then
AC_DEFINE_UNQUOTED(CUPS_BUNDLEDIR, "$CUPS_BUNDLEDIR")
fi
AC_ARG_WITH(bundlelang, [ --with-bundlelang set localization bundle base language (English or en) ],
cups_bundlelang="$withval",[
if test $host_os_version -ge 190; then
cups_bundlelang="en"
else
cups_bundlelang="English"
fi])
if test "x$cups_bundlelang" != x -a "x$CUPS_BUNDLEDIR" != x; then
CUPS_RESOURCEDIR="$CUPS_BUNDLEDIR/Resources/$cups_bundlelang.lproj"
else
CUPS_RESOURCEDIR=""
fi
AC_SUBST(CUPS_RESOURCEDIR)
dnl Default executable file permissions
AC_ARG_WITH(exe_file_perm, [ --with-exe-file-perm set default executable permissions value, default=0555],
CUPS_EXE_FILE_PERM="$withval",
[case "$host_os_name" in
linux* | gnu*)
CUPS_EXE_FILE_PERM="755"
;;
*)
CUPS_EXE_FILE_PERM="555"
;;
esac])
AC_SUBST(CUPS_EXE_FILE_PERM)
dnl Default ConfigFilePerm
AC_ARG_WITH(config_file_perm, [ --with-config-file-perm set default ConfigFilePerm value, default=0640],
AC_ARG_WITH(config_perm, [ --with-config-file-perm set default ConfigFilePerm value, default=0640],
CUPS_CONFIG_FILE_PERM="$withval",
[if test "x$host_os_name" = xdarwin; then
if test "x$uname" = xDarwin; then
CUPS_CONFIG_FILE_PERM="644"
else
CUPS_CONFIG_FILE_PERM="640"
fi])
fi)
AC_SUBST(CUPS_CONFIG_FILE_PERM)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, 0$CUPS_CONFIG_FILE_PERM)
dnl Default permissions for cupsd
AC_ARG_WITH(cupsd_file_perm, [ --with-cupsd-file-perm set default cupsd permissions, default=0500],
CUPS_CUPSD_FILE_PERM="$withval",
[case "$host_os_name" in
linux* | gnu*)
CUPS_CUPSD_FILE_PERM="700"
;;
*)
CUPS_CUPSD_FILE_PERM="500"
;;
esac])
AC_SUBST(CUPS_CUPSD_FILE_PERM)
dnl Default LogFilePerm
AC_ARG_WITH(log_file_perm, [ --with-log-file-perm set default LogFilePerm value, default=0644],
AC_ARG_WITH(log_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 FatalErrors
AC_ARG_WITH(fatal_errors, [ --with-fatal-errors set default FatalErrors value, default=config],
CUPS_FATAL_ERRORS="$withval",
CUPS_FATAL_ERRORS="config")
AC_SUBST(CUPS_FATAL_ERRORS)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_FATAL_ERRORS, "$CUPS_FATAL_ERRORS")
dnl Default LogLevel
AC_ARG_WITH(log_level, [ --with-log-level set default LogLevel value, default=warn],
CUPS_LOG_LEVEL="$withval",
CUPS_LOG_LEVEL="warn")
AC_SUBST(CUPS_LOG_LEVEL)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_LEVEL, "$CUPS_LOG_LEVEL")
dnl Default AccessLogLevel
AC_ARG_WITH(access_log_level, [ --with-access-log-level set default AccessLogLevel value, default=none],
CUPS_ACCESS_LOG_LEVEL="$withval",
CUPS_ACCESS_LOG_LEVEL="none")
AC_SUBST(CUPS_ACCESS_LOG_LEVEL)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_ACCESS_LOG_LEVEL, "$CUPS_ACCESS_LOG_LEVEL")
dnl Default PageLogFormat
AC_ARG_ENABLE(page_logging, [ --enable-page-logging enable page_log by default])
if test "x$enable_page_logging" = xyes; then
CUPS_PAGE_LOG_FORMAT=""
else
CUPS_PAGE_LOG_FORMAT="PageLogFormat"
fi
AC_SUBST(CUPS_PAGE_LOG_FORMAT)
dnl Default Browsing
AC_ARG_ENABLE(browsing, [ --disable-browsing disable Browsing by default])
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)
@@ -135,31 +59,35 @@ fi
AC_SUBST(CUPS_BROWSING)
dnl Default BrowseLocalProtocols
AC_ARG_WITH(local_protocols, [ --with-local-protocols set default BrowseLocalProtocols, default=""],
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$DNSSD_BACKEND" != "x"; then
CUPS_BROWSE_LOCAL_PROTOCOLS="dnssd"
else
CUPS_BROWSE_LOCAL_PROTOCOLS=""
fi
else
CUPS_BROWSE_LOCAL_PROTOCOLS="$default_local_protocols"
fi
else
CUPS_BROWSE_LOCAL_PROTOCOLS=""
fi
AC_ARG_WITH(browse_local, [ --with-local-protocols set default BrowseLocalProtocols, default="CUPS"],
CUPS_BROWSE_LOCAL_PROTOCOLS="$withval",
CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS")
AC_SUBST(CUPS_BROWSE_LOCAL_PROTOCOLS)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS,
"$CUPS_BROWSE_LOCAL_PROTOCOLS")
dnl Default BrowseRemoteProtocols
AC_ARG_WITH(browse_remote, [ --with-remote-protocols set default BrowseRemoteProtocols, default="CUPS"],
CUPS_BROWSE_REMOTE_PROTOCOLS="$withval",
CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS")
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, [ --disable-default-shared
disable DefaultShared by default])
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)
@@ -169,18 +97,35 @@ else
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(network_default, [ --enable-use-network-default
enable UseNetworkDefault by default, default=yes])
if test "x$enable_network_default" = xno; then
CUPS_USE_NETWORK_DEFAULT="No"
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USE_NETWORK_DEFAULT, 0)
else
CUPS_USE_NETWORK_DEFAULT="Yes"
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_USE_NETWORK_DEFAULT, 1)
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],
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$host_os_name = 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
if test -f /etc/passwd; then
CUPS_USER=""
for user in lp lpd guest daemon nobody; do
if test "`grep \^${user}: /etc/passwd`" != ""; then
@@ -199,22 +144,16 @@ AC_ARG_WITH(cups_user, [ --with-cups-user set default user for CUPS],
AC_MSG_RESULT(no password file, using "$CUPS_USER")
fi)
if test "x$CUPS_USER" = "xroot" -o "x$CUPS_USER" = "x0"; then
AC_MSG_ERROR([The default user for CUPS cannot be root!])
fi
AC_ARG_WITH(cups_group, [ --with-cups-group set default group for CUPS],
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$host_os_name = xdarwin; then
if test x`id -g _lp 2>/dev/null` = x; then
CUPS_GROUP="lp";
if test -f /etc/group; then
if test x$uname = xDarwin; then
GROUP_LIST="nobody"
else
CUPS_GROUP="_lp";
GROUP_LIST="lp nobody"
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
@@ -233,49 +172,40 @@ AC_ARG_WITH(cups_group, [ --with-cups-group set default group for CUPS],
AC_MSG_RESULT(no group file, using "$CUPS_GROUP")
fi)
if test "x$CUPS_GROUP" = "xroot" -o "x$CUPS_GROUP" = "xwheel" -o "x$CUPS_GROUP" = "x0"; then
AC_MSG_ERROR([The default group for CUPS cannot be root!])
fi
AC_ARG_WITH(system_groups, [ --with-system-groups set default system groups for CUPS],
AC_ARG_WITH(system-groups, [ --with-system-groups set default system groups for CUPS],
CUPS_SYSTEM_GROUPS="$withval",
if test x$host_os_name = xdarwin; then
CUPS_SYSTEM_GROUPS="admin"
if test x$uname = xDarwin; then
GROUP_LIST="admin"
else
AC_MSG_CHECKING(for default system groups)
if test -f /etc/group; then
CUPS_SYSTEM_GROUPS=""
GROUP_LIST="lpadmin sys system root wheel"
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
GROUP_LIST="lpadmin sys system root"
fi
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")
AC_MSG_CHECKING(for default system groups)
if test -f /etc/group; then
CUPS_SYSTEM_GROUPS=""
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
else
done
if test "x$CUPS_SYSTEM_GROUPS" = x; then
CUPS_SYSTEM_GROUPS="$GROUP_LIST"
AC_MSG_RESULT(no group file, using "$CUPS_SYSTEM_GROUPS")
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)
CUPS_PRIMARY_SYSTEM_GROUP="`echo $CUPS_SYSTEM_GROUPS | awk '{print $1}'`"
for group in $CUPS_SYSTEM_GROUPS; do
if test "x$CUPS_GROUP" = "x$group"; then
AC_MSG_ERROR([The default system groups cannot contain the default CUPS group!])
fi
done
AC_SUBST(CUPS_USER)
AC_SUBST(CUPS_GROUP)
AC_SUBST(CUPS_SYSTEM_GROUPS)
@@ -285,155 +215,7 @@ 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 $host_os_name in
darwin*)
if test $host_os_version -ge 90; then
CUPS_DEFAULT_PRINTCAP="/Library/Preferences/org.cups.printers.plist"
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_SUBST(CUPS_DEFAULT_PRINTCAP)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTCAP, "$CUPS_DEFAULT_PRINTCAP")
dnl Default LPD config file...
AC_ARG_WITH(lpdconfigfile, [ --with-lpdconfigfile set default LPDConfigFile URI],
default_lpdconfigfile="$withval",
default_lpdconfigfile="default")
if test x$default_lpdconfigfile != xno; then
if test "x$default_lpdconfigfile" = "xdefault"; then
case $host_os_name in
darwin*)
CUPS_DEFAULT_LPD_CONFIG_FILE="launchd:///System/Library/LaunchDaemons/org.cups.cups-lpd.plist"
;;
*)
if test "x$XINETD" != x; then
CUPS_DEFAULT_LPD_CONFIG_FILE="xinetd://$XINETD/cups-lpd"
else
CUPS_DEFAULT_LPD_CONFIG_FILE=""
fi
;;
esac
else
CUPS_DEFAULT_LPD_CONFIG_FILE="$default_lpdconfigfile"
fi
else
CUPS_DEFAULT_LPD_CONFIG_FILE=""
fi
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LPD_CONFIG_FILE, "$CUPS_DEFAULT_LPD_CONFIG_FILE")
AC_SUBST(CUPS_DEFAULT_LPD_CONFIG_FILE)
dnl Default SMB config file...
AC_ARG_WITH(smbconfigfile, [ --with-smbconfigfile set default SMBConfigFile URI],
default_smbconfigfile="$withval",
default_smbconfigfile="default")
if test x$default_smbconfigfile != xno; then
if test "x$default_smbconfigfile" = "xdefault"; then
if test -f /etc/smb.conf; then
CUPS_DEFAULT_SMB_CONFIG_FILE="samba:///etc/smb.conf"
else
CUPS_DEFAULT_SMB_CONFIG_FILE=""
fi
else
CUPS_DEFAULT_SMB_CONFIG_FILE="$default_smbconfigfile"
fi
else
CUPS_DEFAULT_SMB_CONFIG_FILE=""
fi
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SMB_CONFIG_FILE, "$CUPS_DEFAULT_SMB_CONFIG_FILE")
AC_SUBST(CUPS_DEFAULT_SMB_CONFIG_FILE)
dnl Default MaxCopies value...
AC_ARG_WITH(max-copies, [ --with-max-copies set default max copies value, default=9999 ],
CUPS_MAX_COPIES="$withval",
CUPS_MAX_COPIES="9999")
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, [ --disable-raw-printing do not allow raw printing by default])
if test "x$enable_raw_printing" != xno; then
DEFAULT_RAW_PRINTING=""
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$host_os_name" = 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 port number for IPP, default=631 ],
DEFAULT_IPP_PORT="$withval",
DEFAULT_IPP_PORT="631")
AC_SUBST(DEFAULT_IPP_PORT)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT)
dnl Web interface...
AC_ARG_ENABLE(webif, [ --enable-webif enable the web interface by default, default=no for macOS])
case "x$enable_webif" in
xno)
CUPS_WEBIF=No
CUPS_DEFAULT_WEBIF=0
;;
xyes)
CUPS_WEBIF=Yes
CUPS_DEFAULT_WEBIF=1
;;
*)
if test $host_os_name = darwin; then
CUPS_WEBIF=No
CUPS_DEFAULT_WEBIF=0
else
CUPS_WEBIF=Yes
CUPS_DEFAULT_WEBIF=1
fi
;;
esac
AC_SUBST(CUPS_WEBIF)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_WEBIF, $CUPS_DEFAULT_WEBIF)
dnl
dnl End of "$Id$".
dnl
+126 -121
Ver Arquivo
@@ -1,10 +1,25 @@
dnl
dnl Directory stuff for CUPS.
dnl "$Id: cups-directories.m4 5314 2006-03-20 19:06:50Z mike $"
dnl
dnl Copyright 2007-2017 by Apple Inc.
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
dnl Directory stuff for the Common UNIX Printing System (CUPS).
dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
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 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
AC_PREFIX_DEFAULT(/)
@@ -42,15 +57,6 @@ 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
@@ -58,8 +64,6 @@ 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...
@@ -70,7 +74,7 @@ fi
dnl Fix "localstatedir" variable if it hasn't been specified...
if test "$localstatedir" = "\${prefix}/var"; then
if test "$prefix" = "/"; then
if test "$host_os_name" = darwin; then
if test "$uname" = Darwin; then
localstatedir="/private/var"
else
localstatedir="/var"
@@ -83,7 +87,7 @@ fi
dnl Fix "sysconfdir" variable if it hasn't been specified...
if test "$sysconfdir" = "\${prefix}/etc"; then
if test "$prefix" = "/"; then
if test "$host_os_name" = darwin; then
if test "$uname" = Darwin; then
sysconfdir="/private/etc"
else
sysconfdir="/etc"
@@ -93,76 +97,105 @@ if test "$sysconfdir" = "\${prefix}/etc"; then
fi
fi
dnl Fix "libdir" variable...
dnl Fix "libdir" variable for IRIX 6.x...
if test "$libdir" = "\${exec_prefix}/lib"; then
case "$host_os_name" in
linux*)
if test -d /usr/lib64 -a ! -d /usr/lib64/fakeroot; then
libdir="$exec_prefix/lib64"
if test "$uname" = "IRIX"; then
libdir="$exec_prefix/lib32"
else
if test "$uname" = Linux -a -d /usr/lib64; then
libdir="$exec_prefix/lib64"
else
libdir="$exec_prefix/lib"
fi
fi
fi
dnl Setup init.d locations...
AC_ARG_WITH(rcdir, [ --with-rcdir set path for rc scripts],rcdir="$withval",rcdir="")
if test x$rcdir = x; then
case "$uname" in
FreeBSD* | OpenBSD*)
# FreeBSD and OpenBSD
INITDIR=""
INITDDIR=""
;;
NetBSD*)
# NetBSD
INITDIR=""
INITDDIR="/etc/rc.d"
;;
Darwin*)
# Darwin and MacOS X...
INITDIR=""
AC_CHECK_PROG(INITDDIR, launchd,
"/System/Library/LaunchDaemons",
"/System/Library/StartupItems/PrintingServices")
;;
Linux | GNU)
# Linux/HURD seems to choose an init.d directory at random...
if test -d /sbin/init.d; then
# SuSE
INITDIR="/sbin/init.d"
INITDDIR=".."
else
if test -d /etc/init.d; then
# Others
INITDIR="/etc"
INITDDIR="../init.d"
else
# RedHat
INITDIR="/etc/rc.d"
INITDDIR="../init.d"
fi
fi
;;
OSF1* | HP-UX*)
INITDIR="/sbin"
INITDDIR="../init.d"
;;
AIX*)
INITDIR="/etc/rc.d"
INITDDIR=".."
;;
*)
INITDIR="/etc"
INITDDIR="../init.d"
;;
esac
fi
dnl Setup private include directory...
AC_ARG_WITH(privateinclude, [ --with-privateinclude set path for private include files, default=none],privateinclude="$withval",privateinclude="")
if test "x$privateinclude" != x -a "x$privateinclude" != xnone; then
PRIVATEINCLUDE="$privateinclude/cups"
else
privateinclude=""
PRIVATEINCLUDE=""
INITDIR=""
INITDDIR="$rcdir"
fi
AC_SUBST(privateinclude)
AC_SUBST(PRIVATEINCLUDE)
dnl LPD sharing support...
AC_ARG_WITH(lpdconfig, [ --with-lpdconfig set URI for LPD config file],
LPDCONFIG="$withval", LPDCONFIG="")
AC_SUBST(INITDIR)
AC_SUBST(INITDDIR)
if test "x$LPDCONFIG" = x; then
if test -f /System/Library/LaunchDaemons/org.cups.cups-lpd.plist; then
LPDCONFIG="launchd:///System/Library/LaunchDaemons/org.cups.cups-lpd.plist"
elif test "x$XINETD" != x; then
LPDCONFIG="xinetd://$XINETD/cups-lpd"
dnl Xinetd support...
XINETD=""
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
fi
done
if test "x$LPDCONFIG" = xoff; then
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LPD_CONFIG, "")
else
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LPD_CONFIG, "$LPDCONFIG")
fi
dnl SMB sharing support...
AC_ARG_WITH(smbconfig, [ --with-smbconfig set URI for Samba config file],
SMBCONFIG="$withval", SMBCONFIG="")
if test "x$SMBCONFIG" = x; then
if test -f /System/Library/LaunchDaemons/smbd.plist; then
SMBCONFIG="launchd:///System/Library/LaunchDaemons/smbd.plist"
else
for dir in /etc /etc/samba /usr/local/etc; do
if test -f $dir/smb.conf; then
SMBCONFIG="samba://$dir/smb.conf"
break
fi
done
fi
fi
if test "x$SMBCONFIG" = xoff; then
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SMB_CONFIG, "")
else
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SMB_CONFIG, "$SMBCONFIG")
fi
AC_SUBST(XINETD)
dnl Setup default locations...
# Cache data...
AC_ARG_WITH(cachedir, [ --with-cachedir set path for cache files],cachedir="$withval",cachedir="")
if test x$cachedir = x; then
if test "x$host_os_name" = xdarwin; then
CUPS_CACHEDIR="$localstatedir/spool/cups/cache"
if test "x$uname" = xDarwin; then
CUPS_CACHEDIR="$localstatedir/tmp/cups"
else
CUPS_CACHEDIR="$localstatedir/cache/cups"
fi
@@ -177,28 +210,6 @@ CUPS_DATADIR="$datadir/cups"
AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$datadir/cups")
AC_SUBST(CUPS_DATADIR)
# 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="")
@@ -225,20 +236,20 @@ AC_SUBST(CUPS_FONTPATH)
AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH")
# Locale data
if test "$localedir" = "\${datarootdir}/locale"; then
case "$host_os_name" in
linux* | gnu* | *bsd* | darwin*)
CUPS_LOCALEDIR="$datarootdir/locale"
;;
case "$uname" in
Linux | GNU | *BSD* | Darwin*)
CUPS_LOCALEDIR="$datadir/locale"
;;
*)
# This is the standard System V location...
CUPS_LOCALEDIR="$exec_prefix/lib/locale"
;;
esac
else
CUPS_LOCALEDIR="$localedir"
fi
OSF1* | AIX*)
CUPS_LOCALEDIR="$exec_prefix/lib/nls/msg"
;;
*)
# This is the standard System V location...
CUPS_LOCALEDIR="$exec_prefix/lib/locale"
;;
esac
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$CUPS_LOCALEDIR")
AC_SUBST(CUPS_LOCALEDIR)
@@ -261,9 +272,9 @@ AC_DEFINE_UNQUOTED(CUPS_REQUESTS, "$localstatedir/spool/cups")
AC_SUBST(CUPS_REQUESTS)
# Server executables...
case "$host_os_name" in
*bsd* | darwin*)
# *BSD and Darwin (macOS)
case "$uname" in
*BSD* | Darwin*)
# *BSD and Darwin (MacOS X)
INSTALL_SYSV=""
CUPS_SERVERBIN="$exec_prefix/libexec/cups"
;;
@@ -284,16 +295,10 @@ AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups")
AC_SUBST(CUPS_SERVERROOT)
# Transient run-time state
AC_ARG_WITH(rundir, [ --with-rundir set transient run-time state directory],CUPS_STATEDIR="$withval",[
case "$host_os_name" in
darwin*)
# Darwin (macOS)
CUPS_STATEDIR="$CUPS_SERVERROOT"
;;
*)
# All others
CUPS_STATEDIR="$localstatedir/run/cups"
;;
esac])
AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$CUPS_STATEDIR")
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 5314 2006-03-20 19:06:50Z mike $".
dnl
-76
Ver Arquivo
@@ -1,76 +0,0 @@
dnl
dnl DNS Service Discovery (aka Bonjour) stuff for CUPS.
dnl
dnl Copyright © 2007-2019 by Apple Inc.
dnl
dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
dnl information.
dnl
AC_ARG_ENABLE(avahi, [ --disable-avahi disable DNS Service Discovery support using Avahi])
AC_ARG_ENABLE(dnssd, [ --disable-dnssd disable DNS Service Discovery support using mDNSResponder])
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"
CPPFLAGS="-I$withval $CPPFLAGS",)
DNSSDLIBS=""
DNSSD_BACKEND=""
IPPFIND_BIN=""
IPPFIND_MAN=""
if test "x$PKGCONFIG" != x -a x$enable_avahi != xno -a x$host_os_name != xdarwin; then
AC_MSG_CHECKING(for Avahi)
if $PKGCONFIG --exists avahi-client; then
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
DNSSD_BACKEND="dnssd"
IPPFIND_BIN="ippfind"
IPPFIND_MAN="ippfind.1"
AC_DEFINE(HAVE_AVAHI)
else
AC_MSG_RESULT(no)
fi
fi
if test "x$DNSSD_BACKEND" = x -a x$enable_dnssd != xno; then
AC_CHECK_HEADER(dns_sd.h, [
case "$host_os_name" in
darwin*)
# Darwin and macOS...
AC_DEFINE(HAVE_DNSSD)
DNSSD_BACKEND="dnssd"
IPPFIND_BIN="ippfind"
IPPFIND_MAN="ippfind.1"
;;
*)
# All others...
AC_MSG_CHECKING(for current version of dns_sd library)
SAVELIBS="$LIBS"
LIBS="$LIBS -ldns_sd"
AC_TRY_COMPILE([#include <dns_sd.h>],
[int constant = kDNSServiceFlagsShareConnection;
unsigned char txtRecord[100];
uint8_t valueLen;
TXTRecordGetValuePtr(sizeof(txtRecord),
txtRecord, "value", &valueLen);],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DNSSD)
DNSSDLIBS="-ldns_sd"
DNSSD_BACKEND="dnssd",
IPPFIND_BIN="ippfind"
IPPFIND_MAN="ippfind.1"
AC_MSG_RESULT(no))
LIBS="$SAVELIBS"
;;
esac
])
fi
AC_SUBST(DNSSDLIBS)
AC_SUBST(DNSSD_BACKEND)
AC_SUBST(IPPFIND_BIN)
AC_SUBST(IPPFIND_MAN)
-123
Ver Arquivo
@@ -1,123 +0,0 @@
dnl
dnl GSSAPI/Kerberos library detection for CUPS.
dnl
dnl Copyright 2007-2017 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 Licensed under Apache License v2.0. See the file "LICENSE" for more information.
dnl
AC_ARG_ENABLE(gssapi, [ --disable-gssapi disable GSSAPI support])
LIBGSSAPI=""
AC_SUBST(LIBGSSAPI)
if test x$enable_gssapi != xno; then
AC_PATH_TOOL(KRB5CONFIG, krb5-config)
if test "x$KRB5CONFIG" != x; then
case "$host_os_name" in
darwin)
# macOS weak-links to the Kerberos framework...
LIBGSSAPI="-weak_framework Kerberos"
AC_MSG_CHECKING(for GSS framework)
if test -d /System/Library/Frameworks/GSS.framework; then
AC_MSG_RESULT(yes)
LIBGSSAPI="$LIBGSSAPI -weak_framework GSS"
else
AC_MSG_RESULT(no)
fi
;;
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 "$host_os_name" 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))
if test -d /System/Library/Frameworks/GSS.framework; then
AC_CHECK_HEADER(GSS/gssapi.h, AC_DEFINE(HAVE_GSS_GSSAPI_H))
AC_CHECK_HEADER(GSS/gssapi_generic.h, AC_DEFINE(HAVE_GSS_GSSAPI_GENERIC_H))
AC_CHECK_HEADER(GSS/gssapi_spi.h, AC_DEFINE(HAVE_GSS_GSSAPI_SPI_H))
else
AC_CHECK_HEADER(gssapi.h, AC_DEFINE(HAVE_GSSAPI_H))
AC_CHECK_HEADER(gssapi/gssapi.h, AC_DEFINE(HAVE_GSSAPI_GSSAPI_H))
fi
SAVELIBS="$LIBS"
LIBS="$LIBS $LIBGSSAPI"
AC_CHECK_FUNC(__ApplePrivate_gss_acquire_cred_ex_f,
AC_DEFINE(HAVE_GSS_ACQUIRE_CRED_EX_F))
AC_MSG_CHECKING(for GSS_C_NT_HOSTBASED_SERVICE)
if test x$ac_cv_header_gssapi_gssapi_h = xyes; 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))
elif test x$ac_cv_header_gss_gssapi_h = xyes; then
AC_TRY_COMPILE([ #include <GSS/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"
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="host"
else
CUPS_DEFAULT_GSSSERVICENAME="$default_gssservicename"
fi
else
CUPS_DEFAULT_GSSSERVICENAME=""
fi
AC_SUBST(CUPS_DEFAULT_GSSSERVICENAME)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GSSSERVICENAME, "$CUPS_DEFAULT_GSSSERVICENAME")
+114
Ver Arquivo
@@ -0,0 +1,114 @@
dnl
dnl "$Id: cups-image.m4 5311 2006-03-19 13:21:42Z mike $"
dnl
dnl Image library/filter stuff for the Common UNIX Printing System (CUPS).
dnl
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 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
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 Save the current libraries since we don't want the image libraries
dnl included with every program...
SAVELIBS="$LIBS"
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=""
LIBZ=""
AC_SUBST(LIBJPEG)
AC_SUBST(LIBPNG)
AC_SUBST(LIBTIFF)
AC_SUBST(LIBZ)
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
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)
if test x$enable_png != xno; then
AC_CHECK_HEADER(png.h,
AC_CHECK_LIB(png, png_set_tRNS_to_alpha,
AC_DEFINE(HAVE_LIBPNG)
LIBPNG="-lpng -lm"))
else
AC_MSG_NOTICE([PNG support disabled with --disable-png.])
fi
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"
EXPORT_LIBJPEG="$LIBJPEG"
EXPORT_LIBPNG="$LIBPNG"
EXPORT_LIBTIFF="$LIBTIFF"
EXPORT_LIBZ="$LIBZ"
AC_SUBST(EXPORT_LIBJPEG)
AC_SUBST(EXPORT_LIBPNG)
AC_SUBST(EXPORT_LIBTIFF)
AC_SUBST(EXPORT_LIBZ)
AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
dnl
dnl End of "$Id: cups-image.m4 5311 2006-03-19 13:21:42Z mike $".
dnl

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais