From: Michael Sweet Date: Tue, 4 Jul 2017 16:17:37 +0000 (-0400) Subject: Implement "default" command (show_default) function for media and other options. X-Git-Tag: v2.2.5~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=534dfe8e941c50491fed4304dfaa38cdf4b1fbe1;p=thirdparty%2Fcups.git Implement "default" command (show_default) function for media and other options. --- diff --git a/cups/testdest.c b/cups/testdest.c index 4e2cbed502..a98d4092ca 100644 --- a/cups/testdest.c +++ b/cups/testdest.c @@ -1,7 +1,7 @@ /* * CUPS destination API test program for CUPS. * - * Copyright 2012-2016 by Apple Inc. + * Copyright 2012-2017 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -463,10 +463,37 @@ show_default(http_t *http, /* I - Connection to destination */ cups_dinfo_t *dinfo, /* I - Destination information */ const char *option) /* I - Option */ { - (void)http; - (void)dest; - (void)dinfo; - (void)option; + if (!strcmp(option, "media")) + { + /* + * Show default media option... + */ + + cups_size_t size; /* Media size information */ + + if (cupsGetDestMediaDefault(http, dest, dinfo, CUPS_MEDIA_FLAGS_DEFAULT, &size)) + printf("%s (%.2fx%.2fmm, margins=[%.2f %.2f %.2f %.2f])\n", size.media, size.width * 0.01, size.length * 0.01, size.left * 0.01, size.bottom * 0.01, size.right * 0.01, size.top * 0.01); + else + puts("FAILED"); + } + else + { + /* + * Show default other option... + */ + + ipp_attribute_t *defattr; /* Default attribute */ + + if ((defattr = cupsFindDestDefault(http, dest, dinfo, option)) != NULL) + { + char value[1024]; /* Value of default attribute */ + + ippAttributeString(defattr, value, sizeof(value)); + puts(value); + } + else + puts("FAILED"); + } }