home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / lib / fs / FSQXExt.c.orig < prev    next >
Encoding:
Text File  |  1991-05-13  |  3.3 KB  |  105 lines

  1. /* $XConsortium: FSQXExt.c,v 1.2 91/05/13 15:11:50 gildea Exp $ */
  2.  
  3. /* @(#)FSQXExt.c    4.1    91/05/02
  4.  * Copyright 1990 Network Computing Devices;
  5.  * Portions Copyright 1987 by Digital Equipment Corporation and the
  6.  * Massachusetts Institute of Technology
  7.  *
  8.  * Permission to use, copy, modify, and distribute this protoype software
  9.  * and its documentation to Members and Affiliates of the MIT X Consortium
  10.  * any purpose and without fee is hereby granted, provided
  11.  * that the above copyright notice appear in all copies and that both that
  12.  * copyright notice and this permission notice appear in supporting
  13.  * documentation, and that the names of Network Computing Devices, Digital or
  14.  * MIT not be used in advertising or publicity pertaining to distribution of
  15.  * the software without specific, written prior permission.
  16.  *
  17.  * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
  18.  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  19.  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT BE
  20.  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  21.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  22.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  */
  25.  
  26. #include    "FSlibint.h"
  27.  
  28. int
  29. FSQueryXExtents8(svr, fid, range_type, str, str_len, extents)
  30.     FSServer   *svr;
  31.     Font        fid;
  32.     Bool        range_type;
  33.     unsigned char *str;
  34.     unsigned long str_len;
  35.     fsCharInfo **extents;
  36. {
  37.     fsQueryXExtents8Req *req;
  38.     fsQueryXExtents8Reply reply;
  39.     fsCharInfo *ext;
  40.     int         i;
  41.  
  42.     GetReq(QueryXExtents8, req);
  43.     req->fid = fid;
  44.     req->range = range_type;
  45.     req->num_ranges = str_len;
  46.     req->length += (str_len + 3) >> 2;
  47.     _FSSend(svr, (char *) str, str_len);
  48.  
  49.     /* get back the info */
  50.     if (!_FSReply(svr, (fsReply *) & reply,
  51.            (sizeof(fsQueryXExtents8Reply) - sizeof(fsGenericReply)) >> 2,
  52.           fsFalse))
  53.     return FSBadAlloc;
  54.  
  55.     ext = (fsCharInfo *) FSmalloc(sizeof(fsCharInfo) * reply.num_extents);
  56.     *extents = ext;
  57.     if (!ext)
  58.     return FSBadAlloc;
  59.     for (i = 0; i < reply.num_extents; i++) {
  60.     _FSReadPad(svr, (char *) &ext[i], sizeof(fsCharInfo));
  61.     }
  62.  
  63.     SyncHandle();
  64.     return FSSuccess;
  65. }
  66.  
  67. int
  68. FSQueryXExtents16(svr, fid, range_type, str, str_len, extents)
  69.     FSServer   *svr;
  70.     Font        fid;
  71.     Bool        range_type;
  72.     fsChar2b   *str;
  73.     unsigned long str_len;
  74.     fsCharInfo **extents;
  75. {
  76.     fsQueryXExtents16Req *req;
  77.     fsQueryXExtents16Reply reply;
  78.     fsCharInfo *ext;
  79.     int         i;
  80.  
  81.     GetReq(QueryXExtents16, req);
  82.     req->fid = fid;
  83.     req->range = range_type;
  84.     req->num_ranges = str_len;
  85.     req->length += ((str_len * sizeof(fsChar2b)) + 3) >> 2;
  86.     _FSSend(svr, (char *) str, (str_len * sizeof(fsChar2b)));
  87.  
  88.     /* get back the info */
  89.     if (!_FSReply(svr, (fsReply *) & reply,
  90.           (sizeof(fsQueryXExtents16Reply) - sizeof(fsGenericReply)) >> 2,
  91.           fsFalse))
  92.     return FSBadAlloc;
  93.  
  94.     ext = (fsCharInfo *) FSmalloc(sizeof(fsCharInfo) * reply.num_extents);
  95.     *extents = ext;
  96.     if (!ext)
  97.     return FSBadAlloc;
  98.     for (i = 0; i < reply.num_extents; i++) {
  99.     _FSReadPad(svr, (char *) &ext[i], sizeof(fsCharInfo));
  100.     }
  101.  
  102.     SyncHandle();
  103.     return FSSuccess;
  104. }
  105.