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