aboutsummaryrefslogtreecommitdiff
path: root/src/nssync.h
blob: 7304e14c001e8a4052152fb4950c2bb854b61cb6 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* This file is part of NSsync 
   Copyright (C) 2011 Sergey Poznyakoff
  
   NSsync is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
  
   NSsync is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License
   along with NSsync.  If not, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sysexits.h>
#include <errno.h>

#include <grecs.h>
#include <wordsplit.h>
#include <mysql/mysql.h>

extern int lint_mode;
extern int dry_run_mode;
extern int preprocess_only;
extern int debug_level;
extern char *config_file;
extern char *slave_status_file;
extern char *pidfile;
extern char *tempdir;
extern char *compare_command;
extern char *reload_command;

extern unsigned changed_zones;

extern char *sql_config_file;
extern char *sql_config_group;
extern char *database_name;
extern char *sql_host;
extern char *sql_socket;
extern char *sql_user;
extern char *sql_password;
extern char *sql_cacert;
extern int sql_port;

extern char *named_conf_file;
extern struct grecs_list *bind_include_path;

extern char *zone_file_pattern;
extern char *zone_conf_file;
extern char *bind_working_dir;

extern struct grecs_list *synclist;

extern unsigned error_count;
extern unsigned changed_zones;

extern int debug_level;

#define debug(n,s)				\
	do {					\
		if ((n) <= debug_level)		\
			debug_printf s;		\
	} while (0)

#ifndef __PRINTFLIKE
# define __PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg)))
#endif

void config_init(void);
void config_parse(void);
void config_help(void);

void verror(const char *fmt, va_list ap);
void error(const char *fmt, ...) __PRINTFLIKE(1,2);
void debug_printf(const char *fmt, ...) __PRINTFLIKE(1,2);

void sql_connect(void);
void sql_disconnect(void);
int sql_do_query(const char *query, 
		 int (*fun)(MYSQL_ROW, unsigned, void*), void *data);
int sql_get_slave_status(char **pfile, char **poff);

struct nssync {
	char *tag;
	char *zone_conf_file;
	char *zone_file_pattern;
	struct grecs_node *zone_tree;
	
	char *soa_query;
	char *rr_query;
	char *rev_rr_query;
	char *ns_query;
	
	char *file_name;
	char *temp_file_name;
	FILE *fp;
};

void format_zones(struct nssync *);

void source_named_conf(void);
char *bindcf_lookup(struct nssync *sp, const char *zone);
void flush_zone_list(struct nssync *sp);

int compare(const char *oldfile, const char *newfile);
int move_file(const char *file, const char *dst_file);

	

Return to:

Send suggestions and report system problems to the System administrator.