-
Notifications
You must be signed in to change notification settings - Fork 1
/
globals.h
67 lines (58 loc) · 2.15 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (c) 2014-2020 by Farsight Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GLOBALS_H_INCLUDED
#define GLOBALS_H_INCLUDED 1
#ifdef MAIN_PROGRAM
#define EXTERN
#define INIT(...) = __VA_ARGS__
#else
#define EXTERN extern
#define INIT(...)
#endif
EXTERN const char id_swclient[] INIT("dnsdbflex");
EXTERN const char id_version[] INIT("1.0.7");
EXTERN const char *program_name INIT(NULL);
EXTERN const char jsonl_header[] INIT("Accept: application/x-ndjson");
EXTERN const char env_config_file[] INIT("DNSDBQ_CONFIG_FILE");
EXTERN const char env_timeout[] INIT("DNSDBFLEX_TIMEOUT");
EXTERN const char status_noerror[] INIT("NOERROR");
EXTERN const char status_error[] INIT("ERROR");
EXTERN pdns_system_ct psys INIT(NULL);
EXTERN int debug_level INIT(0);
EXTERN bool donotverify INIT(false);
EXTERN bool quiet INIT(false);
EXTERN present_e presentation INIT(pres_json);
EXTERN present_t presenter INIT(NULL);
EXTERN struct timeval startup_time INIT({});
EXTERN int exit_code INIT(0);
EXTERN long curl_ipresolve INIT(CURL_IPRESOLVE_WHATEVER);
EXTERN long curl_timeout INIT(0L);
#undef INIT
#undef EXTERN
/* maximum length of a regular expression or glob or exclusion */
#define MAX_VALUE_LEN 4096
__attribute__((noreturn)) void my_exit(int);
__attribute__((noreturn)) void my_panic(bool, const char *);
/* my_logf -- annotate to stderr with program name and current time */
static inline void
my_logf(const char *fmtstr, ...) {
va_list ap;
va_start(ap, fmtstr);
fprintf(stderr, "%s [%s]: ", program_name, timeval_str(NULL, true));
vfprintf(stderr, fmtstr, ap);
putc('\n', stderr);
}
#endif /*GLOBALS_H_INCLUDED*/