home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GSPROPS.H < prev    next >
C/C++ Source or Header  |  1992-09-08  |  4KB  |  122 lines

  1. /* Copyright (C) 1991, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  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. */
  43. typedef 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;
  52. typedef int p_bool;
  53. /* Arrays and strings must represent their size explicitly. */
  54. typedef 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
  59. typedef struct gs_prop_item_s gs_prop_item;
  60. extern const uint gs_prop_item_sizeof;
  61. #endif
  62.  
  63. /* Define the union of all possible value types. */
  64. union gs_prop_value_s {
  65.     long i;
  66.     float f;
  67.     p_bool b;
  68.     struct {
  69.         ushort size;
  70.         union {
  71.             char *s;
  72.             gs_prop_item *v;
  73.         } p;
  74.     } a;
  75. };
  76.  
  77. /* Define the status of an entry in a property list. */
  78. typedef enum {
  79.     pv_unspecified,            /* no value specified */
  80.     pv_set,                /* other explicit value */
  81.         /* Recipients return these codes */
  82.     pv_OK,
  83.     pv_unknown,            /* unknown key */
  84.     pv_typecheck,
  85.     pv_rangecheck,
  86.     pv_limitcheck
  87. } gs_prop_status;
  88.  
  89. /* Finally, define the structure of a property item. */
  90. struct gs_prop_item_s {
  91.     const char *pname;
  92.     int name_size;            /* -1 means use strlen */
  93.     gs_prop_type type;
  94.     gs_prop_status status;
  95.     gs_prop_value value;
  96. };
  97. #define gs_prop_item_s_DEFINED
  98.  
  99. /*
  100.  * It is often convenient to construct a property list template statically,
  101.  * and just copy it and fill in the values.  Here are some macros useful
  102.  * for doing this.  The format is
  103.  *    prop_item xyz_props[] = {
  104.  *        prop_def("name1", prt1),
  105.  *        prop_def("name2", prt2),
  106.  *        ...
  107.  *    };
  108.  * or
  109.  *    typedef struct {
  110.  *        prop_item name1, name2, ...;
  111.  *    xyz_props_struct;
  112.  *    xyz_props_struct xyz_props = {
  113.  *        prop_def("name1", prt1),
  114.  *        prop_def("name2", prt2),
  115.  *        ...
  116.  *    };
  117.  * For slots that form part of an array, use prop_slot instead of prop_def.
  118.  */
  119. #define prop_def(name, type) { name, -1, type, pv_set }
  120. #define prop_int { 0, -1, prt_int, pv_set }
  121. #define prop_float { 0, -1, prt_float, pv_set }
  122.