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

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