aboutsummaryrefslogtreecommitdiff
path: root/xkbcomp/utils.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xkbcomp/utils.c
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xkbcomp/utils.c')
-rw-r--r--xkbcomp/utils.c411
1 files changed, 411 insertions, 0 deletions
diff --git a/xkbcomp/utils.c b/xkbcomp/utils.c
new file mode 100644
index 000000000..aa4dc8987
--- /dev/null
+++ b/xkbcomp/utils.c
@@ -0,0 +1,411 @@
+
+ /*\
+ * $Xorg: utils.c,v 1.4 2000/08/17 19:54:33 cpqbld Exp $
+ *
+ * COPYRIGHT 1990
+ * DIGITAL EQUIPMENT CORPORATION
+ * MAYNARD, MASSACHUSETTS
+ * ALL RIGHTS RESERVED.
+ *
+ * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
+ * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
+ * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
+ * FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
+ * WARRANTY.
+ *
+ * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
+ * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
+ * ADDITION TO THAT SET FORTH ABOVE.
+ *
+ * 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 Digital Equipment Corporation not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ \*/
+/* $XFree86: xc/programs/xkbcomp/utils.c,v 3.6 2001/07/25 15:05:24 dawes Exp $ */
+
+#include "utils.h"
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+/***====================================================================***/
+
+Opaque
+uAlloc(unsigned size)
+{
+ return((Opaque)malloc(size));
+}
+
+/***====================================================================***/
+
+Opaque
+uCalloc(unsigned n,unsigned size)
+{
+ return((Opaque)calloc(n,size));
+}
+
+/***====================================================================***/
+
+Opaque
+uRealloc(Opaque old,unsigned newSize)
+{
+ if (old==NULL)
+ return((Opaque)malloc(newSize));
+ else return((Opaque)realloc((char *)old,newSize));
+}
+
+/***====================================================================***/
+
+Opaque
+uRecalloc(Opaque old,unsigned nOld,unsigned nNew,unsigned itemSize)
+{
+char *rtrn;
+
+ if (old==NULL)
+ rtrn= (char *)calloc(nNew,itemSize);
+ else {
+ rtrn= (char *)realloc((char *)old,nNew*itemSize);
+ if ((rtrn)&&(nNew>nOld)) {
+ bzero(&rtrn[nOld*itemSize],(nNew-nOld)*itemSize);
+ }
+ }
+ return (Opaque)rtrn;
+}
+
+/***====================================================================***/
+
+void
+uFree(Opaque ptr)
+{
+ if (ptr!=(Opaque)NULL)
+ free((char *)ptr);
+ return;
+}
+
+/***====================================================================***/
+/*** FUNCTION ENTRY TRACKING ***/
+/***====================================================================***/
+
+static FILE *entryFile= NULL;
+ int uEntryLevel;
+
+Boolean
+uSetEntryFile(char *name)
+{
+ if ((entryFile!=NULL)&&(entryFile!=stderr)) {
+ fprintf(entryFile,"switching to %s\n",name?name:"stderr");
+ fclose(entryFile);
+ }
+ if (name!=NullString) entryFile= fopen(name,"w");
+ else entryFile= stderr;
+ if (entryFile==NULL) {
+ entryFile= stderr;
+ return(False);
+ }
+ return(True);
+}
+
+void
+uEntry(int l,char *s,...)
+{
+int i;
+va_list args;
+
+ for (i=0;i<uEntryLevel;i++) {
+ putc(' ',entryFile);
+ }
+ va_start(args, s);
+ vfprintf(entryFile,s,args);
+ va_end(args);
+ uEntryLevel+= l;
+}
+
+void
+uExit(int l,char *rtVal)
+{
+int i;
+
+ uEntryLevel-= l;
+ if (uEntryLevel<0) uEntryLevel= 0;
+ for (i=0;i<uEntryLevel;i++) {
+ putc(' ',entryFile);
+ }
+ fprintf(entryFile,"---> %p\n",rtVal);
+ return;
+}
+
+/***====================================================================***/
+/*** PRINT FUNCTIONS ***/
+/***====================================================================***/
+
+ FILE *uDebugFile= NULL;
+ int uDebugIndentLevel= 0;
+ int uDebugIndentSize= 4;
+
+Boolean
+uSetDebugFile(char *name)
+{
+ if ((uDebugFile!=NULL)&&(uDebugFile!=stderr)) {
+ fprintf(uDebugFile,"switching to %s\n",name?name:"stderr");
+ fclose(uDebugFile);
+ }
+ if (name!=NullString) uDebugFile= fopen(name,"w");
+ else uDebugFile= stderr;
+ if (uDebugFile==NULL) {
+ uDebugFile= stderr;
+ return(False);
+ }
+ return(True);
+}
+
+void
+uDebug(char *s,...)
+{
+int i;
+va_list args;
+
+ for (i=(uDebugIndentLevel*uDebugIndentSize);i>0;i--) {
+ putc(' ',uDebugFile);
+ }
+ va_start(args, s);
+ vfprintf(uDebugFile,s,args);
+ va_end(args);
+ fflush(uDebugFile);
+}
+
+void
+uDebugNOI(char *s,...)
+{
+va_list args;
+
+ va_start(args, s);
+ vfprintf(uDebugFile,s,args);
+ va_end(args);
+ fflush(uDebugFile);
+}
+
+/***====================================================================***/
+
+static FILE *errorFile= NULL;
+static int outCount= 0;
+static char *preMsg= NULL;
+static char *postMsg= NULL;
+static char *prefix= NULL;
+
+Boolean
+uSetErrorFile(char *name)
+{
+ if ((errorFile!=NULL)&&(errorFile!=stderr)) {
+ fprintf(errorFile,"switching to %s\n",name?name:"stderr");
+ fclose(errorFile);
+ }
+ if (name!=NullString) errorFile= fopen(name,"w");
+ else errorFile= stderr;
+ if (errorFile==NULL) {
+ errorFile= stderr;
+ return(False);
+ }
+ return(True);
+}
+
+void
+uInformation(const char *s, ...)
+{
+va_list args;
+
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fflush(errorFile);
+}
+
+/***====================================================================***/
+
+void
+uAction(const char *s, ...)
+{
+va_list args;
+
+ if (prefix!=NULL)
+ fprintf(errorFile,"%s",prefix);
+ fprintf(errorFile," ");
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fflush(errorFile);
+}
+
+/***====================================================================***/
+
+void
+uWarning(const char *s, ...)
+{
+va_list args;
+
+ if ((outCount==0)&&(preMsg!=NULL))
+ fprintf(errorFile,"%s\n",preMsg);
+ if (prefix!=NULL)
+ fprintf(errorFile,"%s",prefix);
+ fprintf(errorFile,"Warning: ");
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fflush(errorFile);
+ outCount++;
+}
+
+/***====================================================================***/
+
+void
+uError(const char *s, ...)
+{
+va_list args;
+
+ if ((outCount==0)&&(preMsg!=NULL))
+ fprintf(errorFile,"%s\n",preMsg);
+ if (prefix!=NULL)
+ fprintf(errorFile,"%s",prefix);
+ fprintf(errorFile,"Error: ");
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fflush(errorFile);
+ outCount++;
+}
+
+/***====================================================================***/
+
+void
+uFatalError(const char *s, ...)
+{
+va_list args;
+
+ if ((outCount==0)&&(preMsg!=NULL))
+ fprintf(errorFile,"%s\n",preMsg);
+ if (prefix!=NULL)
+ fprintf(errorFile,"%s",prefix);
+ fprintf(errorFile,"Fatal Error: ");
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fprintf(errorFile," Exiting\n");
+ fflush(errorFile);
+ outCount++;
+ exit(1);
+ /* NOTREACHED */
+}
+
+/***====================================================================***/
+
+void
+uInternalError(const char *s, ...)
+{
+va_list args;
+
+ if ((outCount==0)&&(preMsg!=NULL))
+ fprintf(errorFile,"%s\n",preMsg);
+ if (prefix!=NULL)
+ fprintf(errorFile,"%s",prefix);
+ fprintf(errorFile,"Internal error: ");
+ va_start(args, s);
+ vfprintf(errorFile,s,args);
+ va_end(args);
+ fflush(errorFile);
+ outCount++;
+}
+
+void
+uSetPreErrorMessage(char *msg)
+{
+ outCount= 0;
+ preMsg= msg;
+ return;
+}
+
+void
+uSetPostErrorMessage(char *msg)
+{
+ postMsg= msg;
+ return;
+}
+
+void
+uSetErrorPrefix(char *pre)
+{
+ prefix= pre;
+ return;
+}
+
+void
+uFinishUp(void)
+{
+ if ((outCount>0)&&(postMsg!=NULL))
+ fprintf(errorFile,"%s\n",postMsg);
+ return;
+}
+
+/***====================================================================***/
+
+#ifndef HAVE_STRDUP
+char *
+uStringDup(const char *str)
+{
+char *rtrn;
+
+ if (str==NULL)
+ return NULL;
+ rtrn= (char *)uAlloc(strlen(str)+1);
+ strcpy(rtrn,str);
+ return rtrn;
+}
+#endif
+
+#ifndef HAVE_STRCASECMP
+int
+uStrCaseCmp(const char *str1, const char *str2)
+{
+ char buf1[512],buf2[512];
+ char c, *s;
+ register int n;
+
+ for (n=0, s = buf1; (c = *str1++); n++) {
+ if (isupper(c))
+ c = tolower(c);
+ if (n>510)
+ break;
+ *s++ = c;
+ }
+ *s = '\0';
+ for (n=0, s = buf2; (c = *str2++); n++) {
+ if (isupper(c))
+ c = tolower(c);
+ if (n>510)
+ break;
+ *s++ = c;
+ }
+ *s = '\0';
+ return (strcmp(buf1, buf2));
+}
+
+int
+uStrCasePrefix(const char *my_prefix, char *str)
+{
+ char c1;
+ char c2;
+ while (((c1=*my_prefix)!='\0')&&((c2=*str)!='\0')) {
+ if (isupper(c1)) c1= tolower(c1);
+ if (isupper(c2)) c2= tolower(c2);
+ if (c1!=c2)
+ return 0;
+ my_prefix++; str++;
+ }
+ if (c1!='\0')
+ return 0;
+ return 1;
+}
+
+#endif