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 28 Copyright 1987, 1994, 1998 The Open Group 29 30 Permission to use, copy, modify, distribute, and sell this software and its 31 documentation for any purpose is hereby granted without fee, provided that 32 the above copyright notice appear in all copies and that both that 33 copyright notice and this permission notice appear in supporting 34 documentation. 35 36 The above copyright notice and this permission notice shall be included in 37 all copies or substantial portions of the Software. 38 39 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 40 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 41 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 42 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 43 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 44 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 46 Except as contained in this notice, the name of The Open Group shall not be 47 used in advertising or otherwise to promote the sale, use or other dealings 48 in 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 86 typedef struct _alternate { 87 Bool subset; 88 char *name; 89 } AlternateServer; 90 91 /* extension stuff */ 92 typedef 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 100 typedef 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 107 typedef struct _FSServer FSServer; 108 typedef union _FSEvent FSEvent; 109 110 typedef 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 120 typedef int (*FSSyncHandler)(FSServer *); 121 122 /* server data structure */ 123 struct _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 void *unused_1; /* previously scratch_buffer */ 152 unsigned long unused_2; /* previously scratch_length */ 153 FSSyncHandler synchandler; 154 unsigned long flags; 155 struct _XtransConnInfo *trans_conn; /* transport connection object */ 156 }; 157 158 typedef struct { 159 int type; 160 unsigned long serial; 161 Bool send_event; 162 FSServer *server; 163 } FSAnyEvent; 164 165 typedef 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 175 union _FSEvent { 176 int type; 177 FSAnyEvent fsany; 178 }; 179 180 typedef struct _FSQEvent { 181 struct _FSQEvent *next; 182 FSEvent event; 183 } _FSQEvent; 184 185 186 /* protocol-related stuctures */ 187 188 typedef unsigned long FSBitmapFormat; 189 typedef unsigned long FSBitmapFormatMask; 190 191 typedef struct _FSChar2b { 192 unsigned char high; 193 unsigned char low; 194 } FSChar2b; 195 196 typedef struct _FSRange { 197 FSChar2b min_char; 198 FSChar2b max_char; 199 } FSRange; 200 201 typedef struct _FSOffset { 202 unsigned int position; 203 unsigned int length; 204 } FSOffset; 205 206 /* use names as in xCharInfo? */ 207 typedef struct _FSXCharInfo { 208 short left; 209 short right; 210 short width; 211 short ascent; 212 short descent; 213 unsigned short attributes; 214 } FSXCharInfo; 215 216 typedef struct _FSPropOffset { 217 FSOffset name; 218 FSOffset value; 219 unsigned char type; 220 } FSPropOffset; 221 222 typedef struct _FSPropInfo { 223 unsigned int num_offsets; 224 unsigned int data_len; 225 } FSPropInfo; 226 227 /* should names match FontInfoRec? */ 228 typedef 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 245 extern FSServer * FSOpenServer ( const char *server ); 246 247 extern FSSyncHandler FSSynchronize(FSServer *, int); 248 extern FSSyncHandler FSSetAfterFunction(FSServer *, FSSyncHandler); 249 250 extern const char * FSServerName ( const char *server ); 251 extern char ** FSListExtensions ( FSServer *svr, int *next ); 252 extern int FSQueryExtension ( FSServer *svr, const char *name, int *major_opcode, 253 int *first_event, int *first_error ); 254 255 extern char ** FSListCatalogues ( FSServer *svr, const char *pattern, 256 int maxNames, int *actualCount ); 257 extern char ** FSGetCatalogues ( FSServer *svr, int *num ); 258 259 extern long FSMaxRequestSize ( FSServer *svr ); 260 261 extern char ** FSListFonts ( FSServer *svr, const char *pattern, int maxNames, 262 int *actualCount ); 263 extern 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 ); 269 extern Font FSOpenBitmapFont ( FSServer *svr, FSBitmapFormat hint, 270 FSBitmapFormatMask fmask, const char *name, 271 Font *otherid ); 272 273 extern int FSSync ( FSServer *svr, Bool discard ); 274 275 extern int FSCloseServer ( FSServer *svr ); 276 extern int FSCloseFont ( FSServer *svr, Font fid ); 277 extern int FSGetErrorDatabaseText ( FSServer *svr, const char *name, 278 const char *type, const char *defaultp, 279 char *buffer, int nbytes ); 280 extern int FSGetErrorText ( FSServer *svr, int code, char *buffer, 281 int nbytes ); 282 extern int FSFlush ( FSServer *svr ); 283 extern int FSFreeFontNames ( char **list ); 284 extern int FSFreeCatalogues ( char **list ); 285 extern int FSFreeExtensionList ( char **list ); 286 extern int FSNextEvent ( FSServer *svr, FSEvent *event ); 287 extern int FSQueryXBitmaps8 ( FSServer *svr, Font fid, FSBitmapFormat format, 288 int range_type, const unsigned char *str, 289 unsigned long str_len, FSOffset **offsets, 290 unsigned char **glyphdata ); 291 extern int FSQueryXBitmaps16 ( FSServer *svr, Font fid, FSBitmapFormat format, 292 int range_type, const FSChar2b *str, 293 unsigned long str_len, FSOffset **offsets, 294 unsigned char **glyphdata ); 295 extern int FSQueryXExtents8 ( FSServer *svr, Font fid, int range_type, 296 const unsigned char *str, unsigned long str_len, 297 FSXCharInfo **extents ); 298 extern int FSQueryXExtents16 ( FSServer *svr, Font fid, int range_type, 299 const FSChar2b *str, unsigned long str_len, 300 FSXCharInfo **extents ); 301 extern int FSQueryXInfo ( FSServer *svr, Font fid, FSXFontInfoHeader *info, 302 FSPropInfo *props, FSPropOffset **offsets, 303 unsigned char **prop_data ); 304 extern int FSSetCatalogues ( FSServer *svr, int num, char **cats ); 305 extern int FSFree ( char *data ); 306 extern unsigned char * FSMalloc ( unsigned size ); 307 308 _XFUNCPROTOEND 309 310 #endif /* _FSLIB_H_ */ 311