/* $XConsortium: xkblist.c /main/3 1996/02/05 11:45:07 kaleb $ */ /************************************************************ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Silicon Graphics not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission. Silicon Graphics makes no representation about the suitability of this software for any purpose. It is provided "as is" without any express or implied warranty. SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ #include #include #include #include #include #include #include #include static char * dpyName = NULL; static unsigned dev = XkbUseCoreKbd; static XkbComponentNamesRec patterns; static int synch; static unsigned debug= 0; static int max_rtrn= 65000; int #if NeedFunctionPrototypes parseArgs(int argc,char *argv[]) #else parseArgs(argc,argv) int argc; char *argv[]; #endif { int i; for (i=1;iname?name->name:"!!!ERROR!!!")); } return; } int #if NeedFunctionPrototypes main(int argc,char *argv[]) #else main(argc,argv) int argc; char *argv[]; #endif { Display * dpy; int major,minor,why; unsigned old_debug; int ok; XkbComponentListPtr list; if (!parseArgs(argc,argv)) { fprintf(stderr,"Usage: %s \n",argv[0]); fprintf(stderr,"Where legal options are:\n"); fprintf(stderr,"-display specifies display to use\n"); fprintf(stderr,"-device specifies device to use\n"); fprintf(stderr,"-synch force synchronization\n"); fprintf(stderr,"-keymap pattern for keymap\n"); fprintf(stderr,"-keycodes pattern for keycodes\n"); fprintf(stderr,"-types pattern for types\n"); fprintf(stderr,"-compat pattern for compat map\n"); fprintf(stderr,"-symbols pattern for symbols map\n"); fprintf(stderr,"-geometry pattern for geometry\n"); fprintf(stderr,"-limit maximum # of names to report\n"); fprintf(stderr,"\nLists the elements of the server database whose\n"); fprintf(stderr,"names match the specified patterns.\n"); return 1; } ok= 1; major= XkbMajorVersion; minor= XkbMinorVersion; dpy = XkbOpenDisplay(dpyName,NULL,NULL,&major,&minor,&why); if (dpy==NULL) { if (dpyName==NULL) dpyName= "default display"; switch (why) { case XkbOD_BadLibraryVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Xlib supports incompatible version %d.%02d\n", major,minor); break; case XkbOD_ConnectionRefused: fprintf(stderr,"Cannot open display \"%s\"\n",dpyName); break; case XkbOD_NonXkbServer: fprintf(stderr,"XKB extension not present on %s\n",dpyName); break; case XkbOD_BadServerVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Server %s uses incompatible version %d.%02d\n", dpyName,major,minor); break; default: fprintf(stderr, "Internal Error! Unknown error %d from XkbOpenDisplay\n", why); } return 1; } if (synch) XSynchronize(dpy,1); if ((old_debug=debug)!=0) { XkbSetDebuggingFlags(dpy,~0,debug,argv[0],0,0,&old_debug,NULL); printf("Setting debugging flags to %d (from %d)\n", debug,old_debug); } list= XkbListComponents(dpy,dev,&patterns,&max_rtrn); if (list) { printf("XkbListComponents ok\n"); if (max_rtrn>0) printf("An additional %d matching names were not returned\n"); Show("keymaps",patterns.keymap,list->num_keymaps,list->keymaps); Show("keycodes",patterns.keycodes,list->num_keycodes,list->keycodes); Show("types",patterns.types,list->num_types,list->types); Show("compat",patterns.compat,list->num_compat,list->compat); Show("symbols",patterns.symbols,list->num_symbols,list->symbols); Show("geometry",patterns.geometry,list->num_geometry,list->geometry); } else { printf("XkbListComponents failed\n"); } if (old_debug!=debug) { XkbSetDebuggingFlags(dpy,~0,old_debug,argv[0],0,0,&debug,NULL); printf("Resetting debugging flags to %d (from %d)\n", old_debug,debug); } XCloseDisplay(dpy); return (ok!=0); }