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