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 < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  3.6 KB  |  119 lines

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