]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adding routine to clean conf file line
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 15 Jul 2025 19:45:57 +0000 (15:45 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 15 Jul 2025 19:45:57 +0000 (15:45 -0400)
app/scarmt.c
conf/relayed.conf [new file with mode: 0644]
lib/subrou.c
lib/subrou.h

index faa1f98272f723f3b91843f6e15a5c6053a4bd24..37e321481ed1c250d6a7e42fed465851ea327f77 100644 (file)
@@ -177,22 +177,10 @@ while (proceed==true) {
       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)); 
             }
diff --git a/conf/relayed.conf b/conf/relayed.conf
new file mode 100644 (file)
index 0000000..863788a
--- /dev/null
@@ -0,0 +1,2 @@
+#list of IP number which are relayable
+127.0.0.1/32
index 5e0015c13f6b3d3d2c1feac737acfed9cabf1655..a67b74738fd611e88c9c2cf74bfc6e626a1d4dea 100644 (file)
@@ -743,6 +743,44 @@ if (doabort==true) {
 */
 /********************************************************/
 /*                                                     */
+/*     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               */
 /*                                                     */
@@ -753,7 +791,7 @@ PUBLIC void rou_loadconfig(char *conffile,_Bool load)
 #define OPEP    "subrou.c:rou_loadconfig,"
 
 FILE *fichier;
-char line[200];
+char line[300];
 char *name;
 char *value;
 char *ptr;
@@ -786,20 +824,7 @@ while (proceed==true) {
         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
index d66f26dd9232ba60d5fd8a27fc2ded9b92921931..d95cb5362a67abddd7f13e168e0f260924147ea0 100644 (file)
@@ -113,6 +113,9 @@ extern void rou_crash(const char *fmt,...);
 //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);