kc_helper.c File Reference
`#include <syslog.h>`
`#include <stdarg.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <errno.h>`
`#include <pwd.h>`
`#include <grp.h>`
`#include <limits.h>`
`#include <ctype.h>`
`#include "config.h"`
`#include "kc_helper.h"`
`#include <libxml/tree.h>`
`#include <libxml/parser.h>`
`#include <libxml/xpath.h>`
`#include <libxml/xpathInternals.h>`
`#include <libxml/relaxng.h>`

Go to the source code of this file.

## Macros

#define | _GNU_SOURCE
#define | StrFree(ptr)

## Functions

void | log_init (int facility, const char *program_name)
void | dual_log (const char *format,...)
int | check_rng (const char *filename, const char *rngfilename, int verbose)
int | check_file (const char *filename, const char *log_string)
int | check_file_from_xpath (xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr)
int | check_path (const char *pathname, const char *log_string)
int | check_path_from_xpath (xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr)
int | check_user_group (xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr)
int | check_time_def (const char *time_expr, const char *location, const char *field, const char *filename, int *interval)
int | check_time_def_from_xpath (xmlXPathContextPtr xpath_ctx, const xmlChar *time_xexpr, const char *location, const char *field, const char *filename)
int | check_policy (xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp)
int | DtXMLIntervalSeconds (const char *text, int *interval)
int | StrStrtoi (const char *string, int *value)
int | StrStrtol (const char *string, long *value)
char * | StrStrdup (const char *string)
void | StrTrimR (char *text)
char * | StrTrimL (char *text)
void * | MemCalloc (size_t nmemb, size_t size)
int | check_conf (const char *conf, char **kasp, char **zonelist, char ***repo_listout, int *repo_countout, int verbose)
int | check_zonelist (const char *zonelist, int verbose, char **policy_names, int policy_count)
int | check_kasp (const char *kasp, char **repo_list, int repo_count, int verbose, char ***policy_names_out, int *policy_count_out)

## Variables

int | kc_helper_printto_stdout = 0

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 26 of file kc_helper.c.

## StrFree

#define StrFree | ( |  | ptr | ) |

Value:
{if(ptr != NULL) {free(ptr); (ptr) = NULL;}}

Definition at line 51 of file kc_helper.c.

Referenced by check_conf(), check_file_from_xpath(), check_path_from_xpath(), check_policy(), check_time_def_from_xpath(), check_user_group(), and StrStrtol().

## Function Documentation

## check_conf()

int check_conf | ( | const char * | conf,
|  | char ** | kasp,
|  | char ** | zonelist,
|  | char *** | repo_listout,
|  | int * | repo_countout,
|  | int | verbose )

Check the conf.xml file

Parameters

  conf | config file to validate
  kasp[in,out] | if NULL, will set it to kasp.xml found in config
  zonelist[in,out] | if NULL, will set it to zonelist.xml found in config

Returns
  status (0 == success; 1 == error)

Definition at line 1422 of file kc_helper.c.

References check_file(), check_file_from_xpath(), check_path(), check_path_from_xpath(), check_rng(), check_time_def_from_xpath(), check_user_group(), dual_log(), kc_helper_printto_stdout, KC_REPO::module, KC_REPO::name, StrFree, StrStrdup(), and KC_REPO::TokenLabel.

Referenced by main().

## check_file()

int check_file | ( | const char * | filename,
|  | const char * | log_string )

Definition at line 196 of file kc_helper.c.

References dual_log().

Referenced by check_conf(), check_file_from_xpath(), and check_rng().

## check_file_from_xpath()

int check_file_from_xpath | ( | xmlXPathContextPtr | xpath_ctx,
|  | const char * | log_string,
|  | const xmlChar * | file_xexpr )

Definition at line 220 of file kc_helper.c.

References check_file(), dual_log(), and StrFree.

Referenced by check_conf().

## 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 at line 1776 of file kc_helper.c.

References check_policy(), check_rng(), dual_log(), and kc_helper_printto_stdout.

Referenced by main(), policy_export(), policy_export_all(), and policy_import().

## check_path()

int check_path | ( | const char * | pathname,
|  | const char * | log_string )

Definition at line 253 of file kc_helper.c.

References dual_log().

Referenced by check_conf(), and check_path_from_xpath().

## check_path_from_xpath()

int check_path_from_xpath | ( | xmlXPathContextPtr | xpath_ctx,
|  | const char * | log_string,
|  | const xmlChar * | path_xexpr )

Definition at line 276 of file kc_helper.c.

References check_path(), dual_log(), and StrFree.

Referenced by check_conf().

## check_policy()

int check_policy | ( | xmlNode * | curNode,
|  | const char * | policy_name,
|  | char ** | repo_list,
|  | int | repo_count,
|  | const char * | kasp )

Definition at line 412 of file kc_helper.c.

References check_time_def(), dual_log(), KC_NAME_LENGTH, policy_name(), StrFree, and StrStrtoi().

Referenced by check_kasp().

## check_rng()

int check_rng | ( | const char * | filename,
|  | const char * | rngfilename,
|  | int | verbose )

Definition at line 92 of file kc_helper.c.

References check_file(), and dual_log().

Referenced by check_conf(), check_kasp(), and check_zonelist().

## check_time_def()

int check_time_def | ( | const char * | time_expr,
|  | const char * | location,
|  | const char * | field,
|  | const char * | filename,
|  | int * | interval )

Definition at line 352 of file kc_helper.c.

References DtXMLIntervalSeconds(), and dual_log().

Referenced by check_policy(), and check_time_def_from_xpath().

## 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 at line 389 of file kc_helper.c.

References check_time_def(), dual_log(), and StrFree.

Referenced by check_conf().

## check_user_group()

int check_user_group | ( | xmlXPathContextPtr | xpath_ctx,
|  | const xmlChar * | user_xexpr,
|  | const xmlChar * | group_xexpr )

Definition at line 302 of file kc_helper.c.

References dual_log(), and StrFree.

Referenced by check_conf().

## check_zonelist()

int check_zonelist | ( | const char * | zonelist,
|  | int | verbose,
|  | char ** | policy_names,
|  | int | policy_count )

Definition at line 1700 of file kc_helper.c.

References check_rng(), dual_log(), kc_helper_printto_stdout, and policy_name().

Referenced by main(), zonelist_export(), and zonelist_import().

## DtXMLIntervalSeconds()

int DtXMLIntervalSeconds | ( | const char * | text,
|  | int * | interval )

Definition at line 1059 of file kc_helper.c.

Referenced by check_time_def().

## dual_log()

void dual_log | ( | const char * | format,
|  |  | ... )

Definition at line 63 of file kc_helper.c.

References kc_helper_printto_stdout.

Referenced by check_conf(), check_file(), check_file_from_xpath(), check_kasp(), check_path(), check_path_from_xpath(), check_policy(), check_rng(), check_time_def(), check_time_def_from_xpath(), check_user_group(), check_zonelist(), main(), MemCalloc(), StrStrdup(), StrStrtoi(), and StrStrtol().

## log_init()

void log_init | ( | int | facility,
|  | const char * | program_name )

Definition at line 55 of file kc_helper.c.

Referenced by main().

## MemCalloc()

void * MemCalloc | ( | size_t | nmemb,
|  | size_t | size )

Definition at line 1400 of file kc_helper.c.

References dual_log().

Referenced by StrStrdup().

## StrStrdup()

char * StrStrdup | ( | const char * | string | ) |

Definition at line 1293 of file kc_helper.c.

References dual_log(), and MemCalloc().

Referenced by check_conf(), main(), and StrStrtol().

## StrStrtoi()

int StrStrtoi | ( | const char * | string,
|  | int * | value )

Definition at line 1195 of file kc_helper.c.

References dual_log(), and StrStrtol().

Referenced by check_policy().

## StrStrtol()

int StrStrtol | ( | const char * | string,
|  | long * | value )

Definition at line 1239 of file kc_helper.c.

References dual_log(), StrFree, StrStrdup(), StrTrimL(), and StrTrimR().

Referenced by StrStrtoi().

## StrTrimL()

char * StrTrimL | ( | char * | text | ) |

Definition at line 1389 of file kc_helper.c.

Referenced by StrStrtol().

## StrTrimR()

void StrTrimR | ( | char * | text | ) |

Definition at line 1351 of file kc_helper.c.

Referenced by StrStrtol().

## Variable Documentation

## kc_helper_printto_stdout

int kc_helper_printto_stdout = 0

Definition at line 53 of file kc_helper.c.

Referenced by check_conf(), check_kasp(), check_zonelist(), dual_log(), and main().