1 /* GKrellM
2 | Copyright (C) 1999-2019 Bill Wilson
3 |
4 | Author: Bill Wilson billw@gkrellm.net
5 | Latest versions might be found at: http://gkrellm.net
6 |
7 |
8 | GKrellM is free software: you can redistribute it and/or modify it
9 | under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | GKrellM is distributed in the hope that it will be useful, but WITHOUT
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 | License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program. If not, see http://www.gnu.org/licenses/
20 |
21 |
22 | Additional permission under GNU GPL version 3 section 7
23 |
24 | If you modify this program, or any covered work, by linking or
25 | combining it with the OpenSSL project's OpenSSL library (or a
26 | modified version of that library), containing parts covered by
27 | the terms of the OpenSSL or SSLeay licenses, you are granted
28 | additional permission to convey the resulting work.
29 | Corresponding Source for a non-source form of such a combination
30 | shall include the source code for the parts of OpenSSL used as well
31 | as that of the covered work.
32 */
33
34 #include <string.h>
35
36
37 /* ---------------- Intercept GdkFont ------------------ */
38
39 extern int gkrellm_gdk_text_width(void *font_desc,
40 const char *text, int len);
41
42 extern void *gkrellm_default_font(int n);
43 extern void gkrellm_text_extents(void *font_desc, const char *text,
44 int len, int *width, int *height,
45 int *baseline, int *y_ink);
46
47 int
gdk_text_width(void * gdkfont,const char * string,int len)48 gdk_text_width(void *gdkfont, const char *string, int len)
49 {
50 void *pfd;
51
52 if (gdkfont == gkrellm_default_font(0))
53 pfd = gdkfont;
54 else if (gdkfont == gkrellm_default_font(2))
55 pfd = gdkfont;
56 else
57 pfd = gkrellm_default_font(1);
58
59 return gkrellm_gdk_text_width(pfd, string, len);
60 }
61
62 int
gdk_string_width(void * font_desc,const char * string)63 gdk_string_width(void *font_desc, const char *string)
64 {
65 return gdk_text_width(font_desc, string, strlen(string));
66 }
67
68 void
gdk_string_extents(void * font_desc,const char * string,int * l,int * r,int * w,int * a,int * d)69 gdk_string_extents(void *font_desc, const char *string,
70 int *l, int *r, int *w, int *a, int *d)
71 {
72 int width, height, baseline, y_ink;
73
74 gkrellm_text_extents(font_desc, string, strlen(string),
75 &width, &height, &baseline, &y_ink);
76
77 if (l)
78 *l = 0;
79 if (r)
80 *r = width;
81 if (w)
82 *w = width;
83 if (a)
84 *a = baseline - y_ink;
85 if (d)
86 *d = y_ink + height - baseline;
87 }
88
89
90 /* ---------------- Intercept setuid() and setreuid() ------------------ */
91 /* Enable this code as a debug test for when the gkrellmms plugin hangs.
92 | libxmms calls setuid() and setreuid() which can cause a gkrellm
93 | hang on Linux because of some kind of an interaction with running threads.
94 */
95
96 #if 0
97
98 #include <sys/types.h>
99
100 int
101 setuid(uid_t u)
102 {
103 // g_debug("setuid() intercepted\n");
104 return 0;
105 }
106
107 int
108 setreuid(uid_t r, uid_t e)
109 {
110 // g_debug("setreuid() intercepted\n");
111 return 0;
112 }
113
114 #endif
115