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