kc_helper.h
Go to the documentation of this file.
/*
* Copyright (c) 2012 Nominet UK. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KC_HELPER_H
#define KC_HELPER_H
#ifdef LOG_DAEMON
#define DEFAULT_LOG_FACILITY LOG_DAEMON
#define DEFAULT_LOG_FACILITY_STRING "LOG_DAEMON"
#else
#define DEFAULT_LOG_FACILITY LOG_USER
#define DEFAULT_LOG_FACILITY_STRING "LOG_USER"
#endif /* LOG_DAEMON */
#include "config.h"
#include <libxml/xpath.h>
#define KC_NAME_LENGTH 256
typedef struct {
char *name;
char *module;
char *TokenLabel;
} KC_REPO;
extern int check_conf(const char *conf, char **kasp, char **zonelist,
char ***repo_listout, int *repo_countout, int verbose);
extern int check_kasp(const char *kasp, char **repo_list, int repo_count, int verbose,
char ***policy_names_out, int *policy_count_out);
extern int check_zonelist(const char *zonelist, int verbose, char **policy_names,
int policy_count);
extern void log_init(int facility, const char *program_name);
extern void log_switch(int facility, const char *program_name);
extern void dual_log(const char *format, ...)
#ifdef HAVE___ATTRIBUTE__
__attribute__ ((format (printf, 1, 2)))
#endif
;
extern int check_rng(const char *filename, const char *rngfilename, int verbose);
extern int check_file(const char *filename, const char *log_string);
extern int check_file_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr);
extern int check_path(const char *pathname, const char *log_string);
extern int check_path_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr);
extern int check_user_group(xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr);
extern int check_time_def(const char *time_expr, const char *location, const char *field, const char *filename, int* interval);
extern int check_time_def_from_xpath(xmlXPathContextPtr xpath_ctx, const xmlChar *time_xexpr, const char *location, const char *field, const char *filename);
/* if repo_list NULL, will skip the check to see all repositories in kasp are available in conf */
extern int check_policy(xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp);
extern int DtXMLIntervalSeconds(const char* text, int* interval);
extern int StrStrtoi(const char* string, int* value);
extern int StrStrtol(const char* string, long* value);
extern char* StrStrdup(const char* string);
extern void StrTrimR(char *text);
extern char* StrTrimL(char* text);
extern void* MemCalloc(size_t nmemb, size_t size);
#endif /* KC_HELPER_H */
check_time_def
int check_time_def(const char *time_expr, const char *location, const char *field, const char *filename, int *interval)
Definition kc_helper.c:352
check_user_group
int check_user_group(xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr)
Definition kc_helper.c:302
log_init
void log_init(int facility, const char *program_name)
Definition kc_helper.c:55
check_kasp
int check_kasp(const char *kasp, char **repo_list, int repo_count, int verbose, char ***policy_names_out, int *policy_count_out)
Definition kc_helper.c:1776
check_path
int check_path(const char *pathname, const char *log_string)
Definition kc_helper.c:253
StrStrdup
char * StrStrdup(const char *string)
Definition kc_helper.c:1293
check_rng
int check_rng(const char *filename, const char *rngfilename, int verbose)
Definition kc_helper.c:92
check_policy
int check_policy(xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp)
Definition kc_helper.c:412
log_switch
void log_switch(int facility, const char *program_name)
MemCalloc
void * MemCalloc(size_t nmemb, size_t size)
Definition kc_helper.c:1400
check_path_from_xpath
int check_path_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr)
Definition kc_helper.c:276
StrStrtol
int StrStrtol(const char *string, long *value)
Definition kc_helper.c:1239
check_time_def_from_xpath
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:389
dual_log
void dual_log(const char *format,...)
Definition kc_helper.c:63
StrStrtoi
int StrStrtoi(const char *string, int *value)
Definition kc_helper.c:1195
check_zonelist
int check_zonelist(const char *zonelist, int verbose, char **policy_names, int policy_count)
Definition kc_helper.c:1700
StrTrimL
char * StrTrimL(char *text)
Definition kc_helper.c:1389
StrTrimR
void StrTrimR(char *text)
Definition kc_helper.c:1351
DtXMLIntervalSeconds
int DtXMLIntervalSeconds(const char *text, int *interval)
Definition kc_helper.c:1059
check_conf
int check_conf(const char *conf, char **kasp, char **zonelist, char ***repo_listout, int *repo_countout, int verbose)
Definition kc_helper.c:1422
check_file_from_xpath
int check_file_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr)
Definition kc_helper.c:220
check_file
int check_file(const char *filename, const char *log_string)
Definition kc_helper.c:196
policy_name
const char * policy_name(const policy_t *policy)
Definition policy.c:813
KC_REPO
Definition kc_helper.h:42
KC_REPO::TokenLabel
char * TokenLabel
Definition kc_helper.h:45
KC_REPO::module
char * module
Definition kc_helper.h:44
KC_REPO::name
char * name
Definition kc_helper.h:43