diff options
Diffstat (limited to 'uisimulator/x11/resources.c')
-rw-r--r-- | uisimulator/x11/resources.c | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/uisimulator/x11/resources.c b/uisimulator/x11/resources.c index e0925d0fc7..feaf3b8216 100644 --- a/uisimulator/x11/resources.c +++ b/uisimulator/x11/resources.c | |||
@@ -21,9 +21,6 @@ extern char *progname; | |||
21 | extern char *progclass; | 21 | extern char *progclass; |
22 | extern XrmDatabase db; | 22 | extern XrmDatabase db; |
23 | 23 | ||
24 | static unsigned int get_time_resource (char *res_name, char *res_class, | ||
25 | Bool sec_p); | ||
26 | |||
27 | #ifndef isupper | 24 | #ifndef isupper |
28 | # define isupper(c) ((c) >= 'A' && (c) <= 'Z') | 25 | # define isupper(c) ((c) >= 'A' && (c) <= 'Z') |
29 | #endif | 26 | #endif |
@@ -79,57 +76,6 @@ get_boolean_resource (char *res_name, char *res_class) | |||
79 | return 0; | 76 | return 0; |
80 | } | 77 | } |
81 | 78 | ||
82 | int | ||
83 | get_integer_resource (char *res_name, char *res_class) | ||
84 | { | ||
85 | int val; | ||
86 | char c, *s = get_string_resource (res_name, res_class); | ||
87 | char *ss = s; | ||
88 | if (!s) return 0; | ||
89 | |||
90 | while (*ss && *ss <= ' ') ss++; /* skip whitespace */ | ||
91 | |||
92 | if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */ | ||
93 | { | ||
94 | if (1 == sscanf (ss+2, "%x %c", &val, &c)) | ||
95 | { | ||
96 | free (s); | ||
97 | return val; | ||
98 | } | ||
99 | } | ||
100 | else /* else parse as dec */ | ||
101 | { | ||
102 | if (1 == sscanf (ss, "%d %c", &val, &c)) | ||
103 | { | ||
104 | free (s); | ||
105 | return val; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | fprintf (stderr, "%s: %s must be an integer, not %s.\n", | ||
110 | progname, res_name, s); | ||
111 | free (s); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | double | ||
116 | get_float_resource (char *res_name, char *res_class) | ||
117 | { | ||
118 | double val; | ||
119 | char c, *s = get_string_resource (res_name, res_class); | ||
120 | if (! s) return 0.0; | ||
121 | if (1 == sscanf (s, " %lf %c", &val, &c)) | ||
122 | { | ||
123 | free (s); | ||
124 | return val; | ||
125 | } | ||
126 | fprintf (stderr, "%s: %s must be a float, not %s.\n", | ||
127 | progname, res_name, s); | ||
128 | free (s); | ||
129 | return 0.0; | ||
130 | } | ||
131 | |||
132 | |||
133 | unsigned int | 79 | unsigned int |
134 | get_pixel_resource (char *res_name, char *res_class, | 80 | get_pixel_resource (char *res_name, char *res_class, |
135 | Display *dpy, Colormap cmap) | 81 | Display *dpy, Colormap cmap) |
@@ -165,67 +111,3 @@ get_pixel_resource (char *res_name, char *res_class, | |||
165 | : WhitePixel (dpy, DefaultScreen (dpy))); | 111 | : WhitePixel (dpy, DefaultScreen (dpy))); |
166 | } | 112 | } |
167 | 113 | ||
168 | |||
169 | int | ||
170 | parse_time (const char *string, Bool seconds_default_p, Bool silent_p) | ||
171 | { | ||
172 | unsigned int h, m, s; | ||
173 | char c; | ||
174 | if (3 == sscanf (string, " %u : %2u : %2u %c", &h, &m, &s, &c)) | ||
175 | ; | ||
176 | else if (2 == sscanf (string, " : %2u : %2u %c", &m, &s, &c) || | ||
177 | 2 == sscanf (string, " %u : %2u %c", &m, &s, &c)) | ||
178 | h = 0; | ||
179 | else if (1 == sscanf (string, " : %2u %c", &s, &c)) | ||
180 | h = m = 0; | ||
181 | else if (1 == sscanf (string, " %u %c", | ||
182 | (seconds_default_p ? &s : &m), &c)) | ||
183 | { | ||
184 | h = 0; | ||
185 | if (seconds_default_p) m = 0; | ||
186 | else s = 0; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | if (! silent_p) | ||
191 | fprintf (stderr, "%s: invalid time interval specification \"%s\".\n", | ||
192 | progname, string); | ||
193 | return -1; | ||
194 | } | ||
195 | if (s >= 60 && (h != 0 || m != 0)) | ||
196 | { | ||
197 | if (! silent_p) | ||
198 | fprintf (stderr, "%s: seconds > 59 in \"%s\".\n", progname, string); | ||
199 | return -1; | ||
200 | } | ||
201 | if (m >= 60 && h > 0) | ||
202 | { | ||
203 | if (! silent_p) | ||
204 | fprintf (stderr, "%s: minutes > 59 in \"%s\".\n", progname, string); | ||
205 | return -1; | ||
206 | } | ||
207 | return ((h * 60 * 60) + (m * 60) + s); | ||
208 | } | ||
209 | |||
210 | static unsigned int | ||
211 | get_time_resource (char *res_name, char *res_class, Bool sec_p) | ||
212 | { | ||
213 | int val; | ||
214 | char *s = get_string_resource (res_name, res_class); | ||
215 | if (!s) return 0; | ||
216 | val = parse_time (s, sec_p, False); | ||
217 | free (s); | ||
218 | return (val < 0 ? 0 : val); | ||
219 | } | ||
220 | |||
221 | unsigned int | ||
222 | get_seconds_resource (char *res_name, char *res_class) | ||
223 | { | ||
224 | return get_time_resource (res_name, res_class, True); | ||
225 | } | ||
226 | |||
227 | unsigned int | ||
228 | get_minutes_resource (char *res_name, char *res_class) | ||
229 | { | ||
230 | return get_time_resource (res_name, res_class, False); | ||
231 | } | ||