break;
case 2 : //scaning file
if (blkfile!=(FILE *)0) { //always
- char line[200];
+ char line[300];
while (fgets(line,sizeof(line)-1,blkfile)!=(char *)0) {
- char *ptr;
- int taille;
-
- if ((ptr=strchr(line,'#'))!=(char *)0)
- *ptr='\000';
- taille=strlen(line);
- while (taille>0) {
- taille--;
- ptr=line+taille;
- if ((*ptr!=' ')&&(*ptr!='\t')&&(*ptr!='\n')&&(*ptr!='\r'))
- break;
- *ptr='\000';
- }
+ (void) rou_clean_conf_line(line);
if (strlen(line)>0) {
dnsbls=(char **)rou_addlist((void **)dnsbls,(void *)strdup(line));
}
*/
/********************************************************/
/* */
+/* Procedure to clean a line form a configuration */
+/* line, removing comment part and end of space */
+/* within the line. */
+/* */
+/********************************************************/
+PUBLIC char *rou_clean_conf_line(char *line)
+
+{
+if (line!=(char *)0) {
+ char *ptr;
+ int taille;
+
+ if ((ptr=strchr(line,'#'))!=(char *)0)
+ *ptr='\000';
+ taille=strlen(line);
+ while (taille>0) {
+ taille--;
+ ptr=line+taille;
+ switch (*ptr) {
+ case ' ' : //Space characteres
+ case '\t' :
+ case '\r' :
+ case '\n' :
+ *ptr='\000';
+ break;
+ default : //end of search
+ taille=0;
+ break;
+ }
+ }
+ }
+return line;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to load the configuartion file */
/* message and terminate application */
/* */
#define OPEP "subrou.c:rou_loadconfig,"
FILE *fichier;
-char line[200];
+char line[300];
char *name;
char *value;
char *ptr;
phase=999; //scan terminated
break;
case 2 : //trimming line
- if ((ptr=strchr(line,'#'))!=(char *)0)
- *ptr='\000';
- if ((ptr=strrchr(line,'\n'))!=(char *)0)
- *ptr='\000';
- //cleaning the end of line
- if (strlen(line)>0) {
- ptr=line+strlen(line)-1;
- while (*ptr!='\000') {
- if ((*ptr!=' ')&&(*ptr!='\t'))
- break;
- *ptr='\000';
- ptr--;
- }
- }
+ (void) rou_clean_conf_line(line);
//check remaining clean line
if (strlen(line)==0)
phase=0; //next line
//with an explication message
extern void rou_core_dump(const char *fmt,...);
+//clean configuration file line
+extern char *rou_clean_conf_line(char *line);
+
//load/unload environement configuration
extern void rou_loadconfig(char *conffile,_Bool load);