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

  1. /* $XConsortium: FSQGlyphs.c,v 1.2 91/05/13 15:11:49 gildea Exp $ */
  2.  
  3. /* @(#)FSQGlyphs.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. FSQueryXBitmaps8(svr, fid, format, range_type, str, str_len, offsets, glyphdata)
  30.     FSServer   *svr;
  31.     Font        fid;
  32.     fsBitmapFormat format;
  33.     Bool        range_type;
  34.     unsigned char *str;
  35.     unsigned long str_len;
  36.     fsOffset  **offsets;
  37.     unsigned char **glyphdata;
  38. {
  39.     fsQueryXBitmaps8Req *req;
  40.     fsQueryXBitmaps8Reply reply;
  41.     fsOffset   *offs;
  42.     unsigned char *gd;
  43.     int         left;
  44.  
  45.     GetReq(QueryXBitmaps8, req);
  46.     req->fid = fid;
  47.     req->range = range_type;
  48.     req->format = format;
  49.     req->num_ranges = str_len;
  50.     req->length += (str_len + 3) >> 2;
  51.     _FSSend(svr, (char *) str, str_len);
  52.  
  53.     /* get back the info */
  54.     if (!_FSReply(svr, (fsReply *) & reply,
  55.      (sizeof(fsQueryXBitmaps8Reply) - sizeof(fsGenericReply)) >> 2, fsFalse))
  56.     return FSBadAlloc;
  57.  
  58.     offs = (fsOffset *) FSmalloc(sizeof(fsOffset) * reply.num_chars);
  59.     *offsets = offs;
  60.     if (!offs)
  61.     return FSBadAlloc;
  62.     left = (reply.length << 2) - sizeof(fsQueryXBitmaps8Reply)
  63.     - (sizeof(fsOffset) * reply.num_chars);
  64.     gd = (unsigned char *) FSmalloc(left);
  65.     *glyphdata = gd;
  66.     if (!gd) {
  67.     FSfree((char *) offs);
  68.     return FSBadAlloc;
  69.     }
  70.     _FSReadPad(svr, (char *) offs, (sizeof(fsOffset) * reply.num_chars));
  71.     _FSReadPad(svr, (char *) gd, left);
  72.  
  73.     SyncHandle();
  74.     return FSSuccess;
  75. }
  76.  
  77. int
  78. FSQueryXBitmaps16(svr, fid, format, range_type, str, str_len,
  79.           offsets, glyphdata)
  80.     FSServer   *svr;
  81.     Font        fid;
  82.     fsBitmapFormat format;
  83.     Bool        range_type;
  84.     fsChar2b   *str;
  85.     unsigned long str_len;
  86.     fsOffset  **offsets;
  87.     unsigned char **glyphdata;
  88. {
  89.     fsQueryXBitmaps16Req *req;
  90.     fsQueryXBitmaps16Reply reply;
  91.     fsOffset   *offs;
  92.     unsigned char *gd;
  93.     int         left;
  94.  
  95.     GetReq(QueryXBitmaps16, req);
  96.     req->fid = fid;
  97.     req->range = range_type;
  98.     req->format = format;
  99.     req->num_ranges = str_len;
  100.     req->length += ((str_len * sizeof(fsChar2b)) + 3) >> 2;
  101.     _FSSend(svr, (char *) str, (str_len * sizeof(fsChar2b)));
  102.  
  103.     /* get back the info */
  104.     if (!_FSReply(svr, (fsReply *) & reply,
  105.           (sizeof(fsQueryXBitmaps16Reply) - sizeof(fsGenericReply)) >> 2,
  106.           fsFalse))
  107.     return FSBadAlloc;
  108.  
  109.     offs = (fsOffset *) FSmalloc(sizeof(fsOffset) * reply.num_chars);
  110.     *offsets = offs;
  111.     if (!offs)
  112.     return FSBadAlloc;
  113.     left = (reply.length << 2) - sizeof(fsQueryXBitmaps16Reply)
  114.     - (sizeof(fsOffset) * reply.num_chars);
  115.     gd = (unsigned char *) FSmalloc(left);
  116.     *glyphdata = gd;
  117.     if (!gd) {
  118.     FSfree((char *) offs);
  119.     return FSBadAlloc;
  120.     }
  121.     _FSReadPad(svr, (char *) offs, (sizeof(fsOffset) * reply.num_chars));
  122.     _FSReadPad(svr, (char *) gd, left);
  123.  
  124.     SyncHandle();
  125.     return FSSuccess;
  126. }
  127.