1 /*
2 Copyright (C) 2013-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: htmlbook.ctr
12 */
13 
14 /**	@file htmlbook.h Header file for the htmlbook module.
15 */
16 
17 #ifndef HTMLBOOK_H_INCLUDED
18 /** Avoid multiple inclusions. */
19 #define HTMLBOOK_H_INCLUDED 1
20 
21 
22 #include "dk3conf.h"
23 #include <libdk3c/dk3types.h>
24 #include <libdk3c/dk3numco.h>
25 
26 
27 
28 /**	HTML standard to use.
29 */
30 enum {
31 	HTML_DOCTYPE_UNSPECIFIED = -1 ,	/**< No information about doctype. */
32 	HTML_DOCTYPE_NONE ,		/**< No HTML doctype. */
33 	HTML_DOCTYPE_5 ,		/**< HTML 5. */
34 	HTML_DOCTYPE_401_STRICT ,	/**< HTML 4.01 strict. */
35 	HTML_DOCTYPE_401_TRANSITIONAL ,	/**< HTML 4.01 transitional. */
36 	HTML_DOCTYPE_401_FRAMESET ,	/**< HTML 4.01 with framesets. */
37 	HTML_DOCTYPE_X10_STRICT ,	/**< XHTML 1.0 strict. */
38 	HTML_DOCTYPE_X10_TRANSITIONAL ,	/**< XHTML 1.0 transitional. */
39 	HTML_DOCTYPE_X10_FRAMESET ,	/**< XHTML 1.0 frameset. */
40 	HTML_DOCTYPE_X11		/**< XHTML 1.1. */
41 };
42 
43 
44 
45 /**	Image dimension cache entry.
46 */
47 typedef struct {
48   dkChar		*fn;	/**< Image name. */
49   unsigned long		 w;	/**< Image width. */
50   unsigned long		 h;	/**< Image height. */
51 } hb_img_dim_t;
52 
53 
54 
55 /**	External link.
56 */
57 typedef struct {
58   dkChar		*url;	/**< Link URL. */
59   unsigned long		 lno;	/**< Link number within current page. */
60   int			 flags;	/**< Flags for link. */
61 } hb_link_t;
62 
63 
64 
65 /**	Flags for link, used for the flags field in the hb_link_t type.
66 */
67 enum {
68 	/**	Script fle needs async flag.
69 	*/
70 	LINK_FLAG_SCRIPT_ASYNC	=	0x0001
71 };
72 
73 /**	One contents line.
74 */
75 typedef struct {
76   dkChar	*text;		/**< Allocated line text. */
77   dkChar	*aname;		/**< The a name text (if any). */
78   dkChar	*realtext;	/**< Real start of text for header. */
79   unsigned long	 lineno;	/**< Line number. */
80   unsigned long	 header;	/**< Running number of header. */
81   unsigned	 headlevel;	/**< Header level (1 to 6). */
82   int		 lt;		/**< Line type (0=normal, 1=header). */
83 } hb_line_t;
84 
85 
86 
87 /**	One node in the document tree.
88 */
89 struct hb__node_t {
90   struct hb__node_t	*parent;	/**< Parent node. */
91   struct hb__node_t	*curchild;	/**< Current child to edit. */
92   struct hb__node_t	*jumpnode;	/**< Link target node. */
93   dk3_sto_t		*s_subnodes;	/**< Subnodes collection. */
94   dk3_sto_it_t		*i_subnodes;	/**< Subnodes iterator. */
95   dk3_sto_t		*s_variables;	/**< Variables storage. */
96   dk3_sto_it_t		*i_variables;	/**< Variables iterator. */
97   dk3_sto_t		*s_lines;	/**< Contents lines storage. */
98   dk3_sto_it_t		*i_lines;	/**< Contents lines iterator. */
99   dk3_sto_t		*s_lbyurl;	/**< Storage for links by URL. */
100   dk3_sto_it_t		*i_lbyurl;	/**< Iterator for links by URL. */
101   dk3_sto_t		*s_lbylno;	/**< Storage for links by number. */
102   dk3_sto_it_t		*i_lbylno;	/**< Iterator for links by number. */
103   dk3_sto_t		*s_jsfiles;	/**< Storage for JS files. */
104   dk3_sto_it_t		*i_jsfiles;	/**< Iterator for JS files. */
105   dkChar		*title;		/**< Node title. */
106   dkChar		*shorttitle;	/**< Short title (optional). */
107   dkChar		*fulltitle;	/**< Full title (browser title bar). */
108   dkChar		*filename;	/**< Text file name (optional). */
109   dkChar		*suffix;	/**< Output file name suffix (opt). */
110   dkChar		*templatefi;	/**< Template file name (optional). */
111   dkChar		*stylefile;	/**< Style file. */
112   dkChar		*author;	/**< Name of author. */
113   dkChar		*location;	/**< Location (city) of author. */
114   dkChar		*icontoc;	/**< File name TOC icon. */
115   dkChar		*iconprev;	/**< File name previous section icon. */
116   dkChar		*iconnext;	/**< File name next section icon. */
117   dkChar		*iconindex;	/**< File name index icon. */
118   dkChar		*iconhome;	/**< File name home icon. */
119   dkChar		*favicon;	/**< favicon. */
120   dkChar		*metadesc;	/**< Meta description tag. */
121   dkChar		*metakeyw;	/**< Meta keywords tag. */
122   dkChar const		*outFileName;	/**< Output file name. */
123   unsigned long		 lineno;	/**< Line number in project file. */
124   unsigned long		 objno;		/**< Object index. */
125   unsigned long		 pobjno;	/**< Printable object number. */
126   unsigned long		 nextlink;	/**< Next link number. */
127   unsigned long		 nextindex;	/**< Next index entry number. */
128   unsigned long		 headno;	/**< Head number. */
129   unsigned long		 nextsubheadno;	/**< Next head number for sub node. */
130   unsigned long		 nextjs;	/**< Number of next js file. */
131   long			 contnum;	/**< Context number. */
132   unsigned		 options;	/**< Options for node. */
133   int			 indent;	/**< Line indent (number o spaces). */
134   int			 depth;		/**< Depth. */
135   int			 tocstate;	/**< State when creating TOC. */
136   int			 inenc;		/**< Text file input encoding. */
137   int			 havenavimenu;	/**< Flag: Already have navi menu. */
138   int			 htdt;		/**< HTML doctype. */
139 };
140 
141 /**	One node in the document tree.
142 */
143 typedef struct hb__node_t hb_node_t;
144 
145 
146 
147 /**	Entry in keyword index.
148 */
149 typedef struct {
150   dkChar		*tx;	/**< Keyword index text. */
151   dkChar		*fn;	/**< File name. */
152   dkChar		*an;	/**< Anchor name (optional). */
153   unsigned long		 ul;	/**< Anchor number (if no name available). */
154   hb_node_t		*no;	/**< Node for file name (needed for title). */
155 } hb_index_entry_t;
156 
157 
158 
159 /**	Job type for the htmlbook program.
160 	The s_nodes storage contains a plain list of all nodes,
161 	this storage is used to release all nodes at the end of the program.
162 	The s_pnodes storage contains a plain list of all nodes to
163 	write output for.
164 	The tree structure is below the rootnode element.
165 */
166 typedef struct {
167   char			 elmbuf[8*sizeof(dk3_um_t)];	/**< Buffer. */
168   dk3_tm_t		 starttime;	/**< Start time. */
169   dk3_app_t		*app;		/**< Application structure. */
170   dkChar const * const	*msg;		/**< Localized messages. */
171   dkChar const * const	*kwnl;		/**< Keywords, not localized. */
172   dk3_option_set_t	*opt;		/**< Command line options. */
173   dk3_sto_t		*s_nodes;	/**< All nodes storage. */
174   dk3_sto_it_t		*i_nodes;	/**< All nodes storage iterator. */
175   dk3_sto_t		*s_pnodes;	/**< Leaf nodes storage. */
176   dk3_sto_it_t		*i_pnodes;	/**< Leaf nodes storage iterator. */
177   dk3_sto_t		*s_files;	/**< Additional files storage. */
178   dk3_sto_it_t		*i_files;	/**< Additional files iterator. */
179   dk3_sto_t		*s_index;	/**< Index entries storage. */
180   dk3_sto_it_t		*i_index;	/**< Index entries storage iterator. */
181   dk3_sto_t		*s_optsect;	/**< Optional sections storage. */
182   dk3_sto_it_t		*i_optsect;	/**< Optional sections iterator. */
183   dk3_sto_t		*s_imgdim;	/**< Image dimension cache storage. */
184   dk3_sto_it_t		*i_imgdim;	/**< Image dimension cache iterator. */
185   hb_node_t		*rootnode;	/**< Root node. */
186   hb_node_t		*currentnode;	/**< Current node to modify. */
187   hb_node_t		*impressumnode;	/**< Impressum node. */
188   hb_node_t		*privacynode;	/**< Privacy statement node. */
189   hb_node_t		*firstnode;	/**< First pnode. */
190   hb_node_t		*lastnode;	/**< Last pnode. */
191   dkChar const		*infilename;	/**< Input file name (project). */
192   dkChar const		*outputdir;	/**< Output directory (allocated). */
193   dkChar const		*outputscript;	/**< Name of script to produce. */
194   dkChar const		*url;		/**< URL to publish the results. */
195   dkChar const		*indexfile;	/**< Typically index html. */
196   dkChar const		*impressumlink;	/**< Link to impressum. */
197   dkChar const		*privacylink;	/**< Link to privacy statement. */
198   dkChar const		*chmlang;	/**< Language setting for CHM. */
199   dkChar const		*htmllang;	/**< Language setting for HTML. */
200   dkChar const		*ptocjsfile;	/**< Page TOC JS file (allocated). */
201   dkChar		*shipbuffer;	/**< Shipout buffer. */
202   dkChar		*iltemplate;	/**< Input line from template. */
203   dkChar		*ilfile;	/**< Input line from file. */
204   dkChar		*special;	/**< Buffer for current special. */
205   dk3_c32_t		*buffer32;	/**< Buffer for 32-bit characters. */
206   FILE			*of;		/**< Output file. */
207   unsigned long		 lineno;	/**< Line number. */
208   unsigned long		 nextobj;	/**< Next object number. */
209   unsigned long		 npobjs;	/**< Number of printable objects. */
210   unsigned long		 elmchr;	/**< External link marker. */
211   size_t		 bs;		/**< Buffer size. */
212   size_t		 spused;	/**< Number elements used in special. */
213   size_t		 shipused;	/**< Shipout buffer used. */
214   unsigned		 options;	/**< Job options. */
215   int			 iecmd;		/**< Input encoding from cmd args. */
216   int			 actsect;	/**< Flag: Active section. */
217   int			 cmd;		/**< Option processing result. */
218   int			 exv;		/**< Exit status code. */
219   int			 cs;		/**< Character set for HTML output. */
220   int			 secttype;	/**< Section type. */
221   int			 non_url;	/**< Flag: Non-URL characters found. */
222   int			 maxdepth;	/**< Maximum depth of a node. */
223   int			 headlevels;	/**< Maximum depth to print header. */
224   int			 coli;		/**< Current code line number. */
225   int			 cols;		/**< Code line state. */
226   int			 markel;	/**< Flag: Mark external links. */
227   int			 tabsum;	/**< Flag: Create table summaries. */
228   int			 svgwhdef;	/**< Flag: Default svgwh value. */
229   int			 htdt;		/**< HTML doctype. */
230   int			 ptocjsused;	/**< Flag: ptoc js file used. */
231 } hb_job_t;
232 
233 
234 
235 /**	File processing help structure.
236 */
237 typedef struct {
238   hb_job_t		*job;		/**< Job structure. */
239   hb_node_t		*p;		/**< Previous node. */
240   hb_node_t		*n;		/**< Next node. */
241   int			 in_template;	/**< Flag: Processing template. */
242   int			 stm;		/**< State machine. */
243 } hb_file_processor_t;
244 
245 
246 
247 /**	@defgroup	hboptions	Node options from project file. */
248 /**@{*/
249 
250 /**	Write page TOC.
251 */
252 #define	HB_NODE_OPT_PAGE_TOC			0x0001U
253 
254 /**	Replace ampersand.
255 */
256 #define	HB_NODE_OPT_REPLACE_AMPERSAND		0x0002U
257 
258 /**	Use tidy while copying.
259 */
260 #define	HB_NODE_OPT_USE_TIDY			0x0004U
261 
262 /**	Write header chain.
263 */
264 #define	HB_NODE_OPT_HEADER_CHAIN		0x0008U
265 
266 /**	Indicate the impressum node.
267 */
268 #define	HB_NODE_OPT_IMPRESSUM			0x0010U
269 
270 /**	Stop inheritance of JS files at this node.
271 */
272 #define	HB_NODE_OPT_STOP_JS_INHERITANCE		0x0020U
273 
274 /**	Indicate the privacy node.
275 */
276 #define	HB_NODE_OPT_PRIVACY			0x0040U
277 
278 /**@}*/
279 
280 
281 
282 /**	@defgroup	hbjoboptions	Job options. */
283 /**@{*/
284 
285 /**	Create index file.
286 */
287 #define	HB_JOB_OPT_CREATE_INDEX			0x0001U
288 
289 /**	Create table of contents.
290 */
291 #define	HB_JOB_OPT_CREATE_TOC			0x0002U
292 
293 /**	Currently processing code.
294 */
295 #define	HB_JOB_OPT_CODE				0x0004U
296 
297 /**	Produce output for building a chm file.
298 */
299 #define	HB_JOB_OPT_CHM				0x0008U
300 
301 /**	Use ln instead of cp for resource files.
302 */
303 #define	HB_JOB_OPT_LN				0x0010U
304 
305 /**	Write section number in positions table.
306 */
307 #define	HB_JOB_OPT_NUM_IN_POS			0x0020U
308 
309 /**	Write section number in keyword index.
310 */
311 #define	HB_JOB_OPT_NUM_IN_IDX			0x0040U
312 
313 /**	Write section number in page header.
314 */
315 #define	HB_JOB_OPT_NUM_IN_PAGE_HEADER		0x0080U
316 
317 /**	Enable full text search in chm output.
318 */
319 #define	HB_JOB_OPT_CHM_FULL_TEXT_SEARCH		0x0100U
320 
321 /**	Print line numbers for code.
322 */
323 #define	HB_JOB_OPT_CODE_LINE_NUMBERS		0x0200U
324 
325 /**	Fold and unfold page table of contents.
326 */
327 #define	HB_JOB_OPT_FOLD_PTOC			0x0400U
328 
329 /**@}*/
330 
331 
332 
333 /**	@defgroup	hbcharsets	Character sets used by htmlbook. */
334 /**@{*/
335 
336 /**	Character set us-ascii.
337 */
338 #define	HB_CS_ASCII				0
339 
340 /**	Character set UTF-8.
341 */
342 #define	HB_CS_UTF_8				1
343 
344 /**@}*/
345 
346 
347 
348 /**	@defgroup	hbsections	Section types. */
349 /**@{*/
350 
351 /**	Section type not yet known.
352 */
353 #define	HB_SECTION_UNKNOWN			0
354 
355 /**	Options section.
356 */
357 #define	HB_SECTION_OPTIONS			1
358 
359 /**	Files section.
360 */
361 #define	HB_SECTION_FILES			2
362 
363 /**	Contents section.
364 */
365 #define	HB_SECTION_CONTENTS			3
366 
367 /**@}*/
368 
369 
370 
371 /**	@defgroup	hbtocstate	Node state when creating TOC. */
372 /**@{*/
373 
374 /**	Work on this node is not yet in progress.
375 */
376 #define	HB_TOC_STATE_INIT			0
377 
378 /**	Work on this node is in progress.
379 */
380 #define	HB_TOC_STATE_IN_PROGRESS		1
381 
382 /**	Work on this node is finished.
383 */
384 #define	HB_TOC_STATE_FINISHED			2
385 
386 /**@}*/
387 
388 
389 
390 /**	@defgroup	hbcolist	Code line states. */
391 /**@{*/
392 
393 /**	Directly after code special command.
394 */
395 #define	HB_COLIST_NONE		0
396 
397 /**	In a new line, no contents yet thus no opened code tag.
398 */
399 #define	HB_COLIST_NOT_OPENED	1
400 
401 /**	Code tag was opened and must be closed.
402 */
403 #define	HB_COLIST_OPENED	2
404 
405 /**@}*/
406 
407 
408 
409 /**	Maximum line length.
410 */
411 #define	HB_LINE_LENGTH		16383
412 
413 
414 #include <htmlbook/hbnode.h>
415 #include <htmlbook/hbconf.h>
416 #include <htmlbook/hbhtml.h>
417 #include <htmlbook/hbtool.h>
418 #include <htmlbook/hbcont.h>
419 #include <htmlbook/hbindex.h>
420 #include <htmlbook/hbimgdim.h>
421 #include <htmlbook/hbchm.h>
422 #include <libdk3c/dk3strkv.h>
423 #include <libdk3c/dk3kv.h>
424 #include <libdk3c/dk3se.h>
425 
426 
427 
428 
429 #endif
430