OpenDNSSEC-enforcer  1.4.1
kc_helper.h
Go to the documentation of this file.
1 /*
2  * $Id: kc_helper.h 6293 2012-04-30 14:48:01Z sion $
3  *
4  * Copyright (c) 2012 Nominet UK. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef KC_HELPER_H
29 #define KC_HELPER_H
30 
31 #ifdef LOG_DAEMON
32 #define DEFAULT_LOG_FACILITY LOG_DAEMON
33 #define DEFAULT_LOG_FACILITY_STRING "LOG_DAEMON"
34 #else
35 #define DEFAULT_LOG_FACILITY LOG_USER
36 #define DEFAULT_LOG_FACILITY_STRING "LOG_USER"
37 #endif /* LOG_DAEMON */
38 
39 #include <libxml/xpath.h>
40 
41 #define KC_NAME_LENGTH 256
42 
43 void log_init(int facility, const char *program_name);
44 void log_switch(int facility, const char *program_name);
45 void dual_log(const char *format, ...);
46 
47 int check_rng(const char *filename, const char *rngfilename);
48 
49 int check_file(const char *filename, const char *log_string);
50 int check_file_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr);
51 
52 int check_path(const char *pathname, const char *log_string);
53 int check_path_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr);
54 
55 int check_user_group(xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr);
56 
57 int check_time_def(const char *time_expr, const char *location, const char *field, const char *filename, int* interval);
58 int check_time_def_from_xpath(xmlXPathContextPtr xpath_ctx, const xmlChar *time_xexpr, const char *location, const char *field, const char *filename);
59 
60 int check_policy(xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp);
61 
62 int DtXMLIntervalSeconds(const char* text, int* interval);
63 int StrStrtoi(const char* string, int* value);
64 int StrStrtol(const char* string, long* value);
65 char* StrStrdup(const char* string);
66 void StrAppend(char** str1, const char* str2);
67 void StrTrimR(char *text);
68 char* StrTrimL(char* text);
69 void* MemCalloc(size_t nmemb, size_t size);
70 void* MemRealloc(void *ptr, size_t size);
71 
72 
73 #endif /* KC_HELPER_H */