check test: all unittests
cd cups; make test
+ cd scheduler; make test
echo Running CUPS test suite...
cd test; ./run-stp-tests.sh 1 0 n n
ipp.o: ipp.c backend-private.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.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 ../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 \
+ ../cups/array.h ../cups/base.h ../cups/http.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/pwg.h \
+ \
\
\
\
../cups/thread.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/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.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/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.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 \
+ ../cups/array.h ../cups/base.h ../cups/http.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/pwg.h \
+ \
\
\
\
../cups/thread.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/debug-internal.h \
- ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
- ../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
- ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
- \
+ ../cups/base.h ieee1284.c backend-private.h ../cups/cups-private.h \
+ ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
+ ../cups/array.h ../cups/language.h ../cups/pwg.h \
+ ../cups/http-private.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/base.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 backend-private.h ../cups/cups-private.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/snmp-private.h ../cups/backend.h
testsupplies.o: testsupplies.c backend-private.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.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/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
lpc.o: lpc.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
lpq.o: lpq.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
lpr.o: lpr.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
lprm.o: lprm.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
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/file.h ../cups/base.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/base.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/base.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/base.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/base.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/base.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/base.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/base.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/base.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/base.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/base.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
+testcgi.o: testcgi.c cgi.h ../cups/cups.h ../cups/file.h ../cups/base.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/base.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/base.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h help-index.h
-array.o: array.c ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
- language.h pwg.h string-private.h ../config.h ../cups/versioning.h \
+array.o: array.c ../cups/cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h string-private.h ../config.h ../cups/base.h \
debug-internal.h debug-private.h
-auth.o: auth.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+auth.o: auth.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- \
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
debug.o: debug.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-dest.o: dest.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+dest.o: dest.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- dnssd.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h dnssd.h
dest-job.o: dest-job.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
dest-localization.o: dest-localization.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
dest-options.o: dest-options.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-dir.o: dir.c cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h string-private.h ../config.h ../cups/versioning.h \
- debug-internal.h debug-private.h dir.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+dir.o: dir.c cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ string-private.h ../config.h ../cups/base.h debug-internal.h \
+ debug-private.h dir.h
dnssd.o: dnssd.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- dnssd.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h dnssd.h
encode.o: encode.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
file.o: file.c file-private.h cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-getputfile.o: getputfile.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+form.o: form.c form.h cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-globals.o: globals.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h
+getputfile.o: getputfile.c cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
+ \
+ \
+ \
+ \
+ \
+ \
\
\
\
\
\
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+globals.o: globals.c cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-hash.o: hash.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+hash.o: hash.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- md5-internal.h
-http.o: http.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h md5-internal.h
+http.o: http.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ \
+ \
+ \
+ \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
http-addr.o: http-addr.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
http-addrlist.o: http-addrlist.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
http-support.o: http-support.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- dnssd.h
-ipp.o: ipp.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h dnssd.h
+ipp.o: ipp.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-ipp-file.o: ipp-file.c ipp-private.h ../cups/cups.h file.h versioning.h \
- ipp.h http.h array.h language.h pwg.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h
-ipp-vars.o: ipp-vars.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+ipp-file.o: ipp-file.c cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
ipp-support.o: ipp-support.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
\
\
\
\
\
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+json.o: json.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ \
+ \
+ \
+ \
+ \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h json-private.h json.h
+jwt.o: jwt.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h jwt.h json.h json-private.h
langprintf.o: langprintf.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
language.o: language.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-md5.o: md5.c md5-internal.h ../cups/versioning.h string-private.h \
- ../config.h
-md5passwd.o: md5passwd.c ../cups/cups.h file.h versioning.h ipp.h http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+md5.o: md5.c md5-internal.h base.h string-private.h ../config.h \
+ ../cups/base.h
+md5passwd.o: md5passwd.c ../cups/cups.h file.h base.h ipp.h http.h \
array.h language.h pwg.h http-private.h ../config.h ../cups/language.h \
../cups/http.h ipp-private.h \
\
\
\
\
- string-private.h ../cups/versioning.h
+ string-private.h ../cups/base.h
notify.o: notify.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
options.o: options.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
pwg-media.o: pwg-media.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+rand.o: rand.c cups.h file.h base.h ipp.h http.h array.h language.h pwg.h
raster-error.o: raster-error.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- raster-private.h raster.h ../cups/debug-private.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h raster-private.h raster.h ../cups/debug-private.h \
../cups/string-private.h
raster-stream.o: raster-stream.c raster-private.h raster.h cups.h file.h \
- versioning.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
- ../cups/debug-private.h ../cups/versioning.h ../cups/string-private.h \
+ base.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
+ ../cups/debug-private.h ../cups/base.h ../cups/string-private.h \
../config.h debug-internal.h debug-private.h
raster-stubs.o: raster-stubs.c raster-private.h raster.h cups.h file.h \
- versioning.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
- ../cups/debug-private.h ../cups/versioning.h ../cups/string-private.h \
+ base.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
+ ../cups/debug-private.h ../cups/base.h ../cups/string-private.h \
../config.h
request.o: request.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-snprintf.o: snprintf.c string-private.h ../config.h ../cups/versioning.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+snprintf.o: snprintf.c string-private.h ../config.h ../cups/base.h
string.o: string.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
tempfile.o: tempfile.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
thread.o: thread.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-tls.o: tls.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+tls.o: tls.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- tls-openssl.c \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h tls-openssl.c \
transcode.o: transcode.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
usersys.o: usersys.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-util.o: util.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+util.o: util.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
adminutil.o: adminutil.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd.h raster.h adminutil.h
-backchannel.o: backchannel.c cups.h file.h versioning.h ipp.h http.h \
- array.h language.h pwg.h sidechannel.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd.h raster.h adminutil.h
+backchannel.o: backchannel.c cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h sidechannel.h
backend.o: backend.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- backend.h ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h backend.h ppd.h raster.h
getdevices.o: getdevices.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- adminutil.h
-getifaddrs.o: getifaddrs.c getifaddrs-internal.h ../config.h versioning.h
-ppd.o: ppd.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h adminutil.h
+getifaddrs.o: getifaddrs.c getifaddrs-internal.h ../config.h base.h
+ppd.o: ppd.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- \
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-attr.o: ppd-attr.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-cache.o: ppd-cache.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-conflicts.o: ppd-conflicts.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-custom.o: ppd-custom.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-emit.o: ppd-emit.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd.h raster.h
ppd-localize.o: ppd-localize.c cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h ../cups/cups.h file.h versioning.h ipp.h http.h array.h \
+ ../config.h ../cups/base.h debug-internal.h debug-private.h \
+ ipp-private.h ../cups/cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
ppd-mark.o: ppd-mark.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
-ppd-page.o: ppd-page.c string-private.h ../config.h ../cups/versioning.h \
- debug-internal.h debug-private.h ppd.h cups.h file.h versioning.h \
- ipp.h http.h array.h language.h pwg.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
+ppd-page.o: ppd-page.c string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ppd.h cups.h file.h base.h ipp.h \
+ http.h array.h language.h pwg.h raster.h
ppd-util.o: ppd-util.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h
raster-interpret.o: raster-interpret.c ../cups/raster-private.h raster.h \
- cups.h file.h versioning.h ipp.h http.h array.h language.h pwg.h \
- ../cups/cups.h ../cups/debug-private.h ../cups/versioning.h \
+ cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ ../cups/cups.h ../cups/debug-private.h ../cups/base.h \
../cups/string-private.h ../config.h ../cups/ppd-private.h \
- ../cups/ppd.h pwg-private.h debug-internal.h debug-private.h
+ ../cups/ppd.h pwg-private.h ../cups/pwg.h debug-internal.h \
+ debug-private.h
raster-interstub.o: raster-interstub.c ../cups/ppd-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h ../cups/ppd.h cups.h raster.h pwg-private.h
-sidechannel.o: sidechannel.c sidechannel.h versioning.h cups-private.h \
- string-private.h ../config.h ../cups/versioning.h debug-internal.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ ../cups/ppd.h cups.h raster.h pwg-private.h ../cups/pwg.h
+sidechannel.o: sidechannel.c sidechannel.h base.h cups-private.h \
+ string-private.h ../config.h ../cups/base.h debug-internal.h \
debug-private.h ipp-private.h ../cups/cups.h file.h ipp.h http.h \
array.h language.h pwg.h http-private.h ../cups/language.h \
../cups/http.h \
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-snmp.o: snmp.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
+snmp.o: snmp.c cups-private.h string-private.h ../config.h ../cups/base.h \
+ debug-internal.h debug-private.h ipp-private.h ../cups/cups.h file.h \
+ base.h ipp.h http.h array.h language.h pwg.h http-private.h \
+ ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- snmp-private.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h snmp-private.h
raster-interstub.o: raster-interstub.c ../cups/ppd-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h ../cups/ppd.h cups.h raster.h pwg-private.h
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ ../cups/ppd.h cups.h raster.h pwg-private.h ../cups/pwg.h
raster-stubs.o: raster-stubs.c raster-private.h raster.h cups.h file.h \
- versioning.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
- ../cups/debug-private.h ../cups/versioning.h ../cups/string-private.h \
+ base.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
+ ../cups/debug-private.h ../cups/base.h ../cups/string-private.h \
../config.h
-fuzzipp.o: fuzzipp.c file.h versioning.h string-private.h ../config.h \
- ../cups/versioning.h ipp-private.h ../cups/cups.h ipp.h http.h array.h \
+fuzzipp.o: fuzzipp.c file.h base.h string-private.h ../config.h \
+ ../cups/base.h ipp-private.h ../cups/cups.h ipp.h http.h array.h \
language.h pwg.h
rasterbench.o: rasterbench.c ../config.h ../cups/raster.h cups.h file.h \
- versioning.h ipp.h http.h array.h language.h pwg.h
-testadmin.o: testadmin.c adminutil.h cups.h file.h versioning.h ipp.h \
- http.h array.h language.h pwg.h string-private.h ../config.h \
- ../cups/versioning.h
-testarray.o: testarray.c string-private.h ../config.h \
- ../cups/versioning.h debug-private.h cups.h file.h versioning.h ipp.h \
- http.h array.h language.h pwg.h dir.h test-internal.h
-testcache.o: testcache.c ppd-private.h ../cups/cups.h file.h versioning.h \
- ipp.h http.h array.h language.h pwg.h ../cups/ppd.h cups.h raster.h \
- pwg-private.h file-private.h cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h http-private.h ../cups/language.h ../cups/http.h \
- \
+ base.h ipp.h http.h array.h language.h pwg.h
+testadmin.o: testadmin.c adminutil.h cups.h file.h base.h ipp.h http.h \
+ array.h language.h pwg.h string-private.h ../config.h ../cups/base.h
+testarray.o: testarray.c string-private.h ../config.h ../cups/base.h \
+ debug-private.h cups.h file.h base.h ipp.h http.h array.h language.h \
+ pwg.h dir.h test-internal.h
+testcache.o: testcache.c ppd-private.h ../cups/cups.h file.h base.h ipp.h \
+ http.h array.h language.h pwg.h ../cups/ppd.h cups.h raster.h \
+ pwg-private.h ../cups/pwg.h file-private.h cups-private.h \
+ string-private.h ../config.h ../cups/base.h debug-internal.h \
+ debug-private.h ipp-private.h http-private.h ../cups/language.h \
+ ../cups/http.h \
\
\
\
\
\
language-private.h ../cups/transcode.h thread.h
-testclient.o: testclient.c ../config.h ../cups/cups.h file.h versioning.h \
- ipp.h http.h array.h language.h pwg.h ../cups/raster.h cups.h \
- ../cups/string-private.h ../cups/versioning.h ../cups/thread.h
-testconflicts.o: testconflicts.c cups.h file.h versioning.h ipp.h http.h \
+testclient.o: testclient.c ../config.h ../cups/cups.h file.h base.h ipp.h \
+ http.h array.h language.h pwg.h ../cups/raster.h cups.h \
+ ../cups/string-private.h ../cups/base.h ../cups/thread.h
+testconflicts.o: testconflicts.c cups.h file.h base.h ipp.h http.h \
array.h language.h pwg.h ppd.h raster.h string-private.h ../config.h \
- ../cups/versioning.h
+ ../cups/base.h
testcreds.o: testcreds.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- test-internal.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h test-internal.h
testcups.o: testcups.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd.h raster.h
-testdest.o: testdest.c cups.h file.h versioning.h ipp.h http.h array.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd.h raster.h
+testdest.o: testdest.c cups.h file.h base.h ipp.h http.h array.h \
language.h pwg.h
-testdnssd.o: testdnssd.c test-internal.h dnssd.h cups.h file.h \
- versioning.h ipp.h http.h array.h language.h pwg.h thread.h
-testfile.o: testfile.c string-private.h ../config.h ../cups/versioning.h \
- debug-private.h file.h versioning.h dir.h
-testgetdests.o: testgetdests.c cups.h file.h versioning.h ipp.h http.h \
- array.h language.h pwg.h test-internal.h
+testdnssd.o: testdnssd.c test-internal.h dnssd.h cups.h file.h base.h \
+ ipp.h http.h array.h language.h pwg.h thread.h
+testfile.o: testfile.c string-private.h ../config.h ../cups/base.h \
+ debug-private.h file.h base.h dir.h
+testform.o: testform.c form.h cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h test-internal.h
+testgetdests.o: testgetdests.c cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h test-internal.h
testhttp.o: testhttp.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- test-internal.h
-testi18n.o: testi18n.c cups.h file.h versioning.h ipp.h http.h array.h \
- language.h pwg.h string-private.h ../config.h ../cups/versioning.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h test-internal.h
+testi18n.o: testi18n.c cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h string-private.h ../config.h ../cups/base.h \
language-private.h ../cups/transcode.h
-testipp.o: testipp.c file.h versioning.h string-private.h ../config.h \
- ../cups/versioning.h ipp-private.h ../cups/cups.h ipp.h http.h array.h \
- language.h pwg.h
-testoptions.o: testoptions.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+testipp.o: testipp.c file.h base.h string-private.h ../config.h \
+ ../cups/base.h ipp-private.h ../cups/cups.h ipp.h http.h array.h \
+ language.h pwg.h test-internal.h
+testjson.o: testjson.c cups.h file.h base.h ipp.h http.h array.h \
+ language.h pwg.h json.h test-internal.h
+testjwt.o: testjwt.c cups.h file.h base.h ipp.h http.h array.h language.h \
+ pwg.h jwt.h json.h test-internal.h
+testlang.o: testlang.c cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
-testlang.o: testlang.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h ../cups/dir.h
+testoptions.o: testoptions.c cups-private.h string-private.h ../config.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h ../cups/dir.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
testppd.o: testppd.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- ppd-private.h ../cups/ppd.h raster.h raster-private.h \
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h ppd-private.h ../cups/ppd.h raster.h raster-private.h \
../cups/debug-private.h ../cups/string-private.h
-testpwg.o: testpwg.c ppd-private.h ../cups/cups.h file.h versioning.h \
- ipp.h http.h array.h language.h pwg.h ../cups/ppd.h cups.h raster.h \
- pwg-private.h file-private.h cups-private.h string-private.h \
- ../config.h ../cups/versioning.h debug-internal.h debug-private.h \
- ipp-private.h http-private.h ../cups/language.h ../cups/http.h \
- \
+testpwg.o: testpwg.c ppd-private.h ../cups/cups.h file.h base.h ipp.h \
+ http.h array.h language.h pwg.h ../cups/ppd.h cups.h raster.h \
+ pwg-private.h ../cups/pwg.h file-private.h cups-private.h \
+ string-private.h ../config.h ../cups/base.h debug-internal.h \
+ debug-private.h ipp-private.h http-private.h ../cups/language.h \
+ ../cups/http.h \
\
\
\
\
language-private.h ../cups/transcode.h thread.h
testraster.o: testraster.c ../cups/raster-private.h raster.h cups.h \
- file.h versioning.h ipp.h http.h array.h language.h pwg.h \
- ../cups/cups.h ../cups/debug-private.h ../cups/versioning.h \
- ../cups/string-private.h ../config.h
+ file.h base.h ipp.h http.h array.h language.h pwg.h ../cups/cups.h \
+ ../cups/debug-private.h ../cups/base.h ../cups/string-private.h \
+ ../config.h
testsnmp.o: testsnmp.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h \
- snmp-private.h
-testthreads.o: testthreads.c ../cups/cups.h file.h versioning.h ipp.h \
- http.h array.h language.h pwg.h ../cups/thread.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h snmp-private.h
+testtestpage.o: testtestpage.c raster-testpage.h raster-private.h \
+ raster.h cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ ../cups/cups.h ../cups/debug-private.h ../cups/base.h \
+ ../cups/string-private.h ../config.h test-internal.h
+testthreads.o: testthreads.c ../cups/cups.h file.h base.h ipp.h http.h \
+ array.h language.h pwg.h ../cups/thread.h
tlscheck.o: tlscheck.c cups-private.h string-private.h ../config.h \
- ../cups/versioning.h debug-internal.h debug-private.h ipp-private.h \
- ../cups/cups.h file.h versioning.h ipp.h http.h array.h language.h \
- pwg.h http-private.h ../cups/language.h ../cups/http.h \
+ ../cups/base.h debug-internal.h debug-private.h ipp-private.h \
+ ../cups/cups.h file.h base.h ipp.h http.h array.h language.h pwg.h \
+ http-private.h ../cups/language.h ../cups/http.h \
\
\
\
\
\
\
- language-private.h ../cups/transcode.h pwg-private.h thread.h cups.h
+ language-private.h ../cups/transcode.h pwg-private.h ../cups/pwg.h \
+ thread.h cups.h
dnssd.o \
encode.o \
file.o \
+ form.o \
getputfile.o \
globals.o \
hash.o \
ipp.o \
ipp-file.o \
ipp-support.o \
+ json.o \
+ jwt.o \
langprintf.o \
language.o \
md5.o \
testdest.o \
testdnssd.o \
testfile.o \
+ testform.o \
testgetdests.o \
testhttp.o \
testi18n.o \
testipp.o \
- testoptions.o \
+ testjson.o \
+ testjwt.o \
testlang.o \
+ testoptions.o \
testppd.o \
testpwg.o \
testraster.o \
dir.h \
dnssd.h \
file.h \
+ form.h \
http.h \
ipp.h \
+ json.h \
+ jwt.h \
language.h \
pwg.h \
raster.h \
file-private.h \
http-private.h \
ipp-private.h \
+ json-private.h \
language-private.h \
pwg-private.h \
raster-private.h \
testdest \
testdnssd \
testfile \
+ testform \
testgetdests \
testhttp \
testi18n \
testipp \
+ testjson \
+ testjwt \
testlang \
testoptions \
testppd \
./testarray >>test.log
echo Running file API tests...
./testfile >>test.log
+ echo Running form API tests...
+ ./testform >>test.log
echo Running HTTP API tests...
./testhttp >>test.log
echo Running IPP API tests...
./testipp >>test.log
echo Running internationalization API tests...
./testi18n >>test.log
+ echo Running JSON API tests...
+ ./testjson >>test.log
+ echo Running JWT API tests...
+ ./testjwt >>test.log
echo Creating locale directory structure...
$(RM) -r locale
for po in ../locale/cups_*.po; do \
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+#
+# testform (dependency on static CUPS library is intentional)
+#
+
+testform: testform.o $(LIBCUPSSTATIC)
+ echo Linking $@...
+ $(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testform.o $(LINKCUPSSTATIC)
+ $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+
+
#
# testgetdests (dependency on static CUPS library is intentional)
#
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+#
+# testjson (dependency on static CUPS library is intentional)
+#
+
+testjson: testjson.o $(LIBCUPSSTATIC)
+ echo Linking $@...
+ $(LD_CC) $(ALL_LDFLAGS) -o $@ testjson.o $(LINKCUPSSTATIC)
+ $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+
+
+#
+# testjwt (dependency on static CUPS library is intentional)
+#
+
+testjwt: testjwt.o $(LIBCUPSSTATIC)
+ echo Linking $@...
+ $(LD_CC) $(ALL_LDFLAGS) -o $@ testjwt.o $(LINKCUPSSTATIC)
+ $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+
+
#
# testlang (dependency on static CUPS library is intentional)
#
-/*
- * Administration utility API definitions for CUPS.
- *
- * Copyright 2007-2016 by Apple Inc.
- * Copyright 2001-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Administration utility API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2016 by Apple Inc.
+// Copyright © 2001-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_ADMINUTIL_H_
# define _CUPS_ADMINUTIL_H_
-
-/*
- * Include necessary headers...
- */
-
# include <stdio.h>
# include "cups.h"
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
+//
+// Constants...
+//
# define CUPS_SERVER_DEBUG_LOGGING "_debug_logging"
# define CUPS_SERVER_REMOTE_ADMIN "_remote_admin"
# define CUPS_SERVER_USER_CANCEL_ANY "_user_cancel_any"
-/*
- * Types and structures...
- */
-
-typedef void (*cups_device_cb_t)(const char *device_class,
- const char *device_id, const char *device_info,
- const char *device_make_and_model,
- const char *device_uri,
- const char *device_location, void *user_data);
- /* Device callback
- * @since CUPS 1.4/macOS 10.6@ */
+//
+// Types and structures...
+//
+typedef void (*cups_device_cb_t)(const char *device_class, const char *device_id, const char *device_info, const char *device_make_and_model, const char *device_uri, const char *device_location, void *user_data);
+ // Device callback @since CUPS 1.4/macOS 10.6@
-/*
- * Functions...
- */
-extern int cupsAdminExportSamba(const char *dest, const char *ppd,
- const char *samba_server,
- const char *samba_user,
- const char *samba_password,
- FILE *logfile) _CUPS_DEPRECATED;
-extern char *cupsAdminCreateWindowsPPD(http_t *http, const char *dest,
- char *buffer, int bufsize)
- _CUPS_DEPRECATED;
+//
+// Functions...
+//
-extern int cupsAdminGetServerSettings(http_t *http,
- int *num_settings,
- cups_option_t **settings)
- _CUPS_API_1_3;
-extern int cupsAdminSetServerSettings(http_t *http,
- int num_settings,
- cups_option_t *settings)
- _CUPS_API_1_3;
+extern char *cupsAdminCreateWindowsPPD(http_t *http, const char *dest, char *buffer, int bufsize) _CUPS_DEPRECATED;
+extern int cupsAdminExportSamba(const char *dest, const char *ppd, const char *samba_server, const char *samba_user, const char *samba_password, FILE *logfile) _CUPS_DEPRECATED;
+extern int cupsAdminGetServerSettings(http_t *http, int *num_settings, cups_option_t **settings) _CUPS_PUBLIC;
+extern int cupsAdminSetServerSettings(http_t *http, int num_settings, cups_option_t *settings) _CUPS_PUBLIC;
-extern ipp_status_t cupsGetDevices(http_t *http, int timeout,
- const char *include_schemes,
- const char *exclude_schemes,
- cups_device_cb_t callback,
- void *user_data) _CUPS_DEPRECATED;
+extern ipp_status_t cupsGetDevices(http_t *http, int timeout, const char *include_schemes, const char *exclude_schemes, cups_device_cb_t callback, void *user_data) _CUPS_DEPRECATED;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_ADMINUTIL_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_ADMINUTIL_H_
#ifndef _CUPS_ARRAY_H_
# define _CUPS_ARRAY_H_
-# include "versioning.h"
+# include "base.h"
# include <stdlib.h>
# ifdef __cplusplus
extern "C" {
-/*
- * Backend definitions for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Backend definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2011 by Apple Inc.
+// Copyright © 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_BACKEND_H_
# define _CUPS_BACKEND_H_
-
-
-/*
- * Include necessary headers...
- */
-
-# include "versioning.h"
-
-
-/*
- * C++ magic...
- */
-
+# include "base.h"
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
-enum cups_backend_e /**** Backend exit codes ****/
+//
+// Constants...
+//
+
+enum cups_backend_e // Backend exit codes
{
- CUPS_BACKEND_OK = 0, /* Job completed successfully */
- CUPS_BACKEND_FAILED = 1, /* Job failed, use error-policy */
- CUPS_BACKEND_AUTH_REQUIRED = 2, /* Job failed, authentication required */
- CUPS_BACKEND_HOLD = 3, /* Job failed, hold job */
- CUPS_BACKEND_STOP = 4, /* Job failed, stop queue */
- CUPS_BACKEND_CANCEL = 5, /* Job failed, cancel job */
- CUPS_BACKEND_RETRY = 6, /* Job failed, retry this job later */
- CUPS_BACKEND_RETRY_CURRENT = 7 /* Job failed, retry this job immediately */
+ CUPS_BACKEND_OK = 0, // Job completed successfully
+ CUPS_BACKEND_FAILED = 1, // Job failed, use error-policy
+ CUPS_BACKEND_AUTH_REQUIRED = 2, // Job failed, authentication required
+ CUPS_BACKEND_HOLD = 3, // Job failed, hold job
+ CUPS_BACKEND_STOP = 4, // Job failed, stop queue
+ CUPS_BACKEND_CANCEL = 5, // Job failed, cancel job
+ CUPS_BACKEND_RETRY = 6, // Job failed, retry this job later
+ CUPS_BACKEND_RETRY_CURRENT = 7 // Job failed, retry this job immediately
};
typedef enum cups_backend_e cups_backend_t;
- /**** Backend exit codes ****/
+ // Backend exit codes
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
-extern const char *cupsBackendDeviceURI(char **argv) _CUPS_API_1_2;
-extern void cupsBackendReport(const char *device_scheme,
- const char *device_uri,
- const char *device_make_and_model,
- const char *device_info,
- const char *device_id,
- const char *device_location)
- _CUPS_API_1_4;
+extern const char *cupsBackendDeviceURI(char **argv) _CUPS_PUBLIC;
+extern void cupsBackendReport(const char *device_scheme, const char *device_uri, const char *device_make_and_model, const char *device_info, const char *device_id, const char *device_location) _CUPS_PUBLIC;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_BACKEND_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_BACKEND_H_
--- /dev/null
+//
+// Base definitions for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#ifndef _CUPS_BASE_H_
+# define _CUPS_BASE_H_
+# include <stdbool.h>
+
+
+//
+// This header defines several macros that add compiler-specific attributes for
+// functions:
+//
+// - _CUPS_DEPRECATED: Function is deprecated with no replacement.
+// - _CUPS_DEPRECATED_MSG("message"): Function is deprecated and has a
+// replacement.
+// - _CUPS_FORMAT(format-index, additional-args-index): Function has a
+// printf-style format argument followed by zero or more additional
+// arguments. Indices start at 1.
+// - _CUPS_INTERNAL: Function is internal with no replacement API.
+// - _CUPS_INTERNAL_MSG("msg"): Function is internal - use specified API
+// instead.
+// - _CUPS_NONNULL((arg list)): Specifies the comma-separated argument indices
+// are assumed non-NULL. Indices start at 1.
+// - _CUPS_NORETURN: Specifies the function does not return.
+// - _CUPS_PRIVATE: Specifies the function is private to CUPS.
+// - _CUPS_PUBLIC: Specifies the function is public API.
+//
+
+//
+// Determine which compiler is being used and what annotation features are
+// available...
+//
+
+# ifdef __has_extension // Clang
+# define _CUPS_HAS_DEPRECATED
+# define _CUPS_HAS_FORMAT
+# define _CUPS_HAS_NORETURN
+# define _CUPS_HAS_VISIBILITY
+# if __has_extension(attribute_deprecated_with_message)
+# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
+# endif
+# if __has_extension(attribute_unavailable_with_message)
+# define _CUPS_HAS_UNAVAILABLE_WITH_MESSAGE
+# endif
+# elif defined(__GNUC__) // GCC and compatible
+# if __GNUC__ >= 3 // GCC 3.0 or higher
+# define _CUPS_HAS_DEPRECATED
+# define _CUPS_HAS_FORMAT
+# define _CUPS_HAS_NORETURN
+# define _CUPS_HAS_VISIBILITY
+# endif // __GNUC__ >= 3
+# if __GNUC__ >= 5 // GCC 5.x
+# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
+# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 5
+ // GCC 4.5 or higher
+# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
+# endif // __GNUC__ >= 5
+# elif defined(_WIN32)
+# define __attribute__(...)
+# endif // __has_extension
+
+
+//
+// Define _CUPS_INTERNAL, _CUPS_PRIVATE, and _CUPS_PUBLIC visibility macros for
+// internal/private/public functions...
+//
+
+# ifdef _CUPS_HAS_VISIBILITY
+# define _CUPS_INTERNAL __attribute__ ((visibility("hidden")))
+# define _CUPS_PRIVATE __attribute__ ((visibility("default")))
+# define _CUPS_PUBLIC __attribute__ ((visibility("default")))
+# elif defined(_WIN32) && defined(LIBCUPS2_EXPORTS) && 0
+# define _CUPS_INTERNAL
+# define _CUPS_PRIVATE __declspec(dllexport)
+# define _CUPS_PUBLIC __declspec(dllexport)
+# else
+# define _CUPS_INTERNAL
+# define _CUPS_PRIVATE
+# define _CUPS_PUBLIC
+# endif // _CUPS_HAS_VISIBILITY
+
+
+//
+// Define _CUPS_DEPRECATED and _CUPS_INTERNAL macros to mark old APIs as
+// "deprecated" or "unavailable" with messages so you get warnings/errors are
+// compile-time...
+//
+// Note: Using any of the _CUPS_DEPRECATED macros automatically adds
+// _CUPS_PUBLIC.
+//
+
+# if !defined(_CUPS_HAS_DEPRECATED) || (defined(_CUPS_SOURCE) && !defined(_CUPS_NO_DEPRECATED))
+ // Don't mark functions deprecated if the compiler doesn't support it or we are building CUPS source that doesn't care.
+# define _CUPS_DEPRECATED _CUPS_PUBLIC
+# define _CUPS_DEPRECATED_MSG(m) _CUPS_PUBLIC
+# elif defined(__APPLE__) && defined(_CUPS_NO_DEPRECATED)
+ // Compiler supports the unavailable attribute, so use it when the code wants to exclude the use of deprecated API.
+# define _CUPS_DEPRECATED __attribute__ ((unavailable)) _CUPS_PUBLIC
+# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
+
+# elif defined(__APPLE__)
+ // Just mark things as deprecated...
+# define _CUPS_DEPRECATED __attribute__ ((deprecated)) _CUPS_PUBLIC
+# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
+
+# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) && defined(_CUPS_NO_DEPRECATED)
+ // Compiler supports the unavailable attribute, so use it when the code wants to exclude the use of deprecated API.
+# define _CUPS_DEPRECATED __attribute__ ((unavailable)) _CUPS_PUBLIC
+# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
+
+# else
+ // Compiler supports the deprecated attribute, so use it.
+# define _CUPS_DEPRECATED __attribute__ ((deprecated)) _CUPS_PUBLIC
+# ifdef _CUPS_HAS_DEPRECATED_WITH_MESSAGE
+# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
+# else
+# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
+# endif // _CUPS_HAS_DEPRECATED_WITH_MESSAGE
+# endif // !_CUPS_HAS_DEPRECATED || (_CUPS_SOURCE && !_CUPS_NO_DEPRECATED)
+
+
+//
+// Define _CUPS_FORMAT macro for printf-style functions...
+//
+
+# ifdef _CUPS_HAS_FORMAT
+# define _CUPS_FORMAT(a,b) __attribute__ ((__format__(__printf__, a,b)))
+# else
+# define _CUPS_FORMAT(a,b)
+# endif // _CUPS_HAS_FORMAT
+
+
+//
+// Define _CUPS_INTERNAL_MSG macro for private APIs that have (historical)
+// public visibility.
+//
+// Note: Using the _CUPS_INTERNAL_MSG macro automatically adds _CUPS_PUBLIC.
+//
+
+# ifdef _CUPS_SOURCE
+# define _CUPS_INTERNAL_MSG(m) _CUPS_PUBLIC
+# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE)
+# define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
+# elif defined(_CUPS_HAS_DEPRECATED_WITH_MESSAGE)
+# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
+# else
+# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
+# endif // _CUPS_SOURCE
+
+
+//
+// Define _CUPS_NONNULL macro for functions that don't expect non-null
+// arguments...
+//
+
+# ifdef _CUPS_HAS_NONNULL
+# define _CUPS_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__)))
+# else
+# define _CUPS_NONNULL(...)
+# endif // _CUPS_HAS_FORMAT
+
+
+//
+// Define _CUPS_NORETURN macro for functions that don't return.
+//
+
+# ifdef _CUPS_HAS_NORETURN
+# define _CUPS_NORETURN __attribute__ ((noreturn))
+# else
+# define _CUPS_NORETURN
+# endif // _CUPS_HAS_NORETURN
+#endif // !_CUPS_BASE_H_
-/*
- * Private debugging APIs for CUPS.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private debugging APIs for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_DEBUG_PRIVATE_H_
# define _CUPS_DEBUG_PRIVATE_H_
-
-
-/*
- * Include necessary headers...
- */
-
-# include <cups/versioning.h>
-
-
-/*
- * C++ magic...
- */
-
+# include <cups/base.h>
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
-
-
-/*
- * The debug macros are used if you compile with DEBUG defined.
- *
- * Usage:
- *
- * DEBUG_set("logfile", "level", "filter", 1)
- *
- * The DEBUG_set macro allows an application to programmatically enable (or
- * disable) debug logging. The arguments correspond to the CUPS_DEBUG_LOG,
- * CUPS_DEBUG_LEVEL, and CUPS_DEBUG_FILTER environment variables. The 1 on the
- * end forces the values to override the environment.
- */
+# endif // __cplusplus
+
+
+//
+// The debug macros are used if you compile with DEBUG defined.
+//
+// Usage:
+//
+// DEBUG_set("logfile", "level", "filter", 1)
+//
+// The DEBUG_set macro allows an application to programmatically enable (or
+// disable) debug logging. The arguments correspond to the CUPS_DEBUG_LOG,
+// CUPS_DEBUG_LEVEL, and CUPS_DEBUG_FILTER environment variables. The 1 on the
+// end forces the values to override the environment.
+//
# ifdef DEBUG
# define DEBUG_set(logfile,level,filter) _cups_debug_set(logfile,level,filter,1)
# else
# define DEBUG_set(logfile,level,filter)
-# endif /* DEBUG */
+# endif // DEBUG
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
extern void _cups_debug_set(const char *logfile, const char *level, const char *filter, int force) _CUPS_PRIVATE;
# ifdef _WIN32
extern int _cups_gettimeofday(struct timeval *tv, void *tz) _CUPS_PRIVATE;
# define gettimeofday(a,b) _cups_gettimeofday(a, b)
-# endif /* _WIN32 */
+# endif // _WIN32
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_DEBUG_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_DEBUG_PRIVATE_H_
*/
#include "cups-private.h"
-#include "debug-internal.h"
#ifdef _WIN32
# include <sys/timeb.h>
# include <time.h>
-/*
- * Public directory definitions for CUPS.
- *
- * This set of APIs abstracts enumeration of directory entries.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Public directory definitions for CUPS.
+//
+// This set of APIs abstracts enumeration of directory entries.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2011 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_DIR_H_
# define _CUPS_DIR_H_
-
-
-/*
- * Include necessary headers...
- */
-
-# include "versioning.h"
+# include "base.h"
# include <sys/stat.h>
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Data types...
- */
+//
+// Types...
+//
-typedef struct _cups_dir_s cups_dir_t; /**** Directory type ****/
+typedef struct _cups_dir_s cups_dir_t; // Directory type
-typedef struct cups_dentry_s /**** Directory entry type ****/
+typedef struct cups_dentry_s // Directory entry type
{
- char filename[260]; /* File name */
- struct stat fileinfo; /* File information */
+ char filename[260]; // File name
+ struct stat fileinfo; // File information
} cups_dentry_t;
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
-extern void cupsDirClose(cups_dir_t *dp) _CUPS_API_1_2;
-extern cups_dir_t *cupsDirOpen(const char *directory) _CUPS_API_1_2;
-extern cups_dentry_t *cupsDirRead(cups_dir_t *dp) _CUPS_API_1_2;
-extern void cupsDirRewind(cups_dir_t *dp) _CUPS_API_1_2;
+extern void cupsDirClose(cups_dir_t *dp) _CUPS_PUBLIC;
+extern cups_dir_t *cupsDirOpen(const char *directory) _CUPS_PUBLIC;
+extern cups_dentry_t *cupsDirRead(cups_dir_t *dp) _CUPS_PUBLIC;
+extern void cupsDirRewind(cups_dir_t *dp) _CUPS_PUBLIC;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_DIR_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_DIR_H_
-/*
- * Private file definitions for CUPS.
- *
- * Since stdio files max out at 256 files on many systems, we have to
- * write similar functions without this limit. At the same time, using
- * our own file functions allows us to provide transparent support of
- * different line endings, gzip'd print files, PPD files, etc.
- *
- * Copyright © 2007-2018 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.
- */
+//
+// Private file definitions for CUPS.
+//
+// Since stdio files max out at 256 files on many systems, we have to
+// write similar functions without this limit. At the same time, using
+// our own file functions allows us to provide transparent support of
+// different line endings, gzip'd print files, PPD files, etc.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 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_FILE_PRIVATE_H_
# define _CUPS_FILE_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
# include "cups-private.h"
# include <stdio.h>
# include <stdlib.h>
# include <stdarg.h>
# include <fcntl.h>
-
# ifdef _WIN32
# include <io.h>
# include <sys/locking.h>
-# endif /* _WIN32 */
+# endif // _WIN32
-/*
- * Some operating systems support large files via open flag O_LARGEFILE...
- */
+//
+// Some operating systems support large files via open flag O_LARGEFILE...
+//
# ifndef O_LARGEFILE
# define O_LARGEFILE 0
-# endif /* !O_LARGEFILE */
+# endif // !O_LARGEFILE
-/*
- * Some operating systems don't define O_BINARY, which is used by Microsoft
- * and IBM to flag binary files...
- */
+//
+// Some operating systems don't define O_BINARY, which is used by Microsoft
+// and IBM to flag binary files...
+//
# ifndef O_BINARY
# define O_BINARY 0
-# endif /* !O_BINARY */
+# endif // !O_BINARY
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
-typedef enum /**** _cupsFileCheck return values ****/
+typedef enum // _cupsFileCheck return values
{
- _CUPS_FILE_CHECK_OK = 0, /* Everything OK */
- _CUPS_FILE_CHECK_MISSING = 1, /* File is missing */
- _CUPS_FILE_CHECK_PERMISSIONS = 2, /* File (or parent dir) has bad perms */
- _CUPS_FILE_CHECK_WRONG_TYPE = 3, /* File has wrong type */
- _CUPS_FILE_CHECK_RELATIVE_PATH = 4 /* File contains a relative path */
+ _CUPS_FILE_CHECK_OK = 0, // Everything OK
+ _CUPS_FILE_CHECK_MISSING = 1, // File is missing
+ _CUPS_FILE_CHECK_PERMISSIONS = 2, // File (or parent dir) has bad perms
+ _CUPS_FILE_CHECK_WRONG_TYPE = 3, // File has wrong type
+ _CUPS_FILE_CHECK_RELATIVE_PATH = 4 // File contains a relative path
} _cups_fc_result_t;
-typedef enum /**** _cupsFileCheck file type values ****/
+typedef enum // _cupsFileCheck file type values
{
- _CUPS_FILE_CHECK_FILE = 0, /* Check the file and parent directory */
- _CUPS_FILE_CHECK_PROGRAM = 1, /* Check the program and parent directory */
- _CUPS_FILE_CHECK_FILE_ONLY = 2, /* Check the file only */
- _CUPS_FILE_CHECK_DIRECTORY = 3 /* Check the directory */
+ _CUPS_FILE_CHECK_FILE = 0, // Check the file and parent directory
+ _CUPS_FILE_CHECK_PROGRAM = 1, // Check the program and parent directory
+ _CUPS_FILE_CHECK_FILE_ONLY = 2, // Check the file only
+ _CUPS_FILE_CHECK_DIRECTORY = 3 // Check the directory
} _cups_fc_filetype_t;
typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result,
const char *message);
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
extern _cups_fc_result_t _cupsFileCheck(const char *filename, _cups_fc_filetype_t filetype, int dorootchecks, _cups_fc_func_t cb, void *context) _CUPS_PRIVATE;
extern void _cupsFileCheckFilter(void *context, _cups_fc_result_t result, const char *message) _CUPS_PRIVATE;
-extern int _cupsFilePeekAhead(cups_file_t *fp, int ch);
+extern int _cupsFilePeekAhead(cups_file_t *fp, int ch) _CUPS_PRIVATE;
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_FILE_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_FILE_PRIVATE_H_
-/*
- * Public file definitions for CUPS.
- *
- * Since stdio files max out at 256 files on many systems, we have to
- * write similar functions without this limit. At the same time, using
- * our own file functions allows us to provide transparent support of
- * different line endings, gzip'd print files, PPD files, etc.
- *
- * Copyright © 2007-2018 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.
- */
+//
+// Public file definitions for CUPS.
+//
+// Since stdio files max out at 256 files on many systems, we have to
+// write similar functions without this limit. At the same time, using
+// our own file functions allows us to provide transparent support of
+// different line endings, gzip'd print files, PPD files, etc.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 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_FILE_H_
# define _CUPS_FILE_H_
-
-
-/*
- * Include necessary headers...
- */
-
-# include "versioning.h"
+# include "base.h"
# include <stddef.h>
# include <sys/types.h>
# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
# define __CUPS_SSIZE_T_DEFINED
-/* Windows does not support the ssize_t type, so map it to off_t... */
-typedef off_t ssize_t; /* @private@ */
-# endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
-
-
-/*
- * C++ magic...
- */
-
+// Windows does not support the ssize_t type, so map it to off_t...
+typedef off_t ssize_t; // @private@
+# endif // _WIN32 && !__CUPS_SSIZE_T_DEFINED
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
-
-
-/*
- * CUPS file definitions...
- */
-
-# define CUPS_FILE_NONE 0 /* No compression */
-# define CUPS_FILE_GZIP 1 /* GZIP compression */
-
-
-/*
- * Types and structures...
- */
-
-typedef struct _cups_file_s cups_file_t;/**** CUPS file type ****/
-
-
-/*
- * Prototypes...
- */
-
-extern int cupsFileClose(cups_file_t *fp) _CUPS_API_1_2;
-extern int cupsFileCompression(cups_file_t *fp) _CUPS_API_1_2;
-extern int cupsFileEOF(cups_file_t *fp) _CUPS_API_1_2;
-extern const char *cupsFileFind(const char *filename, const char *path, int executable, char *buffer, int bufsize) _CUPS_API_1_2;
-extern int cupsFileFlush(cups_file_t *fp) _CUPS_API_1_2;
-extern int cupsFileGetChar(cups_file_t *fp) _CUPS_API_1_2;
-extern char *cupsFileGetConf(cups_file_t *fp, char *buf, size_t buflen, char **value, int *linenum) _CUPS_API_1_2;
-extern size_t cupsFileGetLine(cups_file_t *fp, char *buf, size_t buflen) _CUPS_API_1_2;
-extern char *cupsFileGets(cups_file_t *fp, char *buf, size_t buflen) _CUPS_API_1_2;
-extern int cupsFileLock(cups_file_t *fp, int block) _CUPS_API_1_2;
-extern int cupsFileNumber(cups_file_t *fp) _CUPS_API_1_2;
-extern cups_file_t *cupsFileOpen(const char *filename, const char *mode) _CUPS_API_1_2;
-extern cups_file_t *cupsFileOpenFd(int fd, const char *mode) _CUPS_API_1_2;
-extern int cupsFilePeekChar(cups_file_t *fp) _CUPS_API_1_2;
-extern int cupsFilePrintf(cups_file_t *fp, const char *format, ...) _CUPS_FORMAT(2, 3) _CUPS_API_1_2;
-extern int cupsFilePutChar(cups_file_t *fp, int c) _CUPS_API_1_2;
-extern ssize_t cupsFilePutConf(cups_file_t *fp, const char *directive, const char *value) _CUPS_API_1_4;
-extern int cupsFilePuts(cups_file_t *fp, const char *s) _CUPS_API_1_2;
-extern ssize_t cupsFileRead(cups_file_t *fp, char *buf, size_t bytes) _CUPS_API_1_2;
-extern off_t cupsFileRewind(cups_file_t *fp) _CUPS_API_1_2;
-extern off_t cupsFileSeek(cups_file_t *fp, off_t pos) _CUPS_API_1_2;
-extern cups_file_t *cupsFileStderr(void) _CUPS_API_1_2;
-extern cups_file_t *cupsFileStdin(void) _CUPS_API_1_2;
-extern cups_file_t *cupsFileStdout(void) _CUPS_API_1_2;
-extern off_t cupsFileTell(cups_file_t *fp) _CUPS_API_1_2;
-extern int cupsFileUnlock(cups_file_t *fp) _CUPS_API_1_2;
-extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, size_t bytes) _CUPS_API_1_2;
+# endif // __cplusplus
+
+
+//
+// CUPS file definitions...
+//
+
+# define CUPS_FILE_NONE 0 // No compression
+# define CUPS_FILE_GZIP 1 // GZIP compression
+
+
+//
+// Types and structures...
+//
+
+typedef struct _cups_file_s cups_file_t;// CUPS file type
+
+
+//
+// Functions...
+//
+
+extern int cupsFileClose(cups_file_t *fp) _CUPS_PUBLIC;
+extern int cupsFileCompression(cups_file_t *fp) _CUPS_PUBLIC;
+extern int cupsFileEOF(cups_file_t *fp) _CUPS_PUBLIC;
+extern const char *cupsFileFind(const char *filename, const char *path, int executable, char *buffer, int bufsize) _CUPS_PUBLIC;
+extern int cupsFileFlush(cups_file_t *fp) _CUPS_PUBLIC;
+extern int cupsFileGetChar(cups_file_t *fp) _CUPS_PUBLIC;
+extern char *cupsFileGetConf(cups_file_t *fp, char *buf, size_t buflen, char **value, int *linenum) _CUPS_PUBLIC;
+extern size_t cupsFileGetLine(cups_file_t *fp, char *buf, size_t buflen) _CUPS_PUBLIC;
+extern char *cupsFileGets(cups_file_t *fp, char *buf, size_t buflen) _CUPS_PUBLIC;
+extern int cupsFileLock(cups_file_t *fp, int block) _CUPS_PUBLIC;
+extern int cupsFileNumber(cups_file_t *fp) _CUPS_PUBLIC;
+extern cups_file_t *cupsFileOpen(const char *filename, const char *mode) _CUPS_PUBLIC;
+extern cups_file_t *cupsFileOpenFd(int fd, const char *mode) _CUPS_PUBLIC;
+extern int cupsFilePeekChar(cups_file_t *fp) _CUPS_PUBLIC;
+extern int cupsFilePrintf(cups_file_t *fp, const char *format, ...) _CUPS_FORMAT(2, 3) _CUPS_PUBLIC;
+extern int cupsFilePutChar(cups_file_t *fp, int c) _CUPS_PUBLIC;
+extern ssize_t cupsFilePutConf(cups_file_t *fp, const char *directive, const char *value) _CUPS_PUBLIC;
+extern int cupsFilePuts(cups_file_t *fp, const char *s) _CUPS_PUBLIC;
+extern ssize_t cupsFileRead(cups_file_t *fp, char *buf, size_t bytes) _CUPS_PUBLIC;
+extern off_t cupsFileRewind(cups_file_t *fp) _CUPS_PUBLIC;
+extern off_t cupsFileSeek(cups_file_t *fp, off_t pos) _CUPS_PUBLIC;
+extern cups_file_t *cupsFileStderr(void) _CUPS_PUBLIC;
+extern cups_file_t *cupsFileStdin(void) _CUPS_PUBLIC;
+extern cups_file_t *cupsFileStdout(void) _CUPS_PUBLIC;
+extern off_t cupsFileTell(cups_file_t *fp) _CUPS_PUBLIC;
+extern int cupsFileUnlock(cups_file_t *fp) _CUPS_PUBLIC;
+extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, size_t bytes) _CUPS_PUBLIC;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_FILE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_FILE_H_
--- /dev/null
+//
+// Form API functions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2017-2022 by Michael R Sweet
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "form.h"
+#include "cups-private.h"
+
+
+//
+// Local functions...
+//
+
+static const char *decode_string(const char *data, char *buffer, size_t bufsize);
+static char *encode_string(const char *s, char *bufptr, char *bufend);
+
+
+//
+// 'cupsFormDecode()' - Decode URL-encoded form data.
+//
+// This function decodes URL-encoded form data, returning the number of
+// variables and a pointer to a @link cups_option_t@ array of the variables.
+//
+// Use the @link cupsFreeOptions@ function to return the memory used when you
+// are done with the form variables.
+//
+// @since CUPS 2.5@
+//
+
+int // O - Number of variables
+cupsFormDecode(const char *data, // I - URL-encoded form data
+ cups_option_t **vars) // O - Array of variables
+{
+ int num_vars = 0; // Number of variables
+ char name[1024], // Variable name
+ value[4096]; // Variable value
+
+
+ // Range check...
+ if (vars)
+ *vars = NULL;
+
+ if (!data || !*data || !vars)
+ return (0);
+
+ // If the data starts with a "http:", "https:", or "/" prefix, skip past the
+ // URL/path portion to the "query string" portion...
+ if (!strncmp(data, "http://", 7) || !strncmp(data, "https://", 8) || *data == '/')
+ {
+ const char *query = strchr(data, '?');
+ // Pointer to query portion
+
+ if (!query)
+ goto decode_error;
+
+ data = query + 1;
+ }
+
+ // Scan the string for "name=value" pairs, unescaping values as needed.
+ while (*data)
+ {
+ // Get the name and value...
+ data = decode_string(data, name, sizeof(name));
+
+ if (!data || *data != '=')
+ goto decode_error;
+
+ data ++;
+
+ data = decode_string(data, value, sizeof(value));
+
+ if (!data || (*data && *data != '&'))
+ {
+ goto decode_error;
+ }
+ else if (*data)
+ {
+ data ++;
+
+ if (!*data)
+ goto decode_error;
+ }
+
+ // Add the variable...
+ num_vars = cupsAddOption(name, value, num_vars, vars);
+ }
+
+ return (num_vars);
+
+ // If we get here there was an error in the form data...
+ decode_error:
+
+ cupsFreeOptions(num_vars, *vars);
+
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid form data."), 1);
+ *vars = NULL;
+
+ return (0);
+}
+
+
+//
+// 'cupsFormEncode()' - Encode options as URL-encoded form data.
+//
+// This function encodes a CUPS options array as URL-encoded form data with an
+// optional URL prefix, returning an allocated string.
+//
+// Use `free` to return the memory used for the string.
+//
+// @since CUPS 2.5@
+//
+
+char * // O - URL-encoded form data
+cupsFormEncode(const char *url, // I - URL or `NULL` for none
+ int num_vars, // I - Number of variables
+ cups_option_t *vars) // I - Variables
+{
+ char buffer[65536], // Temporary buffer
+ prefix = '\0', // Prefix character, if any
+ *bufptr = buffer, // Current position in buffer
+ *bufend = buffer + sizeof(buffer) - 1;
+ // End of buffer
+
+
+ // Start with the URL, if present...
+ if (url)
+ {
+ char scheme[32], // URL scheme
+ userpass[64], // URL username:password, if any
+ host[256], // URL hostname
+ resource[1024]; // URL resource path
+ int port; // URL port number
+ http_uri_status_t uri_status; // Decoding status
+
+ // Get the URL components and re-assemble to normalize it without user info...
+ if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, url, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource))) < HTTP_URI_STATUS_OK)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, httpURIStatusString(uri_status), 0);
+ return (NULL);
+ }
+
+ httpAssembleURI(HTTP_URI_CODING_ALL, buffer, sizeof(buffer), scheme, NULL, host, port, resource);
+ bufptr = buffer + strlen(buffer);
+
+ // Check whether the URL included some initial query parameters...
+ if (strchr(resource, '?'))
+ prefix = '&';
+ else
+ prefix = '?';
+ }
+
+ // Loop through the variables...
+ while (num_vars > 0)
+ {
+ // Add the prefix character...
+ if (prefix)
+ {
+ if (bufptr < bufend)
+ *bufptr++ = prefix;
+ else
+ goto encode_error;
+ }
+
+ prefix = '&';
+
+ // Encode the name
+ bufptr = encode_string(vars->name, bufptr, bufend);
+
+ if (bufptr >= bufend)
+ goto encode_error;
+
+ // 'name='
+ *bufptr++ = '=';
+
+ // Encode the value...
+ bufptr = encode_string(vars->value, bufptr, bufend);
+
+ if (bufptr >= bufend)
+ goto encode_error;
+
+ // Next variable
+ num_vars --;
+ vars ++;
+ }
+
+ // Nul-terminate and return a copy...
+ *bufptr = '\0';
+
+ return (strdup(buffer));
+
+ // Report encoding errors here...
+ encode_error:
+
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Form data too large."), 1);
+
+ return (NULL);
+}
+
+
+//
+// 'decode_string()' - Decode a URL-encoded string.
+//
+
+static const char * // O - New pointer into string or `NULL` on error
+decode_string(const char *data, // I - Pointer into data string
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
+{
+ int ch; // Current character
+ char *ptr, // Pointer info buffer
+ *end; // Pointer to end of buffer
+
+
+ for (ptr = buffer, end = buffer + bufsize - 1; isalnum(*data & 255) || *data == '%' || *data == '+'; data ++)
+ {
+ if ((ch = *data) == '+')
+ {
+ // "+" is an escaped space...
+ ch = ' ';
+ }
+ else if (ch == '%')
+ {
+ // "%HH" is a hex-escaped character...
+ if (!strncasecmp(data, "%0D%0A", 6))
+ data += 3; // Convert CR LF to just LF
+
+ if (isxdigit(data[1] & 255) && isxdigit(data[2] & 255))
+ {
+ data ++;
+ if (isalpha(*data & 255))
+ ch = (tolower(*data & 255) - 'a' + 10) << 4;
+ else
+ ch = (*data - '0') << 4;
+
+ data ++;
+ if (isalpha(*data & 255))
+ ch += tolower(*data & 255) - 'a' + 10;
+ else
+ ch += *data - '0';
+
+ if (ch == 0)
+ return (NULL); // Nul characters are not allowed
+ }
+ else
+ {
+ // Bad hex escape
+ return (NULL);
+ }
+ }
+
+ if (ch && ptr < end)
+ *ptr++ = (char)ch;
+ }
+
+ *ptr = '\0';
+
+ return (data);
+}
+
+
+//
+// 'encode_string()' - URL-encode a string.
+//
+// The new buffer pointer can go past bufend, but we don't write past there...
+//
+
+static char * // O - New buffer pointer
+encode_string(const char *s, // I - String to encode
+ char *bufptr, // I - Pointer into buffer
+ char *bufend) // I - End of buffer
+{
+ static const char *hex = "0123456789ABCDEF";
+ // Hex digits
+
+
+ // Loop through the string and encode it as needed...
+ while (*s)
+ {
+ if (*s == ' ')
+ {
+ // Space is encoded as '+'
+ *bufptr++ = '+';
+ }
+ else if (*s == '\n')
+ {
+ // Newline is encoded as percent-encoded CR & LF
+ *bufptr++ = '%';
+ if (bufptr < bufend)
+ *bufptr++ = '0';
+ else
+ bufptr ++;
+ if (bufptr < bufend)
+ *bufptr++ = 'D';
+ else
+ bufptr ++;
+ if (bufptr < bufend)
+ *bufptr++ = '%';
+ else
+ bufptr ++;
+ if (bufptr < bufend)
+ *bufptr++ = '0';
+ else
+ bufptr ++;
+ if (bufptr < bufend)
+ *bufptr++ = 'A';
+ else
+ bufptr ++;
+ }
+ else if (!isalnum(*s & 255))
+ {
+ // Characters other than letters and numbers get percent-encoded
+ *bufptr++ = '%';
+ if (bufptr < bufend)
+ *bufptr++ = hex[(*s >> 4) & 15];
+ else
+ bufptr ++;
+ if (bufptr < bufend)
+ *bufptr++ = hex[*s & 15];
+ else
+ bufptr ++;
+ }
+ else if (bufptr < bufend)
+ {
+ // Otherwise this character can be used literally...
+ *bufptr++ = *s;
+ }
+ else
+ {
+ bufptr ++;
+ }
+
+ s ++;
+ }
+
+ // Nul-terminate the output string...
+ if (bufptr <= bufend)
+ *bufptr = '\0';
+ else
+ *bufend = '\0';
+
+ return (bufptr);
+}
--- /dev/null
+//
+// Form API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#ifndef _CUPS_FORM_H_
+# define _CUPS_FORM_H_
+# include "cups.h"
+# ifdef __cplusplus
+extern "C" {
+# endif // __cplusplus
+
+
+//
+// Functions...
+//
+
+extern int cupsFormDecode(const char *data, cups_option_t **vars) _CUPS_PUBLIC;
+extern char *cupsFormEncode(const char *url, int num_vars, cups_option_t *vars) _CUPS_PUBLIC;
+
+
+# ifdef __cplusplus
+}
+# endif // __cplusplus
+#endif // !_CUPS_FORM_H_
-/*
- * getifaddrs definitions for CUPS.
- *
- * Copyright 2007-2018 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.
- */
+//
+// getifaddrs definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 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_GETIFADDRS_INTERNAL_H_
# define _CUPS_GETIFADDRS_INTERNAL_H_
-
-/*
- * Include necessary headers...
- */
-
# include "config.h"
-# include "versioning.h"
+# include "base.h"
# ifdef _WIN32
# define _WINSOCK_DEPRECATED_NO_WARNINGS 1
# include <io.h>
# include <sys/socket.h>
# include <netinet/in.h>
# define CUPS_SOCAST
-# endif /* _WIN32 */
-
+# endif // _WIN32
# if defined(__APPLE__) && !defined(_SOCKLEN_T)
-/*
- * macOS 10.2.x does not define socklen_t, and in fact uses an int instead of
- * unsigned type for length values...
- */
-
+//
+// macOS 10.2.x does not define socklen_t, and in fact uses an int instead of
+// unsigned type for length values...
+//
typedef int socklen_t;
-# endif /* __APPLE__ && !_SOCKLEN_T */
-
+# endif // __APPLE__ && !_SOCKLEN_T
# ifndef _WIN32
# include <net/if.h>
# include <resolv.h>
# include <sys/ioctl.h>
# ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
-# endif /* HAVE_SYS_SOCKIO_H */
-# endif /* HAVE_GETIFADDRS */
-# endif /* !_WIN32 */
-
-
-/*
- * C++ magic...
- */
-
+# endif // HAVE_SYS_SOCKIO_H
+# endif // HAVE_GETIFADDRS
+# endif // !_WIN32
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Some OS's don't have getifaddrs() and freeifaddrs()...
- */
+//
+// Some OS's don't have getifaddrs() and freeifaddrs()...
+//
# if !defined(_WIN32) && !defined(HAVE_GETIFADDRS)
# ifdef ifa_dstaddr
# undef ifa_dstaddr
-# endif /* ifa_dstaddr */
+# endif // ifa_dstaddr
# ifndef ifr_netmask
# define ifr_netmask ifr_addr
-# endif /* !ifr_netmask */
+# endif // !ifr_netmask
-struct ifaddrs /**** Interface Structure ****/
+struct ifaddrs // Interface Structure
{
- struct ifaddrs *ifa_next; /* Next interface in list */
- char *ifa_name; /* Name of interface */
- unsigned int ifa_flags; /* Flags (up, point-to-point, etc.) */
- struct sockaddr *ifa_addr, /* Network address */
- *ifa_netmask; /* Address mask */
+ struct ifaddrs *ifa_next; // Next interface in list
+ char *ifa_name; // Name of interface
+ unsigned int ifa_flags; // Flags (up, point-to-point, etc.)
+ struct sockaddr *ifa_addr, // Network address
+ *ifa_netmask; // Address mask
union
{
- struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
- struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */
+ struct sockaddr *ifu_broadaddr; // Broadcast address of this interface.
+ struct sockaddr *ifu_dstaddr; // Point-to-point destination address.
} ifa_ifu;
- void *ifa_data; /* Interface statistics */
+ void *ifa_data; // Interface statistics
};
# ifndef ifa_broadaddr
# define ifa_broadaddr ifa_ifu.ifu_broadaddr
-# endif /* !ifa_broadaddr */
+# endif // !ifa_broadaddr
# ifndef ifa_dstaddr
# define ifa_dstaddr ifa_ifu.ifu_dstaddr
-# endif /* !ifa_dstaddr */
+# endif // !ifa_dstaddr
extern int _cups_getifaddrs(struct ifaddrs **addrs) _CUPS_PRIVATE;
# define getifaddrs _cups_getifaddrs
extern void _cups_freeifaddrs(struct ifaddrs *addrs) _CUPS_PRIVATE;
# define freeifaddrs _cups_freeifaddrs
-# endif /* !_WIN32 && !HAVE_GETIFADDRS */
+# endif // !_WIN32 && !HAVE_GETIFADDRS
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_GETIFADDRS_INTERNAL_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_GETIFADDRS_INTERNAL_H_
#ifndef _CUPS_HTTP_H_
# define _CUPS_HTTP_H_
-# include "versioning.h"
+# include "base.h"
# include "array.h"
# include <string.h>
# include <time.h>
case IPP_TAG_STRING :
for (i = 0; i < count; i ++)
{
- size_t len; // Length of octetString
+ int len; // Length of octetString
const char *s = (const char *)ippGetOctetString(attr, i, &len);
// octetString value
--- /dev/null
+//
+// Private JSON API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#ifndef _CUPS_JSON_PRIVATE_H_
+# define _CUPS_JSON_PRIVATE_H_
+# include "json.h"
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+
+
+//
+// Functions...
+//
+
+extern void _cupsJSONAdd(cups_json_t *parent, cups_json_t *after, cups_json_t *node) _CUPS_PRIVATE;
+extern void _cupsJSONDelete(cups_json_t *json, const char *key) _CUPS_PRIVATE;
+
+
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+#endif // !_CUPS_JSON_PRIVATE_H_
--- /dev/null
+//
+// JSON API implementation for CUPS.
+//
+// Copyright © 2022-2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "cups-private.h"
+#include "json-private.h"
+#include <sys/stat.h>
+
+
+//
+// Private types...
+//
+
+struct _cups_json_s // JSON node
+{
+ cups_jtype_t type; // Node type
+ cups_json_t *parent, // Parent node, if any
+ *sibling; // Next sibling node, if any
+ union
+ {
+ cups_json_t *child; // First child node
+ double number; // Number value
+ char *string; // String value
+ } value; // Value, if any
+};
+
+
+//
+// Local functions...
+//
+
+static void delete_json(cups_json_t *json);
+static void free_json(cups_json_t *json);
+
+
+//
+// '_cupsJSONAdd()' - Add a node to a JSON node.
+//
+
+void
+_cupsJSONAdd(cups_json_t *parent, // I - Parent JSON node
+ cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
+ cups_json_t *node) // I - JSON node to add
+{
+ cups_json_t *current; // Current node
+
+
+ node->parent = parent;
+
+ if (after)
+ {
+ // Append after the specified sibling...
+ node->sibling = after->sibling;
+ after->sibling = node;
+ }
+ else if ((current = parent->value.child) != NULL)
+ {
+ // Find the last child...
+ while (current && current->sibling)
+ current = current->sibling;
+
+ current->sibling = node;
+ }
+ else
+ {
+ // This is the first child...
+ parent->value.child = node;
+ }
+}
+
+
+//
+// '_cupsJSONDelete()' - Delete a key + value pair.
+//
+
+void
+_cupsJSONDelete(cups_json_t *json, // I - JSON node
+ const char *key) // I - Key
+{
+ cups_json_t *prev,
+ *current, // Current child node
+ *sibling; // Sibling (value) node
+
+
+ // Range check input...
+ if (!json || json->type != CUPS_JTYPE_OBJECT)
+ return;
+
+ // Search for the named key...
+ for (prev = NULL, current = json->value.child; current; prev = current, current = current->sibling)
+ {
+ if (current->type == CUPS_JTYPE_KEY && !strcmp(key, current->value.string))
+ {
+ // Remove the current and next siblings from the parent...
+ sibling = current->sibling;
+
+ if (prev)
+ prev->sibling = sibling->sibling;
+ else
+ json->value.child = sibling->sibling;
+
+ // Delete the key and value...
+ delete_json(current);
+ delete_json(sibling);
+ return;
+ }
+ }
+}
+
+
+//
+// 'cupsJSONDelete()' - Delete a JSON node and all of its children.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJSONDelete(cups_json_t *json) // I - JSON node
+{
+ cups_json_t *child; // Child node
+
+
+ // Range check input...
+ if (!json)
+ return;
+
+ // Remove the node from its parent...
+ if (json->parent)
+ {
+ if ((child = json->parent->value.child) == json)
+ {
+ // This is the first child of the parent...
+ json->parent->value.child = json->sibling;
+ }
+ else
+ {
+ // Find this node in the list of children...
+ while (child)
+ {
+ if (child->sibling == json)
+ {
+ child->sibling = json->sibling;
+ break;
+ }
+
+ child = child->sibling;
+ }
+ }
+ }
+
+ // Free the value(s)
+ delete_json(json);
+}
+
+
+
+//
+// 'cupsJSONExportFile()' - Save a JSON node tree to a file.
+//
+// @since CUPS 2.5@
+//
+
+bool // O - `true` on success, `false` on failure
+cupsJSONExportFile(
+ cups_json_t *json, // I - JSON root node
+ const char *filename) // I - JSON filename
+{
+ char *s; // JSON string
+ int fd; // JSON file
+
+
+ DEBUG_printf("cupsJSONExportFile(json=%p, filename=\"%s\")", (void *)json, filename);
+
+ // Get the JSON as a string...
+ if ((s = cupsJSONExportString(json)) == NULL)
+ return (false);
+
+ // Create the file...
+ if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ free(s);
+ return (false);
+ }
+
+ if (write(fd, s, strlen(s)) < 0)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ close(fd);
+ unlink(filename);
+ free(s);
+ return (false);
+ }
+
+ close(fd);
+ free(s);
+
+ return (true);
+}
+
+
+//
+// 'cupsJSONExportString()' - Save a JSON node tree to a string.
+//
+// This function saves a JSON node tree to an allocated string. The resulting
+// string must be freed using the `free` function.
+//
+// @since CUPS 2.5@
+//
+
+char * // O - JSON string or `NULL` on error
+cupsJSONExportString(cups_json_t *json) // I - JSON root node
+{
+ cups_json_t *current; // Current node
+ size_t length; // Length of JSON data as a string
+ char *s, // JSON string
+ *ptr; // Pointer into string
+ const char *value; // Pointer into string value
+ struct lconv *loc; // Locale data
+
+
+ DEBUG_printf("cupsJSONExportString(json=%p)", (void *)json);
+
+ // Range check input...
+ if (!json)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ DEBUG_puts("3cupsJSONExportString: Returning NULL.");
+ return (NULL);
+ }
+
+ // Figure out the necessary space needed in the string
+ current = json;
+ length = 1; // nul
+
+ while (current)
+ {
+ if (current->parent && current->parent->value.child != current)
+ length ++; // Comma or colon separator
+
+ switch (current->type)
+ {
+ case CUPS_JTYPE_NULL :
+ case CUPS_JTYPE_TRUE :
+ length += 4;
+ break;
+
+ case CUPS_JTYPE_FALSE :
+ length += 5;
+ break;
+
+ case CUPS_JTYPE_ARRAY :
+ case CUPS_JTYPE_OBJECT :
+ length += 2; // Brackets/braces
+ break;
+
+ case CUPS_JTYPE_NUMBER :
+ length += 32;
+ break;
+
+ case CUPS_JTYPE_KEY :
+ case CUPS_JTYPE_STRING :
+ length += 2; // Quotes
+ for (value = current->value.string; *value; value ++)
+ {
+ if (strchr("\\\"\b\f\n\r\t", *value))
+ length += 2; // Simple escaped char
+ else if ((*value & 255) < ' ')
+ length += 6; // Worst case for control char
+ else
+ length ++; // Literal char
+ }
+ break;
+ }
+
+ // Get next node...
+ if ((current->type == CUPS_JTYPE_ARRAY || current->type == CUPS_JTYPE_OBJECT) && current->value.child)
+ {
+ // Descend
+ current = current->value.child;
+ }
+ else if (current->sibling)
+ {
+ // Visit silbling
+ current = current->sibling;
+ }
+ else
+ {
+ // Ascend and continue...
+ current = current->parent;
+ while (current)
+ {
+ if (current->sibling)
+ {
+ current = current->sibling;
+ break;
+ }
+ else
+ {
+ current = current->parent;
+ }
+ }
+ }
+ }
+
+ DEBUG_printf("2cupsJSONExportString: length=%u", (unsigned)length);
+
+ // Allocate memory and fill it up...
+ if ((s = malloc(length)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ DEBUG_puts("3cupsJSONExportString: Returning NULL.");
+ return (NULL);
+ }
+
+ current = json;
+ ptr = s;
+ loc = localeconv();
+
+ while (current)
+ {
+ if (current->parent && current->parent->value.child != current)
+ {
+ // Add separator
+ if (current->type == CUPS_JTYPE_KEY || current->parent->type == CUPS_JTYPE_ARRAY)
+ *ptr++ = ',';
+ else
+ *ptr++ = ':';
+ }
+
+ switch (current->type)
+ {
+ case CUPS_JTYPE_NULL :
+ memcpy(ptr, "null", 4);
+ ptr += 4;
+ break;
+
+ case CUPS_JTYPE_TRUE :
+ memcpy(ptr, "true", 4);
+ ptr += 4;
+ break;
+
+ case CUPS_JTYPE_FALSE :
+ memcpy(ptr, "false", 5);
+ ptr += 5;
+ break;
+
+ case CUPS_JTYPE_ARRAY :
+ *ptr++ = '[';
+ break;
+
+ case CUPS_JTYPE_OBJECT :
+ *ptr++ = '{';
+ break;
+
+ case CUPS_JTYPE_NUMBER :
+ _cupsStrFormatd(ptr, s + length, current->value.number, loc);
+ ptr += strlen(ptr);
+ break;
+
+ case CUPS_JTYPE_KEY :
+ case CUPS_JTYPE_STRING :
+ *ptr++ = '\"';
+
+ for (value = current->value.string; *value; value ++)
+ {
+ // Quote/escape as needed...
+ if (*value == '\\' || *value == '\"')
+ {
+ *ptr++ = '\\';
+ *ptr++ = *value;
+ }
+ else if (*value == '\b')
+ {
+ *ptr++ = '\\';
+ *ptr++ = 'b';
+ }
+ else if (*value == '\f')
+ {
+ *ptr++ = '\\';
+ *ptr++ = 'f';
+ }
+ else if (*value == '\n')
+ {
+ *ptr++ = '\\';
+ *ptr++ = 'n';
+ }
+ else if (*value == '\r')
+ {
+ *ptr++ = '\\';
+ *ptr++ = 'r';
+ }
+ else if (*value == '\t')
+ {
+ *ptr++ = '\\';
+ *ptr++ = 't';
+ }
+ if ((*value & 255) < ' ')
+ {
+ snprintf(ptr, length - (size_t)(ptr - s), "\\u%04x", *value);
+ ptr += 6;
+ }
+ else
+ {
+ *ptr++ = *value;
+ }
+ }
+
+ *ptr++ = '\"';
+ break;
+ }
+
+ // Get next node...
+ if ((current->type == CUPS_JTYPE_ARRAY || current->type == CUPS_JTYPE_OBJECT) && current->value.child)
+ {
+ // Descend
+ current = current->value.child;
+ }
+ else if (current->sibling)
+ {
+ // Visit silbling
+ current = current->sibling;
+ }
+ else if ((current = current->parent) != NULL)
+ {
+ // Ascend and continue...
+ if (current->type == CUPS_JTYPE_ARRAY)
+ *ptr++ = ']';
+ else
+ *ptr++ = '}';
+
+ while (current)
+ {
+ if (current->sibling)
+ {
+ current = current->sibling;
+ break;
+ }
+ else if ((current = current->parent) != NULL)
+ {
+ if (current->type == CUPS_JTYPE_ARRAY)
+ *ptr++ = ']';
+ else
+ *ptr++ = '}';
+ }
+ }
+ }
+ }
+
+ *ptr = '\0';
+
+ DEBUG_printf("3cupsJSONExportString: Returning \"%s\".", s);
+
+ return (s);
+}
+
+
+//
+// 'cupsJSONFind()' - Find the value(s) associated with a given key.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON value or `NULL`
+cupsJSONFind(cups_json_t *json, // I - JSON object node
+ const char *key) // I - Object key
+{
+ cups_json_t *current; // Current child node
+
+
+ // Range check input...
+ if (!json || json->type != CUPS_JTYPE_OBJECT)
+ return (NULL);
+
+ // Search for the named key...
+ for (current = json->value.child; current; current = current->sibling)
+ {
+ if (current->type == CUPS_JTYPE_KEY && !strcmp(key, current->value.string))
+ return (current->sibling);
+ }
+
+ // If we get here there was no match...
+ return (NULL);
+}
+
+
+//
+// 'cupsJSONGetChild()' - Get the first child node of an array or object node.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - First child node or `NULL`
+cupsJSONGetChild(cups_json_t *json, // I - JSON array or object node
+ size_t n) // I - Child node number (starting at `0`)
+{
+ cups_json_t *current; // Current child node
+
+
+ // Range check input...
+ if (!json || (json->type != CUPS_JTYPE_ARRAY && json->type != CUPS_JTYPE_OBJECT))
+ return (NULL);
+
+ // Search for the Nth child...
+ for (current = json->value.child; n > 0 && current; current = current->sibling)
+ n --;
+
+ // Return the child node pointer...
+ return (current);
+}
+
+
+//
+// 'cupsJSONGetCount()' - Get the number of child nodes.
+//
+// @since CUPS 2.5@
+//
+
+size_t // O - Number of child nodes
+cupsJSONGetCount(cups_json_t *json) // I - JSON array or object node
+{
+ cups_json_t *current; // Current child node
+ size_t n; // Number of child nodes
+
+ // Range check input...
+ if (!json || (json->type != CUPS_JTYPE_ARRAY && json->type != CUPS_JTYPE_OBJECT))
+ return (0);
+
+ // Count the child nodes...
+ for (current = json->value.child, n = 0; current; current = current->sibling)
+ n ++;
+
+ // Return the count...
+ return (n);
+}
+
+
+//
+// 'cupsJSONGetKey()' - Get the key string, if any.
+//
+// This function returns the key string for a JSON key node or `NULL` if
+// the node is not a key.
+//
+// @since CUPS 2.5@
+//
+
+const char * // O - String value
+cupsJSONGetKey(cups_json_t *json) // I - JSON string node
+{
+ return (json && json->type == CUPS_JTYPE_KEY ? json->value.string : NULL);
+}
+
+
+//
+// 'cupsJSONGetParent()' - Get the parent node, if any.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Parent node or `NULL` if none
+cupsJSONGetParent(cups_json_t *json) // I - JSON node
+{
+ return (json ? json->parent : NULL);
+}
+
+
+//
+// 'cupsJSONGetSibling()' - Get the next sibling node, if any.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Sibling node or `NULL` if none
+cupsJSONGetSibling(cups_json_t *json) // I - JSON node
+{
+ return (json ? json->sibling : NULL);
+}
+
+
+//
+// 'cupsJSONGetNumber()' - Get the number value, if any.
+//
+// This function returns the number value for a JSON number node or `0.0` if
+// the node is not a number.
+//
+// @since CUPS 2.5@
+//
+
+double // O - Number value
+cupsJSONGetNumber(cups_json_t *json) // I - JSON number node
+{
+ return (json && json->type == CUPS_JTYPE_NUMBER ? json->value.number : 0.0);
+}
+
+
+//
+// 'cupsJSONGetString()' - Get the string value, if any.
+//
+// This function returns the string value for a JSON string node or `NULL` if
+// the node is not a string.
+//
+// @since CUPS 2.5@
+//
+
+const char * // O - String value
+cupsJSONGetString(cups_json_t *json) // I - JSON string node
+{
+ return (json && json->type == CUPS_JTYPE_STRING ? json->value.string : NULL);
+}
+
+
+//
+// 'cupsJSONGetType()' - Get the type of a JSON node.
+//
+// @since CUPS 2.5@
+//
+
+cups_jtype_t // O - JSON node type
+cupsJSONGetType(cups_json_t *json) // I - JSON node
+{
+ return (json ? json->type : CUPS_JTYPE_NULL);
+}
+
+
+//
+// 'cupsJSONImportFile()' - Load a JSON object file.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Root JSON object node
+cupsJSONImportFile(const char *filename)// I - JSON filename
+{
+ cups_json_t *json; // Root JSON object node
+ int fd; // JSON file
+ struct stat fileinfo; // JSON file information
+ char *s; // Allocated string containing JSON file
+ ssize_t bytes; // Bytes read
+
+
+ // Range check input...
+ if (!filename)
+ return (NULL);
+
+ // Try opening the file...
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ return (NULL);
+ }
+ else if (fstat(fd, &fileinfo))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ close(fd);
+ return (NULL);
+ }
+ else if (fileinfo.st_size > 16777216)
+ {
+ // Don't support JSON files over 16MiB
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("JSON file too large."), 1);
+ close(fd);
+ return (NULL);
+ }
+
+ // Allocate memory for the JSON file...
+ if ((s = malloc((size_t)fileinfo.st_size + 1)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ close(fd);
+ return (NULL);
+ }
+
+ // Read the file into the allocated string...
+ if ((bytes = read(fd, s, (size_t)fileinfo.st_size)) < 0)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ close(fd);
+ free(s);
+ return (NULL);
+ }
+
+ s[bytes] = '\0';
+ close(fd);
+
+ // Load the resulting string
+ json = cupsJSONImportString(s);
+
+ // Free the string and return...
+ free(s);
+
+ return (json);
+}
+
+
+//
+// 'cupsJSONImportString()' - Load a JSON object from a string.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Root JSON object node
+cupsJSONImportString(const char *s) // I - JSON string
+{
+ cups_json_t *json, // Root JSON object node
+ *parent, // Current parent node
+ *prev = NULL, // Previous node
+ *current; // Current node
+ size_t count; // Number of children
+ struct lconv *loc; // Locale data
+ static const char *sep = ",]} \n\r\t";// Separator chars
+
+
+ DEBUG_printf("cupsJSONImportString(s=\"%s\")", s);
+
+ // Range check input...
+ if (!s || *s != '{')
+ {
+ DEBUG_puts("2cupsJSONImportString: Doesn't start with '{'.");
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid JSON data."), 1);
+ return (NULL);
+ }
+
+ // Create the root node...
+ if ((json = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to create root object.");
+ return (NULL);
+ }
+
+ // Parse until we get to the end...
+ parent = json;
+ count = 0;
+ loc = localeconv();
+ s ++;
+
+ while (*s)
+ {
+ // Skip leading whitespace/separators
+ while (*s && isspace(*s & 255))
+ s ++;
+
+ if (parent->type == CUPS_JTYPE_ARRAY)
+ {
+ // Arrays can have multiple values separated by commas and whitespace...
+ if (*s == ',')
+ {
+ // Comma (value) separator...
+ if (!parent->value.child)
+ {
+ // Cannot have a comma here
+ DEBUG_puts("2cupsJSONImportString: Unexpected comma.");
+ goto invalid;
+ }
+
+ s ++;
+ while (*s && isspace(*s & 255))
+ s ++;
+ }
+ }
+ else
+ {
+ // Objects have colons between key and value and commas between key/value
+ // pairs...
+ if (*s == ',')
+ {
+ // Comma (value) separator...
+ if (!parent->value.child || (count & 1))
+ {
+ // Cannot have a comma here
+ DEBUG_puts("2cupsJSONImportString: Unexpected comma.");
+ goto invalid;
+ }
+
+ s ++;
+ while (*s && isspace(*s & 255))
+ s ++;
+ }
+ else if (*s == ':')
+ {
+ if (!parent->value.child || !(count & 1))
+ {
+ // Cannot have a colon here
+ DEBUG_puts("2cupsJSONImportString: Unexpected colon.");
+ goto invalid;
+ }
+
+ s ++;
+ while (*s && isspace(*s & 255))
+ s ++;
+ }
+ else if (count & 1)
+ {
+ // Missing colon...
+ DEBUG_puts("2cupsJSONImportString: Missing colon.");
+ goto invalid;
+ }
+
+ if (!(count & 1) && *s != '\"' && *s != '}')
+ {
+ // Need a key string here...
+ DEBUG_puts("2cupsJSONImportString: Missing key string.");
+ goto invalid;
+ }
+ }
+
+ // Parse the key/value
+ if (*s == '\"')
+ {
+ // String
+ size_t len; // Length of value
+ const char *start; // Start of value
+ char *ptr; // Pointer into string
+
+ // Find the end of the string...
+ for (s ++, start = s, len = 1; *s && *s != '\"'; s ++, len ++)
+ {
+ if (*s == '\\')
+ {
+ // Ensure escaped character is valid...
+ s ++;
+ if (!*s || !strchr("\"\\/bfnrtu", *s))
+ {
+ DEBUG_printf("2cupsJSONImportString: Bad escape '\\%c'.", *s);
+ goto invalid;
+ }
+ else if (*s == 'u' && (!isxdigit(s[1] & 255) || !isxdigit(s[2] & 255) || !isxdigit(s[3] & 255) || !isxdigit(s[4] & 255)))
+ {
+ DEBUG_printf("2cupsJSONImportString: Bad escape '\\%s'.", s);
+ goto invalid;
+ }
+ }
+ else if ((*s & 255) < ' ')
+ {
+ // Control characters are not allowed in a string...
+ DEBUG_printf("2cupsJSONImportString: Bad control character 0x%02x in string.", *s);
+ goto invalid;
+ }
+ }
+
+ if (!*s)
+ {
+ // Missing close quote...
+ DEBUG_puts("2cupsJSONImportString: Missing close quote.");
+ goto invalid;
+ }
+
+ // Allocate and copy the string over...
+ if (parent->type == CUPS_JTYPE_OBJECT && !(count & 1))
+ current = cupsJSONNew(parent, prev, CUPS_JTYPE_KEY);
+ else
+ current = cupsJSONNew(parent, prev, CUPS_JTYPE_STRING);
+
+ if (!current)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate key/string node.");
+ goto error;
+ }
+ else if ((current->value.string = malloc(len)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ goto error;
+ }
+
+ for (s = start, ptr = current->value.string; *s && *s != '\"'; s ++)
+ {
+ if (*s == '\\')
+ {
+ // Copy quoted character...
+ s ++;
+
+ if (strchr("\\\"/", *s))
+ {
+ // Backslash, quote, or slash...
+ *ptr++ = *s;
+ }
+ else if (*s == 'b')
+ {
+ // Backspace
+ *ptr++ = '\b';
+ }
+ else if (*s == 'f')
+ {
+ // Formfeed
+ *ptr++ = '\f';
+ }
+ else if (*s == 'n')
+ {
+ // Linefeed
+ *ptr++ = '\n';
+ }
+ else if (*s == 'r')
+ {
+ // Carriage return
+ *ptr++ = '\r';
+ }
+ else if (*s == 't')
+ {
+ // Tab
+ *ptr++ = '\t';
+ }
+ else if (*s == 'u')
+ {
+ // Unicode character
+ int ch, // Unicode character
+ digit; // Current digit
+
+ // Convert hex digits to a 16-bit Unicode character
+ for (ch = 0, digit = 0; digit < 4; digit ++)
+ {
+ s ++;
+ ch <<= 4;
+ if (isdigit(*s))
+ ch |= *s - '0';
+ else
+ ch |= tolower(*s) - 'a' + 10;
+ }
+
+ // Convert 16-bit Unicode character to UTF-8...
+ if (ch < 0x80)
+ {
+ // ASCII
+ *ptr++ = (char)ch;
+ }
+ else if (ch < 0x800)
+ {
+ // 2-byte UTF-8
+ *ptr++ = (char)(0xc0 | (ch >> 6));
+ *ptr++ = (char)(0x80 | (ch & 0x3f));
+ }
+ else
+ {
+ // 3-byte UTF-8
+ *ptr++ = (char)(0xe0 | (ch >> 12));
+ *ptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *ptr++ = (char)(0x80 | (ch & 0x3f));
+ }
+ }
+ }
+ else
+ {
+ // Copy literal character...
+ *ptr++ = *s;
+ }
+ }
+
+ *ptr = '\0';
+ if (*s == '\"')
+ s ++;
+
+ count ++;
+ prev = current;
+
+ DEBUG_printf("3cupsJSONImportString: Added %s '%s'.", current->type == CUPS_JTYPE_KEY ? "key" : "string", current->value.string);
+ }
+ else if (strchr("0123456789-", *s))
+ {
+ // Number
+ if ((current = cupsJSONNew(parent, prev, CUPS_JTYPE_NUMBER)) == NULL)
+ goto error;
+
+ current->value.number = _cupsStrScand(s, (char **)&s, loc);
+ count ++;
+ prev = current;
+
+ DEBUG_printf("3cupsJSONImportString: Added number %g.", current->value.number);
+ }
+ else if (*s == '{')
+ {
+ // Start object
+ if ((parent = cupsJSONNew(parent, prev, CUPS_JTYPE_OBJECT)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate object.");
+ goto error;
+ }
+
+ count = 0;
+ prev = NULL;
+ s ++;
+
+ DEBUG_puts("3cupsJSONImportString: Opened object.");
+ }
+ else if (*s == '}')
+ {
+ // End object
+ if (parent->type != CUPS_JTYPE_OBJECT)
+ {
+ // Not in an object, so this is unexpected...
+ DEBUG_puts("2cupsJSONImportString: Got '}' in an array.");
+ goto invalid;
+ }
+
+ DEBUG_puts("3cupsJSONImportString: Closed object.");
+
+ if ((parent = parent->parent) == NULL)
+ break;
+
+ count = cupsJSONGetCount(parent);
+ prev = NULL;
+ s ++;
+ }
+ else if (*s == '[')
+ {
+ // Start array
+ if ((parent = cupsJSONNew(parent, prev, CUPS_JTYPE_ARRAY)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate array.");
+ goto error;
+ }
+
+ count = 0;
+ prev = NULL;
+ s ++;
+
+ DEBUG_puts("3cupsJSONImportString: Opened array.");
+ }
+ else if (*s == ']')
+ {
+ // End array
+ if (parent->type != CUPS_JTYPE_ARRAY)
+ {
+ // Not in an array, so this is unexpected...
+ DEBUG_puts("2cupsJSONImportString: Got ']' in an object.");
+ goto invalid;
+ }
+
+ DEBUG_puts("3cupsJSONImportString: Closed array.");
+
+ parent = parent->parent;
+ count = cupsJSONGetCount(parent);
+ prev = NULL;
+ s ++;
+ }
+ else if (!strncmp(s, "null", 4) && strchr(sep, s[4]))
+ {
+ // null value
+ if ((prev = cupsJSONNew(parent, prev, CUPS_JTYPE_NULL)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate null value.");
+ goto error;
+ }
+
+ count ++;
+ s += 4;
+
+ DEBUG_puts("3cupsJSONImportString: Added null value.");
+ }
+ else if (!strncmp(s, "false", 5) && strchr(sep, s[5]))
+ {
+ // false value
+ if ((prev = cupsJSONNew(parent, prev, CUPS_JTYPE_FALSE)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate false value.");
+ goto error;
+ }
+
+ count ++;
+ s += 5;
+
+ DEBUG_puts("3cupsJSONImportString: Added false value.");
+ }
+ else if (!strncmp(s, "true", 4) && strchr(sep, s[4]))
+ {
+ // true value
+ if ((prev = cupsJSONNew(parent, prev, CUPS_JTYPE_TRUE)) == NULL)
+ {
+ DEBUG_puts("2cupsJSONImportString: Unable to allocate true value.");
+ goto error;
+ }
+
+ count ++;
+ s += 4;
+
+ DEBUG_puts("3cupsJSONImportString: Added true value.");
+ }
+ else
+ {
+ // Something else we don't understand...
+ DEBUG_printf("2cupsJSONImportString: Unexpected '%s'.", s);
+ goto invalid;
+ }
+ }
+
+ if (*s != '}')
+ {
+ DEBUG_puts("2cupsJSONImportString: Missing '}' at end.");
+ goto invalid;
+ }
+
+ DEBUG_printf("3cupsJSONImportString: Returning %p (%u children)", (void *)json, (unsigned)cupsJSONGetCount(json));
+
+ return (json);
+
+ // If we get here we saw something we didn't understand...
+ invalid:
+
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid JSON data."), 1);
+
+ // and here if we have another error that is already recorded...
+ error:
+
+ cupsJSONDelete(json);
+
+ DEBUG_puts("3cupsJSONImportString: Returning NULL.");
+
+ return (NULL);
+}
+
+
+//
+// 'cupsJSONImportURL()' - Load a JSON object from a URL.
+//
+// This function loads a JSON object from a URL. The "url" can be a "http:" or
+// "https:" URL. The "last_modified" argument provides a pointer to a `time_t`
+// variable with the last modified date and time from a previous load. If
+// `NULL` or the variable has a value of 0, the JSON is loaded unconditionally
+// from the URL.
+//
+// On success, a pointer to the root JSON object node is returned and the
+// "last_modified" variable, if not `NULL`, is updated to the Last-Modified
+// date and time returned by the server. Otherwise, `NULL` is returned with
+// the @link cupsGetError@ value set to `IPP_STATUS_OK_EVENTS_COMPLETE` if
+// the JSON data has not been updated since the "last_modified" date and time
+// or a suitable `IPP_STATUS_ERROR_` value if an error occurred.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Root JSON object node
+cupsJSONImportURL(
+ const char *url, // I - URL
+ time_t *last_modified) // IO - Last modified date/time or `NULL`
+{
+ char scheme[32], // URL scheme
+ userpass[64], // URL username:password info
+ host[256], // URL hostname
+ resource[1024]; // URL resource path
+ int port; // URL port number
+ http_uri_status_t uri_status; // URL decode status
+ http_encryption_t encryption; // Encryption to use
+ http_t *http; // HTTP connection
+ http_status_t status; // HTTP request status
+ http_state_t initial_state; // Initial HTTP state
+ char if_modified_since[HTTP_MAX_VALUE];
+ // If-Modified-Since header
+ bool new_auth = false, // Using new auth information?
+ digest; // Are we using Digest authentication?
+ size_t length; // Length of JSON data
+ ssize_t bytes; // Bytes read
+ char *data = NULL, // Pointer to data
+ *dataptr, // Pointer into data
+ *dataend; // Pointer to end of data (less nul byte)
+ cups_json_t *json = NULL; // Root JSON node
+
+
+ // Range check input...
+ if (!url)
+ return (NULL);
+
+ // Get the URL components...
+ if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, url, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource))) < HTTP_URI_STATUS_OK)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, httpURIStatusString(uri_status), 0);
+ return (NULL);
+ }
+
+ if (strcmp(scheme, "http") && strcmp(scheme, "https"))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unsupported URI scheme."), 1);
+ return (NULL);
+ }
+
+ // Connect to the server...
+ if (!strcmp(scheme, "https") || port == 443)
+ encryption = HTTP_ENCRYPTION_ALWAYS;
+ else
+ encryption = HTTP_ENCRYPTION_IF_REQUESTED;
+
+ if ((http = httpConnect2(host, port, NULL, AF_UNSPEC, encryption, true, 30000, NULL)) == NULL)
+ return (NULL);
+
+ // Send a GET request for the resource path...
+ if (last_modified && *last_modified)
+ httpGetDateString2(*last_modified, if_modified_since, sizeof(if_modified_since));
+ else
+ if_modified_since[0] = '\0';
+
+ do
+ {
+ // Reconnect if the Connection header says "close"...
+ if (!_cups_strcasecmp(httpGetField(http, HTTP_FIELD_CONNECTION), "close"))
+ {
+ httpClearFields(http);
+ if (!httpReconnect2(http, 30000, NULL))
+ {
+ status = HTTP_STATUS_ERROR;
+ break;
+ }
+ }
+
+ // Prep for a request...
+ httpClearFields(http);
+ httpSetField(http, HTTP_FIELD_IF_MODIFIED_SINCE, if_modified_since);
+
+ digest = http->authstring && !strncmp(http->authstring, "Digest ", 7);
+
+ if (digest && !new_auth)
+ {
+ // Update the Digest authentication string...
+ _httpSetDigestAuthString(http, http->nextnonce, "GET", resource);
+ }
+
+ httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
+
+ // Send the GET request...
+ if (!httpWriteRequest(http, "GET", resource))
+ {
+ if (httpReconnect2(http, 30000, NULL))
+ {
+ status = HTTP_STATUS_UNAUTHORIZED;
+ continue;
+ }
+ else
+ {
+ status = HTTP_STATUS_ERROR;
+ break;
+ }
+ }
+
+ new_auth = false;
+
+ // Wait for an update/response...
+ while ((status = httpUpdate(http)) == HTTP_STATUS_CONTINUE);
+
+ if (status == HTTP_STATUS_UNAUTHORIZED)
+ {
+ // Need authentication, flush any error message...
+ httpFlush(http);
+
+ // See if we can do authentication...
+ new_auth = true;
+
+ if (!cupsDoAuthentication(http, "GET", resource))
+ {
+ status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
+ break;
+ }
+
+ if (!httpReconnect2(http, 30000, NULL))
+ {
+ status = HTTP_STATUS_ERROR;
+ break;
+ }
+
+ continue;
+ }
+ else if (status == HTTP_STATUS_UPGRADE_REQUIRED)
+ {
+ // Flush any error message...
+ httpFlush(http);
+
+ // Reconnect...
+ if (!httpReconnect2(http, 30000, NULL))
+ {
+ status = HTTP_STATUS_ERROR;
+ break;
+ }
+
+ // Upgrade with encryption...
+ httpSetEncryption(http, HTTP_ENCRYPTION_REQUIRED);
+
+ // Try again, this time with encryption enabled...
+ continue;
+ }
+ }
+ while (status == HTTP_STATUS_UNAUTHORIZED || status == HTTP_STATUS_UPGRADE_REQUIRED);
+
+ initial_state = httpGetState(http);
+
+ if (status == HTTP_STATUS_OK)
+ {
+ // Save the content date...
+ if (last_modified)
+ *last_modified = httpGetDateTime(httpGetField(http, HTTP_FIELD_LAST_MODIFIED));
+
+ // Allocate memory for string...
+ if ((length = (size_t)httpGetLength(http)) == 0 || length > 65536)
+ length = 65536; // Accept up to 64k
+
+ if ((data = calloc(1, length + 1)) != NULL)
+ {
+ // Read the data into the string...
+ for (dataptr = data, dataend = data + length; dataptr < dataend; dataptr += bytes)
+ {
+ if ((bytes = httpRead(http, dataptr, (size_t)(dataend - dataptr))) <= 0)
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Save the last HTTP status as a CUPS error...
+ _cupsSetHTTPError(status);
+ }
+
+ // Flush any remaining data...
+ if (httpGetState(http) == initial_state)
+ httpFlush(http);
+
+ // Close the connection...
+ httpClose(http);
+
+ // Load the JSON data, free the string, and return...
+ if (data)
+ {
+ json = cupsJSONImportString(data);
+ free(data);
+ }
+
+ return (json);
+}
+
+
+//
+// 'cupsJSONNew()' - Create a new JSON node.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON node
+cupsJSONNew(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root node
+ cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
+ cups_jtype_t type) // I - JSON node type
+{
+ cups_json_t *node; // JSON node
+
+
+ // Range check input...
+ if (parent && parent->type != CUPS_JTYPE_ARRAY && parent->type != CUPS_JTYPE_OBJECT)
+ return (NULL);
+
+ // Allocate the node...
+ if ((node = calloc(1, sizeof(cups_json_t))) != NULL)
+ {
+ node->type = type;
+
+ if (parent)
+ _cupsJSONAdd(parent, after, node);
+ }
+
+ return (node);
+}
+
+
+//
+// 'cupsJSONNewKey()' - Create a new JSON key node.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON node
+cupsJSONNewKey(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root node
+ cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
+ const char *value) // I - Key string
+{
+ cups_json_t *node; // JSON node
+ char *s = strdup(value); // Key string
+
+
+ if (!s)
+ return (NULL);
+
+ if ((node = cupsJSONNew(parent, after, CUPS_JTYPE_KEY)) != NULL)
+ node->value.string = s;
+ else
+ free(s);
+
+ return (node);
+}
+
+
+//
+// 'cupsJSONNewNumber()' - Create a new JSON number node.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON node
+cupsJSONNewNumber(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root node
+ cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
+ double value) // I - Number value
+{
+ cups_json_t *node; // JSON node
+
+
+ if ((node = cupsJSONNew(parent, after, CUPS_JTYPE_NUMBER)) != NULL)
+ node->value.number = value;
+
+ return (node);
+}
+
+
+//
+// 'cupsJSONNewString()' - Create a new JSON string node.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON node
+cupsJSONNewString(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root node
+ cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
+ const char *value) // I - String value
+{
+ cups_json_t *node; // JSON node
+ char *s = strdup(value); // String value
+
+
+ if (!s)
+ return (NULL);
+
+ if ((node = cupsJSONNew(parent, after, CUPS_JTYPE_STRING)) != NULL)
+ node->value.string = s;
+ else
+ free(s);
+
+ return (node);
+}
+
+
+//
+// 'delete_json()' - Free the JSON node and its children.
+//
+
+static void
+delete_json(cups_json_t *json) // I - JSON node
+{
+ cups_json_t *child, // Child node
+ *sibling; // Sibling node
+
+
+ if (json->type == CUPS_JTYPE_ARRAY || json->type == CUPS_JTYPE_OBJECT)
+ {
+ for (child = json->value.child; child && child != json; child = sibling)
+ {
+ if ((child->type == CUPS_JTYPE_ARRAY || child->type == CUPS_JTYPE_OBJECT) && child->value.child)
+ {
+ // Descend into child nodes...
+ sibling = child->value.child;
+ }
+ else if ((sibling = child->sibling) == NULL)
+ {
+ // No more silbings, ascend unless the parent is the original node...
+ sibling = child->parent;
+ free_json(child);
+
+ while (sibling && sibling != json)
+ {
+ cups_json_t *temp = sibling; // Save the current pointer
+
+ if (sibling->sibling)
+ {
+ // More siblings at this level, free the parent...
+ sibling = sibling->sibling;
+ free_json(temp);
+ break;
+ }
+ else
+ {
+ // No more siblings, continue upwards...
+ sibling = sibling->parent;
+ free_json(temp);
+ }
+ }
+ }
+ else
+ {
+ // Free the memory for this node
+ free_json(child);
+ }
+ }
+ }
+
+ free_json(json);
+}
+
+
+//
+// 'free_json()' - Free the JSON node.
+//
+
+static void
+free_json(cups_json_t *json) // I - JSON node
+{
+ if (json->type == CUPS_JTYPE_KEY || json->type == CUPS_JTYPE_STRING)
+ free(json->value.string);
+
+ free(json);
+}
+
--- /dev/null
+//
+// JSON API definitions for CUPS.
+//
+// Copyright © 2022-2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#ifndef _CUPS_JSON_H_
+# define _CUPS_JSON_H_
+# include "base.h"
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+
+
+//
+// Types...
+//
+
+typedef enum cups_jtype_e // JSON node type @since CUPS 2.5@
+{
+ CUPS_JTYPE_NULL, // Null value
+ CUPS_JTYPE_FALSE, // Boolean false value
+ CUPS_JTYPE_TRUE, // Boolean true value
+ CUPS_JTYPE_NUMBER, // Number value
+ CUPS_JTYPE_STRING, // String value
+ CUPS_JTYPE_ARRAY, // Array value
+ CUPS_JTYPE_OBJECT, // Object value
+ CUPS_JTYPE_KEY // Object key (string)
+} cups_jtype_t;
+
+typedef struct _cups_json_s cups_json_t;// JSON node @since CUPS 2.5@
+
+
+//
+// Functions...
+//
+
+extern void cupsJSONDelete(cups_json_t *json) _CUPS_PUBLIC;
+
+extern bool cupsJSONExportFile(cups_json_t *json, const char *filename) _CUPS_PUBLIC;
+extern char *cupsJSONExportString(cups_json_t *json) _CUPS_PUBLIC;
+
+extern cups_json_t *cupsJSONFind(cups_json_t *json, const char *key) _CUPS_PUBLIC;
+
+extern cups_json_t *cupsJSONGetChild(cups_json_t *json, size_t n) _CUPS_PUBLIC;
+extern size_t cupsJSONGetCount(cups_json_t *json) _CUPS_PUBLIC;
+extern const char *cupsJSONGetKey(cups_json_t *json) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONGetParent(cups_json_t *json) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONGetSibling(cups_json_t *json) _CUPS_PUBLIC;
+extern double cupsJSONGetNumber(cups_json_t *json) _CUPS_PUBLIC;
+extern const char *cupsJSONGetString(cups_json_t *json) _CUPS_PUBLIC;
+extern cups_jtype_t cupsJSONGetType(cups_json_t *json) _CUPS_PUBLIC;
+
+extern cups_json_t *cupsJSONImportFile(const char *filename) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONImportString(const char *s) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONImportURL(const char *url, time_t *last_modified) _CUPS_PUBLIC;
+
+extern cups_json_t *cupsJSONNew(cups_json_t *parent, cups_json_t *after, cups_jtype_t type) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONNewKey(cups_json_t *parent, cups_json_t *after, const char *value) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONNewNumber(cups_json_t *parent, cups_json_t *after, double number) _CUPS_PUBLIC;
+extern cups_json_t *cupsJSONNewString(cups_json_t *parent, cups_json_t *after, const char *value) _CUPS_PUBLIC;
+
+
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+#endif // !_CUPS_JSON_H_
--- /dev/null
+//
+// JSON Web Token API implementation for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "cups-private.h"
+#include "jwt.h"
+#include "json-private.h"
+#ifdef HAVE_OPENSSL
+# include <openssl/ecdsa.h>
+# include <openssl/evp.h>
+# include <openssl/rsa.h>
+#else // HAVE_GNUTLS
+# include <gnutls/gnutls.h>
+# include <gnutls/abstract.h>
+# include <gnutls/crypto.h>
+#endif // HAVE_OPENSSL
+
+
+//
+// Constants...
+//
+
+#define _CUPS_JWT_MAX_SIGNATURE 2048 // Enough for 512-bit signature
+
+
+//
+// Private types...
+//
+
+struct _cups_jwt_s // JWT object
+{
+ cups_json_t *jose; // JOSE object
+ char *jose_string; // JOSE string
+ cups_json_t *claims; // JWT claims object
+ char *claims_string; // JWT claims string
+ cups_jwa_t sigalg; // Signature algorithm
+ char *sigkid; // Key ID, if any
+ size_t sigsize; // Size of signature
+ unsigned char *signature; // Signature
+};
+
+
+//
+// Local globals...
+//
+
+static const char * const cups_jwa_strings[CUPS_JWA_MAX] =
+{
+ "none", // No algorithm
+ "HS256", // HMAC using SHA-256
+ "HS384", // HMAC using SHA-384
+ "HS512", // HMAC using SHA-512
+ "RS256", // RSASSA-PKCS1-v1_5 using SHA-256
+ "RS384", // RSASSA-PKCS1-v1_5 using SHA-384
+ "RS512", // RSASSA-PKCS1-v1_5 using SHA-512
+ "ES256", // ECDSA using P-256 and SHA-256
+ "ES384", // ECDSA using P-384 and SHA-384
+ "ES512" // ECDSA using P-521 and SHA-512
+};
+static const char * const cups_jwa_algorithms[CUPS_JWA_MAX] =
+{
+ NULL,
+ "sha2-256",
+ "sha2-384",
+ "sha2-512",
+ "sha2-256",
+ "sha2-384",
+ "sha2-512",
+ "sha2-256",
+ "sha2-384",
+ "sha2-512"
+};
+
+
+//
+// Local functions...
+//
+
+#ifdef HAVE_OPENSSL
+static BIGNUM *make_bignum(cups_json_t *jwk, const char *key);
+static void make_bnstring(const BIGNUM *bn, char *buffer, size_t bufsize);
+static EC_KEY *make_ec_key(cups_json_t *jwk, bool verify);
+static RSA *make_rsa(cups_json_t *jwk);
+#else // HAVE_GNUTLS
+static gnutls_datum_t *make_datum(cups_json_t *jwk, const char *key);
+static void make_datstring(gnutls_datum_t *d, char *buffer, size_t bufsize);
+static gnutls_privkey_t make_private_key(cups_json_t *jwk);
+static gnutls_pubkey_t make_public_key(cups_json_t *jwk);
+#endif // HAVE_OPENSSL
+static bool make_signature(cups_jwt_t *jwt, cups_jwa_t alg, cups_json_t *jwk, unsigned char *signature, size_t *sigsize, const char **sigkid);
+static char *make_string(cups_jwt_t *jwt, bool with_signature);
+
+
+//
+// 'cupsJWTDelete()' - Free the memory used for a JSON Web Token.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTDelete(cups_jwt_t *jwt) // I - JWT object
+{
+ if (jwt)
+ {
+ cupsJSONDelete(jwt->jose);
+ free(jwt->jose_string);
+ cupsJSONDelete(jwt->claims);
+ free(jwt->claims_string);
+ free(jwt->sigkid);
+ free(jwt->signature);
+ free(jwt);
+ }
+}
+
+
+//
+// 'cupsJWTExportString()' - Export a JWT with the JWS Compact or JWS JSON (Flattened) Serialization format.
+//
+// This function exports a JWT to a JWS Compact or JWS JSON Serialization
+// string. The JSON output is always the "flattened" format since the JWT
+// only contains a single signature.
+//
+// The return value must be freed using the `free` function.
+//
+// @since CUPS 2.5@
+//
+
+char * // O - JWT/JWS Serialization string
+cupsJWTExportString(
+ cups_jwt_t *jwt, // I - JWT object
+ cups_jws_format_t format) // I - JWS serialization format
+{
+ char *ret = NULL; // Return value
+
+
+ if (jwt)
+ {
+ if (format == CUPS_JWS_FORMAT_COMPACT)
+ {
+ // Compact token string
+ ret = make_string(jwt, true);
+ }
+ else
+ {
+ // JSON (flattened) serialized string
+ cups_json_t *json; // JSON serialization
+ char *payload, // Payload value
+ signature[((_CUPS_JWT_MAX_SIGNATURE + 2) * 4 / 3) + 1];
+ // Base64URL-encoded signature value
+
+ // The payload is the compact token string without signature...
+ json = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT);
+
+ payload = make_string(jwt, false);
+ cupsJSONNewString(json, cupsJSONNewKey(json, NULL, "payload"), payload);
+ free(payload);
+
+ if (jwt->sigsize)
+ {
+ if (jwt->sigkid)
+ {
+ cups_json_t *header; // Unprotected header
+
+ header = cupsJSONNew(json, cupsJSONNewKey(json, NULL, "header"), CUPS_JTYPE_OBJECT);
+ cupsJSONNewString(header, cupsJSONNewKey(header, NULL, "kid"), jwt->sigkid);
+ }
+
+ // Add the Base64URL-encoded signature value...
+ httpEncode64_3(signature, sizeof(signature), (char *)jwt->signature, jwt->sigsize, true);
+ cupsJSONNewString(json, cupsJSONNewKey(json, NULL, "signature"), signature);
+ }
+
+ ret = cupsJSONExportString(json);
+ cupsJSONDelete(json);
+ }
+ }
+
+ return (ret);
+}
+
+
+//
+// 'cupsJWTGetAlgorithm()' - Get the signature algorithm used by a JSON Web Token.
+//
+// @since CUPS 2.5@
+//
+
+cups_jwa_t // O - Signature algorithm
+cupsJWTGetAlgorithm(cups_jwt_t *jwt) // I - JWT object
+{
+ return (jwt ? jwt->sigalg : CUPS_JWA_NONE);
+}
+
+
+//
+// 'cupsJWTGetClaimNumber()' - Get the number value of a claim.
+//
+// @since CUPS 2.5@
+//
+
+double // O - Number value
+cupsJWTGetClaimNumber(cups_jwt_t *jwt, // I - JWT object
+ const char *claim)// I - Claim name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->claims, claim)) != NULL)
+ return (cupsJSONGetNumber(node));
+ else
+ return (0.0);
+}
+
+
+//
+// 'cupsJWTGetClaimString()' - Get the string value of a claim.
+//
+// @since CUPS 2.5@
+//
+
+const char * // O - String value
+cupsJWTGetClaimString(cups_jwt_t *jwt, // I - JWT object
+ const char *claim)// I - Claim name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->claims, claim)) != NULL)
+ return (cupsJSONGetString(node));
+ else
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTGetClaimType()' - Get the value type of a claim.
+//
+// @since CUPS 2.5@
+//
+
+cups_jtype_t // O - JSON value type
+cupsJWTGetClaimType(cups_jwt_t *jwt, // I - JWT object
+ const char *claim) // I - Claim name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->claims, claim)) != NULL)
+ return (cupsJSONGetType(node));
+ else
+ return (CUPS_JTYPE_NULL);
+}
+
+
+//
+// 'cupsJWTGetClaimValue()' - Get the value node of a claim.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON value node
+cupsJWTGetClaimValue(cups_jwt_t *jwt, // I - JWT object
+ const char *claim) // I - Claim name
+{
+ if (jwt)
+ return (cupsJSONFind(jwt->claims, claim));
+ else
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTGetClaims()' - Get the JWT claims as a JSON object.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON object
+cupsJWTGetClaims(cups_jwt_t *jwt) // I - JWT object
+{
+ return (jwt ? jwt->claims : NULL);
+}
+
+
+//
+// 'cupsJWTGetHeaderNumber()' - Get the number value of a protected header.
+//
+// @since CUPS 2.5@
+//
+
+double // O - Number value
+cupsJWTGetHeaderNumber(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header) // I - Header name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->jose, header)) != NULL)
+ return (cupsJSONGetNumber(node));
+ else
+ return (0.0);
+}
+
+
+//
+// 'cupsJWTGetHeaderString()' - Get the string value of a protected header.
+//
+// @since CUPS 2.5@
+//
+
+const char * // O - String value
+cupsJWTGetHeaderString(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header) // I - Header name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->jose, header)) != NULL)
+ return (cupsJSONGetString(node));
+ else
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTGetHeaderType()' - Get the value type of a protected header.
+//
+// @since CUPS 2.5@
+//
+
+cups_jtype_t // O - JSON value type
+cupsJWTGetHeaderType(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header) // I - Header name
+{
+ cups_json_t *node; // Value node
+
+
+ if (jwt && (node = cupsJSONFind(jwt->jose, header)) != NULL)
+ return (cupsJSONGetType(node));
+ else
+ return (CUPS_JTYPE_NULL);
+}
+
+
+//
+// 'cupsJWTGetHeaderValue()' - Get the value node of a protected header.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON value node
+cupsJWTGetHeaderValue(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header) // I - Header name
+{
+ if (jwt)
+ return (cupsJSONFind(jwt->jose, header));
+ else
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTGetHeaders()' - Get the JWT protected headers as a JSON object.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - JSON object
+cupsJWTGetHeaders(cups_jwt_t *jwt) // I - JWT object
+{
+ return (jwt ? jwt->jose : NULL);
+}
+
+
+//
+// 'cupsJWTHasValidSignature()' - Determine whether the JWT has a valid signature.
+//
+// @since CUPS 2.5@
+//
+
+bool // O - `true` if value, `false` otherwise
+cupsJWTHasValidSignature(
+ cups_jwt_t *jwt, // I - JWT object
+ cups_json_t *jwk) // I - JWK key set
+{
+ bool ret = false; // Return value
+ unsigned char signature[_CUPS_JWT_MAX_SIGNATURE];
+ // Signature
+ const char *sigkid; // Key ID, if any
+ size_t sigsize = _CUPS_JWT_MAX_SIGNATURE;
+ // Size of signature
+ char *text; // Signature text
+ size_t text_len; // Length of signature text
+#ifdef HAVE_OPENSSL
+ unsigned char hash[128]; // Hash
+ ssize_t hash_len; // Length of hash
+ RSA *rsa; // RSA public key
+ EC_KEY *ec; // ECDSA public key
+ static int nids[] = { NID_sha256, NID_sha384, NID_sha512 };
+ // Hash NIDs
+#else // HAVE_GNUTLS
+ gnutls_pubkey_t key; // Public key
+ gnutls_datum_t text_datum, // Text datum
+ sig_datum; // Signature datum
+ static int algs[] = { GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA384, GNUTLS_DIG_SHA512, GNUTLS_SIGN_ECDSA_SHA256, GNUTLS_SIGN_ECDSA_SHA384, GNUTLS_SIGN_ECDSA_SHA512 };
+ // Hash algorithms
+#endif // HAVE_OPENSSL
+
+
+ // Range check input...
+ if (!jwt || !jwt->signature || !jwk)
+ return (false);
+
+ DEBUG_printf("1cupsJWTHasValidSignature: orig sig(%u) = %02X%02X%02X%02X...%02X%02X%02X%02X", (unsigned)jwt->sigsize, jwt->signature[0], jwt->signature[1], jwt->signature[2], jwt->signature[3], jwt->signature[jwt->sigsize - 4], jwt->signature[jwt->sigsize - 3], jwt->signature[jwt->sigsize - 2], jwt->signature[jwt->sigsize - 1]);
+
+ switch (jwt->sigalg)
+ {
+ case CUPS_JWA_HS256 :
+ case CUPS_JWA_HS384 :
+ case CUPS_JWA_HS512 :
+ // Calculate signature with keys...
+ sigkid = jwt->sigkid;
+ if (!make_signature(jwt, jwt->sigalg, jwk, signature, &sigsize, &sigkid))
+ break;
+
+ DEBUG_printf("1cupsJWTHasValidSignature: calc sig(%u) = %02X%02X%02X%02X...%02X%02X%02X%02X", (unsigned)sigsize, signature[0], signature[1], signature[2], signature[3], signature[sigsize - 4], signature[sigsize - 3], signature[sigsize - 2], signature[sigsize - 1]);
+
+ // Compare and return the result...
+ ret = jwt->sigsize == sigsize && !memcmp(jwt->signature, signature, sigsize);
+ break;
+
+ case CUPS_JWA_RS256 :
+ case CUPS_JWA_RS384 :
+ case CUPS_JWA_RS512 :
+ // Get the message hash...
+ text = make_string(jwt, false);
+ text_len = strlen(text);
+
+#ifdef HAVE_OPENSSL
+ hash_len = cupsHashData(cups_jwa_algorithms[jwt->sigalg], text, text_len, hash, sizeof(hash));
+
+ if ((rsa = make_rsa(jwk)) != NULL)
+ {
+ ret = RSA_verify(nids[jwt->sigalg - CUPS_JWA_RS256], hash, hash_len, jwt->signature, jwt->sigsize, rsa) == 1;
+
+ RSA_free(rsa);
+ }
+
+#else // HAVE_GNUTLS
+ if ((key = make_public_key(jwk)) != NULL)
+ {
+ text_datum.data = (unsigned char *)text;
+ text_datum.size = (unsigned)text_len;
+
+ sig_datum.data = jwt->signature;
+ sig_datum.size = (unsigned)jwt->sigsize;
+
+ ret = !gnutls_pubkey_verify_data2(key, algs[jwt->sigalg - CUPS_JWA_RS256], 0, &text_datum, &sig_datum);
+ gnutls_pubkey_deinit(key);
+ }
+#endif // HAVE_OPENSSL
+
+ // Free memory
+ free(text);
+ break;
+
+ case CUPS_JWA_ES256 :
+ case CUPS_JWA_ES384 :
+ case CUPS_JWA_ES512 :
+ // Get the message hash...
+ text = make_string(jwt, false);
+ text_len = strlen(text);
+
+#ifdef HAVE_OPENSSL
+ hash_len = cupsHashData(cups_jwa_algorithms[jwt->sigalg], text, text_len, hash, sizeof(hash));
+
+ if ((ec = make_ec_key(jwk, true)) != NULL)
+ {
+ // Convert binary signature into ECDSA signature for OpenSSL
+ ECDSA_SIG *ec_sig; // EC signature
+ BIGNUM *r, *s; // Signature coordinates
+ int sig_len; // Size of coordinates
+
+ ec_sig = ECDSA_SIG_new();
+ sig_len = (int)jwt->sigsize / 2;
+ r = BN_new();
+ s = BN_new();
+ BN_bin2bn(jwt->signature, sig_len, r);
+ BN_bin2bn(jwt->signature + sig_len, sig_len, s);
+ ECDSA_SIG_set0(ec_sig, r, s);
+
+ // Verify signature and clean up...
+ ret = ECDSA_do_verify(hash, hash_len, ec_sig, ec) == 1;
+
+ ECDSA_SIG_free(ec_sig);
+ EC_KEY_free(ec);
+ }
+
+#else // HAVE_GNUTLS
+ if ((key = make_public_key(jwk)) != NULL)
+ {
+ gnutls_datum_t r, s; // Signature coordinates
+
+ text_datum.data = (unsigned char *)text;
+ text_datum.size = (unsigned)text_len;
+
+ r.data = jwt->signature;
+ r.size = (unsigned)jwt->sigsize / 2;
+ s.data = jwt->signature + jwt->sigsize / 2;
+ s.size = (unsigned)jwt->sigsize / 2;
+
+ gnutls_encode_rs_value(&sig_datum, &r, &s);
+
+ ret = !gnutls_pubkey_verify_data2(key, algs[jwt->sigalg - CUPS_JWA_RS256], 0, &text_datum, &sig_datum);
+ gnutls_free(sig_datum.data);
+ gnutls_pubkey_deinit(key);
+ }
+#endif // HAVE_OPENSSL
+
+ // Free memory
+ free(text);
+ break;
+
+ default :
+ DEBUG_printf("1cupsJWTHasValidSignature: Algorithm %d not supported.", jwt->sigalg);
+ break;
+ }
+
+ return (ret);
+}
+
+
+//
+// 'cupsJWTImportString()' - Import a JSON Web Token or JSON Web Signature.
+//
+// @since CUPS 2.5@
+//
+
+cups_jwt_t * // O - JWT object
+cupsJWTImportString(
+ const char *s, // I - JWS string
+ cups_jws_format_t format) // I - JWS serialization format
+{
+ cups_jwt_t *jwt; // JWT object
+ size_t datalen; // Size of data
+ char data[65536]; // Data
+ const char *alg; // Signature algorithm, if any
+
+
+ // Allocate a JWT...
+ if ((jwt = calloc(1, sizeof(cups_jwt_t))) == NULL)
+ return (NULL);
+
+ // Import it...
+ if (format == CUPS_JWS_FORMAT_COMPACT)
+ {
+ // Import compact Base64URL-encoded token...
+ const char *tokptr; // Pointer into the token
+
+ // Extract the JOSE header...
+ datalen = sizeof(data) - 1;
+ if (!httpDecode64_3(data, &datalen, s, &tokptr) || !tokptr || *tokptr != '.')
+ goto import_error;
+
+ tokptr ++;
+ data[datalen] = '\0';
+ jwt->jose_string = strdup(data);
+ if ((jwt->jose = cupsJSONImportString(data)) == NULL)
+ goto import_error;
+
+ // Extract the JWT claims...
+ datalen = sizeof(data) - 1;
+ if (!httpDecode64_3(data, &datalen, tokptr, &tokptr) || !tokptr || *tokptr != '.')
+ goto import_error;
+
+ tokptr ++;
+ data[datalen] = '\0';
+ jwt->claims_string = strdup(data);
+ if ((jwt->claims = cupsJSONImportString(data)) == NULL)
+ goto import_error;
+
+ // Extract the signature, if any...
+ datalen = sizeof(data);
+ if (!httpDecode64_3(data, &datalen, tokptr, &tokptr) || !tokptr || *tokptr)
+ goto import_error;
+
+ if (datalen > 0)
+ {
+ if ((jwt->signature = malloc(datalen)) == NULL)
+ goto import_error;
+
+ memcpy(jwt->signature, data, datalen);
+ jwt->sigsize = datalen;
+ }
+ }
+ else
+ {
+ // Import JSON...
+ cups_json_t *json, // JSON data
+ *json_value, // BASE64URL-encoded string value node
+ *header, // Unprotected header
+ *kid, // Key ID node
+ *signatures, // Signatures array
+ *signature; // Signature element to load
+ const char *value, // C string value
+ *valueptr; // Pointer into value
+
+ if ((json = cupsJSONImportString(s)) == NULL)
+ goto import_error;
+
+ // Copy the payload...
+ if ((json_value = cupsJSONFind(json, "payload")) == NULL || (value = cupsJSONGetString(json_value)) == NULL)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ datalen = sizeof(data) - 1;
+ if (!httpDecode64_3(data, &datalen, value, &valueptr) || !valueptr || *valueptr)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ data[datalen] = '\0';
+ jwt->claims_string = strdup(data);
+ if ((jwt->claims = cupsJSONImportString(data)) == NULL)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ // See if we have a flattened JSON JWT...
+ if ((signatures = cupsJSONFind(json, "signatures")) != NULL)
+ {
+ // Use the first protected header and signature in the array...
+ signature = cupsJSONGetChild(signatures, 0);
+ }
+ else
+ {
+ // Use the protected header and signature from the main JSON object...
+ signature = json;
+ }
+
+ // Copy the protected header and signature values...
+ if ((json_value = cupsJSONFind(signature, "protected")) == NULL || (value = cupsJSONGetString(json_value)) == NULL)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ datalen = sizeof(data) - 1;
+ if (!httpDecode64_3(data, &datalen, value, &valueptr) || !valueptr || *valueptr)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ data[datalen] = '\0';
+ jwt->jose_string = strdup(data);
+ if ((jwt->jose = cupsJSONImportString(data)) == NULL)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ if ((json_value = cupsJSONFind(signature, "signature")) == NULL || (value = cupsJSONGetString(json_value)) == NULL)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ datalen = sizeof(data);
+ if (!httpDecode64_3(data, &datalen, value, &valueptr) || !valueptr || *valueptr)
+ {
+ cupsJSONDelete(json);
+ goto import_error;
+ }
+
+ if (datalen > 0)
+ {
+ if ((jwt->signature = malloc(datalen)) == NULL)
+ goto import_error;
+
+ memcpy(jwt->signature, data, datalen);
+ jwt->sigsize = datalen;
+ }
+
+ if ((header = cupsJSONFind(signature, "header")) != NULL && (kid = cupsJSONFind(header, "kid")) != NULL && (value = cupsJSONGetString(kid)) != NULL)
+ jwt->sigkid = strdup(value);
+ }
+
+ // Check the algorithm used in the protected header...
+ if ((alg = cupsJSONGetString(cupsJSONFind(jwt->jose, "alg"))) != NULL)
+ {
+ cups_jwa_t sigalg; // Signing algorithm
+
+ for (sigalg = CUPS_JWA_NONE; sigalg < CUPS_JWA_MAX; sigalg ++)
+ {
+ if (!strcmp(alg, cups_jwa_strings[sigalg]))
+ {
+ jwt->sigalg = sigalg;
+ break;
+ }
+ }
+ }
+
+ // Can't have signature with none or no signature for !none...
+ if ((jwt->sigalg == CUPS_JWA_NONE) != (jwt->sigsize == 0))
+ goto import_error;
+
+ // Return the new JWT...
+ return (jwt);
+
+ import_error:
+
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid JSON web token."), 1);
+ cupsJWTDelete(jwt);
+
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTMakePrivateKey()' - Make a JSON Web Key for encryption and signing.
+//
+// This function makes a JSON Web Key (JWK) for the specified JWS/JWE algorithm
+// for use when signing or encrypting JSON Web Tokens. The resulting JWK
+// *must not* be provided to clients - instead, call @link cupsJWTMakePublicKey@
+// to produce a public key subset suitable for verification and decryption.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Private JSON Web Key or `NULL` on error
+cupsJWTMakePrivateKey(cups_jwa_t alg) // I - Signing/encryption algorithm
+{
+ cups_json_t *jwk, // Private JSON Web Key
+ *node; // Current node
+ char kid[256]; // Key identifier value
+ const char *kty; // Key type
+
+
+ if (alg < CUPS_JWA_HS256 || alg > CUPS_JWA_ES512)
+ return (NULL);
+
+ jwk = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT);
+ node = cupsJSONNewKey(jwk, NULL, "kty");
+
+ if (alg >= CUPS_JWA_HS256 && alg <= CUPS_JWA_HS512)
+ {
+ // Simple N-byte random key...
+ unsigned char key[128]; // Key bytes
+ size_t key_len; // Key length
+ char key_base64[172];// Base64URL-encoded key bytes
+
+ node = cupsJSONNewString(jwk, node, kty = "oct");
+
+ key_len = alg == CUPS_JWA_HS256 ? 64 : 128;
+#ifdef HAVE_OPENSSL
+ RAND_bytes(key, key_len);
+#else // HAVE_GNUTLS
+ gnutls_rnd(GNUTLS_RND_KEY, key, key_len);
+#endif // HAVE_OPENSSL
+
+ httpEncode64_3(key_base64, sizeof(key_base64), (char *)key, key_len, true);
+ node = cupsJSONNewKey(jwk, node, "k");
+ node = cupsJSONNewString(jwk, node, key_base64);
+ }
+ else if (alg >= CUPS_JWA_RS256 && alg <= CUPS_JWA_RS512)
+ {
+ // 3072-bit RSA key
+ char n[1024], // Public key modulus
+ e[1024], // Public key exponent
+ d[1024], // Private key exponent
+ p[1024], // Private key first prime factor
+ q[1024], // Private key second prime factor
+ dp[1024], // First factor exponent
+ dq[1024], // Second factor exponent
+ qi[1024]; // First CRT coefficient
+
+#ifdef HAVE_OPENSSL
+ RSA *rsa; // RSA public/private key
+
+ rsa = RSA_generate_key(3072, 0x10001, NULL, NULL);
+ make_bnstring(RSA_get0_n(rsa), n, sizeof(n));
+ make_bnstring(RSA_get0_e(rsa), e, sizeof(e));
+ make_bnstring(RSA_get0_d(rsa), d, sizeof(d));
+ make_bnstring(RSA_get0_p(rsa), p, sizeof(p));
+ make_bnstring(RSA_get0_q(rsa), q, sizeof(q));
+ make_bnstring(RSA_get0_dmp1(rsa), dp, sizeof(dp));
+ make_bnstring(RSA_get0_dmq1(rsa), dq, sizeof(dq));
+ make_bnstring(RSA_get0_iqmp(rsa), qi, sizeof(qi));
+
+ RSA_free(rsa);
+
+#else // HAVE_GNUTLS
+ gnutls_privkey_t key; // Private key
+ gnutls_datum_t dat_n, dat_e, dat_d, dat_p, dat_q, dat_dp, dat_dq, dat_qi;
+ // RSA parameters
+
+ gnutls_privkey_init(&key);
+ gnutls_privkey_generate(key, GNUTLS_PK_RSA, 3072, 0);
+ gnutls_privkey_export_rsa_raw(key, &dat_n, &dat_e, &dat_d, &dat_p, &dat_q, &dat_qi, &dat_dp, &dat_dq);
+ make_datstring(&dat_n, n, sizeof(n));
+ make_datstring(&dat_e, e, sizeof(e));
+ make_datstring(&dat_d, d, sizeof(d));
+ make_datstring(&dat_p, p, sizeof(p));
+ make_datstring(&dat_q, q, sizeof(q));
+ make_datstring(&dat_qi, qi, sizeof(qi));
+ make_datstring(&dat_dp, dp, sizeof(dp));
+ make_datstring(&dat_dq, dq, sizeof(dq));
+ gnutls_privkey_deinit(key);
+#endif // HAVE_OPENSSL
+
+ node = cupsJSONNewString(jwk, node, kty = "RSA");
+ node = cupsJSONNewKey(jwk, node, "n");
+ node = cupsJSONNewString(jwk, node, n);
+ node = cupsJSONNewKey(jwk, node, "e");
+ node = cupsJSONNewString(jwk, node, e);
+ node = cupsJSONNewKey(jwk, node, "d");
+ node = cupsJSONNewString(jwk, node, d);
+ node = cupsJSONNewKey(jwk, node, "p");
+ node = cupsJSONNewString(jwk, node, p);
+ node = cupsJSONNewKey(jwk, node, "q");
+ node = cupsJSONNewString(jwk, node, q);
+ node = cupsJSONNewKey(jwk, node, "dp");
+ node = cupsJSONNewString(jwk, node, dp);
+ node = cupsJSONNewKey(jwk, node, "dq");
+ node = cupsJSONNewString(jwk, node, dq);
+ node = cupsJSONNewKey(jwk, node, "qi");
+ node = cupsJSONNewString(jwk, node, qi);
+ }
+ else
+ {
+ // N-bit ECC key
+ char x[1024], // X coordinate
+ y[1024], // Y coordinate
+ d[1024]; // Private key
+ static const char * const curves[] =
+ {
+ "P-256",
+ "P-384",
+ "P-521"
+ };
+
+#ifdef HAVE_OPENSSL
+ EC_KEY *ec; // EC object
+ const EC_GROUP *group; // Group
+ const EC_POINT *pubkey; // Public key portion
+ BIGNUM *bx, *by; // Public key coordinates
+
+ if (alg == CUPS_JWA_ES256)
+ ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+ else if (alg == CUPS_JWA_ES384)
+ ec = EC_KEY_new_by_curve_name(NID_secp384r1);
+ else
+ ec = EC_KEY_new_by_curve_name(NID_secp521r1);
+
+ EC_KEY_generate_key(ec);
+
+ make_bnstring(EC_KEY_get0_private_key(ec), d, sizeof(d));
+
+ group = EC_KEY_get0_group(ec);
+ pubkey = EC_KEY_get0_public_key(ec);
+
+ bx = BN_new();
+ by = BN_new();
+ EC_POINT_get_affine_coordinates(group, pubkey, bx, by, NULL);
+ make_bnstring(bx, x, sizeof(x));
+ make_bnstring(by, y, sizeof(y));
+ BN_free(bx);
+ BN_free(by);
+
+ EC_KEY_free(ec);
+
+#else // HAVE_GNUTLS
+ gnutls_privkey_t key; // Private key
+ gnutls_ecc_curve_t dat_curve; // Curve
+ gnutls_datum_t dat_x, dat_y, dat_d;
+ // ECDSA parameters
+
+ gnutls_privkey_init(&key);
+ gnutls_privkey_generate(key, GNUTLS_PK_EC, GNUTLS_CURVE_TO_BITS((GNUTLS_ECC_CURVE_SECP256R1 + (alg - CUPS_JWA_ES256))), 0);
+ gnutls_privkey_export_ecc_raw(key, &dat_curve, &dat_x, &dat_y, &dat_d);
+ make_datstring(&dat_x, x, sizeof(x));
+ make_datstring(&dat_y, y, sizeof(y));
+ make_datstring(&dat_d, d, sizeof(d));
+ gnutls_privkey_deinit(key);
+#endif // HAVE_OPENSSL
+
+ node = cupsJSONNewString(jwk, node, kty = "EC");
+ node = cupsJSONNewKey(jwk, node, "crv");
+ node = cupsJSONNewString(jwk, node, curves[alg - CUPS_JWA_ES256]);
+ node = cupsJSONNewKey(jwk, node, "x");
+ node = cupsJSONNewString(jwk, node, x);
+ node = cupsJSONNewKey(jwk, node, "y");
+ node = cupsJSONNewString(jwk, node, y);
+ node = cupsJSONNewKey(jwk, node, "d");
+ node = cupsJSONNewString(jwk, node, d);
+ }
+
+ // Add key identifier using key type and current date/time...
+ snprintf(kid, sizeof(kid), "%s%ld", kty, (long)time(NULL));
+ node = cupsJSONNewKey(jwk, node, "kid");
+ /*node =*/ cupsJSONNewString(jwk, node, kid);
+
+ return (jwk);
+}
+
+
+//
+// 'cupsJWTMakePublicKey()' - Make a JSON Web Key for decryption and verification.
+//
+// This function makes a public JSON Web Key (JWK) from the specified private
+// JWK suitable for use when decrypting or verifying a JWE/JWS message.
+//
+// @since CUPS 2.5@
+//
+
+cups_json_t * // O - Public JSON Web Key or `NULL` on error
+cupsJWTMakePublicKey(cups_json_t *jwk) // I - Private JSON Web Key
+{
+ cups_json_t *pubjwt = NULL, // Public JSON Web Key
+ *node = NULL; // Current node
+ const char *kid, // Key ID
+ *kty; // Key type
+
+
+ kid = cupsJSONGetString(cupsJSONFind(jwk, "kid"));
+
+ if ((kty = cupsJSONGetString(cupsJSONFind(jwk, "kty"))) == NULL)
+ {
+ // No type so we can't load it...
+ return (NULL);
+ }
+ else if (!strcmp(kty, "RSA"))
+ {
+ // RSA private key
+ const char *n = cupsJSONGetString(cupsJSONFind(jwk, "n"));
+ const char *e = cupsJSONGetString(cupsJSONFind(jwk, "e"));
+
+ pubjwt = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT);
+ node = cupsJSONNewKey(pubjwt, NULL, "kty");
+ node = cupsJSONNewString(pubjwt, node, "RSA");
+ node = cupsJSONNewKey(pubjwt, node, "n");
+ node = cupsJSONNewString(pubjwt, node, n);
+ node = cupsJSONNewKey(pubjwt, node, "e");
+ node = cupsJSONNewString(pubjwt, node, e);
+ }
+ else if (!strcmp(kty, "EC"))
+ {
+ // ECDSA private key
+ const char *crv = cupsJSONGetString(cupsJSONFind(jwk, "crv"));
+ const char *x = cupsJSONGetString(cupsJSONFind(jwk, "x"));
+ const char *y = cupsJSONGetString(cupsJSONFind(jwk, "y"));
+
+ pubjwt = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT);
+ node = cupsJSONNewKey(pubjwt, NULL, "kty");
+ node = cupsJSONNewString(pubjwt, node, "EC");
+ node = cupsJSONNewKey(pubjwt, node, "crv");
+ node = cupsJSONNewString(pubjwt, node, crv);
+ node = cupsJSONNewKey(pubjwt, node, "x");
+ node = cupsJSONNewString(pubjwt, node, x);
+ node = cupsJSONNewKey(pubjwt, node, "y");
+ node = cupsJSONNewString(pubjwt, node, y);
+ }
+
+ if (pubjwt && kid)
+ {
+ node = cupsJSONNewKey(pubjwt, node, "kid");
+ /*node=*/ cupsJSONNewString(pubjwt, node, kid);
+ }
+
+ return (pubjwt);
+}
+
+
+//
+// 'cupsJWTNew()' - Create a new, empty JSON Web Token.
+//
+// @since CUPS 2.5@
+//
+
+cups_jwt_t * // O - JWT object
+cupsJWTNew(const char *type) // I - JWT type or `NULL` for default ("JWT")
+{
+ cups_jwt_t *jwt; // JWT object
+
+
+ if ((jwt = calloc(1, sizeof(cups_jwt_t))) != NULL)
+ {
+ if ((jwt->jose = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT)) != NULL)
+ {
+ cupsJSONNewString(jwt->jose, cupsJSONNewKey(jwt->jose, NULL, "typ"), type ? type : "JWT");
+
+ if ((jwt->claims = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT)) != NULL)
+ return (jwt);
+ }
+ }
+
+ cupsJWTDelete(jwt);
+ return (NULL);
+}
+
+
+//
+// 'cupsJWTSetClaimNumber()' - Set a claim number.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetClaimNumber(cups_jwt_t *jwt, // I - JWT object
+ const char *claim,// I - Claim name
+ double value) // I - Number value
+{
+ // Range check input
+ if (!jwt || !claim)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->claims, claim);
+
+ // Add claim...
+ cupsJSONNewNumber(jwt->claims, cupsJSONNewKey(jwt->claims, NULL, claim), value);
+}
+
+
+//
+// 'cupsJWTSetClaimString()' - Set a claim string.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetClaimString(cups_jwt_t *jwt, // I - JWT object
+ const char *claim,// I - Claim name
+ const char *value)// I - String value
+{
+ // Range check input
+ if (!jwt || !claim || !value)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->claims, claim);
+
+ // Add claim...
+ cupsJSONNewString(jwt->claims, cupsJSONNewKey(jwt->claims, NULL, claim), value);
+}
+
+
+//
+// 'cupsJWTSetClaimValue()' - Set a claim value.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetClaimValue(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *claim, // I - Claim name
+ cups_json_t *value) // I - JSON value node
+{
+ // Range check input
+ if (!jwt || !claim)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->claims, claim);
+
+ // Add claim...
+ _cupsJSONAdd(jwt->claims, cupsJSONNewKey(jwt->claims, NULL, claim), value);
+}
+
+
+//
+// 'cupsJWTSetHeaderNumber()' - Set a protected header number.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetHeaderNumber(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header, // I - Header name
+ double value) // I - Number value
+{
+ // Range check input
+ if (!jwt || !header)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->jose, header);
+
+ // Add claim...
+ cupsJSONNewNumber(jwt->jose, cupsJSONNewKey(jwt->jose, NULL, header), value);
+}
+
+
+//
+// 'cupsJWTSetHeaderString()' - Set a protected header string.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetHeaderString(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header, // I - Header name
+ const char *value) // I - String value
+{
+ // Range check input
+ if (!jwt || !header || !value)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->jose, header);
+
+ // Add claim...
+ cupsJSONNewString(jwt->jose, cupsJSONNewKey(jwt->jose, NULL, header), value);
+}
+
+
+//
+// 'cupsJWTSetHeaderValue()' - Set a protected header value.
+//
+// @since CUPS 2.5@
+//
+
+void
+cupsJWTSetHeaderValue(
+ cups_jwt_t *jwt, // I - JWT object
+ const char *header, // I - Header name
+ cups_json_t *value) // I - JSON value node
+{
+ // Range check input
+ if (!jwt || !header)
+ return;
+
+ // Remove existing claim string, if any...
+ free(jwt->claims_string);
+ jwt->claims_string = NULL;
+
+ // Remove existing claim, if any...
+ _cupsJSONDelete(jwt->jose, header);
+
+ // Add claim...
+ _cupsJSONAdd(jwt->jose, cupsJSONNewKey(jwt->jose, NULL, header), value);
+}
+
+
+//
+// 'cupsJWTSign()' - Sign a JSON Web Token, creating a JSON Web Signature.
+//
+// @since CUPS 2.5@
+//
+
+bool // O - `true` on success, `false` on error
+cupsJWTSign(cups_jwt_t *jwt, // I - JWT object
+ cups_jwa_t alg, // I - Signing algorithm
+ cups_json_t *jwk) // I - JWK key set
+{
+ unsigned char signature[_CUPS_JWT_MAX_SIGNATURE];
+ // Signature
+ size_t sigsize = _CUPS_JWT_MAX_SIGNATURE;
+ // Size of signature
+ const char *sigkid = NULL; // Key ID, if any
+
+
+ // Range check input...
+ if (!jwt || alg <= CUPS_JWA_NONE || alg >= CUPS_JWA_MAX || !jwk)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ // Remove existing JOSE string, if any...
+ free(jwt->jose_string);
+ _cupsJSONDelete(jwt->jose, "alg");
+ cupsJSONNewString(jwt->jose, cupsJSONNewKey(jwt->jose, NULL, "alg"), cups_jwa_strings[alg]);
+
+ jwt->jose_string = cupsJSONExportString(jwt->jose);
+
+ // Clear existing signature...
+ free(jwt->signature);
+ free(jwt->sigkid);
+ jwt->signature = NULL;
+ jwt->sigkid = NULL;
+ jwt->sigsize = 0;
+ jwt->sigalg = CUPS_JWA_NONE;
+
+ // Create new signature...
+ if (!make_signature(jwt, alg, jwk, signature, &sigsize, &sigkid))
+ return (false);
+
+ if (sigkid)
+ jwt->sigkid = strdup(sigkid);
+
+ if ((jwt->signature = malloc(sigsize)) == NULL)
+ return (false);
+
+ memcpy(jwt->signature, signature, sigsize);
+ jwt->sigalg = alg;
+ jwt->sigsize = sigsize;
+
+ return (true);
+}
+
+
+#ifdef HAVE_OPENSSL
+//
+// 'make_bignum()' - Make a BIGNUM for the specified key.
+//
+
+static BIGNUM * // O - BIGNUM object or `NULL` on error
+make_bignum(cups_json_t *jwk, // I - JSON web key
+ const char *key) // I - Object key
+{
+ const char *value, // Key value
+ *value_end; // End of value
+ unsigned char value_bytes[1024]; // Decoded value
+ size_t value_len; // Length of value
+
+
+ // See if we have the value...
+ if ((value = cupsJSONGetString(cupsJSONFind(jwk, key))) == NULL)
+ return (NULL);
+
+ // Decode and validate...
+ value_len = sizeof(value_bytes);
+ if (!httpDecode64_3((char *)value_bytes, &value_len, value, &value_end) || (value_end && *value_end))
+ return (NULL);
+
+ // Convert to a BIGNUM...
+ return (BN_bin2bn(value_bytes, value_len, NULL));
+}
+
+
+//
+// 'make_bnstring()' - Make a Base64URL-encoded string for a BIGNUM.
+//
+
+static void
+make_bnstring(const BIGNUM *bn, // I - Number
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
+{
+ unsigned char value_bytes[512]; // Value bytes
+ size_t value_len; // Number of bytes
+
+
+ if ((value_len = (size_t)BN_num_bytes(bn)) > sizeof(value_bytes))
+ {
+ *buffer = '\0';
+ return;
+ }
+
+ BN_bn2bin(bn, value_bytes);
+ httpEncode64_3(buffer, bufsize, (char *)value_bytes, value_len, true);
+}
+
+
+//
+// 'make_ec_key()' - Make an ECDSA signing/verification object.
+//
+
+static EC_KEY * // O - EC object or `NULL` on error
+make_ec_key(cups_json_t *jwk, // I - JSON web key
+ bool verify) // I - `true` for verification only, `false` for signing/verification
+{
+ EC_KEY *ec = NULL; // EC object
+ EC_GROUP *group; // Group parameters
+ EC_POINT *point; // Public key point
+ const char *crv; // EC curve ("P-256", "P-384", or "P-521")
+ BIGNUM *x, // X coordinate
+ *y, // Y coordinate
+ *d; // Private key
+
+
+ crv = cupsJSONGetString(cupsJSONFind(jwk, "crv"));
+ x = make_bignum(jwk, "x");
+ y = make_bignum(jwk, "y");
+ d = verify ? NULL : make_bignum(jwk, "d");
+
+ if (!crv || ((!x || !y) && !d))
+ goto ec_done;
+
+ if (!strcmp(crv, "P-256"))
+ ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+ else if (!strcmp(crv, "P-384"))
+ ec = EC_KEY_new_by_curve_name(NID_secp384r1);
+ else if (!strcmp(crv, "P-521"))
+ ec = EC_KEY_new_by_curve_name(NID_secp521r1);
+ else
+ goto ec_done;
+
+ group = (EC_GROUP *)EC_KEY_get0_group(ec);
+ point = EC_POINT_new(group);
+
+ if (d)
+ {
+ // Set private key...
+ EC_KEY_set_private_key(ec, d);
+
+ // Create a new public key
+ EC_POINT_mul(group, point, d, NULL, NULL, NULL);
+ }
+ else
+ {
+ // Create a public key using the supplied coordinates...
+ EC_POINT_set_affine_coordinates_GFp(group, point, x, y, NULL);
+ }
+
+ // Set public key...
+ EC_KEY_set_public_key(ec, point);
+
+ ec_done:
+
+ if (!ec)
+ {
+ BN_free(x);
+ BN_free(y);
+ BN_free(d);
+ }
+
+ return (ec);
+}
+
+
+//
+// 'make_rsa()' - Create an RSA signing/verification object.
+//
+
+static RSA * // O - RSA object or `NULL` on error
+make_rsa(cups_json_t *jwk) // I - JSON web key
+{
+ RSA *rsa = NULL; // RSA object
+ BIGNUM *n, // Public key modulus
+ *e, // Public key exponent
+ *d, // Private key exponent
+ *p, // Private key first prime factor
+ *q, // Private key second prime factor
+ *dp, // First factor exponent
+ *dq, // Second factor exponent
+ *qi; // First CRT coefficient
+
+
+ n = make_bignum(jwk, "n");
+ e = make_bignum(jwk, "e");
+ d = make_bignum(jwk, "d");
+ p = make_bignum(jwk, "p");
+ q = make_bignum(jwk, "q");
+ dp = make_bignum(jwk, "dp");
+ dq = make_bignum(jwk, "dq");
+ qi = make_bignum(jwk, "qi");
+
+ if (!n || !e)
+ goto rsa_done;
+
+ rsa = RSA_new();
+ RSA_set0_key(rsa, n, e, d);
+ if (p && q)
+ RSA_set0_factors(rsa, p, q);
+ if (dp && dq && qi)
+ RSA_set0_crt_params(rsa, dp, dq, qi);
+
+ rsa_done:
+
+ if (!rsa)
+ {
+ BN_free(n);
+ BN_free(e);
+ BN_free(d);
+ BN_free(p);
+ BN_free(q);
+ BN_free(dp);
+ BN_free(dq);
+ BN_free(qi);
+ }
+
+ return (rsa);
+}
+
+
+#else // HAVE_GNUTLS
+//
+// 'make_datum()' - Make a datum value for a parameter.
+//
+
+static gnutls_datum_t * // O - Datum or `NULL`
+make_datum(cups_json_t *jwk, // I - JSON web key
+ const char *key) // I - Object key
+{
+ const char *value, // Key value
+ *value_end; // End of value
+ unsigned char value_bytes[1024];
+ // Decoded value
+ size_t value_len; // Length of value
+ gnutls_datum_t *datum; // GNU TLS datum
+
+
+ // See if we have the value...
+ if ((value = cupsJSONGetString(cupsJSONFind(jwk, key))) == NULL)
+ return (NULL);
+
+ // Decode and validate...
+ value_len = sizeof(value_bytes);
+ if (!httpDecode64_3((char *)value_bytes, &value_len, value, &value_end) || (value_end && *value_end))
+ return (NULL);
+
+ // Convert to a datum...
+ if ((datum = (gnutls_datum_t *)calloc(1, sizeof(gnutls_datum_t) + value_len)) != NULL)
+ {
+ // Set pointer and length, and copy value bytes...
+ datum->data = (unsigned char *)(datum + 1);
+ datum->size = (unsigned)value_len;
+
+ memcpy(datum + 1, value_bytes, value_len);
+ }
+
+ return (datum);
+}
+
+
+//
+// 'make_datstring()' - Make a Base64URL-encoded string from a datum.
+//
+
+static void
+make_datstring(gnutls_datum_t *d, // I - Datum
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
+{
+ httpEncode64_3(buffer, bufsize, (char *)d->data, d->size, true);
+ gnutls_free(d->data);
+}
+
+
+//
+// 'make_private_key()' - Make a private key for EC or RSA signing.
+//
+
+static gnutls_privkey_t // O - Private key or `NULL`
+make_private_key(cups_json_t *jwk) // I - JSON web key
+{
+ const char *kty; // Key type
+ gnutls_privkey_t key = NULL; // Private key
+
+
+ if ((kty = cupsJSONGetString(cupsJSONFind(jwk, "kty"))) == NULL)
+ {
+ // No type so we can't load it...
+ return (NULL);
+ }
+ else if (!strcmp(kty, "RSA"))
+ {
+ // Get RSA parameters...
+ gnutls_datum_t *n, // Public key modulus
+ *e, // Public key exponent
+ *d, // Private key exponent
+ *p, // Private key first prime factor
+ *q, // Private key second prime factor
+ *dp, // First factor exponent
+ *dq, // Second factor exponent
+ *qi; // First CRT coefficient
+
+ n = make_datum(jwk, "n");
+ e = make_datum(jwk, "e");
+ d = make_datum(jwk, "d");
+ p = make_datum(jwk, "p");
+ q = make_datum(jwk, "q");
+ dp = make_datum(jwk, "dp");
+ dq = make_datum(jwk, "dq");
+ qi = make_datum(jwk, "qi");
+
+ if (n && e && d && p && q && !gnutls_privkey_init(&key))
+ {
+ // Import RSA private key...
+ if (gnutls_privkey_import_rsa_raw(key, n, e, d, p, q, qi, dp, dq))
+ {
+ gnutls_privkey_deinit(key);
+ key = NULL;
+ }
+ }
+
+ // Free memory...
+ free(n);
+ free(e);
+ free(d);
+ free(p);
+ free(q);
+ free(dp);
+ free(dq);
+ free(qi);
+ }
+ else if (!strcmp(kty, "EC"))
+ {
+ // Get EC parameters...
+ const char *crv; // EC curve ("P-256", "P-384", or "P-521")
+ gnutls_ecc_curve_t curve; // Curve constant
+ gnutls_datum *x, // X coordinate
+ *y, // Y coordinate
+ *d; // Private key
+
+ crv = cupsJSONGetString(cupsJSONFind(jwk, "crv"));
+
+ if (!crv)
+ return (NULL);
+ else if (!strcmp(crv, "P-256"))
+ curve = GNUTLS_ECC_CURVE_SECP256R1;
+ else if (!strcmp(crv, "P-384"))
+ curve = GNUTLS_ECC_CURVE_SECP384R1;
+ else if (!strcmp(crv, "P-521"))
+ curve = GNUTLS_ECC_CURVE_SECP521R1;
+ else
+ return (NULL);
+
+ x = make_datum(jwk, "x");
+ y = make_datum(jwk, "y");
+ d = make_datum(jwk, "d");
+
+ if (x && y && d && !gnutls_privkey_init(&key))
+ {
+ // Import EC private key...
+ if (gnutls_privkey_import_ecc_raw(key, curve, x, y, d))
+ {
+ gnutls_privkey_deinit(key);
+ key = NULL;
+ }
+ }
+
+ // Free memory...
+ free(x);
+ free(y);
+ free(d);
+ }
+
+ // Return whatever key we got...
+ return (key);
+}
+
+
+//
+// 'make_public_key()' - Make a public key for EC or RSA verification.
+//
+
+static gnutls_pubkey_t // O - Public key or `NULL`
+make_public_key(cups_json_t *jwk) // I - JSON web key
+{
+ const char *kty; // Key type
+ gnutls_pubkey_t key = NULL; // Private key
+
+
+ if ((kty = cupsJSONGetString(cupsJSONFind(jwk, "kty"))) == NULL)
+ {
+ // No type so we can't load it...
+ return (NULL);
+ }
+ else if (!strcmp(kty, "RSA"))
+ {
+ // Get RSA parameters...
+ gnutls_datum_t *n, // Public key modulus
+ *e; // Public key exponent
+
+
+ n = make_datum(jwk, "n");
+ e = make_datum(jwk, "e");
+
+ if (n && e && !gnutls_pubkey_init(&key))
+ {
+ // Import RSA private key...
+ if (gnutls_pubkey_import_rsa_raw(key, n, e))
+ {
+ gnutls_pubkey_deinit(key);
+ key = NULL;
+ }
+ }
+
+ // Free memory and return...
+ free(n);
+ free(e);
+ }
+ else if (!strcmp(kty, "EC"))
+ {
+ // Get EC parameters...
+ const char *crv; // EC curve ("P-256", "P-384", or "P-521")
+ gnutls_ecc_curve_t curve; // Curve constant
+ gnutls_datum *x, // X coordinate
+ *y; // Y coordinate
+
+ crv = cupsJSONGetString(cupsJSONFind(jwk, "crv"));
+
+ if (!crv)
+ return (NULL);
+ else if (!strcmp(crv, "P-256"))
+ curve = GNUTLS_ECC_CURVE_SECP256R1;
+ else if (!strcmp(crv, "P-384"))
+ curve = GNUTLS_ECC_CURVE_SECP384R1;
+ else if (!strcmp(crv, "P-521"))
+ curve = GNUTLS_ECC_CURVE_SECP521R1;
+ else
+ return (NULL);
+
+ x = make_datum(jwk, "x");
+ y = make_datum(jwk, "y");
+
+ if (x && y && !gnutls_pubkey_init(&key))
+ {
+ // Import EC public key...
+ if (gnutls_pubkey_import_ecc_raw(key, curve, x, y))
+ {
+ gnutls_pubkey_deinit(key);
+ key = NULL;
+ }
+ }
+
+ // Free memory...
+ free(x);
+ free(y);
+ }
+
+ return (key);
+}
+#endif // HAVE_OPENSSL
+
+
+//
+// 'make_signature()' - Make a signature.
+//
+
+static bool // O - `true` on success, `false` on failure
+make_signature(cups_jwt_t *jwt, // I - JWT
+ cups_jwa_t alg, // I - Algorithm
+ cups_json_t *jwk, // I - JSON Web Key Set
+ unsigned char *signature,// I - Signature buffer
+ size_t *sigsize, // IO - Signature size
+ const char **sigkid) // IO - Key ID string, if any
+{
+ bool ret = false; // Return value
+ cups_json_t *keys; // Array of keys
+ char *text; // JWS Signing Input
+ size_t text_len; // Length of signing input
+#ifdef HAVE_OPENSSL
+ static int nids[] = { NID_sha256, NID_sha384, NID_sha512 };
+ // Hash NIDs
+#else // HAVE_GNUTLS
+ gnutls_privkey_t key; // Private key
+ gnutls_datum_t text_datum, // Text datum
+ sig_datum; // Signature datum
+ static int algs[] = { GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA384, GNUTLS_DIG_SHA512, GNUTLS_SIGN_ECDSA_SHA256, GNUTLS_SIGN_ECDSA_SHA384, GNUTLS_SIGN_ECDSA_SHA512 };
+ // Hash algorithms
+#endif // HAVE_OPENSSL
+
+
+ // Get text to sign...
+ text = make_string(jwt, false);
+ text_len = strlen(text);
+
+ if ((keys = cupsJSONFind(jwk, "keys")) != NULL)
+ {
+ // Full key set, find the key we need to use...
+ size_t i, // Looping var
+ count; // Number of keys
+ cups_json_t *current; // Current key
+ const char *curkid, // Current key ID
+ *curkty; // Current key type
+
+ count = cupsJSONGetCount(keys);
+
+ if (*sigkid)
+ {
+ // Find the matching key ID
+ for (i = 0; i < count; i ++)
+ {
+ current = cupsJSONGetChild(keys, i);
+ curkid = cupsJSONGetString(cupsJSONFind(current, "kid"));
+
+ if (curkid && !strcmp(curkid, *sigkid))
+ {
+ jwk = current;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Find a key that can be used for the specified algorithm
+ for (i = 0; i < count; i ++)
+ {
+ current = cupsJSONGetChild(keys, i);
+ curkty = cupsJSONGetString(cupsJSONFind(current, "kty"));
+
+ if (((!curkty || !strcmp(curkty, "ocy")) && alg >= CUPS_JWA_HS256 && alg <= CUPS_JWA_HS512) || (curkty && !strcmp(curkty, "RSA") && alg >= CUPS_JWA_RS256 && alg <= CUPS_JWA_RS512) || (curkty && !strcmp(curkty, "EC") && alg >= CUPS_JWA_ES256 && alg <= CUPS_JWA_ES512))
+ {
+ jwk = current;
+ break;
+ }
+ }
+ }
+ }
+
+ if (alg >= CUPS_JWA_HS256 && alg <= CUPS_JWA_HS512)
+ {
+ // SHA-256/384/512 HMAC
+ const char *k; // "k" value
+ unsigned char key[256]; // Key value
+ size_t key_len; // Length of key
+ ssize_t hmac_len; // Length of HMAC
+
+ // Get key...
+ memset(key, 0, sizeof(key));
+ k = cupsJSONGetString(cupsJSONFind(jwk, "k"));
+ key_len = sizeof(key);
+ if (!httpDecode64_3((char *)key, &key_len, k, NULL))
+ goto done;
+
+ if ((hmac_len = cupsHMACData(cups_jwa_algorithms[alg], key, key_len, text, text_len, signature, _CUPS_JWT_MAX_SIGNATURE)) < 0)
+ goto done;
+
+ *sigsize = (size_t)hmac_len;
+ ret = true;
+ }
+ else if (alg >= CUPS_JWA_RS256 && alg <= CUPS_JWA_RS512)
+ {
+ // RSASSA-PKCS1-v1_5 SHA-256/384/512
+#ifdef HAVE_OPENSSL
+ unsigned char hash[128]; // SHA-256/384/512 hash
+ ssize_t hash_len; // Length of hash
+ unsigned siglen = (unsigned)*sigsize;
+ // Length of signature
+ RSA *rsa; // RSA public/private key
+
+ if ((rsa = make_rsa(jwk)) != NULL)
+ {
+ hash_len = cupsHashData(cups_jwa_algorithms[alg], text, text_len, hash, sizeof(hash));
+ if (RSA_sign(nids[alg - CUPS_JWA_RS256], hash, hash_len, signature, &siglen, rsa) == 1)
+ {
+ *sigsize = siglen;
+ ret = true;
+ }
+
+ RSA_free(rsa);
+ }
+#else // HAVE_GNUTLS
+ if ((key = make_private_key(jwk)) != NULL)
+ {
+ text_datum.data = (unsigned char *)text;
+ text_datum.size = (unsigned)text_len;
+ sig_datum.data = NULL;
+ sig_datum.size = 0;
+
+ if (!gnutls_privkey_sign_data(key, algs[alg - CUPS_JWA_RS256], 0, &text_datum, &sig_datum) && sig_datum.size <= *sigsize)
+ {
+ memcpy(signature, sig_datum.data, sig_datum.size);
+ *sigsize = sig_datum.size;
+ ret = true;
+ }
+
+ gnutls_free(sig_datum.data);
+ gnutls_privkey_deinit(key);
+ }
+#endif // HAVE_OPENSSL
+ }
+ else if (alg >= CUPS_JWA_ES256 && alg <= CUPS_JWA_ES512)
+ {
+ // ECDSA P-256 SHA-256/384/512
+ static unsigned sig_sizes[3] = // Sizes of signatures
+ { 64, 96, 132 };
+#ifdef HAVE_OPENSSL
+ unsigned char hash[128]; // SHA-256/384/512 hash
+ ssize_t hash_len; // Length of hash
+ unsigned sig_len; // Length of signature coordinate
+ EC_KEY *ec; // EC private key
+ ECDSA_SIG *ec_sig; // EC signature
+ const BIGNUM *r, *s; // Signature coordinates
+ unsigned r_len, s_len; // Length of coordinates
+
+ if ((ec = make_ec_key(jwk, false)) != NULL)
+ {
+ hash_len = cupsHashData(cups_jwa_algorithms[alg], text, text_len, hash, sizeof(hash));
+ if ((ec_sig = ECDSA_do_sign(hash, hash_len, ec)) != NULL)
+ {
+ // Get the raw coordinates...
+ ECDSA_SIG_get0(ec_sig, &r, &s);
+ r_len = (unsigned)BN_num_bytes(r);
+ s_len = (unsigned)BN_num_bytes(s);
+ *sigsize = sig_sizes[alg - CUPS_JWA_ES256];
+ sig_len = *sigsize / 2;
+ ret = true;
+
+ // 0-pad raw coordinates
+ memset(signature, 0, *sigsize);
+ BN_bn2bin(r, signature + sig_len - r_len);
+ BN_bn2bin(s, signature + *sigsize - s_len);
+
+ // Free the signature
+ ECDSA_SIG_free(ec_sig);
+ }
+
+ EC_KEY_free(ec);
+ }
+#else // HAVE_GNUTLS
+ if ((key = make_private_key(jwk)) != NULL)
+ {
+ text_datum.data = (unsigned char *)text;
+ text_datum.size = (unsigned)text_len;
+ sig_datum.data = NULL;
+ sig_datum.size = 0;
+
+ if (!gnutls_privkey_sign_data(key, algs[alg - CUPS_JWA_RS256], 0, &text_datum, &sig_datum) && sig_datum.size <= *sigsize)
+ {
+ gnutls_datum_t r, s; // Signature coordinates
+ unsigned sig_len;
+ *sigsize = sig_sizes[alg - CUPS_JWA_ES256];
+ sig_len = *sigsize / 2;
+ gnutls_decode_rs_value(&sig_datum, &r, &s);
+
+ memset(signature, 0, *sigsize);
+ if (r.size < sig_len)
+ memcpy(signature + sig_len - r.size, r.data, r.size);
+ else
+ memcpy(signature, r.data + r.size - sig_len, sig_len);
+ if (s.size < sig_len)
+ memcpy(signature + *sigsize - s.size, s.data, s.size);
+ else
+ memcpy(signature + sig_len, s.data + s.size - sig_len, sig_len);
+ ret = true;
+
+ gnutls_free(r.data);
+ gnutls_free(s.data);
+ }
+
+ gnutls_free(sig_datum.data);
+ gnutls_privkey_deinit(key);
+ }
+#endif // HAVE_OPENSSL
+ }
+
+ done:
+
+ free(text);
+
+ if (ret)
+ *sigkid = cupsJSONGetString(cupsJSONFind(jwk, "kid"));
+ else
+ *sigsize = 0;
+
+ return (ret);
+}
+
+
+//
+// 'make_string()' - Make a JWT/JWS Compact Serialization string.
+//
+
+static char * // O - JWT/JWS string
+make_string(cups_jwt_t *jwt, // I - JWT object
+ bool with_signature) // I - Include signature field?
+{
+ char *s = NULL, // JWT/JWS string
+ *ptr, // Pointer into string
+ *end; // End of string
+ size_t jose_len, // Length of JOSE header
+ claims_len, // Length of claims string
+ len; // Allocation length
+
+
+ // Get the JOSE header and claims object strings...
+ if (!jwt->claims_string)
+ jwt->claims_string = cupsJSONExportString(jwt->claims);
+
+ if (!jwt->jose_string || !jwt->claims_string)
+ return (NULL);
+
+ jose_len = strlen(jwt->jose_string);
+ claims_len = strlen(jwt->claims_string);
+
+ // Calculate the maximum Base64URL-encoded string length...
+ len = ((jose_len + 2) * 4 / 3) + 1 + ((claims_len + 2) * 4 / 3) + 1 + ((_CUPS_JWT_MAX_SIGNATURE + 2) * 4 / 3) + 1;
+
+ if ((s = malloc(len)) == NULL)
+ return (NULL);
+
+ ptr = s;
+ end = s + len;
+
+ httpEncode64_3(ptr, (size_t)(end - ptr), jwt->jose_string, jose_len, true);
+ ptr += strlen(ptr);
+ *ptr++ = '.';
+
+ httpEncode64_3(ptr, (size_t)(end - ptr), jwt->claims_string, claims_len, true);
+ ptr += strlen(ptr);
+
+ if (with_signature)
+ {
+ *ptr++ = '.';
+
+ if (jwt->sigsize)
+ httpEncode64_3(ptr, (size_t)(end - ptr), (char *)jwt->signature, jwt->sigsize, true);
+ }
+
+ return (s);
+}
--- /dev/null
+//
+// JSON Web Token API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#ifndef _CUPS_JWT_H_
+# define _CUPS_JWT_H_
+# include "json.h"
+# ifdef __cplusplus
+extern "C" {
+# endif // __cplusplus
+
+
+//
+// Constants...
+//
+
+#define CUPS_JWT_AUD "aud" // JWT audience claim
+#define CUPS_JWT_EXP "exp" // JWT expiration date/time claim
+#define CUPS_JWT_IAT "iat" // JWT issued at date/time claim
+#define CUPS_JWT_ISS "iss" // JWT issuer claim (authorization server)
+#define CUPS_JWT_JTI "jti" // JWT unique identifier claim
+#define CUPS_JWT_NAME "name" // OpenID display name
+#define CUPS_JWT_NBF "nbf" // JWT not before date/time claim
+#define CUPS_JWT_SUB "sub" // JWT subject claim (username/ID)
+
+
+//
+// Types...
+//
+
+typedef enum cups_jwa_e // JSON Web Algorithms @since CUPS 2.5@
+{
+ CUPS_JWA_NONE, // No algorithm
+ CUPS_JWA_HS256, // HMAC using SHA-256
+ CUPS_JWA_HS384, // HMAC using SHA-384
+ CUPS_JWA_HS512, // HMAC using SHA-512
+ CUPS_JWA_RS256, // RSASSA-PKCS1-v1_5 using SHA-256
+ CUPS_JWA_RS384, // RSASSA-PKCS1-v1_5 using SHA-384
+ CUPS_JWA_RS512, // RSASSA-PKCS1-v1_5 using SHA-512
+ CUPS_JWA_ES256, // ECDSA using P-256 and SHA-256
+ CUPS_JWA_ES384, // ECDSA using P-384 and SHA-384
+ CUPS_JWA_ES512, // ECDSA using P-521 and SHA-512
+ CUPS_JWA_MAX // @private@ Maximum JWA value
+} cups_jwa_t;
+
+typedef enum cups_jws_format_e // JSON Web Signature Formats @since CUPS 2.5@
+{
+ CUPS_JWS_FORMAT_COMPACT, // JWS Compact Serialization
+ CUPS_JWS_FORMAT_JSON // JWS JSON Serialization
+} cups_jws_format_t;
+
+typedef struct _cups_jwt_s cups_jwt_t; // JSON Web Token @since CUPS 2.5@
+
+
+//
+// Functions...
+//
+
+extern void cupsJWTDelete(cups_jwt_t *jwt) _CUPS_PUBLIC;
+extern char *cupsJWTExportString(cups_jwt_t *jwt, cups_jws_format_t format) _CUPS_PUBLIC;
+extern cups_jwa_t cupsJWTGetAlgorithm(cups_jwt_t *jwt) _CUPS_PUBLIC;
+extern double cupsJWTGetClaimNumber(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern const char *cupsJWTGetClaimString(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_jtype_t cupsJWTGetClaimType(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTGetClaimValue(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTGetClaims(cups_jwt_t *jwt) _CUPS_PUBLIC;
+extern double cupsJWTGetHeaderNumber(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern const char *cupsJWTGetHeaderString(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_jtype_t cupsJWTGetHeaderType(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTGetHeaderValue(cups_jwt_t *jwt, const char *claim) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTGetHeaders(cups_jwt_t *jwt) _CUPS_PUBLIC;
+extern bool cupsJWTHasValidSignature(cups_jwt_t *jwt, cups_json_t *keys) _CUPS_PUBLIC;
+extern cups_jwt_t *cupsJWTImportString(const char *s, cups_jws_format_t format) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTMakePrivateKey(cups_jwa_t alg) _CUPS_PUBLIC;
+extern cups_json_t *cupsJWTMakePublicKey(cups_json_t *jwk) _CUPS_PUBLIC;
+extern cups_jwt_t *cupsJWTNew(const char *type) _CUPS_PUBLIC;
+extern void cupsJWTSetClaimNumber(cups_jwt_t *jwt, const char *claim, double value) _CUPS_PUBLIC;
+extern void cupsJWTSetClaimString(cups_jwt_t *jwt, const char *claim, const char *value) _CUPS_PUBLIC;
+extern void cupsJWTSetClaimValue(cups_jwt_t *jwt, const char *claim, cups_json_t *value) _CUPS_PUBLIC;
+extern void cupsJWTSetHeaderNumber(cups_jwt_t *jwt, const char *claim, double value) _CUPS_PUBLIC;
+extern void cupsJWTSetHeaderString(cups_jwt_t *jwt, const char *claim, const char *value) _CUPS_PUBLIC;
+extern void cupsJWTSetHeaderValue(cups_jwt_t *jwt, const char *claim, cups_json_t *value) _CUPS_PUBLIC;
+extern bool cupsJWTSign(cups_jwt_t *jwt, cups_jwa_t alg, cups_json_t *keys) _CUPS_PUBLIC;
+
+
+# ifdef __cplusplus
+}
+# endif // __cplusplus
+#endif // !_CUPS_JWT_H_
-/*
- * Private localization support for CUPS.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private localization support for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_LANGUAGE_PRIVATE_H_
# define _CUPS_LANGUAGE_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
# include "config.h"
# include <stdio.h>
# include <cups/transcode.h>
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Macro for localized text...
- */
+//
+// Macro for localized text...
+//
# define _(x) x
-/*
- * Constants...
- */
+//
+// Constants...
+//
-# define _CUPS_MESSAGE_PO 0 /* Message file is in GNU .po format */
-# define _CUPS_MESSAGE_UNQUOTE 1 /* Unescape \foo in strings? */
-# define _CUPS_MESSAGE_STRINGS 2 /* Message file is in Apple .strings format */
-# define _CUPS_MESSAGE_EMPTY 4 /* Allow empty localized strings */
+# define _CUPS_MESSAGE_PO 0 // Message file is in GNU .po format
+# define _CUPS_MESSAGE_UNQUOTE 1 // Unescape \foo in strings?
+# define _CUPS_MESSAGE_STRINGS 2 // Message file is in Apple .strings format
+# define _CUPS_MESSAGE_EMPTY 4 // Allow empty localized strings
-/*
- * Types...
- */
+//
+// Types...
+//
-typedef struct _cups_message_s /**** Message catalog entry ****/
+typedef struct _cups_message_s // Message catalog entry
{
- char *msg, /* Original string */
- *str; /* Localized string */
+ char *msg, // Original string
+ *str; // Localized string
} _cups_message_t;
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
extern void _cupsCharmapFlush(void) _CUPS_INTERNAL;
extern const char *_cupsEncodingName(cups_encoding_t encoding) _CUPS_PRIVATE;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_LANGUAGE_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_LANGUAGE_PRIVATE_H_
-/*
- * Multi-language support for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Multi-language support for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2011 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_LANGUAGE_H_
# define _CUPS_LANGUAGE_H_
-
-/*
- * Include necessary headers...
- */
-
# include <locale.h>
# include "array.h"
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Types...
- */
+//
+// Types...
+//
-typedef enum cups_encoding_e /**** Language Encodings @exclude all@ ****/
+typedef enum cups_encoding_e // Language Encodings @exclude all@
{
- CUPS_AUTO_ENCODING = -1, /* Auto-detect the encoding @private@ */
- CUPS_US_ASCII, /* US ASCII */
- CUPS_ISO8859_1, /* ISO-8859-1 */
- CUPS_ISO8859_2, /* ISO-8859-2 */
- CUPS_ISO8859_3, /* ISO-8859-3 */
- CUPS_ISO8859_4, /* ISO-8859-4 */
- CUPS_ISO8859_5, /* ISO-8859-5 */
- CUPS_ISO8859_6, /* ISO-8859-6 */
- CUPS_ISO8859_7, /* ISO-8859-7 */
- CUPS_ISO8859_8, /* ISO-8859-8 */
- CUPS_ISO8859_9, /* ISO-8859-9 */
- CUPS_ISO8859_10, /* ISO-8859-10 */
- CUPS_UTF8, /* UTF-8 */
- CUPS_ISO8859_13, /* ISO-8859-13 */
- CUPS_ISO8859_14, /* ISO-8859-14 */
- CUPS_ISO8859_15, /* ISO-8859-15 */
- CUPS_WINDOWS_874, /* CP-874 */
- CUPS_WINDOWS_1250, /* CP-1250 */
- CUPS_WINDOWS_1251, /* CP-1251 */
- CUPS_WINDOWS_1252, /* CP-1252 */
- CUPS_WINDOWS_1253, /* CP-1253 */
- CUPS_WINDOWS_1254, /* CP-1254 */
- CUPS_WINDOWS_1255, /* CP-1255 */
- CUPS_WINDOWS_1256, /* CP-1256 */
- CUPS_WINDOWS_1257, /* CP-1257 */
- CUPS_WINDOWS_1258, /* CP-1258 */
- CUPS_KOI8_R, /* KOI-8-R */
- CUPS_KOI8_U, /* KOI-8-U */
- CUPS_ISO8859_11, /* ISO-8859-11 */
- CUPS_ISO8859_16, /* ISO-8859-16 */
- CUPS_MAC_ROMAN, /* MacRoman */
- CUPS_ENCODING_SBCS_END = 63, /* End of single-byte encodings @private@ */
+ CUPS_AUTO_ENCODING = -1, // Auto-detect the encoding @private@
+ CUPS_US_ASCII, // US ASCII
+ CUPS_ISO8859_1, // ISO-8859-1
+ CUPS_ISO8859_2, // ISO-8859-2
+ CUPS_ISO8859_3, // ISO-8859-3
+ CUPS_ISO8859_4, // ISO-8859-4
+ CUPS_ISO8859_5, // ISO-8859-5
+ CUPS_ISO8859_6, // ISO-8859-6
+ CUPS_ISO8859_7, // ISO-8859-7
+ CUPS_ISO8859_8, // ISO-8859-8
+ CUPS_ISO8859_9, // ISO-8859-9
+ CUPS_ISO8859_10, // ISO-8859-10
+ CUPS_UTF8, // UTF-8
+ CUPS_ISO8859_13, // ISO-8859-13
+ CUPS_ISO8859_14, // ISO-8859-14
+ CUPS_ISO8859_15, // ISO-8859-15
+ CUPS_WINDOWS_874, // CP-874
+ CUPS_WINDOWS_1250, // CP-1250
+ CUPS_WINDOWS_1251, // CP-1251
+ CUPS_WINDOWS_1252, // CP-1252
+ CUPS_WINDOWS_1253, // CP-1253
+ CUPS_WINDOWS_1254, // CP-1254
+ CUPS_WINDOWS_1255, // CP-1255
+ CUPS_WINDOWS_1256, // CP-1256
+ CUPS_WINDOWS_1257, // CP-1257
+ CUPS_WINDOWS_1258, // CP-1258
+ CUPS_KOI8_R, // KOI-8-R
+ CUPS_KOI8_U, // KOI-8-U
+ CUPS_ISO8859_11, // ISO-8859-11
+ CUPS_ISO8859_16, // ISO-8859-16
+ CUPS_MAC_ROMAN, // MacRoman
+ CUPS_ENCODING_SBCS_END = 63, // End of single-byte encodings @private@
- CUPS_WINDOWS_932, /* Japanese JIS X0208-1990 */
- CUPS_WINDOWS_936, /* Simplified Chinese GB 2312-80 */
- CUPS_WINDOWS_949, /* Korean KS C5601-1992 */
- CUPS_WINDOWS_950, /* Traditional Chinese Big Five */
- CUPS_WINDOWS_1361, /* Korean Johab */
- CUPS_BG18030, /* Chinese GB 18030 @since CUPS 2.4.0@ */
- CUPS_ENCODING_DBCS_END = 127, /* End of double-byte encodings @private@ */
+ CUPS_WINDOWS_932, // Japanese JIS X0208-1990
+ CUPS_WINDOWS_936, // Simplified Chinese GB 2312-80
+ CUPS_WINDOWS_949, // Korean KS C5601-1992
+ CUPS_WINDOWS_950, // Traditional Chinese Big Five
+ CUPS_WINDOWS_1361, // Korean Johab
+ CUPS_BG18030, // Chinese GB 18030 @since CUPS 2.4.0@
+ CUPS_ENCODING_DBCS_END = 127, // End of double-byte encodings @private@
- CUPS_EUC_CN, /* EUC Simplified Chinese */
- CUPS_EUC_JP, /* EUC Japanese */
- CUPS_EUC_KR, /* EUC Korean */
- CUPS_EUC_TW, /* EUC Traditional Chinese */
- CUPS_JIS_X0213, /* JIS X0213 aka Shift JIS */
- CUPS_ENCODING_VBCS_END = 191 /* End of variable-length encodings @private@ */
+ CUPS_EUC_CN, // EUC Simplified Chinese
+ CUPS_EUC_JP, // EUC Japanese
+ CUPS_EUC_KR, // EUC Korean
+ CUPS_EUC_TW, // EUC Traditional Chinese
+ CUPS_JIS_X0213, // JIS X0213 aka Shift JIS
+ CUPS_ENCODING_VBCS_END = 191 // End of variable-length encodings @private@
} cups_encoding_t;
-typedef struct cups_lang_s /**** Language Cache Structure ****/
+typedef struct cups_lang_s // Language Cache Structure
{
- struct cups_lang_s *next; /* Next language in cache */
- int used; /* Number of times this entry has been used. */
- cups_encoding_t encoding; /* Text encoding */
- char language[16]; /* Language/locale name */
- cups_array_t *strings; /* Message strings @private@ */
+ struct cups_lang_s *next; // Next language in cache
+ int used; // Number of times this entry has been used.
+ cups_encoding_t encoding; // Text encoding
+ char language[16]; // Language/locale name
+ cups_array_t *strings; // Message strings @private@
} cups_lang_t;
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
extern cups_lang_t *cupsLangDefault(void) _CUPS_PUBLIC;
extern const char *cupsLangEncoding(cups_lang_t *lang) _CUPS_PUBLIC;
extern void cupsLangFree(cups_lang_t *lang) _CUPS_PUBLIC;
extern cups_lang_t *cupsLangGet(const char *language) _CUPS_PUBLIC;
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_LANGUAGE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_LANGUAGE_H_
#ifndef _CUPS_MD5_INTERNAL_H_
# define _CUPS_MD5_INTERNAL_H_
+# include "base.h"
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
-# include <cups/versioning.h>
/* Define the state of the MD5 Algorithm. */
typedef struct _cups_md5_state_s {
unsigned char buf[64]; /* accumulate block */
} _cups_md5_state_t;
-# ifdef __cplusplus
-extern "C" {
-# endif /* __cplusplus */
-
/* Initialize the algorithm. */
void _cupsMD5Init(_cups_md5_state_t *pms) _CUPS_INTERNAL;
-/*
- * PostScript Printer Description definitions for CUPS.
- *
- * THESE APIS ARE DEPRECATED. THIS HEADER AND THESE FUNCTIONS WILL BE REMOVED
- * IN A FUTURE RELEASE OF CUPS.
- *
- * Copyright © 2007-2019 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.
- *
- * PostScript is a trademark of Adobe Systems, Inc.
- */
+//
+// PostScript Printer Description definitions for CUPS.
+//
+// THESE APIS ARE DEPRECATED. THIS HEADER AND THESE FUNCTIONS WILL BE REMOVED
+// IN A FUTURE RELEASE OF CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2019 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.
+//
+// PostScript is a trademark of Adobe Systems, Inc.
+//
#ifndef _CUPS_PPD_H_
# define _CUPS_PPD_H_
-
-/*
- * Include necessary headers...
- */
-
# include <stdio.h>
# include "cups.h"
# include "array.h"
# include "file.h"
# include "raster.h"
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * PPD version...
- */
+//
+// PPD version...
+//
-# define PPD_VERSION 4.3 /* Kept in sync with Adobe version number */
+# define PPD_VERSION 4.3 // Kept in sync with Adobe version number
-/*
- * PPD size limits (defined in Adobe spec)
- */
+//
+// PPD size limits (defined in Adobe spec)
+//
-# define PPD_MAX_NAME 41 /* Maximum size of name + 1 for nul */
-# define PPD_MAX_TEXT 81 /* Maximum size of text + 1 for nul */
-# define PPD_MAX_LINE 256 /* Maximum size of line + 1 for nul */
+# define PPD_MAX_NAME 41 // Maximum size of name + 1 for nul
+# define PPD_MAX_TEXT 81 // Maximum size of text + 1 for nul
+# define PPD_MAX_LINE 256 // Maximum size of line + 1 for nul
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
- /**** cupsRasterInterpretPPD callback function
- *
- * This function is called by
- * @link cupsRasterInterpretPPD@ to
- * validate (and update, as needed)
- * the page header attributes. The
- * "preferred_bits" argument provides
- * the value of the
- * @code cupsPreferredBitsPerColor@
- * key from the PostScript page device
- * dictionary and is 0 if undefined.
- ****/
-
-typedef enum ppd_ui_e /**** UI Types @deprecated@ ****/
+ // cupsRasterInterpretPPD callback function
+ //
+ // This function is called by
+ // @link cupsRasterInterpretPPD@ to
+ // validate (and update, as needed)
+ // the page header attributes. The
+ // "preferred_bits" argument provides
+ // the value of the
+ // @code cupsPreferredBitsPerColor@
+ // key from the PostScript page device
+ // dictionary and is 0 if undefined.
+
+typedef enum ppd_ui_e // UI Types @deprecated@
{
- PPD_UI_BOOLEAN, /* True or False option */
- PPD_UI_PICKONE, /* Pick one from a list */
- PPD_UI_PICKMANY /* Pick zero or more from a list */
+ PPD_UI_BOOLEAN, // True or False option
+ PPD_UI_PICKONE, // Pick one from a list
+ PPD_UI_PICKMANY // Pick zero or more from a list
} ppd_ui_t;
-typedef enum ppd_section_e /**** Order dependency sections @deprecated@ ****/
+typedef enum ppd_section_e // Order dependency sections @deprecated@
{
- PPD_ORDER_ANY, /* Option code can be anywhere in the file */
- PPD_ORDER_DOCUMENT, /* ... must be in the DocumentSetup section */
- PPD_ORDER_EXIT, /* ... must be sent prior to the document */
- PPD_ORDER_JCL, /* ... must be sent as a JCL command */
- PPD_ORDER_PAGE, /* ... must be in the PageSetup section */
- PPD_ORDER_PROLOG /* ... must be in the Prolog section */
+ PPD_ORDER_ANY, // Option code can be anywhere in the file
+ PPD_ORDER_DOCUMENT, // ... must be in the DocumentSetup section
+ PPD_ORDER_EXIT, // ... must be sent prior to the document
+ PPD_ORDER_JCL, // ... must be sent as a JCL command
+ PPD_ORDER_PAGE, // ... must be in the PageSetup section
+ PPD_ORDER_PROLOG // ... must be in the Prolog section
} ppd_section_t;
-typedef enum ppd_cs_e /**** Colorspaces @deprecated@ ****/
+typedef enum ppd_cs_e // Colorspaces @deprecated@
{
- PPD_CS_CMYK = -4, /* CMYK colorspace */
- PPD_CS_CMY, /* CMY colorspace */
- PPD_CS_GRAY = 1, /* Grayscale colorspace */
- PPD_CS_RGB = 3, /* RGB colorspace */
- PPD_CS_RGBK, /* RGBK (K = gray) colorspace */
- PPD_CS_N /* DeviceN colorspace */
+ PPD_CS_CMYK = -4, // CMYK colorspace
+ PPD_CS_CMY, // CMY colorspace
+ PPD_CS_GRAY = 1, // Grayscale colorspace
+ PPD_CS_RGB = 3, // RGB colorspace
+ PPD_CS_RGBK, // RGBK (K = gray) colorspace
+ PPD_CS_N // DeviceN colorspace
} ppd_cs_t;
-typedef enum ppd_status_e /**** Status Codes @deprecated@ ****/
+typedef enum ppd_status_e // Status Codes @deprecated@
{
- PPD_OK = 0, /* OK */
- PPD_FILE_OPEN_ERROR, /* Unable to open PPD file */
- PPD_NULL_FILE, /* NULL PPD file pointer */
- PPD_ALLOC_ERROR, /* Memory allocation error */
- PPD_MISSING_PPDADOBE4, /* Missing PPD-Adobe-4.x header */
- PPD_MISSING_VALUE, /* Missing value string */
- PPD_INTERNAL_ERROR, /* Internal error */
- PPD_BAD_OPEN_GROUP, /* Bad OpenGroup */
- PPD_NESTED_OPEN_GROUP, /* OpenGroup without a CloseGroup first */
- PPD_BAD_OPEN_UI, /* Bad OpenUI/JCLOpenUI */
- PPD_NESTED_OPEN_UI, /* OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first */
- PPD_BAD_ORDER_DEPENDENCY, /* Bad OrderDependency */
- PPD_BAD_UI_CONSTRAINTS, /* Bad UIConstraints */
- PPD_MISSING_ASTERISK, /* Missing asterisk in column 0 */
- PPD_LINE_TOO_LONG, /* Line longer than 255 chars */
- PPD_ILLEGAL_CHARACTER, /* Illegal control character */
- PPD_ILLEGAL_MAIN_KEYWORD, /* Illegal main keyword string */
- PPD_ILLEGAL_OPTION_KEYWORD, /* Illegal option keyword string */
- PPD_ILLEGAL_TRANSLATION, /* Illegal translation string */
- PPD_ILLEGAL_WHITESPACE, /* Illegal whitespace character */
- PPD_BAD_CUSTOM_PARAM, /* Bad custom parameter */
- PPD_MISSING_OPTION_KEYWORD, /* Missing option keyword */
- PPD_BAD_VALUE, /* Bad value string */
- PPD_MISSING_CLOSE_GROUP, /* Missing CloseGroup */
- PPD_BAD_CLOSE_UI, /* Bad CloseUI/JCLCloseUI */
- PPD_MISSING_CLOSE_UI, /* Missing CloseUI/JCLCloseUI */
- PPD_MAX_STATUS /* @private@ */
+ PPD_OK = 0, // OK
+ PPD_FILE_OPEN_ERROR, // Unable to open PPD file
+ PPD_NULL_FILE, // NULL PPD file pointer
+ PPD_ALLOC_ERROR, // Memory allocation error
+ PPD_MISSING_PPDADOBE4, // Missing PPD-Adobe-4.x header
+ PPD_MISSING_VALUE, // Missing value string
+ PPD_INTERNAL_ERROR, // Internal error
+ PPD_BAD_OPEN_GROUP, // Bad OpenGroup
+ PPD_NESTED_OPEN_GROUP, // OpenGroup without a CloseGroup first
+ PPD_BAD_OPEN_UI, // Bad OpenUI/JCLOpenUI
+ PPD_NESTED_OPEN_UI, // OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first
+ PPD_BAD_ORDER_DEPENDENCY, // Bad OrderDependency
+ PPD_BAD_UI_CONSTRAINTS, // Bad UIConstraints
+ PPD_MISSING_ASTERISK, // Missing asterisk in column 0
+ PPD_LINE_TOO_LONG, // Line longer than 255 chars
+ PPD_ILLEGAL_CHARACTER, // Illegal control character
+ PPD_ILLEGAL_MAIN_KEYWORD, // Illegal main keyword string
+ PPD_ILLEGAL_OPTION_KEYWORD, // Illegal option keyword string
+ PPD_ILLEGAL_TRANSLATION, // Illegal translation string
+ PPD_ILLEGAL_WHITESPACE, // Illegal whitespace character
+ PPD_BAD_CUSTOM_PARAM, // Bad custom parameter
+ PPD_MISSING_OPTION_KEYWORD, // Missing option keyword
+ PPD_BAD_VALUE, // Bad value string
+ PPD_MISSING_CLOSE_GROUP, // Missing CloseGroup
+ PPD_BAD_CLOSE_UI, // Bad CloseUI/JCLCloseUI
+ PPD_MISSING_CLOSE_UI, // Missing CloseUI/JCLCloseUI
+ PPD_MAX_STATUS // @private@
} ppd_status_t;
-enum ppd_conform_e /**** Conformance Levels @deprecated@ ****/
+enum ppd_conform_e // Conformance Levels @deprecated@
{
- PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
- PPD_CONFORM_STRICT /* Require strict conformance */
+ PPD_CONFORM_RELAXED, // Relax whitespace and control char
+ PPD_CONFORM_STRICT // Require strict conformance
};
typedef enum ppd_conform_e ppd_conform_t;
- /**** Conformance Levels @deprecated@ ****/
+ // Conformance Levels @deprecated@
-typedef struct ppd_attr_s /**** PPD Attribute Structure @deprecated@ ****/
+typedef struct ppd_attr_s // PPD Attribute Structure @deprecated@
{
- char name[PPD_MAX_NAME]; /* Name of attribute (cupsXYZ) */
- char spec[PPD_MAX_NAME]; /* Specifier string, if any */
- char text[PPD_MAX_TEXT]; /* Human-readable text, if any */
- char *value; /* Value string */
+ char name[PPD_MAX_NAME]; // Name of attribute (cupsXYZ)
+ char spec[PPD_MAX_NAME]; // Specifier string, if any
+ char text[PPD_MAX_TEXT]; // Human-readable text, if any
+ char *value; // Value string
} ppd_attr_t;
typedef struct ppd_option_s ppd_option_t;
- /**** Options @deprecated@ ****/
+ // Options @deprecated@
-typedef struct ppd_choice_s /**** Option choices @deprecated@ ****/
+typedef struct ppd_choice_s // Option choices @deprecated@
{
- char marked; /* 0 if not selected, 1 otherwise */
- char choice[PPD_MAX_NAME]; /* Computer-readable option name */
- char text[PPD_MAX_TEXT]; /* Human-readable option name */
- char *code; /* Code to send for this option */
- ppd_option_t *option; /* Pointer to parent option structure */
+ char marked; // 0 if not selected, 1 otherwise
+ char choice[PPD_MAX_NAME]; // Computer-readable option name
+ char text[PPD_MAX_TEXT]; // Human-readable option name
+ char *code; // Code to send for this option
+ ppd_option_t *option; // Pointer to parent option structure
} ppd_choice_t;
-struct ppd_option_s /**** Options @deprecated@ ****/
+struct ppd_option_s // Options @deprecated@
{
- char conflicted; /* 0 if no conflicts exist, 1 otherwise */
- char keyword[PPD_MAX_NAME]; /* Option keyword name ("PageSize", etc.) */
- char defchoice[PPD_MAX_NAME];/* Default option choice */
- char text[PPD_MAX_TEXT]; /* Human-readable text */
- ppd_ui_t ui; /* Type of UI option */
- ppd_section_t section; /* Section for command */
- float order; /* Order number */
- int num_choices; /* Number of option choices */
- ppd_choice_t *choices; /* Option choices */
+ char conflicted; // 0 if no conflicts exist, 1 otherwise
+ char keyword[PPD_MAX_NAME]; // Option keyword name ("PageSize", etc.)
+ char defchoice[PPD_MAX_NAME];// Default option choice
+ char text[PPD_MAX_TEXT]; // Human-readable text
+ ppd_ui_t ui; // Type of UI option
+ ppd_section_t section; // Section for command
+ float order; // Order number
+ int num_choices; // Number of option choices
+ ppd_choice_t *choices; // Option choices
};
-typedef struct ppd_group_s /**** Groups @deprecated@ ****/
+typedef struct ppd_group_s // Groups @deprecated@
{
/**** Group text strings are limited to 39 chars + nul in order to
**** preserve binary compatibility and allow applications to get
**** the group's keyword name.
****/
char text[PPD_MAX_TEXT - PPD_MAX_NAME];
- /* Human-readable group name */
- char name[PPD_MAX_NAME]; /* Group name @since CUPS 1.1.18/macOS 10.3@ */
- int num_options; /* Number of options */
- ppd_option_t *options; /* Options */
- int num_subgroups; /* Number of sub-groups */
- struct ppd_group_s *subgroups; /* Sub-groups (max depth = 1) */
+ // Human-readable group name
+ char name[PPD_MAX_NAME]; // Group name @since CUPS 1.1.18/macOS 10.3@
+ int num_options; // Number of options
+ ppd_option_t *options; // Options
+ int num_subgroups; // Number of sub-groups
+ struct ppd_group_s *subgroups; // Sub-groups (max depth = 1)
} ppd_group_t;
-typedef struct ppd_const_s /**** Constraints @deprecated@ ****/
+typedef struct ppd_const_s // Constraints @deprecated@
{
- char option1[PPD_MAX_NAME]; /* First keyword */
- char choice1[PPD_MAX_NAME]; /* First option/choice (blank for all) */
- char option2[PPD_MAX_NAME]; /* Second keyword */
- char choice2[PPD_MAX_NAME]; /* Second option/choice (blank for all) */
+ char option1[PPD_MAX_NAME]; // First keyword
+ char choice1[PPD_MAX_NAME]; // First option/choice (blank for all)
+ char option2[PPD_MAX_NAME]; // Second keyword
+ char choice2[PPD_MAX_NAME]; // Second option/choice (blank for all)
} ppd_const_t;
-typedef struct ppd_size_s /**** Page Sizes @deprecated@ ****/
+typedef struct ppd_size_s // Page Sizes @deprecated@
{
- int marked; /* Page size selected? */
- char name[PPD_MAX_NAME]; /* Media size option */
- float width; /* Width of media in points */
- float length; /* Length of media in points */
- float left; /* Left printable margin in points */
- float bottom; /* Bottom printable margin in points */
- float right; /* Right printable margin in points */
- float top; /* Top printable margin in points */
+ int marked; // Page size selected?
+ char name[PPD_MAX_NAME]; // Media size option
+ float width; // Width of media in points
+ float length; // Length of media in points
+ float left; // Left printable margin in points
+ float bottom; // Bottom printable margin in points
+ float right; // Right printable margin in points
+ float top; // Top printable margin in points
} ppd_size_t;
-typedef struct ppd_emul_s /**** Emulators @deprecated@ ****/
+typedef struct ppd_emul_s // Emulators @deprecated@
{
- char name[PPD_MAX_NAME]; /* Emulator name */
- char *start; /* Code to switch to this emulation */
- char *stop; /* Code to stop this emulation */
+ char name[PPD_MAX_NAME]; // Emulator name
+ char *start; // Code to switch to this emulation
+ char *stop; // Code to stop this emulation
} ppd_emul_t;
-typedef struct ppd_profile_s /**** sRGB Color Profiles @deprecated@ ****/
+typedef struct ppd_profile_s // sRGB Color Profiles @deprecated@
{
char resolution[PPD_MAX_NAME];
- /* Resolution or "-" */
+ // Resolution or "-"
char media_type[PPD_MAX_NAME];
- /* Media type or "-" */
- float density; /* Ink density to use */
- float gamma; /* Gamma correction to use */
- float matrix[3][3]; /* Transform matrix */
+ // Media type or "-"
+ float density; // Ink density to use
+ float gamma; // Gamma correction to use
+ float matrix[3][3]; // Transform matrix
} ppd_profile_t;
-/**** New in CUPS 1.2/macOS 10.5 ****/
-typedef enum ppd_cptype_e /**** Custom Parameter Type @deprecated@ ****/
+// New in CUPS 1.2/macOS 10.5
+typedef enum ppd_cptype_e // Custom Parameter Type @deprecated@
{
- PPD_CUSTOM_UNKNOWN = -1, /* Unknown type (error) */
- PPD_CUSTOM_CURVE, /* Curve value for f(x) = x^value */
- PPD_CUSTOM_INT, /* Integer number value */
- PPD_CUSTOM_INVCURVE, /* Curve value for f(x) = x^(1/value) */
- PPD_CUSTOM_PASSCODE, /* String of (hidden) numbers */
- PPD_CUSTOM_PASSWORD, /* String of (hidden) characters */
- PPD_CUSTOM_POINTS, /* Measurement value in points */
- PPD_CUSTOM_REAL, /* Real number value */
- PPD_CUSTOM_STRING /* String of characters */
+ PPD_CUSTOM_UNKNOWN = -1, // Unknown type (error)
+ PPD_CUSTOM_CURVE, // Curve value for f(x) = x^value
+ PPD_CUSTOM_INT, // Integer number value
+ PPD_CUSTOM_INVCURVE, // Curve value for f(x) = x^(1/value)
+ PPD_CUSTOM_PASSCODE, // String of (hidden) numbers
+ PPD_CUSTOM_PASSWORD, // String of (hidden) characters
+ PPD_CUSTOM_POINTS, // Measurement value in points
+ PPD_CUSTOM_REAL, // Real number value
+ PPD_CUSTOM_STRING // String of characters
} ppd_cptype_t;
-typedef union ppd_cplimit_u /**** Custom Parameter Limit @deprecated@ ****/
+typedef union ppd_cplimit_u // Custom Parameter Limit @deprecated@
{
- float custom_curve; /* Gamma value */
- int custom_int; /* Integer value */
- float custom_invcurve; /* Gamma value */
- int custom_passcode; /* Passcode length */
- int custom_password; /* Password length */
- float custom_points; /* Measurement value */
- float custom_real; /* Real value */
- int custom_string; /* String length */
+ float custom_curve; // Gamma value
+ int custom_int; // Integer value
+ float custom_invcurve; // Gamma value
+ int custom_passcode; // Passcode length
+ int custom_password; // Password length
+ float custom_points; // Measurement value
+ float custom_real; // Real value
+ int custom_string; // String length
} ppd_cplimit_t;
-typedef union ppd_cpvalue_u /**** Custom Parameter Value @deprecated@ ****/
+typedef union ppd_cpvalue_u // Custom Parameter Value @deprecated@
{
- float custom_curve; /* Gamma value */
- int custom_int; /* Integer value */
- float custom_invcurve; /* Gamma value */
- char *custom_passcode; /* Passcode value */
- char *custom_password; /* Password value */
- float custom_points; /* Measurement value */
- float custom_real; /* Real value */
- char *custom_string; /* String value */
+ float custom_curve; // Gamma value
+ int custom_int; // Integer value
+ float custom_invcurve; // Gamma value
+ char *custom_passcode; // Passcode value
+ char *custom_password; // Password value
+ float custom_points; // Measurement value
+ float custom_real; // Real value
+ char *custom_string; // String value
} ppd_cpvalue_t;
-typedef struct ppd_cparam_s /**** Custom Parameter @deprecated@ ****/
+typedef struct ppd_cparam_s // Custom Parameter @deprecated@
{
- char name[PPD_MAX_NAME]; /* Parameter name */
- char text[PPD_MAX_TEXT]; /* Human-readable text */
- int order; /* Order (0 to N) */
- ppd_cptype_t type; /* Parameter type */
- ppd_cplimit_t minimum, /* Minimum value */
- maximum; /* Maximum value */
- ppd_cpvalue_t current; /* Current value */
+ char name[PPD_MAX_NAME]; // Parameter name
+ char text[PPD_MAX_TEXT]; // Human-readable text
+ int order; // Order (0 to N)
+ ppd_cptype_t type; // Parameter type
+ ppd_cplimit_t minimum, // Minimum value
+ maximum; // Maximum value
+ ppd_cpvalue_t current; // Current value
} ppd_cparam_t;
-typedef struct ppd_coption_s /**** Custom Option @deprecated@ ****/
+typedef struct ppd_coption_s // Custom Option @deprecated@
{
- char keyword[PPD_MAX_NAME]; /* Name of option that is being extended... */
- ppd_option_t *option; /* Option that is being extended... */
- int marked; /* Extended option is marked */
- cups_array_t *params; /* Parameters */
+ char keyword[PPD_MAX_NAME]; // Name of option that is being extended...
+ ppd_option_t *option; // Option that is being extended...
+ int marked; // Extended option is marked
+ cups_array_t *params; // Parameters
} ppd_coption_t;
typedef struct _ppd_cache_s _ppd_cache_t;
- /**** PPD cache and mapping data @deprecated@ ****/
+ // PPD cache and mapping data @deprecated@
-typedef struct ppd_file_s /**** PPD File @deprecated@ ****/
+typedef struct ppd_file_s // PPD File @deprecated@
{
- int language_level; /* Language level of device */
- int color_device; /* 1 = color device, 0 = grayscale */
- int variable_sizes; /* 1 = supports variable sizes, 0 = doesn't */
- int accurate_screens; /* 1 = supports accurate screens, 0 = not */
- int contone_only; /* 1 = continuous tone only, 0 = not */
- int landscape; /* -90 or 90 */
- int model_number; /* Device-specific model number */
- int manual_copies; /* 1 = Copies done manually, 0 = hardware */
- int throughput; /* Pages per minute */
- ppd_cs_t colorspace; /* Default colorspace */
- char *patches; /* Patch commands to be sent to printer */
- int num_emulations; /* Number of emulations supported (no longer supported) @private@ */
- ppd_emul_t *emulations; /* Emulations and the code to invoke them (no longer supported) @private@ */
- char *jcl_begin; /* Start JCL commands */
- char *jcl_ps; /* Enter PostScript interpreter */
- char *jcl_end; /* End JCL commands */
- char *lang_encoding; /* Language encoding */
- char *lang_version; /* Language version (English, Spanish, etc.) */
- char *modelname; /* Model name (general) */
- char *ttrasterizer; /* Truetype rasterizer */
- char *manufacturer; /* Manufacturer name */
- char *product; /* Product name (from PS RIP/interpreter) */
- char *nickname; /* Nickname (specific) */
- char *shortnickname; /* Short version of nickname */
- int num_groups; /* Number of UI groups */
- ppd_group_t *groups; /* UI groups */
- int num_sizes; /* Number of page sizes */
- ppd_size_t *sizes; /* Page sizes */
- float custom_min[2]; /* Minimum variable page size */
- float custom_max[2]; /* Maximum variable page size */
- float custom_margins[4]; /* Margins around page */
- int num_consts; /* Number of UI/Non-UI constraints */
- ppd_const_t *consts; /* UI/Non-UI constraints */
- int num_fonts; /* Number of pre-loaded fonts */
- char **fonts; /* Pre-loaded fonts */
- int num_profiles; /* Number of sRGB color profiles @deprecated@ */
- ppd_profile_t *profiles; /* sRGB color profiles @deprecated@ */
- int num_filters; /* Number of filters */
- char **filters; /* Filter strings... */
-
- /**** New in CUPS 1.1 ****/
- int flip_duplex; /* 1 = Flip page for back sides @deprecated@ */
-
- /**** New in CUPS 1.1.19 ****/
- char *protocols; /* Protocols (BCP, TBCP) string @since CUPS 1.1.19/macOS 10.3@ */
- char *pcfilename; /* PCFileName string @since CUPS 1.1.19/macOS 10.3@ */
- int num_attrs; /* Number of attributes @since CUPS 1.1.19/macOS 10.3@ @private@ */
- int cur_attr; /* Current attribute @since CUPS 1.1.19/macOS 10.3@ @private@ */
- ppd_attr_t **attrs; /* Attributes @since CUPS 1.1.19/macOS 10.3@ @private@ */
-
- /**** New in CUPS 1.2/macOS 10.5 ****/
- cups_array_t *sorted_attrs; /* Attribute lookup array @since CUPS 1.2/macOS 10.5@ @private@ */
- cups_array_t *options; /* Option lookup array @since CUPS 1.2/macOS 10.5@ @private@ */
- cups_array_t *coptions; /* Custom options array @since CUPS 1.2/macOS 10.5@ @private@ */
-
- /**** New in CUPS 1.3/macOS 10.5 ****/
- cups_array_t *marked; /* Marked choices @since CUPS 1.3/macOS 10.5@ @private@ */
-
- /**** New in CUPS 1.4/macOS 10.6 ****/
- cups_array_t *cups_uiconstraints; /* cupsUIConstraints @since CUPS 1.4/macOS 10.6@ @private@ */
-
- /**** New in CUPS 1.5 ****/
- _ppd_cache_t *cache; /* PPD cache and mapping data @since CUPS 1.5/macOS 10.7@ @private@ */
+ int language_level; // Language level of device
+ int color_device; // 1 = color device, 0 = grayscale
+ int variable_sizes; // 1 = supports variable sizes, 0 = doesn't
+ int accurate_screens; // 1 = supports accurate screens, 0 = not
+ int contone_only; // 1 = continuous tone only, 0 = not
+ int landscape; // -90 or 90
+ int model_number; // Device-specific model number
+ int manual_copies; // 1 = Copies done manually, 0 = hardware
+ int throughput; // Pages per minute
+ ppd_cs_t colorspace; // Default colorspace
+ char *patches; // Patch commands to be sent to printer
+ int num_emulations; // Number of emulations supported (no longer supported) @private@
+ ppd_emul_t *emulations; // Emulations and the code to invoke them (no longer supported) @private@
+ char *jcl_begin; // Start JCL commands
+ char *jcl_ps; // Enter PostScript interpreter
+ char *jcl_end; // End JCL commands
+ char *lang_encoding; // Language encoding
+ char *lang_version; // Language version (English, Spanish, etc.)
+ char *modelname; // Model name (general)
+ char *ttrasterizer; // Truetype rasterizer
+ char *manufacturer; // Manufacturer name
+ char *product; // Product name (from PS RIP/interpreter)
+ char *nickname; // Nickname (specific)
+ char *shortnickname; // Short version of nickname
+ int num_groups; // Number of UI groups
+ ppd_group_t *groups; // UI groups
+ int num_sizes; // Number of page sizes
+ ppd_size_t *sizes; // Page sizes
+ float custom_min[2]; // Minimum variable page size
+ float custom_max[2]; // Maximum variable page size
+ float custom_margins[4]; // Margins around page
+ int num_consts; // Number of UI/Non-UI constraints
+ ppd_const_t *consts; // UI/Non-UI constraints
+ int num_fonts; // Number of pre-loaded fonts
+ char **fonts; // Pre-loaded fonts
+ int num_profiles; // Number of sRGB color profiles @deprecated@
+ ppd_profile_t *profiles; // sRGB color profiles @deprecated@
+ int num_filters; // Number of filters
+ char **filters; // Filter strings...
+
+ // New in CUPS 1.1
+ int flip_duplex; // 1 = Flip page for back sides @deprecated@
+
+ // New in CUPS 1.1.19
+ char *protocols; // Protocols (BCP, TBCP) string @since CUPS 1.1.19/macOS 10.3@
+ char *pcfilename; // PCFileName string @since CUPS 1.1.19/macOS 10.3@
+ int num_attrs; // Number of attributes @since CUPS 1.1.19/macOS 10.3@ @private@
+ int cur_attr; // Current attribute @since CUPS 1.1.19/macOS 10.3@ @private@
+ ppd_attr_t **attrs; // Attributes @since CUPS 1.1.19/macOS 10.3@ @private@
+
+ // New in CUPS 1.2/macOS 10.5
+ cups_array_t *sorted_attrs; // Attribute lookup array @since CUPS 1.2/macOS 10.5@ @private@
+ cups_array_t *options; // Option lookup array @since CUPS 1.2/macOS 10.5@ @private@
+ cups_array_t *coptions; // Custom options array @since CUPS 1.2/macOS 10.5@ @private@
+
+ // New in CUPS 1.3/macOS 10.5
+ cups_array_t *marked; // Marked choices @since CUPS 1.3/macOS 10.5@ @private@
+
+ // New in CUPS 1.4/macOS 10.6
+ cups_array_t *cups_uiconstraints; // cupsUIConstraints @since CUPS 1.4/macOS 10.6@ @private@
+
+ // New in CUPS 1.5
+ _ppd_cache_t *cache; // PPD cache and mapping data @since CUPS 1.5/macOS 10.7@ @private@
} ppd_file_t;
-/*
- * Prototypes...
- */
-
-extern const char *cupsGetPPD(const char *name) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern const char *cupsGetPPD2(http_t *http, const char *name) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern http_status_t cupsGetPPD3(http_t *http, const char *name, time_t *modtime, char *buffer, size_t bufsize) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern char *cupsGetServerPPD(http_t *http, const char *name) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int cupsMarkOptions(ppd_file_t *ppd, int num_options, cups_option_t *options) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-extern void ppdClose(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdCollect(ppd_file_t *ppd, ppd_section_t section,
- ppd_choice_t ***choices) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdConflicts(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdEmit(ppd_file_t *ppd, FILE *fp,
- ppd_section_t section) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdEmitFd(ppd_file_t *ppd, int fd,
- ppd_section_t section) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdEmitJCL(ppd_file_t *ppd, FILE *fp, int job_id,
- const char *user, const char *title)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_choice_t *ppdFindChoice(ppd_option_t *o, const char *option)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd,
- const char *keyword)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_option_t *ppdFindOption(ppd_file_t *ppd, const char *keyword)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdIsMarked(ppd_file_t *ppd, const char *keyword,
- const char *option) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern void ppdMarkDefaults(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdMarkOption(ppd_file_t *ppd, const char *keyword,
- const char *option) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_file_t *ppdOpen(FILE *fp) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_file_t *ppdOpenFd(int fd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_file_t *ppdOpenFile(const char *filename) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern float ppdPageLength(ppd_file_t *ppd, const char *name)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern float ppdPageWidth(ppd_file_t *ppd, const char *name)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-/**** New in CUPS 1.1.19 ****/
-extern const char *ppdErrorString(ppd_status_t status) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
- const char *spec) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
- const char *spec) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_status_t ppdLastError(int *line) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-/**** New in CUPS 1.1.20 ****/
-extern void ppdSetConformance(ppd_conform_t c) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-/**** New in CUPS 1.2 ****/
-extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
- ppd_file_t *ppd,
- int num_options,
- cups_option_t *options,
- cups_interpret_cb_t func) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdCollect2(ppd_file_t *ppd, ppd_section_t section,
- float min_order, ppd_choice_t ***choices)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdEmitAfterOrder(ppd_file_t *ppd, FILE *fp,
- ppd_section_t section, int limit,
- float min_order) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern char *ppdEmitString(ppd_file_t *ppd, ppd_section_t section,
- float min_order) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_coption_t *ppdFindCustomOption(ppd_file_t *ppd,
- const char *keyword)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_cparam_t *ppdFindCustomParam(ppd_coption_t *opt,
- const char *name) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_cparam_t *ppdFirstCustomParam(ppd_coption_t *opt)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_option_t *ppdFirstOption(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_cparam_t *ppdNextCustomParam(ppd_coption_t *opt) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_option_t *ppdNextOption(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdLocalize(ppd_file_t *ppd) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_file_t *ppdOpen2(cups_file_t *fp) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-/**** New in CUPS 1.3/macOS 10.5 ****/
-extern const char *ppdLocalizeIPPReason(ppd_file_t *ppd,
- const char *reason,
- const char *scheme,
- char *buffer,
- size_t bufsize) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-/**** New in CUPS 1.4/macOS 10.6 ****/
-extern int cupsGetConflicts(ppd_file_t *ppd, const char *option,
- const char *choice,
- cups_option_t **options)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int cupsResolveConflicts(ppd_file_t *ppd,
- const char *option,
- const char *choice,
- int *num_options,
- cups_option_t **options)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdInstallableConflict(ppd_file_t *ppd,
- const char *option,
- const char *choice)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern ppd_attr_t *ppdLocalizeAttr(ppd_file_t *ppd, const char *keyword,
- const char *spec) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern const char *ppdLocalizeMarkerName(ppd_file_t *ppd,
- const char *name)
- _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-extern int ppdPageSizeLimits(ppd_file_t *ppd,
- ppd_size_t *minimum,
- ppd_size_t *maximum) _CUPS_DEPRECATED_1_6_MSG("Use cupsCopyDestInfo and friends instead.");
-
-
-/*
- * C++ magic...
- */
+//
+// Functions...
+//
+
+extern int cupsGetConflicts(ppd_file_t *ppd, const char *option, const char *choice, cups_option_t **options) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern const char *cupsGetPPD(const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern const char *cupsGetPPD2(http_t *http, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern http_status_t cupsGetPPD3(http_t *http, const char *name, time_t *modtime, char *buffer, size_t bufsize) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern char *cupsGetServerPPD(http_t *http, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int cupsMarkOptions(ppd_file_t *ppd, int num_options, cups_option_t *options) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int cupsRasterInterpretPPD(cups_page_header2_t *h, ppd_file_t *ppd, int num_options, cups_option_t *options, cups_interpret_cb_t func) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int cupsResolveConflicts(ppd_file_t *ppd, const char *option, const char *choice, int *num_options, cups_option_t **options) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+
+extern void ppdClose(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdCollect(ppd_file_t *ppd, ppd_section_t section, ppd_choice_t ***choices) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdCollect2(ppd_file_t *ppd, ppd_section_t section, float min_order, ppd_choice_t ***choices) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdConflicts(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdEmit(ppd_file_t *ppd, FILE *fp, ppd_section_t section) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdEmitAfterOrder(ppd_file_t *ppd, FILE *fp, ppd_section_t section, int limit, float min_order) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdEmitFd(ppd_file_t *ppd, int fd, ppd_section_t section) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdEmitJCL(ppd_file_t *ppd, FILE *fp, int job_id, const char *user, const char *title) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern char *ppdEmitString(ppd_file_t *ppd, ppd_section_t section, float min_order) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern const char *ppdErrorString(ppd_status_t status) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name, const char *spec) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_choice_t *ppdFindChoice(ppd_option_t *o, const char *option) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_coption_t *ppdFindCustomOption(ppd_file_t *ppd, const char *keyword) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_cparam_t *ppdFindCustomParam(ppd_coption_t *opt, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name, const char *spec) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_option_t *ppdFindOption(ppd_file_t *ppd, const char *keyword) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_cparam_t *ppdFirstCustomParam(ppd_coption_t *opt) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_option_t *ppdFirstOption(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdInstallableConflict(ppd_file_t *ppd, const char *option, const char *choice) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdIsMarked(ppd_file_t *ppd, const char *keyword, const char *option) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_status_t ppdLastError(int *line) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdLocalize(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_attr_t *ppdLocalizeAttr(ppd_file_t *ppd, const char *keyword, const char *spec) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern const char *ppdLocalizeIPPReason(ppd_file_t *ppd, const char *reason, const char *scheme, char *buffer, size_t bufsize) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern const char *ppdLocalizeMarkerName(ppd_file_t *ppd, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern void ppdMarkDefaults(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdMarkOption(ppd_file_t *ppd, const char *keyword, const char *option) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_cparam_t *ppdNextCustomParam(ppd_coption_t *opt) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_option_t *ppdNextOption(ppd_file_t *ppd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_file_t *ppdOpen(FILE *fp) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_file_t *ppdOpen2(cups_file_t *fp) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_file_t *ppdOpenFd(int fd) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_file_t *ppdOpenFile(const char *filename) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern float ppdPageLength(ppd_file_t *ppd, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern int ppdPageSizeLimits(ppd_file_t *ppd, ppd_size_t *minimum, ppd_size_t *maximum) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern float ppdPageWidth(ppd_file_t *ppd, const char *name) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+extern void ppdSetConformance(ppd_conform_t c) _CUPS_DEPRECATED_MSG("Use cupsCopyDestInfo and friends instead.");
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_PPD_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_PPD_H_
-/*
- * Private PWG media API definitions for CUPS.
- *
- * Copyright 2009-2016 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Private PWG media API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2009-2016 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_PWG_PRIVATE_H_
# define _CUPS_PWG_PRIVATE_H_
-
-
-/*
- * Include necessary headers...
- */
-
# include <cups/cups.h>
-
-
-/*
- * C++ magic...
- */
-
+# include <cups/pwg.h>
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Functions...
- */
+//
+// Functions...
+//
-extern void _pwgGenerateSize(char *keyword, size_t keysize,
- const char *prefix,
- const char *name,
- int width, int length)
- _CUPS_INTERNAL_MSG("Use pwgFormatSizeName instead.");
-extern int _pwgInitSize(pwg_size_t *size, ipp_t *job,
- int *margins_set)
- _CUPS_INTERNAL_MSG("Use pwgInitSize instead.");
+extern void _pwgGenerateSize(char *keyword, size_t keysize, const char *prefix, const char *name, int width, int length) _CUPS_INTERNAL_MSG("Use pwgFormatSizeName instead.");
+extern int _pwgInitSize(pwg_size_t *size, ipp_t *job, int *margins_set) _CUPS_INTERNAL_MSG("Use pwgInitSize instead.");
extern const pwg_media_t *_pwgMediaTable(size_t *num_media) _CUPS_PRIVATE;
-extern pwg_media_t *_pwgMediaNearSize(int width, int length, int epsilon) _CUPS_PRIVATE;
+extern pwg_media_t *_pwgMediaNearSize(int width, int length, int epsilon) _CUPS_PRIVATE;
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_PWG_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_PWG_PRIVATE_H_
-/*
- * PWG media API definitions for CUPS.
- *
- * Copyright 2009-2017 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// PWG media API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2009-2017 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_PWG_H_
# define _CUPS_PWG_H_
-
-
-/*
- * C++ magic...
- */
-
+# include "base.h"
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Macros...
- */
+//
+// Macros...
+//
-/* Convert from points to hundredths of millimeters */
+// Convert from points to hundredths of millimeters
# define PWG_FROM_POINTS(n) (int)(((n) * 2540 + 36) / 72)
-/* Convert from hundredths of millimeters to points */
+// Convert from hundredths of millimeters to points
# define PWG_TO_POINTS(n) ((n) * 72.0 / 2540.0)
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
-typedef struct pwg_map_s /**** Map element - PPD to/from PWG @exclude all@ */
+typedef struct pwg_map_s // Map element - PPD to/from PWG @exclude all@
{
- char *pwg, /* PWG media keyword */
- *ppd; /* PPD option keyword */
+ char *pwg, // PWG media keyword
+ *ppd; // PPD option keyword
} pwg_map_t;
-typedef struct pwg_media_s /**** Common media size data ****/
+typedef struct pwg_media_s // Common media size data
{
- const char *pwg, /* PWG 5101.1 "self describing" name */
- *legacy, /* IPP/ISO legacy name */
- *ppd; /* Standard Adobe PPD name */
- int width, /* Width in 2540ths */
- length; /* Length in 2540ths */
+ const char *pwg, // PWG 5101.1 "self describing" name
+ *legacy, // IPP/ISO legacy name
+ *ppd; // Standard Adobe PPD name
+ int width, // Width in 2540ths
+ length; // Length in 2540ths
} pwg_media_t;
-typedef struct pwg_size_s /**** Size element - PPD to/from PWG @exclude all@ */
+typedef struct pwg_size_s // Size element - PPD to/from PWG @exclude all@
{
- pwg_map_t map; /* Map element */
- int width, /* Width in 2540ths */
- length, /* Length in 2540ths */
- left, /* Left margin in 2540ths */
- bottom, /* Bottom margin in 2540ths */
- right, /* Right margin in 2540ths */
- top; /* Top margin in 2540ths */
+ pwg_map_t map; // Map element
+ int width, // Width in 2540ths
+ length, // Length in 2540ths
+ left, // Left margin in 2540ths
+ bottom, // Bottom margin in 2540ths
+ right, // Right margin in 2540ths
+ top; // Top margin in 2540ths
} pwg_size_t;
-/*
- * Functions...
- */
+//
+// Functions...
+//
+
+extern int pwgFormatSizeName(char *keyword, size_t keysize, const char *prefix, const char *name, int width, int length, const char *units) _CUPS_PUBLIC;
+extern int pwgInitSize(pwg_size_t *size, ipp_t *job, int *margins_set) _CUPS_PUBLIC;
+extern pwg_media_t *pwgMediaForLegacy(const char *legacy) _CUPS_PUBLIC;
+extern pwg_media_t *pwgMediaForPPD(const char *ppd) _CUPS_PUBLIC;
+extern pwg_media_t *pwgMediaForPWG(const char *pwg) _CUPS_PUBLIC;
+extern pwg_media_t *pwgMediaForSize(int width, int length) _CUPS_PUBLIC;
-extern int pwgFormatSizeName(char *keyword, size_t keysize,
- const char *prefix, const char *name,
- int width, int length,
- const char *units) _CUPS_API_1_7;
-extern int pwgInitSize(pwg_size_t *size, ipp_t *job,
- int *margins_set) _CUPS_API_1_7;
-extern pwg_media_t *pwgMediaForLegacy(const char *legacy) _CUPS_API_1_7;
-extern pwg_media_t *pwgMediaForPPD(const char *ppd) _CUPS_API_1_7;
-extern pwg_media_t *pwgMediaForPWG(const char *pwg) _CUPS_API_1_7;
-extern pwg_media_t *pwgMediaForSize(int width, int length) _CUPS_API_1_7;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_PWG_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_PWG_H_
-/*
- * Private image library definitions for CUPS.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1993-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private image library definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1993-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_RASTER_PRIVATE_H_
# define _CUPS_RASTER_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
# include "raster.h"
# include <cups/cups.h>
# include <cups/debug-private.h>
# include <cups/string-private.h>
# ifdef _WIN32
# include <io.h>
-# include <winsock2.h> /* for htonl() definition */
+# include <winsock2.h> // for htonl() definition
# else
# include <unistd.h>
# include <fcntl.h>
-# endif /* _WIN32 */
-
+# endif // _WIN32
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Structure...
- */
+//
+// Structure...
+//
-struct _cups_raster_s /**** Raster stream data ****/
+struct _cups_raster_s // Raster stream data
{
- unsigned sync; /* Sync word from start of stream */
- void *ctx; /* File descriptor */
- cups_raster_iocb_t iocb; /* IO callback */
- cups_mode_t mode; /* Read/write mode */
- cups_page_header2_t header; /* Raster header for current page */
- unsigned rowheight, /* Row height in lines */
- count, /* Current row run-length count */
- remaining, /* Remaining rows in page image */
- bpp; /* Bytes per pixel/color */
- unsigned char *pixels, /* Pixels for current row */
- *pend, /* End of pixel buffer */
- *pcurrent; /* Current byte in pixel buffer */
- int compressed, /* Non-zero if data is compressed */
- swapped; /* Non-zero if data is byte-swapped */
- unsigned char *buffer, /* Read/write buffer */
- *bufptr, /* Current (read) position in buffer */
- *bufend; /* End of current (read) buffer */
- size_t bufsize; /* Buffer size */
+ unsigned sync; // Sync word from start of stream
+ void *ctx; // File descriptor
+ cups_raster_iocb_t iocb; // IO callback
+ cups_mode_t mode; // Read/write mode
+ cups_page_header2_t header; // Raster header for current page
+ unsigned rowheight, // Row height in lines
+ count, // Current row run-length count
+ remaining, // Remaining rows in page image
+ bpp; // Bytes per pixel/color
+ unsigned char *pixels, // Pixels for current row
+ *pend, // End of pixel buffer
+ *pcurrent; // Current byte in pixel buffer
+ int compressed, // Non-zero if data is compressed
+ swapped; // Non-zero if data is byte-swapped
+ unsigned char *buffer, // Read/write buffer
+ *bufptr, // Current (read) position in buffer
+ *bufend; // End of current (read) buffer
+ size_t bufsize; // Buffer size
# ifdef DEBUG
- size_t iostart, /* Start of read/write buffer */
- iocount; /* Number of bytes read/written */
-# endif /* DEBUG */
- unsigned apple_page_count;/* Apple raster page count */
+ size_t iostart, // Start of read/write buffer
+ iocount; // Number of bytes read/written
+# endif // DEBUG
+ unsigned apple_page_count;// Apple raster page count
};
-#if 0
-/*
- * min/max macros...
- */
-
-# ifndef max
-# define max(a,b) ((a) > (b) ? (a) : (b))
-# endif /* !max */
-# ifndef min
-# define min(a,b) ((a) < (b) ? (a) : (b))
-# endif /* !min */
-#endif // 0
-
-
-/*
- * Prototypes...
- */
+//
+// Functions...
+//
extern void _cupsRasterAddError(const char *f, ...) _CUPS_FORMAT(1,2) _CUPS_PRIVATE;
extern void _cupsRasterClearError(void) _CUPS_PRIVATE;
extern const char *_cupsRasterColorSpaceString(cups_cspace_t cspace) _CUPS_PRIVATE;
extern void _cupsRasterDelete(cups_raster_t *r) _CUPS_PRIVATE;
-extern const char *_cupsRasterErrorString(void) _CUPS_PRIVATE;
extern int _cupsRasterInitPWGHeader(cups_page_header2_t *h, pwg_media_t *media, const char *type, int xdpi, int ydpi, const char *sides, const char *sheet_back) _CUPS_PRIVATE;
-extern cups_raster_t *_cupsRasterNew(cups_raster_iocb_t iocb, void *ctx, cups_mode_t mode) _CUPS_PRIVATE;
+extern cups_raster_t *_cupsRasterNew(cups_raster_cb_t iocb, void *ctx, cups_raster_mode_t mode) _CUPS_PRIVATE;
extern unsigned _cupsRasterReadHeader(cups_raster_t *r) _CUPS_PRIVATE;
extern unsigned _cupsRasterReadPixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PRIVATE;
extern unsigned _cupsRasterWriteHeader(cups_raster_t *r) _CUPS_PRIVATE;
extern unsigned _cupsRasterWritePixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PRIVATE;
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_RASTER_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_RASTER_PRIVATE_H_
static bool // O - `true` on success, `false` on failure
cupsRasterWriteTest(
- cups_raster_t *ras, // I - Raster stream
- cups_page_header2_t *header, // I - Raster page header (front side)
+ cups_raster_t *ras, // I - Raster stream
+ cups_page_header2_t *header, // I - Raster page header (front side)
cups_page_header2_t *back_header, // I - Raster page header (back side)
- const char *sheet_back, // I - Back side transform needed
- ipp_orient_t orientation, // I - Output orientation
- int num_copies, // I - Number of copies
- int num_pages) // I - Number of pages
+ const char *sheet_back, // I - Back side transform needed
+ ipp_orient_t orientation, // I - Output orientation
+ int num_copies, // I - Number of copies
+ int num_pages) // I - Number of pages
{
int copy, // Current copy number
page; // Current page number
-/*
- * Side-channel API definitions for CUPS.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Side-channel API definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_SIDECHANNEL_H_
# define _CUPS_SIDECHANNEL_H_
-
-/*
- * Include necessary headers...
- */
-
-# include "versioning.h"
+# include "base.h"
# include <sys/types.h>
# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
# define __CUPS_SSIZE_T_DEFINED
# include <stddef.h>
-/* Windows does not support the ssize_t type, so map it to __int64... */
-typedef __int64 ssize_t; /* @private@ */
-# endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
-
-
-/*
- * C++ magic...
- */
-
+// Windows does not support the ssize_t type, so map it to __int64...
+typedef __int64 ssize_t; // @private@
+# endif // _WIN32 && !__CUPS_SSIZE_T_DEFINED
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
+//
+// Constants...
+//
-#define CUPS_SC_FD 4 /* File descriptor for select/poll */
+#define CUPS_SC_FD 4 // File descriptor for select/poll
-/*
- * Enumerations...
- */
+//
+// Enumerations...
+//
-enum cups_sc_bidi_e /**** Bidirectional capability values ****/
+enum cups_sc_bidi_e // Bidirectional capability values
{
- CUPS_SC_BIDI_NOT_SUPPORTED = 0, /* Bidirectional I/O is not supported */
- CUPS_SC_BIDI_SUPPORTED = 1 /* Bidirectional I/O is supported */
+ CUPS_SC_BIDI_NOT_SUPPORTED = 0, // Bidirectional I/O is not supported
+ CUPS_SC_BIDI_SUPPORTED = 1 // Bidirectional I/O is supported
};
typedef enum cups_sc_bidi_e cups_sc_bidi_t;
- /**** Bidirectional capabilities ****/
+ // Bidirectional capabilities
-enum cups_sc_command_e /**** Request command codes ****/
+enum cups_sc_command_e // Request command codes
{
- CUPS_SC_CMD_NONE = 0, /* No command @private@ */
- CUPS_SC_CMD_SOFT_RESET = 1, /* Do a soft reset */
- CUPS_SC_CMD_DRAIN_OUTPUT = 2, /* Drain all pending output */
- CUPS_SC_CMD_GET_BIDI = 3, /* Return bidirectional capabilities */
- CUPS_SC_CMD_GET_DEVICE_ID = 4, /* Return the IEEE-1284 device ID */
- CUPS_SC_CMD_GET_STATE = 5, /* Return the device state */
- CUPS_SC_CMD_SNMP_GET = 6, /* Query an SNMP OID @since CUPS 1.4/macOS 10.6@ */
- CUPS_SC_CMD_SNMP_GET_NEXT = 7, /* Query the next SNMP OID @since CUPS 1.4/macOS 10.6@ */
- CUPS_SC_CMD_GET_CONNECTED = 8, /* Return whether the backend is "connected" to the printer @since CUPS 1.5/macOS 10.7@ */
- CUPS_SC_CMD_MAX /* End of valid values @private@ */
+ CUPS_SC_CMD_NONE = 0, // No command @private@
+ CUPS_SC_CMD_SOFT_RESET = 1, // Do a soft reset
+ CUPS_SC_CMD_DRAIN_OUTPUT = 2, // Drain all pending output
+ CUPS_SC_CMD_GET_BIDI = 3, // Return bidirectional capabilities
+ CUPS_SC_CMD_GET_DEVICE_ID = 4, // Return the IEEE-1284 device ID
+ CUPS_SC_CMD_GET_STATE = 5, // Return the device state
+ CUPS_SC_CMD_SNMP_GET = 6, // Query an SNMP OID @since CUPS 1.4/macOS 10.6@
+ CUPS_SC_CMD_SNMP_GET_NEXT = 7, // Query the next SNMP OID @since CUPS 1.4/macOS 10.6@
+ CUPS_SC_CMD_GET_CONNECTED = 8, // Return whether the backend is "connected" to the printer @since CUPS 1.5/macOS 10.7@
+ CUPS_SC_CMD_MAX // End of valid values @private@
};
typedef enum cups_sc_command_e cups_sc_command_t;
- /**** Request command codes ****/
+ // Request command codes
-enum cups_sc_connected_e /**** Connectivity values ****/
+enum cups_sc_connected_e // Connectivity values
{
- CUPS_SC_NOT_CONNECTED = 0, /* Backend is not "connected" to printer */
- CUPS_SC_CONNECTED = 1 /* Backend is "connected" to printer */
+ CUPS_SC_NOT_CONNECTED = 0, // Backend is not "connected" to printer
+ CUPS_SC_CONNECTED = 1 // Backend is "connected" to printer
};
typedef enum cups_sc_connected_e cups_sc_connected_t;
- /**** Connectivity values ****/
+ // Connectivity values
-enum cups_sc_state_e /**** Printer state bits ****/
+enum cups_sc_state_e // Printer state bits
{
- CUPS_SC_STATE_OFFLINE = 0, /* Device is offline */
- CUPS_SC_STATE_ONLINE = 1, /* Device is online */
- CUPS_SC_STATE_BUSY = 2, /* Device is busy */
- CUPS_SC_STATE_ERROR = 4, /* Other error condition */
- CUPS_SC_STATE_MEDIA_LOW = 16, /* Paper low condition */
- CUPS_SC_STATE_MEDIA_EMPTY = 32, /* Paper out condition */
- CUPS_SC_STATE_MARKER_LOW = 64, /* Toner/ink low condition */
- CUPS_SC_STATE_MARKER_EMPTY = 128 /* Toner/ink out condition */
+ CUPS_SC_STATE_OFFLINE = 0, // Device is offline
+ CUPS_SC_STATE_ONLINE = 1, // Device is online
+ CUPS_SC_STATE_BUSY = 2, // Device is busy
+ CUPS_SC_STATE_ERROR = 4, // Other error condition
+ CUPS_SC_STATE_MEDIA_LOW = 16, // Paper low condition
+ CUPS_SC_STATE_MEDIA_EMPTY = 32, // Paper out condition
+ CUPS_SC_STATE_MARKER_LOW = 64, // Toner/ink low condition
+ CUPS_SC_STATE_MARKER_EMPTY = 128 // Toner/ink out condition
};
typedef enum cups_sc_state_e cups_sc_state_t;
- /**** Printer state bits ****/
+ // Printer state bits
-enum cups_sc_status_e /**** Response status codes ****/
+enum cups_sc_status_e // Response status codes
{
- 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 */
+ 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
};
typedef enum cups_sc_status_e cups_sc_status_t;
- /**** Response status codes ****/
-
-typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data,
- int datalen, void *context);
- /**** SNMP walk callback ****/
-
-
-/*
- * Prototypes...
- */
-
-/**** New in CUPS 1.2/macOS 10.5 ****/
-extern ssize_t cupsBackChannelRead(char *buffer, size_t bytes,
- double timeout) _CUPS_API_1_2;
-extern ssize_t cupsBackChannelWrite(const char *buffer, size_t bytes,
- double timeout) _CUPS_API_1_2;
-
-/**** New in CUPS 1.3/macOS 10.5 ****/
-extern cups_sc_status_t cupsSideChannelDoRequest(cups_sc_command_t command,
- char *data, int *datalen,
- double timeout) _CUPS_API_1_3;
-extern int cupsSideChannelRead(cups_sc_command_t *command,
- cups_sc_status_t *status,
- char *data, int *datalen,
- double timeout) _CUPS_API_1_3;
-extern int cupsSideChannelWrite(cups_sc_command_t command,
- cups_sc_status_t status,
- const char *data, int datalen,
- double timeout) _CUPS_API_1_3;
-
-/**** New in CUPS 1.4/macOS 10.6 ****/
-extern cups_sc_status_t cupsSideChannelSNMPGet(const char *oid, char *data,
- int *datalen, double timeout)
- _CUPS_API_1_4;
-extern cups_sc_status_t cupsSideChannelSNMPWalk(const char *oid, double timeout,
- cups_sc_walk_func_t cb,
- void *context) _CUPS_API_1_4;
+ // Response status codes
+
+typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, int datalen, void *context);
+ // SNMP walk callback
+
+
+//
+// Functions...
+//
+
+extern ssize_t cupsBackChannelRead(char *buffer, size_t bytes, double timeout) _CUPS_PUBLIC;
+extern ssize_t cupsBackChannelWrite(const char *buffer, size_t bytes, double timeout) _CUPS_PUBLIC;
+
+extern cups_sc_status_t cupsSideChannelDoRequest(cups_sc_command_t command, char *data, int *datalen, double timeout) _CUPS_PUBLIC;
+extern int cupsSideChannelRead(cups_sc_command_t *command, cups_sc_status_t *status, char *data, int *datalen, double timeout) _CUPS_PUBLIC;
+extern cups_sc_status_t cupsSideChannelSNMPGet(const char *oid, char *data, int *datalen, double timeout) _CUPS_PUBLIC;
+extern cups_sc_status_t cupsSideChannelSNMPWalk(const char *oid, double timeout, cups_sc_walk_func_t cb, void *context) _CUPS_PUBLIC;
+extern int cupsSideChannelWrite(cups_sc_command_t command, cups_sc_status_t status, const char *data, int datalen, double timeout) _CUPS_PUBLIC;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_SIDECHANNEL_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_SIDECHANNEL_H_
-/*
- * Private SNMP definitions for CUPS.
- *
- * 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.
- */
+//
+// Private SNMP definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// 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.
+//
#ifndef _CUPS_SNMP_PRIVATE_H_
# define _CUPS_SNMP_PRIVATE_H_
+# include <cups/http.h>
+# ifdef __cplusplus
+extern "C" {
+# endif // __cplusplus
-/*
- * Include necessary headers.
- */
-
-#include <cups/http.h>
-
-
-/*
- * Constants...
- */
+//
+// Constants...
+//
-#define CUPS_SNMP_PORT 161 /* SNMP well-known port */
-#define CUPS_SNMP_MAX_COMMUNITY 512 /* Maximum size of community name */
-#define CUPS_SNMP_MAX_OID 128 /* Maximum number of OID numbers */
-#define CUPS_SNMP_MAX_PACKET 1472 /* Maximum size of SNMP packet */
-#define CUPS_SNMP_MAX_STRING 1024 /* Maximum size of string */
-#define CUPS_SNMP_VERSION_1 0 /* SNMPv1 */
+#define CUPS_SNMP_PORT 161 // SNMP well-known port
+#define CUPS_SNMP_MAX_COMMUNITY 512 // Maximum size of community name
+#define CUPS_SNMP_MAX_OID 128 // Maximum number of OID numbers
+#define CUPS_SNMP_MAX_PACKET 1472 // Maximum size of SNMP packet
+#define CUPS_SNMP_MAX_STRING 1024 // Maximum size of string
+#define CUPS_SNMP_VERSION_1 0 // SNMPv1
-/*
- * Types...
- */
+//
+// Types...
+//
-enum cups_asn1_e /**** ASN1 request/object types ****/
+enum cups_asn1_e // ASN1 request/object types
{
- CUPS_ASN1_END_OF_CONTENTS = 0x00, /* End-of-contents */
- CUPS_ASN1_BOOLEAN = 0x01, /* BOOLEAN */
- CUPS_ASN1_INTEGER = 0x02, /* INTEGER or ENUMERATION */
- CUPS_ASN1_BIT_STRING = 0x03, /* BIT STRING */
- CUPS_ASN1_OCTET_STRING = 0x04, /* OCTET STRING */
- CUPS_ASN1_NULL_VALUE = 0x05, /* NULL VALUE */
- CUPS_ASN1_OID = 0x06, /* OBJECT IDENTIFIER */
- CUPS_ASN1_SEQUENCE = 0x30, /* SEQUENCE */
- CUPS_ASN1_HEX_STRING = 0x40, /* Binary string aka Hex-STRING */
- CUPS_ASN1_COUNTER = 0x41, /* 32-bit unsigned aka Counter32 */
- CUPS_ASN1_GAUGE = 0x42, /* 32-bit unsigned aka Gauge32 */
- CUPS_ASN1_TIMETICKS = 0x43, /* 32-bit unsigned aka Timeticks32 */
- CUPS_ASN1_GET_REQUEST = 0xa0, /* GetRequest-PDU */
- CUPS_ASN1_GET_NEXT_REQUEST = 0xa1, /* GetNextRequest-PDU */
- CUPS_ASN1_GET_RESPONSE = 0xa2 /* GetResponse-PDU */
+ CUPS_ASN1_END_OF_CONTENTS = 0x00, // End-of-contents
+ CUPS_ASN1_BOOLEAN = 0x01, // BOOLEAN
+ CUPS_ASN1_INTEGER = 0x02, // INTEGER or ENUMERATION
+ CUPS_ASN1_BIT_STRING = 0x03, // BIT STRING
+ CUPS_ASN1_OCTET_STRING = 0x04, // OCTET STRING
+ CUPS_ASN1_NULL_VALUE = 0x05, // NULL VALUE
+ CUPS_ASN1_OID = 0x06, // OBJECT IDENTIFIER
+ CUPS_ASN1_SEQUENCE = 0x30, // SEQUENCE
+ CUPS_ASN1_HEX_STRING = 0x40, // Binary string aka Hex-STRING
+ CUPS_ASN1_COUNTER = 0x41, // 32-bit unsigned aka Counter32
+ CUPS_ASN1_GAUGE = 0x42, // 32-bit unsigned aka Gauge32
+ CUPS_ASN1_TIMETICKS = 0x43, // 32-bit unsigned aka Timeticks32
+ CUPS_ASN1_GET_REQUEST = 0xa0, // GetRequest-PDU
+ CUPS_ASN1_GET_NEXT_REQUEST = 0xa1, // GetNextRequest-PDU
+ CUPS_ASN1_GET_RESPONSE = 0xa2 // GetResponse-PDU
};
-typedef enum cups_asn1_e cups_asn1_t; /**** ASN1 request/object types ****/
+typedef enum cups_asn1_e cups_asn1_t; // ASN1 request/object types
-typedef struct cups_snmp_string_s /**** String value ****/
+typedef struct cups_snmp_string_s // String value
{
unsigned char bytes[CUPS_SNMP_MAX_STRING];
- /* Bytes in string */
- unsigned num_bytes; /* Number of bytes */
+ // Bytes in string
+ unsigned num_bytes; // Number of bytes
} cups_snmp_string_t;
-union cups_snmp_value_u /**** Object value ****/
+union cups_snmp_value_u // Object value
{
- int boolean; /* Boolean value */
- int integer; /* Integer value */
- int counter; /* Counter value */
- unsigned gauge; /* Gauge value */
- unsigned timeticks; /* Timeticks value */
- int oid[CUPS_SNMP_MAX_OID]; /* OID value */
- cups_snmp_string_t string; /* String value */
+ int boolean; // Boolean value
+ int integer; // Integer value
+ int counter; // Counter value
+ unsigned gauge; // Gauge value
+ unsigned timeticks; // Timeticks value
+ int oid[CUPS_SNMP_MAX_OID]; // OID value
+ cups_snmp_string_t string; // String value
};
-typedef struct cups_snmp_s /**** SNMP data packet ****/
+typedef struct cups_snmp_s // SNMP data packet
{
- const char *error; /* Encode/decode error */
- http_addr_t address; /* Source address */
- int version; /* Version number */
+ const char *error; // Encode/decode error
+ http_addr_t address; // Source address
+ int version; // Version number
char community[CUPS_SNMP_MAX_COMMUNITY];
- /* Community name */
- cups_asn1_t request_type; /* Request type */
- unsigned request_id; /* request-id value */
- int error_status; /* error-status value */
- int error_index; /* error-index value */
+ // Community name
+ cups_asn1_t request_type; // Request type
+ unsigned request_id; // request-id value
+ int error_status; // error-status value
+ int error_index; // error-index value
int object_name[CUPS_SNMP_MAX_OID];
- /* object-name value */
- cups_asn1_t object_type; /* object-value type */
+ // object-name value
+ cups_asn1_t object_type; // object-value type
union cups_snmp_value_u
- object_value; /* object-value value */
+ object_value; // object-value value
} cups_snmp_t;
typedef void (*cups_snmp_cb_t)(cups_snmp_t *packet, void *data);
+ // `_cupsSNMPWalk` callback
-/*
- * Prototypes...
- */
-# ifdef __cplusplus
-extern "C" {
-# endif /* __cplusplus */
+//
+// Functions...
+//
extern void _cupsSNMPClose(int fd) _CUPS_PRIVATE;
-extern int *_cupsSNMPCopyOID(int *dst, const int *src, int dstsize)
- _CUPS_PRIVATE;
+extern int *_cupsSNMPCopyOID(int *dst, const int *src, int dstsize) _CUPS_PRIVATE;
extern const char *_cupsSNMPDefaultCommunity(void) _CUPS_PRIVATE;
-extern int _cupsSNMPIsOID(cups_snmp_t *packet, const int *oid)
- _CUPS_PRIVATE;
-extern int _cupsSNMPIsOIDPrefixed(cups_snmp_t *packet,
- const int *prefix) _CUPS_PRIVATE;
-extern char *_cupsSNMPOIDToString(const int *src, char *dst,
- size_t dstsize) _CUPS_PRIVATE;
+extern int _cupsSNMPIsOID(cups_snmp_t *packet, const int *oid) _CUPS_PRIVATE;
+extern int _cupsSNMPIsOIDPrefixed(cups_snmp_t *packet, const int *prefix) _CUPS_PRIVATE;
+extern char *_cupsSNMPOIDToString(const int *src, char *dst, size_t dstsize) _CUPS_PRIVATE;
extern int _cupsSNMPOpen(int family) _CUPS_PRIVATE;
-extern cups_snmp_t *_cupsSNMPRead(int fd, cups_snmp_t *packet,
- double timeout) _CUPS_PRIVATE;
+extern cups_snmp_t *_cupsSNMPRead(int fd, cups_snmp_t *packet, double timeout) _CUPS_PRIVATE;
extern void _cupsSNMPSetDebug(int level) _CUPS_PRIVATE;
-extern int *_cupsSNMPStringToOID(const char *src,
- int *dst, int dstsize)
- _CUPS_PRIVATE;
-extern int _cupsSNMPWalk(int fd, http_addr_t *address, int version,
- const char *community, const int *prefix,
- double timeout, cups_snmp_cb_t cb,
- void *data) _CUPS_PRIVATE;
-extern int _cupsSNMPWrite(int fd, http_addr_t *address, int version,
- const char *community,
- cups_asn1_t request_type,
- const unsigned request_id,
- const int *oid) _CUPS_PRIVATE;
+extern int *_cupsSNMPStringToOID(const char *src, int *dst, int dstsize) _CUPS_PRIVATE;
+extern int _cupsSNMPWalk(int fd, http_addr_t *address, int version, const char *community, const int *prefix, double timeout, cups_snmp_cb_t cb, void *data) _CUPS_PRIVATE;
+extern int _cupsSNMPWrite(int fd, http_addr_t *address, int version, const char *community, cups_asn1_t request_type, const unsigned request_id, const int *oid) _CUPS_PRIVATE;
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_SNMP_PRIVATE_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_SNMP_PRIVATE_H_
# include <errno.h>
# include <locale.h>
# include <time.h>
-# include <cups/versioning.h>
+# include <cups/base.h>
# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
# define __CUPS_SSIZE_T_DEFINED
# include <stddef.h>
--- /dev/null
+//
+// Form API unit test program for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "form.h"
+#include "test-internal.h"
+
+
+//
+// Local types...
+//
+
+typedef struct _form_data_s // Form test data
+{
+ const char *url, // URL prefix, if any
+ *encoded; // URL-encoded data
+ size_t num_pairs; // Number of name=value pairs
+ const char * const * pairs; // name=value pairs
+} _form_data_t;
+
+
+//
+// Local functions...
+//
+
+static void do_test(_form_data_t *test);
+static void usage(FILE *fp);
+
+
+//
+// 'main()' - Main entry.
+//
+
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
+{
+ int status = 0; // Exit status
+
+
+ if (argc == 1)
+ {
+ // Do canned API unit tests...
+ static _form_data_t test1 =
+ {
+ NULL,
+ "",
+ 0,
+ NULL
+ };
+ static const char * const pairs2[] =
+ {
+ "name", "value"
+ };
+ static _form_data_t test2 =
+ {
+ NULL,
+ "name=value",
+ 1,
+ pairs2
+ };
+ static const char * const pairs3[] =
+ {
+ "name", "value",
+ "name_2", "value 2",
+ "third", "3.1415926535"
+ };
+ static _form_data_t test3 =
+ {
+ NULL,
+ "name=value&name%5F2=value+2&third=3%2E1415926535",
+ 3,
+ pairs3
+ };
+ static _form_data_t test4 =
+ {
+ NULL,
+ "bogus",
+ 0,
+ NULL
+ };
+ static _form_data_t test5 =
+ {
+ NULL,
+ "bogus=foo=bar",
+ 0,
+ NULL
+ };
+ static _form_data_t test6 =
+ {
+ NULL,
+ "nul=%00",
+ 0,
+ NULL
+ };
+ static const char * const pairs7[] =
+ {
+ "name", "value",
+ "name_2", "value 2",
+ "third", "3.1415926535"
+ };
+ static _form_data_t test7 =
+ {
+ "http://www.example.com:8080/userinfo",
+ "http://www.example.com:8080/userinfo?name=value&name%5F2=value+2&third=3%2E1415926535",
+ 3,
+ pairs7
+ };
+ static const char * const pairs8[] =
+ {
+ "name", "value",
+ "name_2", "value 2",
+ "third", "3.1415926535"
+ };
+ static _form_data_t test8 =
+ {
+ "https://www.example.com",
+ "https://www.example.com/?name=value&name%5F2=value+2&third=3%2E1415926535",
+ 3,
+ pairs8
+ };
+
+ do_test(&test1);
+ do_test(&test2);
+ do_test(&test3);
+ do_test(&test4);
+ do_test(&test5);
+ do_test(&test6);
+ do_test(&test7);
+ do_test(&test8);
+ }
+ else
+ {
+ // Parse command-line...
+ int i; // Looping var
+ const char *opt; // Current option
+ const char *url = NULL; // URL, if any
+ size_t num_vars; // Number of variables
+ cups_option_t *vars; // Variables
+ char *data; // Form data
+
+ for (i = 1; i < argc; i ++)
+ {
+ if (!strcmp(argv[i], "--help"))
+ {
+ // --help
+ usage(stdout);
+ }
+ else if (!strncmp(argv[i], "--", 2))
+ {
+ // Unknown option
+ fprintf(stderr, "testform: Unknown option '%s'.\n", argv[i]);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+ else if (argv[i][0] == '-')
+ {
+ // Process options
+ for (opt = argv[i] + 1; *opt && !status; opt ++)
+ {
+ switch (*opt)
+ {
+ case 'f' : // -f FORM-DATA
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testform: Missing form data after '-f'.\n", stderr);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+
+ num_vars = cupsFormDecode(argv[i], &vars);
+ if (num_vars == 0)
+ {
+ fprintf(stderr, "testform: %s\n", cupsGetErrorString());
+ status = 1;
+ }
+ else
+ {
+ size_t j; // Looping var
+
+ for (j = 0; j < num_vars; j ++)
+ printf("%s=%s\n", vars[j].name, vars[j].value);
+
+ cupsFreeOptions(num_vars, vars);
+ }
+ break;
+
+ case 'o' : // -o 'NAME=VALUE [... NAME=VALUE]'
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testform: Missing form data after '-o'.\n", stderr);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+
+ num_vars = cupsParseOptions(argv[i], 0, &vars);
+ data = cupsFormEncode(url, num_vars, vars);
+
+ if (data)
+ {
+ puts(data);
+ free(data);
+ }
+ else
+ {
+ fprintf(stderr, "testform: %s\n", cupsGetErrorString());
+ status = 1;
+ }
+
+ cupsFreeOptions(num_vars, vars);
+ break;
+
+ case 'u' : // -u URL
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testform: Missing URL after '-u'.\n", stderr);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+
+ url = argv[i];
+ break;
+
+ default :
+ fprintf(stderr, "testform: Unknown option '-%c'.\n", *opt);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Unknown option...
+ fprintf(stderr, "testform: Unknown argument '%s'.\n", argv[i]);
+ usage(stderr);
+ status = 1;
+ break;
+ }
+ }
+ }
+
+ return (status);
+}
+
+
+//
+// 'do_test()' - Test the form functions.
+//
+
+static void
+do_test(_form_data_t *test) // I - Test data
+{
+ size_t i, // Looping var
+ num_vars; // Number of variables
+ cups_option_t *vars; // Variables
+ char *data; // Form data
+
+
+ testBegin("cupsFormDecode(\"%s\")", test->encoded);
+ num_vars = cupsFormDecode(test->encoded, &vars);
+ if (num_vars != test->num_pairs)
+ {
+ testEndMessage(false, "got %u pairs, expected %u", (unsigned)num_vars, (unsigned)test->num_pairs);
+ }
+ else
+ {
+ size_t count; // Max count
+ const char *value; // Value
+
+ for (i = 0, count = 2 * test->num_pairs; i < count; i += 2)
+ {
+ if ((value = cupsGetOption(test->pairs[i], num_vars, vars)) == NULL)
+ {
+ testEndMessage(false, "Missing %s", test->pairs[i]);
+ break;
+ }
+ else if (strcmp(value, test->pairs[i + 1]))
+ {
+ testEndMessage(false, "Got value \"%s\" for %s, expected \"%s\"", value, test->pairs[i], test->pairs[i + 1]);
+ break;
+ }
+ }
+
+ if (i >= count)
+ testEnd(true);
+ }
+
+ cupsFreeOptions(num_vars, vars);
+
+ if (test->num_pairs == 0 && test->encoded[0])
+ return;
+
+ testBegin("cupsFormEncode(%u pairs)", (unsigned)test->num_pairs);
+ for (i = 0, num_vars = 0, vars = NULL; i < test->num_pairs; i ++)
+ num_vars = cupsAddOption(test->pairs[i * 2], test->pairs[i * 2 + 1], num_vars, &vars);
+
+ data = cupsFormEncode(test->url, num_vars, vars);
+
+ if (!data && test->encoded[0])
+ testEndMessage(false, cupsGetErrorString());
+ else if (data && strcmp(data, test->encoded))
+ testEndMessage(false, "Got \"%s\", expected \"%s\"", data, test->encoded);
+ else
+ testEnd(true);
+
+ free(data);
+ cupsFreeOptions(num_vars, vars);
+}
+
+
+//
+// 'usage()' - Show program usage.
+//
+
+static void
+usage(FILE *fp) // I - Output file
+{
+ fputs("Usage: ./testform [OPTIONS]\n", fp);
+ fputs("Options:\n", fp);
+ fputs(" --help Show program help.\n", fp);
+ fputs(" -f FORM-DATA Decode form data.\n", fp);
+ fputs(" -o 'NAME=VALUE [... NAME=VALUE]' Encode form data.\n", fp);
+}
--- /dev/null
+//
+// JSON API unit tests for CUPS.
+//
+// Copyright © 2022 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "cups.h"
+#include "json.h"
+#include "test-internal.h"
+
+
+//
+// 'main()' - Main entry.
+//
+
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
+{
+ int i; // Looping var
+ cups_json_t *json; // JSON root object
+
+
+ if (argc == 1)
+ {
+ // Do unit tests...
+ cups_json_t *current, // Current node
+ *parent; // Current parent node
+ cups_jtype_t type; // Node type
+ size_t count; // Number of children
+ char *s; // JSON string
+ time_t last_modified = 0; // Last-Modified value
+ static const char * const types[] = // Node types
+ {
+ "CUPS_JTYPE_NULL", // Null value
+ "CUPS_JTYPE_FALSE", // Boolean false value
+ "CUPS_JTYPE_TRUE", // Boolean true value
+ "CUPS_JTYPE_NUMBER", // Number value
+ "CUPS_JTYPE_STRING", // String value
+ "CUPS_JTYPE_ARRAY", // Array value
+ "CUPS_JTYPE_OBJECT", // Object value
+ "CUPS_JTYPE_KEY" // Object key (string)
+ };
+
+ testBegin("cupsJSONNew(root object)");
+ json = cupsJSONNew(NULL, NULL, CUPS_JTYPE_OBJECT);
+ testEnd(json != NULL);
+
+ testBegin("cupsJSONGetCount(root)");
+ count = cupsJSONGetCount(json);
+ testEndMessage(count == 0, "%u", (unsigned)count);
+
+ testBegin("cupsJSONGetType(root)");
+ type = cupsJSONGetType(json);
+ testEndMessage(type == CUPS_JTYPE_OBJECT, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('string')");
+ current = cupsJSONNewKey(json, NULL, "string");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(key)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_KEY, "%s", types[type]);
+
+ testBegin("cupsJSONNewString('value')");
+ current = cupsJSONNewString(json, current, "value");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(string)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_STRING, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('number')");
+ current = cupsJSONNewKey(json, NULL, "number");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewNumber(42)");
+ current = cupsJSONNewNumber(json, current, 42);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(number)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_NUMBER, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('null')");
+ current = cupsJSONNewKey(json, NULL, "null");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(null)");
+ current = cupsJSONNew(json, current, CUPS_JTYPE_NULL);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(null)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_NULL, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('false')");
+ current = cupsJSONNewKey(json, NULL, "false");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(false)");
+ current = cupsJSONNew(json, current, CUPS_JTYPE_FALSE);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(false)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_FALSE, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('true')");
+ current = cupsJSONNewKey(json, NULL, "true");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(true)");
+ current = cupsJSONNew(json, current, CUPS_JTYPE_TRUE);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetType(true)");
+ type = cupsJSONGetType(current);
+ testEndMessage(type == CUPS_JTYPE_TRUE, "%s", types[type]);
+
+ testBegin("cupsJSONNewKey('array')");
+ current = cupsJSONNewKey(json, NULL, "array");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(array)");
+ parent = cupsJSONNew(json, current, CUPS_JTYPE_ARRAY);
+ testEnd(parent != NULL);
+
+ testBegin("cupsJSONGetType(array)");
+ type = cupsJSONGetType(parent);
+ testEndMessage(type == CUPS_JTYPE_ARRAY, "%s", types[type]);
+
+ testBegin("cupsJSONNewString(array, 'foo')");
+ current = cupsJSONNewString(parent, NULL, "foo");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewString(array, 'bar')");
+ current = cupsJSONNewString(parent, current, "bar");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewNumber(array, 0.5)");
+ current = cupsJSONNewNumber(parent, current, 0.5);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewNumber(array, 123456789123456789.0)");
+ current = cupsJSONNewNumber(parent, current, 123456789123456789.0);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(array, null)");
+ current = cupsJSONNew(parent, current, CUPS_JTYPE_NULL);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewKey('object')");
+ current = cupsJSONNewKey(json, NULL, "object");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNew(object)");
+ parent = cupsJSONNew(json, current, CUPS_JTYPE_OBJECT);
+ testEnd(parent != NULL);
+
+ testBegin("cupsJSONNewKey(object, 'a')");
+ current = cupsJSONNewKey(parent, NULL, "a");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewString(object, 'one')");
+ current = cupsJSONNewString(parent, current, "one");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewKey(object, 'b')");
+ current = cupsJSONNewKey(parent, current, "b");
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONNewNumber(object, 2)");
+ current = cupsJSONNewNumber(parent, current, 2);
+ testEnd(current != NULL);
+
+ testBegin("cupsJSONGetCount(root)");
+ count = cupsJSONGetCount(json);
+ testEndMessage(count == 14, "%u", (unsigned)count);
+
+ testBegin("cupsJSONExportFile(root, 'test.json')");
+ if (cupsJSONExportFile(json, "test.json"))
+ {
+ testEnd(true);
+
+ testBegin("cupsJSONImportFile('test.json')");
+ parent = cupsJSONImportFile("test.json");
+ testEnd(parent != NULL);
+
+ cupsJSONDelete(parent);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsGetErrorString());
+ }
+
+ testBegin("cupsJSONExportString(root)");
+ if ((s = cupsJSONExportString(json)) != NULL)
+ {
+ testEnd(true);
+
+ testBegin("cupsJSONImportString('%s')", s);
+ parent = cupsJSONImportString(s);
+ testEnd(parent != NULL);
+
+ cupsJSONDelete(parent);
+ free(s);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsGetErrorString());
+ }
+
+ testBegin("cupsJSONDelete(root)");
+ cupsJSONDelete(json);
+ testEnd(true);
+
+ testBegin("cupsJSONImportURL('https://accounts.google.com/.well-known/openid-configuration', no last modified)");
+ json = cupsJSONImportURL("https://accounts.google.com/.well-known/openid-configuration", &last_modified);
+
+ if (json)
+ {
+ char last_modified_date[256];// Last-Modified string value
+
+ testEnd(true);
+ cupsJSONDelete(json);
+
+ testBegin("cupsJSONImportURL('https://accounts.google.com/.well-known/openid-configuration', since %s)", httpGetDateString2(last_modified, last_modified_date, sizeof(last_modified_date)));
+ json = cupsJSONImportURL("https://accounts.google.com/.well-known/openid-configuration", &last_modified);
+
+ if (json)
+ testEnd(true);
+ else if (cupsGetError() == IPP_STATUS_OK_EVENTS_COMPLETE)
+ testEndMessage(true, "no change from last request");
+ else
+ testEndMessage(false, cupsGetErrorString());
+
+ cupsJSONDelete(json);
+ }
+ else if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ {
+ testEndMessage(true, "%s", cupsGetErrorString());
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsGetErrorString());
+ }
+
+ if (!testsPassed)
+ return (1);
+ }
+ else
+ {
+ // Try loading JSON files/strings on the command-line...
+ for (i = 1; i < argc; i ++)
+ {
+ if (argv[i][0] == '{')
+ {
+ // Load JSON string...
+ if ((json = cupsJSONImportString(argv[i])) != NULL)
+ printf("string%d: OK, %u key/value pairs in root object.\n", i, (unsigned)(cupsJSONGetCount(json) / 2));
+ else
+ fprintf(stderr, "string%d: %s\n", i, cupsGetErrorString());
+ }
+ else if ((json = cupsJSONImportFile(argv[i])) != NULL)
+ printf("%s: OK, %u key/value pairs in root object.\n", argv[i], (unsigned)(cupsJSONGetCount(json) / 2));
+ else
+ fprintf(stderr, "%s: %s\n", argv[i], cupsGetErrorString());
+
+ cupsJSONDelete(json);
+ }
+ }
+
+ return (0);
+}
--- /dev/null
+//
+// JWT API unit tests for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "cups.h"
+#include "jwt.h"
+#include "test-internal.h"
+
+
+//
+// 'main()' - Main entry.
+//
+
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
+{
+ int i; // Looping var
+ cups_jwt_t *jwt; // JSON Web Token object
+ cups_json_t *jwk; // JSON Web Key Set
+
+
+ if (argc == 1)
+ {
+ // Do unit tests...
+ cups_json_t *pubjwk; // Public key set
+ char *temp; // Temporary string
+ static const char * const examples[][2] =
+ { // JWT examples
+ {
+ "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9."
+ "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQo"
+ "gImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ."
+ "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
+ "{\"kty\":\"oct\","
+ "\"k\":\"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75"
+ "aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow\"}"
+ },
+ {
+ "eyJhbGciOiJSUzI1NiJ9."
+ "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt"
+ "cGxlLmNvbS9pc19yb290Ijp0cnVlfQ."
+ "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7"
+ "AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4"
+ "BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K"
+ "0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv"
+ "hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB"
+ "p0igcN_IoypGlUPQGe77Rw",
+ "{\"kty\":\"RSA\","
+ "\"n\":\"ofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd_wWJcyQoTbji9k0l8W26mPddx"
+ "HmfHQp-Vaw-4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL-yRT-SFd2lZS-pCgNMs"
+ "D1W_YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb_7OMg0LOL-bSf63kpaSH"
+ "SXndS5z5rexMdbBYUsLA9e-KXBdQOS-UTo7WTBEMa2R2CapHg665xsmtdV"
+ "MTBQY4uDZlxvb3qCo5ZwKh9kG4LT6_I5IhlJH7aGhyxXFvUK-DWNmoudF8"
+ "NAco9_h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQ\","
+ "\"e\":\"AQAB\","
+ "\"d\":\"Eq5xpGnNCivDflJsRQBXHx1hdR1k6Ulwe2JZD50LpXyWPEAeP88vLNO97I"
+ "jlA7_GQ5sLKMgvfTeXZx9SE-7YwVol2NXOoAJe46sui395IW_GO-pWJ1O0"
+ "BkTGoVEn2bKVRUCgu-GjBVaYLU6f3l9kJfFNS3E0QbVdxzubSu3Mkqzjkn"
+ "439X0M_V51gfpRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT"
+ "CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh"
+ "BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ\","
+ "\"p\":\"4BzEEOtIpmVdVEZNCqS7baC4crd0pqnRH_5IB3jw3bcxGn6QLvnEtfdUdi"
+ "YrqBdss1l58BQ3KhooKeQTa9AB0Hw_Py5PJdTJNPY8cQn7ouZ2KKDcmnPG"
+ "BY5t7yLc1QlQ5xHdwW1VhvKn-nXqhJTBgIPgtldC-KDV5z-y2XDwGUc\","
+ "\"q\":\"uQPEfgmVtjL0Uyyx88GZFF1fOunH3-7cepKmtH4pxhtCoHqpWmT8YAmZxa"
+ "ewHgHAjLYsp1ZSe7zFYHj7C6ul7TjeLQeZD_YwD66t62wDmpe_HlB-TnBA"
+ "-njbglfIsRLtXlnDzQkv5dTltRJ11BKBBypeeF6689rjcJIDEz9RWdc\","
+ "\"dp\":\"BwKfV3Akq5_MFZDFZCnW-wzl-CCo83WoZvnLQwCTeDv8uzluRSnm71I3Q"
+ "CLdhrqE2e9YkxvuxdBfpT_PI7Yz-FOKnu1R6HsJeDCjn12Sk3vmAktV2zb"
+ "34MCdy7cpdTh_YVr7tss2u6vneTwrA86rZtu5Mbr1C1XsmvkxHQAdYo0\","
+ "\"dq\":\"h_96-mK1R_7glhsum81dZxjTnYynPbZpHziZjeeHcXYsXaaMwkOlODsWa"
+ "7I9xXDoRwbKgB719rrmI2oKr6N3Do9U0ajaHF-NKJnwgjMd2w9cjz3_-ky"
+ "NlxAr2v4IKhGNpmM5iIgOS1VZnOZ68m6_pbLBSp3nssTdlqvd0tIiTHU\","
+ "\"qi\":\"IYd7DHOhrWvxkwPQsRM2tOgrjbcrfvtQJipd-DlcxyVuuM9sQLdgjVk2o"
+ "y26F0EmpScGLq2MowX7fhd_QJQ3ydy5cY7YIBi87w93IKLEdfnbJtoOPLU"
+ "W0ITrJReOgo1cq9SbsxYawBgfp_gh6A5603k2-ZQwVK0JKSHuLFkuQ3U\""
+ "}"
+ },
+ {
+ "eyJhbGciOiJFUzI1NiJ9."
+ "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt"
+ "cGxlLmNvbS9pc19yb290Ijp0cnVlfQ."
+ "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA"
+ "pmWQxfKTUJqPP3-Kg6NU1Q",
+ "{\"kty\":\"EC\","
+ "\"crv\":\"P-256\","
+ "\"x\":\"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU\","
+ "\"y\":\"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0\","
+ "\"d\":\"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI\""
+ "}"
+ }
+ };
+
+ testBegin("cupsJWTNew(NULL)");
+ jwt = cupsJWTNew(NULL);
+ testEnd(jwt != NULL);
+
+ testBegin("cupsJWTSetClaimNumber(CUPS_JWT_IAT)");
+ cupsJWTSetClaimNumber(jwt, CUPS_JWT_IAT, (double)time(NULL) + 86400.0);
+ testEnd(cupsJWTGetClaimNumber(jwt, CUPS_JWT_IAT) > 0.0);
+
+ testBegin("cupsJWTSetClaimString(CUPS_JWT_SUB)");
+ cupsJWTSetClaimString(jwt, CUPS_JWT_SUB, "joe.user");
+ testEnd(cupsJWTGetClaimString(jwt, CUPS_JWT_SUB) != NULL);
+
+ testBegin("cupsJWTMakePrivateKey(HS256)");
+ jwk = cupsJWTMakePrivateKey(CUPS_JWA_HS256);
+ testEnd(jwk != NULL);
+
+ if ((temp = cupsJSONExportString(jwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTSign(HS256)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_HS256, jwk));
+
+ testBegin("cupsJWTHasValidSignature(HS256)");
+ testEnd(cupsJWTHasValidSignature(jwt, jwk));
+
+ cupsJSONDelete(jwk);
+
+ testBegin("cupsJWTMakePrivateKey(RS256)");
+ jwk = cupsJWTMakePrivateKey(CUPS_JWA_RS256);
+ testEnd(jwk != NULL);
+
+ if ((temp = cupsJSONExportString(jwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTMakePublicKey(RS256)");
+ pubjwk = cupsJWTMakePublicKey(jwk);
+ testEnd(pubjwk != NULL);
+
+ if ((temp = cupsJSONExportString(pubjwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTSign(RS256)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_RS256, jwk));
+
+ testBegin("cupsJWTHasValidSignature(RS256)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ testBegin("cupsJWTSign(RS384)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_RS384, jwk));
+
+ testBegin("cupsJWTHasValidSignature(RS384)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ testBegin("cupsJWTSign(RS512)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_RS512, jwk));
+
+ testBegin("cupsJWTHasValidSignature(RS512)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ cupsJSONDelete(jwk);
+ cupsJSONDelete(pubjwk);
+
+ testBegin("cupsJWTMakePrivateKey(ES256)");
+ jwk = cupsJWTMakePrivateKey(CUPS_JWA_ES256);
+ testEnd(jwk != NULL);
+
+ if ((temp = cupsJSONExportString(jwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTMakePublicKey(ES256)");
+ pubjwk = cupsJWTMakePublicKey(jwk);
+ testEnd(pubjwk != NULL);
+
+ if ((temp = cupsJSONExportString(pubjwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTSign(ES256)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_ES256, jwk));
+
+ testBegin("cupsJWTHasValidSignature(ES256)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ cupsJSONDelete(jwk);
+ cupsJSONDelete(pubjwk);
+
+ testBegin("cupsJWTMakePrivateKey(ES384)");
+ jwk = cupsJWTMakePrivateKey(CUPS_JWA_ES384);
+ testEnd(jwk != NULL);
+
+ if ((temp = cupsJSONExportString(jwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTMakePublicKey(ES384)");
+ pubjwk = cupsJWTMakePublicKey(jwk);
+ testEnd(pubjwk != NULL);
+
+ if ((temp = cupsJSONExportString(pubjwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTSign(ES384)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_ES384, jwk));
+
+ testBegin("cupsJWTHasValidSignature(ES384)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ cupsJSONDelete(jwk);
+ cupsJSONDelete(pubjwk);
+
+ testBegin("cupsJWTMakePrivateKey(ES512)");
+ jwk = cupsJWTMakePrivateKey(CUPS_JWA_ES512);
+ testEnd(jwk != NULL);
+
+ if ((temp = cupsJSONExportString(jwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTMakePublicKey(ES512)");
+ pubjwk = cupsJWTMakePublicKey(jwk);
+ testEnd(pubjwk != NULL);
+
+ if ((temp = cupsJSONExportString(pubjwk)) != NULL)
+ {
+ puts(temp);
+ free(temp);
+ }
+
+ testBegin("cupsJWTSign(ES512)");
+ testEnd(cupsJWTSign(jwt, CUPS_JWA_ES512, jwk));
+
+ testBegin("cupsJWTHasValidSignature(ES512)");
+ testEnd(cupsJWTHasValidSignature(jwt, pubjwk));
+
+ cupsJSONDelete(jwk);
+ cupsJSONDelete(pubjwk);
+
+ testBegin("cupsJWTDelete()");
+ cupsJWTDelete(jwt);
+ testEnd(true);
+
+ for (i = 0; i < (int)(sizeof(examples) / sizeof(examples[0])); i ++)
+ {
+ testBegin("cupsJWTImportString(\"%s\", CUPS_JWS_FORMAT_COMPACT)", examples[i][0]);
+ if ((jwt = cupsJWTImportString(examples[i][0], CUPS_JWS_FORMAT_COMPACT)) != NULL)
+ {
+ testEnd(true);
+
+ testBegin("cupsJSONImportString(\"%s\")", examples[i][1]);
+ if ((jwk = cupsJSONImportString(examples[i][1])) != NULL)
+ {
+ testEnd(true);
+ testBegin("cupsJWTHasValidSignature()");
+ testEnd(cupsJWTHasValidSignature(jwt, jwk));
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsGetErrorString());
+ }
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsGetErrorString());
+ }
+
+ cupsJSONDelete(jwk);
+ cupsJWTDelete(jwt);
+ }
+
+ if (!testsPassed)
+ return (1);
+ }
+ else
+ {
+ // Try loading JWT string on the command-line...
+ for (i = 1; i < argc; i ++)
+ {
+ if ((jwt = cupsJWTImportString(argv[i], CUPS_JWS_FORMAT_COMPACT)) != NULL)
+ {
+// printf("%s: OK, %u key/value pairs in root object.\n", argv[i], (unsigned)(cupsJSONGetCount(json) / 2));
+
+ cupsJWTDelete(jwt);
+ }
+ else
+ {
+ fprintf(stderr, "%s: %s\n", argv[i], cupsGetErrorString());
+ return (1);
+ }
+ }
+ }
+
+ return (0);
+}
#ifndef _CUPS_THREAD_H_
# define _CUPS_THREAD_H_
-# include "versioning.h"
+# include "base.h"
# ifdef __cplusplus
extern "C" {
# endif // __cplusplus
-/*
- * Transcoding definitions for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
+//
+// Transcoding definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2011 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_TRANSCODE_H_
# define _CUPS_TRANSCODE_H_
-
-/*
- * Include necessary headers...
- */
-
# include "language.h"
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
+
+//
+// Constants...
+//
-/*
- * Constants...
- */
+# define CUPS_MAX_USTRING 8192 // Max size of Unicode string
-# define CUPS_MAX_USTRING 8192 /* Max size of Unicode string */
+//
+// Types...
+//
-/*
- * Types...
- */
+typedef unsigned char cups_utf8_t; // UTF-8 Unicode/ISO-10646 unit
+typedef unsigned long cups_utf32_t; // UTF-32 Unicode/ISO-10646 unit
+typedef unsigned short cups_ucs2_t; // UCS-2 Unicode/ISO-10646 unit
+typedef unsigned long cups_ucs4_t; // UCS-4 Unicode/ISO-10646 unit
+typedef unsigned char cups_sbcs_t; // SBCS Legacy 8-bit unit
+typedef unsigned short cups_dbcs_t; // DBCS Legacy 16-bit unit
+typedef unsigned long cups_vbcs_t; // VBCS Legacy 32-bit unit
+ // EUC uses 8, 16, 24, 32-bit
-typedef unsigned char cups_utf8_t; /* UTF-8 Unicode/ISO-10646 unit */
-typedef unsigned long cups_utf32_t; /* UTF-32 Unicode/ISO-10646 unit */
-typedef unsigned short cups_ucs2_t; /* UCS-2 Unicode/ISO-10646 unit */
-typedef unsigned long cups_ucs4_t; /* UCS-4 Unicode/ISO-10646 unit */
-typedef unsigned char cups_sbcs_t; /* SBCS Legacy 8-bit unit */
-typedef unsigned short cups_dbcs_t; /* DBCS Legacy 16-bit unit */
-typedef unsigned long cups_vbcs_t; /* VBCS Legacy 32-bit unit */
- /* EUC uses 8, 16, 24, 32-bit */
+//
+// Functions...
+//
-/*
- * Prototypes...
- */
+extern int cupsCharsetToUTF8(cups_utf8_t *dest, const char *src, const int maxout, const cups_encoding_t encoding) _CUPS_PUBLIC;
+extern int cupsUTF8ToCharset(char *dest, const cups_utf8_t *src, const int maxout, const cups_encoding_t encoding) _CUPS_PUBLIC;
+extern int cupsUTF8ToUTF32(cups_utf32_t *dest, const cups_utf8_t *src, const int maxout) _CUPS_PUBLIC;
+extern int cupsUTF32ToUTF8(cups_utf8_t *dest, const cups_utf32_t *src, const int maxout) _CUPS_PUBLIC;
-extern int cupsCharsetToUTF8(cups_utf8_t *dest,
- const char *src,
- const int maxout,
- const cups_encoding_t encoding) _CUPS_API_1_2;
-extern int cupsUTF8ToCharset(char *dest,
- const cups_utf8_t *src,
- const int maxout,
- const cups_encoding_t encoding) _CUPS_API_1_2;
-extern int cupsUTF8ToUTF32(cups_utf32_t *dest,
- const cups_utf8_t *src,
- const int maxout) _CUPS_API_1_2;
-extern int cupsUTF32ToUTF8(cups_utf8_t *dest,
- const cups_utf32_t *src,
- const int maxout) _CUPS_API_1_2;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
+# endif // __cplusplus
-#endif /* !_CUPS_TRANSCODE_H_ */
+#endif // !_CUPS_TRANSCODE_H_
+++ /dev/null
-/*
- * API versioning definitions for CUPS.
- *
- * Copyright © 2021 by OpenPrinting.
- * Copyright © 2007-2019 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-#ifndef _CUPS_VERSIONING_H_
-# define _CUPS_VERSIONING_H_
-# include <stdbool.h>
-
-
-/*
- * This header defines several macros that add compiler-specific attributes for
- * functions:
- *
- * - _CUPS_API_major_minor[_patch]: Specifies when an API became available by
- * CUPS version.
- * - _CUPS_DEPRECATED: Function is deprecated with no replacement.
- * - _CUPS_DEPRECATED_MSG("message"): Function is deprecated and has a
- * replacement.
- * - _CUPS_FORMAT(format-index, additional-args-index): Function has a
- * printf-style format argument followed by zero or more additional
- * arguments. Indices start at 1.
- * - _CUPS_INTERNAL: Function is internal with no replacement API.
- * - _CUPS_INTERNAL_MSG("msg"): Function is internal - use specified API
- * instead.
- * - _CUPS_NONNULL((arg list)): Specifies the comma-separated argument indices
- * are assumed non-NULL. Indices start at 1.
- * - _CUPS_NORETURN: Specifies the function does not return.
- * - _CUPS_PRIVATE: Specifies the function is private to CUPS.
- * - _CUPS_PUBLIC: Specifies the function is public API.
- */
-
-/*
- * Determine which compiler is being used and what annotation features are
- * available...
- */
-
-# if defined(__APPLE__) && defined(__has_include)
-# if __has_include(<os/availability.h>)
-# include <os/availability.h>
-# define _CUPS_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
-# define _CUPS_API_DEPRECATED(...) API_DEPRECATED(__VA_ARGS__)
-# else
-# define _CUPS_API_AVAILABLE(...)
-# define _CUPS_API_DEPRECATED(...)
-# endif /* __has_include(<os/availability.h>) */
-# else
-# define _CUPS_API_AVAILABLE(...)
-# define _CUPS_API_DEPRECATED(...)
-# endif /* __APPLE__ && __has_include */
-
-# ifdef __has_extension /* Clang */
-# define _CUPS_HAS_DEPRECATED
-# define _CUPS_HAS_FORMAT
-# define _CUPS_HAS_NORETURN
-# define _CUPS_HAS_VISIBILITY
-# if __has_extension(attribute_deprecated_with_message)
-# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
-# endif
-# if __has_extension(attribute_unavailable_with_message)
-# define _CUPS_HAS_UNAVAILABLE_WITH_MESSAGE
-# endif
-# elif defined(__GNUC__) /* GCC and compatible */
-# if __GNUC__ >= 3 /* GCC 3.0 or higher */
-# define _CUPS_HAS_DEPRECATED
-# define _CUPS_HAS_FORMAT
-# define _CUPS_HAS_NORETURN
-# define _CUPS_HAS_VISIBILITY
-# endif /* __GNUC__ >= 3 */
-# if __GNUC__ >= 5 /* GCC 5.x */
-# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
-# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 5
- /* GCC 4.5 or higher */
-# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
-# endif /* __GNUC__ >= 5 */
-# elif defined(_WIN32)
-# define __attribute__(...)
-# endif /* __has_extension */
-
-
-/*
- * Define _CUPS_INTERNAL, _CUPS_PRIVATE, and _CUPS_PUBLIC visibility macros for
- * internal/private/public functions...
- */
-
-# ifdef _CUPS_HAS_VISIBILITY
-# define _CUPS_INTERNAL __attribute__ ((visibility("hidden")))
-# define _CUPS_PRIVATE __attribute__ ((visibility("default")))
-# define _CUPS_PUBLIC __attribute__ ((visibility("default")))
-# elif defined(_WIN32) && defined(LIBCUPS2_EXPORTS) && 0
-# define _CUPS_INTERNAL
-# define _CUPS_PRIVATE __declspec(dllexport)
-# define _CUPS_PUBLIC __declspec(dllexport)
-# else
-# define _CUPS_INTERNAL
-# define _CUPS_PRIVATE
-# define _CUPS_PUBLIC
-# endif /* _CUPS_HAS_VISIBILITY */
-
-
-/*
- * Define _CUPS_API_major_minor[_patch] availability macros for CUPS.
- *
- * Note: Using any of the _CUPS_API macros automatically adds _CUPS_PUBLIC.
- */
-
-# if defined(__APPLE__) && !defined(_CUPS_SOURCE) && TARGET_OS_OSX
-/*
- * On Apple operating systems, the _CUPS_API_* constants are defined using the
- * API_ macros in <os/availability.h>.
- *
- * On iOS, we don't actually have libcups available directly, but the supplied
- * libcups_static target in the Xcode project supports building on iOS 11.0 and
- * later.
- */
-# define _CUPS_API_1_1_19 _CUPS_API_AVAILABLE(macos(10.3), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_1_20 _CUPS_API_AVAILABLE(macos(10.4), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_1_21 _CUPS_API_AVAILABLE(macos(10.4), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_2 _CUPS_API_AVAILABLE(macos(10.5), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_3 _CUPS_API_AVAILABLE(macos(10.5), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_4 _CUPS_API_AVAILABLE(macos(10.6), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_5 _CUPS_API_AVAILABLE(macos(10.7), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_6 _CUPS_API_AVAILABLE(macos(10.8), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_1_7 _CUPS_API_AVAILABLE(macos(10.9), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_0 _CUPS_API_AVAILABLE(macos(10.10), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_2 _CUPS_API_AVAILABLE(macos(10.12), ios(11.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_2_4 _CUPS_API_AVAILABLE(macos(10.13), ios(12.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_2_7 _CUPS_API_AVAILABLE(macos(10.14), ios(13.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_3 _CUPS_API_AVAILABLE(macos(10.14), ios(13.0)) _CUPS_PUBLIC
-# define _CUPS_API_2_4 _CUPS_PUBLIC
-# else
-# define _CUPS_API_1_1_19 _CUPS_PUBLIC
-# define _CUPS_API_1_1_20 _CUPS_PUBLIC
-# define _CUPS_API_1_1_21 _CUPS_PUBLIC
-# define _CUPS_API_1_2 _CUPS_PUBLIC
-# define _CUPS_API_1_3 _CUPS_PUBLIC
-# define _CUPS_API_1_4 _CUPS_PUBLIC
-# define _CUPS_API_1_5 _CUPS_PUBLIC
-# define _CUPS_API_1_6 _CUPS_PUBLIC
-# define _CUPS_API_1_7 _CUPS_PUBLIC
-# define _CUPS_API_2_0 _CUPS_PUBLIC
-# define _CUPS_API_2_2 _CUPS_PUBLIC
-# define _CUPS_API_2_2_4 _CUPS_PUBLIC
-# define _CUPS_API_2_2_7 _CUPS_PUBLIC
-# define _CUPS_API_2_3 _CUPS_PUBLIC
-# define _CUPS_API_2_4 _CUPS_PUBLIC
-# endif /* __APPLE__ && !_CUPS_SOURCE */
-
-
-/*
- * Define _CUPS_DEPRECATED and _CUPS_INTERNAL macros to mark old APIs as
- * "deprecated" or "unavailable" with messages so you get warnings/errors are
- * compile-time...
- *
- * Note: Using any of the _CUPS_DEPRECATED macros automatically adds
- * _CUPS_PUBLIC.
- */
-
-# if !defined(_CUPS_HAS_DEPRECATED) || (defined(_CUPS_SOURCE) && !defined(_CUPS_NO_DEPRECATED))
- /*
- * Don't mark functions deprecated if the compiler doesn't support it
- * or we are building CUPS source that doesn't care.
- */
-# define _CUPS_DEPRECATED _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_MSG(m) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) _CUPS_PUBLIC
-# elif defined(__APPLE__) && defined(_CUPS_NO_DEPRECATED)
- /*
- * Compiler supports the unavailable attribute, so use it when the code
- * wants to exclude the use of deprecated API.
- */
-# define _CUPS_DEPRECATED __attribute__ ((unavailable)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.5), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.8), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.9), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.12), ios(11.0,11.0)) _CUPS_PUBLIC
-
-# elif defined(__APPLE__)
- /*
- * Just mark things as deprecated...
- */
-# define _CUPS_DEPRECATED __attribute__ ((deprecated)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.5), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.8), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.9), ios(11.0,11.0)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) _CUPS_API_DEPRECATED(m, macos(10.2,10.12), ios(11.0,11.0)) _CUPS_PUBLIC
-
-# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) && defined(_CUPS_NO_DEPRECATED)
- /*
- * Compiler supports the unavailable attribute, so use it when the code
- * wants to exclude the use of deprecated API.
- */
-# define _CUPS_DEPRECATED __attribute__ ((unavailable)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# else
- /*
- * Compiler supports the deprecated attribute, so use it.
- */
-# define _CUPS_DEPRECATED __attribute__ ((deprecated)) _CUPS_PUBLIC
-# ifdef _CUPS_HAS_DEPRECATED_WITH_MESSAGE
-# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# else
-# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_2_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_6_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_1_7_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# define _CUPS_DEPRECATED_2_2_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# endif /* _CUPS_HAS_DEPRECATED_WITH_MESSAGE */
-# endif /* !_CUPS_HAS_DEPRECATED || (_CUPS_SOURCE && !_CUPS_NO_DEPRECATED) */
-
-
-/*
- * Define _CUPS_FORMAT macro for printf-style functions...
- */
-
-# ifdef _CUPS_HAS_FORMAT
-# define _CUPS_FORMAT(a,b) __attribute__ ((__format__(__printf__, a,b)))
-# else
-# define _CUPS_FORMAT(a,b)
-# endif /* _CUPS_HAS_FORMAT */
-
-
-/*
- * Define _CUPS_INTERNAL_MSG macro for private APIs that have (historical)
- * public visibility.
- *
- * Note: Using the _CUPS_INTERNAL_MSG macro automatically adds _CUPS_PUBLIC.
- */
-
-# ifdef _CUPS_SOURCE
-# define _CUPS_INTERNAL_MSG(m) _CUPS_PUBLIC
-# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE)
-# define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) _CUPS_PUBLIC
-# elif defined(_CUPS_HAS_DEPRECATED_WITH_MESSAGE)
-# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated(m))) _CUPS_PUBLIC
-# else
-# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated)) _CUPS_PUBLIC
-# endif /* _CUPS_SOURCE */
-
-
-/*
- * Define _CUPS_NONNULL macro for functions that don't expect non-null
- * arguments...
- */
-
-# ifdef _CUPS_HAS_NONNULL
-# define _CUPS_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__)))
-# else
-# define _CUPS_NONNULL(...)
-# endif /* _CUPS_HAS_FORMAT */
-
-
-/*
- * Define _CUPS_NORETURN macro for functions that don't return.
- */
-
-# ifdef _CUPS_HAS_NORETURN
-# define _CUPS_NORETURN __attribute__ ((noreturn))
-# else
-# define _CUPS_NORETURN
-# endif /* _CUPS_HAS_NORETURN */
-
-
-#endif /* !_CUPS_VERSIONING_H_ */
commandtops.o: commandtops.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd.h ../cups/raster.h ../cups/sidechannel.h
gziptoany.o: gziptoany.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
common.o: common.c common.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
+ ../cups/base.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/ppd.h ../cups/raster.h
pstops.o: pstops.c common.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
+ ../cups/base.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/ppd.h ../cups/raster.h ../cups/language-private.h \
../cups/transcode.h
rastertoepson.o: rastertoepson.c ../cups/cups.h ../cups/file.h \
- ../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
- ../cups/language.h ../cups/pwg.h ../cups/ppd.h ../cups/raster.h \
- ../cups/string-private.h ../config.h ../cups/language-private.h \
- ../cups/transcode.h
-rastertohp.o: rastertohp.c ../cups/cups.h ../cups/file.h \
- ../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/base.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/ppd.h ../cups/raster.h \
../cups/string-private.h ../config.h ../cups/language-private.h \
../cups/transcode.h
+rastertohp.o: rastertohp.c ../cups/cups.h ../cups/file.h ../cups/base.h \
+ ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
+ ../cups/pwg.h ../cups/ppd.h ../cups/raster.h ../cups/string-private.h \
+ ../config.h ../cups/language-private.h ../cups/transcode.h
rastertolabel.o: rastertolabel.c ../cups/cups.h ../cups/file.h \
- ../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/base.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/ppd.h ../cups/raster.h \
../cups/string-private.h ../config.h ../cups/language-private.h \
../cups/transcode.h
rastertopwg.o: rastertopwg.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
checkpo.o: checkpo.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
po2strings.o: po2strings.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
bcp.o: bcp.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd.h ../cups/raster.h
tbcp.o: tbcp.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
-dbus.o: dbus.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
- ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
- ../cups/pwg.h ../cups/string-private.h ../config.h
+dbus.o: dbus.c ../cups/cups.h ../cups/file.h ../cups/base.h ../cups/ipp.h \
+ ../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
+ ../cups/string-private.h ../config.h
mailto.o: mailto.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
-rss.o: rss.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
- ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
- ../cups/pwg.h ../cups/string-private.h ../config.h \
- ../cups/ipp-private.h
+rss.o: rss.c ../cups/cups.h ../cups/file.h ../cups/base.h ../cups/ipp.h \
+ ../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
+ ../cups/string-private.h ../config.h ../cups/ipp-private.h
testnotify.o: testnotify.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
ppdc-array.o: ppdc-array.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-attr.o: ppdc-attr.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-catalog.o: ppdc-catalog.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-choice.o: ppdc-choice.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-constraint.o: ppdc-constraint.cxx ppdc-private.h ppdc.h \
- ../cups/file.h ../cups/versioning.h ../cups/cups-private.h \
+ ../cups/file.h ../cups/base.h ../cups/cups-private.h \
../cups/string-private.h ../config.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-driver.o: ppdc-driver.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-file.o: ppdc-file.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-filter.o: ppdc-filter.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-font.o: ppdc-font.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-group.o: ppdc-group.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-import.o: ppdc-import.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd.h ../cups/raster.h
ppdc-mediasize.o: ppdc-mediasize.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-message.o: ppdc-message.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-option.o: ppdc-option.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-profile.o: ppdc-profile.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-shared.o: ppdc-shared.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-source.o: ppdc-source.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.h ../cups/raster.h ../data/epson.h ../data/hp.h \
../data/label.h
ppdc-string.o: ppdc-string.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdc-variable.o: ppdc-variable.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
genstrings.o: genstrings.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
-ppdc.o: ppdc.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/debug-internal.h ../cups/debug-private.h \
- ../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/array.h ../cups/language.h ../cups/pwg.h \
- ../cups/http-private.h \
+ppdc.o: ppdc.cxx ppdc-private.h ppdc.h ../cups/file.h ../cups/base.h \
+ ../cups/cups-private.h ../cups/string-private.h ../config.h \
+ ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
+ \
\
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdhtml.o: ppdhtml.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
-ppdi.o: ppdi.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/debug-internal.h ../cups/debug-private.h \
- ../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/array.h ../cups/language.h ../cups/pwg.h \
- ../cups/http-private.h \
+ppdi.o: ppdi.cxx ppdc-private.h ppdc.h ../cups/file.h ../cups/base.h \
+ ../cups/cups-private.h ../cups/string-private.h ../config.h \
+ ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
+ \
\
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
ppdmerge.o: ppdmerge.cxx ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h
-ppdpo.o: ppdpo.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/debug-internal.h ../cups/debug-private.h \
- ../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/array.h ../cups/language.h ../cups/pwg.h \
- ../cups/http-private.h \
+ppdpo.o: ppdpo.cxx ppdc-private.h ppdc.h ../cups/file.h ../cups/base.h \
+ ../cups/cups-private.h ../cups/string-private.h ../config.h \
+ ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/language.h ../cups/pwg.h ../cups/http-private.h \
+ \
\
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
testcatalog.o: testcatalog.cxx ppdc-private.h ppdc.h ../cups/file.h \
- ../cups/versioning.h ../cups/cups-private.h ../cups/string-private.h \
+ ../cups/base.h ../cups/cups-private.h ../cups/string-private.h \
../config.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
auth.o: auth.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
banners.o: banners.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
cert.o: cert.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
classes.o: classes.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
client.o: client.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
colorman.o: colorman.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
conf.o: conf.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
dirsvc.o: dirsvc.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
env.o: env.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
file.o: file.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
main.o: main.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
ipp.o: ipp.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
listen.o: listen.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
job.o: job.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
banners.h dirsvc.h network.h subscriptions.h ../cups/backend.h \
../cups/dir.h
log.o: log.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
network.o: network.c ../cups/http-private.h ../config.h \
- ../cups/language.h ../cups/array.h ../cups/versioning.h ../cups/http.h \
+ ../cups/language.h ../cups/array.h ../cups/base.h ../cups/http.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/pwg.h \
\
banners.h dirsvc.h network.h subscriptions.h \
../cups/getifaddrs-internal.h
policy.o: policy.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
printers.o: printers.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
process.o: process.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
quotas.o: quotas.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
select.o: select.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
server.o: server.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 \
+ ../cups/array.h ../cups/base.h ../cups/http.h ../cups/ipp-private.h \
+ ../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/pwg.h \
+ \
\
\
\
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
statbuf.o: statbuf.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
subscriptions.o: subscriptions.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
sysman.o: sysman.c cupsd.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
client.h policy.h printers.h classes.h job.h colorman.h conf.h \
banners.h dirsvc.h network.h subscriptions.h
-filter.o: filter.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
- ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
- ../cups/pwg.h ../cups/string-private.h ../config.h mime.h \
- ../cups/thread.h
-mime.o: mime.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
- ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
- ../cups/pwg.h ../cups/string-private.h ../config.h ../cups/dir.h \
- mime-private.h mime.h ../cups/thread.h
-type.o: type.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
+filter.o: filter.c ../cups/cups.h ../cups/file.h ../cups/base.h \
../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
../cups/pwg.h ../cups/string-private.h ../config.h mime.h \
../cups/thread.h
+mime.o: mime.c ../cups/cups.h ../cups/file.h ../cups/base.h ../cups/ipp.h \
+ ../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
+ ../cups/string-private.h ../config.h ../cups/dir.h mime-private.h \
+ mime.h ../cups/thread.h
+type.o: type.c ../cups/cups.h ../cups/file.h ../cups/base.h ../cups/ipp.h \
+ ../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
+ ../cups/string-private.h ../config.h mime.h ../cups/thread.h
cupsfilter.o: cupsfilter.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/ppd.h ../cups/raster.h mime.h
cups-deviced.o: cups-deviced.c util.h ../cups/file-private.h \
../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/dir.h
cups-exec.o: cups-exec.c ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/file.h
+ ../cups/base.h ../cups/file.h
cups-lpd.o: cups-lpd.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
-testlpd.o: testlpd.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
+testlpd.o: testlpd.c ../cups/cups.h ../cups/file.h ../cups/base.h \
../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
../cups/pwg.h ../cups/string-private.h ../config.h
testmime.o: testmime.c ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/dir.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/dir.h ../cups/debug-private.h \
../cups/ppd-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/ppd.h ../cups/raster.h ../cups/pwg-private.h mime.h \
../cups/thread.h
testspeed.o: testspeed.c ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
+ ../cups/base.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/debug-private.h
-testsub.o: testsub.c ../cups/cups.h ../cups/file.h ../cups/versioning.h \
+testsub.o: testsub.c ../cups/cups.h ../cups/file.h ../cups/base.h \
../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
../cups/pwg.h ../cups/debug-private.h ../cups/string-private.h \
../config.h ../cups/ipp-private.h
util.o: util.c util.h ../cups/file-private.h ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.h
cups-driverd.o: cups-driverd.cxx util.h ../cups/file-private.h \
../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
unittests: $(UNITTARGETS)
+#
+# Run unit tests...
+#
+
+test: unittests
+ echo "Tests started at $(date)..." >test.log
+ echo Running MIME API tests...
+ ./testmime >>test.log
+ echo "Tests finished at $(date)..." >>test.log
+
+
#
# Clean all object files...
#
$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testmime.o libcupsmime.a \
$(LINKCUPSSTATIC)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
- echo Running MIME tests...
- ./testmime
#
-/*
- * MIME type/conversion database definitions for CUPS.
- *
- * Copyright 2007-2013 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.
- */
+//
+// MIME type/conversion database definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2013 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_MIME_H_
# define _CUPS_MIME_H_
-
# include <cups/array.h>
# include <cups/ipp.h>
# include <cups/file.h>
# include <cups/thread.h>
# include <regex.h>
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
+//
+// Constants...
+//
-# define MIME_MAX_SUPER 16 /* Maximum size of supertype name */
-# define MIME_MAX_TYPE IPP_MAX_NAME /* Maximum size of type name */
-# define MIME_MAX_FILTER 256 /* Maximum size of filter pathname */
-# define MIME_MAX_BUFFER 4096 /* Maximum size of file buffer */
+# define MIME_MAX_SUPER 16 // Maximum size of supertype name
+# define MIME_MAX_TYPE IPP_MAX_NAME
+ // Maximum size of type name
+# define MIME_MAX_FILTER 256 // Maximum size of filter pathname
+# define MIME_MAX_BUFFER 4096 // Maximum size of file buffer
-/*
- * Types/structures...
- */
+//
+// Types/structures...
+//
typedef enum
{
- MIME_MAGIC_NOP, /* No operation */
- MIME_MAGIC_AND, /* Logical AND of all children */
- MIME_MAGIC_OR, /* Logical OR of all children */
- MIME_MAGIC_MATCH, /* Filename match */
- MIME_MAGIC_ASCII, /* ASCII characters in range */
- MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */
- MIME_MAGIC_STRING, /* String matches */
- MIME_MAGIC_CHAR, /* Character/byte matches */
- MIME_MAGIC_SHORT, /* Short/16-bit word matches */
- MIME_MAGIC_INT, /* Integer/32-bit word matches */
- MIME_MAGIC_LOCALE, /* Current locale matches string */
- MIME_MAGIC_CONTAINS, /* File contains a string */
- MIME_MAGIC_ISTRING, /* Case-insensitive string matches */
- MIME_MAGIC_REGEX /* Regular expression matches */
+ MIME_MAGIC_NOP, // No operation
+ MIME_MAGIC_AND, // Logical AND of all children
+ MIME_MAGIC_OR, // Logical OR of all children
+ MIME_MAGIC_MATCH, // Filename match
+ MIME_MAGIC_ASCII, // ASCII characters in range
+ MIME_MAGIC_PRINTABLE, // Printable characters (32-255) in range
+ MIME_MAGIC_STRING, // String matches
+ MIME_MAGIC_CHAR, // Character/byte matches
+ MIME_MAGIC_SHORT, // Short/16-bit word matches
+ MIME_MAGIC_INT, // Integer/32-bit word matches
+ MIME_MAGIC_LOCALE, // Current locale matches string
+ MIME_MAGIC_CONTAINS, // File contains a string
+ MIME_MAGIC_ISTRING, // Case-insensitive string matches
+ MIME_MAGIC_REGEX // Regular expression matches
} mime_op_t;
-typedef struct _mime_magic_s /**** MIME Magic Data ****/
+typedef struct _mime_magic_s // MIME Magic Data
{
- struct _mime_magic_s *prev, /* Previous rule */
- *next, /* Next rule */
- *parent, /* Parent rules */
- *child; /* Child rules */
- short op, /* Operation code (see above) */
- invert; /* Invert the result */
- int offset, /* Offset in file */
- region, /* Region length */
- length; /* Length of data */
+ struct _mime_magic_s *prev, // Previous rule
+ *next, // Next rule
+ *parent, // Parent rules
+ *child; // Child rules
+ short op, // Operation code (see above)
+ invert; // Invert the result
+ int offset, // Offset in file
+ region, // Region length
+ length; // Length of data
union
{
- char matchv[64]; /* Match value */
- char localev[64]; /* Locale value */
- char stringv[64]; /* String value */
- unsigned char charv; /* Byte value */
- unsigned short shortv; /* Short value */
- unsigned intv; /* Integer value */
- regex_t rev; /* Regular expression value */
+ char matchv[64]; // Match value
+ char localev[64]; // Locale value
+ char stringv[64]; // String value
+ unsigned char charv; // Byte value
+ unsigned short shortv; // Short value
+ unsigned intv; // Integer value
+ regex_t rev; // Regular expression value
} value;
} mime_magic_t;
-typedef struct _mime_type_s /**** MIME Type Data ****/
+typedef struct _mime_type_s // MIME Type Data
{
- mime_magic_t *rules; /* Rules used to detect this type */
- int priority; /* Priority of this type */
- char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
- type[MIME_MAX_TYPE]; /* Type name ("png", "postscript", etc.) */
+ mime_magic_t *rules; // Rules used to detect this type
+ int priority; // Priority of this type
+ char super[MIME_MAX_SUPER], // Super-type name ("image", "application", etc.)
+ type[MIME_MAX_TYPE]; // Type name ("png", "postscript", etc.)
} mime_type_t;
-typedef struct _mime_filter_s /**** MIME Conversion Filter Data ****/
+typedef struct _mime_filter_s // MIME Conversion Filter Data
{
- mime_type_t *src, /* Source type */
- *dst; /* Destination type */
- int cost; /* Relative cost */
- char filter[MIME_MAX_FILTER];/* Filter program to use */
- size_t maxsize; /* Maximum file size for this filter */
+ mime_type_t *src, // Source type
+ *dst; // Destination type
+ int cost; // Relative cost
+ char filter[MIME_MAX_FILTER];// Filter program to use
+ size_t maxsize; // Maximum file size for this filter
} mime_filter_t;
typedef void (*mime_error_cb_t)(void *ctx, const char *message);
-typedef struct _mime_s /**** MIME Database ****/
+typedef struct _mime_s // MIME Database
{
- cups_array_t *types; /* File types */
- cups_array_t *filters; /* Type conversion filters */
- cups_array_t *srcs; /* Filters sorted by source type */
- mime_error_cb_t error_cb; /* Error message callback */
- void *error_ctx; /* Pointer for callback */
- cups_rwlock_t lock; /* Read/write lock for guarding data for background updates */
+ cups_array_t *types; // File types
+ cups_array_t *filters; // Type conversion filters
+ cups_array_t *srcs; // Filters sorted by source type
+ mime_error_cb_t error_cb; // Error message callback
+ void *error_ctx; // Pointer for callback
+ cups_rwlock_t lock; // Read/write lock for guarding data for background updates
} mime_t;
-/*
- * Functions...
- */
+//
+// Functions...
+//
+
+extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst, int cost, const char *filter);
+extern mime_type_t *mimeAddType(mime_t *mime, const char *super, const char *type);
+extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
extern void mimeDelete(mime_t *mime);
-extern mime_t *mimeNew(void) _CUPS_API_1_5;
+extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter);
+extern void mimeDeleteType(mime_t *mime, mime_type_t *mt);
+
+extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname, const char *filename, int *compression);
+extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst, int *cost);
+extern cups_array_t *mimeFilter2(mime_t *mime, mime_type_t *src, size_t srcsize, mime_type_t *dst, int *cost);
+extern mime_filter_t *mimeFilterLookup(mime_t *mime, mime_type_t *src, mime_type_t *dst);
+extern mime_filter_t *mimeFirstFilter(mime_t *mime);
+extern mime_type_t *mimeFirstType(mime_t *mime);
+
extern mime_t *mimeLoad(const char *pathname, const char *filterpath);
-extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname,
- const char *filterpath);
+extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname, const char *filterpath);
extern mime_t *mimeLoadTypes(mime_t *mime, const char *pathname);
-extern mime_type_t *mimeAddType(mime_t *mime, const char *super,
- const char *type);
-extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
-extern void mimeDeleteType(mime_t *mime, mime_type_t *mt);
-extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname,
- const char *filename, int *compression);
-extern mime_type_t *mimeFirstType(mime_t *mime);
+extern mime_t *mimeNew(void);
+extern mime_filter_t *mimeNextFilter(mime_t *mime);
extern mime_type_t *mimeNextType(mime_t *mime);
+extern int mimeNumFilters(mime_t *mime);
extern int mimeNumTypes(mime_t *mime);
-extern mime_type_t *mimeType(mime_t *mime, const char *super,
- const char *type);
-extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src,
- mime_type_t *dst, int cost,
- const char *filter);
-extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter);
-extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src,
- mime_type_t *dst, int *cost);
-extern cups_array_t *mimeFilter2(mime_t *mime, mime_type_t *src,
- size_t srcsize, mime_type_t *dst,
- int *cost);
-extern mime_filter_t *mimeFilterLookup(mime_t *mime, mime_type_t *src,
- mime_type_t *dst);
-extern mime_filter_t *mimeFirstFilter(mime_t *mime);
-extern mime_filter_t *mimeNextFilter(mime_t *mime);
-extern int mimeNumFilters(mime_t *mime);
-extern void mimeSetErrorCallback(mime_t *mime, mime_error_cb_t cb,
- void *context) _CUPS_API_1_5;
+extern void mimeSetErrorCallback(mime_t *mime, mime_error_cb_t cb, void *context);
+
+extern mime_type_t *mimeType(mime_t *mime, const char *super, const char *type);
+
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_MIME_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_MIME_H_
cancel.o: cancel.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
cupsaccept.o: cupsaccept.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
cupsctl.o: cupsctl.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/adminutil.h
cupstestppd.o: cupstestppd.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/thread.h ../cups/dir.h ../cups/ppd-private.h ../cups/ppd.h \
../cups/raster.h
lp.o: lp.c ../cups/cups-private.h ../cups/string-private.h ../config.h \
- ../cups/versioning.h ../cups/debug-internal.h ../cups/debug-private.h \
+ ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
lpadmin.o: lpadmin.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h
lpinfo.o: lpinfo.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/adminutil.h
lpmove.o: lpmove.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h
lpoptions.o: lpoptions.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
../cups/thread.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h
lpstat.o: lpstat.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
ippevepcl.o: ippevepcl.c ippevecommon.h ../cups/cups.h ../cups/file.h \
- ../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/base.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/raster.h \
../cups/string-private.h ../config.h dither.h
ippeveprinter.o: ippeveprinter.c ../cups/cups-private.h \
- ../cups/string-private.h ../config.h ../cups/versioning.h \
+ ../cups/string-private.h ../config.h ../cups/base.h \
../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/http.h \
../cups/array.h ../cups/language.h ../cups/pwg.h \
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
- ../cups/thread.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h \
- printer-png.h printer-lg-png.h printer-sm-png.h
+ ../cups/thread.h ../cups/dnssd.h printer-png.h printer-lg-png.h \
+ printer-sm-png.h
ippeveps.o: ippeveps.c ippevecommon.h ../cups/cups.h ../cups/file.h \
- ../cups/versioning.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
+ ../cups/base.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/raster.h \
../cups/string-private.h ../config.h ../cups/ppd-private.h \
../cups/ppd.h ../cups/pwg-private.h
ippfind.o: ippfind.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
- ../cups/thread.h
+ ../cups/thread.h ../cups/dnssd.h
ipptool.o: ipptool.c ../cups/cups-private.h ../cups/string-private.h \
- ../config.h ../cups/versioning.h ../cups/debug-internal.h \
+ ../config.h ../cups/base.h ../cups/debug-internal.h \
../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
../cups/file.h ../cups/ipp.h ../cups/http.h ../cups/array.h \
../cups/language.h ../cups/pwg.h ../cups/http-private.h \
\
\
../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
- ../cups/thread.h
+ ../cups/thread.h ../cups/raster-testpage.h ../cups/raster-private.h \
+ ../cups/raster.h