summaryrefslogtreecommitdiff
path: root/support/dktools/dk4gralo.ctr
blob: 9d1625c018459c9342c77e5b50481a414518b2cc (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
%%	options

copyright owner	=	Dirk Krause
copyright year	=	2017-xxxx
SPDX-License-Identifier:	BSD-3-Clause

%%	header

#ifndef	DK4CONF_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif

#ifndef	DK4TYPES_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4types.h"
#else
#include <dktools-4/dk4types.h>
#endif
#endif

#ifndef	DK4APP_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4app.h"
#else
#include <dktools-4/dk4app.h>
#endif
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/**	Obtain array of localized texts.
	@param	app	Application structure.
	@return	String table of localized texts.
	The table can be used only as long as app is valid,
	as app manages the memory for the string table.
*/
const dkChar * const	*
dk4gralog_localized_texts(dk4_app_t *app);

/**	Find string table size (number of strings) in default string array.
	@return	Number of strings required in string table file.
*/
size_t
dk4gralog_sz_localized_texts(void);


/**	Issue message of 1 component (const).
	@param	app			Aplication structure.
	@param	priority	Message priority.
	@param	i1			Index of first constant part in message array.
*/
void
dk4gralog_1(
	dk4_app_t		*app,
	int				 priority,
	size_t			 i1
);

/**	Issue message of 3 components (const, variable, const).
	@param	app			Aplication structure.
	@param	priority	Message priority.
	@param	i1			Index of first constant part in message array.
	@param	i2			Index of second constant part in message array.
	@param	t1			Variable text.
*/
void
dk4gralog_3(
	dk4_app_t		*app,
	int				 priority,
	size_t			 i1,
	size_t			 i2,
	const dkChar	*t1
);


/**	Write error message about illegal resolution value.
	@param	app			Application structure for diagnostics.
	@param	priority	Diagnostic message priority.
	@param	t1			Text entered by the user.
	@param	allowed		Allowed texts to use instead.
*/
void
dk4gralog_choice(
	dk4_app_t		*app,
	int				 priority,
	const dkChar	*t1,
	const dkChar	*allowed
);


#ifdef	__cplusplus
}
#endif

/* vim: set ai sw=4 ts=4 : */

%%	module

#include "dk4conf.h"

#ifndef	DK4GRALO_H_INCLUDED
#include "dk4gralo.h"
#endif



$!trace-include



/**	Default texts in English returned if the string table is not found.
*/
static const dkChar * const	dk4gralog_kwdef[] = {
$!string-table	macro=dkT
#
#	  0	  1		ERROR: Not a boolean value.
#
Not a boolean value: "
"!
#
#	  2	  3		ERROR: Not a resolution value.
#
Not a resolution value: "
"!
#
#	  4	  5		ERROR: Color value out of range.
#
Color value "
" out of range 0...255!
#
#	  6	 7	ERROR: Not a number!
#
Not a number: "
"!
#
#	  8	 9	ERROR: Not a boolean
#
Not a boolean: "
"!
#
#	 10	11	ERROR: Not  a hexadecimal digit!
#
Not a hexadecimal digit: "
"!
#
#	 12	13	ERROR: Hexadecimal number to short!
#
Hexadecimal number "
" too short, must have 6 digits!
#
#	 14		ERROR: Wrong number of components in background specification!
#
Wrong number of components in background specification!
#
#	15		ERROR: Negative number not allowed in resolution specification!
#
Negative number not allowed in resolution specification!
#
#	16	17	ERROR: Paper size not found
#
Paper size not found: "
"!
#
#	18
#
Negative number not allowed in size specification!
#
#	19
#
Illegal number of arguments for paper size!
#
#	20	21	ERROR: Option requires a value!
#
Option "
" requires a value!
#
#	22	23	ERROR: Invalid tsize value!
#
Invalid tsize value: "
"!
#
#	24	25	ERROR: Invalid PS level
#
Invalid PS level: "
", must be "2" or "3"!
#
#	26		ERROR: Text size must not be negative
#
Negative text size not allowed!
#
#	27	28	ERROR: Illegal purpose!
#
No such purpose: "
"!
#
#	29	30	ERROR: No such driver!
#
No such driver: "
"!
#
#	31	32	ERROR: Illegal configuration key!
#
Illegal configuration key: "
"!
#
#	33		ERROR: Empty configuration string!
#
Empty configuration string!
#
#	34	35	ERROR: Unknown RGB to gray conversion method name "..."!
#
Invalid value!\n\tUnknown RGB to gray conversion method name "
"!
#
#	36	37	ERROR: Unknown RGB to gray conversion method name "..."!
#
Invalid value!\n\tUnknown RGB to gray conversion method name "
"!
#
#	38	39	ERROR: Not an alpha handling method: "..."!
#
Invalid value!\n\tNot an alpha handling method: "
"!
#
#	40		ERROR:	Failed to set up text stream processing!
#
Failed to set up text stream processing!
#
#	41		ERROR: Failed to read file!
#
Failed to read file!
#
#	42	43	Warning: Ignoring configuration key "..."!
#
Ignoring configuration key "
"!
#
#	44	45	ERROR: No such driver or purpose: "..."!
#
No such driver or purpose: "
"!
#
#	46		ERROR: Line does not contain a value!
#
Line does not contain a value!
#
#	47		ERROR: Purpose "document" only available for "ps", "pdf", "tex"!
#
Purpose "document" only available for "ps", "pdf", "tex" output!
#
#	48-49	Progress messages for configuration files
#
Processing configuration files (start).
Processing configuration files (finished).
#
#	50-51	Progress messages for files to convert
#
Processing file (start).
Processing file (finished).
#
#	52		ERROR: Failed to create graphics output structure!
#
Failed to create graphics output structure!
#
#	53		ERROR: Invalid function arguments, probably bug!
#
Invalid function arguments, probably bug!
#
#	54		ERROR: Numeric overflow
#
Numeric overflow in size calculation!\n\tSome dimension too large?
#
#	55		ERROR: Failed to write data!
#
Failed to write data!
#
#	56		ERROR: Failed to flush write buffers!
#
Failed to flush write buffers!
#
#	57		ERROR: Failed to add graphics details!
#
Failed to add graphics details!
#
#	58		ERROR: Failed to change graphics setup!
#
Failed to change graphics setup!
#
#	59		ERROR: Failed to write graphics to file!
#
Failed to write graphics to file!
#
#	60		ERROR: Only PNG/JPEG allowed in PGF output!
#
Only PNG/JPEG allowed in PGF output!
#
#	61 62	Not an unsigned number!
#
Not an unsigned number: "
"!
#
#	63		Illegal value: 0!
#
Illegal value: 0!
#
#	64		Warning: Unusual large number of x-spline sub segments!
#
Unusual large number of x-spline sub segments!\n\tMay result in large output files.
#
#	65		Warning: Unusual low number of x-spline sub segments!
#
Unusual low number of x-spline sub segments!\n\tMay result in inexact approximation.
#
#	66 67	Warning: Option ... requires a value!
#
Option "
" requires a value!
#
#	68 69	ERROR: Not a floating point number: "..."!
#
Not a floating point number: "
"!
#
#	70 71	ERROR: Positive value required for "..."!
#
Positive value required for "
"!
$!end
};



/**	String table file name.
*/
static const dkChar	dk4gralog_stt_file_name[] = { dkT("dk4gra.str") };



/**	Number of elements in the dk4gralog_kwdef array.
*/
static const size_t dk4gralog_sz_kwdef =
(sizeof(dk4gralog_kwdef)/sizeof(DK4_PDKCHAR) - 1);


const dkChar * const	*
dk4gralog_localized_texts(dk4_app_t *app)
{
	if (NULL != app) {
		return (
			dk4app_string_table(
				app,
				dk4gralog_stt_file_name,
				dk4gralog_kwdef
			)
		);
	}
	else {
		return dk4gralog_kwdef;
	}
}



size_t
dk4gralog_sz_localized_texts(void)
{
	return ( dk4app_string_table_size(dk4gralog_kwdef) );
}



void
dk4gralog_1(
	dk4_app_t		*app,
	int				 priority,
	size_t			 i1
)
{
	const dkChar * const	*msg;		/* Localized texts */
	
	if (NULL != app) {
		msg = dk4gralog_localized_texts(app);
		dk4app_log_1(app, msg, dk4gralog_sz_kwdef, priority, i1);
	}
}



void
dk4gralog_3(
	dk4_app_t		*app,
	int				 priority,
	size_t			 i1,
	size_t			 i2,
	const dkChar	*t1
)
{
	const dkChar * const	*msg;		/* Localized texts */
	
	if (NULL != app) {
		msg = dk4gralog_localized_texts(app);
		dk4app_log_3(app, msg, dk4gralog_sz_kwdef, priority, i1, i2, t1);
	}
}



void
dk4gralog_choice(
	dk4_app_t		*app,
	int				 priority,
	const dkChar	*t1,
	const dkChar	*allowed
)
{
	const dkChar			*mp[8];		/* Array of message components */
	const dkChar * const	*msg;		/* Localized text fragments */

	if ((NULL != app) && (NULL != t1) && (NULL != allowed)) {
		msg = dk4gralog_localized_texts(app);
		mp[0] = msg[2];
		mp[1] = t1;
		mp[2] = msg[3];
		mp[4] = allowed;
		dk4app_log_msg(app, priority, mp, 4);
	}
}


/* vim: set ai sw=4 ts=4 : */