Home | History | Annotate | Line # | Download | only in src
      1 /*
      2  * Copyright 1990 Network Computing Devices;
      3  * Portions Copyright 1987 by Digital Equipment Corporation
      4  *
      5  * Permission to use, copy, modify, distribute, and sell this software
      6  * and its documentation for any purpose is hereby granted without fee,
      7  * provided that the above copyright notice appear in all copies and
      8  * that both that copyright notice and this permission notice appear
      9  * in supporting documentation, and that the names of Network Computing
     10  * Devices or Digital not be used in advertising or publicity pertaining
     11  * to distribution of the software without specific, written prior
     12  * permission. Network Computing Devices or Digital make no representations
     13  * about the suitability of this software for any purpose.  It is provided
     14  * "as is" without express or implied warranty.
     15  *
     16  * NETWORK COMPUTING DEVICES AND  DIGITAL DISCLAIM ALL WARRANTIES WITH
     17  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
     18  * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
     19  * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
     20  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     21  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     22  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     23  * SOFTWARE.
     24  */
     25 
     26 /*
     27 
     28 Copyright 1987, 1998  The Open Group
     29 
     30 Permission to use, copy, modify, distribute, and sell this software and its
     31 documentation for any purpose is hereby granted without fee, provided that
     32 the above copyright notice appear in all copies and that both that
     33 copyright notice and this permission notice appear in supporting
     34 documentation.
     35 
     36 The above copyright notice and this permission notice shall be included in
     37 all copies or substantial portions of the Software.
     38 
     39 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     40 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     41 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     42 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     43 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     44 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     45 
     46 Except as contained in this notice, the name of The Open Group shall not be
     47 used in advertising or otherwise to promote the sale, use or other dealings
     48 in this Software without prior written authorization from The Open Group.
     49 
     50 */
     51 
     52 #ifdef HAVE_CONFIG_H
     53 #include <config.h>
     54 #endif
     55 #include	"FSlibint.h"
     56 
     57 /*
     58  * Note:  only the range in the first FSQuery is sent to the server.
     59  * the others exist as return values only.
     60  */
     61 
     62 int
     63 FSQueryXInfo(
     64     FSServer		 *svr,
     65     Font		  fid,
     66     FSXFontInfoHeader	 *info,
     67     FSPropInfo		 *props,
     68     FSPropOffset	**offsets,
     69     unsigned char	**prop_data)
     70 {
     71     fsQueryXInfoReq *req;
     72     fsQueryXInfoReply reply;
     73     FSPropOffset *offset_data;
     74     unsigned char *pdata;
     75     fsPropInfo local_pi;
     76     fsPropOffset local_po;
     77 
     78     GetReq(QueryXInfo, req);
     79     req->id = fid;
     80 
     81     /* get back the info */
     82     if (!_FSReply(svr, (fsReply *) & reply, ((SIZEOF(fsQueryXInfoReply) -
     83 			    SIZEOF(fsGenericReply)) >> 2), fsFalse)) {
     84 	return FSBadAlloc;
     85     }
     86 
     87     FSUnpack_XFontInfoHeader(&reply, info, FSProtocolVersion(svr));
     88 
     89     /* get the prop header */
     90     _FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo));
     91     props->num_offsets = local_pi.num_offsets;
     92     props->data_len = local_pi.data_len;
     93 
     94 #if SIZE_MAX <= UINT_MAX
     95     if (props->num_offsets > SIZE_MAX / sizeof(FSPropOffset))
     96 	return FSBadAlloc;
     97 #endif
     98 
     99     /* prepare for prop data */
    100     offset_data = FSmallocarray(props->num_offsets, sizeof(FSPropOffset));
    101     if (!offset_data)
    102 	return FSBadAlloc;
    103     pdata = FSmalloc(props->data_len);
    104     if (!pdata) {
    105 	FSfree(offset_data);
    106 	return FSBadAlloc;
    107     }
    108     /* get offsets */
    109     for (unsigned int j = 0; j < props->num_offsets; j++)
    110     {
    111 	_FSReadPad(svr, (char *) &local_po, SIZEOF(fsPropOffset));
    112 	offset_data[j].name.position = local_po.name.position;
    113 	offset_data[j].name.length = local_po.name.length;
    114 	offset_data[j].value.position = local_po.value.position;
    115 	offset_data[j].value.length = local_po.value.length;
    116 	offset_data[j].type = local_po.type;
    117     }
    118 
    119     /* get data */
    120     _FSReadPad(svr, (char *) pdata, props->data_len);
    121     *offsets = offset_data;
    122     *prop_data = pdata;
    123 
    124     SyncHandle();
    125     return FSSuccess;
    126 }
    127