xfsinfo.c revision 7e6533d5
1/*
2 * xfsinfo -- report info about a font server
3 */
4
5/* $TOG: fsinfo.c /main/7 1998/02/09 13:43:08 kaleb $ */
6/*
7
8Portions Copyright 1987, 1998  The Open Group
9
10Permission to use, copy, modify, distribute, and sell this software and its
11documentation for any purpose is hereby granted without fee, provided that
12the above copyright notice appear in all copies and that both that
13copyright notice and this permission notice appear in supporting
14documentation.
15
16The above copyright notice and this permission notice shall be included
17in all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
23OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25OTHER DEALINGS IN THE SOFTWARE.
26
27Except as contained in this notice, the name of The Open Group shall
28not be used in advertising or otherwise to promote the sale, use or
29other dealings in this Software without prior written authorization
30from The Open Group.
31
32*/
33/* $XFree86: xc/programs/xfsinfo/xfsinfo.c,v 1.3 2001/08/27 17:41:02 dawes Exp $ */
34
35/*
36 * Copyright 1990 Network Computing Devices;
37 * Portions Copyright 1987 by Digital Equipment Corporation
38 *
39 * Permission to use, copy, modify, distribute, and sell this software and its
40 * documentation for any purpose is hereby granted without fee, provided that
41 * the above copyright notice appear in all copies and that both that
42 * copyright notice and this permission notice appear in supporting
43 * documentation, and that the names of Network Computing Devices
44 * or Digital not be used in advertising or
45 * publicity pertaining to distribution of the software without specific,
46 * written prior permission.  Network Computing Devices and Digital
47 * make no representations about the
48 * suitability of this software for any purpose.  It is provided "as is"
49 * without express or implied warranty.
50 *
51 * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
52 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53 * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
54 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
55 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
56 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
57 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
58 *
59 */
60
61#include	<stdio.h>
62#include	<stdlib.h>
63#include	<X11/Xos.h>
64#include	<X11/fonts/FSlib.h>
65
66static void print_server_info(FSServer *svr);
67static void print_catalogue_info(FSServer *svr);
68static void print_extension_info(FSServer *svr);
69static void print_alternate_info(FSServer *svr);
70
71static char *progname;
72
73static void
74usage(void)
75{
76    fprintf(stderr, "usage:  %s [-server server_name]\n", progname);
77    exit(-1);
78}
79
80int
81main(int argc, char *argv[])
82{
83    FSServer   *svr;
84    char       *servername = NULL;
85    int         i;
86
87    progname = argv[0];
88
89    for (i = 1; i < argc; i++) {
90	if (strncmp(argv[i], "-s", 2) == 0) {
91	    if (++i > argc)
92		usage();
93	    servername = argv[i];
94	} else {
95	    usage();
96	}
97    }
98
99    svr = FSOpenServer(servername);
100
101    if (!svr) {
102	if (FSServerName(servername) == NULL) {
103	    if ((svr = FSOpenServer("unix/:-1")) == NULL) {
104		fprintf(stderr, "%s: no font server defined\n", progname);
105		exit(1);
106	    }
107	}
108	if (!svr) {
109	    fprintf(stderr, "%s:  unable to open server \"%s\"\n",
110		    progname, FSServerName(servername));
111	    exit(1);
112	}
113    }
114    print_server_info(svr);
115    FSCloseServer(svr);
116    exit(0);
117}
118
119static void
120print_server_info(FSServer *svr)
121{
122    printf("name of server:	%s\n", FSServerString(svr));
123    printf("version number:	%d\n", FSProtocolVersion(svr));
124    printf("vendor string:	%s\n", FSServerVendor(svr));
125    printf("vendor release number:	%d\n", FSVendorRelease(svr));
126    printf("maximum request size:	%ld longwords (%ld bytes)\n",
127	   FSMaxRequestSize(svr), FSMaxRequestSize(svr) * sizeof(long));
128    print_catalogue_info(svr);
129    print_alternate_info(svr);
130    print_extension_info(svr);
131}
132
133static void
134print_catalogue_info(FSServer *svr)
135{
136    int         n = 0;
137    char      **cats = FSListCatalogues(svr, "*", 1000, &n);
138
139    printf("number of catalogues:	%d\n", n);
140    if (cats) {
141	int         i;
142
143	for (i = 0; i < n; i++) {
144	    printf("	%s\n", cats[i]);
145	}
146	FSFreeCatalogues(cats);
147    }
148}
149
150static void
151print_extension_info(FSServer *svr)
152{
153    int         n = 0;
154    char      **extlist = FSListExtensions(svr, &n);
155
156    printf("number of extensions:	%d\n", n);
157    if (extlist) {
158	int         i;
159
160	for (i = 0; i < n; i++) {
161	    printf("	%s\n", extlist[i]);
162	}
163	FSFreeExtensionList(extlist);
164    }
165}
166
167static void
168print_alternate_info(FSServer *svr)
169{
170    AlternateServer *alts;
171    int         i,
172                num;
173
174    num = FSNumAlternateServers(svr);
175    printf("Number of alternate servers: %d\n", num);
176    if (num) {
177	alts = FSAlternateServers(svr);
178	for (i = 0; i < num; i++) {
179	    printf("    #%1d\t%s%s\n", i, alts[i].name,
180		   (alts[i].subset) ? "(subset)" : "");
181	}
182    }
183}
184