1 /* options.h 2 * 3 * Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com> 4 * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net> 5 * 6 * This file is part of foomatic-rip. 7 * 8 * Foomatic-rip is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * Foomatic-rip is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the 20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 * Boston, MA 02111-1307, USA. 22 */ 23 24 #ifndef options_h 25 #define options_h 26 27 28 #include <stddef.h> 29 #include <regex.h> 30 #include "util.h" 31 32 /* Option types */ 33 #define TYPE_NONE 0 34 #define TYPE_ENUM 1 35 #define TYPE_PICKMANY 2 36 #define TYPE_BOOL 3 37 #define TYPE_INT 4 38 #define TYPE_FLOAT 5 39 #define TYPE_STRING 6 40 #define TYPE_PASSWORD 7 41 #define TYPE_CURVE 8 42 #define TYPE_INVCURVE 9 43 #define TYPE_PASSCODE 10 44 #define TYPE_POINTS 11 45 46 /* Sections */ 47 #define SECTION_ANYSETUP 1 48 #define SECTION_PAGESETUP 2 49 #define SECTION_PROLOG 3 50 #define SECTION_DOCUMENTSETUP 4 51 #define SECTION_JCLSETUP 5 52 53 54 55 typedef struct choice_s { 56 char value [128]; 57 char text [128]; 58 char command[65536]; 59 struct choice_s *next; 60 } choice_t; 61 62 /* Custom option parameter */ 63 typedef struct param_s { 64 char name [128]; 65 char text [128]; /* formerly comment, changed to 'text' to 66 be consistent with cups */ 67 int order; 68 69 int type; 70 char min[20], max[20]; /* contents depend on 'type' */ 71 72 regex_t *allowedchars; 73 regex_t *allowedregexp; 74 75 struct param_s *next; 76 } param_t; 77 78 /* Option */ 79 typedef struct option_s { 80 char name [128]; 81 char text [128]; 82 char varname [128]; /* clean version of 'name' (no spaces etc.) */ 83 int type; 84 int style; 85 char spot; 86 double order; 87 int section; 88 89 int notfirst; /* TODO remove */ 90 91 choice_t *choicelist; 92 93 /* Foomatic PPD extensions */ 94 char *proto; /* *FoomaticRIPOptionPrototype: if this is set 95 it will be used with only the first option 96 in paramlist (there should be only one) */ 97 param_t *foomatic_param; 98 99 /* CUPS custom options */ 100 char *custom_command; /* *CustomFoo */ 101 param_t *paramlist; /* for custom values, sorted by stack order */ 102 size_t param_count; 103 104 struct value_s *valuelist; 105 106 struct option_s *next; 107 struct option_s *next_by_order; 108 } option_t; 109 110 111 /* A value for an option */ 112 typedef struct value_s { 113 int optionset; 114 char *value; 115 option_t *fromoption; /* This is set when this value is set by a composite */ 116 struct value_s *next; 117 } value_t; 118 119 120 extern option_t *optionlist; 121 extern option_t *optionlist_sorted_by_order; 122 123 extern char jclbegin[256]; 124 extern char jcltointerpreter[256]; 125 extern char jclend[256]; 126 extern char jclprefix[256]; 127 128 extern char cmd[4096]; 129 extern char cmd_pdf[4096]; 130 131 132 int option_is_composite(option_t *opt); 133 int option_is_ps_command(option_t *opt); 134 int option_is_jcl_arg(option_t *opt); 135 int option_is_commandline_arg(option_t *opt); 136 137 138 int option_get_section(option_t *opt); /* TODO deprecated */ 139 140 /* handles ANYSETUP (for (PAGE|DOCUMENT)SETUP) */ 141 int option_is_in_section(option_t *opt, int section); 142 143 void options_init(); 144 void options_free(); 145 146 size_t option_count(); 147 option_t *find_option(const char *name); 148 149 void read_ppd_file(const char *filename); 150 151 int ppd_supports_pdf(); 152 153 154 int option_set_value(option_t *opt, int optset, const char *value); 155 const char * option_get_value(option_t *opt, int optset); 156 157 /* section == -1 for all sections */ 158 int option_get_command(dstr_t *cmd, option_t *opt, int optset, int section); 159 160 int option_accepts_value(option_t *opt, const char *value); 161 int option_has_choice(option_t *opt, const char *choice); 162 int option_is_custom_value(option_t *opt, const char *value); 163 164 165 const char * optionset_name(int idx); 166 int optionset(const char * name); 167 168 void optionset_copy_values(int src_optset, int dest_optset); 169 int optionset_equal(int optset1, int optset2, int exceptPS); 170 void optionset_delete_values(int optionset); 171 172 void append_prolog_section(dstr_t *str, int optset, int comments); 173 void append_setup_section(dstr_t *str, int optset, int comments); 174 void append_page_setup_section(dstr_t *str, int optset, int comments); 175 int build_commandline(int optset, dstr_t *cmdline, int pdfcmdline); 176 177 void set_options_for_page(int optset, int page); 178 char *get_icc_profile_for_qualifier(const char **qualifier); 179 const char **get_ppd_qualifier(void); 180 181 #endif 182 183