1%%	options
2
3copyright owner	=	Dirk Krause
4copyright year	=	2012-xxxx
5SPDX-License-Identifier:	BSD-3-Clause
6
7
8
9%%	header
10
11#include <libdk3c/dk3all.h>
12#include <itadmin/dk3uc2l.h>
13
14
15/**	Computer owner/user.
16*/
17typedef struct {
18  char const		*us;	/**< Short name, login name (primary key). */
19  char const		*tt;	/**< Title, academic degree. */
20  char const		*sn;	/**< Surname. */
21  char const		*na;	/**< Family name. */
22  char const		*em;	/**< E-mail address. */
23  char const		*cc;	/**< ID in cost controlling. */
24  char const		*si;	/**< Staff ID number. */
25  dk3_sto_t		*s_ho;	/**< Hosts for user. */
26  dk3_sto_it_t		*i_ho;	/**< Iterator for hosts storage. */
27  dk3_sto_t		*s_li;	/**< Licenses assigned to user. */
28  dk3_sto_it_t		*i_li;	/**< Iterator for licenses storage. */
29} itadmin_user;
30
31
32
33/**	Building.
34*/
35typedef struct {
36  char const		*s;	/**< Short name (primary key). */
37  char const		*l;	/**< Full building name. */
38  char const		*a1;	/**< Address line 1. */
39  char const		*a2;	/**< Address line 2. */
40  char const		*a3;	/**< Address line 3. */
41  char const		*a4;	/**< Address line 4. */
42  char const		*zc;	/**< Zip code (german: Postleitzahl). */
43  char const		*city;	/**< City/Town name. */
44} itadmin_building;
45
46
47
48/**	Speed for network connection.
49*/
50typedef struct {
51  char const		*s;	/**< Short speed name (primary key). */
52  char const		*l;	/**< Long speed name (description). */
53} itadmin_speed;
54
55
56
57/**	VLAN.
58*/
59typedef struct {
60  char const		*s;	/**< Short VLAN name (primary key). */
61  char const		*l;	/**< Long VLAN name (description). */
62  dk3_sto_t		*s_nw;	/**< Storage for networks. */
63  dk3_sto_it_t		*i_nw;	/**< Iterator through networks storage. */
64  dk3_sto_t		*s_do;	/**< DHCP options for VLAN. */
65  dk3_sto_it_t		*i_do;	/**< Iterator through DHCP options. */
66} itadmin_vlan;
67
68
69
70/**	Network connection socket.
71*/
72typedef struct {
73  char const		*s;	/**< Short name (label on socket, pk). */
74  char const		*hp;	/**< Hub port used for socket. */
75  char const		*room;	/**< Room name or number in building. */
76  itadmin_speed		*sp;	/**< Speed setting for socket. */
77  itadmin_vlan		*vl;	/**< VLAN for socket. */
78  itadmin_building	*bu;	/**< Building. */
79} itadmin_connect;
80
81
82
83/**	Network.
84*/
85typedef struct {
86  itadmin_vlan		*vl;	/**< Parent VLAN. */
87  dk3_sto_t		*s_p;	/**< Storage for DHCP pools. */
88  dk3_sto_it_t		*i_p;	/**< Iterator through pools storage. */
89  dk3_sto_t		*s_dg;	/**< Storage for DHCP groups in network. */
90  dk3_sto_it_t		*i_dg;	/**< Iterator through groups in nw storage. */
91  dk3_sto_t		*s_do;	/**< DHCP options. */
92  dk3_sto_it_t		*i_do;	/**< Iterator for DHCP options. */
93  dk3_sto_t		*s_hoi;	/**< Storage for hosts. */
94  dk3_sto_it_t		*i_hoi;	/**< Iterator for hosts storage. */
95  dk3_sto_t		*s_dc;	/**< DHCP classes for this network. */
96  dk3_sto_it_t		*i_dc;	/**< Iterator through DHCP classes storage. */
97  unsigned long	 	 ip4;	/**< IPv4 start address (primary key). */
98  unsigned long	 	 ma4;	/**< IPv4 network mask. */
99  unsigned long	 	 gw4;	/**< IPv4 gateway. */
100  unsigned long	 	 bc4;	/**< IPv4 broadcast address. */
101} itadmin_network;
102
103
104
105/**	Netgroup.
106*/
107typedef struct {
108  char const		*sn;	/**< Short name (primary key). */
109  char const		*ln;	/**< Long name (description). */
110  size_t		 no;	/**< Netgroup number. */
111} itadmin_netgroup;
112
113
114
115/**	Netgroup dependency.
116*/
117typedef struct {
118  itadmin_netgroup	*pa;	/**< Parent group. */
119  itadmin_netgroup	*ch;	/**< Child group. */
120} itadmin_ngdep;
121
122
123
124/**	DHCP class.
125*/
126typedef struct {
127  char const		*sn;	/**< Short name (primary key). */
128  char const		*ln;	/**< Long name (description). */
129  dk3_sto_t		*s_ho;	/**< Hosts in this class. */
130  dk3_sto_it_t		*i_ho;	/**< Iterator through hosts storage. */
131  itadmin_network	*dhcpn;	/**< Network for DHCP hosts. */
132} itadmin_dhcp_class;
133
134
135
136/**	DHCP address pool.
137*/
138typedef struct {
139  itadmin_network	*nw;	/**< Network. */
140  itadmin_dhcp_class	*acl;	/**< Allowed DHCP class. */
141  dk3_sto_t		*s_do;	/**< DHCP options for pool. */
142  dk3_sto_it_t		*i_do;	/**< Iterator for DHCP options. */
143  dk3_sto_t		*s_hoi;	/**< Hosts storage. */
144  dk3_sto_it_t		*i_hoi;	/**< Hosts storage iterator. */
145  unsigned long		 ip4s;	/**< IPv4 start address. */
146  unsigned long		 ip4e;	/**< IPv4 end address. */
147  char			 duc;	/**< Flag: Deny unknown clients. */
148  char			 auc;	/**< Flag: Allow unknown clients. */
149} itadmin_dhcp_pool;
150
151
152
153/**	DHCP group.
154*/
155typedef struct {
156  char const		*sn;	/**< Short group name (primary key). */
157  char const		*ln;	/**< Long name (description). */
158  dk3_sto_t		*s_do;	/**< DHCP options storage. */
159  dk3_sto_it_t		*i_do;	/**< DHCP options iterator. */
160} itadmin_dhcp_group;
161
162
163
164/**	DHCP group within a network.
165*/
166typedef struct {
167  itadmin_dhcp_group	*gr;	/**< Group. */
168  dk3_sto_t		*s_h;	/**< Storage for hosts in this group. */
169  dk3_sto_it_t		*i_h;	/**< Iterator for storage. */
170} itadmin_dhcp_ginw;
171
172
173
174/**	Date (used for host expiration).
175*/
176typedef struct {
177  int	y;			/**< Year. */
178  int	m;			/**< Month. */
179  int	d;			/**< Day in month. */
180} itadmin_date;
181
182
183
184/**	Host.
185*/
186typedef struct {
187  itadmin_date		 expi;	/**< Expiration date. */
188  char const		*sn;	/**< Short host name (primary key). */
189  char const		*co;	/**< Comment, description. */
190  char const		*maca;	/**< MAC address. */
191  char const		*room;	/**< Room within the building. */
192  char const		*inv;	/**< Inventory ID. */
193  char const		*serno;	/**< Serial number. */
194  char const		*hid;	/**< Host ID. */
195  char const		*dnsd;	/**< DNS domain. */
196  itadmin_user		*un;	/**< System owner. */
197  itadmin_netgroup	*ng;	/**< Netgroup. */
198  itadmin_dhcp_class	*dc;	/**< DHCP class. */
199  itadmin_dhcp_group	*dg;	/**< DHCP group. */
200  itadmin_dhcp_pool	*dp;	/**< DHCP pool. */
201  itadmin_connect	*nc;	/**< Network connection socket. */
202  itadmin_building	*bu;	/**< Building. */
203  dk3_sto_t		*s_al;	/**< Storage for aliases. */
204  dk3_sto_it_t		*i_al;	/**< Iterator through aliases storage. */
205  dk3_sto_t		*s_do;	/**< DHCP options for host. */
206  dk3_sto_it_t		*i_do;	/**< DHCP options iterator. */
207  dk3_sto_t		*s_li;	/**< Licenses assigned to host. */
208  dk3_sto_it_t		*i_li;	/**< Iterator through licenses storage. */
209  unsigned long		 ipv4;	/**< IPv4 address. */
210  char			 fnf;	/**< Flag: Full name first in hosts. */
211  char			 fgu;	/**< Flag: Guest computer. */
212  char			 snd;	/**< Flag: Skip in network documentation. */
213  char			 saw;	/**< Flag: Skip in arpwatch configuration. */
214} itadmin_host;
215
216
217
218/**	Software manufacturer.
219*/
220typedef struct {
221  char const		*sn;	/**< Short name (primary key). */
222  char const		*ln;	/**< Full name. */
223} itadmin_swman;
224
225
226
227/**	Software product.
228*/
229typedef struct {
230  char const		*sn;	/**< Short name (primary key). */
231  char const		*ln;	/**< Full name. */
232  itadmin_swman		*mn;	/**< Software manufacturer. */
233} itadmin_swprod;
234
235
236
237/**	License type.
238*/
239typedef struct {
240  char const		*sn;	/**< Short name (primary key). */
241  char const		*ln;	/**< Full name. */
242  int			 num;	/**< Number of client licenses. */
243} itadmin_lictype;
244
245
246
247/**	Software license.
248*/
249typedef struct {
250  itadmin_date		 d_del;	/**< Delivery date. */
251  itadmin_date		 d_inv; /**< Invoice date. */
252  char const		*order;	/**< Internal order ID. */
253  char const		*notes;	/**< Additional notes about the license. */
254  char const		*i_del;	/**< Delivery note ID. */
255  char const		*i_inv;	/**< Invoice ID. */
256  itadmin_swprod	*prod;	/**< Software product. */
257  itadmin_lictype	*ltype;	/**< License type. */
258  itadmin_user		*owner;	/**< License owner. */
259  itadmin_host		*host;	/**< Host where license is used. */
260  unsigned long		 pk;	/**< Primary key from database. */
261} itadmin_license;
262
263
264
265/**	DHCP option.
266*/
267typedef struct {
268  char const		*k;	/**< Key (option name). */
269  char const		*v;	/**< Option value. */
270  long			 pk;	/**< Primary key from database. */
271} itadmin_dhcp_option;
272
273
274
275/**	Job structure for the itadmin program.
276*/
277typedef struct {
278  itadmin_date		 today;	/**< Current date. */
279  dk3_app_t		*app;	/**< Application structure. */
280  dk3_option_set_t	*opt;	/**< Option set. */
281  dk3_sto_t		*s_us;	/**< User storage. */
282  dk3_sto_it_t		*i_us;	/**< User storage iterator. */
283  dk3_sto_t		*s_usn;	/**< User sorted by name. */
284  dk3_sto_it_t		*i_usn;	/**< Storage iterator for users by name. */
285  dk3_sto_t		*s_bu;	/**< Building storage. */
286  dk3_sto_it_t		*i_bu;	/**< Building storage iterator. */
287  dk3_sto_t		*s_sp;	/**< Patch speed storage. */
288  dk3_sto_it_t		*i_sp;	/**< Patch speed storage iterator. */
289  dk3_sto_t		*s_vl;	/**< VLAN storage. */
290  dk3_sto_it_t		*i_vl;	/**< VLAN storage iterator. */
291  dk3_sto_t		*s_pa;	/**< Network patch storage. */
292  dk3_sto_it_t		*i_pa;	/**< Network patch storage iterator. */
293  dk3_sto_t		*s_nw;	/**< Network storage. */
294  dk3_sto_it_t		*i_nw;	/**< Network storage iterator. */
295  dk3_sto_t		*s_ng;	/**< Netgroup storage. */
296  dk3_sto_it_t		*i_ng;	/**< Netgroup storage iterator. */
297  dk3_sto_t		*s_nd;	/**< Netgroup dependency storage. */
298  dk3_sto_it_t		*i_nd;	/**< Netgroup dependency storage iterator. */
299  dk3_sto_t		*s_dc;	/**< DHCP class storage. */
300  dk3_sto_it_t		*i_dc;	/**< DHCP class storage iterator. */
301  dk3_sto_t		*s_dp;	/**< DHCP pool storage. */
302  dk3_sto_it_t		*i_dp;	/**< DHCP pool storage iterator. */
303  dk3_sto_t		*s_dg;	/**< DHCP group storage. */
304  dk3_sto_it_t		*i_dg;	/**< DHCP group storage iterator. */
305  dk3_sto_t		*s_ho;	/**< Host storage, sorted by name. */
306  dk3_sto_it_t		*i_ho;	/**< Host storage iterator for s_ho. */
307  dk3_sto_t		*s_hoi;	/**< Host storage, sorted by IP address. */
308  dk3_sto_it_t		*i_hoi;	/**< Host storage iterator for s_hoi. */
309  dk3_sto_t		*s_sm;	/**< Software manufacturer storage. */
310  dk3_sto_it_t		*i_sm;	/**< Software manufacturer storage iterator. */
311  dk3_sto_t		*s_sw;	/**< Software storage. */
312  dk3_sto_it_t		*i_sw;	/**< Software storage iterator. */
313  dk3_sto_t		*s_lt;	/**< License type storage. */
314  dk3_sto_it_t		*i_lt;	/**< License type storage iterator. */
315  dk3_sto_t		*s_lc;	/**< Licenses storage. */
316  dk3_sto_it_t		*i_lc;	/**< Licenses storage iterator. */
317  dk3_sto_t		*s_lf;	/**< Free licenses. */
318  dk3_sto_it_t		*i_lf;	/**< Free licenses iterator. */
319  dk3_sto_t		*s_do;	/**< DHCP options for entire server. */
320  dk3_sto_it_t		*i_do;	/**< Iterator for DHCP options. */
321  void			*dbptr;	/**< Database object pointer. */
322  dk3_bm_t		*ngdep;	/**< Direct/indirect netgroup dependencies. */
323  dk3_uc2lat_t		*uc2l;	/**< Unicode to LaTeX converter. */
324  dkChar const * const	*msg;	/**< Localized message texts. */
325  dkChar const * const	*noloc;	/**< Texts, not localized. */
326  dkChar const		*dbhn;	/**< Database host name. */
327  dkChar const		*dbn;	/**< Database name. */
328  dkChar const		*dbcf;	/**< Database credentials files. */
329  dkChar const		*dbus;	/**< Database user name. */
330  dkChar const		*dbpw;	/**< Database password. */
331  dkChar const		*vlan;	/**< VLAN name. */
332  dkChar const		*org;	/**< Organization name. */
333  dkChar const		*ou;	/**< Organizational unit name. */
334  dkChar const		*admn;	/**< Administrator name. */
335  dkChar const		*ldapb;	/**< LDAP base. */
336  size_t		 nng;	/**< Number of netgroups. */
337  int			 exval;	/**< Exit status code. */
338  int			 ec;	/**< Error code, see @ref errorcodes. */
339  int			 cmd;	/**< Command to execute. */
340  int			 f_dh;	/**< Flag: Write dhcpd.conf file. */
341  int			 dbt;	/**< Database type. */
342  int			 gdate;	/**< Flag: German date notation. */
343  int			 hlh;	/**< Flag: Have localhost entry. */
344  int			 ukoma;	/**< Flag: Use koma-script. */
345  int			 rel;	/**< Release lease on shutdown. */
346  int			 m_p;	/**< Flag: Markers for points. */
347  int			 m_vl;	/**< Flag: Markers for vlan. */
348  int			 m_sn;	/**< Flag: Markers for subnets. */
349  int			 m_gr;	/**< Flag: Markers for groups. */
350  int			 m_po;	/**< Flag: Markers for pools. */
351  int			 m_ho;	/**< Flag: Markers for hosts. */
352} itadmin_job;
353
354
355
356/**	Reader structure for credentials file.
357*/
358typedef struct {
359  itadmin_job		*job;		/**< Job structure. */
360  int			 f_clnt;	/**< Flag: In client section. */
361} itadmin_cred_reader;
362
363
364/**	@defgroup	itadmincommand	Command IDs for itadmin. */
365/**@{*/
366/**	itadmin command: Rebuild configuration and network documentation.
367*/
368#define	ITADMIN_CMD_CONFIG		1
369
370/**	itadmin command: Rebuild license report.
371*/
372#define	ITADMIN_CMD_LICENSES		2
373
374/**	itadmin command: show help text.
375*/
376#define	ITADMIN_CMD_HELP		4
377
378/**	itadmin command: show version information.
379*/
380#define	ITADMIN_CMD_VERSION		8
381
382/**	itadmin command: show license terms.
383*/
384#define	ITADMIN_CMD_LICENSE_TERMS	16
385/**@}*/
386
387
388
389/**	Maximum size for configuration file lines.
390*/
391#define	ITADMIN_CONFIG_LINE_SIZE	256
392
393/**	Function to remove one object.
394*/
395typedef void itadmin_obj_del(void *);
396
397#ifdef __cplusplus
398extern "C" {
399#endif
400
401/**	Read configuration file(s).
402	@param	job	Job structure.
403	@return	1 on success, 0 on error.
404*/
405int
406itadmin_config_read(itadmin_job *job);
407
408/**	Delete one user.
409	@param	v	Object to delete.
410*/
411void
412itadmin_mem_user_del(void *v);
413
414/**	Delete one building.
415	@param	v	Object to delete.
416*/
417void
418itadmin_mem_building_del(void *v);
419
420/**	Delete one speed setting.
421	@param	v	Object to delete.
422*/
423void
424itadmin_mem_speed_del(void *v);
425
426/**	Delete one VLAN.
427	@param	v	Object to delete.
428*/
429void
430itadmin_mem_vlan_del(void *v);
431
432/**	Delete one network connection patch.
433	@param	v	Object to delete.
434*/
435void
436itadmin_mem_connect_del(void *v);
437
438/**	Delete one network.
439	@param	v	Object to delete.
440*/
441void
442itadmin_mem_network_del(void *v);
443
444/**	Delete one netgroup.
445	@param	v	Object to delete.
446*/
447void
448itadmin_mem_netgroup_del(void *v);
449
450/**	Delete one netgroup dependency.
451	@param	v	Object to delete.
452*/
453void
454itadmin_mem_ngdep_del(void *v);
455
456/**	Delete one DHCP class.
457	@param	v	Object to delete.
458*/
459void
460itadmin_mem_dhcp_class_del(void *v);
461
462/**	Delete one DHCP pool.
463	@param	v	Object to delete.
464*/
465void
466itadmin_mem_dhcp_pool_del(void *v);
467
468/**	Delete one DHCP group.
469	@param	v	Object to delete.
470*/
471void
472itadmin_mem_dhcp_group_del(void *v);
473
474/**	Delete one host.
475	@param	v	Object to delete.
476*/
477void
478itadmin_mem_host_del(void *v);
479
480/**	Delete one software manufacturer.
481	@param	v	Object to delete.
482*/
483void
484itadmin_mem_sw_man_del(void *v);
485
486/**	Delete one software product.
487	@param	v	Object to delete.
488*/
489void
490itadmin_mem_software_del(void *v);
491
492/**	Delete one license type.
493	@param	v	Object to delete.
494*/
495void
496itadmin_mem_lic_type_del(void *v);
497
498/**	Delete one license.
499	@param	v	Object to delete.
500*/
501void
502itadmin_mem_license_del(void *v);
503
504/**	Create new user.
505	@param	job	Job structure.
506	@param	un	Name.
507	@param	tt	Academic degree or title (may be NULL).
508	@param	sn	Surname (may be NULL).
509	@param	na	Name.
510	@param	em	E-Mail (may be NULL).
511	@param	cc	Cost control ID (may be NULL).
512	@param	si	Staff ID number (may be NULL).
513	@return	Pointer to new object on success, NULL on error.
514*/
515itadmin_user *
516itadmin_mem_user_new(
517  itadmin_job	*job,
518  char const	*un,
519  char const	*tt,
520  char const	*sn,
521  char const	*na,
522  char const	*em,
523  char const	*cc,
524  char const	*si
525);
526
527/**	Create new building.
528	@param	job	Job structure.
529	@param	s	Name.
530	@param	l	Long name (may be NULL).
531	@param	a1	Address line 1 (typically street and number,
532			may be NULL).
533	@param	a2	Address line 2 (may be NULL).
534	@param	a3	Address line 3 (may be NULL).
535	@param	a4	Address line 4 (may be NULL).
536	@param	zc	Zip code (may be NULL).
537	@param	city	Town or city name (may be NULL).
538	@return	Pointer to new object on success, NULL on error.
539*/
540itadmin_building *
541itadmin_mem_building_new(
542  itadmin_job	*job,
543  char const	*s,
544  char const	*l,
545  char const	*a1,
546  char const	*a2,
547  char const	*a3,
548  char const	*a4,
549  char const	*zc,
550  char const	*city
551);
552
553/**	Create new speed setting.
554	@param	job	Job structure.
555	@param	s	Name.
556	@param	n	Description (may be NULL).
557	@return	Pointer to new object on success, NULL on error.
558*/
559itadmin_speed *
560itadmin_mem_speed_new(
561  itadmin_job	*job,
562  char const	*s,
563  char const	*n
564);
565
566/**	Create new VLAN.
567	@param	job	Job structure.
568	@param	s	Name.
569	@param	l	Long name (may be NULL).
570	@return	Pointer to new object on success, NULL on error.
571*/
572itadmin_vlan *
573itadmin_mem_vlan_new(
574  itadmin_job	*job,
575  char const	*s,
576  char const	*l
577);
578
579/**	Create new network connector.
580	@param	job	Job structure.
581	@param	s	Name.
582	@param	hp	Building.
583	@param	room	Room.
584	@param	sp	Speed setting.
585	@param	vl	VLAN.
586	@param	bu	Building.
587	@return	Pointer to new object on success, NULL on error.
588*/
589itadmin_connect *
590itadmin_mem_connect_new(
591  itadmin_job		*job,
592  char const		*s,
593  char const		*hp,
594  char const		*room,
595  itadmin_speed		*sp,
596  itadmin_vlan		*vl,
597  itadmin_building	*bu
598);
599
600/**	Create new network.
601	@param	job	Job structure.
602	@param	ip4	Network address.
603	@param	ma4	Network mask.
604	@param	gw4	Gateway.
605	@param	bc4	Broadcast address.
606	@param	vl	VLAN.
607	@return	Pointer to new object on success, NULL on error.
608*/
609itadmin_network *
610itadmin_mem_network_new(
611  itadmin_job	*job,
612  unsigned long	 ip4,
613  unsigned long	 ma4,
614  unsigned long	 gw4,
615  unsigned long	 bc4,
616  itadmin_vlan	*vl
617);
618
619/**	Create new netgroup.
620	@param	job	Job structure.
621	@param	sn	Short name.
622	@param	ln	Long name (may be NULL).
623	@return	Pointer to new object on success, NULL on error.
624*/
625itadmin_netgroup *
626itadmin_mem_netgroup_new(
627  itadmin_job	*job,
628  char const	*sn,
629  char const	*ln
630);
631
632/**	Create new netgroup dependency.
633	@param	job	Job structure.
634	@param	pa	Parent group.
635	@param	ch	Child group.
636	@return	Pointer to new object on success, NULL on error.
637*/
638itadmin_ngdep *
639itadmin_mem_ngdep_new(
640  itadmin_job		*job,
641  itadmin_netgroup	*pa,
642  itadmin_netgroup	*ch
643);
644
645/**	Create new DHCP class.
646	@param	job	Job structure.
647	@param	sn	Short name.
648	@param	ln	Long name (may be NULL).
649	@return	Pointer to new object on success, NULL on error.
650*/
651itadmin_dhcp_class *
652itadmin_mem_dhcp_class_new(
653  itadmin_job	*job,
654  char const	*sn,
655  char const	*ln
656);
657
658/**	Create new DHCP pool.
659	@param	job	Job structure.
660	@param	nw	Network.
661	@param	cn	Allowed class (if unknown clients are denied,
662			may be NULL).
663	@param	ip4s	IPv4 start address.
664	@param	ip4e	IPv4 end address.
665	@param	duc	Flag: Deny unknown clients (needs cn).
666	@param	auc	Flag: Allow unknown clients.
667	@return	Pointer to new object on success, NULL on error.
668*/
669itadmin_dhcp_pool *
670itadmin_mem_dhcp_pool_new(
671  itadmin_job		*job,
672  itadmin_network	*nw,
673  itadmin_dhcp_class	*cn,
674  unsigned long		 ip4s,
675  unsigned long		 ip4e,
676  int			 duc,
677  int			 auc
678);
679
680/**	Create new DHCP group.
681	@param	job	Job structure.
682	@param	sn	Short name.
683	@param	ln	Long name (may be NULL).
684	@return	Pointer to new object on success, NULL on error.
685*/
686itadmin_dhcp_group *
687itadmin_mem_dhcp_group_new(
688  itadmin_job	*job,
689  char const	*sn,
690  char const	*ln
691);
692
693/**	Create new host
694	@param	job	Job structure.
695	@param	sn	Short name.
696	@param	co	Comment/description (may be NULL).
697	@param	maca	MAC address (may be NULL).
698	@param	room	Room (may be NULL).
699	@param	inv	Inventory number (may be NULL).
700	@param	serno	Serial number (may be NULL).
701	@param	hid	Host ID (may be NULL).
702	@param	expi	Expiration date (may be NULL).
703	@param	dnsd	DNS domain (may be NULL).
704	@param	un	System owner.
705	@param	ng	Netgroup (may be NULL).
706	@param	dc	DHCP class (may be NULL).
707	@param	dg	DHCP group (may be NULL).
708	@param	nc	Network connection socket (may be NULL).
709	@param	bu	Building (may be NULL).
710	@param	ipv4	IPv4 address (may be NULL).
711	@param	fnf	Flag: FQDN first in hosts file.
712	@param	fgu	Flag: Guest computer (bring your own device).
713	@param	snd	Flag: Skip in network documentation.
714	@param	saw	Flag: Skip in arpwatch configuration.
715	@return	Pointer to new object on success, NULL on error.
716*/
717itadmin_host *
718itadmin_mem_host_new(
719  itadmin_job		*job,
720  itadmin_date		*expi,
721  char const		*sn,
722  char const		*co,
723  char const		*maca,
724  char const		*room,
725  char const		*inv,
726  char const		*serno,
727  char const		*hid,
728  char const		*dnsd,
729  itadmin_user		*un,
730  itadmin_netgroup	*ng,
731  itadmin_dhcp_class	*dc,
732  itadmin_dhcp_group	*dg,
733  itadmin_connect	*nc,
734  itadmin_building	*bu,
735  unsigned long		 ipv4,
736  int			 fnf,
737  int			 fgu,
738  int			 snd,
739  int			 saw
740);
741
742/**	Create new software manufacturer.
743	@param	job	Job structure.
744	@param	sn	Short name.
745	@param	ln	Long name (description).
746	@return	Pointer to new object on success, NULL on error.
747*/
748itadmin_swman *
749itadmin_mem_sw_man_new(
750  itadmin_job	*job,
751  char const	*sn,
752  char const	*ln
753);
754
755/**	Create new software product.
756	@param	job	Job structure.
757	@param	sn	Short name.
758	@param	ln	Long name.
759	@param	mn	Software manufacturer name (may be NULL).
760	@return	Pointer to new object on success, NULL on error.
761*/
762itadmin_swprod *
763itadmin_mem_swprod_new(
764  itadmin_job	*job,
765  char const	*sn,
766  char const	*ln,
767  itadmin_swman	*mn
768);
769
770/**	Create new license type.
771	@param	job	Job structure.
772	@param	sn	Short license type name.
773	@param	ln	Long name (description).
774	@param	num	Number of client licenses for floating license servers.
775	@return	Pointer to new object on success, NULL on error.
776*/
777itadmin_lictype *
778itadmin_mem_lictype_new(
779  itadmin_job	*job,
780  char const	*sn,
781  char const	*ln,
782  int		 num
783);
784
785/**	Create new license.
786	@param	job	Job structure.
787	@param	pk	Primary key from licenses table (unused).
788	@param	order	Order ID or tracking information (may be NULL).
789	@param	notes	Additional notes (may be NULL).
790	@param	i_del	Delivery note ID (may be NULL).
791	@param	i_inv	Invoice ID (may be NULL).
792	@param	prod	Software product.
793	@param	ltype	License type.
794	@param	owner	License owner (may be NULL).
795	@param	host	Computer (may be NULL).
796	@return	Pointer to new object on success, NULL on error.
797*/
798itadmin_license *
799itadmin_mem_license_new(
800  itadmin_job		*job,
801  unsigned long		 pk,
802  char const		*order,
803  char const		*notes,
804  char const		*i_del,
805  char const		*i_inv,
806  itadmin_swprod	*prod,
807  itadmin_lictype	*ltype,
808  itadmin_user		*owner,
809  itadmin_host		*host
810);
811
812/**	Create new DHCP group in network.
813	@param	job	Job structure.
814	@param	gr	DHCP group structure.
815	@return	Pointer to new object on success, NULL on error.
816*/
817itadmin_dhcp_ginw *
818itadmin_mem_dhcp_ginw_new(itadmin_job *job, itadmin_dhcp_group *gr);
819
820/**	Destroy DHCP group in network structure, release memory.
821	@param	g	Group structure to destroy.
822*/
823void
824itadmin_mem_dhcp_ginw_del(itadmin_dhcp_ginw *g);
825
826/**	Initialize date structure.
827	@param	dp	Date pointer.
828*/
829void
830itadmin_mem_date_init(itadmin_date *dp);
831
832/**	Copy date structure.
833	@param	dp	Destination pointer.
834	@param	sp	Source pointer.
835*/
836void
837itadmin_mem_date_copy(itadmin_date *dp, itadmin_date *sp);
838
839/**	Create a DHCP option structure.
840	@param	job	Job structure.
841	@param	k	Key (option name).
842	@param	v	Option value.
843	@param	pk	Primary key number from table (unused).
844	@return	Valid pointer to new object on success, NULL on error.
845*/
846itadmin_dhcp_option *
847itadmin_mem_dhcp_option_new(
848  itadmin_job	*job,
849  char const	*k,
850  char const	*v,
851  long		 pk
852);
853
854/**	Destroy DHCP option structure, release memory.
855	@param	v	Option to destroy.
856*/
857void
858itadmin_mem_dhcp_option_del(void *v);
859
860/**	Read data from database.
861	@param	job	Job structure.
862	@return	1 on success, 0 on error.
863*/
864int
865itadmin_data_read(itadmin_job *job);
866
867/**	Read data from MySQL database.
868	@param	job	Job structure.
869	@return	1 on success, 0 on error.
870*/
871int
872itadmin_data_mysql_read(itadmin_job *job);
873
874/**	Register a user record.
875	@param	job	Job structure.
876	@param	us_s	User short name (login name).
877	@param	us_t	User title or academic degree.
878	@param	us_sn	Surname.
879	@param	us_fn	Family name.
880	@param	us_em	E-Mail.
881	@param	us_ko	Cost control ID.
882	@param	us_se	Organizational unit.
883	@return	1 on success, 0 on error.
884*/
885int
886itadmin_register_user(
887  itadmin_job	*job,
888  char const	*us_s,
889  char const	*us_t,
890  char const	*us_sn,
891  char const	*us_fn,
892  char const	*us_em,
893  char const	*us_ko,
894  char const	*us_se
895);
896
897/**	Register building.
898	@param	job	Job structure.
899	@param	gb_s	Short building name.
900	@param	gb_l	Long building name.
901	@param	gb_a1	Address line 1.
902	@param	gb_a2	Address line 2.
903	@param	gb_a3	Address line 3.
904	@param	gb_a4	Address line 4.
905	@param	gb_plz	Zip code.
906	@param	gb_ort	City name.
907	@return	1 on success, 0 on error.
908*/
909int
910itadmin_register_building(
911  itadmin_job		*job,
912  char const		*gb_s,
913  char const		*gb_l,
914  char const		*gb_a1,
915  char const		*gb_a2,
916  char const		*gb_a3,
917  char const		*gb_a4,
918  char const		*gb_plz,
919  char const		*gb_ort
920);
921
922/**	Register a speed setting.
923	@param	job	Job structure.
924	@param	sn	Short name for setting.
925	@param	ln	Description.
926	@return	1 on success, 0 on error.
927*/
928int
929itadmin_register_speed(
930  itadmin_job		*job,
931  char const		*sn,
932  char const		*ln
933);
934
935/**	Register a VLAN.
936	@param	job	Job structure.
937	@param	vl_s	Short name for VLAN.
938	@param	vl_l	Description.
939	@return	1 on success, 0 on error.
940*/
941int
942itadmin_register_vlan(itadmin_job *job, char const *vl_s, char const *vl_l);
943
944/**	Register patch (ethernet socket).
945	@param	job	Job structure.
946	@param	dd_n	Patch name.
947	@param	sp_s	Speed setting name.
948	@param	vl_s	VLAN short name.
949	@param	dd_p	Hub port name.
950	@param	gb_s	Building.
951	@param	dd_r	Room number/name of patch.
952	@return	1 on success, 0 on error.
953*/
954int
955itadmin_register_patch(
956  itadmin_job		*job,
957  char const		*dd_n,
958  char const		*sp_s,
959  char const		*vl_s,
960  char const		*dd_p,
961  char const		*gb_s,
962  char const		*dd_r
963);
964
965/**	Register network.
966	@param	job	Job structure.
967	@param	nw_ip	IP address.
968	@param	nw_ma	Network mask.
969	@param	nw_gw	Gateway.
970	@param	nw_bc	Broadcast address.
971	@param	vl_s	VLAN for network.
972	@return	1 on success, 0 on error.
973*/
974int
975itadmin_register_network(
976  itadmin_job		*job,
977  char const		*nw_ip,
978  char const		*nw_ma,
979  char const		*nw_gw,
980  char const		*nw_bc,
981  char const		*vl_s
982);
983
984/**	Register DHCP pool.
985	@param	job	Job structure.
986	@param	ips	IP start address of pool.
987	@param	ipe	IP end address of pool.
988	@param	nw	Network address (may be NULL or empty).
989	@param	alu	Flag: Allow unknown clients.
990	@param	dnu	Flag: Deny unknown clients.
991	@param	dcn	Allowed class name if unknown clients denied.
992	@return	1 on success, 0 on error.
993*/
994int
995itadmin_register_dhcp_pool(
996  itadmin_job		*job,
997  char const		*ips,
998  char const		*ipe,
999  char const		*nw,
1000  int			 alu,
1001  int			 dnu,
1002  char const		*dcn
1003);
1004
1005/**	Register DHCP class.
1006	@param	job	Job structure.
1007	@param	dcs	Short class name.
1008	@param	dcl	Long class name (description).
1009	@return	1 on success, 0 on error.
1010*/
1011int
1012itadmin_register_dhcp_class(itadmin_job *job,char const *dcs,char const *dcl);
1013
1014/**	Register DHCP group.
1015	@param	job	Job structure.
1016	@param	sn	Short name.
1017	@param	ln	Long name (description).
1018	@return	1 on success, 0 on error.
1019*/
1020int
1021itadmin_register_dhcp_group(itadmin_job *job, char const *sn, char const *ln);
1022
1023/**	Register netgroup.
1024	@param	job	Job structure.
1025	@param	ng_s	Short netgroup name.
1026	@param	ng_l	Long name (description).
1027	@return	1 on success, 0 on error.
1028*/
1029int
1030itadmin_register_netgroup(itadmin_job *job,char const *ng_s,char const *ng_l);
1031
1032/**	Register netgroup dependency.
1033	@param	job	Job structure.
1034	@param	pgn	Name of the parent group.
1035	@param	cgn	Name of the child group.
1036	@return	1 on success, 0 on error.
1037*/
1038int
1039itadmin_register_ngdep(itadmin_job *job, char const *pgn, char const *cgn);
1040
1041/**	Register one host.
1042	@param	job		Job structure.
1043	@param	co_s		Short name for computer.
1044	@param	us_s		Owner / user in charge.
1045	@param	co_ip		IPv4 address.
1046	@param	co_mc		MAC address.
1047	@param	ng_s		Netgroup.
1048	@param	co_co		Comment for PC.
1049	@param	dc_s		DHCP class.
1050	@param	dg_s		DHCP group.
1051	@param	dd_n		Patch/connector number.
1052	@param	gb_s		Building.
1053	@param	co_r		Room number.
1054	@param	co_in		Inventory ID.
1055	@param	co_sn		Serial number.
1056	@param	co_dd		DNS domain name.
1057	@param	co_ff		Flag: Write FQDN first in /etc/hosts.
1058	@param	co_gu		Flag: BYOD (bring your own device).
1059	@param	co_hi		Host ID.
1060	@param	co_ex		Expiration date.
1061	@param	co_nn		Flag: Skip host in network documentation.
1062	@param	co_na		Flag: Skip host for arpwatch.
1063*/
1064
1065int
1066itadmin_register_host(
1067  itadmin_job		*job,
1068  char const		*co_s,
1069  char const		*us_s,
1070  char const		*co_ip,
1071  char const		*co_mc,
1072  char const		*ng_s,
1073  char const		*co_co,
1074  char const		*dc_s,
1075  char const		*dg_s,
1076  char const		*dd_n,
1077  char const		*gb_s,
1078  char const		*co_r,
1079  char const		*co_in,
1080  char const		*co_sn,
1081  char const		*co_dd,
1082  int			 co_ff,
1083  int			 co_gu,
1084  char const		*co_hi,
1085  itadmin_date		*co_ex,
1086  int			 co_nn,
1087  int			 co_na
1088);
1089
1090/**	Register host name alias.
1091	@param	job	Job structure.
1092	@param	al	Alias name.
1093	@param	rn	Real host name.
1094	@return	1 on success, 0 on error.
1095*/
1096int
1097itadmin_register_alias(itadmin_job *job, char const *al, char const *rn);
1098
1099/**	Register a DHCP option.
1100	@param	job	Job structure.
1101	@param	sct	Scope type name.
1102	@param	scn	Scope name.
1103	@param	k	Key (option name).
1104	@param	v	Option value.
1105	@param	pk	Primary key from database.
1106	@return	1 on success, 0 on error.
1107*/
1108int
1109itadmin_register_dhcp_option(
1110  itadmin_job	*job,
1111  char const	*sct,
1112  char const	*scn,
1113  char const	*k,
1114  char const	*v,
1115  long		 pk
1116);
1117
1118/**	Check name for empty string or minus.
1119	We have to save the entry if the string pointer is not
1120	NULL and the string is not empty and not a minus.
1121	@param	sn	String to check.
1122	@return	1 if string must be saved, 0 for ignore.
1123*/
1124int
1125itadmin_register_check_user_name(char const *sn);
1126
1127/**	Check whether we can attempt to convert a string to an IP address.
1128	@param	ip	String to test.
1129	@return	1 for string with text, 0 for empty string.
1130*/
1131int
1132itadmin_register_check_ip(char const *ip);
1133
1134/**	Register a software manufacturer.
1135	@param	job	Job structure.
1136	@param	sm_s	Short name.
1137	@param	sm_l	Long name.
1138	@return	1 on success, 0 on error.
1139*/
1140int
1141itadmin_register_swman( itadmin_job *job, char const *sm_s, char const *sm_l);
1142
1143/**	Register a software product.
1144	@param	job	Job structure.
1145	@param	sw_s	Short software name.
1146	@param	sw_l	Long software name.
1147	@param	sm_s	Software manufacturer.
1148	@return	1 on success, 0 on error.
1149*/
1150int
1151itadmin_register_swprod(
1152  itadmin_job	*job,
1153  char const	*sw_s,
1154  char const	*sw_l,
1155  char const	*sm_s
1156);
1157/**	Register a license type.
1158	@param	job	Job structure.
1159	@param	lt_s	Short license type name.
1160	@param	lt_l	Long name/description of license type.
1161	@param	nl	Number of licenses (for floating licenses).
1162*/
1163int
1164itadmin_register_lictype(
1165  itadmin_job	*job,
1166  char const	*lt_s,
1167  char const	*lt_l,
1168  int		 nl
1169);
1170
1171/**	Register license.
1172	@param	job	Job structure.
1173	@param	pk	Primary key.
1174	@param	li_on	Order number (purchase process ID).
1175	@param	sw_s	Software short name.
1176	@param	us_s	User to which the license is assigned.
1177	@param	co_s	Computer on which the license is used.
1178	@param	lt_s	License type.
1179	@param	li_no	Optional note for the license.
1180	@param	li_nd	Delivery note number.
1181	@param	li_ni	Invoice number.
1182	@return	1 on success, 0 on error.
1183*/
1184int
1185itadmin_register_license(
1186  itadmin_job	*job,
1187  unsigned long	 pk,
1188  char const	*li_on,
1189  char const	*sw_s,
1190  char const	*us_s,
1191  char const	*co_s,
1192  char const	*lt_s,
1193  char const	*li_no,
1194  char const	*li_nd,
1195  char const	*li_ni
1196);
1197
1198/**	Compare structures for user.
1199	@param	l	Left structure.
1200	@param	r	Right structure, object, or name.
1201	@param	cr	Comparison criteria
1202	(0=user/user by us, 1=user/name by us, 2=user/user by na+sn+tt+us).
1203	@return	Comparison result.
1204*/
1205int
1206itadmin_comp_user(void const *l, void const *r, int cr);
1207
1208/**	Compare structures for buildings.
1209	@param	l	Left structure.
1210	@param	r	Right structure, object, or name.
1211	@param	cr	Comparison criteria
1212	(0=building/building by s, 1=building/name by s).
1213	@return	Comparison result.
1214*/
1215int
1216itadmin_comp_building(void const *l, void const *r, int cr);
1217
1218/**	Compare structures for network speed.
1219	@param	l	Left structure.
1220	@param	r	Right structure, object, or name.
1221	@param	cr	Comparison criteria
1222	(0=speed/speed by s, 1=speed/name).
1223	@return	Comparison result.
1224*/
1225int
1226itadmin_comp_speed(void const *l, void const *r, int cr);
1227
1228/**	Compare structures for VLAN.
1229	@param	l	Left structure.
1230	@param	r	Right structure, object, or name.
1231	@param	cr	Comparison criteria
1232	(0=vlan/vlan by s, 1=vlan/name by s).
1233	@return	Comparison result.
1234*/
1235int
1236itadmin_comp_vlan(void const *l, void const *r, int cr);
1237
1238/**	Compare structures for ethernet socket.
1239	@param	l	Left structure.
1240	@param	r	Right structure, object, or name.
1241	@param	cr	Comparison criteria
1242	(0=socket/socket by s, 1=socket/name).
1243	@return	Comparison result.
1244*/
1245int
1246itadmin_comp_connect(void const *l, void const *r, int cr);
1247
1248/**	Compare structures for network.
1249	@param	l	Left structure.
1250	@param	r	Right structure, object, or name.
1251	@param	cr	Comparison criteria
1252	(0=network/network by ip4, 1=network/ipaddress).
1253	@return	Comparison result.
1254*/
1255int
1256itadmin_comp_network(void const *l, void const *r, int cr);
1257
1258/**	Compare structures for netgroup.
1259	@param	l	Left structure.
1260	@param	r	Right structure, object, or name.
1261	@param	cr	Comparison criteria
1262	(0=netgroup/netgroup by sn, 1=netgroup/name by sn).
1263	@return	Comparison result.
1264*/
1265int
1266itadmin_comp_netgroup(void const *l, void const *r, int cr);
1267
1268/**	Compare structures for DHCP class.
1269	@param	l	Left structure.
1270	@param	r	Right structure, object, or name.
1271	@param	cr	Comparison criteria
1272	(0=class/class by sn, 1=class/name by sn).
1273	@return	Comparison result.
1274*/
1275int
1276itadmin_comp_dhcp_class(void const *l, void const *r, int cr);
1277
1278/**	Compare structures for DHCP pool.
1279	@param	l	Left structure.
1280	@param	r	Right structure, object, or name.
1281	@param	cr	Comparison criteria
1282	(0=pool/pool by ip4s, 1=pool/ipaddress).
1283	@return	Comparison result.
1284*/
1285int
1286itadmin_comp_dhcp_pool(void const *l, void const *r, int cr);
1287
1288/**	Compare structures for DHCP group.
1289	@param	l	Left structure.
1290	@param	r	Right structure, object, or name.
1291	@param	cr	Comparison criteria
1292	(0=group/group by sn, 1=group/name).
1293	@return	Comparison result.
1294*/
1295int
1296itadmin_comp_dhcp_group(void const *l, void const *r, int cr);
1297
1298/**	Compare structures for host
1299	@param	l	Left structure.
1300	@param	r	Right structure, object, or name.
1301	@param	cr	Comparison criteria
1302	(0=host/host by sn, 1=host/name, 2=host/host by ipv4, 3=host/ipaddr).
1303	@return	Comparison result.
1304*/
1305int
1306itadmin_comp_host(void const *l, void const *r, int cr);
1307
1308/**	Compare structures for software manufacturer.
1309	@param	l	Left structure.
1310	@param	r	Right structure, object, or name.
1311	@param	cr	Comparison criteria
1312	(0=swman/swman by sn, 1=swman/name).
1313	@return	Comparison result.
1314*/
1315int
1316itadmin_comp_swman(void const *l, void const *r, int cr);
1317
1318/**	Compare structures for software product.
1319	@param	l	Left structure.
1320	@param	r	Right structure, object, or name.
1321	@param	cr	Comparison criteria
1322	(0=product/product by sn, 1=product/name,
1323	2=product/product by mn->ln+ln).
1324	@return	Comparison result.
1325*/
1326int
1327itadmin_comp_swprod(void const *l, void const *r, int cr);
1328
1329/**	Compare structures for license type.
1330	@param	l	Left structure.
1331	@param	r	Right structure, object, or name.
1332	@param	cr	Comparison criteria
1333	(0=license/license by product).
1334	@return	Comparison result.
1335*/
1336int
1337itadmin_comp_lictype(void const *l, void const *r, int cr);
1338
1339/**	Compare structures for license.
1340	@param	l	Left structure.
1341	@param	r	Right structure, object, or name.
1342	@param	cr	Comparison criteria
1343	(0=license/license by pk, 1=license/pk, 2=license/license by product).
1344	@return	Comparison result.
1345*/
1346int
1347itadmin_comp_license(void const *l, void const *r, int cr);
1348
1349/**	Compare two licenses within a network.
1350	@param	l	Left object.
1351	@param	r	Right object or name.
1352	@param	cr	Comparison criteria (0=group/group,
1353	1=group/name).
1354	@return	Comparison result.
1355*/
1356int
1357itadmin_comp_dhcp_ginw(void const *l, void const *r, int cr);
1358
1359/**	Compare two date structures.
1360	@param	l	Left object.
1361	@param	r	Right object.
1362	@return	1 if @arg l is later than @arg r, 0 for equal days,
1363	1 if @arg l is earlier than @arg r.
1364*/
1365int
1366itadmin_comp_date(itadmin_date const *l, itadmin_date const *r);
1367
1368/**	Compare two DHCP options.
1369	@param	l	Left object.
1370	@param	r	Right object.
1371	@param	cr	Comparison criteria (ignored).
1372	@return	Comparison result.
1373*/
1374int
1375itadmin_comp_dhcp_option(void const *l, void const *r, int cr);
1376
1377/**	Compare two strings.
1378	@param	l	Left string.
1379	@param	r	Right string.
1380	@param	cr	Comparison criteria (1=case-insensitive, 0=normal).
1381	@return	Comparison result.
1382*/
1383int
1384itadmin_comp_string(void const *l, void const *r, int cr);
1385
1386/**	Check whether we have to write network configuration
1387	and documentation.
1388	@param	job	Job structure.
1389	@return	1 for yes, 0 for no.
1390*/
1391int
1392itadmin_job_do_network(itadmin_job *job);
1393
1394/**	Check whether we have to write a dhcpd.conf file.
1395	@param	job	Job structure.
1396	@return	1 for yes, 0 for no.
1397*/
1398int
1399itadmin_job_do_dhcp(itadmin_job *job);
1400
1401/**	Check whether we have to write a license report.
1402	@param	job	Job structure.
1403	@return	1 for yes, 0 for no.
1404*/
1405int
1406itadmin_job_do_licenses(itadmin_job *job);
1407
1408/**	Convert string yyyy-mm-dd to date structure.
1409	@param	job	Job structure.
1410	@param	dp	Destination pointer.
1411	@param	str	Source text.
1412	@return	1 on success, 0 on error.
1413*/
1414int
1415itadmin_tool_convert_date(itadmin_job *job, itadmin_date *dp, char const *str);
1416
1417/**	Write IPv4 address to file.
1418	@param	df	Destination file.
1419	@param	ipv4	Address to write.
1420*/
1421void
1422itadmin_tool_write_ip(FILE *df, unsigned long ipv4);
1423
1424/**	Write IPv4 address to stream.
1425	@param	os	Output stream.
1426	@param	ipv4	Address to write.
1427*/
1428void
1429itadmin_tool_stream_ip(dk3_stream_t *os, unsigned long ipv4);
1430
1431/**	Write user name short to LaTeX output.
1432	@param	job	Job structure.
1433	@param	os	Output stream.
1434	@param	user	User to write.
1435*/
1436void
1437itadmin_tool_write_user_latex_short(
1438  itadmin_job	*job,
1439  dk3_stream_t	*os,
1440  itadmin_user	*user
1441);
1442
1443/**	Write user name long to LaTeX output.
1444	@param	job	Job structure.
1445	@param	os	Output stream.
1446	@param	user	User to write.
1447*/
1448void
1449itadmin_tool_write_user_latex_long(
1450  itadmin_job	*job,
1451  dk3_stream_t	*os,
1452  itadmin_user	*user
1453);
1454
1455/**	Write the section header in the table.
1456	@param	job	Job structure.
1457	@param	os	Output stream.
1458	@param	kwi	Keyword index.
1459*/
1460void
1461itadmin_tool_table_section_header(
1462  itadmin_job	*job,
1463  dk3_stream_t	*os,
1464  size_t	 kwi
1465);
1466
1467/**	Start a table line.
1468	@param	job	Job structure.
1469	@param	os	Output stream.
1470	@param	kwi	Keyword index in localized messages.
1471*/
1472void
1473itadmin_tool_table_line_start(
1474  itadmin_job	*job,
1475  dk3_stream_t	*os,
1476  size_t	 kwi
1477);
1478
1479/**	Separate two items in a table.
1480	@param	os	Output stream.
1481*/
1482void
1483itadmin_tool_table_line_sep_rows(
1484  dk3_stream_t	*os
1485);
1486
1487/**	Finish a table line.
1488	@param	job	Job structure.
1489	@param	os	Output stream.
1490	@param	pb	Flag: Allow page break here.
1491*/
1492void
1493itadmin_tool_table_line_finish(
1494  dk3_stream_t	*os,
1495  int		 pb
1496);
1497
1498/**	Create empty table field.
1499	@param	job	Job structure.
1500	@param	os	Output stream.
1501	@param	nu	Flag: Write notification for missing value.
1502*/
1503void
1504itadmin_tool_table_line_no_data(
1505  itadmin_job	*job,
1506  dk3_stream_t	*os,
1507  int		 nu
1508);
1509
1510/**	Write one detail table line.
1511	@param	job	Job structure.
1512	@param	os	Output stream.
1513	@param	kwi	Keyword index for option name.
1514	@param	det	Details to write.
1515	@param	nu	Flag: Write a note about unknown values.
1516	@param	pb	Flag: Allow page break after line.
1517*/
1518void
1519itadmin_tool_table_line(
1520  itadmin_job	*job,
1521  dk3_stream_t	*os,
1522  size_t	 kwi,
1523  char const	*det,
1524  int		 nu,
1525  int		 pb
1526);
1527
1528/**	Write a table line consisting of two values.
1529	@param	job	Job structure.
1530	@param	os	Output stream.
1531	@param	key	Key.
1532	@param	val	Value.
1533	@param	fb	Flag: Key in bold.
1534	@param	pb	Flag: Allow page break.
1535*/
1536void
1537itadmin_tool_table_values(
1538  itadmin_job	*job,
1539  dk3_stream_t	*os,
1540  char const	*key,
1541  char const	*val,
1542  int		 fb,
1543  int		 pb
1544);
1545
1546/**	Check whether a host is owned by a user.
1547	@param	us	User.
1548	@param	co	Host.
1549	@return	1 if the host is owned by the user, 0 otherwise.
1550*/
1551int
1552itadmin_tool_check_same_user(itadmin_user *us, itadmin_host *co);
1553
1554/**	Write a section of text to output stream.
1555	@param	job	Job structure.
1556	@param	os	Output stream.
1557	@param	sect	Text section to write.
1558*/
1559void
1560itadmin_tool_write_section(
1561  dk3_stream_t		*os,
1562  char const * const	*sect
1563);
1564
1565/**	Write log message of one part.
1566	@param	job	Job structure.
1567	@param	ll	Log level.
1568	@param	i	Index of message text in localized messages array.
1569*/
1570void
1571itadmin_tool_log_1(
1572  itadmin_job		*job,
1573  int			 ll,
1574  size_t		 i
1575);
1576
1577/**	Write log message of three parts.
1578	@param	job	Job structure.
1579	@param	ll	Log level.
1580	@param	i1	Index of first message text in localized messages array.
1581	@param	i2	Index of third text part in localized messages array.
1582	@param	msg	Variable message text, second text part.
1583*/
1584void
1585itadmin_tool_log_utf8_3(
1586  itadmin_job		*job,
1587  int			 ll,
1588  size_t		 i1,
1589  size_t		 i2,
1590  char const		*msg
1591);
1592
1593/**	Write log message of five parts.
1594	@param	job	Job structure.
1595	@param	ll	Log level.
1596	@param	i1	Index of first message text in localized messages array.
1597	@param	i2	Index of third text part in localized messages array.
1598	@param	i3	Index of fifth text part in localized messages array.
1599	@param	msg1	First variable message text, second text part.
1600	@param	msg2	Second variable messagetext, fourth text part.
1601*/
1602void
1603itadmin_tool_log_utf8_5(
1604  itadmin_job		*job,
1605  int			 ll,
1606  size_t		 i1,
1607  size_t		 i2,
1608  size_t		 i3,
1609  char const		*msg1,
1610  char const		*msg2
1611);
1612
1613/**	Write log message of three parts.
1614	@param	job	Job structure.
1615	@param	ll	Log level.
1616	@param	i1	Index of first constant message part.
1617	@param	i2	Index of third message part.
1618	@param	pk	Primary key as numeric value.
1619*/
1620void
1621itadmin_tool_log_pk_3(
1622  itadmin_job		*job,
1623  int			 ll,
1624  size_t		 i1,
1625  size_t		 i2,
1626  unsigned long		 pk
1627);
1628
1629/**	Write log message of five parts.
1630	@param	job	Job structure.
1631	@param	ll	Log level.
1632	@param	i1	Index of first constant message part.
1633	@param	i2	Index of third message part.
1634	@param	i3	Index of fifth message part.
1635	@param	pk	Primary key as numeric value.
1636	@param	msg	Variable message part.
1637*/
1638void
1639itadmin_tool_log_pk_5(
1640  itadmin_job		*job,
1641  int			 ll,
1642  size_t		 i1,
1643  size_t		 i2,
1644  size_t		 i3,
1645  unsigned long		 pk,
1646  char const		*msg
1647);
1648
1649/**	Write IPv4 address to buffer.
1650	@param	bu	Destination buffer, at least 16 bytes long.
1651	@param	ip	IP address.
1652*/
1653void
1654itadmin_tool_ip_to_buffer(char *bu, unsigned long ip);
1655
1656/**	Write hosts file.
1657	@param	job	Job structure.
1658	@return	1 on success, 0 on error.
1659*/
1660int
1661itadmin_hosts_output(itadmin_job *job);
1662
1663/**	Write hosts.ldif file.
1664	@param	job	Job structure.
1665	@return	1 on success, 0 on error.
1666*/
1667int
1668itadmin_hosts_ldif_output(itadmin_job *job);
1669
1670/**	Write ethers-by-ip and ethers-by-mac files.
1671	@param	job	Job structure.
1672	@return	1 on success, 0 on error.
1673*/
1674int
1675itadmin_ethers_output(itadmin_job *job);
1676
1677/**	Write ethers.ldif file.
1678	@param	job	Job structure.
1679	@return	1 on success, 0 on error.
1680*/
1681int
1682itadmin_ethers_ldif_output(itadmin_job *job);
1683
1684/**	Expand netgroup dependencies.
1685	@param	job	Job structure.
1686	@return	1 on success, 0 on error.
1687*/
1688int
1689itadmin_netgroup_expand(itadmin_job *job);
1690
1691/**	Check whether a host is a member of a netgroup.
1692	@param	job		Job structure.
1693	@param	netgroup	Netgroup.
1694	@param	host		Host.
1695	@return	0 for no member, 1 for indirect member, 2 for direct member.
1696*/
1697int
1698itadmin_netgroup_host_member(
1699  itadmin_job		*job,
1700  itadmin_netgroup	*netgroup,
1701  itadmin_host		*host
1702);
1703
1704/**	Write netgroup.ldif file.
1705	@param	job	Job structure.
1706	@return	1 on success, 0 on error.
1707*/
1708int
1709itadmin_netgroup_ldif_output(itadmin_job *job);
1710
1711/**	Write dhcpd.conf file.
1712	@param	job	Job structure.
1713	@return	1 on success, 0 on error.
1714*/
1715int
1716itadmin_dhcpd_conf_output(itadmin_job *job);
1717
1718/**	Write network documentation file.
1719	@param	job	Job structure.
1720	@return	1 on success, 0 on error.
1721*/
1722int
1723itadmin_netdocu(itadmin_job *job);
1724
1725/**	Write license report.
1726	@param	job	Job structure.
1727	@return	1 on success, 0 on error.
1728*/
1729int
1730itadmin_license_report(itadmin_job *job);
1731
1732#ifdef __cplusplus
1733}
1734#endif
1735
1736%%	module
1737
1738
1739#include <libdk3c/dk3all.h>
1740#include <itadmin/itadmin.h>
1741#if 0
1742#include <libdk3c/dkt-version.h>
1743#endif
1744#include <libdk4base/dk4vers.h>
1745
1746
1747$!trace-include
1748
1749
1750
1751/**	Keywords used by the program, not localized.
1752*/
1753static dkChar const * const	itadmin_kw_noloc[] = {
1754$!string-table	macro=dkT
1755#
1756#   0: Program group name.
1757#
1758dktools
1759#
1760#   1: String table name.
1761#
1762itadmin.str
1763#
1764#   2: Program name used in version
1765#
1766itadmin
1767#
1768#   3: Help text file name.
1769#
1770itadmin.txt
1771#
1772#   4: Configuration file name.
1773#
1774itadmin.conf
1775$!end
1776};
1777
1778
1779
1780/**	Localized message texts.
1781*/
1782static dkChar const * const	itadmin_kw[] = {
1783$!string-table	macro=dkT
1784#
1785#   0:	Title for network documentation
1786#
1787Network documentation
1788#
1789#   1:	Subject for network documentation
1790#
1791Network documentation
1792#
1793#   2:	LaTeX packages for localization
1794#
1795
1796#
1797#   3:	Hosts
1798#
1799Hosts
1800#
1801#   4:	Other hosts
1802#
1803Other hosts
1804#
1805#   5:	Overview
1806#
1807Overview
1808#
1809#   6:	Purpose:
1810#
1811Purpose:
1812#
1813#   7:	Inventory ID:
1814#
1815Inventory ID:
1816#
1817#   8:	Serial no:
1818#
1819Serial no:
1820#
1821#   9:	not specified (unknown)
1822#
1823not specified
1824#
1825#  10:	Main user: (person responsible for host)
1826#
1827Main user:
1828#
1829#  11:	Place (building and room)
1830#
1831Place:
1832#
1833#  12:	Network
1834#
1835Network
1836#
1837#  13:	IP address
1838#
1839IP address:
1840#
1841#  14:	DNS domain
1842#
1843DNS domain:
1844#
1845#  15:	MAC address
1846#
1847MAC address:
1848#
1849#  16:	Ethernet socket (patch no)
1850#
1851Ethernet socket:
1852#
1853#  17:	DHCP class
1854#
1855DHCP class:
1856#
1857#  18:	DHCP group
1858#
1859DHCP group:
1860#
1861#  19:	Netgroups
1862#
1863Netgroups
1864#
1865#  20:	Notice, this is an address from a DHCP pool
1866#
1867IP address from DHCP pool, dynamically assigned to DHCP clients
1868#
1869#  21:	Short section header BYOD + DHCP
1870#
1871BYOD DHCP
1872#
1873#  22:	Section header BYOD + DHCP
1874#
1875Bring your own device, use DHCP
1876#
1877#  23:
1878#
1879Not sucject to license management.
1880#
1881#  24:
1882#
1883This device is private property (BYOD), not owned by our organizational unit.
1884#
1885#  25:
1886#
1887This host is outside our responsibility.
1888#
1889#  26:
1890#
1891It is listed in configuration files and documentation because there is a
1892#
1893#  27:
1894#
1895need for communication between our computers and this system.
1896#
1897#  28:
1898#
1899Organizational unit not responsible for correct licensing.
1900#
1901#  29: Parent groups
1902#
1903Parent groups
1904#
1905#  30: Subgroups
1906#
1907Subgroups
1908#
1909#  31: Additional network interface
1910#
1911UNUSED
1912#
1913#  32: Member hosts for netgroups
1914#
1915Member hosts
1916#
1917#  33: DHCP pools
1918#
1919DHCP pools
1920#
1921#  34: Start address
1922#
1923Start address:
1924#
1925#  35: End address
1926#
1927End address:
1928#
1929#  36: Allow unknown clients
1930#
1931Allow unknown clients:
1932#
1933#  37: Deny unknown clients
1934#
1935Deny unknown clients:
1936#
1937#  38: Allow members of group
1938#
1939Allow class:
1940#
1941#  39: yes
1942#
1943yes
1944#
1945#  40: no
1946#
1947no
1948#
1949#  41: DHCP classes
1950#
1951DHCP classes
1952#
1953#  42: Ethernet connectors
1954#
1955Ethernet connectors
1956#
1957#  43: Connector
1958#
1959Connector
1960#
1961#  44: Room
1962#
1963Room
1964#
1965#  45: VLAN
1966#
1967VLAN
1968#
1969#  46: Speed
1970#
1971Speed
1972#
1973#  47: Hub port
1974#
1975Hub port
1976#
1977#  48: Available licenses
1978#
1979Available licenses
1980#
1981#  49/50: Message to explain section contents
1982#
1983The licenses listed here were purchased by the organizational unit
1984but not (yet) assigned to a user or computer.
1985#
1986#  51:	LaTeX text for pdftitle
1987#
1988License report
1989#
1990#  52:	LaTeX text for pdfsubject
1991#
1992licenses
1993#
1994#  53:	Default license type: Single computer license
1995#
1996Single computer license
1997#
1998#  54:	LaTeX text: Purchase process ID
1999#
2000Purchase process ID:
2001#
2002#  55:	LaTeX text: Delivery date
2003#
2004Delivery date:
2005#
2006#  56:	LaTeX text: Delivery note ID (Lieferschein-Nr)
2007#
2008Delivery note ID:
2009#
2010#  57:	LaTeX text: Invoice date
2011#
2012Invoice date:
2013#
2014#  58:	LaTeX text: Invoice ID (Rechnungs-Nr)
2015#
2016Invoice ID:
2017#
2018#  59:	LaTeX text: Complete license list
2019#
2020Complete license list
2021#
2022#  60:	LaTeX text: Host unknown
2023#
2024Host unknown
2025#
2026#  61:	LaTeX text: Assignment to host not specified.
2027#
2028Assignment to host not specified
2029#
2030#  62:	LaTeX text: Other people's hosts
2031#
2032Other people's hosts
2033#
2034#  63:	LaTeX text: Licenses used on other people's hosts
2035#
2036Licenses used on other people's hosts
2037#
2038#  64:	LaTeX text
2039#
2040The licenses listed in this section were assigned to the user.
2041#
2042#  65:	LaTeX text
2043#
2044There is no information available (yet) on which computers the licenses
2045#
2046#  66:	LaTeX text
2047#
2048are used.
2049#
2050#  67:	LaTeX text
2051#
2052The licenses listed in this section were assigned to the user.
2053#
2054#  68:	LaTeX text
2055#
2056At this time they are used on computers other people are
2057#
2058#  69:	LaTeX text
2059#
2060responsible for.
2061#
2062#  70:	LaTeX text
2063#
2064Note:
2065#
2066#  71:	LaTeX text
2067#
2068These licenses are listed twice in the license report:
2069#
2070#  72:	LaTeX text
2071#
2072Once in the section for the host and once again here.
2073#
2074#  73:	LaTeX text
2075#
2076This special situation is indicated in the host licenses section by
2077#
2078#  74:	LaTeX text
2079#
2080the license owner name written in an
2081#
2082#  75:	LaTeX text
2083#
2084italic font.
2085#
2086#  76:	String separator in date, - for english, . for german
2087#
2088-
2089#
2090#  77:	Progress message: Expanding netgroup dependencies.
2091#
2092Expanding netgroup dependencies.
2093#
2094#  78:	Progress message: Writing hosts file.
2095#
2096Writing "hosts" file.
2097#
2098#  79:	Progress message: Writing hosts.ldif file.
2099#
2100Writing "hosts.ldif" file.
2101#
2102#  80:	Progress message: Writing ethers files.
2103#
2104Writing "ethers" files.
2105#
2106#  81:	Progress message: Writing ethers.ldif file.
2107#
2108Writing "ethers.ldif" file.
2109#
2110#  82:	Progress message: Writing netgroup.ldif file.
2111#
2112Writing "netgroup.ldif" file.
2113#
2114#  83:	Progress message: Writing dhcpd.conf file.
2115#
2116Writing "dhcpd.conf" file.
2117#
2118#  84:	Progress message: Writing netdocu.tex file.
2119#
2120Writing "netdocu.tex" file.
2121#
2122#  85:	Progress message: Writing licenses.tex file.
2123#
2124Writing "licenses.tex" file.
2125#
2126#  86:	Progress message: Finished writing output files.
2127#
2128Finished writing output files.
2129#
2130#  87:	Progress message: Reading users table.
2131#
2132Reading users table.
2133#
2134#  88:	Progress message: Reading buildings table.
2135#
2136Reading buildings table.
2137#
2138#  89:	Progress message: Reading network speed types table.
2139#
2140Reading network speed types table.
2141#
2142#  90:	Progress message: Reading VLANs table.
2143#
2144Reading VLANs table.
2145#
2146#  91:	Progress message: Reading ethernet connectors table.
2147#
2148Reading ethernet connectors table.
2149#
2150#  92:	Progress message: Reading netgroups table.
2151#
2152Reading netgroups table.
2153#
2154#  93:	Progress message: Reading netgroup dependencies table.
2155#
2156Reading netgroup dependencies  table.
2157#
2158#  94:	Progress message: Reading networks table.
2159#
2160Reading networks table.
2161#
2162#  95:	Progress message: Reading DHCP classes table.
2163#
2164Reading DHCP classes table.
2165#
2166#  96:	Progress message: Reading DHCP groups table.
2167#
2168Reading DHCP groups table.
2169#
2170#  97:	Progress message: Reading DHCP pools table.
2171#
2172Reading DHCP pools table.
2173#
2174#  98:	Progress message: Reading hosts table.
2175#
2176Reading hosts table.
2177#
2178#  99:	Progress message: Reading host name aliases table.
2179#
2180Reading host name aliases table.
2181#
2182# 100:	Progress message: Reading DHCP options table.
2183#
2184Reading DHCP options table.
2185#
2186# 101:	Progress message: Reading software manufacturers table.
2187#
2188Reading software manufacturers table.
2189#
2190# 102:	Progress message: Reading software products table.
2191#
2192Reading software products table.
2193#
2194# 103:	Progress message: Reading license types table.
2195#
2196Reading license types table.
2197#
2198# 104:	Progress message: Reading licenses table.
2199#
2200Reading licenses table.
2201#
2202# 105:	Progress message: Finished reading input from database.
2203#
2204Finished reading input from database.
2205#
2206# 106/107:	ERROR: Not a boolean value "..."!
2207#
2208Not a boolean value: "
2209"!
2210#
2211# 108/109:	ERROR: Configuration text "..." too long!
2212#
2213Configuration value text "
2214" too long!
2215#
2216# 110/111:	ERROR: No such database type: "..."!
2217#
2218No such database type: "
2219"!
2220#
2221# 112:	ERROR: A value text is required!
2222#
2223A value text is required!
2224#
2225# 113/114:	ERROR: Unknown configuration option "..."!
2226#
2227Unknown configuration option "
2228"!
2229#
2230# 115:	ERROR: Syntax error - "=" and value required!
2231#
2232Syntax error - "=" and value required!
2233#
2234# 116:	ERROR: Input line too long!
2235#
2236Input line too long!
2237#
2238# 117:	ERROR: Missing end of section name!
2239#
2240Missing end of section name!
2241#
2242# 118/119:	ERROR: File name contains wildcards, this is not allowed!
2243#
2244File name "
2245"\ncontains wildcards, this is not allowed!
2246#
2247# 120/121:	WARNING: File name "..." is not an absolute path name!
2248#
2249File name "
2250"\nis not an absolute path name!
2251#
2252# 122:	ERROR: Missing database host name!
2253#
2254Missing database host name!
2255#
2256# 123:	ERROR: Missing database name!
2257#
2258Missing database name!
2259#
2260# 124:	WARNING: Missing DHCP VLAN name!
2261#
2262Missing DHCP VLAN name!
2263#
2264# 125:	ERROR: Missing organization name!
2265#
2266Missing organization name!
2267#
2268# 126:	ERROR: Missing organizational unit name!
2269#
2270Missing organizational unit name!
2271#
2272# 127:	ERROR: Missing administrator name!
2273#
2274Missing administrator name!
2275#
2276# 128:	ERROR: Missing database credentials file name!
2277#
2278Missing database credentials file name!
2279#
2280# 129:	ERROR: Missing database user name!
2281#
2282Missing database user name!
2283#
2284# 130:	ERROR: Missing database user password!
2285#
2286Missing database user password!
2287#
2288# 131:	ERROR: No configuration files found!
2289#
2290No configuration file(s) "itadmin.conf" found!#
2291#
2292# 132:	ERROR: Configuration problems!
2293#
2294Configuration problems,\nplease check the itadmin.conf configuration files!
2295#
2296# 133:	ERROR: Unsupported database type!
2297#
2298Unsupported database type!
2299#
2300# 134:	ERROR start: DHCP pool "
2301#
2302DHCP pool "
2303#
2304# 135:	ERROR:
2305#
2306": Inconsistent setup!\nUnknown clients can be allowed or denied to use a pool, not both!
2307#
2308# 136:	ERROR start DHCP class "
2309#
2310DHCP class "
2311#
2312# 137:	ERROR: DHCP class assigned to pools in different networks!
2313#
2314" assigned to pools in different networks!
2315#
2316# 138:	ERROR: DHCP pool "...": Missing allowed DHCP class name!
2317#
2318": Missing allowed DHCP class name!
2319#
2320# 139/140:	ERROR: No such VLAN!
2321#
2322No such VLAN: "
2323"!
2324#
2325# 141:	ERROR: Failed to obtain results list!
2326#
2327Failed to obtain results list for database query!
2328#
2329# 142:	ERROR: Failed to query database!
2330#
2331Failed to query database!
2332#
2333# 143:	ERROR: Primary key is not numeric!
2334#
2335Table "licenses", record
2336#
2337# 144:	ERROR: Primary key is not numeric!
2338#
2339 Primary key is not numeric!
2340#
2341# 145:	ERROR: Missing primary key!
2342#
2343 Missing primary key!
2344#
2345# 146, 147, 148: License type "...": Not a number "..."!
2346#
2347License type "
2348": Not a number "
2349"!
2350#
2351# 149/150:	ERROR: Tabel swm record ... Missing primary key!
2352#
2353Table "swmanufacturers" record
2354 Missing primary key!
2355#
2356# 151:		ERROR start: Table "dhcpoptions" record ...
2357#
2358Table "dhcpoptions" record
2359#
2360# 152:		ERROR: Primary key is not numeric!
2361#
2362 Primary key is not numeric!
2363#
2364# 153:		ERROR: Missing primary key!
2365#
2366 Missing primary key!
2367#
2368# 154:	ERROR: Failed to set database encoding!
2369#
2370Failed to set database encoding!
2371#
2372# 155/156/157:	ERROR: Failed to connect to database!
2373#
2374Failed to connect to database "
2375" at host "
2376"!
2377#
2378# 158/159:	ERROR: Illegal database name!
2379#
2380Illegal database name: "
2381"!
2382#
2383# 160:	ERROR: Failed to convert database user password!
2384#
2385Failed to convert database user passwort to UTF-8!
2386#
2387# 161/162:	ERROR: Failed to convert database user name to UTF-8!
2388#
2389Failed to convert database user name "
2390" to UTF-8!
2391#
2392# 163/164:	ERROR: Failed to convert database host name to UTF-8!
2393#
2394Failed to convert database host name "
2395" to UTF-8!
2396#
2397# 165:	ERROR: Failed to initialize MySQL client object!
2398#
2399Failed to initialize MySQL client object!
2400#
2401# 166:	ERROR: Failed to initialize MySQL client library!
2402#
2403Failed to initialize MySQL client library!
2404#
2405# 167:	ERROR:	MySQL database support not available!
2406#
2407MySQL database support not available!
2408#
2409# 168/169:	ERROR: User name "...": Duplicated entry!
2410#
2411User name "
2412": Duplicated entry!
2413#
2414# 170/171:	ERROR: Building "...": Duplicated entry!
2415#
2416Building "
2417": Duplicated entry!
2418#
2419# 172/173:	ERROR: Ethernet speed setting "...": Duplicated entry!
2420#
2421Ethernet speed setting "
2422": Duplicated entry!
2423#
2424# 174/175:	VLAN "...": Duplicated entry!
2425#
2426VLAN "
2427": Duplicated entry!
2428#
2429# 176/177:	Computer "...": Duplicated entry!
2430#
2431Computer "
2432": Duplicated entry!
2433#
2434# 178/179:	Software manufacturer "...": Duplicated entry!
2435#
2436Software manufacturer "
2437": Duplicated entry!
2438#
2439# 180/181:	Netgroup "...": Duplicated entry!
2440#
2441Netgroup "
2442": Duplicated entry!
2443#
2444# 182/183:	Netgroup "..." not defined!
2445#
2446Netgroup "
2447" not defined!
2448#
2449# 184/185:	Ethernet connector "...": Duplicated entry!
2450#
2451Ethernet connector "
2452": Duplicated entry!
2453#
2454# 186/187:	Ethernet speed setting "..." not defined!
2455#
2456Ethernet speed setting "
2457" not defined!
2458#
2459# 188/189:	VLAN "..." not defined!
2460#
2461VLAN "
2462" not defined!
2463#
2464# 190/191:	Building "..." not defined!
2465#
2466Building "
2467" not defined!
2468#
2469# 192/193:	Failed to convert net mask "..."!
2470#
2471Failed to convert net mask "
2472"!
2473#
2474# 194:	Using default net mask 255.255.255.0!
2475#
2476Using default net mask 255.255.255.0!
2477#
2478# 195/196:	Failed to convert default gateway "..."!
2479#
2480Failed to convert default gateway "
2481"!
2482#
2483# 197/198:	Using default gateway ...
2484#
2485Using default gateway
2486.
2487#
2488# 199/200:	Failed to convert broadcast address!
2489#
2490Failed to convert broadcast address "
2491"!
2492#
2493# 201/202:	Network "...": Duplicated entry!
2494#
2495Network "
2496": Duplicated entry!
2497#
2498# 203:	Attempt to define IP network without specifying an IP address!
2499#
2500Attempt to define IP network without specifying an IP address!
2501#
2502# 204/205:	DHCP class "...": Duplicated entry!
2503#
2504DHCP class "
2505": Duplicated entry!
2506#
2507# 206/207:	DHCP group "...": Duplicated entry!
2508#
2509DHCP group "
2510": Duplicated entry!
2511#
2512# 208/209:	Invalied network address "..."!
2513#
2514Invalid network address "
2515"!
2516#
2517# 210/211:	DHCP class "..." not defined!
2518#
2519DHCP class "
2520" not defined!
2521#
2522# 212/213:	Network "..." not defined!
2523#
2524Network "
2525" not defined!
2526#
2527# 214/215:	DHCP pool "...": Invalid end address!
2528#
2529DHCP pool "
2530": Invalid end address!
2531#
2532# 216/217:	DHCP pool "...": Missing end address!
2533#
2534DHCP pool "
2535": Missing end address!
2536#
2537# 218/219:	DHCP pool "...": Invalid start address!
2538#
2539DHCP pool "
2540": Invalid start address!
2541#
2542# 220:	DHCP pool definition attempted with empty start address!
2543#
2544DHCP pool definition attempted with empty start address!
2545#
2546# 221/222:	Computer "...": Illegal MAC address!
2547#
2548Computer "
2549": Illegal MAC address!
2550#
2551# 223/224:	Computer "...": MAC address too long!
2552#
2553Computer "
2554": MAC address too long!
2555#
2556# 225/226/227:	Computer "...": User "..." not defined!
2557#
2558Computer "
2559": User "
2560" not defined!
2561#
2562# 228/229/230:	Computer "...": Netgroup "..." not defined!
2563#
2564Computer "
2565": Netgroup "
2566" not defined!
2567#
2568# 231/232/233:	Computer "...": DHCP class "..." not defined!
2569#
2570Computer "
2571": DHCP class "
2572" not defined!
2573#
2574# 234/235/236:	Computer "...": DHCP group "..." not defined!
2575#
2576Computer "
2577": DHCP group "
2578" not defined!
2579#
2580# 237/238/239:	Computer "...": Ethernet connector "..." not defined!
2581#
2582Computer "
2583": Ethernet connector "
2584" not defined!
2585#
2586# 240/241/242:	Computer "...": Building "..." not defined!
2587#
2588Computer "
2589": Building "
2590" not defined!
2591#
2592# 243/244:	Computer "...": Both DHCP class and IP address defined!
2593#
2594Computer "
2595": Both DHCP class and IP address specified!
2596#
2597# 245/246:	Computer "...": DHCP class specified, but MAC address missing!
2598#
2599Computer "
2600": DHCP class specified, but MAC address is missing!
2601#
2602# 247/248:	Computer "...": Netgroup specified, but IP address missing!
2603#
2604Computer "
2605": Netgroup specified, but IP address is missing!
2606#
2607# 249/250:	Computer "...": Netgroup specified, but DNS domain missing!
2608#
2609Computer "
2610": Netgroup specified, but DNS domain is missing!
2611#
2612# 251/252:	Computer "...": FQDN first flag set, but DNS domain missing!
2613#
2614Computer "
2615": FQDN first flag set, but DNS domain is missing!
2616#
2617# 253/254:	Computer "...": Over expiration date, should be removed!
2618#
2619Computer "
2620": Over expiration date, should be removed!
2621#
2622# 255:		Attempt to define a computer without a host name!
2623#
2624Attempt to define a computer without a host name!
2625#
2626# 256/257/258:	Alias "...": Computer "..." not defined!
2627#
2628Alias "
2629": Computer "
2630" not defined!
2631#
2632# 259/260/261:	DHCP option ...: VLAN "..." not defined!
2633#
2634DHCP option
2635: VLAN "
2636" not defined!
2637#
2638# 262/263/264:	DHCP option ...: Network "..." not defined!
2639#
2640DHCP option
2641: Network "
2642" not defined!
2643#
2644# 265/266/267:	DHCP option ...: DHCP group "..." not defined!
2645#
2646DHCP option
2647: DHCP group "
2648" not defined!
2649#
2650# 268/269/270:	DHCP option ...: DHCP pool "..." not defined!
2651#
2652DHCP option
2653: DHCP pool "
2654" not defined!
2655#
2656# 271/272/273:	DHCP option ...: Computer "..." not defined!
2657#
2658DHCP option
2659: Computer "
2660" not defined!
2661#
2662# 274/275/276:	DHCP option ...: Unknown scope type name "..."!
2663#
2664DHCP option
2665: Unknown scope type name "
2666"!
2667#
2668# 277/278:	Software product "...": Duplicated entry!
2669#
2670Software product "
2671": Duplicated entry!
2672#
2673# 279/280/281:	Software product "...": Manufacturer "..." not defined!
2674#
2675Software product "
2676": Software manufacturer "
2677" not defined!
2678#
2679# 282/283:	License type "...": Duplicated entry!
2680#
2681License type "
2682": Duplicated entry!
2683#
2684# 284/285:	License ...: Duplicated entry!
2685#
2686License
2687: Duplicated entry!
2688#
2689# 286/287/288:	License ...: User "..." not defined!
2690#
2691License
2692: User "
2693" not defined!
2694#
2695# 289/290/291:	License ...: Computer "..." not defined!
2696#
2697License
2698: Computer "
2699" not defined!
2700#
2701# 292/293/294:	License ...: License type "..." not defined!
2702#
2703License
2704: License type "
2705" not defined!
2706#
2707# 295/296/297:	License ... assigned to computer "..." but no user specified!
2708#
2709License
2710 assigned to computer "
2711" but no user specified!
2712#
2713# 298/299:	License ...: No software product specified!
2714#
2715License
2716: No software product specified!
2717#
2718# 300/301:	Illegal date specification "..."!
2719#
2720Illegal date specification "
2721"!
2722#
2723# 302:	Koma-script suggestion.
2724#
2725Users from Europe - especially from Germany - should consider using koma-script.
2726#
2727# 303/304:	ERROR: Illegal software manufacturer!
2728#
2729Illegal software manufacturer (short name): "
2730"!
2731#
2732# 305/306:	ERROR: Illegal software!
2733#
2734Illegal software (short name): "
2735"!
2736#
2737# 307/308:	ERROR: Illegal license type!
2738#
2739Illegal license type (short name): "
2740"!
2741#
2742# 309:		ERROR: Failed to reset sensitive memory range!
2743#
2744Failed to reset sensitive memory range!
2745#
2746# 310:		Info The device owner is responsible.
2747#
2748The device owner is responsible for correct licensing.
2749#
2750# 311/312
2751#
2752This IP address is assigned dynamically to different computers by DHCP.
2753Licenses are listed below real computer names.
2754#
2755# 313
2756#
2757This is an additional network interface for a computer.
2758#
2759# 314-317
2760#
2761UNUSED
2762This is just a network interface of a non-computer device (i.e. printer,
2763web cam, measurement device, oscilloscope, control unit...) without
2764software requring license accounting.
2765#
2766# 318-320
2767#
2768Reserved IP address and host name.
2769This combination of IP address and host name ist not yet in use,
2770they are reserved for later use.
2771#
2772# 321		Device no longer in use.
2773#
2774Retired, this device is no longer in use.
2775#
2776#
2777#
2778$!end
2779};
2780
2781
2782
2783/**	License text written for --license option.
2784*/
2785static dkChar const * const	itadmin_license_overview[] = {
2786$!text	macro=dkT
2787
2788Overview
2789========
2790This software uses code from the following projects, either directly or
2791by linking a library:
2792
2793dktools		DK tools and libraries
2794		See http://sourceforge.net/p/dktools/wiki/Home/ for information.
2795
2796MySQL		MySQL client library.
2797		See http://www.mysql.com for information.
2798
2799$!end
2800};
2801
2802
2803
2804/**	License for the dktools project.
2805*/
2806static dkChar const * const	itadmin_license_dktools[] = {
2807$!text	macro=dkT
2808
2809License conditions for DK tools and libraries
2810=============================================
2811Copyright (c) 2012-2016, Dirk Krause
2812All rights reserved.
2813
2814Redistribution and use in source and binary forms, with or without
2815modification, are permitted provided that the following conditions are met:
2816
2817* Redistributions of source code must retain the above copyright notice,
2818  this list of conditions and the following disclaimer.
2819* Redistributions in binary form must reproduce the above copyright
2820  notice, this list of conditions and the following disclaimer in the
2821  documentation and/or other materials provided with the distribution.
2822* Neither the name of the copyright holder(s) nor the names of
2823  contributors may be used to endorse or promote products derived from
2824  this software without specific prior written permission.
2825
2826THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2827"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2828LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2829A PARTICULAR PURPOSE ARE DISCLAIMED.
2830
2831IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
2832DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2833DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2834OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2835HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2836STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
2837IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2838POSSIBILITY OF SUCH DAMAGE.
2839
2840$!end
2841};
2842
2843
2844
2845/**	License for the MySQL client library (GPL + FLOSS exception).
2846*/
2847static dkChar const * const	itadmin_license_mysql[] = {
2848$!text	macro=dkT
2849License conditions for the MySQL client library
2850===============================================
2851
2852GNU General Public License
2853--------------------------
2854
2855		    GNU GENERAL PUBLIC LICENSE
2856		       Version 2, June 1991
2857
2858 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
2859 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2860 Everyone is permitted to copy and distribute verbatim copies
2861 of this license document, but changing it is not allowed.
2862
2863			    Preamble
2864
2865  The licenses for most software are designed to take away your
2866freedom to share and change it.  By contrast, the GNU General Public
2867License is intended to guarantee your freedom to share and change free
2868software--to make sure the software is free for all its users.  This
2869General Public License applies to most of the Free Software
2870Foundation's software and to any other program whose authors commit to
2871using it.  (Some other Free Software Foundation software is covered by
2872the GNU Lesser General Public License instead.)  You can apply it to
2873your programs, too.
2874
2875  When we speak of free software, we are referring to freedom, not
2876price.  Our General Public Licenses are designed to make sure that you
2877have the freedom to distribute copies of free software (and charge for
2878this service if you wish), that you receive source code or can get it
2879if you want it, that you can change the software or use pieces of it
2880in new free programs; and that you know you can do these things.
2881
2882  To protect your rights, we need to make restrictions that forbid
2883anyone to deny you these rights or to ask you to surrender the rights.
2884These restrictions translate to certain responsibilities for you if you
2885distribute copies of the software, or if you modify it.
2886
2887  For example, if you distribute copies of such a program, whether
2888gratis or for a fee, you must give the recipients all the rights that
2889you have.  You must make sure that they, too, receive or can get the
2890source code.  And you must show them these terms so they know their
2891rights.
2892
2893  We protect your rights with two steps: (1) copyright the software, and
2894(2) offer you this license which gives you legal permission to copy,
2895distribute and/or modify the software.
2896
2897  Also, for each author's protection and ours, we want to make certain
2898that everyone understands that there is no warranty for this free
2899software.  If the software is modified by someone else and passed on, we
2900want its recipients to know that what they have is not the original, so
2901that any problems introduced by others will not reflect on the original
2902authors' reputations.
2903
2904  Finally, any free program is threatened constantly by software
2905patents.  We wish to avoid the danger that redistributors of a free
2906program will individually obtain patent licenses, in effect making the
2907program proprietary.  To prevent this, we have made it clear that any
2908patent must be licensed for everyone's free use or not licensed at all.
2909
2910  The precise terms and conditions for copying, distribution and
2911modification follow.
2912
2913		    GNU GENERAL PUBLIC LICENSE
2914   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2915
2916  0. This License applies to any program or other work which contains
2917a notice placed by the copyright holder saying it may be distributed
2918under the terms of this General Public License.  The "Program", below,
2919refers to any such program or work, and a "work based on the Program"
2920means either the Program or any derivative work under copyright law:
2921that is to say, a work containing the Program or a portion of it,
2922either verbatim or with modifications and/or translated into another
2923language.  (Hereinafter, translation is included without limitation in
2924the term "modification".)  Each licensee is addressed as "you".
2925
2926Activities other than copying, distribution and modification are not
2927covered by this License; they are outside its scope.  The act of
2928running the Program is not restricted, and the output from the Program
2929is covered only if its contents constitute a work based on the
2930Program (independent of having been made by running the Program).
2931Whether that is true depends on what the Program does.
2932
2933  1. You may copy and distribute verbatim copies of the Program's
2934source code as you receive it, in any medium, provided that you
2935conspicuously and appropriately publish on each copy an appropriate
2936copyright notice and disclaimer of warranty; keep intact all the
2937notices that refer to this License and to the absence of any warranty;
2938and give any other recipients of the Program a copy of this License
2939along with the Program.
2940
2941You may charge a fee for the physical act of transferring a copy, and
2942you may at your option offer warranty protection in exchange for a fee.
2943
2944  2. You may modify your copy or copies of the Program or any portion
2945of it, thus forming a work based on the Program, and copy and
2946distribute such modifications or work under the terms of Section 1
2947above, provided that you also meet all of these conditions:
2948
2949    a) You must cause the modified files to carry prominent notices
2950    stating that you changed the files and the date of any change.
2951
2952    b) You must cause any work that you distribute or publish, that in
2953    whole or in part contains or is derived from the Program or any
2954    part thereof, to be licensed as a whole at no charge to all third
2955    parties under the terms of this License.
2956
2957    c) If the modified program normally reads commands interactively
2958    when run, you must cause it, when started running for such
2959    interactive use in the most ordinary way, to print or display an
2960    announcement including an appropriate copyright notice and a
2961    notice that there is no warranty (or else, saying that you provide
2962    a warranty) and that users may redistribute the program under
2963    these conditions, and telling the user how to view a copy of this
2964    License.  (Exception: if the Program itself is interactive but
2965    does not normally print such an announcement, your work based on
2966    the Program is not required to print an announcement.)
2967
2968These requirements apply to the modified work as a whole.  If
2969identifiable sections of that work are not derived from the Program,
2970and can be reasonably considered independent and separate works in
2971themselves, then this License, and its terms, do not apply to those
2972sections when you distribute them as separate works.  But when you
2973distribute the same sections as part of a whole which is a work based
2974on the Program, the distribution of the whole must be on the terms of
2975this License, whose permissions for other licensees extend to the
2976entire whole, and thus to each and every part regardless of who wrote it.
2977
2978Thus, it is not the intent of this section to claim rights or contest
2979your rights to work written entirely by you; rather, the intent is to
2980exercise the right to control the distribution of derivative or
2981collective works based on the Program.
2982
2983In addition, mere aggregation of another work not based on the Program
2984with the Program (or with a work based on the Program) on a volume of
2985a storage or distribution medium does not bring the other work under
2986the scope of this License.
2987
2988  3. You may copy and distribute the Program (or a work based on it,
2989under Section 2) in object code or executable form under the terms of
2990Sections 1 and 2 above provided that you also do one of the following:
2991
2992    a) Accompany it with the complete corresponding machine-readable
2993    source code, which must be distributed under the terms of Sections
2994    1 and 2 above on a medium customarily used for software interchange;
2995    or,
2996
2997    b) Accompany it with a written offer, valid for at least three
2998    years, to give any third party, for a charge no more than your
2999    cost of physically performing source distribution, a complete
3000    machine-readable copy of the corresponding source code, to be
3001    distributed under the terms of Sections 1 and 2 above on a medium
3002    customarily used for software interchange; or,
3003
3004    c) Accompany it with the information you received as to the offer
3005    to distribute corresponding source code.  (This alternative is
3006    allowed only for noncommercial distribution and only if you
3007    received the program in object code or executable form with such
3008    an offer, in accord with Subsection b above.)
3009
3010The source code for a work means the preferred form of the work for
3011making modifications to it.  For an executable work, complete source
3012code means all the source code for all modules it contains, plus any
3013associated interface definition files, plus the scripts used to
3014control compilation and installation of the executable.  However, as a
3015special exception, the source code distributed need not include
3016anything that is normally distributed (in either source or binary
3017form) with the major components (compiler, kernel, and so on) of the
3018operating system on which the executable runs, unless that component
3019itself accompanies the executable.
3020
3021If distribution of executable or object code is made by offering
3022access to copy from a designated place, then offering equivalent
3023access to copy the source code from the same place counts as
3024distribution of the source code, even though third parties are not
3025compelled to copy the source along with the object code.
3026
3027  4. You may not copy, modify, sublicense, or distribute the Program
3028except as expressly provided under this License.  Any attempt
3029otherwise to copy, modify, sublicense or distribute the Program is
3030void, and will automatically terminate your rights under this License.
3031However, parties who have received copies, or rights, from you under
3032this License will not have their licenses terminated so long as such
3033parties remain in full compliance.
3034
3035  5. You are not required to accept this License, since you have not
3036signed it.  However, nothing else grants you permission to modify or
3037distribute the Program or its derivative works.  These actions are
3038prohibited by law if you do not accept this License.  Therefore, by
3039modifying or distributing the Program (or any work based on the
3040Program), you indicate your acceptance of this License to do so, and
3041all its terms and conditions for copying, distributing or modifying
3042the Program or works based on it.
3043
3044  6. Each time you redistribute the Program (or any work based on the
3045Program), the recipient automatically receives a license from the
3046original licensor to copy, distribute or modify the Program subject to
3047these terms and conditions.  You may not impose any further
3048restrictions on the recipients' exercise of the rights granted herein.
3049You are not responsible for enforcing compliance by third parties to
3050this License.
3051
3052  7. If, as a consequence of a court judgment or allegation of patent
3053infringement or for any other reason (not limited to patent issues),
3054conditions are imposed on you (whether by court order, agreement or
3055otherwise) that contradict the conditions of this License, they do not
3056excuse you from the conditions of this License.  If you cannot
3057distribute so as to satisfy simultaneously your obligations under this
3058License and any other pertinent obligations, then as a consequence you
3059may not distribute the Program at all.  For example, if a patent
3060license would not permit royalty-free redistribution of the Program by
3061all those who receive copies directly or indirectly through you, then
3062the only way you could satisfy both it and this License would be to
3063refrain entirely from distribution of the Program.
3064
3065If any portion of this section is held invalid or unenforceable under
3066any particular circumstance, the balance of the section is intended to
3067apply and the section as a whole is intended to apply in other
3068circumstances.
3069
3070It is not the purpose of this section to induce you to infringe any
3071patents or other property right claims or to contest validity of any
3072such claims; this section has the sole purpose of protecting the
3073integrity of the free software distribution system, which is
3074implemented by public license practices.  Many people have made
3075generous contributions to the wide range of software distributed
3076through that system in reliance on consistent application of that
3077system; it is up to the author/donor to decide if he or she is willing
3078to distribute software through any other system and a licensee cannot
3079impose that choice.
3080
3081This section is intended to make thoroughly clear what is believed to
3082be a consequence of the rest of this License.
3083
3084  8. If the distribution and/or use of the Program is restricted in
3085certain countries either by patents or by copyrighted interfaces, the
3086original copyright holder who places the Program under this License
3087may add an explicit geographical distribution limitation excluding
3088those countries, so that distribution is permitted only in or among
3089countries not thus excluded.  In such case, this License incorporates
3090the limitation as if written in the body of this License.
3091
3092  9. The Free Software Foundation may publish revised and/or new versions
3093of the General Public License from time to time.  Such new versions will
3094be similar in spirit to the present version, but may differ in detail to
3095address new problems or concerns.
3096
3097Each version is given a distinguishing version number.  If the Program
3098specifies a version number of this License which applies to it and "any
3099later version", you have the option of following the terms and conditions
3100either of that version or of any later version published by the Free
3101Software Foundation.  If the Program does not specify a version number of
3102this License, you may choose any version ever published by the Free Software
3103Foundation.
3104
3105  10. If you wish to incorporate parts of the Program into other free
3106programs whose distribution conditions are different, write to the author
3107to ask for permission.  For software which is copyrighted by the Free
3108Software Foundation, write to the Free Software Foundation; we sometimes
3109make exceptions for this.  Our decision will be guided by the two goals
3110of preserving the free status of all derivatives of our free software and
3111of promoting the sharing and reuse of software generally.
3112
3113			    NO WARRANTY
3114
3115  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
3116FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
3117OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
3118PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
3119OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3120MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
3121TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
3122PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
3123REPAIR OR CORRECTION.
3124
3125  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
3126WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
3127REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
3128INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
3129OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
3130TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
3131YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
3132PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
3133POSSIBILITY OF SUCH DAMAGES.
3134
3135		     END OF TERMS AND CONDITIONS
3136
3137	    How to Apply These Terms to Your New Programs
3138
3139  If you develop a new program, and you want it to be of the greatest
3140possible use to the public, the best way to achieve this is to make it
3141free software which everyone can redistribute and change under these terms.
3142
3143  To do so, attach the following notices to the program.  It is safest
3144to attach them to the start of each source file to most effectively
3145convey the exclusion of warranty; and each file should have at least
3146the "copyright" line and a pointer to where the full notice is found.
3147
3148    <one line to give the program's name and a brief idea of what it does.>
3149    Copyright (C) <year>  <name of author>
3150
3151    This program is free software; you can redistribute it and/or modify
3152    it under the terms of the GNU General Public License as published by
3153    the Free Software Foundation; either version 2 of the License, or
3154    (at your option) any later version.
3155
3156    This program is distributed in the hope that it will be useful,
3157    but WITHOUT ANY WARRANTY; without even the implied warranty of
3158    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3159    GNU General Public License for more details.
3160
3161    You should have received a copy of the GNU General Public License along
3162    with this program; if not, write to the Free Software Foundation, Inc.,
3163    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3164
3165Also add information on how to contact you by electronic and paper mail.
3166
3167If the program is interactive, make it output a short notice like this
3168when it starts in an interactive mode:
3169
3170    Gnomovision version 69, Copyright (C) year name of author
3171    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
3172    This is free software, and you are welcome to redistribute it
3173    under certain conditions; type `show c' for details.
3174
3175The hypothetical commands `show w' and `show c' should show the appropriate
3176parts of the General Public License.  Of course, the commands you use may
3177be called something other than `show w' and `show c'; they could even be
3178mouse-clicks or menu items--whatever suits your program.
3179
3180You should also get your employer (if you work as a programmer) or your
3181school, if any, to sign a "copyright disclaimer" for the program, if
3182necessary.  Here is a sample; alter the names:
3183
3184  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
3185  `Gnomovision' (which makes passes at compilers) written by James Hacker.
3186
3187  <signature of Ty Coon>, 1 April 1989
3188  Ty Coon, President of Vice
3189
3190This General Public License does not permit incorporating your program into
3191proprietary programs.  If your program is a subroutine library, you may
3192consider it more useful to permit linking proprietary applications with the
3193library.  If this is what you want to do, use the GNU Lesser General
3194Public License instead of this License.
3195
3196MySQL FLOSS License Exception
3197-----------------------------
3198
3199MySQL FLOSS License Exception
3200
3201The MySQL AB Exception for Free/Libre and Open Source Software-only
3202Applications Using MySQL Client Libraries (the "FLOSS Exception").
3203
3204Version 0.6, 7 March 2007
3205
3206Exception Intent
3207
3208We want specified Free/Libre and Open Source Software (``FLOSS'')
3209applications to be able to use specified GPL-licensed MySQL client
3210libraries (the ``Program'') despite the fact that not all FLOSS
3211licenses are compatible with version 2 of the GNU General Public
3212License (the ``GPL'').
3213
3214Legal Terms and Conditions
3215
3216As a special exception to the terms and conditions of version 2.0
3217of the GPL:
3218
3219 1. You are free to distribute a Derivative Work that is formed
3220    entirely from the Program and one or more works (each, a
3221    "FLOSS Work") licensed under one or more of the licenses
3222    listed below in section 1, as long as:
3223      a. You obey the GPL in all respects for the Program and the
3224         Derivative Work, except for identifiable sections of the
3225         Derivative Work which are not derived from the Program,
3226         and which can reasonably be considered independent and
3227         separate works in themselves,
3228      b. all identifiable sections of the Derivative Work which
3229         are not derived from the Program, and which can
3230         reasonably be considered independent and separate works
3231         in themselves,
3232           i. are distributed subject to one of the FLOSS licenses
3233              listed below, and
3234          ii. the object code or executable form of those sections
3235              are accompanied by the complete corresponding
3236              machine-readable source code for those sections on
3237              the same medium and under the same FLOSS license as
3238              the corresponding object code or executable forms of
3239              those sections, and
3240      c. any works which are aggregated with the Program or with a
3241         Derivative Work on a volume of a storage or distribution
3242         medium in accordance with the GPL, can reasonably be
3243         considered independent and separate works in themselves
3244         which are not derivatives of either the Program, a
3245         Derivative Work or a FLOSS Work.
3246    If the above conditions are not met, then the Program may only
3247    be copied, modified, distributed or used under the terms and
3248    conditions of the GPL or another valid licensing option from
3249    MySQL AB.
3250
3251 2. FLOSS License List
3252
3253License name Version(s)/Copyright Date
3254Academic Free License 2.0
3255Apache Software License 1.0/1.1/2.0
3256Apple Public Source License 2.0
3257Artistic license From Perl 5.8.0
3258BSD license "July 22 1999"
3259Common Development and Distribution License (CDDL) 1.0
3260Common Public License 1.0
3261Eclipse Public License 1.0
3262GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1
3263Jabber Open Source License 1.0
3264MIT license (As listed in file MIT-License.txt) ---
3265Mozilla Public License (MPL) 1.0/1.1
3266Open Software License 2.0
3267OpenSSL license (with original SSLeay license) "2003" ("1998")
3268PHP License 3.0
3269Python license (CNRI Python License) ---
3270Python Software Foundation License 2.1.1
3271Sleepycat License "1999"
3272University of Illinois/NCSA Open Source License ---
3273W3C License "2001"
3274X11 License "2001"
3275Zlib/libpng License ---
3276Zope Public License 2.0
3277
3278    Due to the many variants of some of the above licenses, we
3279    require that any version follow the 2003 version of the Free
3280    Software Foundation's Free Software Definition
3281    (http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of
3282    the Open Source Definition by the Open Source Initiative
3283    (http://www.opensource.org/docs/definition.php).
3284
3285 3. Definitions
3286
3287      a. Terms used, but not defined, herein shall have the
3288         meaning provided in the GPL.
3289      b. Derivative Work means a derivative work under copyright
3290         law.
3291
3292 4. Applicability: This FLOSS Exception applies to all Programs
3293    that contain a notice placed by MySQL AB saying that the
3294    Program may be distributed under the terms of this FLOSS
3295    Exception. If you create or distribute a work which is a
3296    Derivative Work of both the Program and any other work
3297    licensed under the GPL, then this FLOSS Exception is not
3298    available for that work; thus, you must remove the FLOSS
3299    Exception notice from that work and comply with the GPL in all
3300    respects, including by retaining all GPL notices. You may
3301    choose to redistribute a copy of the Program exclusively under
3302    the terms of the GPL by removing the FLOSS Exception notice
3303    from that copy of the Program, provided that the copy has
3304    never been modified by you or any third party.
3305
3306Appendix A. Qualified Libraries and Packages
3307
3308The following is a non-exhaustive list of libraries and packages
3309which are covered by the FLOSS License Exception. Please note that
3310this appendix is provided merely as an additional service to
3311specific FLOSS projects wishing to simplify licensing information
3312for their users. Compliance with one of the licenses noted under
3313the "FLOSS license list" section remains a prerequisite.
3314
3315Package Name                  Qualifying License and Version
3316Apache Portable Runtime (APR) Apache Software License 2.0
3317
3318$!end
3319};
3320
3321
3322
3323/**	Help text shown for --help.
3324*/
3325static dkChar const * const	itadmin_help_text[] = {
3326$!text	macro=dkT
3327
3328NAME
3329
3330  itadmin - IT administration using databases
3331
3332SYNOPSIS
3333
3334  itadmin [<options>] [<config-file>]
3335
3336DESCRIPTION
3337
3338The program reads IT-related information from a database and creates
3339configuration files, a network documentation, and a license report.
3340A configuration file can be specified as argument, the program searches
3341for itadmin.conf files if no configuration file is specified.
3342
3343OPTIONS
3344
3345-c
3346--configuration
3347	Create configuration files and network documentation.
3348
3349-l
3350--licenses
3351	Create license report.
3352	If none of -c and -l is used the program creates all output
3353	(same as both -c and -l used).
3354
3355-h
3356--help
3357	Show a help text.
3358
3359-v
3360--version
3361	Show version information.
3362
3363-L
3364--license-terms
3365	Show license terms.
3366
3367EXIT STATUS
3368
33690 on success, all other exit status codes indicate an error.
3370
3371FILES
3372
3373itadmin.conf
3374	The itadmin.conf file contains the configuration information
3375	used by the program. The file consists of key=value pairs, one
3376	per line. Keys can consist of multiple words.
3377	Lines started by '#' are comments.
3378	The following key=value pairs can be used:
3379
3380	database host			=	<string>
3381	database name			=	<string>
3382	database credentials file	=	<filename>
3383	dhcpd.conf vlan			=	<name>
3384	organization			=	<name>
3385	organizational unit		=	<name>
3386	administrator name		=	<name>
3387
3388AUTHOR
3389
3390Dirk Krause
3391
3392HISTORY
3393
3394The itadmin program replaces the hostsadm script found in previous
3395versions of dktools.
3396
3397COPYRIGHT AND LICENSE
3398
3399Run
3400  itadmin --license-terms
3401to see the license conditions.
3402
3403SEE ALSO
3404
3405http://sourceforge.net/p/dktools/wiki/itadmin/
3406
3407$!end
3408};
3409
3410
3411/**	Options for the itadmin program.
3412*/
3413static dk3_option_t const itadmin_options[] = {
3414  { dkT('h'), dkT("help"), 0 },
3415  { dkT('v'), dkT("version"), 0 },
3416  { dkT('L'), dkT("license-terms"), 0 },
3417  { dkT('c'), dkT("configuration"), 0 },
3418  { dkT('l'), dkT("licenses"), 0 },
3419};
3420
3421/**	Number of elements in itadmin_options.
3422*/
3423static size_t itadmin_sz_options =
3424(sizeof(itadmin_options)/sizeof(dk3_option_t));
3425
3426
3427
3428int
3429itadmin_job_do_network(itadmin_job *job)
3430{
3431  int back = 0;
3432  if(job) {
3433    if((job->cmd) & ITADMIN_CMD_CONFIG) {
3434      back = 1;
3435    }
3436  }
3437  return back;
3438}
3439
3440
3441
3442int
3443itadmin_job_do_dhcp(itadmin_job *job)
3444{
3445  int back = 0;
3446  if(itadmin_job_do_network(job)) {
3447    if(job->f_dh) {
3448      back = 1;
3449    }
3450  }
3451  return back;
3452}
3453
3454
3455
3456int
3457itadmin_job_do_licenses(itadmin_job *job)
3458{
3459  int back = 0;
3460  if(job) {
3461    if((job->cmd) & ITADMIN_CMD_LICENSES) {
3462      back = 1;
3463    }
3464  }
3465  return back;
3466}
3467
3468
3469
3470/**	Clean up a storage, destroy contained objects.
3471	@param	s	Storage to clean up.
3472	@param	i	Iterator through storage.
3473	@param	f	Function to use on each object.
3474*/
3475static
3476void
3477itadmin_clean_storage(
3478  dk3_sto_t		**s,
3479  dk3_sto_it_t		**i,
3480  itadmin_obj_del	 *f
3481)
3482{
3483  void *v;
3484
3485  if(*s) {
3486    if(*i) {
3487      dk3sto_it_reset(*i);
3488      while((v = dk3sto_it_next(*i)) != NULL) {
3489        (*f)(v);
3490      }
3491      dk3sto_it_close(*i);
3492    }
3493    dk3sto_close(*s);
3494  }
3495  *s = NULL;
3496  *i = NULL;
3497}
3498
3499
3500
3501/**	Initialize job structure.
3502	@param	job	Job structure to initialize.
3503	@param	app	Application structure for diagnostics.
3504	@param	msg	Localized message texts.
3505	@param	noloc	Texts, not localized.
3506*/
3507static
3508void
3509itadmin_job_init(
3510  itadmin_job		*job,
3511  dk3_app_t		*app,
3512  dkChar const * const	*msg,
3513  dkChar const * const	*noloc
3514)
3515{
3516  job->app = app;
3517  job->opt = NULL;
3518  job->msg = msg;
3519  job->noloc = noloc;
3520  job->exval = 1;
3521  job->cmd = 0;
3522  job->ec  = 0;
3523  job->f_dh = 0;
3524  job->dbt = DK3_SQLDB_TYPE_MYSQL;
3525  job->dbhn = NULL;
3526  job->uc2l = NULL;
3527  job->dbn = NULL;
3528  job->dbcf = NULL;
3529  job->dbus = NULL;
3530  job->dbpw = NULL;
3531  job->vlan = NULL;
3532  job->org = NULL;
3533  job->ou = NULL;
3534  job->admn = NULL;
3535  job->ldapb = NULL;
3536  job->ngdep = NULL;
3537  job->nng = 0;
3538  job->s_us = NULL; job->i_us = NULL;
3539  job->s_usn = NULL; job->i_usn = NULL;
3540  job->s_bu = NULL; job->i_bu = NULL;
3541  job->s_sp = NULL; job->i_sp = NULL;
3542  job->s_vl = NULL; job->i_vl = NULL;
3543  job->s_pa = NULL; job->i_pa = NULL;
3544  job->s_nw = NULL; job->i_nw = NULL;
3545  job->s_ng = NULL; job->i_ng = NULL;
3546  job->s_nd = NULL; job->i_nd = NULL;
3547  job->s_dc = NULL; job->i_dc = NULL;
3548  job->s_dp = NULL; job->i_dp = NULL;
3549  job->s_dg = NULL; job->i_dg = NULL;
3550  job->s_ho = NULL; job->i_ho = NULL;
3551  job->s_hoi = NULL; job->i_hoi = NULL;
3552  job->s_sm = NULL; job->i_sm = NULL;
3553  job->s_sw = NULL; job->i_sw = NULL;
3554  job->s_lt = NULL; job->i_lt = NULL;
3555  job->s_lc = NULL; job->i_lc = NULL;
3556  job->s_lf = NULL; job->i_lf = NULL;
3557  job->s_do = NULL; job->i_do = NULL;
3558  job->dbptr = NULL;
3559  job->gdate = 0;
3560  job->hlh = 0;
3561  job->ukoma = 0;
3562  job->rel = 0;
3563  job->m_p	= 1;
3564  job->m_vl	= 1;
3565  job->m_sn	= 1;
3566  job->m_gr	= 1;
3567  job->m_po	= 1;
3568  job->m_ho	= 0;
3569  if(*(msg[76]) == dkT('.')) { job->gdate = 1; }
3570}
3571
3572
3573
3574/**	Prepare a storage/iterator pair.
3575	@param	job	Job structure.
3576	@param	s	Address of storage pointer.
3577	@param	i	Address if iterator pointer.
3578	@param	f	Object comparison function for storage.
3579	@param	cr	Comparison criteria.
3580	@param	ok	Pointer to OK flag, reset on errors.
3581*/
3582static
3583void
3584itadmin_job_prepare_storage(
3585  itadmin_job		 *job,
3586  dk3_sto_t		**s,
3587  dk3_sto_it_t		**i,
3588  dk3_fct_comp_t	 *f,
3589  int			  cr,
3590  int			 *ok
3591)
3592{
3593  *s = NULL;
3594  *i = NULL;
3595  *s = dk3sto_open_app(job->app);
3596  if(*s) {
3597    *i = dk3sto_it_open(*s);
3598    if(*i) {
3599      if(f) {
3600        dk3sto_set_comp(*s, f, cr);
3601      }
3602    } else {
3603      *ok = 0;
3604    }
3605  } else {
3606    *ok = 0;
3607  }
3608}
3609
3610
3611
3612/**	Prepare all data structures for a job.
3613	@param	job	Job structure.
3614	@return	1 on success, 0 on error.
3615*/
3616static
3617int
3618itadmin_job_up(itadmin_job *job)
3619{
3620  dk3_time_t		ct;
3621  dk3_tm_t		tm;
3622  int			back	= 1;
3623  int			f_utf8	= 0;
3624  (job->today).y = 0;
3625  (job->today).m = 0;
3626  (job->today).d = 0;
3627  if(dk3sf_time(&ct)) {
3628    if(dk3sf_localtime_app(&tm, &ct, job->app)) {
3629      (job->today).y = tm.Y;
3630      (job->today).m = tm.M;
3631      (job->today).d = tm.D;
3632    }
3633  }
3634  itadmin_job_prepare_storage(
3635    job, &(job->s_us), &(job->i_us), itadmin_comp_user, 0, &back
3636  );
3637  itadmin_job_prepare_storage(
3638    job, &(job->s_usn), &(job->i_usn), itadmin_comp_user, 2, &back
3639  );
3640  itadmin_job_prepare_storage(
3641    job, &(job->s_bu), &(job->i_bu), itadmin_comp_building, 0, &back
3642  );
3643  itadmin_job_prepare_storage(
3644    job, &(job->s_sp), &(job->i_sp), itadmin_comp_speed, 0, &back
3645  );
3646  itadmin_job_prepare_storage(
3647    job, &(job->s_vl), &(job->i_vl), itadmin_comp_vlan, 0, &back
3648  );
3649  itadmin_job_prepare_storage(
3650    job, &(job->s_pa), &(job->i_pa), itadmin_comp_connect, 0, &back
3651  );
3652  itadmin_job_prepare_storage(
3653    job, &(job->s_nw), &(job->i_nw), itadmin_comp_network, 0, &back
3654  );
3655  itadmin_job_prepare_storage(
3656    job, &(job->s_ng), &(job->i_ng), itadmin_comp_netgroup, 0, &back
3657  );
3658  itadmin_job_prepare_storage(
3659    job, &(job->s_nd), &(job->i_nd), NULL, 0, &back
3660  );
3661  itadmin_job_prepare_storage(
3662    job, &(job->s_dc), &(job->i_dc), itadmin_comp_dhcp_class, 0, &back
3663  );
3664  itadmin_job_prepare_storage(
3665    job, &(job->s_dp), &(job->i_dp), itadmin_comp_dhcp_pool, 0, &back
3666  );
3667  itadmin_job_prepare_storage(
3668    job, &(job->s_dg), &(job->i_dg), itadmin_comp_dhcp_group, 0, &back
3669  );
3670  itadmin_job_prepare_storage(
3671    job, &(job->s_ho), &(job->i_ho), itadmin_comp_host, 0, &back
3672  );
3673  itadmin_job_prepare_storage(
3674    job, &(job->s_hoi), &(job->i_hoi), itadmin_comp_host, 2, &back
3675  );
3676  itadmin_job_prepare_storage(
3677    job, &(job->s_sm), &(job->i_sm), itadmin_comp_swman, 0, &back
3678  );
3679  itadmin_job_prepare_storage(
3680    job, &(job->s_sw), &(job->i_sw), itadmin_comp_swprod, 0, &back
3681  );
3682  itadmin_job_prepare_storage(
3683    job, &(job->s_lt), &(job->i_lt), itadmin_comp_lictype, 0, &back
3684  );
3685  itadmin_job_prepare_storage(
3686    job, &(job->s_lc), &(job->i_lc), itadmin_comp_license, 0, &back
3687  );
3688  itadmin_job_prepare_storage(
3689    job, &(job->s_lf), &(job->i_lf), itadmin_comp_license, 2, &back
3690  );
3691  itadmin_job_prepare_storage(
3692    job, &(job->s_do), &(job->i_do), itadmin_comp_dhcp_option, 0, &back
3693  );
3694  f_utf8 = 0;
3695  if(DK3_ENCODING_UTF8 == dk3app_get_encoding(job->app)) { f_utf8 = 1; }
3696  job->uc2l = dk3uc2lat_open_app(NULL, f_utf8, job->app);
3697  if(!(job->uc2l)) { back = 0; }
3698  return back;
3699}
3700
3701
3702
3703/**	Clean up job structure.
3704	@param	job	Job structure to clean up.
3705*/
3706static
3707void
3708itadmin_job_cleanup(itadmin_job *job)
3709{
3710#if 0
3711  /*	2016-12-09
3712    	Function dk3mem_reset_secure() to sanitize memory was added.
3713  */
3714  size_t	sz;
3715  size_t	i;
3716  int		ok = 1;
3717#endif
3718  if(job->opt) {
3719    dk3opt_close(job->opt);
3720  } job->opt = NULL;
3721  if(job->uc2l) {
3722    dk3uc2lat_close(job->uc2l);
3723  } job->uc2l = NULL;
3724  $!trace-code if(job->dbhn) {
3725  $!trace-code   dk3sf_fputs(dkT("DB hostname:  "), stdout);
3726  $!trace-code   dk3sf_fputs(job->dbhn, stdout);
3727  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3728  $!trace-code }
3729  dk3_release(job->dbhn);
3730  $!trace-code if(job->dbn) {
3731  $!trace-code   dk3sf_fputs(dkT("DB     name:  "), stdout);
3732  $!trace-code   dk3sf_fputs(job->dbn, stdout);
3733  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3734  $!trace-code }
3735  dk3_release(job->dbn);
3736  $!trace-code if(job->dbcf) {
3737  $!trace-code   dk3sf_fputs(dkT("DB credfile:  "), stdout);
3738  $!trace-code   dk3sf_fputs(job->dbcf, stdout);
3739  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3740  $!trace-code }
3741  dk3_release(job->dbcf);
3742  $!trace-code if(job->dbus) {
3743  $!trace-code   dk3sf_fputs(dkT("DB username:  "), stdout);
3744  $!trace-code   dk3sf_fputs(job->dbus, stdout);
3745  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3746  $!trace-code }
3747  if(job->dbus) {
3748#if 0
3749    /*	2016-12-09
3750    	Function dk3mem_reset_secure() to sanitize memory was added.
3751    */
3752    dk3mem_res((void *)(job->dbus), dk3str_c8_len(job->dbus));
3753#endif
3754    (void)dk3mem_reset_secure((void *)(job->dbus), dk3str_c8_len(job->dbus));
3755  }
3756  dk3_release(job->dbus);
3757  $!trace-code if(job->dbpw) {
3758#if 0
3759  $!trace-code   dk3sf_fputs(dkT("DB password:  "), stdout);
3760  $!trace-code   dk3sf_fputs(job->dbpw, stdout);
3761  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3762#endif
3763  $!trace-code }
3764  if(job->dbpw) {
3765#if 0
3766    /*	2016-12-09
3767    	Function dk3mem_reset_secure() to sanitize memory was added.
3768    */
3769    sz = dk3str_c8_len(job->dbpw);
3770    dk3mem_res((void *)(job->dbpw), dk3str_c8_len(job->dbpw));
3771    /* Static code analysis: Dead assignment ok = 0 */
3772    /* The purpose of the following instruction is to avoid */
3773    /* optimizing out the memory reset in the instruction before. */
3774    for (i = 0; i < sz; i++) { if('\0' != (job->dbpw)[i]) { ok = 0; } }
3775    if (1 != ok) {
3776      dk3app_log_1(job->app, DK3_LL_ERROR, job->msg, 309);
3777    }
3778#endif
3779    (void)dk3mem_reset_secure((void *)(job->dbpw), dk3str_c8_len(job->dbpw));
3780  }
3781  dk3_release(job->dbpw);
3782  $!trace-code if(job->vlan) {
3783  $!trace-code   dk3sf_fputs(dkT("VLAN name:    "), stdout);
3784  $!trace-code   dk3sf_fputs(job->vlan, stdout);
3785  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3786  $!trace-code }
3787  dk3_release(job->vlan);
3788  $!trace-code if(job->org) {
3789  $!trace-code   dk3sf_fputs(dkT("Organization: "), stdout);
3790  $!trace-code   dk3sf_fputs(job->org, stdout);
3791  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3792  $!trace-code }
3793  dk3_release(job->org);
3794  $!trace-code if(job->ou) {
3795  $!trace-code   dk3sf_fputs(dkT("OU name:      "), stdout);
3796  $!trace-code   dk3sf_fputs(job->ou, stdout);
3797  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3798  $!trace-code }
3799  dk3_release(job->ou);
3800  $!trace-code if(job->admn) {
3801  $!trace-code   dk3sf_fputs(dkT("admin name:   "), stdout);
3802  $!trace-code   dk3sf_fputs(job->admn, stdout);
3803  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3804  $!trace-code }
3805  dk3_release(job->admn);
3806  $!trace-code if(job->ldapb) {
3807  $!trace-code   dk3sf_fputs(dkT("ldap base:    "), stdout);
3808  $!trace-code   dk3sf_fputs(job->ldapb, stdout);
3809  $!trace-code   dk3sf_fputc(dkT('\n'), stdout);
3810  $!trace-code }
3811  dk3_release(job->ldapb);
3812  itadmin_clean_storage(&(job->s_us), &(job->i_us), itadmin_mem_user_del);
3813  itadmin_clean_storage(&(job->s_bu), &(job->i_bu), itadmin_mem_building_del);
3814  itadmin_clean_storage(&(job->s_sp), &(job->i_sp), itadmin_mem_speed_del);
3815  itadmin_clean_storage(&(job->s_vl), &(job->i_vl), itadmin_mem_vlan_del);
3816  itadmin_clean_storage(&(job->s_pa), &(job->i_pa), itadmin_mem_connect_del);
3817  itadmin_clean_storage(&(job->s_nw), &(job->i_nw), itadmin_mem_network_del);
3818  itadmin_clean_storage(&(job->s_ng), &(job->i_ng), itadmin_mem_netgroup_del);
3819  itadmin_clean_storage(&(job->s_nd), &(job->i_nd), itadmin_mem_ngdep_del);
3820  itadmin_clean_storage(&(job->s_dc), &(job->i_dc), itadmin_mem_dhcp_class_del);
3821  itadmin_clean_storage(&(job->s_dp), &(job->i_dp), itadmin_mem_dhcp_pool_del);
3822  itadmin_clean_storage(&(job->s_dg), &(job->i_dg), itadmin_mem_dhcp_group_del);
3823  if(job->s_hoi) {
3824    if(job->i_hoi) {
3825      dk3sto_it_close(job->i_hoi);
3826    }
3827    dk3sto_close(job->s_hoi);
3828  }
3829  job->s_hoi = NULL; job->i_hoi = NULL;
3830  if(job->s_usn) {
3831    if(job->i_usn) {
3832      dk3sto_it_close(job->i_usn);
3833    }
3834    dk3sto_close(job->s_usn);
3835  }
3836  job->s_usn = NULL; job->i_usn = NULL;
3837  itadmin_clean_storage(&(job->s_ho), &(job->i_ho), itadmin_mem_host_del);
3838  itadmin_clean_storage(&(job->s_sm), &(job->i_sm), itadmin_mem_sw_man_del);
3839  itadmin_clean_storage(&(job->s_sw), &(job->i_sw), itadmin_mem_software_del);
3840  itadmin_clean_storage(&(job->s_lt), &(job->i_lt), itadmin_mem_lic_type_del);
3841  if(job->s_lf) {
3842    if(job->i_lf) {
3843      dk3sto_it_close(job->i_lf);
3844    }
3845    dk3sto_close(job->s_lf);
3846  }
3847  job->s_lf = NULL; job->i_lf = NULL;
3848  itadmin_clean_storage(&(job->s_lc), &(job->i_lc), itadmin_mem_license_del);
3849  itadmin_clean_storage(&(job->s_do),&(job->i_do),itadmin_mem_dhcp_option_del);
3850  if(job->ngdep) {
3851    dk3bm_close(job->ngdep);
3852    job->ngdep = NULL;
3853  }
3854}
3855
3856
3857
3858/**	Process command line arguments.
3859	@param	job	Job structure.
3860	@return	1 on success (can continue), 0 on error.
3861*/
3862static
3863int
3864itadmin_process_arguments(itadmin_job *job)
3865{
3866  dkChar const * const	*xargv	= NULL;
3867  int			 xargc	= 0;
3868  int			 back	= 0;
3869  $? "+ itadmin_process_arguments"
3870  xargc = dk3app_get_argc(job->app);
3871  xargv = dk3app_get_argv(job->app);
3872  xargv++; xargc--;
3873  job->opt = dk3opt_open_app(
3874    itadmin_options, itadmin_sz_options,
3875    dkT('\0'), NULL,
3876    xargc, xargv,
3877    job->app
3878  );
3879  if(job->opt) {
3880    if(0 == dk3opt_get_error_code(job->opt)) {
3881      back = 1;
3882      if(dk3opt_is_set(job->opt, dkT('c'))) {
3883        job->cmd |= ITADMIN_CMD_CONFIG;
3884      }
3885      if(dk3opt_is_set(job->opt, dkT('l'))) {
3886        job->cmd |= ITADMIN_CMD_LICENSES;
3887      }
3888      if(dk3opt_is_set(job->opt, dkT('h'))) {
3889        job->cmd |= ITADMIN_CMD_HELP;
3890      }
3891      if(dk3opt_is_set(job->opt, dkT('v'))) {
3892        job->cmd |= ITADMIN_CMD_VERSION;
3893      }
3894      if(dk3opt_is_set(job->opt, dkT('L'))) {
3895        job->cmd |= ITADMIN_CMD_LICENSE_TERMS;
3896      }
3897    } else {					$? "! errors in opt proc"
3898    }
3899  } else {					$? "! failed to read opts"
3900  }
3901  $? "- itadmin_process_arguments %d", back
3902  return back;
3903}
3904
3905
3906
3907/**	Show version number.
3908*/
3909static
3910void
3911itadmin_show_version(void)
3912{
3913  dk3sf_fputs(itadmin_kw_noloc[2], stdout);
3914  dk3sf_fputs(DKT_VERSION_DK, stdout);
3915  dk3sf_fputc(dkT('\n'), stdout);
3916#if !(DK3_HAVE_MARIADB_MYSQL_H || DK3_HAVE_MYSQL_MYSQL_H || DK3_HAVE_MYSQL_H)
3917  dk3app_log_1(job->app, DK3_LL_ERROR, job->msg, 167);
3918#endif
3919}
3920
3921
3922
3923/**	Show help text.
3924	@param	job	Job structure.
3925*/
3926static
3927void
3928itadmin_show_help(itadmin_job *job)
3929{
3930  dk3app_help(job->app, itadmin_kw_noloc[3], itadmin_help_text);
3931}
3932
3933
3934
3935/**	Show one text section, used to show license terms.
3936	@param	ltxt	License text to show.
3937*/
3938static
3939void
3940itadmin_show_license_section(dkChar const * const *ltxt)
3941{
3942  dkChar const * const	*sptr;
3943  sptr = ltxt;
3944  while(*sptr) {
3945    dk3sf_fputs(*(sptr++), stdout);
3946    dk3sf_fputc(dkT('\n'), stdout);
3947  }
3948}
3949
3950
3951
3952/**	Show license conditions.
3953	@param	job	Job structure.
3954*/
3955static
3956void
3957itadmin_show_license(void)
3958{
3959  itadmin_show_license_section(itadmin_license_overview);
3960  itadmin_show_license_section(itadmin_license_dktools);
3961  itadmin_show_license_section(itadmin_license_mysql);
3962}
3963
3964
3965
3966/**	Run the tasks.
3967	@param	job	Job structure.
3968*/
3969static
3970void
3971itadmin_run(itadmin_job *job)
3972{
3973  int		success	= 0;
3974  if(itadmin_config_read(job)) {
3975    if(itadmin_data_read(job)) {
3976      /* PROGRESS: Expanding netgroup dependencies. */
3977      itadmin_tool_log_1(job, DK3_LL_PROGRESS, 77);
3978      if(itadmin_netgroup_expand(job)) {
3979        success = 1;
3980        if(itadmin_job_do_network(job)) {
3981	  /*
3982	  	Hosts
3983	  */
3984	  /* PROGRESS: Writing hosts file. */
3985	  itadmin_tool_log_1(job, DK3_LL_PROGRESS, 78);
3986          if(!itadmin_hosts_output(job)) {	$? "! hosts output"
3987	    success = 0;
3988	  }
3989	  if(job->ldapb) {
3990	    /* PROGRESS: Writing hosts.ldif file. */
3991	    itadmin_tool_log_1(job, DK3_LL_PROGRESS, 79);
3992	    if(!itadmin_hosts_ldif_output(job)) {	$? "! hosts.ldif output"
3993	      success = 0;
3994	    }
3995	  }
3996	  /*
3997	  	Ethers
3998	  */
3999	  /* PROGRESS: Writing ethers file. */
4000	  itadmin_tool_log_1(job, DK3_LL_PROGRESS, 80);
4001	  if(!itadmin_ethers_output(job)) {		$? "! ethers output"
4002	    success = 0;
4003	  }
4004	  if(job->ldapb) {
4005	    /* PROGRESS: Writing ethers.ldif file. */
4006	    itadmin_tool_log_1(job, DK3_LL_PROGRESS, 81);
4007	    if(!itadmin_ethers_ldif_output(job)) {	$? "! ethers ldif"
4008	      success = 0;
4009	    }
4010	  }
4011	  /*
4012	  	Netgroups
4013	  */
4014	  /* PROGRESS: Writing netgroup.ldif file. */
4015	  itadmin_tool_log_1(job, DK3_LL_PROGRESS, 82);
4016	  if(!itadmin_netgroup_ldif_output(job)) {	$? "! netgroup.ldif"
4017	    success = 0;
4018	  }
4019	  /*
4020	  	DHCP configuration
4021	  */
4022          if(itadmin_job_do_dhcp(job)) {
4023	    /* PROGRESS: Writing dhcpd.conf file. */
4024	    itadmin_tool_log_1(job, DK3_LL_PROGRESS, 83);
4025	    if(!itadmin_dhcpd_conf_output(job)) {	$? "! dhcpd.conf"
4026	      success = 0;
4027	    }
4028	  }
4029	  /*
4030	  	Network documentation
4031	  */
4032	  /* PROGRESS: Writing netdocu.tex file. */
4033	  itadmin_tool_log_1(job, DK3_LL_PROGRESS, 84);
4034	  if(!itadmin_netdocu(job)) {			$? "! netdocu output"
4035	    success = 0;
4036	  }
4037        }
4038        if(itadmin_job_do_licenses(job)) {
4039	  /*
4040	  	Write license report.
4041	  */
4042	  /* PROGRESS: Writing licenses.tex file. */
4043	  itadmin_tool_log_1(job, DK3_LL_PROGRESS, 85);
4044	  if(!itadmin_license_report(job)) {		$? "! license report"
4045	    success = 0;
4046	  }
4047        }
4048      }
4049      /* PROGRESS: Finished writing output. */
4050      itadmin_tool_log_1(job, DK3_LL_PROGRESS, 86);
4051    }
4052  }
4053  if(success) {
4054    job->exval = 0;
4055  } else {						$? "! no success"
4056  }
4057}
4058
4059
4060
4061/**	Run program or print help/license/version.
4062	@param	job	Job structure.
4063*/
4064static
4065void
4066itadmin_run_or_help(itadmin_job *job)
4067{
4068  $? "+ itadmin_run_or_help"
4069  if((job->cmd) & (~(ITADMIN_CMD_CONFIG | ITADMIN_CMD_LICENSES))) { $? ". help"
4070    job->exval = 0;
4071    dk3sf_initialize_stdout();
4072    if((job->cmd) & ITADMIN_CMD_VERSION) {		$? ". version"
4073      itadmin_show_version();
4074    }
4075    if((job->cmd) & ITADMIN_CMD_LICENSE_TERMS) {	$? ". license"
4076      itadmin_show_license();
4077    }
4078    if((job->cmd) & ITADMIN_CMD_HELP) {			$? ". help"
4079      itadmin_show_help(job);
4080    }
4081  } else {						$? ". run"
4082    if(!((job->cmd) & (ITADMIN_CMD_CONFIG | ITADMIN_CMD_LICENSES))) {
4083      job->cmd = (ITADMIN_CMD_CONFIG | ITADMIN_CMD_LICENSES);
4084    }
4085    itadmin_run(job);
4086  } $? "- itadmin_run_or_help"
4087}
4088
4089
4090
4091/**	Entry point of the program.
4092	@param	argc	Number of command line arguments.
4093	@param	argv	Command line arguments array.
4094	@return	0 on success, any other value indicates an error.
4095*/
4096DK3_MAIN
4097{
4098  itadmin_job		 job;		/* Job structure. */
4099  dk3_app_t		*app;		/* Application structure. */
4100  dkChar const * const	*msg;		/* Localized message texts. */
4101  int			 exval = 1;	/* Exit status code. */
4102  $!trace-init itadmin.deb
4103  $? "+ main"
4104#if DK3_HAVE_TZSET
4105  tzset();
4106#endif
4107  job.exval = 1;
4108  app = dk3app_open_command(
4109    argc, (dkChar const * const *)argv, itadmin_kw_noloc[0]
4110  );
4111  if(app) {
4112    msg = dk3app_messages(app,itadmin_kw_noloc[1],(dkChar const **)itadmin_kw);
4113    if(msg) {
4114      itadmin_job_init(&job, app, msg, itadmin_kw_noloc);
4115      if(itadmin_job_up(&job)) {
4116        if(itadmin_process_arguments(&job)) {
4117	  itadmin_run_or_help(&job);
4118	}
4119      }
4120      itadmin_job_cleanup(&job);
4121    } else {
4122      /*
4123      	BUG: Should not happen as dk3app_messages() returns the default
4124	string array if there is any error.
4125      */
4126    }
4127    dk3app_close(app);
4128  } else {
4129    /* ERROR: Memory */
4130    fprintf(
4131      stderr,
4132      "ERROR: Not enough memory\n"
4133    );
4134    fflush(stderr);
4135  }
4136  exval = job.exval;
4137  $? "- main %d", exval
4138  $!trace-end
4139  fflush(stdout);
4140  exit(exval); return exval;
4141}
4142
4143
4144
4145