xfsinfo.c revision 067610f1
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 71char *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 fprintf(stderr, "%s: no font server defined\n", progname); 104 exit(1); 105 } 106 fprintf(stderr, "%s: unable to open server \"%s\"\n", 107 progname, FSServerName(servername)); 108 exit(1); 109 } 110 print_server_info(svr); 111 FSCloseServer(svr); 112 exit(0); 113} 114 115static void 116print_server_info(FSServer *svr) 117{ 118 printf("name of server: %s\n", FSServerString(svr)); 119 printf("version number: %d\n", FSProtocolVersion(svr)); 120 printf("vendor string: %s\n", FSServerVendor(svr)); 121 printf("vendor release number: %d\n", FSVendorRelease(svr)); 122 printf("maximum request size: %ld longwords (%ld bytes)\n", 123 FSMaxRequestSize(svr), FSMaxRequestSize(svr) * sizeof(long)); 124 print_catalogue_info(svr); 125 print_alternate_info(svr); 126 print_extension_info(svr); 127} 128 129static void 130print_catalogue_info(FSServer *svr) 131{ 132 int n = 0; 133 char **cats = FSListCatalogues(svr, "*", 1000, &n); 134 135 printf("number of catalogues: %d\n", n); 136 if (cats) { 137 int i; 138 139 for (i = 0; i < n; i++) { 140 printf(" %s\n", cats[i]); 141 } 142 FSFreeCatalogues(cats); 143 } 144} 145 146static void 147print_extension_info(FSServer *svr) 148{ 149 int n = 0; 150 char **extlist = FSListExtensions(svr, &n); 151 152 printf("number of extensions: %d\n", n); 153 if (extlist) { 154 int i; 155 156 for (i = 0; i < n; i++) { 157 printf(" %s\n", extlist[i]); 158 } 159 FSFreeExtensionList(extlist); 160 } 161} 162 163static void 164print_alternate_info(FSServer *svr) 165{ 166 AlternateServer *alts; 167 int i, 168 num; 169 170 num = FSNumAlternateServers(svr); 171 printf("Number of alternate servers: %d\n", num); 172 if (num) { 173 alts = FSAlternateServers(svr); 174 for (i = 0; i < num; i++) { 175 printf(" #%1d\t%s%s\n", i, alts[i].name, 176 (alts[i].subset) ? "(subset)" : ""); 177 } 178 } 179} 180