[xorg-commit-diffs] xc/lib/Xst Xst_util.h, 1.1.4.1, 1.1.4.2 Xst_util.c, 1.1.4.1, 1.1.4.2 Xst_ext.c, 1.1.4.1, 1.1.4.2 Xst_conv.h, 1.1.4.1, 1.1.4.2

Jay Hobson xorg-commit at pdx.freedesktop.org
Tue Apr 13 14:31:04 PDT 2004


Committed by: jhobson

Update of /cvs/xorg/xc/lib/Xst
In directory pdx:/tmp/cvs-serv6638

Modified Files:
      Tag: XORG-RELEASE-1-STSF
	Xst_util.h Xst_util.c Xst_ext.c Xst_conv.h 
Log Message:
Add XError descriptions that show messages rather than numbers



Index: Xst_util.h
===================================================================
RCS file: /cvs/xorg/xc/lib/Xst/Attic/Xst_util.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Xst_util.h	6 Apr 2004 02:41:19 -0000	1.1.4.1
+++ b/Xst_util.h	13 Apr 2004 21:30:59 -0000	1.1.4.2
@@ -37,7 +37,7 @@
  *
  */
 
-/* @(#)Xst_util.h	1.2 03/10/23 SMI */
+/* @(#)Xst_util.h	1.3 04/04/13 SMI */
 
 #ifndef _XSTUTIL_H
 #define _XSTUTIL_H
@@ -74,6 +74,14 @@
 void XST_Error ( Display *dpy, int iFunc, STStatus iError );
 
 /**
+ *
+ * @param dpy			Display
+ *
+ * @return NONE
+ */
+void XSTHandleClientErrors ( Display *dpy );
+
+/**
  * @}
  */
 

Index: Xst_util.c
===================================================================
RCS file: /cvs/xorg/xc/lib/Xst/Attic/Xst_util.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Xst_util.c	6 Apr 2004 02:41:19 -0000	1.1.4.1
+++ b/Xst_util.c	13 Apr 2004 21:30:59 -0000	1.1.4.2
@@ -37,7 +37,9 @@
  *
  */
 
-/* @(#)Xst_util.c	1.2	03/10/23 SMI */
+/* @(#)Xst_util.c	1.3	04/04/13 SMI */
+
+#include "stsfutil.h"
 
 #include "Xlibint.h"
 #include <errno.h>
@@ -47,13 +49,148 @@
 #include <string.h>
 #include <stdio.h>
 #include <locale.h>
+#include "extensions/XSTstr.h"
+
+#include "Xst_ext.h"
 #include "Xst_typedef.h"
 #include "Xst_conv.h"
 
 /******************************** General support structures ************************/
 
+static char *XSTErrors[] = { "XSTQueryVersion",
+                             "XSTCapable",
+                             "XSTEnable",
+                             "XSTDisable",
+                             "XSTInfo",
+                             "XSTTypeEnvNewCopy",
+                             "XSTTypeEnvDispose",
+                             "XSTTypeEnvSetFontFallbackPolicy",
+                             "XSTTypeEnvGetFontFallbackPolicy",
+                             "XSTTypeEnvSetFontFallbacks",
+                             "XSTTypeEnvGetFontFallbacks",
+                             "XSTTypeEnvFindAllScalers",
+                             "XSTTypeEnvFindScaler",
+                             "XSTTypeEnvFindFontFamily",
+                             "XSTTypeEnvGetFontFolders",
+                             "XSTTypeEnvSetFontFolders",
+                             "XSTTypeEnvFindAllLayoutEngines",
+                             "XSTTypeEnvFindLayoutEngine",
+                             "XSTTypeEnvFindFontsByName",
+                             "XSTTypeEnvCreateFont",
+                             "XSTTypeEnvFindFontBySignature",
+                             "XSTTypeEnvFindCreateFontFromURI",
+                             "XSTTypeEnvDestroyFont",
+                             "XSTTypeEnvGetLocations",
+                             "XSTTypeEnvSetLocations",
+                             "XSTScalerGetInfo",
+                             "XSTScalerControl",
+                             "XSTLayoutEngineGetInfo",
+                             "XSTLayoutEngineControl",
+                             "XSTFontGetInfo",
+                             "XSTFontGetFontFamily",
+                             "XSTFontGetTypefaceName",
+                             "XSTFontGetData",
+                             "XSTFontGetNameTags",
+                             "XSTFontGetNameString",
+                             "XSTFontGetBaselines",
+                             "XSTFontGetFeatures",
+                             "XSTFontGetSignature",
+                             "XSTFontFamilyGetName",
+                             "XSTFontFamilyGetFonts",
+                             "XSTGCSetColors",
+                             "XSTGCGetColors",
+                             "XSTGCSetAlphaRange",
+                             "XSTGCGetAlphaRange",
+                             "XSTGCSetOutputFormat",
+                             "XSTGCGetOutputFormat",
+                             "XSTGCGetMatrix",
+                             "XSTGCSetMatrix",
+                             "XSTGCConcatMatrix",
+                             "XSTGCTranslate",
+                             "XSTGCScale",
+                             "XSTGCRotate",
+                             "XSTGCShear",
+                             "XSTGCSetRegion",
+                             "XSTStyleNewCopy",
+                             "XSTStyleDispose",
+                             "XSTStyleCompare",
+                             "XSTStyleIsEmpty",
+                             "XSTStyleRemoveAttributes",
+                             "XSTStyleSetFont",
+                             "XSTStyleGetFont",
+                             "XSTStyleSetScaler",
+                             "XSTStyleGetScaler",
+                             "XSTStyleSetEffects",
+                             "XSTStyleGetEffects",
+                             "XSTStyleResetAttributes",
+                             "XSTStyleCopyAttributes",
+                             "XSTStyleOverwriteAttributes",
+                             "XSTStyleUnderwriteAttributes",
+                             "XSTStyleCalculateBaselines",
+                             "XSTStyleGetDesignMetrics",
+                             "XSTStyleGetOptions",
+                             "XSTStyleSetOptions",
+                             "XSTStyleSetLayoutEngine",
+                             "XSTStyleGetLayoutEngine",
+                             "XSTTextNew",
+                             "XSTTextNewCopy",
+                             "XSTTextDispose",
+                             "XSTTextClear",
+                             "XSTTextSetMetrics",
+                             "XSTTextGetMetrics",
+                             "XSTTextSetControls",
+                             "XSTTextGetControls",
+                             "XSTTextSetFontFallbacks",
+                             "XSTTextGetFontFallbacks",
+                             "XSTTextCopyAttributes",
+                             "XSTTextResetAttributes",
+                             "XSTTextRemoveAttributes",
+                             "XSTTextSetText",
+                             "XSTTextGetText",
+                             "XSTTextUpdate",
+                             "XSTTextSetStyle",
+                             "XSTTextGetStyle",
+                             "XSTTextGetCommonStyle",
+                             "XSTTextFindMissingChars",
+                             "XSTTextOverwriteStyle",
+                             "XSTTextUnderwriteStyle",
+                             "XSTTextAugmentStyle",
+                             "XSTTextGetStyledGlyphs",
+                             "XSTLineNew",
+                             "XSTLineNewForWidth",
+                             "XSTLineDispose",
+                             "XSTLineGrow",
+                             "XSTLineShrink",
+                             "XSTLineGetPosition",
+                             "XSTLineSetMetrics",
+                             "XSTLineGetMetrics",
+                             "XSTLineMeasureText",
+                             "XSTLineMeasureTextImage",
+                             "XSTLineGetGlyphBounds",
+                             "XSTLineHitTest",
+                             "XSTLinePositionToCaret",
+                             "XSTLineMoveCaret",
+                             "XSTLineRender",
+                             "XSTLineAddHighlight",
+                             "XSTLineRemoveHighlight",
+                             "XSTLineGetDesignMetrics",
+                             "XSTLineGetHighlights",
+                             "XSTLineGetStyledGlyphs",
+                             "XSTGlyphVectorNew",
+                             "XSTGlyphVectorNewCopy",
+                             "XSTGlyphVectorDispose",
+                             "XSTGlyphVectorSetGlyphs",
+                             "XSTGlyphVectorGetGlyphs",
+                             "XSTGlyphVectorReplaceGlyphs",
+                             "XSTGlyphVectorAdjustPositions",
+                             "XSTGlyphVectorMeasure",
+                             "XSTGlyphVectorGetBounds",
+                             "XSTGlyphVectorRender" };
+
 /********************************** Static Local Variables **************************/
 
+static int XSTClientErrorBase = 20;
+
 /********************************* XSTConv Static Functions *************************/
 
 /* **********************************************************************************
@@ -79,12 +216,50 @@
 
 void XST_Error ( Display *dpy, int iFunc, STStatus iError )
 {
+    extern int XSTClientErrorBase;
     xError rep;
 
-    rep.errorCode  = iError + 20;
+    rep.errorCode  = iError + XSTClientErrorBase;
     rep.minorCode  = iFunc;
     rep.resourceID = 0;
     rep.majorCode  = 182;
     _XError ( dpy, (xError *)&rep );      
 }
 
+int
+XSTClientErrorHandler(Display *dpy, XErrorEvent *rep)
+{
+    extern int _XDefaultError ( Display *, XErrorEvent *);
+
+    if ( rep->request_code == 182 )
+    {
+        if ( rep->error_code < ST_MAX_ERROR + XSTClientErrorBase &&
+             rep->error_code > XSTClientErrorBase &&
+             rep->minor_code < STNumberRequests )
+        {
+	    fprintf ( stderr, "X Error of failed request: %s\n", 
+                      ErrorCodeName ( rep->error_code - XSTClientErrorBase ));
+            fprintf ( stderr, "  Major opcode of failed request:  182 (ST)\n" );
+            fprintf ( stderr, "  Minor opcode of failed request:  %d (%s)\n", rep->minor_code, XSTErrors[rep->minor_code] );
+            fprintf ( stderr, "  Serial number of failed request:  0\n" );
+            fprintf ( stderr, "  Current serial number in output stream:  0\n" );
+            return 0;
+        }
+    }
+
+    _XDefaultError ( dpy, rep );
+}
+
+void
+XSTHandleClientErrors ( Display *dpy )
+{
+#ifdef USE_XST_EXTENSION
+    XSTCodes *extcodes = _XSTCodes ( dpy );
+#endif
+
+    if ( !extcodes )
+    {
+        XSetErrorHandler ( (XErrorHandler) XSTClientErrorHandler );
+    }
+}
+

Index: Xst_ext.c
===================================================================
RCS file: /cvs/xorg/xc/lib/Xst/Attic/Xst_ext.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Xst_ext.c	6 Apr 2004 02:41:19 -0000	1.1.4.1
+++ b/Xst_ext.c	13 Apr 2004 21:30:59 -0000	1.1.4.2
@@ -37,9 +37,12 @@
  *
  */
 
-/* @(#)Xst_ext.c	1.14 03/06/20 SMI */
+/* @(#)Xst_ext.c	1.15 04/04/13 SMI */
 
 #define NEED_REPLIES
+
+#include "stsfutil.h"
+
 #include <stdlib.h>
 #include "Xlibint.h"
 #include <X11/Xlib.h>
@@ -82,6 +85,31 @@
 }
 
 /* **********************************************************************************
+ * _XSTErrorString(Display *, int, XExtCodes, char *, int)
+ *
+ * Returns:     character string
+ * Called by:   ErrorHandling code in X
+ * Calls:       NONE
+ *
+ * @extension:  Extension data structure
+ *
+ * This function returns the error message to print for the error handling code in X
+ */
+static char *
+_XSTErrorString (Display *dpy, int code, XExtCodes *codes, char *buf, int n)
+{
+    code -= codes->first_error;
+    if ( code >= 0 && code < ST_MAX_ERROR ) 
+    {
+        char tmp[256];
+        sprintf ( tmp, "%s.%d", "ST", code );
+        XGetErrorDatabaseText ( dpy, "XProtoError", tmp, ErrorCodeName(code), buf, n);
+        return buf;
+    }
+    return (char *)0;
+}
+
+/* **********************************************************************************
  * _XSTCodes(Display *)
  *
  * Returns:     XSTCodes pointer
@@ -109,7 +137,16 @@
 	if ( service )
             if ( !strcasecmp ( service, "CLIENT" ) || 
 		 !strcasecmp ( service, "LOCAL" ))
+	    {
+                char *error_handling = getenv ( "XST_ERROR_HANDLE" );
+
 	        env_client = 1;
+
+                if ( error_handling )
+                    if ( !strcasecmp ( error_handling, "YES" ) ||
+                         !strcasecmp ( error_handling, "Y" ))
+                        XSTHandleClientErrors ( dpy );
+            }
     }
 
     if ( dpy == NULL || STClient || env_client )
@@ -167,6 +204,8 @@
     {
         int result;
 
+        XESetErrorString ( dpy, pCodes->codes->extension,
+                            _XSTErrorString );
         /* See if the server supports the XSTQueryFont request. */
         xSTQueryVersionReply         reply;
         register xSTQueryVersionReq *req;

Index: Xst_conv.h
===================================================================
RCS file: /cvs/xorg/xc/lib/Xst/Attic/Xst_conv.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Xst_conv.h	6 Apr 2004 02:41:19 -0000	1.1.4.1
+++ b/Xst_conv.h	13 Apr 2004 21:30:59 -0000	1.1.4.2
@@ -37,7 +37,7 @@
  *
  */
 
-/* @(#)Xst_conv.h	1.17 03/06/26 SMI */
+/* @(#)Xst_conv.h	1.18 04/04/13 SMI */
 
 #ifndef _XSTCONV_H
 #define _XSTCONV_H
@@ -78,5 +78,6 @@
 
 XSTEncoding _XSTConvGetEncoding ( char *iLocale );
 
+XSTEncoding _XSTGetEncoding ( char *);
 #endif
 #endif




More information about the xorg-commit-diffs mailing list