diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:04:09 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-17 19:04:09 +0000 |
commit | 934e5054453579699172a1f59478608a5eee5e24 (patch) | |
tree | afbf92ee5db9e720f8eefe4a8607bc8e497b08ac | |
parent | 53c921965d341cfa3f14fedf862d9db666c16002 (diff) |
merge XFree86 4.3.0.1 to -CURRENT
-rw-r--r-- | LED.c | 52 | ||||
-rw-r--r-- | utils.c | 105 | ||||
-rw-r--r-- | utils.h | 34 | ||||
-rw-r--r-- | xkbbell.c | 14 | ||||
-rw-r--r-- | xkbvleds.c | 30 | ||||
-rw-r--r-- | xkbwatch.c | 72 |
6 files changed, 127 insertions, 180 deletions
@@ -24,6 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/xkbutils/LED.c,v 1.5 2001/07/25 15:05:25 dawes Exp $ */ #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> @@ -34,13 +35,8 @@ #include <X11/Xmu/Drawing.h> #include <stdio.h> #include <ctype.h> - /* needed for abs() */ -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#else -int abs(); -#endif #define streq(a,b) (strcmp( (a), (b) ) == 0) @@ -79,13 +75,16 @@ static XtResource resources[] = { }; #undef offset -static void Initialize(); -static void Resize(); -static void Realize(); -static Boolean SetValues(); -static void ClassInitialize(); -static void Destroy(); -static XtGeometryResult QueryGeometry(); +static void ClassInitialize ( void ); +static void Initialize ( Widget request, Widget new, ArgList args, + Cardinal *num_args ); +static void Realize ( Widget w, Mask * mask, XSetWindowAttributes * xswa ); +static void Resize ( Widget w ); +static Boolean SetValues ( Widget current, Widget request, Widget new, + ArgList args, Cardinal *num_args ); +static void Destroy ( Widget w ); +static XtGeometryResult QueryGeometry ( Widget w, XtWidgetGeometry *intended, + XtWidgetGeometry *preferred ); LEDClassRec ledClassRec = { { @@ -139,14 +138,14 @@ WidgetClass ledWidgetClass = (WidgetClass)&ledClassRec; * ****************************************************************/ -static void ClassInitialize() +static void +ClassInitialize(void) { XawInitializeWidgetSet(); } static void -GetPixmaps(lw) - LEDWidget lw; +GetPixmaps(LEDWidget lw) { XGCValues values; GC gc; @@ -213,10 +212,7 @@ static void Initialize(request, new, args, num_args) } /* Initialize */ static void -Realize(w, mask, xswa) - Widget w; - Mask * mask; - XSetWindowAttributes * xswa; +Realize(Widget w, Mask *mask, XSetWindowAttributes *xswa) { LEDWidget lw = (LEDWidget)w; WidgetClass super = simpleWidgetClass; @@ -230,8 +226,7 @@ Realize(w, mask, xswa) } static void -Resize(w) - Widget w; +Resize(Widget w) { GetPixmaps((LEDWidget)w); return; @@ -242,10 +237,8 @@ Resize(w) */ static Boolean -SetValues(current, request, new, args, num_args) - Widget current, request, new; - ArgList args; - Cardinal *num_args; +SetValues(Widget current, Widget request, Widget new, + ArgList args, Cardinal *num_args) { LEDWidget curlw = (LEDWidget) current; LEDWidget newlw = (LEDWidget) new; @@ -275,8 +268,7 @@ SetValues(current, request, new, args, num_args) } static void -Destroy(w) - Widget w; +Destroy(Widget w) { LEDWidget lw = (LEDWidget)w; @@ -292,9 +284,9 @@ Destroy(w) } -static XtGeometryResult QueryGeometry(w, intended, preferred) - Widget w; - XtWidgetGeometry *intended, *preferred; +static XtGeometryResult +QueryGeometry(Widget w, XtWidgetGeometry *intended, + XtWidgetGeometry *preferred) { LEDWidget lw = (LEDWidget)w; @@ -25,14 +25,11 @@ * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. \*/ +/* $XFree86: xc/programs/xkbutils/utils.c,v 3.5 2001/07/25 15:05:25 dawes Exp $ */ #include "utils.h" #include <ctype.h> -#ifndef X_NOT_STDC_ENV -#include <stdlib.h> -#else -char *malloc(); -#endif +#include <stdlib.h> /***====================================================================***/ @@ -102,7 +99,7 @@ uFree(ptr) /*** FUNCTION ENTRY TRACKING ***/ /***====================================================================***/ -static FILE *entryFile= stderr; +static FILE *entryFile= NULL; int uEntryLevel; Boolean @@ -123,18 +120,18 @@ uSetEntryFile(name) } void -uEntry(l,s,a1,a2,a3,a4,a5,a6,a7,a8) -int l; -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uEntry(int l, char *s,...) { int i; +va_list ap; + va_start(ap, s); for (i=0;i<uEntryLevel;i++) { putc(' ',entryFile); } - fprintf(entryFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(entryFile,s,ap); uEntryLevel+= l; + va_end(ap); return; } @@ -158,7 +155,7 @@ int i; /*** PRINT FUNCTIONS ***/ /***====================================================================***/ - FILE *uDebugFile= stderr; + FILE *uDebugFile= NULL; int uDebugIndentLevel= 0; int uDebugIndentSize= 4; @@ -180,37 +177,39 @@ uSetDebugFile(name) } void -uDebug(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uDebug(char *s,...) { int i; +va_list ap; + va_start(ap, s); for (i=(uDebugIndentLevel*uDebugIndentSize);i>0;i--) { putc(' ',uDebugFile); } - fprintf(uDebugFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(uDebugFile,s,ap); fflush(uDebugFile); + va_end(ap); return; } void -uDebugNOI(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uDebugNOI(char *s,...) { - fprintf(uDebugFile,s,a1,a2,a3,a4,a5,a6,a7,a8); +va_list ap; + + va_start(ap, s); + vfprintf(uDebugFile,s,ap); fflush(uDebugFile); + va_end(ap); return; } /***====================================================================***/ -static FILE *errorFile= stderr; +static FILE *errorFile= NULL; Boolean -uSetErrorFile(name) - char *name; +uSetErrorFile(char *name) { if ((errorFile!=NULL)&&(errorFile!=stderr)) { fprintf(errorFile,"switching to %s\n",name?name:"stderr"); @@ -226,65 +225,75 @@ uSetErrorFile(name) } void -uInformation(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uInformation(char *s,...) { - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + va_list ap; + + va_start(ap, s); + vfprintf(errorFile,s,ap); fflush(errorFile); + va_end(ap); return; } /***====================================================================***/ void -uAction(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uAction(char *s,...) { + va_list ap; + + va_start(ap, s); fprintf(errorFile," "); - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(errorFile,s,ap); fflush(errorFile); + va_end(ap); return; } /***====================================================================***/ void -uWarning(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uWarning(char *s,...) { + va_list ap; + + va_start(ap, s); fprintf(errorFile,"Warning: "); - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(errorFile,s,ap); fflush(errorFile); + va_end(ap); return; } /***====================================================================***/ void -uError(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uError(char *s,...) { + va_list ap; + + va_start(ap, s); fprintf(errorFile,"Error: "); - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(errorFile,s,ap); fflush(errorFile); + va_end(ap); return; } /***====================================================================***/ void -uFatalError(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uFatalError(char *s,...) { + va_list ap; + + va_start(ap, s); fprintf(errorFile,"Fatal Error: "); - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(errorFile,s,ap); fprintf(errorFile," Exiting\n"); fflush(errorFile); + va_end(ap); exit(1); /* NOTREACHED */ } @@ -292,13 +301,15 @@ Opaque a1,a2,a3,a4,a5,a6,a7,a8; /***====================================================================***/ void -uInternalError(s,a1,a2,a3,a4,a5,a6,a7,a8) -char *s; -Opaque a1,a2,a3,a4,a5,a6,a7,a8; +uInternalError(char *s,...) { + va_list ap; + + va_start(ap, s); fprintf(errorFile,"Internal error: "); - fprintf(errorFile,s,a1,a2,a3,a4,a5,a6,a7,a8); + vfprintf(errorFile,s,ap); fflush(errorFile); + va_end(ap); return; } @@ -27,6 +27,7 @@ * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. \*/ +/* $XFree86: xc/programs/xkbutils/utils.h,v 1.5 2001/07/25 15:05:26 dawes Exp $ */ /***====================================================================***/ @@ -34,12 +35,11 @@ #include <X11/Xos.h> #include <X11/Xfuncproto.h> #include <X11/Xfuncs.h> +#include <stdarg.h> +#include <stddef.h> _XFUNCPROTOBEGIN -#ifndef NULL -#define NULL 0 -#endif #ifndef NUL #define NUL '\0' @@ -74,12 +74,14 @@ typedef int Comparison; #define comparisonText(c) ((c)?((c)<0?"Less":"Greater"):"Equal") #endif +#ifdef notyet typedef union { int i; unsigned u; void *p; - void *(*fp)(); + void *(*fp)(); } Union; +#endif /***====================================================================***/ @@ -128,17 +130,13 @@ extern void uFree( /***====================================================================***/ -extern Boolean uSetErrorFile( -#if NeedFunctionPrototypes - char * /* name */ -#endif -); -extern void uInformation(); -extern void uAction(); -extern void uWarning(); -extern void uError(); -extern void uFatalError(); -extern void uInternalError(); +extern Boolean uSetErrorFile ( char *name ); +extern void uInformation ( char *s, ...); +extern void uAction ( char *s, ... ); +extern void uWarning ( char *s, ... ); +extern void uError ( char *s, ... ); +extern void uFatalError(char *s,...); +extern void uInternalError ( char *s, ... ); /***====================================================================***/ @@ -196,8 +194,8 @@ extern #endif unsigned int DEBUG_VAR; -extern void uDebug(); -extern void uDebugNOI(); /* no indent */ +extern void uDebug( char *s, ... ); +extern void uDebugNOI( char *s, ... ); /* no indent */ extern Boolean uSetDebugFile( #if NeedFunctionPrototypes char *name @@ -241,7 +239,7 @@ extern Boolean uSetEntryFile( char *name #endif ); -extern void uEntry(); +extern void uEntry(int l, char *s, ... ); extern void uExit( #if NeedFunctionPrototypes int l,char *rtVal @@ -24,8 +24,10 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/xkbutils/xkbbell.c,v 1.5 2001/04/01 14:00:22 tsi Exp $ */ #include <stdio.h> +#include <string.h> #include <X11/Xproto.h> #include <X11/Xlib.h> #include <X11/X.h> @@ -44,10 +46,8 @@ static int win = None; static int force = 0; static int nobeep = 0; -int -parseArgs(argc,argv) - int argc; - char *argv[]; +static int +parseArgs(int argc, char *argv[]) { int i; @@ -146,9 +146,7 @@ int i; } int -main(argc,argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { Display *dpy; int i1,i2,i3,i4,i5; @@ -219,7 +217,7 @@ int i1,i2,i3,i4,i5; if (!ok) fprintf(stderr,"XkbDeviceBell request failed\n"); } -BAIL: +/* BAIL: */ XCloseDisplay(dpy); return 0; } @@ -24,7 +24,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/xkbutils/xkbvleds.c,v 3.5 2001/04/01 14:00:22 tsi Exp $ */ +#include <stdlib.h> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/XKBlib.h> @@ -62,8 +64,7 @@ static char * inDpyName; /***====================================================================***/ static void -usage(program) - char * program; +usage(char *program) { uInformation("Usage: %s <options>\n",program); uInformation("Legal options include the usual X toolkit options plus:\n"); @@ -82,9 +83,7 @@ usage(program) } static Bool -parseArgs(argc,argv) - int argc; - char * argv[]; +parseArgs(int argc, char *argv[]) { register int i; @@ -152,10 +151,8 @@ register int i; /***====================================================================***/ -Display * -GetDisplay(program,dpyName) - char * program; - char * dpyName; +static Display * +GetDisplay(char *program, char *dpyName) { int mjr,mnr,error; Display * dpy; @@ -195,9 +192,7 @@ Display * dpy; /***====================================================================***/ int -main(argc,argv) - int argc; - char * argv[]; +main(int argc, char *argv[]) { Widget toplevel; XtAppContext app_con; @@ -208,14 +203,17 @@ unsigned bit; unsigned n; XkbDescPtr xkb; XkbEvent ev; -static Arg boxArgs[]= { XtNorientation, (XtArgVal)XtorientHorizontal }; -static Arg onArgs[]= { XtNon, (XtArgVal)True }; -static Arg offArgs[]= { XtNon, (XtArgVal)False }; +static Arg boxArgs[]= {{ XtNorientation, (XtArgVal)XtorientHorizontal }}; +static Arg onArgs[]= {{ XtNon, (XtArgVal)True }}; +static Arg offArgs[]= {{ XtNon, (XtArgVal)False }}; static char * fallback_resources[] = { "*Box*background: grey40", NULL }; + uSetEntryFile(NullString); + uSetDebugFile(NullString); + uSetErrorFile(NullString); bzero(leds,XkbNumIndicators*sizeof(Widget)); toplevel = XtOpenApplication(&app_con, "XkbLEDPanel", NULL, 0, &argc, argv, fallback_resources, @@ -352,7 +350,7 @@ static char * fallback_resources[] = { } else XtDispatchEvent(&ev.core); } -BAIL: +/* BAIL: */ if (inDpy) XCloseDisplay(inDpy); if (outDpy!=inDpy) @@ -24,7 +24,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/xkbutils/xkbwatch.c,v 3.5 2001/04/01 14:00:22 tsi Exp $ */ +#include <stdlib.h> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/XKBlib.h> @@ -44,22 +46,11 @@ /***====================================================================***/ Display * inDpy,*outDpy; -static unsigned long wanted= 0xff; int evBase,errBase; Bool synch; /***====================================================================***/ -struct _resource { - char * inDpyName; -}; - -#define offset(field) XtOffsetOf(struct _resource, field) -static XtResource app_resources[] = { - {"inputDisplay", "InputDisplay", XtRString, sizeof(char *), - offset(inDpyName), XtRString, NULL } -}; -#undef offset static XrmOptionDescRec options[] = { {"-off", "*on.on", XrmoptionNoArg, "FALSE"}, @@ -68,52 +59,8 @@ static XrmOptionDescRec options[] = { /***====================================================================***/ -Display * -GetDisplay(program,dpyName) - char * program; - char * dpyName; -{ -int mjr,mnr,error; -Display * dpy; - - mjr= XkbMajorVersion; - mnr= XkbMinorVersion; - dpy= XkbOpenDisplay(dpyName,&evBase,&errBase,&mjr,&mnr,&error); - if (dpy==NULL) { - switch (error) { - case XkbOD_BadLibraryVersion: - uInformation("%s was compiled with XKB version %d.%02d\n", - program,XkbMajorVersion,XkbMinorVersion); - uError("X library supports incompatible version %d.%02d\n", - mjr,mnr); - break; - case XkbOD_ConnectionRefused: - uError("Cannot open display \"%s\"\n",dpyName); - break; - case XkbOD_NonXkbServer: - uError("XKB extension not present on %s\n",dpyName); - break; - case XkbOD_BadServerVersion: - uInformation("%s was compiled with XKB version %d.%02d\n", - program,XkbMajorVersion,XkbMinorVersion); - uError("Server %s uses incompatible version %d.%02d\n", - dpyName,mjr,mnr); - break; - default: - uInternalError("Unknown error %d from XkbOpenDisplay\n",error); - } - } - else if (synch) - XSynchronize(dpy,True); - return dpy; -} - -/***====================================================================***/ - int -main(argc,argv) - int argc; - char * argv[]; +main(int argc, char *argv[]) { Widget toplevel; XtAppContext app_con; @@ -128,10 +75,10 @@ register int i; unsigned bit; XkbEvent ev; XkbStateRec state; -static Arg hArgs[]= { XtNorientation, (XtArgVal)XtorientHorizontal }; -static Arg vArgs[]= { XtNorientation, (XtArgVal)XtorientVertical }; -static Arg onArgs[]= { XtNon, (XtArgVal)True }; -static Arg offArgs[]= { XtNon, (XtArgVal)False }; +static Arg hArgs[]= {{ XtNorientation, (XtArgVal)XtorientHorizontal }}; +static Arg vArgs[]= {{ XtNorientation, (XtArgVal)XtorientVertical }}; +static Arg onArgs[]= {{ XtNon, (XtArgVal)True }}; +static Arg offArgs[]= {{ XtNon, (XtArgVal)False }}; static char * fallback_resources[] = { "*Box*background: grey50", "*Box*borderWidth: 0", @@ -139,6 +86,9 @@ static char * fallback_resources[] = { NULL }; + uSetEntryFile(NullString); + uSetDebugFile(NullString); + uSetErrorFile(NullString); toplevel = XtOpenApplication(&app_con, "XkbWatch", options, XtNumber(options), &argc, argv, fallback_resources, @@ -273,7 +223,7 @@ static char * fallback_resources[] = { } else XtDispatchEvent(&ev.core); } -BAIL: +/* BAIL: */ if (inDpy) XCloseDisplay(inDpy); if (outDpy!=inDpy) |