Home | History | Annotate | Download | only in X11
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 /* $XConsortium: Xresource.h,v 1.37 94/04/17 20:21:52 rws Exp $ */
     26 
     27 /***********************************************************
     28 
     29 Copyright (c) 1987, 1988  X Consortium
     30 
     31 Permission is hereby granted, free of charge, to any person obtaining a copy
     32 of this software and associated documentation files (the "Software"), to deal
     33 in the Software without restriction, including without limitation the rights
     34 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     35 copies of the Software, and to permit persons to whom the Software is
     36 furnished to do so, subject to the following conditions:
     37 
     38 The above copyright notice and this permission notice shall be included in
     39 all copies or substantial portions of the Software.
     40 
     41 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     42 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     43 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     44 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     45 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     46 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     47 
     48 Except as contained in this notice, the name of the X Consortium shall not be
     49 used in advertising or otherwise to promote the sale, use or other dealings
     50 in this Software without prior written authorization from the X Consortium.
     51 
     52 
     53 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
     54 
     55                         All Rights Reserved
     56 
     57 Permission to use, copy, modify, and distribute this software and its
     58 documentation for any purpose and without fee is hereby granted,
     59 provided that the above copyright notice appear in all copies and that
     60 both that copyright notice and this permission notice appear in
     61 supporting documentation, and that the name of Digital not be
     62 used in advertising or publicity pertaining to distribution of the
     63 software without specific, written prior permission.
     64 
     65 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     66 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     67 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     68 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     69 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     70 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     71 SOFTWARE.
     72 
     73 ******************************************************************/
     74 
     75 #ifndef _XRESOURCE_H_
     76 #define _XRESOURCE_H_
     77 
     78 /* You must include <X11/Xlib.h> before including this file */
     79 
     80 /****************************************************************
     81  ****************************************************************
     82  ***                                                          ***
     83  ***                                                          ***
     84  ***          X Resource Manager Intrinsics                   ***
     85  ***                                                          ***
     86  ***                                                          ***
     87  ****************************************************************
     88  ****************************************************************/
     89 
     90 _XFUNCPROTOBEGIN
     91 
     92 /****************************************************************
     93  *
     94  * Memory Management
     95  *
     96  ****************************************************************/
     97 
     98 extern char *Xpermalloc(
     99 #if NeedFunctionPrototypes
    100     unsigned int	/* size */
    101 #endif
    102 );
    103 
    104 /****************************************************************
    105  *
    106  * Quark Management
    107  *
    108  ****************************************************************/
    109 
    110 typedef int     XrmQuark, *XrmQuarkList;
    111 #define NULLQUARK ((XrmQuark) 0)
    112 
    113 typedef char *XrmString;
    114 #define NULLSTRING ((XrmString) 0)
    115 
    116 /* find quark for string, create new quark if none already exists */
    117 extern XrmQuark XrmStringToQuark(
    118 #if NeedFunctionPrototypes
    119     _Xconst char* 	/* string */
    120 #endif
    121 );
    122 
    123 extern XrmQuark XrmPermStringToQuark(
    124 #if NeedFunctionPrototypes
    125     _Xconst char* 	/* string */
    126 #endif
    127 );
    128 
    129 /* find string for quark */
    130 extern XrmString XrmQuarkToString(
    131 #if NeedFunctionPrototypes
    132     XrmQuark 		/* quark */
    133 #endif
    134 );
    135 
    136 extern XrmQuark XrmUniqueQuark(
    137 #if NeedFunctionPrototypes
    138     void
    139 #endif
    140 );
    141 
    142 #define XrmStringsEqual(a1, a2) (strcmp(a1, a2) == 0)
    143 
    144 
    145 /****************************************************************
    146  *
    147  * Conversion of Strings to Lists
    148  *
    149  ****************************************************************/
    150 
    151 typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;
    152 
    153 extern void XrmStringToQuarkList(
    154 #if NeedFunctionPrototypes
    155     _Xconst char*	/* string */,
    156     XrmQuarkList	/* quarks_return */
    157 #endif
    158 );
    159 
    160 extern void XrmStringToBindingQuarkList(
    161 #if NeedFunctionPrototypes
    162     _Xconst char*	/* string */,
    163     XrmBindingList	/* bindings_return */,
    164     XrmQuarkList	/* quarks_return */
    165 #endif
    166 );
    167 
    168 /****************************************************************
    169  *
    170  * Name and Class lists.
    171  *
    172  ****************************************************************/
    173 
    174 typedef XrmQuark     XrmName;
    175 typedef XrmQuarkList XrmNameList;
    176 #define XrmNameToString(name)		XrmQuarkToString(name)
    177 #define XrmStringToName(string)		XrmStringToQuark(string)
    178 #define XrmStringToNameList(str, name)	XrmStringToQuarkList(str, name)
    179 
    180 typedef XrmQuark     XrmClass;
    181 typedef XrmQuarkList XrmClassList;
    182 #define XrmClassToString(c_class)	XrmQuarkToString(c_class)
    183 #define XrmStringToClass(c_class)	XrmStringToQuark(c_class)
    184 #define XrmStringToClassList(str,c_class) XrmStringToQuarkList(str, c_class)
    185 
    186 
    187 
    188 /****************************************************************
    189  *
    190  * Resource Representation Types and Values
    191  *
    192  ****************************************************************/
    193 
    194 typedef XrmQuark     XrmRepresentation;
    195 #define XrmStringToRepresentation(string)   XrmStringToQuark(string)
    196 #define	XrmRepresentationToString(type)   XrmQuarkToString(type)
    197 
    198 typedef struct {
    199     unsigned int    size;
    200     XPointer	    addr;
    201 } XrmValue, *XrmValuePtr;
    202 
    203 
    204 /****************************************************************
    205  *
    206  * Resource Manager Functions
    207  *
    208  ****************************************************************/
    209 
    210 typedef struct _XrmHashBucketRec *XrmHashBucket;
    211 typedef XrmHashBucket *XrmHashTable;
    212 typedef XrmHashTable XrmSearchList[];
    213 typedef struct _XrmHashBucketRec *XrmDatabase;
    214 
    215 
    216 extern void XrmDestroyDatabase(
    217 #if NeedFunctionPrototypes
    218     XrmDatabase		/* database */
    219 #endif
    220 );
    221 
    222 extern void XrmQPutResource(
    223 #if NeedFunctionPrototypes
    224     XrmDatabase*	/* database */,
    225     XrmBindingList	/* bindings */,
    226     XrmQuarkList	/* quarks */,
    227     XrmRepresentation	/* type */,
    228     XrmValue*		/* value */
    229 #endif
    230 );
    231 
    232 extern void XrmPutResource(
    233 #if NeedFunctionPrototypes
    234     XrmDatabase*	/* database */,
    235     _Xconst char*	/* specifier */,
    236     _Xconst char*	/* type */,
    237     XrmValue*		/* value */
    238 #endif
    239 );
    240 
    241 extern void XrmQPutStringResource(
    242 #if NeedFunctionPrototypes
    243     XrmDatabase*	/* database */,
    244     XrmBindingList      /* bindings */,
    245     XrmQuarkList	/* quarks */,
    246     _Xconst char*	/* value */
    247 #endif
    248 );
    249 
    250 extern void XrmPutStringResource(
    251 #if NeedFunctionPrototypes
    252     XrmDatabase*	/* database */,
    253     _Xconst char*	/* specifier */,
    254     _Xconst char*	/* value */
    255 #endif
    256 );
    257 
    258 extern void XrmPutLineResource(
    259 #if NeedFunctionPrototypes
    260     XrmDatabase*	/* database */,
    261     _Xconst char*	/* line */
    262 #endif
    263 );
    264 
    265 extern  XrmQGetResource(
    266 #if NeedFunctionPrototypes
    267     XrmDatabase		/* database */,
    268     XrmNameList		/* quark_name */,
    269     XrmClassList	/* quark_class */,
    270     XrmRepresentation*	/* quark_type_return */,
    271     XrmValue*		/* value_return */
    272 #endif
    273 );
    274 
    275 extern Bool XrmGetResource(
    276 #if NeedFunctionPrototypes
    277     XrmDatabase		/* database */,
    278     _Xconst char*	/* str_name */,
    279     _Xconst char*	/* str_class */,
    280     char**		/* str_type_return */,
    281     XrmValue*		/* value_return */
    282 #endif
    283 );
    284 
    285 extern Bool XrmQGetSearchList(
    286 #if NeedFunctionPrototypes
    287     XrmDatabase		/* database */,
    288     XrmNameList		/* names */,
    289     XrmClassList	/* classes */,
    290     XrmSearchList	/* list_return */,
    291     int			/* list_length */
    292 #endif
    293 );
    294 
    295 extern Bool XrmQGetSearchResource(
    296 #if NeedFunctionPrototypes
    297     XrmSearchList	/* list */,
    298     XrmName		/* name */,
    299     XrmClass		/* class */,
    300     XrmRepresentation*	/* type_return */,
    301     XrmValue*		/* value_return */
    302 #endif
    303 );
    304 
    305 /****************************************************************
    306  *
    307  * Resource Database Management
    308  *
    309  ****************************************************************/
    310 
    311 extern void XrmSetDatabase(
    312 #if NeedFunctionPrototypes
    313     Display*		/* display */,
    314     XrmDatabase		/* database */
    315 #endif
    316 );
    317 
    318 extern XrmDatabase XrmGetDatabase(
    319 #if NeedFunctionPrototypes
    320     Display*		/* display */
    321 #endif
    322 );
    323 
    324 extern XrmDatabase XrmGetFileDatabase(
    325 #if NeedFunctionPrototypes
    326     _Xconst char*	/* filename */
    327 #endif
    328 );
    329 
    330 extern Status XrmCombineFileDatabase(
    331 #if NeedFunctionPrototypes
    332     _Xconst char* 	/* filename */,
    333     XrmDatabase*	/* target */,
    334     Bool		/* override */
    335 #endif
    336 );
    337 
    338 extern XrmDatabase XrmGetStringDatabase(
    339 #if NeedFunctionPrototypes
    340     _Xconst char*	/* data */  /*  null terminated string */
    341 #endif
    342 );
    343 
    344 extern void XrmPutFileDatabase(
    345 #if NeedFunctionPrototypes
    346     XrmDatabase		/* database */,
    347     _Xconst char*	/* filename */
    348 #endif
    349 );
    350 
    351 extern void XrmMergeDatabases(
    352 #if NeedFunctionPrototypes
    353     XrmDatabase		/* source_db */,
    354     XrmDatabase*	/* target_db */
    355 #endif
    356 );
    357 
    358 extern void XrmCombineDatabase(
    359 #if NeedFunctionPrototypes
    360     XrmDatabase		/* source_db */,
    361     XrmDatabase*	/* target_db */,
    362     Bool		/* override */
    363 #endif
    364 );
    365 
    366 #define XrmEnumAllLevels 0
    367 #define XrmEnumOneLevel  1
    368 
    369 extern Bool XrmEnumerateDatabase(
    370 #if NeedFunctionPrototypes
    371     XrmDatabase		/* db */,
    372     XrmNameList		/* name_prefix */,
    373     XrmClassList	/* class_prefix */,
    374     int			/* mode */,
    375     Bool (*)(
    376 #if NeedNestedPrototypes
    377 	     XrmDatabase*	/* db */,
    378 	     XrmBindingList	/* bindings */,
    379 	     XrmQuarkList	/* quarks */,
    380 	     XrmRepresentation*	/* type */,
    381 	     XrmValue*		/* value */,
    382 	     XPointer		/* closure */
    383 #endif
    384 	     )		/* proc */,
    385     XPointer		/* closure */
    386 #endif
    387 );
    388 
    389 extern char *XrmLocaleOfDatabase(
    390 #if NeedFunctionPrototypes
    391     XrmDatabase 	/* database */
    392 #endif
    393 );
    394 
    395 
    396 /****************************************************************
    397  *
    398  * Command line option mapping to resource entries
    399  *
    400  ****************************************************************/
    401 
    402 typedef enum {
    403     XrmoptionNoArg,	/* Value is specified in OptionDescRec.value	    */
    404     XrmoptionIsArg,     /* Value is the option string itself		    */
    405     XrmoptionStickyArg, /* Value is characters immediately following option */
    406     XrmoptionSepArg,    /* Value is next argument in argv		    */
    407     XrmoptionResArg,	/* Resource and value in next argument in argv      */
    408     XrmoptionSkipArg,   /* Ignore this option and the next argument in argv */
    409     XrmoptionSkipLine,  /* Ignore this option and the rest of argv	    */
    410     XrmoptionSkipNArgs	/* Ignore this option and the next
    411 			   OptionDescRes.value arguments in argv */
    412 } XrmOptionKind;
    413 
    414 typedef struct {
    415     char	    *option;	    /* Option abbreviation in argv	    */
    416     char	    *specifier;     /* Resource specifier		    */
    417     XrmOptionKind   argKind;	    /* Which style of option it is	    */
    418     XPointer	    value;	    /* Value to provide if XrmoptionNoArg   */
    419 } XrmOptionDescRec, *XrmOptionDescList;
    420 
    421 
    422 extern void XrmParseCommand(
    423 #if NeedFunctionPrototypes
    424     XrmDatabase*	/* database */,
    425     XrmOptionDescList	/* table */,
    426     int			/* table_count */,
    427     _Xconst char*	/* name */,
    428     int*		/* argc_in_out */,
    429     char**		/* argv_in_out */
    430 #endif
    431 );
    432 
    433 _XFUNCPROTOEND
    434 
    435 #endif /* _XRESOURCE_H_ */
    436 /* DON'T ADD STUFF AFTER THIS #endif */
    437