X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=mngsrc%2Fgetparam.c;h=c2544e16fa6f4fcbd9ca4a910011957b3a974dc4;hb=8e54deeda4cca8e6ceceea7d7df11d6047e7e8cd;hp=efd57a30672140dc35b01cba6da6c65876798b05;hpb=8da4f192a4aeba5ac0b592859af2df8d979d43a7;p=opengatem%2Fopengatem.git
diff --git a/mngsrc/getparam.c b/mngsrc/getparam.c
index efd57a3..c2544e1 100644
--- a/mngsrc/getparam.c
+++ b/mngsrc/getparam.c
@@ -1,11 +1,11 @@
/**************************************************
OpengateM - MAC address authentication system
- module for getting parameters from conf file
+ module for getting parameters from conf file in XML form
+ ezxml library(by Aaron Voisine) is used for handling XML
Copyright (C) 2006 Opengate Project Team
Written by Yoshiaki Watanabe
-
This program 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 2
@@ -28,8 +28,8 @@ Programmed by Yoshiaki WATANABE
#include "opengatemmng.h"
#include "../ezxml/ezxml.h"
-#define CONFIG_VERSION "0.7.5"
-#define SEPARATOR "/"
+#define CONFIG_VERSION "0.7.5" /* compared to the value in conf file */
+#define SEPARATOR "/" /* separator used in XML tree description */
int debug=0;
static ezxml_t xmlRoot=NULL;
@@ -48,8 +48,7 @@ char *GetConfAuthServer(char *name);
/* Prepare Conf file to use */
/* this is called before syslog setup */
/**************************************************/
-int openConfFile(void)
-{
+int openConfFile(void){
char buff[BUFFMAXLN];
char *s;
char *errMsg;
@@ -71,8 +70,8 @@ int openConfFile(void)
/* if failed, show error message */
errMsg=(char *)ezxml_error(xmlRoot);
-
if(*errMsg!='\0'){
+
/* as the syslog is not prepared, error is send to web*/
strlcpy(buff, "
Error: Opengate configuration file ",BUFFMAXLN);
strlcat(buff, CONFIGFILE,BUFFMAXLN);
@@ -85,7 +84,7 @@ int openConfFile(void)
return -1;
}
- /* check the config file version */
+ /* check compatibility between conf file and this program (compare version number) */
if(isNull(ezxml_attr(xmlRoot, "ConfigVersion"))||
(strcmp(CONFIG_VERSION, ezxml_attr(xmlRoot, "ConfigVersion"))!=0)){
strlcpy(buff, "Error: Opengate configuration file ",BUFFMAXLN);
@@ -98,7 +97,7 @@ int openConfFile(void)
return -1;
}
- /* check the syslog */
+ /* check the syslog setting */
if(atoi(GetConfValue("Syslog/Enable")) &&
atoi(GetConfValue("Syslog/Facility"))==0){
@@ -117,32 +116,30 @@ int openConfFile(void)
/**************************************************/
/* initialize the Config */
/**************************************************/
-void initConf(void)
-{
- /* as debug flag is used many times, put it in gloval variable */
+void initConf(void){
+
+ /* as debug flag is used many times, put it in static variable */
debug=atoi(getConfValue("Debug"));
}
/**************************************************/
-/* Finish Conf file usage */
+/* Finish Config file usage */
/**************************************************/
-void closeConfFile(void)
-{
+void closeConfFile(void){
if(xmlRoot!=NULL)ezxml_free(xmlRoot);
}
/**************************************************/
/* Setup pointer to the matched ExtraSet */
/**************************************************/
-void setupConfExtra(char * userId,char *extraId)
-{
+void setupConfExtra(char *userId, char *extraId){
char* progName;
char useridfull[USERMAXLN]; /* userid@extraid */
/* setup long userid (userid@extraid) */
ConcatUserId(useridfull, userId, extraId);
- /* init as no ExtraSet */
+ /* init as non-ExtraSet */
xmlExtraSet=NULL;
/* search the matching extra set (first match is employed) */
@@ -205,14 +202,14 @@ void setupConfExtra(char * userId,char *extraId)
InitConf();
}
-/***********************************************/
-/* regular expression matching */
-/* inStr : string to match */
-/* regEx : regular expression */
-/* caseSensitive : 0=ignore case, 1=sensitive */
-/***********************************************/
-int regExMatch(const char *inStr, const char *regEx, int caseSensitive)
-{
+/****************************************************/
+/* regular expression matching */
+/* inStr : (in) string to match */
+/* regEx : (in) regular expression */
+/* caseSensitive : (in) 0=ignore case, 1=sensitive */
+/* return value : TRUE=match, FALSE=unmatch */
+/****************************************************/
+int regExMatch(const char *inStr, const char *regEx, int caseSensitive){
regex_t reg;
int errcode;
int match;
@@ -238,6 +235,7 @@ int regExMatch(const char *inStr, const char *regEx, int caseSensitive)
else match=FALSE;
}
+ /* free memory for the compiled regex */
regfree(®);
return match;
@@ -245,11 +243,10 @@ int regExMatch(const char *inStr, const char *regEx, int caseSensitive)
/**************************************************/
/* get a value for name from Conf file */
-/* the name[aa/bb/cc] means the path */
-/* if ID is set, extraSet value is overlayed */
+/* the name[aa/bb/cc] means the path in xml */
+/* extraSet value is overlayed, if exists */
/**************************************************/
-char *getConfValue(char *name)
-{
+char *getConfValue(char *name){
char *pValue;
char *pValueExtra;
char *pStr;
@@ -281,9 +278,21 @@ char *getConfValue(char *name)
err_msg("ERR at %s#%d: cannot get %s from conf file",__FILE__,__LINE__,name);
}
- /* get value in extra set matched to ID */
+ /* get value in extra set matched to name */
/* if name is matched in first level, reset all child setting */
- /* in this section, many parameters are not set */
+ /*****************************************************************
+ in the following, and for 'user1' is NOT defined
+
+ /bin/rmail
+ /etc/opengate/warningmail
+ date(now())=date(........)
+
+
+
+ /etc/opengate/warningmail-special
+
+
+ *****************************************************************/
if(!isNull(pValueExtra=getConfValueExtra(name))){
pValue=pValueExtra;
}
@@ -298,10 +307,9 @@ char *getConfValue(char *name)
}
/************************************************/
-/* get the value in extra set matched to ID */
+/* get the value in extra set matched to name */
/************************************************/
-char *getConfValueExtra(char *name)
-{
+char *getConfValueExtra(char *name){
char *pStr;
char buff[BUFFMAXLN];
ezxml_t xml;
@@ -315,6 +323,7 @@ char *getConfValueExtra(char *name)
/* get a first level matched node in extra set */
/* the first level is not included in the following loop */
/* as to prevent partial overlay of sub level value */
+ /* (see 40-lines above) */
xml=ezxml_child(xmlExtraSet, pStr);
if(xml==NULL) return "";
@@ -332,7 +341,7 @@ char *getConfValueExtra(char *name)
/***************************************************/
/* get a value for AuthServer param from Conf file*/
-/* the name[AuthServer/bb/cc] means the path */
+/* the name[AuthServer/bb/cc] means the xml path */
/***************************************************/
char *getConfAuthServer(char *name)
{
@@ -378,9 +387,12 @@ char *getConfAuthServer(char *name)
return pValue;
}
-/**********************************/
-/* select next authserver setting */
-/**********************************/
+/*****************************************************************/
+/* select next authserver setting */
+/* at first call, this selects the first server setting */
+/* and form second call, this selects the next server setting */
+/* ResetAuthServerPointer() returns the pointer to first setting */
+/*****************************************************************/
int selectNextAuthServer(void){
ezxml_t xmlTmp; /* temporary variable */
@@ -415,18 +427,17 @@ int selectNextAuthServer(void){
}
}
-/**********************************************
-reset pointer for auth server list
-**********************************************/
+/*********************************************/
+/* reset pointer for auth server list */
+/*********************************************/
void resetAuthServerPointer(void){
xmlAuthServer=NULL;
}
-/***********************************************/
-/* Convart the syslog facility id to raw value */
-/***********************************************/
-char *convertToFacilityRaw(char *pValue)
-{
+/************************************************************/
+/* Convart the syslog facility id(string) to raw value(int) */
+/************************************************************/
+char *convertToFacilityRaw(char *pValue){
static char facility[WORDMAXLN];
int rawValue;
@@ -446,11 +457,10 @@ char *convertToFacilityRaw(char *pValue)
}
/**************************************************/
-/* get the first value as previous call */
-/* (next node of the lowest level of tree) */
+/* get the first value matched to name */
+/* (first node of matched lowest level of tree) */
/**************************************************/
-char *getFirstConfValue(char* name)
-{
+char *getFirstConfValue(char* name){
char *pValue;
pValue=GetConfValue(name);
@@ -462,11 +472,10 @@ char *getFirstConfValue(char* name)
}
/**************************************************/
-/* get the next value as previous call */
+/* get the value in sibling of previous get */
/* (next node of the lowest level of tree) */
/**************************************************/
-char *getNextConfValue(void)
-{
+char *getNextConfValue(void){
char *pValue;
/* recover previous pointer */