FSlib.h revision 1bedbe3f
1/* 2 * Copyright 1990 Network Computing Devices; 3 * Portions Copyright 1987 by Digital Equipment Corporation 4 * 5 * Permission to use, copy, modify, distribute, and sell this software 6 * and its documentation for any purpose is hereby granted without fee, 7 * provided that the above copyright notice appear in all copies and 8 * that both that copyright notice and this permission notice appear 9 * in supporting documentation, and that the names of Network Computing 10 * Devices or Digital not be used in advertising or publicity pertaining 11 * to distribution of the software without specific, written prior 12 * permission. Network Computing Devices or Digital make no representations 13 * about the suitability of this software for any purpose. It is provided 14 * "as is" without express or implied warranty. 15 * 16 * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH 17 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 18 * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES 19 * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES 20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 22 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 23 * SOFTWARE. 24 */ 25 26/* 27 28Copyright 1987, 1994, 1998 The Open Group 29 30Permission to use, copy, modify, distribute, and sell this software and its 31documentation for any purpose is hereby granted without fee, provided that 32the above copyright notice appear in all copies and that both that 33copyright notice and this permission notice appear in supporting 34documentation. 35 36The above copyright notice and this permission notice shall be included in 37all copies or substantial portions of the Software. 38 39THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 40IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 41FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 42OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 43AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 44CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 46Except as contained in this notice, the name of The Open Group shall not be 47used in advertising or otherwise to promote the sale, use or other dealings 48in this Software without prior written authorization from The Open Group. 49 50*/ 51 52/* 53 * Font server C interface library 54 */ 55 56#ifndef _FSLIB_H_ 57#define _FSLIB_H_ 58 59#include <X11/Xfuncproto.h> 60 61#include <X11/fonts/FS.h> 62#include <X11/fonts/FSproto.h> 63 64#define Bool int 65#define Status int 66#define True 1 67#define False 0 68 69#define QueuedAlready 0 70#define QueuedAfterReading 1 71#define QueuedAfterFlush 2 72 73#define FSServerString(svr) ((svr)->server_name) 74#define FSVendorRelease(svr) ((svr)->release) 75#define FSProtocolVersion(svr) ((svr)->proto_version) 76#define FSServerVendor(svr) ((svr)->vendor) 77#define FSAuthorizationData(svr) ((svr)->auth_data) 78#define FSAlternateServers(svr) ((svr)->alternate_servers) 79#define FSNumAlternateServers(svr) ((svr)->num_alternates) 80#define FSQLength(svr) ((svr)->qlen) 81#define FSNextRequest(svr) ((svr)->request + 1) 82#define FSLastKnownRequestProcessed(svr) ((svr)->last_request_read) 83 84#define FSAllocID(svr) ((*(svr)->resource_alloc)((svr))) 85 86typedef struct _alternate { 87 Bool subset; 88 char *name; 89} AlternateServer; 90 91/* extension stuff */ 92typedef struct _FSExtData { 93 int number; /* number returned by FSRegisterExtension */ 94 struct _FSExtData *next; /* next item on list of data for structure */ 95 int (*free_private) (char *); /* called to free private storage */ 96 char *private_data; /* data private to this extension. */ 97} FSExtData; 98 99 100typedef struct { /* public to extension, cannot be changed */ 101 int extension; /* extension number */ 102 int major_opcode; /* major op-code assigned by server */ 103 int first_event; /* first event number for the extension */ 104 int first_error; /* first error number for the extension */ 105} FSExtCodes; 106 107typedef struct _FSServer FSServer; 108typedef union _FSEvent FSEvent; 109 110typedef struct _FSExtent { 111 struct _FSExtent *next; /* next in list */ 112 FSExtCodes codes; /* public information, all extension told */ 113 int (*close_server) (FSServer *, FSExtCodes *); /* routine to call when connection 114 * closed */ 115 int (*error) (FSServer *, fsError *, FSExtCodes *, int *); /* who to call when an error occurs */ 116 int (*error_string) (FSServer *, int, FSExtCodes *, char *, int); /* routine to supply error string */ 117 char *name; 118} _FSExtension; 119 120typedef int (*FSSyncHandler)(FSServer *); 121 122/* server data structure */ 123struct _FSServer { 124 struct _FSServer *next; 125 int fd; 126 int proto_version; 127 char *vendor; 128 int byte_order; 129 int vnumber; 130 int release; 131 int resource_id; 132 struct _FSQEvent *head, 133 *tail; 134 int qlen; 135 unsigned long last_request_read; 136 unsigned long request; 137 char *last_req; 138 char *buffer; 139 char *bufptr; 140 char *bufmax; 141 unsigned max_request_size; 142 char *server_name; 143 char *auth_data; 144 AlternateServer *alternate_servers; 145 int num_alternates; 146 FSExtData *ext_data; 147 _FSExtension *ext_procs; 148 int ext_number; 149 Bool (*event_vec[132]) (FSServer *, FSEvent *, fsEvent *); 150 Status (*wire_vec[132]) (FSServer *, FSEvent *, fsEvent *); 151 char *scratch_buffer; 152 unsigned long scratch_length; 153 FSSyncHandler synchandler; 154 unsigned long flags; 155 struct _XtransConnInfo *trans_conn; /* transport connection object */ 156}; 157 158typedef struct { 159 int type; 160 unsigned long serial; 161 Bool send_event; 162 FSServer *server; 163} FSAnyEvent; 164 165typedef struct { 166 int type; 167 FSServer *server; 168 FSID resourceid; 169 unsigned long serial; 170 unsigned char error_code; 171 unsigned char request_code; 172 unsigned char minor_code; 173} FSErrorEvent; 174 175union _FSEvent { 176 int type; 177 FSAnyEvent fsany; 178}; 179 180typedef struct _FSQEvent { 181 struct _FSQEvent *next; 182 FSEvent event; 183} _FSQEvent; 184 185 186/* protocol-related stuctures */ 187 188typedef unsigned long FSBitmapFormat; 189typedef unsigned long FSBitmapFormatMask; 190 191typedef struct _FSChar2b { 192 unsigned char high; 193 unsigned char low; 194} FSChar2b; 195 196typedef struct _FSRange { 197 FSChar2b min_char; 198 FSChar2b max_char; 199} FSRange; 200 201typedef struct _FSOffset { 202 unsigned int position; 203 unsigned int length; 204} FSOffset; 205 206/* use names as in xCharInfo? */ 207typedef struct _FSXCharInfo { 208 short left; 209 short right; 210 short width; 211 short ascent; 212 short descent; 213 unsigned short attributes; 214} FSXCharInfo; 215 216typedef struct _FSPropOffset { 217 FSOffset name; 218 FSOffset value; 219 unsigned char type; 220} FSPropOffset; 221 222typedef struct _FSPropInfo { 223 unsigned int num_offsets; 224 unsigned int data_len; 225} FSPropInfo; 226 227/* should names match FontInfoRec? */ 228typedef struct _FSXFontInfoHeader { 229 int flags; 230 FSRange char_range; 231 unsigned draw_direction; 232 FSChar2b default_char; 233 FSXCharInfo min_bounds; 234 FSXCharInfo max_bounds; 235 short font_ascent; 236 short font_descent; 237} FSXFontInfoHeader; 238 239 240 241/* function decls */ 242 243_XFUNCPROTOBEGIN 244 245extern FSServer * FSOpenServer ( const char *server ); 246 247extern FSSyncHandler FSSynchronize(FSServer *, int); 248extern FSSyncHandler FSSetAfterFunction(FSServer *, FSSyncHandler); 249 250extern const char * FSServerName ( const char *server ); 251extern char ** FSListExtensions ( FSServer *svr, int *next ); 252extern int FSQueryExtension ( FSServer *svr, char *name, int *major_opcode, 253 int *first_event, int *first_error ); 254 255extern char ** FSListCatalogues ( FSServer *svr, char *pattern, 256 int maxNames, int *actualCount ); 257extern char ** FSGetCatalogues ( FSServer *svr, int *num ); 258 259extern long FSMaxRequestSize ( FSServer *svr ); 260 261extern char ** FSListFonts ( FSServer *svr, const char *pattern, int maxNames, 262 int *actualCount ); 263extern char ** FSListFontsWithXInfo ( FSServer *svr, const char *pattern, 264 int maxNames, int *count, 265 FSXFontInfoHeader ***info, 266 FSPropInfo ***pprops, 267 FSPropOffset ***offsets, 268 unsigned char ***prop_data ); 269extern Font FSOpenBitmapFont ( FSServer *svr, FSBitmapFormat hint, 270 FSBitmapFormatMask fmask, char *name, 271 Font *otherid ); 272 273extern int FSSync ( FSServer *svr, Bool discard ); 274 275extern int FSCloseServer ( FSServer *svr ); 276extern int FSCloseFont ( FSServer *svr, Font fid ); 277extern int FSGetErrorDatabaseText ( FSServer *svr, const char *name, 278 const char *type, const char *defaultp, 279 char *buffer, int nbytes ); 280extern int FSGetErrorText ( FSServer *svr, int code, char *buffer, 281 282 int nbytes ); 283extern int FSFlush ( FSServer *svr ); 284extern int FSFreeFontNames ( char **list ); 285extern int FSFreeCatalogues ( char **list ); 286extern int FSFreeExtensionList ( char **list ); 287extern int FSNextEvent ( FSServer *svr, FSEvent *event ); 288extern int FSQueryXBitmaps8 ( FSServer *svr, Font fid, FSBitmapFormat format, 289 int range_type, unsigned char *str, 290 unsigned long str_len, FSOffset **offsets, 291 unsigned char **glyphdata ); 292extern int FSQueryXBitmaps16 ( FSServer *svr, Font fid, FSBitmapFormat format, 293 int range_type, FSChar2b *str, 294 unsigned long str_len, FSOffset **offsets, 295 unsigned char **glyphdata ); 296extern int FSQueryXExtents8 ( FSServer *svr, Font fid, int range_type, 297 unsigned char *str, unsigned long str_len, 298 FSXCharInfo **extents ); 299extern int FSQueryXExtents16 ( FSServer *svr, Font fid, int range_type, 300 FSChar2b *str, unsigned long str_len, 301 FSXCharInfo **extents ); 302extern int FSQueryXInfo ( FSServer *svr, Font fid, FSXFontInfoHeader *info, 303 FSPropInfo *props, FSPropOffset **offsets, 304 unsigned char **prop_data ); 305extern int FSSetCatalogues ( FSServer *svr, int num, char **cats ); 306extern int FSFree ( char *data ); 307extern unsigned char * FSMalloc ( unsigned size ); 308 309_XFUNCPROTOEND 310 311#endif /* _FSLIB_H_ */ 312