xfsinfo.c revision 7e6533d5
1067610f1Smrg/*
2067610f1Smrg * xfsinfo -- report info about a font server
3067610f1Smrg */
4067610f1Smrg
5067610f1Smrg/* $TOG: fsinfo.c /main/7 1998/02/09 13:43:08 kaleb $ */
6067610f1Smrg/*
7067610f1Smrg
8067610f1SmrgPortions Copyright 1987, 1998  The Open Group
9067610f1Smrg
10067610f1SmrgPermission to use, copy, modify, distribute, and sell this software and its
11067610f1Smrgdocumentation for any purpose is hereby granted without fee, provided that
12067610f1Smrgthe above copyright notice appear in all copies and that both that
13067610f1Smrgcopyright notice and this permission notice appear in supporting
14067610f1Smrgdocumentation.
15067610f1Smrg
16067610f1SmrgThe above copyright notice and this permission notice shall be included
17067610f1Smrgin all copies or substantial portions of the Software.
18067610f1Smrg
19067610f1SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20067610f1SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21067610f1SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22067610f1SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
23067610f1SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24067610f1SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25067610f1SmrgOTHER DEALINGS IN THE SOFTWARE.
26067610f1Smrg
27067610f1SmrgExcept as contained in this notice, the name of The Open Group shall
28067610f1Smrgnot be used in advertising or otherwise to promote the sale, use or
29067610f1Smrgother dealings in this Software without prior written authorization
30067610f1Smrgfrom The Open Group.
31067610f1Smrg
32067610f1Smrg*/
33067610f1Smrg/* $XFree86: xc/programs/xfsinfo/xfsinfo.c,v 1.3 2001/08/27 17:41:02 dawes Exp $ */
34067610f1Smrg
35067610f1Smrg/*
36067610f1Smrg * Copyright 1990 Network Computing Devices;
37067610f1Smrg * Portions Copyright 1987 by Digital Equipment Corporation
38067610f1Smrg *
39067610f1Smrg * Permission to use, copy, modify, distribute, and sell this software and its
40067610f1Smrg * documentation for any purpose is hereby granted without fee, provided that
41067610f1Smrg * the above copyright notice appear in all copies and that both that
42067610f1Smrg * copyright notice and this permission notice appear in supporting
43067610f1Smrg * documentation, and that the names of Network Computing Devices
44067610f1Smrg * or Digital not be used in advertising or
45067610f1Smrg * publicity pertaining to distribution of the software without specific,
46067610f1Smrg * written prior permission.  Network Computing Devices and Digital
47067610f1Smrg * make no representations about the
48067610f1Smrg * suitability of this software for any purpose.  It is provided "as is"
49067610f1Smrg * without express or implied warranty.
50067610f1Smrg *
51067610f1Smrg * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
52067610f1Smrg * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53067610f1Smrg * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
54067610f1Smrg * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
55067610f1Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
56067610f1Smrg * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
57067610f1Smrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
58067610f1Smrg *
59067610f1Smrg */
60067610f1Smrg
61067610f1Smrg#include	<stdio.h>
62067610f1Smrg#include	<stdlib.h>
63067610f1Smrg#include	<X11/Xos.h>
64067610f1Smrg#include	<X11/fonts/FSlib.h>
65067610f1Smrg
66067610f1Smrgstatic void print_server_info(FSServer *svr);
67067610f1Smrgstatic void print_catalogue_info(FSServer *svr);
68067610f1Smrgstatic void print_extension_info(FSServer *svr);
69067610f1Smrgstatic void print_alternate_info(FSServer *svr);
70067610f1Smrg
717e6533d5Smrgstatic char *progname;
72067610f1Smrg
73067610f1Smrgstatic void
74067610f1Smrgusage(void)
75067610f1Smrg{
76067610f1Smrg    fprintf(stderr, "usage:  %s [-server server_name]\n", progname);
77067610f1Smrg    exit(-1);
78067610f1Smrg}
79067610f1Smrg
80067610f1Smrgint
81067610f1Smrgmain(int argc, char *argv[])
82067610f1Smrg{
83067610f1Smrg    FSServer   *svr;
84067610f1Smrg    char       *servername = NULL;
85067610f1Smrg    int         i;
86067610f1Smrg
87067610f1Smrg    progname = argv[0];
88067610f1Smrg
89067610f1Smrg    for (i = 1; i < argc; i++) {
90067610f1Smrg	if (strncmp(argv[i], "-s", 2) == 0) {
91067610f1Smrg	    if (++i > argc)
92067610f1Smrg		usage();
93067610f1Smrg	    servername = argv[i];
94067610f1Smrg	} else {
95067610f1Smrg	    usage();
96067610f1Smrg	}
97067610f1Smrg    }
98067610f1Smrg
99067610f1Smrg    svr = FSOpenServer(servername);
100067610f1Smrg
101067610f1Smrg    if (!svr) {
102067610f1Smrg	if (FSServerName(servername) == NULL) {
1037e6533d5Smrg	    if ((svr = FSOpenServer("unix/:-1")) == NULL) {
1047e6533d5Smrg		fprintf(stderr, "%s: no font server defined\n", progname);
1057e6533d5Smrg		exit(1);
1067e6533d5Smrg	    }
1077e6533d5Smrg	}
1087e6533d5Smrg	if (!svr) {
1097e6533d5Smrg	    fprintf(stderr, "%s:  unable to open server \"%s\"\n",
1107e6533d5Smrg		    progname, FSServerName(servername));
111067610f1Smrg	    exit(1);
112067610f1Smrg	}
113067610f1Smrg    }
114067610f1Smrg    print_server_info(svr);
115067610f1Smrg    FSCloseServer(svr);
116067610f1Smrg    exit(0);
117067610f1Smrg}
118067610f1Smrg
119067610f1Smrgstatic void
120067610f1Smrgprint_server_info(FSServer *svr)
121067610f1Smrg{
122067610f1Smrg    printf("name of server:	%s\n", FSServerString(svr));
123067610f1Smrg    printf("version number:	%d\n", FSProtocolVersion(svr));
124067610f1Smrg    printf("vendor string:	%s\n", FSServerVendor(svr));
125067610f1Smrg    printf("vendor release number:	%d\n", FSVendorRelease(svr));
126067610f1Smrg    printf("maximum request size:	%ld longwords (%ld bytes)\n",
127067610f1Smrg	   FSMaxRequestSize(svr), FSMaxRequestSize(svr) * sizeof(long));
128067610f1Smrg    print_catalogue_info(svr);
129067610f1Smrg    print_alternate_info(svr);
130067610f1Smrg    print_extension_info(svr);
131067610f1Smrg}
132067610f1Smrg
133067610f1Smrgstatic void
134067610f1Smrgprint_catalogue_info(FSServer *svr)
135067610f1Smrg{
136067610f1Smrg    int         n = 0;
137067610f1Smrg    char      **cats = FSListCatalogues(svr, "*", 1000, &n);
138067610f1Smrg
139067610f1Smrg    printf("number of catalogues:	%d\n", n);
140067610f1Smrg    if (cats) {
141067610f1Smrg	int         i;
142067610f1Smrg
143067610f1Smrg	for (i = 0; i < n; i++) {
144067610f1Smrg	    printf("	%s\n", cats[i]);
145067610f1Smrg	}
146067610f1Smrg	FSFreeCatalogues(cats);
147067610f1Smrg    }
148067610f1Smrg}
149067610f1Smrg
150067610f1Smrgstatic void
151067610f1Smrgprint_extension_info(FSServer *svr)
152067610f1Smrg{
153067610f1Smrg    int         n = 0;
154067610f1Smrg    char      **extlist = FSListExtensions(svr, &n);
155067610f1Smrg
156067610f1Smrg    printf("number of extensions:	%d\n", n);
157067610f1Smrg    if (extlist) {
158067610f1Smrg	int         i;
159067610f1Smrg
160067610f1Smrg	for (i = 0; i < n; i++) {
161067610f1Smrg	    printf("	%s\n", extlist[i]);
162067610f1Smrg	}
163067610f1Smrg	FSFreeExtensionList(extlist);
164067610f1Smrg    }
165067610f1Smrg}
166067610f1Smrg
167067610f1Smrgstatic void
168067610f1Smrgprint_alternate_info(FSServer *svr)
169067610f1Smrg{
170067610f1Smrg    AlternateServer *alts;
171067610f1Smrg    int         i,
172067610f1Smrg                num;
173067610f1Smrg
174067610f1Smrg    num = FSNumAlternateServers(svr);
175067610f1Smrg    printf("Number of alternate servers: %d\n", num);
176067610f1Smrg    if (num) {
177067610f1Smrg	alts = FSAlternateServers(svr);
178067610f1Smrg	for (i = 0; i < num; i++) {
179067610f1Smrg	    printf("    #%1d\t%s%s\n", i, alts[i].name,
180067610f1Smrg		   (alts[i].subset) ? "(subset)" : "");
181067610f1Smrg	}
182067610f1Smrg    }
183067610f1Smrg}
184