fservestr.h revision 23a0898a
1/* $Xorg: fservestr.h,v 1.3 2000/08/17 19:46:36 cpqbld Exp $ */
2/*
3 * Copyright 1990 Network Computing Devices
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Network Computing Devices not be
10 * used in advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission.  Network Computing
12 * Devices makes no representations about the suitability of this software
13 * for any purpose.  It is provided "as is" without express or implied
14 * warranty.
15 *
16 * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
18 * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
19 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22 * OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Author:  	Dave Lemke, Network Computing Devices, Inc
25 */
26/* $XFree86: xc/lib/font/fc/fservestr.h,v 3.3 2001/01/17 19:43:29 dawes Exp $ */
27
28#ifndef _FSERVESTR_H_
29#define _FSERVESTR_H_
30
31#include	"fserve.h"
32#include	"fsio.h"
33
34/*
35 * font server data structures
36 */
37/*
38 * font server private storage
39 */
40
41typedef struct _fs_glyph {
42    struct _fs_glyph	*next;
43} FSGlyphRec, *FSGlyphPtr;
44
45typedef struct _fs_font {
46    CharInfoPtr pDefault;
47    CharInfoPtr encoding;
48    CharInfoPtr inkMetrics;
49    FSGlyphPtr	glyphs;
50}           FSFontRec, *FSFontPtr;
51
52/* FS special data for the font */
53typedef struct _fs_font_data {
54    long        fontid;
55    int		generation;	/* FS generation when opened */
56    unsigned long glyphs_to_get;	/* # glyphs remaining to be gotten */
57
58    /* Following data needed in case font needs to be reopened. */
59    int		namelen;
60    char       *name;
61    fsBitmapFormat	format;
62    fsBitmapFormatMask	fmask;
63}           FSFontDataRec;
64
65typedef struct fs_clients_depending {
66    pointer	client;
67    struct fs_clients_depending *next;
68}	FSClientsDependingRec, *FSClientsDependingPtr;
69
70/* OpenFont specific data for blocked request */
71typedef struct _fs_blocked_font {
72    FontPtr     pfont;		/* must be first for fs_read_glyphs */
73    long        fontid;
74    int         state;		/* how many of the replies have landed */
75    int         flags;
76    Bool	freeFont;	/* free this font on failure */
77    CARD16	queryInfoSequence;
78    CARD16	queryExtentsSequence;
79    CARD16	queryBitmapsSequence;
80    fsBitmapFormat format;
81    FSClientsDependingPtr	clients_depending;
82}           FSBlockedFontRec;
83
84/* LoadGlyphs data for blocked request */
85typedef struct _fs_blocked_glyphs {
86    FontPtr     pfont;		/* must be first for fs_read_glyphs */
87    int		num_expected_ranges;
88    fsRange     *expected_ranges;
89    FSClientsDependingPtr	clients_depending;
90}           FSBlockedGlyphRec;
91
92/* LoadExtents data for blocked request */
93typedef struct _fs_blocked_extents {
94    FontPtr     pfont;
95    fsRange    *expected_ranges;
96    int         nranges;
97    unsigned long nextents;
98    fsXCharInfo *extents;
99}           FSBlockedExtentRec;
100
101/* LoadBitmaps data for blocked request */
102typedef struct _fs_blocked_bitmaps {
103    FontPtr     pfont;
104    fsRange    *expected_ranges;
105    int         nranges;
106    unsigned long size;
107    unsigned long nglyphs;
108    fsOffset32   *offsets;
109    pointer     gdata;
110}           FSBlockedBitmapRec;
111
112/* state for blocked ListFonts */
113typedef struct _fs_blocked_list {
114    FontNamesPtr names;
115}           FSBlockedListRec;
116
117/* state for blocked ListFontsWithInfo */
118typedef struct _fs_blocked_list_info {
119    int         status;
120    int         namelen;
121    FontInfoRec info;
122    char	name[256];
123    int         remaining;
124}           FSBlockedListInfoRec;
125
126/* state for blocked request */
127typedef struct _fs_block_data {
128    int			    type;	    /* Open Font, LoadGlyphs, ListFonts,
129					     * ListWithInfo */
130    pointer		    client;	    /* who wants it */
131    CARD16    		    sequenceNumber; /* expected */
132    pointer		    data;	    /* type specific data */
133    int			    errcode;	    /* Suspended, et al. */
134    struct _fs_block_data   *depending;	    /* clients depending on this one */
135    struct _fs_block_data   *next;
136}           FSBlockDataRec;
137
138/* state for reconnected to dead font server */
139typedef struct _fs_reconnect {
140    int	    i;
141} FSReconnectRec, *FSReconnectPtr;
142
143
144#if !defined(UNIXCPP) || defined(ANSICPP)
145#define fsCat(x,y) x##_##y
146#else
147#define fsCat(x,y) x/**/_/**/y
148#endif
149
150
151/* copy XCharInfo parts of a protocol reply into a xCharInfo */
152
153#define fsUnpack_XCharInfo(packet, structure) \
154    (structure)->leftSideBearing = fsCat(packet,left); \
155    (structure)->rightSideBearing = fsCat(packet,right); \
156    (structure)->characterWidth = fsCat(packet,width); \
157    (structure)->ascent = fsCat(packet,ascent); \
158    (structure)->descent = fsCat(packet,descent); \
159    (structure)->attributes = fsCat(packet,attributes)
160
161
162/* copy XFontInfoHeader parts of a protocol reply into a FontInfoRec */
163
164#define fsUnpack_XFontInfoHeader(packet, structure) \
165    (structure)->allExist = ((packet)->font_header_flags & FontInfoAllCharsExist) != 0; \
166    (structure)->drawDirection = \
167        ((packet)->font_header_draw_direction == LeftToRightDrawDirection) ? \
168	LeftToRight : RightToLeft; \
169    (structure)->inkInside = ((packet)->font_header_flags & FontInfoInkInside) != 0; \
170 \
171    (structure)->firstRow = (packet)->font_hdr_char_range_min_char_high; \
172    (structure)->firstCol = (packet)->font_hdr_char_range_min_char_low; \
173    (structure)->lastRow = (packet)->font_hdr_char_range_max_char_high; \
174    (structure)->lastCol = (packet)->font_hdr_char_range_max_char_low; \
175    (structure)->defaultCh = (packet)->font_header_default_char_low \
176                           + ((packet)->font_header_default_char_high << 8); \
177 \
178    (structure)->fontDescent = (packet)->font_header_font_descent; \
179    (structure)->fontAscent = (packet)->font_header_font_ascent; \
180 \
181    fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->minbounds); \
182    fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->ink_minbounds); \
183    fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \
184    fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds)
185
186extern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi );
187extern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd,
188			       FontInfoPtr pfi );
189extern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi,
190				    fsListFontsWithXInfoReply *fsrep,
191				    fsPropInfo *pi, fsPropOffset *po,
192				    pointer pd );
193extern int fs_build_range ( FontPtr pfont, Bool range_flag,
194			    unsigned int count, int item_size,
195			    unsigned char *data, int *nranges,
196			    fsRange **ranges );
197extern void _fs_clean_aborted_loadglyphs ( FontPtr pfont,
198					   int num_expected_ranges,
199					   fsRange *expected_ranges );
200extern void _fs_init_font ( FontPtr pfont );
201extern pointer fs_alloc_glyphs (FontPtr pFont, int size);
202#endif				/* _FSERVESTR_H_ */
203