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