386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gsprops.h
CommitLineData
7d4b1503
WJ
1/* Copyright (C) 1991, 1992 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* gsprops.h */
21/* "Property list" definitions for Ghostscript */
22
23/*
24 * Several interfaces in Ghostscript use the idea of a "property list",
25 * essentially a dictionary with a fixed set of key names and known
26 * value types. A property list is represented by an array of structures
27 * with four components:
28 *
29 * - The name of the property;
30 *
31 * - The type of value provided (or expected);
32 *
33 * - The value itself;
34 *
35 * - An indication of whether the value was supplied, and if so,
36 * whether it was acceptable.
37 *
38 * Currently, property lists are only used to communicate parameter values
39 * to devices.
40 */
41
42/* Define the types of values. */
43typedef enum {
44 prt_int, /* (long) */
45 prt_float,
46 prt_bool,
47 prt_string,
48 prt_int_array, /* array of prt_int item */
49 prt_float_array, /* array of prt_float item */
50 prt_null
51} gs_prop_type;
52typedef int p_bool;
53/* Arrays and strings must represent their size explicitly. */
54typedef union gs_prop_value_s gs_prop_value;
55
56/* Define the type for property list items. */
57#ifndef gs_prop_item_DEFINED
58# define gs_prop_item_DEFINED
59typedef struct gs_prop_item_s gs_prop_item;
60#endif
61
62/* Define the union of all possible value types. */
63union gs_prop_value_s {
64 long i;
65 float f;
66 p_bool b;
67 struct {
68 ushort size;
69 union {
70 char *s;
71 gs_prop_item *v;
72 } p;
73 } a;
74};
75
76/* Define the status of an entry in a property list. */
77typedef enum {
78 pv_unspecified, /* no value specified */
79 pv_set, /* other explicit value */
80 /* Recipients return these codes */
81 pv_OK,
82 pv_unknown, /* unknown key */
83 pv_typecheck,
84 pv_rangecheck,
85 pv_limitcheck
86} gs_prop_status;
87
88/* Finally, define the structure of a property item. */
89struct gs_prop_item_s {
90 const char *pname;
91 int name_size; /* -1 means use strlen */
92 gs_prop_type type;
93 gs_prop_status status;
94 gs_prop_value value;
95};
96#define gs_prop_item_s_DEFINED
97
98/*
99 * It is often convenient to construct a property list template statically,
100 * and just copy it and fill in the values. Here are some macros useful
101 * for doing this. The format is
102 * prop_item xyz_props[] = {
103 * prop_def("name1", prt1),
104 * prop_def("name2", prt2),
105 * ...
106 * };
107 * or
108 * typedef struct {
109 * prop_item name1, name2, ...;
110 * xyz_props_struct;
111 * xyz_props_struct xyz_props = {
112 * prop_def("name1", prt1),
113 * prop_def("name2", prt2),
114 * ...
115 * };
116 * For slots that form part of an array, use prop_slot instead of prop_def.
117 */
118#define prop_def(name, type) { name, -1, type, pv_set }
119#define prop_int { 0, -1, prt_int, pv_set }
120#define prop_float { 0, -1, prt_float, pv_set }