2c0fc5c13f674e8cc1885805185d0b901d1f1379
[pspp] / src / output / options.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2007, 2009, 2010 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef OUTPUT_OPTIONS_H
18 #define OUTPUT_OPTIONS_H 1
19
20 /* Helper functions for driver option parsing. */
21
22 #include <stdbool.h>
23 #include "libpspp/compiler.h"
24 #include "libpspp/string-map.h"
25 #include "libpspp/string-array.h"
26
27 struct output_driver;
28 struct string_map;
29
30 struct driver_options
31   {
32     const char *driver_name;
33     struct string_map map;
34     struct string_array garbage;
35   };
36
37 /* An option being parsed. */
38 struct driver_option
39   {
40     const char *driver_name;    /* Driver's name, for use in error messages. */
41     const char *name;           /* Option name, for use in error messages.  */
42     const char *value;          /* Value supplied by user (NULL if none). */
43     const char *default_value;  /* Default value supplied by driver. */
44   };
45
46 struct driver_option driver_option_get (struct driver_options *,
47                                         const char *name,
48                                         const char *default_value);
49
50 void parse_paper_size (struct driver_option, int *h, int *v);
51 bool parse_boolean (struct driver_option);
52 int parse_enum (struct driver_option, ...) SENTINEL(0);
53 int parse_int (struct driver_option, int min_value, int max_value);
54 int parse_dimension (struct driver_option);
55 char *parse_string (struct driver_option);
56 char *parse_chart_file_name (struct driver_option);
57
58 struct cell_color parse_color (struct driver_option);
59 bool parse_color__ (const char *, struct cell_color *);
60
61 #endif /* output/options.h */