1/* 2 * "$Id: custom.c 11093 2013-07-03 20:48:42Z msweet $" 3 * 4 * PPD custom option routines for CUPS. 5 * 6 * Copyright 2007-2012 by Apple Inc. 7 * Copyright 1997-2006 by Easy Software Products, all rights reserved. 8 * 9 * These coded instructions, statements, and computer programs are the 10 * property of Apple Inc. and are protected by Federal copyright 11 * law. Distribution and use rights are outlined in the file "LICENSE.txt" 12 * which should have been included with this file. If this file is 13 * file is missing or damaged, see the license at "http://www.cups.org/". 14 * 15 * PostScript is a trademark of Adobe Systems, Inc. 16 * 17 * This code and any derivative of it may be used and distributed 18 * freely under the terms of the GNU General Public License when 19 * used with GNU Ghostscript or its derivatives. Use of the code 20 * (or any derivative of it) with software other than GNU 21 * GhostScript (or its derivatives) is governed by the CUPS license 22 * agreement. 23 * 24 * This file is subject to the Apple OS-Developed Software exception. 25 * 26 * Contents: 27 * 28 * ppdFindCustomOption() - Find a custom option. 29 * ppdFindCustomParam() - Find a parameter for a custom option. 30 * ppdFirstCustomParam() - Return the first parameter for a custom option. 31 * ppdNextCustomParam() - Return the next parameter for a custom option. 32 */ 33 34/* 35 * Include necessary headers. 36 */ 37 38#include "cups-private.h" 39 40 41/* 42 * 'ppdFindCustomOption()' - Find a custom option. 43 * 44 * @since CUPS 1.2/OS X 10.5@ 45 */ 46 47ppd_coption_t * /* O - Custom option or NULL */ 48ppdFindCustomOption(ppd_file_t *ppd, /* I - PPD file */ 49 const char *keyword)/* I - Custom option name */ 50{ 51 ppd_coption_t key; /* Custom option search key */ 52 53 54 if (!ppd) 55 return (NULL); 56 57 strlcpy(key.keyword, keyword, sizeof(key.keyword)); 58 return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key)); 59} 60 61 62/* 63 * 'ppdFindCustomParam()' - Find a parameter for a custom option. 64 * 65 * @since CUPS 1.2/OS X 10.5@ 66 */ 67 68ppd_cparam_t * /* O - Custom parameter or NULL */ 69ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */ 70 const char *name) /* I - Parameter name */ 71{ 72 ppd_cparam_t *param; /* Current custom parameter */ 73 74 75 if (!opt) 76 return (NULL); 77 78 for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params); 79 param; 80 param = (ppd_cparam_t *)cupsArrayNext(opt->params)) 81 if (!_cups_strcasecmp(param->name, name)) 82 break; 83 84 return (param); 85} 86 87 88/* 89 * 'ppdFirstCustomParam()' - Return the first parameter for a custom option. 90 * 91 * @since CUPS 1.2/OS X 10.5@ 92 */ 93 94ppd_cparam_t * /* O - Custom parameter or NULL */ 95ppdFirstCustomParam(ppd_coption_t *opt) /* I - Custom option */ 96{ 97 if (!opt) 98 return (NULL); 99 100 return ((ppd_cparam_t *)cupsArrayFirst(opt->params)); 101} 102 103 104/* 105 * 'ppdNextCustomParam()' - Return the next parameter for a custom option. 106 * 107 * @since CUPS 1.2/OS X 10.5@ 108 */ 109 110ppd_cparam_t * /* O - Custom parameter or NULL */ 111ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */ 112{ 113 if (!opt) 114 return (NULL); 115 116 return ((ppd_cparam_t *)cupsArrayNext(opt->params)); 117} 118 119 120/* 121 * End of "$Id: custom.c 11093 2013-07-03 20:48:42Z msweet $". 122 */ 123