1067610f1Smrg/* 2067610f1Smrg * xfsinfo -- report info about a font server 3067610f1Smrg */ 4067610f1Smrg 5067610f1Smrg/* 6067610f1Smrg 7067610f1SmrgPortions Copyright 1987, 1998 The Open Group 8067610f1Smrg 9067610f1SmrgPermission to use, copy, modify, distribute, and sell this software and its 10067610f1Smrgdocumentation for any purpose is hereby granted without fee, provided that 11067610f1Smrgthe above copyright notice appear in all copies and that both that 12067610f1Smrgcopyright notice and this permission notice appear in supporting 13067610f1Smrgdocumentation. 14067610f1Smrg 15067610f1SmrgThe above copyright notice and this permission notice shall be included 16067610f1Smrgin all copies or substantial portions of the Software. 17067610f1Smrg 18067610f1SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19067610f1SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20067610f1SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21067610f1SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 22067610f1SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23067610f1SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24067610f1SmrgOTHER DEALINGS IN THE SOFTWARE. 25067610f1Smrg 26067610f1SmrgExcept as contained in this notice, the name of The Open Group shall 27067610f1Smrgnot be used in advertising or otherwise to promote the sale, use or 28067610f1Smrgother dealings in this Software without prior written authorization 29067610f1Smrgfrom The Open Group. 30067610f1Smrg 31067610f1Smrg*/ 32067610f1Smrg 33067610f1Smrg/* 34067610f1Smrg * Copyright 1990 Network Computing Devices; 35067610f1Smrg * Portions Copyright 1987 by Digital Equipment Corporation 36067610f1Smrg * 37067610f1Smrg * Permission to use, copy, modify, distribute, and sell this software and its 38067610f1Smrg * documentation for any purpose is hereby granted without fee, provided that 39067610f1Smrg * the above copyright notice appear in all copies and that both that 40067610f1Smrg * copyright notice and this permission notice appear in supporting 41067610f1Smrg * documentation, and that the names of Network Computing Devices 42067610f1Smrg * or Digital not be used in advertising or 43067610f1Smrg * publicity pertaining to distribution of the software without specific, 44067610f1Smrg * written prior permission. Network Computing Devices and Digital 45067610f1Smrg * make no representations about the 46067610f1Smrg * suitability of this software for any purpose. It is provided "as is" 47067610f1Smrg * without express or implied warranty. 48067610f1Smrg * 49067610f1Smrg * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH 50067610f1Smrg * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 51067610f1Smrg * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE 52067610f1Smrg * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 53067610f1Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 54067610f1Smrg * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 55067610f1Smrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 56067610f1Smrg * 57067610f1Smrg */ 58067610f1Smrg 59e7fdea5fSmrg#ifdef HAVE_CONFIG_H 60e7fdea5fSmrg# include "config.h" 61e7fdea5fSmrg#endif 62e7fdea5fSmrg 63067610f1Smrg#include <stdio.h> 64067610f1Smrg#include <stdlib.h> 65067610f1Smrg#include <X11/Xos.h> 66067610f1Smrg#include <X11/fonts/FSlib.h> 67067610f1Smrg 68067610f1Smrgstatic void print_server_info(FSServer *svr); 69067610f1Smrgstatic void print_catalogue_info(FSServer *svr); 70067610f1Smrgstatic void print_extension_info(FSServer *svr); 71067610f1Smrgstatic void print_alternate_info(FSServer *svr); 72067610f1Smrg 737e6533d5Smrgstatic char *progname; 74067610f1Smrg 7558105723Smrgstatic void _X_NORETURN _X_COLD 76067610f1Smrgusage(void) 77067610f1Smrg{ 78e7fdea5fSmrg fprintf(stderr, "usage: %s [-server server_name] [-version]\n", progname); 79067610f1Smrg exit(-1); 80067610f1Smrg} 81067610f1Smrg 82067610f1Smrgint 83067610f1Smrgmain(int argc, char *argv[]) 84067610f1Smrg{ 85067610f1Smrg FSServer *svr; 86067610f1Smrg char *servername = NULL; 87067610f1Smrg 88067610f1Smrg progname = argv[0]; 89067610f1Smrg 9058105723Smrg for (int i = 1; i < argc; i++) { 91067610f1Smrg if (strncmp(argv[i], "-s", 2) == 0) { 92e7fdea5fSmrg if (++i >= argc) { 93e7fdea5fSmrg fprintf (stderr, "%s: %s requires an argument\n", 94e7fdea5fSmrg progname, argv[i-1]); 95067610f1Smrg usage(); 96e7fdea5fSmrg } 97067610f1Smrg servername = argv[i]; 98e7fdea5fSmrg } else if (strcmp(argv[i], "-version") == 0) { 99e7fdea5fSmrg puts(PACKAGE_STRING); 100e7fdea5fSmrg exit(0); 101067610f1Smrg } else { 102e7fdea5fSmrg fprintf (stderr, "%s: unrecognized argument %s\n", 103e7fdea5fSmrg progname, argv[i]); 104067610f1Smrg usage(); 105067610f1Smrg } 106067610f1Smrg } 107067610f1Smrg 108067610f1Smrg svr = FSOpenServer(servername); 109067610f1Smrg 110067610f1Smrg if (!svr) { 111067610f1Smrg if (FSServerName(servername) == NULL) { 1127e6533d5Smrg if ((svr = FSOpenServer("unix/:-1")) == NULL) { 1137e6533d5Smrg fprintf(stderr, "%s: no font server defined\n", progname); 1147e6533d5Smrg exit(1); 1157e6533d5Smrg } 1167e6533d5Smrg } 1177e6533d5Smrg if (!svr) { 1187e6533d5Smrg fprintf(stderr, "%s: unable to open server \"%s\"\n", 1197e6533d5Smrg progname, FSServerName(servername)); 120067610f1Smrg exit(1); 121067610f1Smrg } 122067610f1Smrg } 123067610f1Smrg print_server_info(svr); 124067610f1Smrg FSCloseServer(svr); 125067610f1Smrg exit(0); 126067610f1Smrg} 127067610f1Smrg 128067610f1Smrgstatic void 129067610f1Smrgprint_server_info(FSServer *svr) 130067610f1Smrg{ 131067610f1Smrg printf("name of server: %s\n", FSServerString(svr)); 132067610f1Smrg printf("version number: %d\n", FSProtocolVersion(svr)); 133067610f1Smrg printf("vendor string: %s\n", FSServerVendor(svr)); 134067610f1Smrg printf("vendor release number: %d\n", FSVendorRelease(svr)); 135aea1d7ffSmrg if (strstr(FSServerVendor(svr), "X.Org")) { 136aea1d7ffSmrg int vendrel = FSVendorRelease(svr); 137aea1d7ffSmrg 138aea1d7ffSmrg printf("X.Org xfs version: "); 139aea1d7ffSmrg printf("%d.%d.%d", vendrel / 10000000, 140aea1d7ffSmrg (vendrel / 100000) % 100, 141aea1d7ffSmrg (vendrel / 1000) % 100); 142aea1d7ffSmrg if (vendrel % 1000) 143aea1d7ffSmrg printf(".%d", vendrel % 1000); 144aea1d7ffSmrg printf("\n"); 145aea1d7ffSmrg } 1464d9306dbSmrg printf("maximum request size: %ld words (%ld bytes)\n", 1474d9306dbSmrg FSMaxRequestSize(svr), FSMaxRequestSize(svr) * sizeof(CARD32)); 148067610f1Smrg print_catalogue_info(svr); 149067610f1Smrg print_alternate_info(svr); 150067610f1Smrg print_extension_info(svr); 151067610f1Smrg} 152067610f1Smrg 153067610f1Smrgstatic void 154067610f1Smrgprint_catalogue_info(FSServer *svr) 155067610f1Smrg{ 156067610f1Smrg int n = 0; 157067610f1Smrg char **cats = FSListCatalogues(svr, "*", 1000, &n); 158067610f1Smrg 159067610f1Smrg printf("number of catalogues: %d\n", n); 160067610f1Smrg if (cats) { 16158105723Smrg for (int i = 0; i < n; i++) { 162067610f1Smrg printf(" %s\n", cats[i]); 163067610f1Smrg } 164067610f1Smrg FSFreeCatalogues(cats); 165067610f1Smrg } 166067610f1Smrg} 167067610f1Smrg 168067610f1Smrgstatic void 169067610f1Smrgprint_extension_info(FSServer *svr) 170067610f1Smrg{ 171067610f1Smrg int n = 0; 172067610f1Smrg char **extlist = FSListExtensions(svr, &n); 173067610f1Smrg 174067610f1Smrg printf("number of extensions: %d\n", n); 175067610f1Smrg if (extlist) { 17658105723Smrg for (int i = 0; i < n; i++) { 177067610f1Smrg printf(" %s\n", extlist[i]); 178067610f1Smrg } 179067610f1Smrg FSFreeExtensionList(extlist); 180067610f1Smrg } 181067610f1Smrg} 182067610f1Smrg 183067610f1Smrgstatic void 184067610f1Smrgprint_alternate_info(FSServer *svr) 185067610f1Smrg{ 18658105723Smrg int num; 187067610f1Smrg 188067610f1Smrg num = FSNumAlternateServers(svr); 189067610f1Smrg printf("Number of alternate servers: %d\n", num); 190067610f1Smrg if (num) { 19158105723Smrg AlternateServer *alts = FSAlternateServers(svr); 19258105723Smrg 19358105723Smrg for (int i = 0; i < num; i++) { 194067610f1Smrg printf(" #%1d\t%s%s\n", i, alts[i].name, 195067610f1Smrg (alts[i].subset) ? "(subset)" : ""); 196067610f1Smrg } 197067610f1Smrg } 198067610f1Smrg} 199