]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound/util/config_file.h
Upgrade to OpenSSH 6.9p1.
[FreeBSD/FreeBSD.git] / contrib / unbound / util / config_file.h
1 /*
2  * util/config_file.h - reads and stores the config file for unbound.
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  * 
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  * 
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * 
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  * 
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 /**
37  * \file
38  *
39  * This file contains functions for the config file.
40  */
41
42 #ifndef UTIL_CONFIG_FILE_H
43 #define UTIL_CONFIG_FILE_H
44 struct config_stub;
45 struct config_strlist;
46 struct config_str2list;
47 struct module_qstate;
48 struct sock_list;
49 struct ub_packed_rrset_key;
50
51 /**
52  * The configuration options.
53  * Strings are malloced.
54  */
55 struct config_file {
56         /** verbosity level as specified in the config file */
57         int verbosity;
58
59         /** statistics interval (in seconds) */
60         int stat_interval;
61         /** if false, statistics values are reset after printing them */
62         int stat_cumulative;
63         /** if true, the statistics are kept in greater detail */
64         int stat_extended;
65
66         /** number of threads to create */
67         int num_threads;
68
69         /** port on which queries are answered. */
70         int port;
71         /** do ip4 query support. */
72         int do_ip4;
73         /** do ip6 query support. */
74         int do_ip6;
75         /** do udp query support. */
76         int do_udp;
77         /** do tcp query support. */
78         int do_tcp;
79         /** tcp upstream queries (no UDP upstream queries) */
80         int tcp_upstream;
81
82         /** private key file for dnstcp-ssl service (enabled if not NULL) */
83         char* ssl_service_key;
84         /** public key file for dnstcp-ssl service */
85         char* ssl_service_pem;
86         /** port on which to provide ssl service */
87         int ssl_port;
88         /** if outgoing tcp connections use SSL */
89         int ssl_upstream;
90
91         /** outgoing port range number of ports (per thread) */
92         int outgoing_num_ports;
93         /** number of outgoing tcp buffers per (per thread) */
94         size_t outgoing_num_tcp;
95         /** number of incoming tcp buffers per (per thread) */
96         size_t incoming_num_tcp;
97         /** allowed udp port numbers, array with 0 if not allowed */
98         int* outgoing_avail_ports;
99
100         /** EDNS buffer size to use */
101         size_t edns_buffer_size;
102         /** number of bytes buffer size for DNS messages */
103         size_t msg_buffer_size;
104         /** size of the message cache */
105         size_t msg_cache_size;
106         /** slabs in the message cache. */
107         size_t msg_cache_slabs;
108         /** number of queries every thread can service */
109         size_t num_queries_per_thread;
110         /** number of msec to wait before items can be jostled out */
111         size_t jostle_time;
112         /** size of the rrset cache */
113         size_t rrset_cache_size;
114         /** slabs in the rrset cache */
115         size_t rrset_cache_slabs;
116         /** host cache ttl in seconds */
117         int host_ttl;
118         /** number of slabs in the infra host cache */
119         size_t infra_cache_slabs;
120         /** max number of hosts in the infra cache */
121         size_t infra_cache_numhosts;
122         /** min value for infra cache rtt */
123         int infra_cache_min_rtt;
124         /** delay close of udp-timeouted ports, if 0 no delayclose. in msec */
125         int delay_close;
126
127         /** the target fetch policy for the iterator */
128         char* target_fetch_policy;
129
130         /** automatic interface for incoming messages. Uses ipv6 remapping,
131          * and recvmsg/sendmsg ancillary data to detect interfaces, boolean */
132         int if_automatic;
133         /** SO_RCVBUF size to set on port 53 UDP socket */
134         size_t so_rcvbuf;
135         /** SO_SNDBUF size to set on port 53 UDP socket */
136         size_t so_sndbuf;
137         /** SO_REUSEPORT requested on port 53 sockets */
138         int so_reuseport;
139         /** IP_TRANSPARENT socket option requested on port 53 sockets */
140         int ip_transparent;
141
142         /** number of interfaces to open. If 0 default all interfaces. */
143         int num_ifs;
144         /** interface description strings (IP addresses) */
145         char **ifs;
146
147         /** number of outgoing interfaces to open. 
148          * If 0 default all interfaces. */
149         int num_out_ifs;
150         /** outgoing interface description strings (IP addresses) */
151         char **out_ifs;
152
153         /** the root hints */
154         struct config_strlist* root_hints;
155         /** the stub definitions, linked list */
156         struct config_stub* stubs;
157         /** the forward zone definitions, linked list */
158         struct config_stub* forwards;
159         /** list of donotquery addresses, linked list */
160         struct config_strlist* donotqueryaddrs;
161         /** list of access control entries, linked list */
162         struct config_str2list* acls;
163         /** use default localhost donotqueryaddr entries */
164         int donotquery_localhost;
165
166         /** harden against very small edns buffer sizes */
167         int harden_short_bufsize;
168         /** harden against very large query sizes */
169         int harden_large_queries;
170         /** harden against spoofed glue (out of zone data) */
171         int harden_glue;
172         /** harden against receiving no DNSSEC data for trust anchor */
173         int harden_dnssec_stripped;
174         /** harden against queries that fall under known nxdomain names */
175         int harden_below_nxdomain;
176         /** harden the referral path, query for NS,A,AAAA and validate */
177         int harden_referral_path;
178         /** harden against algorithm downgrade */
179         int harden_algo_downgrade;
180         /** use 0x20 bits in query as random ID bits */
181         int use_caps_bits_for_id;
182         /** 0x20 whitelist, domains that do not use capsforid */
183         struct config_strlist* caps_whitelist;
184         /** strip away these private addrs from answers, no DNS Rebinding */
185         struct config_strlist* private_address;
186         /** allow domain (and subdomains) to use private address space */
187         struct config_strlist* private_domain;
188         /** what threshold for unwanted action. */
189         size_t unwanted_threshold;
190         /** the number of seconds maximal TTL used for RRsets and messages */
191         int max_ttl;
192         /** the number of seconds minimum TTL used for RRsets and messages */
193         int min_ttl;
194         /** the number of seconds maximal negative TTL for SOA in auth */
195         int max_negative_ttl;
196         /** if prefetching of messages should be performed. */
197         int prefetch;
198         /** if prefetching of DNSKEYs should be performed. */
199         int prefetch_key;
200
201         /** chrootdir, if not "" or chroot will be done */
202         char* chrootdir;
203         /** username to change to, if not "". */
204         char* username;
205         /** working directory */
206         char* directory;
207         /** filename to log to. */
208         char* logfile;
209         /** pidfile to write pid to. */
210         char* pidfile;
211
212         /** should log messages be sent to syslogd */
213         int use_syslog;
214         /** log timestamp in ascii UTC */
215         int log_time_ascii;
216         /** log queries with one line per query */
217         int log_queries;
218
219         /** do not report identity (id.server, hostname.bind) */
220         int hide_identity;
221         /** do not report version (version.server, version.bind) */
222         int hide_version;
223         /** identity, hostname is returned if "". */
224         char* identity;
225         /** version, package version returned if "". */
226         char* version;
227
228         /** the module configuration string */
229         char* module_conf;
230         
231         /** files with trusted DS and DNSKEYs in zonefile format, list */
232         struct config_strlist* trust_anchor_file_list;
233         /** list of trustanchor keys, linked list */
234         struct config_strlist* trust_anchor_list;
235         /** files with 5011 autotrust tracked keys */
236         struct config_strlist* auto_trust_anchor_file_list;
237         /** files with trusted DNSKEYs in named.conf format, list */
238         struct config_strlist* trusted_keys_file_list;
239         /** DLV anchor file */
240         char* dlv_anchor_file;
241         /** DLV anchor inline */
242         struct config_strlist* dlv_anchor_list;
243         /** insecure domain list */
244         struct config_strlist* domain_insecure;
245
246         /** if not 0, this value is the validation date for RRSIGs */
247         int32_t val_date_override;
248         /** the minimum for signature clock skew */
249         int32_t val_sig_skew_min;
250         /** the maximum for signature clock skew */
251         int32_t val_sig_skew_max;
252         /** this value sets the number of seconds before revalidating bogus */
253         int bogus_ttl; 
254         /** should validator clean additional section for secure msgs */
255         int val_clean_additional;
256         /** log bogus messages by the validator */
257         int val_log_level;
258         /** squelch val_log_level to log - this is library goes to callback */
259         int val_log_squelch;
260         /** should validator allow bogus messages to go through */
261         int val_permissive_mode;
262         /** ignore the CD flag in incoming queries and refuse them bogus data */
263         int ignore_cd;
264         /** nsec3 maximum iterations per key size, string */
265         char* val_nsec3_key_iterations;
266         /** autotrust add holddown time, in seconds */
267         unsigned int add_holddown;
268         /** autotrust del holddown time, in seconds */
269         unsigned int del_holddown;
270         /** autotrust keep_missing time, in seconds. 0 is forever. */
271         unsigned int keep_missing;
272         /** permit small holddown values, allowing 5011 rollover very fast */
273         int permit_small_holddown;
274
275         /** size of the key cache */
276         size_t key_cache_size;
277         /** slabs in the key cache. */
278         size_t key_cache_slabs;
279         /** size of the neg cache */
280         size_t neg_cache_size;
281
282         /** local zones config */
283         struct config_str2list* local_zones;
284         /** local zones nodefault list */
285         struct config_strlist* local_zones_nodefault;
286         /** local data RRs configured */
287         struct config_strlist* local_data;
288         /** unblock lan zones (reverse lookups for 10/8 and so on) */
289         int unblock_lan_zones;
290
291         /** remote control section. enable toggle. */
292         int remote_control_enable;
293         /** the interfaces the remote control should listen on */
294         struct config_strlist* control_ifs;
295         /** port number for the control port */
296         int control_port;
297         /** use certificates for remote control */
298         int remote_control_use_cert;
299         /** private key file for server */
300         char* server_key_file;
301         /** certificate file for server */
302         char* server_cert_file;
303         /** private key file for unbound-control */
304         char* control_key_file;
305         /** certificate file for unbound-control */
306         char* control_cert_file;
307
308         /** Python script file */
309         char* python_script;
310
311         /** daemonize, i.e. fork into the background. */
312         int do_daemonize;
313
314         /* minimal response when positive answer */
315         int minimal_responses;
316
317         /* RRSet roundrobin */
318         int rrset_roundrobin;
319
320         /* maximum UDP response size */
321         size_t max_udp_size;
322
323         /* DNS64 prefix */
324         char* dns64_prefix;
325
326         /* Synthetize all AAAA record despite the presence of an authoritative one */
327         int dns64_synthall;
328
329         /** true to enable dnstap support */
330         int dnstap;
331         /** dnstap socket path */
332         char* dnstap_socket_path;
333         /** true to send "identity" via dnstap */
334         int dnstap_send_identity;
335         /** true to send "version" via dnstap */
336         int dnstap_send_version;
337         /** dnstap "identity", hostname is used if "". */
338         char* dnstap_identity;
339         /** dnstap "version", package version is used if "". */
340         char* dnstap_version;
341
342         /** true to log dnstap RESOLVER_QUERY message events */
343         int dnstap_log_resolver_query_messages;
344         /** true to log dnstap RESOLVER_RESPONSE message events */
345         int dnstap_log_resolver_response_messages;
346         /** true to log dnstap CLIENT_QUERY message events */
347         int dnstap_log_client_query_messages;
348         /** true to log dnstap CLIENT_RESPONSE message events */
349         int dnstap_log_client_response_messages;
350         /** true to log dnstap FORWARDER_QUERY message events */
351         int dnstap_log_forwarder_query_messages;
352         /** true to log dnstap FORWARDER_RESPONSE message events */
353         int dnstap_log_forwarder_response_messages;
354
355         /** ratelimit 0 is off, otherwise qps (unless overridden) */
356         int ratelimit;
357         /** number of slabs for ratelimit cache */
358         size_t ratelimit_slabs;
359         /** memory size in bytes for ratelimit cache */
360         size_t ratelimit_size;
361         /** ratelimits for domain (exact match) */
362         struct config_str2list* ratelimit_for_domain;
363         /** ratelimits below domain */
364         struct config_str2list* ratelimit_below_domain;
365         /** ratelimit factor, 0 blocks all, 10 allows 1/10 of traffic */
366         int ratelimit_factor;
367         /** minimise outgoing QNAME and hide original QTYPE if possible */
368         int qname_minimisation;
369 };
370
371 /** from cfg username, after daemonise setup performed */
372 extern uid_t cfg_uid;
373 /** from cfg username, after daemonise setup performed */
374 extern gid_t cfg_gid;
375 /** debug and enable small timeouts */
376 extern int autr_permit_small_holddown;
377
378 /**
379  * Stub config options
380  */
381 struct config_stub {
382         /** next in list */
383         struct config_stub* next;
384         /** domain name (in text) of the stub apex domain */
385         char* name;
386         /** list of stub nameserver hosts (domain name) */
387         struct config_strlist* hosts;
388         /** list of stub nameserver addresses (IP address) */
389         struct config_strlist* addrs;
390         /** if stub-prime is set */
391         int isprime;
392         /** if forward-first is set (failover to without if fails) */
393         int isfirst;
394 };
395
396 /**
397  * List of strings for config options
398  */
399 struct config_strlist {
400         /** next item in list */
401         struct config_strlist* next;
402         /** config option string */
403         char* str;
404 };
405
406 /**
407  * List of two strings for config options
408  */
409 struct config_str2list {
410         /** next item in list */
411         struct config_str2list* next;
412         /** first string */
413         char* str;
414         /** second string */
415         char* str2;
416 };
417
418 /** List head for strlist processing, used for append operation. */
419 struct config_strlist_head {
420         /** first in list of text items */
421         struct config_strlist* first;
422         /** last in list of text items */
423         struct config_strlist* last;
424 };
425
426 /**
427  * Create config file structure. Filled with default values.
428  * @return: the new structure or NULL on memory error.
429  */
430 struct config_file* config_create(void);
431
432 /**
433  * Create config file structure for library use. Filled with default values.
434  * @return: the new structure or NULL on memory error.
435  */
436 struct config_file* config_create_forlib(void);
437
438 /**
439  * Read the config file from the specified filename.
440  * @param config: where options are stored into, must be freshly created.
441  * @param filename: name of configfile. If NULL nothing is done.
442  * @param chroot: if not NULL, the chroot dir currently in use (for include).
443  * @return: false on error. In that case errno is set, ENOENT means 
444  *      file not found.
445  */
446 int config_read(struct config_file* config, const char* filename,
447         const char* chroot);
448
449 /**
450  * Destroy the config file structure.
451  * @param config: to delete.
452  */
453 void config_delete(struct config_file* config);
454
455 /**
456  * Apply config to global constants; this routine is called in single thread.
457  * @param config: to apply. Side effect: global constants change.
458  */
459 void config_apply(struct config_file* config);
460
461 /**
462  * Find username, sets cfg_uid and cfg_gid.
463  * @param config: the config structure.
464  */
465 void config_lookup_uid(struct config_file* config);
466
467 /**
468  * Set the given keyword to the given value.
469  * @param config: where to store config
470  * @param option: option name, including the ':' character.
471  * @param value: value, this string is copied if needed, or parsed.
472  *      The caller owns the value string.
473  * @return 0 on error (malloc or syntax error).
474  */
475 int config_set_option(struct config_file* config, const char* option,
476         const char* value);
477
478 /** 
479  * Call print routine for the given option.
480  * @param cfg: config.
481  * @param opt: option name without trailing :. 
482  *      This is different from config_set_option.
483  * @param func: print func, called as (str, arg) for every data element.
484  * @param arg: user argument for print func.
485  * @return false if the option name is not supported (syntax error).
486  */
487 int config_get_option(struct config_file* cfg, const char* opt, 
488         void (*func)(char*,void*), void* arg);
489
490 /**
491  * Get an option and return strlist
492  * @param cfg: config file
493  * @param opt: option name.
494  * @param list: list is returned here. malloced, caller must free it.
495  * @return 0=OK, 1=syntax error, 2=malloc failed.
496  */
497 int config_get_option_list(struct config_file* cfg, const char* opt,
498         struct config_strlist** list);
499
500 /**
501  * Get an option and collate results into string
502  * @param cfg: config file
503  * @param opt: option name.
504  * @param str: string. malloced, caller must free it.
505  * @return 0=OK, 1=syntax error, 2=malloc failed.
506  */
507 int config_get_option_collate(struct config_file* cfg, const char* opt, 
508         char** str);
509
510 /**
511  * function to print to a file, use as func with config_get_option.
512  * @param line: text to print. \n appended.
513  * @param arg: pass a FILE*, like stdout.
514  */
515 void config_print_func(char* line, void* arg);
516
517 /**
518  * function to collate the text strings into a strlist_head.
519  * @param line: text to append.
520  * @param arg: pass a strlist_head structure. zeroed on start.
521  */
522 void config_collate_func(char* line, void* arg);
523
524 /**
525  * take a strlist_head list and return a malloc string. separated with newline.
526  * @param list: strlist first to collate. zeroes return "".
527  * @return NULL on malloc failure. Or if malloc failure happened in strlist.
528  */
529 char* config_collate_cat(struct config_strlist* list);
530
531 /**
532  * Append text at end of list.
533  * @param list: list head. zeroed at start.
534  * @param item: new item. malloced by caller. if NULL the insertion fails.
535  * @return true on success.
536  */
537 int cfg_strlist_append(struct config_strlist_head* list, char* item);
538
539 /**
540  * Insert string into strlist.
541  * @param head: pointer to strlist head variable.
542  * @param item: new item. malloced by caller. If NULL the insertion fails.
543  * @return: true on success.
544  */
545 int cfg_strlist_insert(struct config_strlist** head, char* item);
546
547 /**
548  * Insert string into str2list.
549  * @param head: pointer to str2list head variable.
550  * @param item: new item. malloced by caller. If NULL the insertion fails.
551  * @param i2: 2nd string, malloced by caller. If NULL the insertion fails.
552  * @return: true on success.
553  */
554 int cfg_str2list_insert(struct config_str2list** head, char* item, char* i2);
555
556 /**
557  * Delete items in config string list.
558  * @param list: list.
559  */
560 void config_delstrlist(struct config_strlist* list);
561
562 /**
563  * Delete items in config double string list.
564  * @param list: list.
565  */
566 void config_deldblstrlist(struct config_str2list* list);
567
568 /**
569  * Delete items in config stub list.
570  * @param list: list.
571  */
572 void config_delstubs(struct config_stub* list);
573
574 /**
575  * Convert 14digit to time value
576  * @param str: string of 14 digits
577  * @return time value or 0 for error.
578  */
579 time_t cfg_convert_timeval(const char* str);
580
581 /**
582  * Count number of values in the string.
583  * format ::= (sp num)+ sp
584  * num ::= [-](0-9)+
585  * sp ::= (space|tab)*
586  *
587  * @param str: string
588  * @return: 0 on parse error, or empty string, else
589  *      number of integer values in the string.
590  */
591 int cfg_count_numbers(const char* str);
592
593 /**
594  * Convert a 'nice' memory or file size into a bytecount
595  * From '100k' to 102400. and so on. Understands kKmMgG.
596  * k=1024, m=1024*1024, g=1024*1024*1024.
597  * @param str: string
598  * @param res: result is stored here, size in bytes.
599  * @return: true if parsed correctly, or 0 on a parse error (and an error 
600  * is logged).
601  */
602 int cfg_parse_memsize(const char* str, size_t* res);
603
604 /**
605  * Parse local-zone directive into two strings and register it in the config.
606  * @param cfg: to put it in.
607  * @param val: argument strings to local-zone, "example.com nodefault".
608  * @return: false on failure
609  */
610 int cfg_parse_local_zone(struct config_file* cfg, const char* val);
611
612 /**
613  * Mark "number" or "low-high" as available or not in ports array.
614  * @param str: string in input
615  * @param allow: give true if this range is permitted.
616  * @param avail: the array from cfg.
617  * @param num: size of the array (65536).
618  * @return: true if parsed correctly, or 0 on a parse error (and an error 
619  * is logged).
620  */
621 int cfg_mark_ports(const char* str, int allow, int* avail, int num);
622
623 /**
624  * Get a condensed list of ports returned. allocated.
625  * @param cfg: config file.
626  * @param avail: the available ports array is returned here.
627  * @return: number of ports in array or 0 on error.
628  */
629 int cfg_condense_ports(struct config_file* cfg, int** avail);
630
631 /**
632  * Scan ports available
633  * @param avail: the array from cfg.
634  * @param num: size of the array (65536).
635  * @return the number of ports available for use.
636  */
637 int cfg_scan_ports(int* avail, int num);
638
639 /** 
640  * Convert a filename to full pathname in original filesys
641  * @param fname: the path name to convert.
642  *      Must not be null or empty.
643  * @param cfg: config struct for chroot and chdir (if set).
644  * @param use_chdir: if false, only chroot is applied.
645  * @return pointer to malloced buffer which is: [chroot][chdir]fname
646  *      or NULL on malloc failure.
647  */
648 char* fname_after_chroot(const char* fname, struct config_file* cfg, 
649         int use_chdir);
650
651 /**
652  * Convert a ptr shorthand into a full reverse-notation PTR record.
653  * @param str: input string, "IP name"
654  * @return: malloced string "reversed-ip-name PTR name"
655  */
656 char* cfg_ptr_reverse(char* str);
657
658 /**
659  * Append text to the error info for validation.
660  * @param qstate: query state.
661  * @param str: copied into query region and appended.
662  * Failures to allocate are logged.
663  */
664 void errinf(struct module_qstate* qstate, const char* str);
665
666 /**
667  * Append text to error info:  from 1.2.3.4
668  * @param qstate: query state.
669  * @param origin: sock list with origin of trouble. 
670  *      Every element added.
671  *      If NULL: nothing is added.
672  *      if 0len element: 'from cache' is added.
673  */
674 void errinf_origin(struct module_qstate* qstate, struct sock_list *origin);
675
676 /**
677  * Append text to error info:  for RRset name type class
678  * @param qstate: query state.
679  * @param rr: rrset_key.
680  */
681 void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr);
682
683 /**
684  * Append text to error info:  str dname
685  * @param qstate: query state.
686  * @param str: explanation string
687  * @param dname: the dname.
688  */
689 void errinf_dname(struct module_qstate* qstate, const char* str, 
690         uint8_t* dname);
691
692 /**
693  * Create error info in string
694  * @param qstate: query state.
695  * @return string or NULL on malloc failure (already logged).
696  *    This string is malloced and has to be freed by caller.
697  */
698 char* errinf_to_str(struct module_qstate* qstate);
699
700 /**
701  * Used during options parsing
702  */
703 struct config_parser_state {
704         /** name of file being parser */
705         char* filename;
706         /** line number in the file, starts at 1 */
707         int line;
708         /** number of errors encountered */
709         int errors;
710         /** the result of parsing is stored here. */
711         struct config_file* cfg;
712         /** the current chroot dir (or NULL if none) */
713         const char* chroot;
714 };
715
716 /** global config parser object used during config parsing */
717 extern struct config_parser_state* cfg_parser;
718 /** init lex state */
719 void init_cfg_parse(void);
720 /** lex in file */
721 extern FILE* ub_c_in;
722 /** lex out file */
723 extern FILE* ub_c_out;
724 /** the yacc lex generated parse function */
725 int ub_c_parse(void);
726 /** the lexer function */
727 int ub_c_lex(void);
728 /** wrap function */
729 int ub_c_wrap(void);
730 /** parsing helpers: print error with file and line numbers */
731 void ub_c_error(const char* msg);
732 /** parsing helpers: print error with file and line numbers */
733 void ub_c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2);
734
735 #ifdef UB_ON_WINDOWS
736 /**
737  * Obtain registry string (if it exists).
738  * @param key: key string
739  * @param name: name of value to fetch.
740  * @return malloced string with the result or NULL if it did not
741  *      exist on an error (logged with log_err) was encountered.
742  */
743 char* w_lookup_reg_str(const char* key, const char* name);
744
745 /** Modify directory in options for module file name */
746 void w_config_adjust_directory(struct config_file* cfg);
747 #endif /* UB_ON_WINDOWS */
748
749 #endif /* UTIL_CONFIG_FILE_H */