...
 
Commits (3)
This diff is collapsed.
......@@ -25,14 +25,11 @@
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
\*/
/* $XFree86: xc/programs/xkbprint/utils.c,v 3.4 2001/01/17 23:46:11 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/xkbprint/utils.h,v 1.5 2001/07/25 15:05:25 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,44 +74,36 @@ 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
/***====================================================================***/
extern Opaque uAlloc(
#if NeedFunctionPrototypes
unsigned /* size */
#endif
);
extern Opaque uCalloc(
#if NeedFunctionPrototypes
unsigned /* n */,
unsigned /* size */
#endif
);
extern Opaque uRealloc(
#if NeedFunctionPrototypes
Opaque /* old */,
unsigned /* newSize */
#endif
);
extern Opaque uRecalloc(
#if NeedFunctionPrototypes
Opaque /* old */,
unsigned /* nOld */,
unsigned /* nNew */,
unsigned /* newSize */
#endif
);
extern void uFree(
#if NeedFunctionPrototypes
Opaque /* ptr */
#endif
);
#define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t)))
......@@ -128,17 +120,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, ... );
/***====================================================================***/
......@@ -154,25 +142,19 @@ extern void uInternalError();
#define uStrCasePrefix(p,s) (strncasecmp(p,s,strlen(p))==0)
#else
extern int uStrCaseCmp(
#if NeedFunctionPrototypes
char * /* s1 */,
char * /* s2 */
#endif
);
extern int uStrCasePrefix(
#if NeedFunctionPrototypes
char * /* p */,
char * /* str */
#endif
);
#endif
#ifdef HAVE_STRDUP
#define uStringDup(s1) (strdup(s1))
#else
extern char *uStringDup(
#if NeedFunctionPrototypes
char * /* s1 */
#endif
);
#endif
......@@ -196,12 +178,10 @@ 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
#endif
);
extern FILE *uDebugFile;
extern int uDebugIndentLevel;
......@@ -237,15 +217,11 @@ extern int uDebugIndentSize;
#endif
extern Boolean uSetEntryFile(
#if NeedFunctionPrototypes
char *name
#endif
);
extern void uEntry();
extern void uEntry(int l, char *s, ... );
extern void uExit(
#if NeedFunctionPrototypes
int l,char *rtVal
#endif
);
#ifdef ENTRY_TRACKING_ON
#define ENTRY_BIT 0x10
......
......@@ -24,6 +24,7 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
/* $XFree86: xc/programs/xkbprint/xkbprint.c,v 3.10 2003/05/27 22:27:07 tsi Exp $ */
#include <stdio.h>
#include <ctype.h>
......@@ -42,9 +43,7 @@
#define DEBUG_VAR_NOT_LOCAL
#define DEBUG_VAR debugFlags
#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
#endif
#include "utils.h"
#include "xkbprint.h"
......@@ -60,13 +59,14 @@
#define INPUT_XKB 1
#define INPUT_XKM 2
#ifdef notyet
static char *fileTypeExt[] = {
"XXX",
"xkm",
"xkb"
};
#endif
static unsigned inputFormat= INPUT_UNKNOWN;
static unsigned outputFormat= WANT_DEFAULT;
static char * wantLocale= "C";
static char * rootDir;
......@@ -76,17 +76,17 @@ static char * outputFont= NULL;
static char * inDpyName,*outDpyName;
static Display * inDpy;
static Display * outDpy;
#ifdef NOTYET
static Bool computeDflts= False;
#endif
static XKBPrintArgs args;
unsigned warningLevel= 5;
Bool synch;
/***====================================================================***/
void
Usage(argc,argv)
int argc;
char * argv[];
static void
Usage(int argc, char *argv[])
{
fprintf(stderr,"Usage: %s [options] input-file [ output-file ]\n",argv[0]);
fprintf(stderr,"Legal options:\n");
......@@ -134,10 +134,8 @@ fprintf(stderr," be \"all\", \"none\" or \"common\" (default)\n");
/***====================================================================***/
Bool
parseArgs(argc,argv)
int argc;
char * argv[];
static Bool
parseArgs(int argc, char *argv[])
{
register int i;
......@@ -189,7 +187,9 @@ register int i;
}
#endif
else if (strcmp(argv[i],"-dflts")==0) {
#ifdef NOTYET
computeDflts= True;
#endif
uWarning("Compute defaults not implemented yet\n");
}
else if (strcmp(argv[i],"-diffs")==0) {
......@@ -388,7 +388,9 @@ register int i;
warningLevel= 0;
}
else {
sscanf(argv[++i],"%i",&warningLevel);
int itmp;
if (sscanf(argv[++i],"%i",&itmp))
warningLevel = itmp;
}
}
else {
......@@ -444,19 +446,17 @@ register int i;
return False;
}
else if (uStringEqual(inputFile,"-")) {
inputFormat= INPUT_XKM;
/* Nothing */
}
else if (strchr(inputFile,':')==0) {
int len= strlen(inputFile);
if ((len>4)&&(strcmp(&inputFile[len-4],".xkm")==0)) {
inputFormat= INPUT_XKM;
/* Nothing */
}
else {
FILE *file;
file= fopen(inputFile,"r");
if (file) {
if (XkmProbe(file)) inputFormat= INPUT_XKM;
else inputFormat= INPUT_XKB;
fclose(file);
}
else {
......@@ -468,7 +468,6 @@ register int i;
else {
inDpyName= inputFile;
inputFile= NULL;
inputFormat= INPUT_XKM;
}
if (outputFormat==WANT_DEFAULT)
......@@ -544,10 +543,8 @@ register int i;
return True;
}
Display *
GetDisplay(program,dpyName)
char * program;
char * dpyName;
static Display *
GetDisplay(char *program, char *dpyName)
{
int mjr,mnr,error;
Display *dpy;
......@@ -586,19 +583,22 @@ Display *dpy;
/***====================================================================***/
#ifdef notyet
#define MAX_INCLUDE_OPTS 10
static char *includeOpt[MAX_INCLUDE_OPTS];
static int numIncludeOpts = 0;
#endif
int
main(argc,argv)
int argc;
char * argv[];
main(int argc, char *argv[])
{
FILE * file;
int ok;
XkbFileInfo result;
uSetEntryFile(NullString);
uSetDebugFile(NullString);
uSetErrorFile(NullString);
if (!parseArgs(argc,argv))
exit(1);
#ifdef DEBUG
......@@ -706,7 +706,7 @@ XkbFileInfo result;
ok= 0;
}
if (ok) {
FILE *out;
FILE *out = NULL;
if (setlocale(LC_ALL,(wantLocale))==NULL) {
if (wantLocale!=NULL) {
uWarning("Couldn't change to locale %s\n",wantLocale);
......
......@@ -27,6 +27,7 @@
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
/* $XFree86$ */
#define LABEL_AUTO -1
#define LABEL_NONE 0
......@@ -58,19 +59,15 @@ typedef struct _XKBPrintArgs {
extern Bool
DumpInternalFont(
#if NeedFunctionPrototypes
FILE * /* out */,
char * /* fontName */
#endif
);
extern Bool
GeometryToPostScript(
#if NeedFunctionPrototypes
FILE * /* out */,
XkbFileInfo * /* result */,
XKBPrintArgs * /* args */
#endif
);
#endif /* _XKBPRINT_H_ */
.\" $Xorg: xkbprint.man,v 1.3 2000/08/17 19:54:50 cpqbld Exp $
.TH XKBPRINT 1 "Release 6.4" "X Version 11"
.\"
.\" $XFree86: xc/programs/xkbprint/xkbprint.man,v 1.7 2001/01/27 18:21:16 dawes Exp $
.\"
.TH XKBPRINT 1 __xorgversion__
.SH NAME
xkbprint \- print an XKB keyboard description
.SH SYNOPSIS
......@@ -10,7 +13,7 @@ xkbprint \- print an XKB keyboard description
The
.I xkbprint
comman generates a printable or encapsulated PostScript description of the
XKB keyboard description specifed by \fIsource\fP. The \fIsource\fP can be
XKB keyboard description specified by \fIsource\fP. The \fIsource\fP can be
any compiled keymap (.xkm) file that includes a geometry description or an
X display specification. If an \fIoutput_file\fP is specified, xkbprint
writes to it. If no output file is specified, xkbprint creates replaces
......@@ -100,11 +103,11 @@ Forces synchronization for X requests.
.B -w\ \fIlevel\fP
Sets warning level (0 for no warning, 10 for all warnings).
.SH "SEE ALSO"
X(1),xkbcomp(1)
X(__miscmansuffix__),xkbcomp(1)
.SH COPYRIGHT
Copyright 1995, Silicon Graphics Computer Systems
Copyright 1995, 1998 The Open Group
.br
See \fIX(1)\fP for a full statement of rights and permissions.
See \fIX(__miscmansuffix__)\fP for a full statement of rights and permissions.
.SH AUTHOR
Erik Fortune, Silicon Graphics