aboutsummaryrefslogtreecommitdiff
path: root/doc/nx-X11_vs_XOrg69_patches/dixfonts.c.NX.patch
blob: 1f0cbd4fd358cf0105428db64feaf8d00678ffcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
--- ./nx-X11/programs/Xserver/dix/dixfonts.c.X.original	2015-02-13 14:03:44.704442298 +0100
+++ ./nx-X11/programs/Xserver/dix/dixfonts.c	2015-02-13 14:03:44.704442298 +0100
@@ -72,6 +72,63 @@
 #include	<stdio.h>
 #endif
 
+#ifdef NX_TRANS_SOCKET
+
+char _NXFontPath[1024];
+
+/*
+ * Override the default font path and make
+ * it configurable at run time, based on
+ * the NX_FONT environment.
+ */
+
+static const char *_NXGetFontPath(const char *path)
+{
+  const char *fontEnv;
+
+    /*
+     * Check the environment only once.
+     */
+
+    if (*_NXFontPath != '\0')
+    {
+        return _NXFontPath;
+    }
+
+    fontEnv = getenv("NX_FONT");
+
+    if (fontEnv != NULL && *fontEnv != '\0')
+    {
+        if (strlen(fontEnv) + 1 > 1024)
+        {
+#ifdef NX_TRANS_TEST
+            fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n");
+#endif
+            goto _NXGetFontPathError;
+        }
+
+        strcpy(_NXFontPath, fontEnv);
+
+#ifdef NX_TRANS_TEST
+        fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath);
+#endif
+
+        return _NXFontPath;
+    }
+
+_NXGetFontPathError:
+
+    strcpy(_NXFontPath, path);
+
+#ifdef NX_TRANS_TEST
+    fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath);
+#endif
+
+    return _NXFontPath;
+}
+
+#endif
+
 #ifdef PANORAMIX
 #include "panoramiX.h"
 #endif
@@ -1817,11 +1874,19 @@
                 bad;
 
     /* get enough for string, plus values -- use up commas */
+#ifdef NX_TRANS_SOCKET
+    len = strlen(_NXGetFontPath(path)) + 1;
+#else
     len = strlen(path) + 1;
+#endif
     nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
     if (!newpath)
 	return BadAlloc;
+#ifdef NX_TRANS_SOCKET
+    pp = (unsigned char *) _NXGetFontPath(path);
+#else
     pp = (unsigned char *) path;
+#endif
     cp++;
     while (*pp) {
 	if (*pp == ',') {