1 /*
2 Copyright 2020, Dirk Krause. All rights reserved.
3 SPDX-License-Identifier:	BSD-3-Clause
4 */
5 
6 /**	@file	dk3types.h	Type definitions for the dk3 library.
7  */
8 
9 #ifndef DK3_TYPES_H_INCLUDED
10 /** Avoid multiple file inclusions. */
11 #define DK3_TYPES_H_INCLUDED 1
12 
13 #include "dk3conf.h"
14 
15 #if DK3_HAVE_SYS_TYPES_H
16 #include <sys/types.h>
17 #endif
18 #if DK3_HAVE_STDINT_H
19 #include <stdint.h>
20 #endif
21 #if DK3_HAVE_INTTYPES_H
22 #include <inttypes.h>
23 #endif
24 #if DK3_HAVE_SIGNAL_H
25 #include <signal.h>
26 #endif
27 #if DK3_HAVE_WCHAR_H
28 #include <wchar.h>
29 #endif
30 #if DK3_HAVE_TERMIOS_H
31 #include <termios.h>
32 #endif
33 #if DK3_HAVE_SYS_TERMIOS_H
34 #include <sys/termios.h>
35 #endif
36 #if DK3_HAVE_SYS_TTOLD_H
37 #include <sys/ttold.h>
38 #endif
39 #if DK3_HAVE_ZLIB_H
40 #include <zlib.h>
41 #endif
42 
43 #ifndef DK3_CHAR_SIZE
44 /* previously: if DK3_ON_WINDOWS && (defined(_UNICODE)) */
45 #if _WIN32
46 /**	Specify default character size 16 bit.
47 */
48 #define	DK3_CHAR_SIZE	2
49 #else
50 /**	Specify default character size 8 bit.
51 */
52 #define	DK3_CHAR_SIZE	1
53 #endif
54 #endif
55 
56 
57 /*
58 	Simple data types.
59 */
60 
61 /**	A 8-bit unsigned int  type.
62 */
63 typedef unsigned char	dk3_u8_t;
64 
65 /**	An 8-bit signed int type.
66 */
67 typedef signed char dk3_i8_t;
68 
69 /**	A 8-bit character type.
70 */
71 typedef char /*^unsignedintegraltype^*/	dk3_c8_t;
72 
73 /**	A 16-bit unsigned int type.
74 */
75 typedef	unsigned short	dk3_u16_t;
76 
77 /**	A 16-bit signed int type.
78 */
79 typedef short dk3_i16_t;
80 
81 /**	A 16 bit character type (used on Windows).
82 */
83 #if DK3_SIZEOF_WCHAR_T == 2
84 typedef wchar_t		/*^unsignedintegraltype^*/	dk3_c16_t;
85 #define	dkC16(x)	((dk3_c16_t)(x ## U))
86 #else
87 typedef unsigned short	/*^unsignedintegraltype^*/	dk3_c16_t;
88 #define	dkC16(x)	((dk3_c16_t)(x ## U))
89 #endif
90 
91 /**	A 32-bit character/unsigned int type (wchar_t on UNIX, not used).
92 */
93 typedef unsigned long dk3_u32_t;
94 
95 /**	A 32-bit signed int type.
96 */
97 typedef long dk3_i32_t;
98 
99 /**	A 32-bit character type (used i.e. by X11).
100 */
101 #if DK3_SIZEOF_WCHAR_T == 4
102 typedef	wchar_t	      /*^unsignedintegraltype^*/	dk3_c32_t;
103 #define	dkC32(x) ((dk3_c32_t)(x ## U))
104 #else
105 #if DK3_SIZEOF_INT >= 4
106 typedef unsigned      /*^unsignedintegraltype^*/	dk3_c32_t;
107 #define	dkC32(x) ((dk3_c32_t)(x ## U))
108 #else
109 typedef unsigned long /*^unsignedintegraltype^*/	dk3_c32_t;
110 #define	dkC32(x) ((dk3_c32_t)(x ## UL))
111 #endif
112 #endif
113 
114 
115 
116 #if DK3_CHAR_SIZE > 1
117 #if defined(DK3_SIZEOF_WCHAR_T)
118 #if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T
119 
120 #ifndef	DK3_WMAIN_DEFINED
121 #define DK3_WMAIN_DEFINED 1
122 int wmain(int argc, wchar_t *argv[]);
123 #endif
124 
125 /**	Text character type.
126 */
127 typedef	wchar_t		/*^unsignedintegraltype^*/	dkChar;
128 /**	Macro to switch text literals between 8-bit and 16-bit text.
129 */
130 #define	dkT(s)		L ## s
131 /**	Macro to switch the main function between 8 and 16 bit.
132 */
133 #define	DK3_MAIN	int wmain(int argc, wchar_t *argv[])
134 #else
135 /* if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T */
136 #if DK3_CHAR_SIZE > 2
137 /**	Text character type.
138 */
139 typedef	dk3_c32_t	/*^unsignedintegraltype^*/	dkChar;
140 #error	"Can not use prefix L to specify dkChar string literals!"
141 #error	"Can not define DK3_MAIN to dkChar!"
142 #else
143 /* if DK3_CHAR_SIZE > 2 */
144 /**	Text character type.
145 */
146 typedef	dk3_c16_t	/*^unsignedintegraltype^*/	dkChar;
147 #error	"Can not use prefix L to specify dkChar string literals!"
148 #error	"Can not define DK3_MAIN to dkChar!"
149 #endif
150 /* if DK3_CHAR_SIZE > 2 */
151 #endif
152 /* if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T */
153 #else
154 /* if defined(DK3_SIZEOF_WCHAR_T) */
155 #error	"Missing definition for DK3_SIZEOF_WCHAR_T!"
156 #endif
157 /* if defined(DK3_SIZEOF_WCHAR_T) */
158 #if !DK3_ON_WINDOWS
159 #error "Usable support for UNICODE/MBCS is available on Windows platforms only!"
160 #endif
161 /* if !DK3_ON_WINDOWS */
162 #else
163 /* if DK3_CHAR_SIZE > 1 */
164 /* +++ DK3_CHAR_SIZE == 1 */
165 /**	Text character type.
166 */
167 typedef	char		/*^unsignedintegraltype^*/	dkChar;
168 /**	Macro to switch the main function between 8 and 16 bit.
169 */
170 #define	dkT(s)		s
171 /**	Macro to switch the main function between 8 and 16 bit.
172 */
173 #define	DK3_MAIN	int main(int argc, char *argv[])
174 /* --- DK3_CHAR_SIZE == 1 */
175 #endif
176 /* if DK3_CHAR_SIZE > 1 */
177 
178 
179 
180 #if DK3_HAVE_INTMAX_T
181 
182 /**	Maximum size integer type.
183 */
184 typedef intmax_t			dk3_im_t;
185 
186 /**	Maximum size unsigned integer type.
187 */
188 typedef uintmax_t			dk3_um_t;
189 
190 #else
191 
192 #if DK3_HAVE_LONG_LONG
193 
194 /**	Maximum size integer type.
195 */
196 typedef long long int			dk3_im_t;
197 
198 /**	Maximum size unsigned integer type.
199 */
200 typedef long long unsigned		dk3_um_t;
201 
202 #else
203 
204 /**	Maximum size integer type.
205 */
206 typedef long int			dk3_im_t;
207 
208 /**	Maximum size unsigned integer type.
209 */
210 typedef long unsigned			dk3_um_t;
211 
212 #endif
213 #endif
214 
215 
216 /**	Timer.
217 */
218 
219 #if DK3_ON_WINDOWS
220 /**	Portable type to save a timestamp.
221 */
222 typedef	__time64_t	dk3_time_t;
223 #else
224 #if (defined(DK3_HAVE_SYS_TIME_H) || defined(DK3_HAVE_TIME_H)) && defined(DK3_HAVE_TIME)
225 /**	Portable type to save a timestamp.
226 */
227 typedef	time_t		dk3_time_t;
228 #else
229 #error "No mechanism known to obtain current time!"
230 #endif
231 #endif
232 
233 
234 
235 #if DK3_HAVE_LONG_DOUBLE && (DK3_SIZEOF_LONG_DOUBLE > DK3_SIZEOF_DOUBLE)
236 /**	Most precise double type.
237 */
238 typedef long double	dk3_double_t;
239 #else
240 /**	Most precise double type.
241 */
242 typedef double		dk3_double_t;
243 #endif
244 
245 
246 #if DK3_ON_WINDOWS
247 /**	Number of bytes successfully read/written by read()/write().
248 */
249 #define	dk3_rw_res_t	int
250 #else
251 #if DK3_HAVE_SSIZE_T
252 /**	Number of bytes successfully read/written by read()/write().
253 */
254 #define dk3_rw_res_t	ssize_t
255 #else
256 /**	Number of bytes successfully read/written by read()/write().
257 */
258 #define	dk3_rw_res_t	int
259 #endif
260 #endif
261 
262 #if DK3_ON_WINDOWS
263 /**	Buffer size in read()/write().
264 */
265 #define	dk3_rw_arg_t	unsigned int
266 #else
267 /**	Buffer size in read()/write().
268 */
269 #define	dk3_rw_arg_t	size_t
270 #endif
271 
272 
273 /*
274 	Structured data types.
275 */
276 
277 
278 
279 /**	Timestamp.
280 */
281 typedef struct _dk3_time_t_ {
282   /**	Year.
283   */
284   int	Y;
285 
286   /**	Month.
287   */
288   int	M;
289 
290   /**	Day in month.
291   */
292   int	D;
293 
294   /**	Hours.
295   */
296   int	h;
297 
298   /**	Minutes.
299   */
300   int	m;
301 
302   /**	Seconds.
303   */
304   int	s;
305 } dk3_tm_t;
306 
307 
308 
309 /**	File information.
310 	When retrieving information about a symbolic link the dk3sf_stat()
311 	function retrieves information about both the link destination and
312 	the link itself.
313 */
314 typedef struct {
315 
316   /**	Creation timestamp.
317   */
318   dk3_time_t	cre;
319 
320   /**	Modification timestamp.
321   */
322   dk3_time_t	mod;
323 
324   /**	Last access timestamp.
325   */
326   dk3_time_t	acc;
327 
328   /**	Link creation timestamp.
329   */
330   dk3_time_t	lcre;
331 
332   /**	Link modification timestamp.
333   */
334   dk3_time_t	lmod;
335 
336   /**	Link last access timestamp.
337   */
338   dk3_time_t	lacc;
339 
340   /**	User ID.
341   */
342   dk3_um_t	u;
343 
344   /**	Group ID.
345   */
346   dk3_um_t	g;
347 
348   /**	Device number.
349   */
350   dk3_um_t	device;
351 
352   /**	Relative device number.
353   */
354   dk3_um_t	rdev;
355 
356   /**	Inode number.
357   */
358   dk3_um_t	inode;
359 
360   /**	Number of hard links to inode.
361   */
362   dk3_um_t	nlink;
363 
364   /**	File size in bytes.
365   */
366   dk3_um_t	sz;
367 
368   /**	Link user ID.
369   */
370   dk3_um_t	lu;
371 
372   /**	Link group ID.
373   */
374   dk3_um_t	lg;
375 
376   /**	Link device number.
377   */
378   dk3_um_t	ldevice;
379 
380   /**	Link relative device number.
381   */
382   dk3_um_t	lrdev;
383 
384   /**	Link inode number.
385   */
386   dk3_um_t	linode;
387 
388   /**	Number of hard links to the link.
389   */
390   dk3_um_t	lnlink;
391 
392 #if DK3_ON_WINDOWS
393   long		dwReparse;
394 #endif
395 
396   /**	File type, see @ref filetypes.
397   */
398   int		ft;
399 
400   /**	Permissions, see @ref filepermissions.
401   */
402   int		perm;
403 
404   /**	Link file type.
405   */
406   int		lft;
407 
408   /**	Link permissions.
409   */
410   int		lperm;
411 
412   /**	Link file size.
413   */
414   dk3_um_t	lsz;
415 
416   /**	Additional information about file, see @ref statadditional.
417   */
418   unsigned char	ai;
419 
420 #if DK3_ON_WINDOWS
421   /**	Reparse point information.
422   */
423   char		cReparse;
424 #endif
425 } dk3_stat_t;
426 
427 
428 
429 
430 /**	Evaluation result for an object.
431 */
432 typedef union {
433 
434     /**	Evaluation to double.
435     */
436     double d;
437 
438     /**	Evaluation to float.
439     */
440     float f;
441 
442     /**	Evaluation to long.
443     */
444     long l;
445 
446     /**	Evaluation to unsigned long.
447     */
448     unsigned long ul;
449 
450     /**	Evaluation to int.
451     */
452     int i;
453 
454     /**	Evaluation to unsigned int.
455     */
456     unsigned int ui;
457 
458     /**	Evaluation to short.
459     */
460     short s;
461 
462     /**	Evaluation to unsigned short.
463     */
464     unsigned short us;
465 
466     /**	Evaluation to char.
467     */
468     char c;
469 
470     /**	Evaluation to unsigned char.
471     */
472     unsigned char uc;
473 } dk3_object_eval_res_t;
474 
475 
476 /**	Internal node for dk3_sto_t.
477 	This structure is used internally by the dksto module.
478 */
479 struct _dk3_sto_node_ {
480 
481   /**	Object evaluation of @a o.
482   */
483   dk3_object_eval_res_t	   v;
484 
485   /**	Parent node in tree.
486   */
487   struct _dk3_sto_node_ *p;
488 
489   /**	Left child node (tree) or preceeding node (list).
490   */
491   struct _dk3_sto_node_ *l;
492 
493   /**	Right child node (tree) or following node (list).
494   */
495   struct _dk3_sto_node_ *r;
496 
497   /**	Object to store.
498   */
499   void                    *o;
500 
501   /**	Balance flag (used in trees only).
502   */
503   short                    b;
504 
505   /**	Direction to walk in tree.
506   */
507   short                    w;	/**< Direction to walk. */
508 };
509 
510 /** Internal node for dk3_sto_t.
511 */
512 typedef struct _dk3_sto_node_ dk3_sto_node_t;
513 
514 /** Pointer to internal node for dk3_sto_t.
515 */
516 typedef dk3_sto_node_t *dk3_sto_node_p;
517 
518 
519 
520 /**	Evaluation functions.
521 	These function type are used to evaluate and compare objects
522 	stored in a sorted dk3_sto_t.
523 */
524 
525 /** Object evaluation function for sorted storage.
526 */
527 typedef char dk3_fct_eval_c_t(void const *obj, int crit) /*^*/ ;
528 
529 /** Object evaluation function for sorted storage.
530 */
531 typedef unsigned char dk3_fct_eval_uc_t(void const *obj, int crit) /*^*/ ;
532 
533 /** Object evaluation function for sorted storage.
534 */
535 typedef short dk3_fct_eval_s_t(void const *obj, int crit) /*^*/ ;
536 
537 /** Object evaluation function for sorted storage.
538 */
539 typedef unsigned short dk3_fct_eval_us_t(void const *obj, int crit) /*^*/ ;
540 
541 /** Object evaluation function for sorted storage.
542 */
543 typedef int dk3_fct_eval_i_t(void const *obj, int crit) /*^*/ ;
544 
545 /** Object evaluation function for sorted storage.
546 */
547 typedef unsigned int dk3_fct_eval_ui_t(void const *obj, int crit) /*^*/ ;
548 
549 /** Object evaluation function for sorted storage.
550 */
551 typedef long dk3_fct_eval_l_t(void const *obj, int crit) /*^*/ ;
552 
553 /** Object evaluation function for sorted storage.
554 */
555 typedef unsigned long dk3_fct_eval_ul_t(void const *obj, int crit) /*^*/ ;
556 
557 /** Object evaluation function for sorted storage.
558 */
559 typedef float dk3_fct_eval_f_t(void const *obj, int crit) /*^*/ ;
560 
561 /** Object evaluation function for sorted storage.
562 */
563 typedef double dk3_fct_eval_d_t(void const *obj, int crit) /*^*/ ;
564 
565 /** Object comparison function for sorted storage.
566     When comparing to objects while inserting a new object into
567     a storage both @a o1 and @a o2 are object pointers.
568     When this function is called from dk3sto_it_find_like() the
569     @a o1 argument is an object pointer from the storage,
570     @a o2 is the pointer passed to dk3sto_it_find_like().
571 */
572 typedef int dk3_fct_comp_t(
573   /*^null^*/	void const *o1,
574   /*^null^*/	void const *o2,
575 		int crit
576 ) /*^*/ ;
577 
578 
579 
580 /**	Choice for object evaluation function.
581 */
582 typedef union {
583 
584   /** Evaluation function returning a char value.
585   */
586   dk3_fct_eval_c_t *c;
587 
588   /** Evaluation function returning an unsigned char value.
589   */
590   dk3_fct_eval_uc_t *uc;
591 
592   /** Evaluation function returning a short value.
593   */
594   dk3_fct_eval_s_t *s;
595 
596   /** Evaluation function returning an unsigned short value.
597   */
598   dk3_fct_eval_us_t *us;
599 
600   /** Evaluation function returning an int value.
601   */
602   dk3_fct_eval_i_t *i;
603 
604   /** Evaluation function returning an unsigned int value.
605   */
606   dk3_fct_eval_ui_t *ui;
607 
608   /** Evaluation function returning a long value.
609   */
610   dk3_fct_eval_l_t *l;
611 
612   /** Evaluation function returning an unsigned long value.
613   */
614   dk3_fct_eval_ul_t*ul;
615 
616   /** Evaluation function returning a float value.
617   */
618   dk3_fct_eval_f_t *f;
619 
620   /** Evaluation function returning a double value.
621   */
622   dk3_fct_eval_d_t *d;
623 
624   /** Function to compare two objects.
625   */
626   dk3_fct_comp_t *comp;
627 } dk3_object_eval_fct_t;
628 
629 
630 
631 /**	Object storage.
632 	A storage can be used to store pointers to objects.
633 */
634 typedef struct _dk3_sto_t_ {
635 
636   /**	Comparison or evaluation function.
637   */
638   dk3_object_eval_fct_t	e;
639 
640   /**	Application structure for diagnostics.
641   */
642   void		  	*app;
643 
644   /**	Critical path for delete operations.
645   */
646   dk3_sto_node_p 	*d;
647 
648   /**	Root element (tree) or left element (list).
649   */
650   dk3_sto_node_t 	*r;
651 
652   /**	Double-linked list of iterators.
653   */
654   void              	*i;
655 
656   /**	Algorithm selection for comparison or evaluation.
657   */
658   int 		     	h;
659 
660   /**	Criteria for comparison or evaluation.
661   */
662   int                	c;
663 
664   /**	Flag: Use tree, 1=tree, 0=list.
665   */
666   int		     	t;
667 
668   /**	Path length of critical path (number of elements).
669   */
670   short              	l;
671 } dk3_sto_t;
672 
673 
674 
675 /**	Storage iterator.
676 	This structure can be used to iterate through a dk3_sto_t.
677 */
678 struct _dk3_sto_iterator_ {
679 
680   /**	Preceeding iterator in iterator linked list.
681   */
682   struct _dk3_sto_iterator_ *l;
683 
684   /**	Following iterator in iterator linked list.
685   */
686   struct _dk3_sto_iterator_ *r;
687 
688   /**	Storage owning this iterator.
689   */
690   dk3_sto_t                *s;
691 
692   /**	Current node.
693   */
694   dk3_sto_node_t           *c;
695 };
696 /**	Storage iterator. Can be used to iterate through a dk3_sto_t. */
697 typedef struct _dk3_sto_iterator_ dk3_sto_it_t;
698 
699 
700 
701 /**	Key value pair.
702 */
703 typedef struct {
704   dkChar	*key;	/**< Key. */
705   dkChar	*val;	/**< Value. */
706 } dk3_key_value_t;
707 
708 
709 
710 /**	Directory contents.
711 */
712 typedef struct _dk3_dir_t_ {
713 
714   /**	Stat buffer for current entry to process.
715   */
716   dk3_stat_t		stb;
717 
718   /**	Storage containing the directory names.
719   */
720   dk3_sto_t		*sdi;
721 
722   /**	Iterator for directory names storage.
723   */
724   dk3_sto_it_t		*idi;
725 
726   /**	Storage containing file names.
727   */
728   dk3_sto_t		*sfi;
729 
730   /**	Iterator for file names storage.
731   */
732   dk3_sto_it_t		*ifi;
733 
734   /**	Directory name.
735   */
736   dkChar const		*dirname;
737 
738   /**	Full path of current entry to process.
739   */
740   dkChar		*fullname;
741 
742   /**	Short name of current entry to process.
743   */
744   dkChar		*shortname;
745 
746   /**	Application used for diagnostics.
747   */
748   void			*app;
749 
750   /**	Number of directories found.
751   */
752   dk3_um_t		ndir;
753 
754   /**	Number of files found.
755   */
756   dk3_um_t		nfi;
757 } dk3_dir_t;
758 
759 
760 
761 /**	Arguments in a stream command API call.
762 */
763 typedef struct {
764 
765   /**	Low-level data.
766   */
767   void	*d;
768 
769   /**	Buffer for bytes to read/write.
770   */
771   char	*b;
772 
773   /**	Buffer size (number of bytes to read/write).
774   */
775   size_t	sz;
776 } dk3_stream_api_arg_t;
777 
778 
779 
780 /**	Results of a stream command API call.
781 */
782 typedef struct {
783 
784   /**	Number of bytes read.
785   */
786   size_t	sz;
787 
788   /**	Error code DK3_ERROR_xxx, see @ref errorcodes.
789   */
790   int		ec;
791 } dk3_stream_api_result_t;
792 
793 
794 
795 /**	Stream command API.
796 */
797 typedef struct _dk3_stream_api_t_ {
798 
799   /**	API call arguments.
800   */
801   dk3_stream_api_arg_t	arg;
802 
803   /**	API call results.
804   */
805   dk3_stream_api_result_t	res;
806 
807   /**	Command to execute, DK3_STREAM_API_xxx, see @ref streamapicommands.
808   */
809   int	cmd;
810 
811   /**	Success flag, 1=success, 0=error.
812   */
813   int	suc;
814 } dk3_stream_api_t;
815 
816 /**	Stream API function type.
817 */
818 typedef void dk3_stream_api_fct_t(dk3_stream_api_t *);
819 
820 /**	Generic I/O stream.
821 */
822 typedef struct _dk3_stream_t_ {
823 
824   /**	Optional application structure for diagnostics.
825   */
826   void			*app;
827 
828   /**	Low-level data.
829   */
830   void			*d;
831 
832   /**	Stream API function.
833   */
834   dk3_stream_api_fct_t	*f;
835 
836   /**	Input buffer.
837   */
838   char			*ib;
839 
840   /**	Output buffer.
841   */
842   char			*ob;
843 
844   /**	Number of bytes written.
845   */
846   dk3_um_t		wr;
847 
848   /**	Size of input buffer.
849   */
850   size_t		sz_ib;
851 
852   /**	Bytes available in input buffer.
853   */
854   size_t		av_ib;
855 
856   /**	Number of bytes already used from input buffer.
857   */
858   size_t		us_ib;
859 
860   /**	Size of output buffer.
861   */
862   size_t		sz_ob;
863 
864   /**	Number of bytes already placed in output buffer.
865   */
866   size_t		us_ob;
867 
868   /**	Output encoding, see @ref fileenc.
869   */
870   int			oe;
871 
872   /**	Usage flags, see @ref streamuseflags.
873   */
874   int			fl;
875 
876   /**	Flag: End of input found.
877   */
878   int			fe;
879 
880   /**	Flag: Reading 0 bytex indicates end of input.
881   */
882   int			ze;
883 
884   /**	Flag: Flush output buffer at end of line.
885   */
886   int			lf;
887 
888   /**	Flag: Error occured.
889   */
890   int			er;
891 
892   /**	Last error occured, see @ref errorcodes.
893   */
894   int			ec;
895 } dk3_stream_t;
896 
897 
898 
899 /**	Application structure.
900 */
901 typedef struct _dk3_app_t_ {
902 
903   /**	Messages array, either localized messages or default texts.
904   */
905   dkChar const * const	*msg;
906 
907   /**	Input file name currently processed (used in error messages).
908   */
909   dkChar const		*n_sourcefile;
910 
911   /**	Command line arguments.
912   */
913   dkChar const * 	*argv;
914 
915   /**	Application name.
916   */
917   dkChar const		*n_app;
918 
919   /**	Name of executable file for process.
920   */
921   dkChar const		*n_execfile;
922 
923   /**	Directory bin (directory for binaries - bindir).
924   */
925   dkChar const		*n_bindir;
926 
927   /**	Directory etc (system configuration directory - sysconfdir).
928   */
929   dkChar const		*n_etcdir;
930 
931   /**	Directory share (data root directory - datarootdir).
932   */
933   dkChar const		*n_sharedir;
934 
935   /**	Directory var (local state directory - vardir).
936   */
937   dkChar const		*n_vardir;
938 
939   /**	Login name of process owner.
940   */
941   dkChar const		*n_logname;
942 
943   /**	Home directory of process owner.
944   */
945   dkChar const		*n_homedir;
946 
947   /**	Aplication group name.
948   */
949   dkChar const		*n_appgroup;
950 
951   /**	File name for log file.
952   */
953   dkChar const		*n_logfilename;
954 
955   /**	Directory for temporary files.
956   */
957   dkChar const		*n_tmpdir;
958 
959   /**	Users language.
960   */
961   dkChar const		*n_language;
962 
963   /**	Users region.
964   */
965   dkChar const		*n_region;
966 
967   /**	Language/region setting string from environment or registry.
968   */
969   dkChar const		*n_langstr;
970 
971   /**	Host name.
972   */
973   dkChar const		*n_hostname;
974 
975   /**	Container for message catalogs.
976   */
977   dk3_sto_t		*s_mc;
978 
979   /**	Iterator through message catalogs container.
980   */
981   dk3_sto_it_t		*i_mc;
982 
983   /**	Container for preferences read from command line.
984   */
985   dk3_sto_t		*s_cmdprefs;
986 
987   /**	Iterator through command line preferences container.
988   */
989   dk3_sto_it_t		*i_cmdprefs;
990 
991   /**	Container for self-set preferences.
992   */
993   dk3_sto_t		*s_selfprefs;
994 
995   /**	Iterator through self-set preferences container.
996   */
997   dk3_sto_it_t		*i_selfprefs;
998 
999   /**	Container for system-wide preferences.
1000   */
1001   dk3_sto_t		*s_sysprefs;
1002 
1003   /**	Iterator through system-wide preferences container.
1004   */
1005   dk3_sto_it_t		*i_sysprefs;
1006 
1007   /**	Container for users constant preferences.
1008   */
1009   dk3_sto_t		*s_constprefs;
1010 
1011   /**	Iterator through users constant preferences container.
1012   */
1013   dk3_sto_it_t		*i_constprefs;
1014 
1015   /**	Container for users variable preferences.
1016   */
1017   dk3_sto_t		*s_varprefs;
1018 
1019   /**	Iterator through users variable preferences container.
1020   */
1021   dk3_sto_it_t		*i_varprefs;
1022 
1023   /**	Timestamp: Last logging to stderr.
1024   */
1025   dk3_time_t		 t_last_log_stderr;
1026 
1027   /**	Timestamp: Last logging to file.
1028   */
1029   dk3_time_t		 t_last_log_file;
1030 
1031   /**	Line number in current input file (used in error messages).
1032   */
1033   unsigned long		sourceline;
1034 
1035   /**	Name part of next temporary file name.
1036   */
1037   unsigned long		ul_tmpname;
1038 
1039   /**	Suffix part of next temporary file name.
1040   */
1041   unsigned		u_tmpsuffix;
1042 
1043   /**	Application type, see @ref apptypes.
1044   */
1045   int	app_type;
1046 
1047   /**	Error code, report delayed after finishing application initialization.
1048   */
1049   int	de;
1050 
1051   /**	Log level required for reporting to stderr, see @ref loglevels.
1052   */
1053   int	ll_stderr;
1054 
1055   /**	Log level required for reporting to file, see @ref loglevels.
1056   */
1057   int	ll_file;
1058 
1059   /**	Log level required to keep log file, see @ref loglevels.
1060   */
1061   int	ll_file_keep;
1062 
1063   /**	Log level required to keep temporary files, see @ref loglevels.
1064   */
1065   int	ll_tmp_keep;
1066 
1067   /**	Most relevant log level found, see @ref loglevels.
1068   */
1069   int	ll_highest;
1070 
1071   /**	Carry flag, too many temporary file names requested.
1072   */
1073   int	i_tmpcarry;
1074 
1075   /**	Number of command line arguments.
1076   */
1077   int	argc;
1078 
1079   /**	Internal encoding, used for strings in memory, see @ref stringenc.
1080   */
1081   int	i_encoding;
1082 
1083   /**	Encoding for output files, see @ref fileenc.
1084   */
1085   int	i_output_encoding;
1086 
1087   /**	Encoding expected on stdin, see @ref fileenc.
1088   */
1089   int	i_stdin_input_encoding;
1090 
1091   /**	Encoding expected when reading from files, see @ref fileenc.
1092   */
1093   int	i_file_input_encoding;
1094 
1095   /**	Flag: Unconfigure application (delete users variable preferences)
1096 	when finishing the application.
1097   */
1098   int	f_unconfigure;
1099 
1100   /**	Flag: Changes applied to preferences, need to save when finishing
1101 	the application.
1102   */
1103   int	f_prefschanged;
1104 
1105   /**	Flag: Setup completed, we can write log messages.
1106   */
1107   int	f_readytolog;
1108 
1109   /**	Flag: First attempt to log to file.
1110   */
1111   int	f_first_file_log;
1112 
1113   /**	Flag: Already attempted to initialize PRNG.
1114   */
1115   int	f_rand_initialized;
1116 
1117   /**	Flag: PRNG was initialized successfully.
1118   */
1119   int	f_rand_success;
1120 
1121   /**	PRNG type to use, see @ref rndtypes.
1122   */
1123   int	rand_type;
1124 
1125   /**	Flag: ${HOME}/log created.
1126   */
1127   int	cr_log;
1128 
1129   /**	Flag: ${HOME}/tmp/xxx created.
1130   */
1131   int	cr_tmp;
1132 
1133 } dk3_app_t;
1134 
1135 
1136 
1137 /**	File search result.
1138 */
1139 typedef struct _dk3_search_t_ {
1140 
1141   /**	Container for all file names found.
1142   */
1143   dk3_sto_t	*s_fn;
1144 
1145   /**	Iterator for all file names container.
1146   */
1147   dk3_sto_it_t	*i_fn;
1148 
1149   /**	Application structure, used for diagnostics.
1150   */
1151   dk3_app_t	*app;
1152 
1153   /**	Number of next file to add.
1154   */
1155   unsigned long	nf;
1156 
1157   /**	Flag: Inverted search order (most relevant files first).
1158   */
1159   int		inverted;
1160 } dk3_search_t;
1161 
1162 
1163 
1164 /**	Bit field.
1165 */
1166 typedef struct _dk3_bf_t_ {
1167 
1168   /**	Data bytes to store the bits.
1169   */
1170   unsigned char	*data;
1171 
1172   /**	Optional application structure for diagnostics.
1173   */
1174   dk3_app_t	*app;
1175 
1176   /**	Number of bits to save.
1177   */
1178   size_t	nbits;
1179 } dk3_bf_t;
1180 
1181 
1182 
1183 /**	Bit matrix.
1184 */
1185 typedef struct _dk3_bm_t_ {
1186 
1187   /**	Data bytes to store the bits.
1188   */
1189   unsigned char	**data;
1190 
1191   /**	Optional application structure for diagnostics.
1192   */
1193   dk3_app_t	*app;
1194 
1195   /**	Size of available cache for dk3bm_expand.
1196   */
1197   size_t	cachesize;
1198 
1199   /**	Number of bits per row.
1200   */
1201   size_t	columns;
1202 
1203   /**	Number of rows.
1204   */
1205   size_t	rows;
1206 } dk3_bm_t;
1207 
1208 
1209 
1210 /**	LaTeX font encoding information.
1211 */
1212 typedef unsigned char dk3_font_encoding_t;
1213 
1214 
1215 /**	Information about one package needed for an encoding.
1216 */
1217 typedef struct {
1218   char const	*name;	/**< Package name. */
1219   char		 used;	/**< Flag: Package used. */
1220 } dk3_uc2lat_pkg_t;
1221 
1222 
1223 /**	Pointer to a package information.
1224 */
1225 typedef dk3_uc2lat_pkg_t	*dk3_uc2lat_pkg_ptr;
1226 
1227 /**	Pointer to pointer to a package information.
1228 */
1229 typedef	dk3_uc2lat_pkg_ptr	*dk3_uc2lat_pkg_pptr;
1230 
1231 
1232 /**	Directory entry for UC to LaTeX, represents one input file.
1233 */
1234 typedef struct {
1235 
1236   /**	Container to store ranges.
1237   */
1238   dk3_sto_t		*s_ran;
1239 
1240   /**	Iterator through ranges container.
1241   */
1242   dk3_sto_it_t		*i_ran;
1243 
1244   /**	Short file name containing data for this directory entry.
1245   */
1246   dkChar const		*sn;
1247 
1248   /**	Flag: Data was loaded.
1249   */
1250   unsigned char		loaded;
1251 } dk3_uc2lat_dir_t;
1252 
1253 
1254 
1255 /**	Range of UC characters.
1256 */
1257 typedef struct {
1258 
1259   /**	LaTeX encodings for both text and math mode.
1260   */
1261   char const		**a;
1262 
1263   /**	LaTeX encodings for text mode only.
1264   */
1265   char const		**t;
1266 
1267   /**	LaTeX encodings for math mode only.
1268   */
1269   char const		**m;
1270 
1271   /**	Descriptions texts for character.
1272   */
1273   dkChar const		**dsc;
1274 
1275   /**	Package collections required for character.
1276  	NOT USED IN itadmin.
1277   */
1278   dk3_uc2lat_pkg_t	***p;
1279 
1280   /**	Information about font encodings required by characters.
1281   */
1282   dk3_font_encoding_t	*f;
1283 
1284   /**	Directory entry responsible for this range.
1285   */
1286   dk3_uc2lat_dir_t	*dir;
1287 
1288   /**	First character in range.
1289   */
1290   dk3_c32_t		start;
1291 
1292   /**	Last character in range.
1293   */
1294   dk3_c32_t		end;
1295 
1296   /**	Flag: Initialization of range attempted, no second attempt.
1297   */
1298   unsigned char		ia;
1299 } dk3_uc2lat_range_t;
1300 
1301 
1302 
1303 /**	Data for U32 to LaTeX conversion.
1304 */
1305 typedef struct {
1306 
1307   /**	Application structure for diagnostics and file search.
1308   */
1309   dk3_app_t	*app;
1310 
1311   /**	Name of data directory containing the LaTeX encodings.
1312   */
1313   dkChar const	*dir;
1314 
1315   /**	Allocated buffer for characters directly passed through.
1316   */
1317   char		*buf;
1318 
1319   /**	Container for ranges.
1320   */
1321   dk3_sto_t	*s_ran;
1322 
1323   /**	Iterator through ranges container.
1324   */
1325   dk3_sto_it_t	*i_ran;
1326 
1327   /**	Container for directories.
1328   */
1329   dk3_sto_t	*s_dir;
1330 
1331   /**	Iterator for directories container.
1332   */
1333   dk3_sto_it_t	*i_dir;
1334 
1335   /**	Container for packages.
1336   */
1337   dk3_sto_t	*s_pkg;
1338 
1339   /**	Iterator through packages container.
1340   */
1341   dk3_sto_it_t	*i_pkg;
1342 
1343   /**	Cache: Last range used.
1344   */
1345   dk3_uc2lat_range_t	*rca;
1346 
1347   /**	Size of buffer @a buf.
1348   */
1349   size_t	 szbuf;
1350 
1351   /**	Flag: Load descriptions for characters too (normally the
1352 	descriptions are ignored).
1353   */
1354   int		 f_dsc;
1355 
1356   /**	Flag: Generate UTF-8 output.
1357   */
1358   int		 f_utf8;
1359 
1360   /**	Font encoding information.
1361   */
1362   dk3_font_encoding_t	fe;
1363 } dk3_uc2lat_t;
1364 
1365 
1366 
1367 /**	Handler function for one line.
1368 	@param	obj	Object to modify using the line.
1369 	@param	il	Input line to process.
1370 	@return	1=OK, 0=error, can continue, -1=error, abort processing.
1371 */
1372 typedef
1373 int
1374 dk3_line_handler_t(
1375   void		*obj,
1376   dkChar	*il
1377 );
1378 
1379 
1380 
1381 /**	Struct for processing a file line by line.
1382 */
1383 typedef struct {
1384   /**	Application structure for diagnostics.
1385   */
1386   dk3_app_t		*app;
1387   /**	Data object to modify while processing input lines.
1388   */
1389   void			*obj;
1390   /**	Handler function.
1391   */
1392   dk3_line_handler_t	*hf;
1393   /**	Buffer for input lines.
1394   */
1395   dkChar		*buf;
1396   /**	Current insertion position for next character to add.
1397   */
1398   dkChar		*cp;
1399   /**	Size of input buffer @a buf.
1400   */
1401   size_t		 szbuf;
1402   /**	Number of characters used in @a buf.
1403   */
1404   size_t		 bufus;
1405   /**	System encoding, see @ref stringenc.
1406   */
1407   int			 se;
1408 } dk3_line_handler_data_t;
1409 
1410 
1411 
1412 /**	One option.
1413 */
1414 typedef struct {
1415   /**	Short option character.
1416   */
1417   dkChar 		 so;
1418   /**	Long option text.
1419   */
1420   dkChar const		*lo;
1421   /**	Flag: Option needs an argument.
1422   */
1423   int			 na;
1424 } dk3_option_t;
1425 
1426 
1427 
1428 /**	Options set.
1429 */
1430 typedef struct {
1431   /**	Application structure for diagnostics.
1432   */
1433   dk3_app_t		 *app;
1434   /**	Options to find in command line arguments.
1435   */
1436   dk3_option_t const	 *options;
1437   /**	Array of flags, one for each options, whether or not the option was
1438 	found.
1439   */
1440   int		 	 *found;
1441   /**	Array for option arguments.
1442   */
1443   dkChar const		**optargs;
1444   /**	Array of normal arguments (no options and no option arguments).
1445   */
1446   dkChar const		**args;
1447   /**	Further options.
1448   */
1449   dkChar const		**fo;
1450   /**	Short option to introduce further options.
1451   */
1452   dkChar		  foc;
1453   /**	Long option to introduce further options.
1454   */
1455   dkChar const		 *focl;
1456   /**	Number of elements in @a options.
1457   */
1458   size_t		  szoptions;
1459   /**	Number of normal arguments available.
1460   */
1461   int			  argsav;
1462   /**	Number of normal arguments used (found).
1463   */
1464   int			  argsused;
1465   /**	Number of further options available.
1466   */
1467   int			  foav;
1468   /**	Number of further options found.
1469   */
1470   int			  fou;
1471   /**	Error code of last error occured, see @ref errorcodes.
1472   */
1473   int			  ec;
1474 } dk3_option_set_t;
1475 
1476 
1477 
1478 /**	Output filter cell details for ASCII/Hex encoding.
1479 */
1480 typedef struct {
1481   /**	Number of characters already printed in current line.
1482   */
1483   size_t			nl;
1484 } dk3_of_cell_ah_details_t;
1485 
1486 /**	Output filter cell details for ASCII85 encoding.
1487 */
1488 typedef struct {
1489   /**	32-bit value built up by for bytes.
1490   */
1491   unsigned long			val;
1492   /**	Number of characters merged into @a val.
1493   */
1494   size_t			nc;
1495   /**	Number of characters already printed in current line.
1496   */
1497   size_t			nl;
1498 } dk3_of_cell_a85_details_t;
1499 
1500 
1501 
1502 /**	Output filter cell details for run-length compression.
1503 */
1504 typedef struct {
1505   /**	Data buffer.
1506   */
1507   unsigned char		*bu;
1508   /**	Number of bytes used in buffer @a bu.
1509   */
1510   size_t		 used;
1511   /**	Number of same bytes repeated.
1512   */
1513   size_t		 same;
1514   /**	Previous character processed.
1515   */
1516   unsigned char		 pc;
1517   /**	Flag: Have a previous character.
1518   */
1519   unsigned char		 hc;
1520   /**	Flag: In a run.
1521   */
1522   unsigned char		 run;
1523 } dk3_of_cell_rl_details_t;
1524 
1525 
1526 
1527 #if DK3_HAVE_ZLIB_H
1528 /**	Output filter cell details for flate compression.
1529 */
1530 typedef struct {
1531   /**	zlib stream.
1532   */
1533   z_stream		*zs;
1534   /**	Input buffer.
1535   */
1536   Bytef			*ibu;
1537   /**	Output buffer.
1538   */
1539   Bytef			*obu;
1540   /**	Number of input bytes used.
1541   */
1542   uLong			 iused;
1543   /**	Flag: Everything ok, no errors yet.
1544   */
1545   int			 ok;
1546 } dk3_of_cell_flate_details_t;
1547 #endif
1548 
1549 
1550 /**	Output filter cell details.
1551 */
1552 typedef union {
1553 #if DK3_HAVE_ZLIB_H
1554     /**	Flate compression data.
1555     */
1556     dk3_of_cell_flate_details_t	flate;
1557 #endif
1558     /**	Run-length compression data.
1559     */
1560     dk3_of_cell_rl_details_t	psrl;
1561     /**	ASCII85 encoding data.
1562     */
1563     dk3_of_cell_a85_details_t	a85;
1564     /**	ASCII-Hex encoding data.
1565     */
1566     dk3_of_cell_ah_details_t	ah;
1567 } dk3_of_cell_details_t;
1568 
1569 
1570 
1571 /**	Output filter cell.
1572 */
1573 typedef struct _dk3_of_cell_t_ {
1574   /**	Compression/encoding algorithm-specific data.
1575   */
1576   dk3_of_cell_details_t		data;
1577   /**	Next cell downwards.
1578   */
1579   struct _dk3_of_cell_t_	*down;
1580   /**	Next cell upwards.
1581   */
1582   struct _dk3_of_cell_t_	*up;
1583   /**	Output filter owning this cell.
1584   */
1585   void				*of;	/**< Output filter. */
1586   /**	Output filter cell type DK3_OF_CELL_TYPE_xxx,
1587 	see @ref outputfiltercelltypes.
1588   */
1589   int				 type;
1590 } dk3_of_cell_t;
1591 
1592 
1593 
1594 /**	Output filter on top of a stream.
1595 */
1596 typedef struct {
1597   /**	Application structure for diagnostics.
1598   */
1599   dk3_app_t		*app;
1600   /**	Output stream to receive the filtered data.
1601   */
1602   dk3_stream_t		*os;
1603   /**	Bottom filter cell (next to the stream).
1604   */
1605   dk3_of_cell_t		*bottom;
1606   /**	Top filter cell (input goes to here).
1607   */
1608   dk3_of_cell_t		*top;
1609   /**	Number of cells.
1610   */
1611   size_t		 nCells;
1612   /**	Number of bits used in the @a bits variable.
1613   */
1614   size_t		 nBits;
1615   /**	The bits stored so far.
1616   */
1617   unsigned char		 bits;
1618   /**	Flag set for output filter.
1619   */
1620   unsigned char		 flags;
1621 } dk3_of_t;
1622 
1623 
1624 
1625 #if 0
1626 
1627 /**	One datum stored in the in-memory database.
1628 */
1629 typedef struct {
1630   /**	Start address of data.
1631   */
1632   void		*data;
1633   /**	Data size (number of bytes).
1634   */
1635   size_t	 size;
1636 } dk3_memdb_datum_t;
1637 
1638 
1639 
1640 /**	In-memory database.
1641 */
1642 typedef struct {
1643   /**	Container for the key/value pairs.
1644   */
1645   dk3_sto_t		*st;
1646   /**	Iterator through key/value pair container.
1647   */
1648   dk3_sto_it_t		*it;
1649   /**	Application structure for diagnostics.
1650   */
1651   dk3_app_t		*app;
1652   /**	File name of database on disk.
1653   */
1654   dkChar const		*fn;
1655   /**	Start of key.
1656   */
1657   char			*kb;
1658   /**	Start of value.
1659   */
1660   char			*vb;
1661   /**	Input line buffer.
1662   */
1663   char			*il;
1664   /**	Binary key size.
1665   */
1666   size_t		 szkb;
1667   /**	Text key size.
1668   */
1669   size_t		 szkt;
1670   /**	Binary value size.
1671   */
1672   size_t		 szvb;
1673   /**	Text value size.
1674   */
1675   size_t		 szvt;
1676   /**	Text line size.
1677   */
1678   size_t		 szl;
1679   /**	Error code of last error occured, see @ref errorcodes.
1680   */
1681   int			 ec;
1682   /**	Flag: Dirty (synchronization needed).
1683   */
1684   int			 f_dt;
1685 } dk3_memdb_t;
1686 
1687 #endif
1688 
1689 
1690 
1691 /**	Data to store in a database as key or value.
1692 */
1693 typedef struct {
1694   /**	Data bytes.
1695   */
1696   void		*dt;
1697   /**	Number of bytes.
1698   */
1699   size_t	 sz;
1700 } dk3_datum_t;
1701 
1702 
1703 
1704 /**	Details for a memory database.
1705 */
1706 typedef struct {
1707   /**	Container for key/value pairs.
1708   */
1709   dk3_sto_t		*s_mem;
1710   /**	Container iterator.
1711   */
1712   dk3_sto_it_t		*i_mem;
1713 } dk3_dbi_mem_details_t;
1714 
1715 
1716 
1717 /**	Details for Berkeley DB database.
1718 */
1719 typedef struct {
1720   /**	The BDB database.
1721   */
1722   void			*dbptr;
1723 } dk3_dbi_bdb_details_t;
1724 
1725 
1726 
1727 /**	Details for NDBM database.
1728 */
1729 typedef struct {
1730   /**	8-bit character file name, only used if dkChar is 16 bit or above.
1731   */
1732   void			*dbptr;
1733 } dk3_dbi_ndbm_details_t;
1734 
1735 
1736 
1737 /**	Database type specific details.
1738 */
1739 typedef union {
1740   /**	Memory database.
1741   */
1742   dk3_dbi_mem_details_t		mem;
1743   /**	Berkeley database details.
1744   */
1745   dk3_dbi_bdb_details_t		bdb;
1746   /**	NDBM database details.
1747   */
1748   dk3_dbi_ndbm_details_t	ndbm;
1749 } dk3_dbi_details_t;
1750 
1751 
1752 
1753 /**	Database interface.
1754 */
1755 typedef struct {
1756   /**	Database type specific details.
1757    */
1758   dk3_dbi_details_t	details;
1759   /**	Application structure for diagnostics.
1760   */
1761   dk3_app_t		*app;
1762   /**	File name for database on disk.
1763   */
1764   dkChar const		*fn;
1765   /**	Database type, DK3_DB_TYPE_xxx, see @ref databasetypes.
1766   */
1767   int			tp;
1768   /**	Flag: Database opened for writing.
1769   */
1770   int			wr;
1771   /**	Flag: Database modified, sync to file necessary.
1772   */
1773   int			mod;
1774   /**	Flag: Write error messages for keys not found.
1775   */
1776   int			rfk;
1777   /**	Error code for last error occured.
1778   */
1779   int			ec;
1780 } dk3_dbi_t;
1781 
1782 
1783 
1784 /**	BIF coordinates type.
1785 	Must include negative values as predictor operators may
1786 	try to obtain values in row and column -1.
1787 */
1788 typedef long	dk3_bif_coord_t;
1789 
1790 
1791 
1792 /**	BIF pixel value type.
1793 */
1794 typedef unsigned short dk3_bif_pixel_t;
1795 
1796 /**	Size of BIF pixel value.
1797 */
1798 #define	DK3_SIZEOF_BIF_PIXEL_T	DK3_SIZEOF_SHORT
1799 
1800 /**	Pixel resample information.
1801 */
1802 typedef struct {
1803   size_t		iw;	/**< Input width. */
1804   size_t		ow;	/**< Output width. */
1805   dk3_bif_pixel_t	im;	/**< Input maximum. */
1806   dk3_bif_pixel_t	om;	/**< Output maximum. */
1807   dk3_bif_pixel_t	im2;	/**< Half of input minimum. */
1808 } dk3_pixel_resample_t;
1809 
1810 
1811 
1812 /**	One frame in bitmap image file.
1813 */
1814 typedef struct {
1815   /**	X resolution.
1816   */
1817   double		 xres;
1818   /**	Y resolution.
1819   */
1820   double		 yres;
1821   /**	Bitmap type specific data per frame.
1822   */
1823   void			*implspec;
1824   /**	Frame width.
1825   */
1826   dk3_bif_coord_t	 w;
1827   /**	Frame height.
1828   */
1829   dk3_bif_coord_t	 h;
1830   /**	Bits per component for frame found in file.
1831   */
1832   size_t		 bits;
1833   /**	Number of non-redundant bits in @ bits.
1834   */
1835   size_t		 realbits;
1836   /**	Frame number.
1837   */
1838   size_t		 n;		/**< Frame number. */
1839   /**	Color space, DK3_COLOR_SPACE_xxx, see @ref colorspaces.
1840   */
1841   int			 cs;
1842   /**	Flag: Really colored, 1=colored, 0=gray.
1843   */
1844   int			 realcolor;
1845   /**	Flag: Really found alpha data.
1846   */
1847   int			 realalpha;
1848   /**	Flag: Background color defined for frame.
1849   */
1850   int			 bg;
1851   /**	Background red found in file.
1852   */
1853   dk3_bif_pixel_t	 bgr;
1854   /**	Background green found in file.
1855   */
1856   dk3_bif_pixel_t	 bgg;
1857   /**	Background blue found in file.
1858   */
1859   dk3_bif_pixel_t	 bgb;
1860   /**	Background gray found in file.
1861   */
1862   dk3_bif_pixel_t	 bggr;
1863 } dk3_bif_frame_t;
1864 
1865 
1866 
1867 /**	Bitmap image file.
1868 */
1869 typedef struct {
1870   /**	Structure to upsample or downsample pixel values.
1871   */
1872   dk3_pixel_resample_t	 pr;
1873   /**	Application structure for diagnostics.
1874   */
1875   dk3_app_t		*app;
1876   /**	Container for frames.
1877   */
1878   dk3_sto_t		*s_frames;
1879   /**	Iterator through frames container.
1880   */
1881   dk3_sto_it_t		*i_frames;
1882   /**	Current frame to process.
1883   */
1884   dk3_bif_frame_t	*cf;
1885   /**	Bitmap image type specific data per file.
1886   */
1887   void			*implspec;
1888   /**	Name of temporary file (if any), may be NULL.
1889   */
1890   char const		*tmpfn;
1891   /**	Temporary file (if any), may be NULL.
1892   */
1893   FILE			*tmpfipo;
1894   /**	Number of bitmap image file within process.
1895   */
1896   unsigned long		 n;
1897   /**	Number of frames available.
1898   */
1899   size_t		 n_frames;
1900   /**	Bits per component requested for output.
1901   */
1902   size_t		 bits;
1903   /**	BIF image type DK3_BIF_IMAGE_TYPE_xxx, see @ref bifimagetypes.
1904   */
1905   int			 bt;
1906   /**	Flag: Force use of requested background over bg found in file.
1907   */
1908   int			 bg;
1909   /**	Flag: Remove temporary file when closing the structure.
1910   */
1911   int			 remtmpf;
1912   /**	Background red requested.
1913   */
1914   dk3_bif_pixel_t	 bgr;
1915   /**	Background green requested.
1916   */
1917   dk3_bif_pixel_t	 bgg;
1918   /**	Background blue requested.
1919   */
1920   dk3_bif_pixel_t	 bgb;
1921 } dk3_bif_t;
1922 
1923 
1924 
1925 /**	Paper size description. All sizes are specified in PS points.
1926 */
1927 typedef struct {
1928   /**	Width.
1929   */
1930   double	w;
1931   /**	Height.
1932   */
1933   double	h;
1934   /**	Left border (inner border for duplex without tumble).
1935   */
1936   double	i;
1937   /**	Right border (outer border for duplex without tumble).
1938   */
1939   double	o;
1940   /**	Top border (inner border for duplex with tumble).
1941   */
1942   double	t;
1943   /**	Bottom bofder (outer border for duplex with tumble).
1944   */
1945   double	b;
1946 } dk3_paper_size_t;
1947 
1948 
1949 
1950 /**	Named paper size.
1951 */
1952 typedef struct {
1953   /**	Size.
1954   */
1955   dk3_paper_size_t		 size;
1956   /**	Size name.
1957   */
1958   dkChar const		*name;
1959 } dk3_named_paper_size_t;
1960 
1961 
1962 
1963 /**	Collection of multiple named paper sizes.
1964 */
1965 typedef struct {
1966   /**	Application structure for diagnostics and file search.
1967   */
1968   dk3_app_t		*app;
1969   /**	Container of named paper sizes.
1970   */
1971   dk3_sto_t		*s_sizes;
1972   /**	Iterator through named paper sizes container.
1973   */
1974   dk3_sto_it_t		*i_sizes;
1975 } dk3_paper_size_collection_t;
1976 
1977 
1978 
1979 
1980 
1981 
1982 /**	Area to place an image.
1983 */
1984 typedef struct {
1985   /**	Left x.
1986   */
1987   double	xl;
1988   /**	Right x.
1989   */
1990   double	xr;
1991   /**	Top y.
1992   */
1993   double	yt;
1994   /**	Bottom y.
1995   */
1996   double	yb;
1997 } dk3_image_area_t;
1998 
1999 
2000 
2001 /**	Area to place a PS/PDF image.
2002 */
2003 typedef union {
2004   /**	Paper size for creating a document.
2005   */
2006   dk3_paper_size_t	ps;
2007   /**	Image area to use when converting Fig to PS.
2008   */
2009   dk3_image_area_t	ia;
2010 } dk3_bm_eps_area_t;
2011 
2012 
2013 
2014 /**	Object start position.
2015 */
2016 typedef struct {
2017   /**	Object number.
2018   */
2019   unsigned long		objno;
2020 
2021   /**	Start position in file.
2022   */
2023   dk3_um_t		startpos;
2024 } dk3_pdf_position_t;
2025 
2026 
2027 
2028 /**	XObject representing one image or alpha mask.
2029 */
2030 typedef struct {
2031   /**	Name of temporary file with contents.
2032   */
2033   dkChar const		*tempfilename;
2034 
2035   /**	Xobject for alpha mask.
2036   */
2037   void			*mask;
2038 
2039   /**	Stream length.
2040   */
2041   dk3_um_t		slgt;
2042 
2043   /**	Image width (number of pixels).
2044   */
2045   dk3_bif_coord_t	width;
2046 
2047   /**	Image height (number of pixels).
2048   */
2049   dk3_bif_coord_t	height;
2050 
2051   /**	Object number for XObject.
2052   */
2053   unsigned long		objno;
2054 
2055   /**	XObject type DK3_PDF_XO_TYPE_xxx, see @ref pdfxobjecttype.
2056   */
2057   int			xot;
2058 
2059   /**	Procedure for object, DK3_BMEPS_xxx, see @ref bmepscompression.
2060   */
2061   int			procedure;
2062 
2063   /**	Bits per component.
2064   */
2065   int			bpc;
2066 
2067   /**	Flag: Stream is DCT (1) or flate (0).
2068   */
2069   int			dct;
2070 
2071   /**	Predictor DK3_COMPRESSIONPREDICTOR_xxx, see @ref flatepredictors.
2072   */
2073   int			pred;
2074 
2075   /**	Flag: Adobe marker was found in CMYK DCT file.
2076   */
2077   int			adobe_marker_found;
2078 
2079   /**	Flag: Used by current page.
2080   */
2081   int			used;
2082 
2083   /**	Flag: Interpolate this object.
2084   */
2085   int			interpolate;
2086 } dk3_pdf_xobject_t;
2087 
2088 
2089 
2090 /**	One PDF page.
2091 */
2092 typedef struct {
2093   /**	Name of temporary file for page description stream.
2094   */
2095   dkChar const		*tempfilename;
2096 
2097   /**	Temporary file.
2098   */
2099   FILE			*tempfile;
2100 
2101   /**	Stream to write to temporary file.
2102   */
2103   dk3_stream_t		*tempstream;
2104 
2105   /**	Output filter, used to write to temporary file.
2106   */
2107   dk3_of_t		*tempof;
2108 
2109   /**	Collection of all XObjects used by this page.
2110   */
2111   dk3_sto_t		*s_xobjects;
2112 
2113   /**	Iterator through XObjects collection.
2114   */
2115   dk3_sto_it_t		*i_xobjects;
2116 
2117   /**	Stream length.
2118   */
2119   dk3_um_t		slgt;
2120 
2121   /**	PDF object number.
2122   */
2123   unsigned long		objno;
2124 
2125   /**	Page number.
2126   */
2127   unsigned long		pageno;
2128 
2129   /**	Media box x0.
2130   */
2131   long			mbx0;
2132 
2133   /**	Media box x1.
2134   */
2135   long			mbx1;
2136 
2137   /**	Media box y0.
2138   */
2139   long			mby0;
2140 
2141   /**	Media box y1.
2142   */
2143   long			mby1;
2144 } dk3_pdf_page_t;
2145 
2146 
2147 
2148 /**	Structure used to write a PDF file.
2149 */
2150 typedef struct {
2151   /**	Application structure, used to find temporary file names.
2152   */
2153   dk3_app_t		*app;
2154 
2155   /**	XObject storage (bitmaps).
2156   */
2157   dk3_sto_t		*s_xobjects;
2158 
2159   /**	Iterator through XObject storage.
2160   */
2161   dk3_sto_it_t		*i_xobjects;
2162 
2163   /**	Pages storage.
2164   */
2165   dk3_sto_t		*s_pages;
2166 
2167   /**	Iterator through pages storage.
2168   */
2169   dk3_sto_it_t		*i_pages;
2170 
2171   /**	Current page.
2172   */
2173   dk3_pdf_page_t	*cp;
2174 
2175   /**	Next XObject object number.
2176   	First Xobject is object number 4 as we have info object,
2177 	root object and pages collection object as 1, 2, and 3.
2178   */
2179   unsigned long		nextobject;
2180 
2181   /**	Next page number.
2182   */
2183   unsigned long		nextpage;
2184 
2185   /**	Media box x0 for next page.
2186   */
2187   long			mbx0;
2188 
2189   /**	Media box x1 for next page.
2190   */
2191   long			mbx1;
2192 
2193   /**	Media box y0 for next page.
2194   */
2195   long			mby0;
2196 
2197   /**	Media box y1 for next page.
2198   */
2199   long			mby1;
2200 
2201   /**	Flag: Document mode (1) or image/object (0).
2202   */
2203   int			documentMode;
2204 
2205 } dk3_pdf_t;
2206 
2207 
2208 /**	Options to convert a bitmap image to PS/PDF.
2209 */
2210 typedef struct {
2211   /**	Image area.
2212   */
2213   dk3_bm_eps_area_t	ima;
2214 
2215   /**	Resolution in dpi.
2216   */
2217   double		resolution;
2218 
2219   /**	Application structure for diagnostics, may be NULL.
2220   */
2221   dk3_app_t		*app;
2222 
2223   /**	Output driver DK3_BMEPS_DRIVER_xxx, see @ref bmepsdrivers.
2224   */
2225   int			dr;
2226 
2227   /**	Run mode DK3_BMEPS_MODE_xxx, see @ref dkbmmodes.
2228   */
2229   int			mode;
2230 
2231   /**	Size conversion mode.
2232   */
2233   int			szmode;
2234 
2235   /**	Compression predictor for flate compression,
2236 	DK3_COMPRESSION_PREDICTOR_xxx, see @ref flatepredictors.
2237   */
2238   int			pred;
2239 
2240   /**	Image origin position DK3_IMAGE_ORIGIN, see @ref imageorigin.
2241   */
2242   int			io;
2243 
2244   /**	Flag: Draft mode.
2245   */
2246   int			draft;
2247 
2248   /**	Flag: Printout in duplex.
2249   */
2250   int			duplex;
2251 
2252   /**	Flag: Printout in tumble mode (like a calendar).
2253   */
2254   int			tumble;
2255 
2256   /**	PS level (2 or 3).
2257   */
2258   int			psl;
2259 
2260   /**	Flag: Write DSC comments.
2261   */
2262   int			dsc;
2263 
2264   /**	Flag: Allow direct DCT data transfer.
2265   */
2266   int			dct;
2267 
2268   /**	Flag: Keep aspect ratio.
2269   */
2270   int			kar;
2271 
2272   /**	Requested/suggested background red, 8 bits per pixel.
2273   */
2274   int			bgr;
2275 
2276   /**	Requested/suggested background green, 8 bits per pixel.
2277   */
2278   int			bgg;
2279 
2280   /**	Requested/suggested background blue, 8 bits per pixel.
2281   */
2282   int			bgb;
2283 
2284   /**	Flag: Enforce this background over bg color found in file.
2285   */
2286   int			fbg;
2287 
2288   /**	Flag: Image interpolation enabled.
2289   */
2290   int			ip;
2291 
2292   /**	Flag: Image interpolation enabled for JPEG files too.
2293   */
2294   int			jip;
2295 
2296   /**	Flag: Make mode.
2297   */
2298   int			make;
2299 
2300   /**	Write colored output.
2301   */
2302   int			color;
2303 
2304   /**	Flag: Reduce bits per component.
2305   */
2306   int			rbpc;
2307 
2308   /**	Flag: Write to stdout.
2309   */
2310   int			to_stdout;
2311 } dk3_bm_eps_options_t;
2312 
2313 
2314 
2315 /**	Internal conversion job structure.
2316 */
2317 typedef struct {
2318 
2319   /**	Conversion option set.
2320   */
2321   dk3_bm_eps_options_t		*opt;
2322 
2323   /**	Localized message texts.
2324   */
2325   dkChar const * const		*msg;
2326 
2327   /**	Source file name.
2328   */
2329   dkChar const			*sfn;
2330 
2331   /**	Destination file name.
2332   */
2333   dkChar const			*dfn;
2334 
2335   /**	Destination file.
2336   */
2337   FILE				*dfile;
2338 
2339   /**	PDF writer structure.
2340   */
2341   dk3_pdf_t			*pdf;
2342 
2343   /**	Bitmap image file.
2344   */
2345   dk3_bif_t			*bif;
2346 
2347   /**	Communication object.
2348   */
2349   void				*pComm;
2350 
2351   /**	Translation x.
2352   */
2353   double			 x_translate;
2354 
2355   /**	Translation y.
2356   */
2357   double			 y_translate;
2358 
2359   /**	Scale x.
2360   */
2361   double			 x_scale;
2362 
2363   /**	Scale y.
2364   */
2365   double			 y_scale;
2366 
2367   /**	Left x coordinate (used for the draft).
2368   */
2369   double			 x_0;
2370 
2371   /**	Right x coordinate (used for the draft).
2372   */
2373   double			 x_1;
2374 
2375   /**	Lower y coordinate (used for the draft).
2376   */
2377   double			 y_0;
2378 
2379   /**	Upper y coordinate (used for the draft).
2380   */
2381   double			 y_1;
2382 
2383   /**	Image width (bounding box).
2384   */
2385   long				 x_size;
2386 
2387   /**	Image width (bounding box).
2388   */
2389   long				 y_size;
2390 
2391   /**	Number of bits per component.
2392   */
2393   size_t			 bpc;
2394 
2395   /**	Number of pages to produce.
2396   */
2397   size_t			 nPages;
2398 
2399   /**	Number of current page.
2400   */
2401   size_t			 currentPage;
2402 
2403   /**	Minimum value for progress bar.
2404   */
2405   int				 minpb;
2406 
2407   /**	Maximum value for progress bar.
2408   */
2409   int				 maxpb;
2410 
2411   /**	Image file type.
2412   */
2413   int				 biftype;
2414 
2415   /**	Flag: Must translate coordinates.
2416   */
2417   int				 do_translate;
2418 
2419   /**	Rotation (multiples of 90 degree).
2420   */
2421   int				 do_rotate;
2422 
2423   /**	Use floating point numbers for scaling.
2424   */
2425   int				 do_float_scale;
2426 
2427   /**	Flag: Must do header and footer.
2428   */
2429   int				 do_header_footer;
2430 
2431   /**	Output procedure DK3_BMEPS_xxx, see @ref bmepscompression.
2432   */
2433   int				 procedure;
2434 
2435 } dk3_bm_conversion_job_t;
2436 
2437 
2438 
2439 /**	Information about one font.
2440 */
2441 typedef struct {
2442   char const		*psFontName;	/**< PS font name. */
2443   char const		*texFontName;	/**< LaTeX font name. */
2444   char const		*texFamilyName;	/**< LaTeX font family name. */
2445   char const		*gsFontName;	/**< GhostScript font name. */
2446   char const		*gsFileOld;	/**< Old GhostScript font file name. */
2447   char const		*gsFileNew;	/**< New GhostScript font file name. */
2448   char const		*psFamilyName;	/**< PS font family name. */
2449   char const		*svgFamilyName;	/**< SVG font family name. */
2450   char const		*svgFontId;	/**< SVG font identifier. */
2451   char const * const	*replacements;	/**< Replacement family names. */
2452   int			 features;	/**< Font features (bold/italic). */
2453   int			 svgFeatures;	/**< Font features when used in SVG. */
2454   int			 svgFontWeight;	/**< Font weight. */
2455 } dk3_font_t;
2456 
2457 
2458 
2459 /**	Bounding box data.
2460 */
2461 typedef struct {
2462   double	xmin;	/**< Minimum x. */
2463   double	xmax;	/**< Maximum x. */
2464   double	ymin;	/**< Minimum y. */
2465   double	ymax;	/**< Maximum y. */
2466   int		xused;	/**< Flag: x-value specified. */
2467   int		yused;	/**< Flag: y-value specified. */
2468 } dk3_bb_t;
2469 
2470 
2471 
2472 /**	Coordinates transformation-
2473 */
2474 typedef struct {
2475   double	mx;	/**< X factor. */
2476   double	nx;	/**< X summand. */
2477   double	my;	/**< Y factor. */
2478   double	ny;	/**< Y summand. */
2479 } dk3_ct_2d_t;
2480 
2481 
2482 
2483 /**	Color specified as RGB.
2484 */
2485 typedef struct {
2486   double	r;	/**< Red. */
2487   double	g;	/**< Green. */
2488   double	b;	/**< Blue. */
2489 } dk3_rgb_color_t;
2490 
2491 
2492 
2493 /**	Coordinates system transformation to place an image.
2494 	Order of operations is translate, rotate, scale.
2495 */
2496 typedef struct {
2497   double	x_translate;	/**< X translation. */
2498   double	y_translate;	/**< Y translation. */
2499   double	x_scale;	/**< X scale factor. */
2500   double	y_scale;	/**< Y scale factor. */
2501   int		rot;		/**< Rotation angle, multiple of 90 degrees. */
2502 } dk3_coordinates_transformation_t;
2503 
2504 
2505 
2506 /**	Details for a Windows printer.
2507 */
2508 typedef struct {
2509   int			dummy;		/**< No details for Windows. */
2510 } dk3_printer_windows_details_t;
2511 
2512 
2513 
2514 /**	Details for LPRng/LPD queue.
2515 */
2516 typedef struct {
2517   dkChar const		*hostname;	/**< Destination host name. */
2518   dkChar const		*queuename;	/**< Destination queue name. */
2519   double		 to_c;		/**< Timeout for connect. */
2520   double		 to_r;		/**< Timeout for receive. */
2521   double		 to_s;		/**< Timeout for send. */
2522 } dk3_printer_lprng_details_t;
2523 
2524 
2525 
2526 /**	Details for a socket connected printer.
2527 */
2528 typedef struct {
2529   dkChar const		*hostname;	/**< Destination host or address. */
2530   unsigned short	 portno;	/**< Port no, host representation. */
2531   unsigned char		 ordrel;	/**< Flag: Orderly release. */
2532   double		 to_c;		/**< Timeout for connect. */
2533   double		 to_r;		/**< Timeout for receive. */
2534   double		 to_s;		/**< Timeout for send. */
2535 } dk3_printer_socket_t;
2536 
2537 
2538 
2539 /**	Details for a printer.
2540 */
2541 typedef union {
2542   dk3_printer_windows_details_t		win;	/**< Windows printer details. */
2543   dk3_printer_lprng_details_t		lprng;	/**< LPRng printer details. */
2544   dk3_printer_socket_t			sock;	/**< Socket printer details. */
2545 } dk3_printer_details_t;
2546 
2547 
2548 
2549 /**	Printer.
2550 	Windows printer ports can be a connection to a remote
2551 	raw socket or LPD/LPRng queue. In these cases t_p and det_p
2552 	indicate "Windows printer" and the t_s and det_s contain
2553 	information about the backend.
2554 	For the "clean" and "status" commands we need to access
2555 	the backend, other operations only access the Windows printer.
2556 
2557 */
2558 typedef struct {
2559   dk3_printer_details_t	 det_p;	/**< Primary type printer details. */
2560   dk3_printer_details_t	 det_s;	/**< Secondary type printer details. */
2561   dkChar const		*name;	/**< Printer name. */
2562   dkChar const		*h_snmp;	/**< Host to access for SNMP. */
2563   dkChar const		*c_snmp;	/**< SNMP community. */
2564   int			 t_p;	/**< Primary type,see @ref printertypes.  */
2565   int			 t_s;	/**< Secondard type, see @ref printertypes.  */
2566   int			 v_snmp;	/**< SNMP version. */
2567   int			 ps;	/**< Flag: PS printer. */
2568 } dk3_printer_t;
2569 
2570 
2571 
2572 /**	Queue name alias.
2573 */
2574 typedef struct {
2575   dkChar const		*name;		/**< Alias name. */
2576   dk3_printer_t		*printer;	/**< Alias destination. */
2577 } dk3_printer_alias_t;
2578 
2579 
2580 
2581 /**	Print host.
2582 */
2583 typedef struct {
2584   dkChar const		*name;		/**< Host name. */
2585   double		 to_c;		/**< Timeout for connect. */
2586   double		 to_r;		/**< Timeout for receive. */
2587   double		 to_s;		/**< Timeout for send. */
2588   int			 enc;		/**< Host encoding (plain or UTF-8). */
2589 } dk3_print_host_t;
2590 
2591 
2592 
2593 /**	Print host alias.
2594 */
2595 typedef struct {
2596   dkChar const		*name;		/**< Alias name. */
2597   dk3_print_host_t	*host;		/**< Destination host. */
2598 } dk3_print_host_alias_t;
2599 
2600 
2601 
2602 /**	Print configuration for a computer system.
2603 */
2604 typedef struct {
2605   dk3_app_t		*app;		/**< Application structure. */
2606   dkChar const * const	*msg;		/**< Localized message texts. */
2607   dk3_sto_t		*sPrinters;	/**< Printers storage. */
2608   dk3_sto_it_t		*iPrinters;	/**< Iterator through printers. */
2609   dk3_sto_t		*sPrintAliases;	/**< Printer aliases storage. */
2610   dk3_sto_it_t		*iPrintAliases;	/**< Iterator through print aliases. */
2611   dk3_sto_t		*sPrintHosts;	/**< Print hosts storage. */
2612   dk3_sto_it_t		*iPrintHosts;	/**< Iterator through hosts. */
2613   dk3_sto_t		*sHostAliases;	/**< Print host aliases storage. */
2614   dk3_sto_it_t		*iHostAliases;	/**< Iterator through host aliases. */
2615   dk3_printer_t		*defPrinter;	/**< Default printer. */
2616   dk3_print_host_t	*defHost;	/**< Default host. */
2617   int			 defPsl;	/**< Default PS level. */
2618 } dk3_print_conf_t;
2619 
2620 
2621 
2622 #if DK3_HAVE_VOLATILE
2623 /**	The volatile keyword can be used.
2624 */
2625 #define	DK3_VOLATILE	volatile
2626 #else
2627 /**	The volatile keyword can not be used.
2628 */
2629 #define	DK3_VOLATILE	/* NIX */
2630 #endif
2631 
2632 typedef
2633 #if DK3_HAVE_SIG_ATOMIC_T
2634 /**	Atomic type for signal handlers.
2635 */
2636 sig_atomic_t
2637 #else
2638 /**	Atomic type or int for signal handlers.
2639 */
2640 int
2641 #endif
2642 dk3_sig_atomic_t;
2643 
2644 /**	Pointer to dkChar.
2645 */
2646 typedef dkChar		*DK3_PDKCHAR;
2647 
2648 /**	Pointer to const dkChar.
2649 */
2650 typedef	dkChar const	*DK3_PCDKCHAR;
2651 
2652 /**	Pointer to unsigned char.
2653 */
2654 typedef	unsigned char	*DK3_PUCHAR;
2655 
2656 /**	Pointer to char.
2657 */
2658 typedef char		*DK3_PCHAR;
2659 
2660 /**	Pointer to char const.
2661 */
2662 typedef char const	*DK3_PCCHAR;
2663 
2664 /**	Return type for signal handlers.
2665 */
2666 typedef	void		dk3_signal_ret_t;
2667 
2668 /**	Signal handler function prototype.
2669 */
2670 typedef
2671 dk3_signal_ret_t
2672 dk3_signal_fct_t(int)
2673 /*^modifies internalState^*/
2674 ;
2675 
2676 /**	Signal disposition (handler function address).
2677 */
2678 typedef	dk3_signal_fct_t	*dk3_signal_disp_t;
2679 
2680 /**	Handler function for one character.
2681 	@param	obj	Object to modify using the line.
2682 	@param	ch	Character to process.
2683 	@return	1=OK, 0=error, can continue, -1=error, abort processing.
2684 */
2685 typedef
2686 int
2687 dk3_char_handler_t(
2688   void		*obj,
2689   dk3_c32_t	 ch
2690 );
2691 
2692 /**	Function to traverse a simple database.
2693 	@param	obj	Object to modify while traversing the database.
2694 	@param	key	Key data.
2695 	@param	val	Value data.
2696 	@return	1 on success, 0 on error (can continue), -1 on error (abort).
2697 */
2698 typedef
2699 int
2700 dk3_db_traverse_fct_t(
2701   void		*obj,
2702   dk3_datum_t	*key,
2703   dk3_datum_t	*val
2704 )
2705 /*^modifies *obj,*key,*val^*/
2706 ;
2707 
2708 /**	Position in a text stream.
2709 */
2710 typedef struct {
2711   dk3_um_t	bytes;	/**< Number of bytes successfully proceeded. */
2712   dk3_um_t	chars;	/**< Number of current character. */
2713   dk3_um_t	lineno;	/**< Current line number. */
2714   dk3_um_t	charil;	/**< Current character position in line. */
2715 } dk3_text_stream_position_t;
2716 
2717 #endif
2718 
2719