home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / lib / fs / FSQXInfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  3.1 KB  |  87 lines

  1. /* $XConsortium: FSQXInfo.c,v 1.3 92/05/12 18:07:24 gildea Exp $ */
  2. /*
  3.  * Copyright 1990 Network Computing Devices;
  4.  * Portions Copyright 1987 by Digital Equipment Corporation and the
  5.  * Massachusetts Institute of Technology
  6.  *
  7.  * Permission to use, copy, modify, and distribute this protoype software
  8.  * and its documentation to Members and Affiliates of the MIT X Consortium
  9.  * any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the names of Network Computing Devices, Digital or
  13.  * MIT not be used in advertising or publicity pertaining to distribution of
  14.  * the software without specific, written prior permission.
  15.  *
  16.  * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
  17.  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  18.  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT BE
  19.  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  22.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23.  */
  24.  
  25. #include    "FSlibint.h"
  26.  
  27. /*
  28.  * Note:  only the range in the first FSQuery is sent to the server.
  29.  * the others exist as return values only.
  30.  */
  31.  
  32. int
  33. FSQueryXInfo(svr, fid, info, props, offsets, prop_data)
  34.     FSServer   *svr;
  35.     Font        fid;
  36.     fsFontHeader *info;
  37.     fsPropInfo *props;
  38.     fsPropOffset **offsets;
  39.     unsigned char **prop_data;
  40. {
  41.     fsQueryXInfoReq *req;
  42.     fsQueryXInfoReply reply;
  43.     fsPropOffset *offset_data;
  44.     unsigned char *pdata;
  45.  
  46.     GetReq(QueryXInfo, req);
  47.     req->id = fid;
  48.  
  49.     /* get back the info */
  50.     if (!_FSReply(svr, (fsReply *) & reply, ((SIZEOF(fsQueryXInfoReply) -
  51.                 SIZEOF(fsGenericReply)) >> 2), fsFalse)) {
  52.     return FSBadAlloc;
  53.     }
  54.     bcopy((char *) &reply.header, (char *) info, sizeof(fsFontHeader));
  55.     if (FSProtocolVersion(svr) == 1)
  56.     {
  57.     info->char_range.min_char.high = reply.header.char_range.min_char.low;
  58.     info->char_range.min_char.low = reply.header.char_range.min_char.high;
  59.     info->char_range.max_char.high = reply.header.char_range.max_char.low;
  60.     info->char_range.max_char.low = reply.header.char_range.max_char.high;
  61.     info->default_char.high = reply.header.default_char.low;
  62.     info->default_char.low = reply.header.default_char.high;
  63.     }
  64.     /* get the prop header */
  65.     _FSReadPad(svr, (char *) props, sizeof(fsPropInfo));
  66.     /* prepare for prop data */
  67.     offset_data = (fsPropOffset *)
  68.     FSmalloc(props->num_offsets * sizeof(fsPropOffset));
  69.     if (!offset_data)
  70.     return FSBadAlloc;
  71.     pdata = (unsigned char *) FSmalloc(props->data_len);
  72.     if (!pdata) {
  73.     FSfree((char *) offset_data);
  74.     return FSBadAlloc;
  75.     }
  76.     /* get offsets */
  77.     _FSReadPad(svr, (char *) offset_data,
  78.            (props->num_offsets * sizeof(fsPropOffset)));
  79.     /* get data */
  80.     _FSReadPad(svr, (char *) pdata, props->data_len);
  81.     *offsets = offset_data;
  82.     *prop_data = pdata;
  83.  
  84.     SyncHandle();
  85.     return FSSuccess;
  86. }
  87.