From: Michael R Sweet Date: Wed, 2 Oct 2019 19:44:30 +0000 (-0400) Subject: Add missing file. X-Git-Tag: v2.3.1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6936a1222dce91c68376fed799d5d18e6b9276cf;p=thirdparty%2Fcups.git Add missing file. --- diff --git a/.gitignore b/.gitignore index dd9be570a7..2a8d1e42ac 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ cups/testppd cups/testpwg cups/testraster cups/testsnmp +cups/testthreads cups/tlscheck desktop/cups.desktop doc/index.html diff --git a/cups/testthreads.c b/cups/testthreads.c new file mode 100644 index 0000000000..e447a6eb5f --- /dev/null +++ b/cups/testthreads.c @@ -0,0 +1,266 @@ +/* + * Threaded test program for CUPS. + * + * Copyright © 2012-2019 by Apple Inc. + * + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. + */ + +/* + * Include necessary headers... + */ + +#include +#include +#include +#include + + +/* + * Local functions... + */ + +static int enum_dests_cb(void *_name, unsigned flags, cups_dest_t *dest); +static void *run_query(cups_dest_t *dest); +static void show_supported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value); + + +/* + * 'main()' - Main entry. + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ +{ + /* + * Go through all the available destinations to find the requested one... + */ + + (void)argc; + + cupsEnumDests(CUPS_DEST_FLAGS_NONE, -1, NULL, 0, 0, enum_dests_cb, argv[1]); + + return (0); +} + + +/* + * 'enum_dests_cb()' - Destination enumeration function... + */ + +static int /* O - 1 to continue, 0 to stop */ +enum_dests_cb(void *_name, /* I - Printer name, if any */ + unsigned flags, /* I - Enumeration flags */ + cups_dest_t *dest) /* I - Found destination */ +{ + const char *name = (const char *)_name; + /* Printer name */ + cups_dest_t *cdest; /* Copied destination */ + + + /* + * If a name was specified, compare it... + */ + + if (name && strcasecmp(name, dest->name)) + return (1); /* Continue */ + + /* + * Copy the destination and run the query on a separate thread... + */ + + cupsCopyDest(dest, 0, &cdest); + _cupsThreadWait(_cupsThreadCreate((_cups_thread_func_t)run_query, cdest)); + + cupsFreeDests(1, cdest); + + /* + * Continue if no name was specified or the name matches... + */ + + return (!name || !strcasecmp(name, dest->name)); +} + + +/* + * 'run_query()' - Query printer capabilities on a separate thread. + */ + +static void * /* O - Return value (not used) */ +run_query(cups_dest_t *dest) /* I - Destination to query */ +{ + http_t *http; /* Connection to destination */ + cups_dinfo_t *dinfo; /* Destination info */ + unsigned dflags = CUPS_DEST_FLAGS_NONE; + /* Destination flags */ + + + if ((http = cupsConnectDest(dest, dflags, 300, NULL, NULL, 0, NULL, NULL)) == NULL) + { + printf("testthreads: Unable to connect to destination \"%s\": %s\n", dest->name, cupsLastErrorString()); + return (NULL); + } + + if ((dinfo = cupsCopyDestInfo(http, dest)) == NULL) + { + printf("testdest: Unable to get information for destination \"%s\": %s\n", dest->name, cupsLastErrorString()); + return (NULL); + } + + printf("\n%s:\n", dest->name); + + show_supported(http, dest, dinfo, NULL, NULL); + + return (NULL); +} + + + +/* + * 'show_supported()' - Show supported options, values, etc. + */ + +static void +show_supported(http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + const char *option, /* I - Option, if any */ + const char *value) /* I - Value, if any */ +{ + ipp_attribute_t *attr; /* Attribute */ + int i, /* Looping var */ + count; /* Number of values */ + + + if (!option) + { + attr = cupsFindDestSupported(http, dest, dinfo, "job-creation-attributes"); + if (attr) + { + count = ippGetCount(attr); + for (i = 0; i < count; i ++) + show_supported(http, dest, dinfo, ippGetString(attr, i, NULL), NULL); + } + else + { + static const char * const options[] = + { /* List of standard options */ + CUPS_COPIES, + CUPS_FINISHINGS, + CUPS_MEDIA, + CUPS_NUMBER_UP, + CUPS_ORIENTATION, + CUPS_PRINT_COLOR_MODE, + CUPS_PRINT_QUALITY, + CUPS_SIDES + }; + + puts(" No job-creation-attributes-supported attribute, probing instead."); + + for (i = 0; i < (int)(sizeof(options) / sizeof(options[0])); i ++) + if (cupsCheckDestSupported(http, dest, dinfo, options[i], NULL)) + show_supported(http, dest, dinfo, options[i], NULL); + } + } + else if (!value) + { + printf(" %s (%s - %s)\n", option, cupsLocalizeDestOption(http, dest, dinfo, option), cupsCheckDestSupported(http, dest, dinfo, option, NULL) ? "supported" : "not-supported"); + + if ((attr = cupsFindDestSupported(http, dest, dinfo, option)) != NULL) + { + count = ippGetCount(attr); + + switch (ippGetValueTag(attr)) + { + case IPP_TAG_INTEGER : + for (i = 0; i < count; i ++) + printf(" %d\n", ippGetInteger(attr, i)); + break; + + case IPP_TAG_ENUM : + for (i = 0; i < count; i ++) + { + int val = ippGetInteger(attr, i); + char valstr[256]; + + snprintf(valstr, sizeof(valstr), "%d", val); + printf(" %s (%s)\n", ippEnumString(option, ippGetInteger(attr, i)), cupsLocalizeDestValue(http, dest, dinfo, option, valstr)); + } + break; + + case IPP_TAG_RANGE : + for (i = 0; i < count; i ++) + { + int upper, lower = ippGetRange(attr, i, &upper); + + printf(" %d-%d\n", lower, upper); + } + break; + + case IPP_TAG_RESOLUTION : + for (i = 0; i < count; i ++) + { + int xres, yres; + ipp_res_t units; + xres = ippGetResolution(attr, i, &yres, &units); + + if (xres == yres) + printf(" %d%s\n", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + else + printf(" %dx%d%s\n", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + } + break; + + case IPP_TAG_KEYWORD : + for (i = 0; i < count; i ++) + printf(" %s (%s)\n", ippGetString(attr, i, NULL), cupsLocalizeDestValue(http, dest, dinfo, option, ippGetString(attr, i, NULL))); + break; + + case IPP_TAG_TEXTLANG : + case IPP_TAG_NAMELANG : + case IPP_TAG_TEXT : + case IPP_TAG_NAME : + case IPP_TAG_URI : + case IPP_TAG_URISCHEME : + case IPP_TAG_CHARSET : + case IPP_TAG_LANGUAGE : + case IPP_TAG_MIMETYPE : + for (i = 0; i < count; i ++) + printf(" %s\n", ippGetString(attr, i, NULL)); + break; + + case IPP_TAG_STRING : + for (i = 0; i < count; i ++) + { + int j, len; + unsigned char *data = ippGetOctetString(attr, i, &len); + + fputs(" ", stdout); + for (j = 0; j < len; j ++) + { + if (data[j] < ' ' || data[j] >= 0x7f) + printf("<%02X>", data[j]); + else + putchar(data[j]); + } + putchar('\n'); + } + break; + + case IPP_TAG_BOOLEAN : + break; + + default : + printf(" %s\n", ippTagString(ippGetValueTag(attr))); + break; + } + } + + } + else if (cupsCheckDestSupported(http, dest, dinfo, option, value)) + puts("YES"); + else + puts("NO"); +} diff --git a/xcode/CUPS.xcodeproj/project.pbxproj b/xcode/CUPS.xcodeproj/project.pbxproj index a4f6b65832..a5a4767676 100644 --- a/xcode/CUPS.xcodeproj/project.pbxproj +++ b/xcode/CUPS.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 271284C31CC11FA500E517C7 /* PBXTargetDependency */, 271284C51CC11FA500E517C7 /* PBXTargetDependency */, 271284C71CC11FA500E517C7 /* PBXTargetDependency */, + 274770E42345347D0089BC31 /* PBXTargetDependency */, 271284C91CC11FA500E517C7 /* PBXTargetDependency */, 726AD704135E8AA1002C930D /* PBXTargetDependency */, 2767FC5419267469000F61D3 /* PBXTargetDependency */, @@ -333,6 +334,12 @@ 273B1ECA226B420C00428143 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; }; 273B1ECD226B421E00428143 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; }; 273BF6C71333B5370022CAAB /* testcups.c in Sources */ = {isa = PBXBuildFile; fileRef = 273BF6C61333B5370022CAAB /* testcups.c */; }; + 274770D72345342B0089BC31 /* libcups_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 72A4332F155844CF002E172D /* libcups_static.a */; }; + 274770D82345342B0089BC31 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E5136B64AF00836530 /* CoreFoundation.framework */; }; + 274770D92345342B0089BC31 /* Kerberos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E6136B64B000836530 /* Kerberos.framework */; }; + 274770DA2345342B0089BC31 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E7136B64B000836530 /* Security.framework */; }; + 274770DB2345342B0089BC31 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E8136B64B000836530 /* SystemConfiguration.framework */; }; + 274770E2234534660089BC31 /* testthreads.c in Sources */ = {isa = PBXBuildFile; fileRef = 274770E1234534660089BC31 /* testthreads.c */; }; 274FF5D913332CC700317ECB /* cups-driverd.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 274FF5D613332CC700317ECB /* cups-driverd.cxx */; }; 274FF5DA13332CC700317ECB /* util.c in Sources */ = {isa = PBXBuildFile; fileRef = 274FF5D713332CC700317ECB /* util.c */; }; 274FF5DD13332D0600317ECB /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; }; @@ -1661,6 +1668,20 @@ remoteGlobalIDString = 273BF6BC1333B5000022CAAB; remoteInfo = testcups; }; + 274770D32345342B0089BC31 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 72BF96371333042100B1EAD7 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 274FF6891333B1C400317ECB; + remoteInfo = libcups_static; + }; + 274770E32345347D0089BC31 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 72BF96371333042100B1EAD7 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 274770D12345342B0089BC31; + remoteInfo = testthreads; + }; 274FF5DB13332CF900317ECB /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 72BF96371333042100B1EAD7 /* Project object */; @@ -2676,6 +2697,15 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + 274770DC2345342B0089BC31 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 274FF5CA13332B1F00317ECB /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -3210,6 +3240,8 @@ 274561471F545B2E000378E4 /* cupspm.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = cupspm.md; path = ../cups/cupspm.md; sourceTree = ""; }; 274561481F545B2E000378E4 /* api-admin.header */ = {isa = PBXFileReference; lastKnownFileType = text; name = "api-admin.header"; path = "../cups/api-admin.header"; sourceTree = ""; }; 274561491F545B2E000378E4 /* api-admin.shtml */ = {isa = PBXFileReference; lastKnownFileType = text.html.other; name = "api-admin.shtml"; path = "../cups/api-admin.shtml"; sourceTree = ""; }; + 274770E02345342B0089BC31 /* testthreads */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testthreads; sourceTree = BUILT_PRODUCTS_DIR; }; + 274770E1234534660089BC31 /* testthreads.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testthreads.c; path = ../cups/testthreads.c; sourceTree = ""; }; 274FF5CC13332B1F00317ECB /* cups-driverd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cups-driverd"; sourceTree = BUILT_PRODUCTS_DIR; }; 274FF5D613332CC700317ECB /* cups-driverd.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "cups-driverd.cxx"; path = "../scheduler/cups-driverd.cxx"; sourceTree = ""; }; 274FF5D713332CC700317ECB /* util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = util.c; path = ../scheduler/util.c; sourceTree = ""; }; @@ -3972,6 +4004,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 274770D62345342B0089BC31 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 274770D72345342B0089BC31 /* libcups_static.a in Frameworks */, + 274770D82345342B0089BC31 /* CoreFoundation.framework in Frameworks */, + 274770D92345342B0089BC31 /* Kerberos.framework in Frameworks */, + 274770DA2345342B0089BC31 /* Security.framework in Frameworks */, + 274770DB2345342B0089BC31 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 274FF5C913332B1F00317ECB /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -4699,6 +4743,7 @@ 727EF04F192E3602001EF690 /* testsub.c */, 724FA65D1CC0389F0092477B /* testsupplies.c */, 727EF03F192E3498001EF690 /* testtemplate.c */, + 274770E1234534660089BC31 /* testthreads.c */, 271286681CC130BD00E517C7 /* tlscheck.c */, ); name = tests; @@ -4888,6 +4933,7 @@ 729181BE201155C1005E7560 /* testclient */, 273B1EAA226B3E4800428143 /* ippevepcl */, 273B1EBB226B3E5200428143 /* ippeveps */, + 274770E02345342B0089BC31 /* testthreads */, ); name = Products; sourceTree = ""; @@ -6120,6 +6166,24 @@ productReference = 273BF6BD1333B5000022CAAB /* testcups */; productType = "com.apple.product-type.tool"; }; + 274770D12345342B0089BC31 /* testthreads */ = { + isa = PBXNativeTarget; + buildConfigurationList = 274770DD2345342B0089BC31 /* Build configuration list for PBXNativeTarget "testthreads" */; + buildPhases = ( + 274770D42345342B0089BC31 /* Sources */, + 274770D62345342B0089BC31 /* Frameworks */, + 274770DC2345342B0089BC31 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 274770D22345342B0089BC31 /* PBXTargetDependency */, + ); + name = testthreads; + productName = testmime; + productReference = 274770E02345342B0089BC31 /* testthreads */; + productType = "com.apple.product-type.tool"; + }; 274FF5CB13332B1F00317ECB /* cups-driverd */ = { isa = PBXNativeTarget; buildConfigurationList = 274FF5D213332B1F00317ECB /* Build configuration list for PBXNativeTarget "cups-driverd" */; @@ -7355,6 +7419,7 @@ 724FA6BF1CC0395A0092477B /* testtemplate */, 271286571CC1309000E517C7 /* tlscheck */, 7243795A1333FF1D009631B9 /* usb */, + 274770D12345342B0089BC31 /* testthreads */, ); }; /* End PBXProject section */ @@ -7702,6 +7767,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 274770D42345342B0089BC31 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 274770E2234534660089BC31 /* testthreads.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 274FF5C813332B1F00317ECB /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -8941,6 +9014,16 @@ target = 273BF6BC1333B5000022CAAB /* testcups */; targetProxy = 273BF6DD1333B6370022CAAB /* PBXContainerItemProxy */; }; + 274770D22345342B0089BC31 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 274FF6891333B1C400317ECB /* libcups_static */; + targetProxy = 274770D32345342B0089BC31 /* PBXContainerItemProxy */; + }; + 274770E42345347D0089BC31 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 274770D12345342B0089BC31 /* testthreads */; + targetProxy = 274770E32345347D0089BC31 /* PBXContainerItemProxy */; + }; 274FF5DC13332CF900317ECB /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72220EAD1333047D00FCA411 /* libcups */; @@ -10207,6 +10290,24 @@ }; name = Release; }; + 274770DE2345342B0089BC31 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "-"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 274770DF2345342B0089BC31 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "-"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; 274FF5D313332B1F00317ECB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -11960,6 +12061,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 274770DD2345342B0089BC31 /* Build configuration list for PBXNativeTarget "testthreads" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 274770DE2345342B0089BC31 /* Debug */, + 274770DF2345342B0089BC31 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 274FF5D213332B1F00317ECB /* Build configuration list for PBXNativeTarget "cups-driverd" */ = { isa = XCConfigurationList; buildConfigurations = (