123a0898aSmrg/*
223a0898aSmrg * Copyright 1990 Network Computing Devices
323a0898aSmrg *
423a0898aSmrg * Permission to use, copy, modify, distribute, and sell this software and
523a0898aSmrg * its documentation for any purpose is hereby granted without fee, provided
623a0898aSmrg * that the above copyright notice appear in all copies and that both that
723a0898aSmrg * copyright notice and this permission notice appear in supporting
823a0898aSmrg * documentation, and that the name of Network Computing Devices not be
923a0898aSmrg * used in advertising or publicity pertaining to distribution of the
1023a0898aSmrg * software without specific, written prior permission.  Network Computing
1123a0898aSmrg * Devices makes no representations about the suitability of this software
1223a0898aSmrg * for any purpose.  It is provided "as is" without express or implied
1323a0898aSmrg * warranty.
1423a0898aSmrg *
1523a0898aSmrg * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
1623a0898aSmrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
1723a0898aSmrg * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
1823a0898aSmrg * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1923a0898aSmrg * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
2023a0898aSmrg * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
2123a0898aSmrg * OR PERFORMANCE OF THIS SOFTWARE.
2223a0898aSmrg *
2323a0898aSmrg * Author:  	Dave Lemke, Network Computing Devices, Inc
2423a0898aSmrg */
2523a0898aSmrg
2623a0898aSmrg#ifndef _FSERVESTR_H_
2723a0898aSmrg#define _FSERVESTR_H_
2823a0898aSmrg
2923a0898aSmrg#include	"fserve.h"
3023a0898aSmrg#include	"fsio.h"
3123a0898aSmrg
3223a0898aSmrg/*
3323a0898aSmrg * font server data structures
3423a0898aSmrg */
3523a0898aSmrg/*
3623a0898aSmrg * font server private storage
3723a0898aSmrg */
3823a0898aSmrg
3923a0898aSmrgtypedef struct _fs_glyph {
4023a0898aSmrg    struct _fs_glyph	*next;
4123a0898aSmrg} FSGlyphRec, *FSGlyphPtr;
4223a0898aSmrg
4323a0898aSmrgtypedef struct _fs_font {
4423a0898aSmrg    CharInfoPtr pDefault;
4523a0898aSmrg    CharInfoPtr encoding;
4623a0898aSmrg    CharInfoPtr inkMetrics;
4723a0898aSmrg    FSGlyphPtr	glyphs;
4823a0898aSmrg}           FSFontRec, *FSFontPtr;
4923a0898aSmrg
5023a0898aSmrg/* FS special data for the font */
5123a0898aSmrgtypedef struct _fs_font_data {
5223a0898aSmrg    long        fontid;
5323a0898aSmrg    int		generation;	/* FS generation when opened */
5423a0898aSmrg    unsigned long glyphs_to_get;	/* # glyphs remaining to be gotten */
5523a0898aSmrg
5623a0898aSmrg    /* Following data needed in case font needs to be reopened. */
5723a0898aSmrg    int		namelen;
5823a0898aSmrg    char       *name;
5923a0898aSmrg    fsBitmapFormat	format;
6023a0898aSmrg    fsBitmapFormatMask	fmask;
6123a0898aSmrg}           FSFontDataRec;
6223a0898aSmrg
6323a0898aSmrgtypedef struct fs_clients_depending {
6423a0898aSmrg    pointer	client;
6523a0898aSmrg    struct fs_clients_depending *next;
6623a0898aSmrg}	FSClientsDependingRec, *FSClientsDependingPtr;
6723a0898aSmrg
6823a0898aSmrg/* OpenFont specific data for blocked request */
6923a0898aSmrgtypedef struct _fs_blocked_font {
7023a0898aSmrg    FontPtr     pfont;		/* must be first for fs_read_glyphs */
7123a0898aSmrg    long        fontid;
7223a0898aSmrg    int         state;		/* how many of the replies have landed */
7323a0898aSmrg    int         flags;
7423a0898aSmrg    Bool	freeFont;	/* free this font on failure */
7523a0898aSmrg    CARD16	queryInfoSequence;
7623a0898aSmrg    CARD16	queryExtentsSequence;
7723a0898aSmrg    CARD16	queryBitmapsSequence;
7823a0898aSmrg    fsBitmapFormat format;
7923a0898aSmrg    FSClientsDependingPtr	clients_depending;
8023a0898aSmrg}           FSBlockedFontRec;
8123a0898aSmrg
8223a0898aSmrg/* LoadGlyphs data for blocked request */
8323a0898aSmrgtypedef struct _fs_blocked_glyphs {
8423a0898aSmrg    FontPtr     pfont;		/* must be first for fs_read_glyphs */
8523a0898aSmrg    int		num_expected_ranges;
8623a0898aSmrg    fsRange     *expected_ranges;
8723a0898aSmrg    FSClientsDependingPtr	clients_depending;
8823a0898aSmrg}           FSBlockedGlyphRec;
8923a0898aSmrg
9023a0898aSmrg/* LoadExtents data for blocked request */
9123a0898aSmrgtypedef struct _fs_blocked_extents {
9223a0898aSmrg    FontPtr     pfont;
9323a0898aSmrg    fsRange    *expected_ranges;
9423a0898aSmrg    int         nranges;
9523a0898aSmrg    unsigned long nextents;
9623a0898aSmrg    fsXCharInfo *extents;
9723a0898aSmrg}           FSBlockedExtentRec;
9823a0898aSmrg
9923a0898aSmrg/* LoadBitmaps data for blocked request */
10023a0898aSmrgtypedef struct _fs_blocked_bitmaps {
10123a0898aSmrg    FontPtr     pfont;
10223a0898aSmrg    fsRange    *expected_ranges;
10323a0898aSmrg    int         nranges;
10423a0898aSmrg    unsigned long size;
10523a0898aSmrg    unsigned long nglyphs;
10623a0898aSmrg    fsOffset32   *offsets;
10723a0898aSmrg    pointer     gdata;
10823a0898aSmrg}           FSBlockedBitmapRec;
10923a0898aSmrg
11023a0898aSmrg/* state for blocked ListFonts */
11123a0898aSmrgtypedef struct _fs_blocked_list {
11223a0898aSmrg    FontNamesPtr names;
11323a0898aSmrg}           FSBlockedListRec;
11423a0898aSmrg
11523a0898aSmrg/* state for blocked ListFontsWithInfo */
11623a0898aSmrgtypedef struct _fs_blocked_list_info {
11723a0898aSmrg    int         status;
11823a0898aSmrg    int         namelen;
11923a0898aSmrg    FontInfoRec info;
12023a0898aSmrg    char	name[256];
12123a0898aSmrg    int         remaining;
12223a0898aSmrg}           FSBlockedListInfoRec;
12323a0898aSmrg
12423a0898aSmrg/* state for blocked request */
12523a0898aSmrgtypedef struct _fs_block_data {
12623a0898aSmrg    int			    type;	    /* Open Font, LoadGlyphs, ListFonts,
12723a0898aSmrg					     * ListWithInfo */
12823a0898aSmrg    pointer		    client;	    /* who wants it */
12923a0898aSmrg    CARD16    		    sequenceNumber; /* expected */
13023a0898aSmrg    pointer		    data;	    /* type specific data */
13123a0898aSmrg    int			    errcode;	    /* Suspended, et al. */
13223a0898aSmrg    struct _fs_block_data   *depending;	    /* clients depending on this one */
13323a0898aSmrg    struct _fs_block_data   *next;
13423a0898aSmrg}           FSBlockDataRec;
13523a0898aSmrg
13623a0898aSmrg/* state for reconnected to dead font server */
13723a0898aSmrgtypedef struct _fs_reconnect {
13823a0898aSmrg    int	    i;
13923a0898aSmrg} FSReconnectRec, *FSReconnectPtr;
14023a0898aSmrg
14123a0898aSmrg
14223a0898aSmrg#define fsCat(x,y) x##_##y
14323a0898aSmrg
14423a0898aSmrg/* copy XCharInfo parts of a protocol reply into a xCharInfo */
14523a0898aSmrg
14623a0898aSmrg#define fsUnpack_XCharInfo(packet, structure) \
14723a0898aSmrg    (structure)->leftSideBearing = fsCat(packet,left); \
14823a0898aSmrg    (structure)->rightSideBearing = fsCat(packet,right); \
14923a0898aSmrg    (structure)->characterWidth = fsCat(packet,width); \
15023a0898aSmrg    (structure)->ascent = fsCat(packet,ascent); \
15123a0898aSmrg    (structure)->descent = fsCat(packet,descent); \
15223a0898aSmrg    (structure)->attributes = fsCat(packet,attributes)
15323a0898aSmrg
15423a0898aSmrg
15523a0898aSmrg/* copy XFontInfoHeader parts of a protocol reply into a FontInfoRec */
15623a0898aSmrg
15723a0898aSmrg#define fsUnpack_XFontInfoHeader(packet, structure) \
15823a0898aSmrg    (structure)->allExist = ((packet)->font_header_flags & FontInfoAllCharsExist) != 0; \
15923a0898aSmrg    (structure)->drawDirection = \
16023a0898aSmrg        ((packet)->font_header_draw_direction == LeftToRightDrawDirection) ? \
16123a0898aSmrg	LeftToRight : RightToLeft; \
16223a0898aSmrg    (structure)->inkInside = ((packet)->font_header_flags & FontInfoInkInside) != 0; \
16323a0898aSmrg \
16423a0898aSmrg    (structure)->firstRow = (packet)->font_hdr_char_range_min_char_high; \
16523a0898aSmrg    (structure)->firstCol = (packet)->font_hdr_char_range_min_char_low; \
16623a0898aSmrg    (structure)->lastRow = (packet)->font_hdr_char_range_max_char_high; \
16723a0898aSmrg    (structure)->lastCol = (packet)->font_hdr_char_range_max_char_low; \
16823a0898aSmrg    (structure)->defaultCh = (packet)->font_header_default_char_low \
16923a0898aSmrg                           + ((packet)->font_header_default_char_high << 8); \
17023a0898aSmrg \
17123a0898aSmrg    (structure)->fontDescent = (packet)->font_header_font_descent; \
17223a0898aSmrg    (structure)->fontAscent = (packet)->font_header_font_ascent; \
17323a0898aSmrg \
17423a0898aSmrg    fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->minbounds); \
17523a0898aSmrg    fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->ink_minbounds); \
17623a0898aSmrg    fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \
17723a0898aSmrg    fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds)
17823a0898aSmrg
17923a0898aSmrgextern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi );
18041c30155Smrgextern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd,
18123a0898aSmrg			       FontInfoPtr pfi );
18241c30155Smrgextern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi,
18341c30155Smrg				    fsListFontsWithXInfoReply *fsrep,
18441c30155Smrg				    fsPropInfo *pi, fsPropOffset *po,
18523a0898aSmrg				    pointer pd );
18641c30155Smrgextern int fs_build_range ( FontPtr pfont, Bool range_flag,
18741c30155Smrg			    unsigned int count, int item_size,
18841c30155Smrg			    unsigned char *data, int *nranges,
18923a0898aSmrg			    fsRange **ranges );
19041c30155Smrgextern void _fs_clean_aborted_loadglyphs ( FontPtr pfont,
19141c30155Smrg					   int num_expected_ranges,
19223a0898aSmrg					   fsRange *expected_ranges );
19323a0898aSmrgextern void _fs_init_font ( FontPtr pfont );
19423a0898aSmrgextern pointer fs_alloc_glyphs (FontPtr pFont, int size);
19523a0898aSmrg#endif				/* _FSERVESTR_H_ */
196