]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working out the unidns module
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 14 Aug 2024 18:52:36 +0000 (14:52 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 14 Aug 2024 18:52:36 +0000 (14:52 -0400)
lib/subrou.c
lib/subrou.h
lib/unidns.c

index 9fa3673758dddaa1432a48a6c5b984522c3b7fac..61d85ecc412e912dfe035bfffb2cea8361bd221d 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.4.2"
-#define RELEASE "3"
+#define RELEASE "4"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level
@@ -352,6 +352,31 @@ if ((list!=(void **)0)&&(entry!=(void **)0)) {
 return found;
 }
 /*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to free all list entries, return a    */
+/*      NULL pointer.                                   */
+/*                                                     */
+/********************************************************/
+PUBLIC void **rou_freelist(void **list,freehandler_t handler)
+
+{
+if (list!=(void **)0) {
+  void **ptr;
+
+  ptr=list;
+  while (*ptr!=(void *)0) {
+    (void) handler(*ptr);
+    ptr++;
+    }
+  (void) free(list);
+  list=(void **)0;
+  }
+return list;
+}
+/*
 ^L
 */
 /********************************************************/
index 912f0d4f31703ca9114056e98105b6cfa879bf92..2e583bc77e065562d8871e65ab0e80099a7bd951 100644 (file)
@@ -61,9 +61,12 @@ extern int rou_nbrlist(void **list);
 extern void **rou_addlist(void **list,void *entry);
 
 //Procedure to free one entry part of list
-// return true if found, false otherwize. 
+//return true if found, false otherwise. 
 extern _Bool rou_rmlist(void **list,void *entry,freehandler_t handler);
 
+//Procedure to free all entries of list
+extern void **rou_freelist(void **list,freehandler_t handler);
+
 //change the application name
 extern char *rou_setappname(const char *newname);
 
index dc0715872ae6945b66112278ddcdff2b730e20f4..649c154cdee7f4da1038dcb8e36650d857a270d1 100644 (file)
@@ -153,16 +153,13 @@ while((answer-->0)&&(cp<eom)) {
         dynbuf=(char *)calloc(10,sizeof(char));
        while (collected<dlen) {
           u_int taille;
-         char *newdynbuf;
 
          (void) memset(buf,'\000',sizeof(buf));
           taille=((u_int)(txtptr[0]))&0X0FF; 
          txtptr++;
           (void) snprintf(buf,sizeof(buf),"%.*s ",taille,txtptr);
-         if ((newdynbuf=(char *)realloc(dynbuf,strlen(dynbuf)+strlen(buf)+5))!=(char *)0) {
-            dynbuf=newdynbuf;
-           (void) strcat(dynbuf,buf);
-            }
+         dynbuf=(char *)realloc(dynbuf,strlen(dynbuf)+strlen(buf)+5);
+         (void) strcat(dynbuf,buf);
          collected+=taille+1;
          txtptr+=taille;
           }
@@ -244,11 +241,29 @@ return inftxt;
 static char **getspf(char *domain)
 
 {
-char **inftxt;
+char **infspf;
+
+if ((infspf=gettxt(domain,T_SPF,"SPF"))==(char **)0) {
+  char **inftxt;
 
-if ((inftxt=gettxt(domain,T_SPF,"SPF"))==(char **)0)
   inftxt=gettxt(domain,T_TXT,"TXT");
-return inftxt;
+  if (inftxt!=(char **)0) {
+    char **ptr;
+
+    ptr=inftxt;
+    while (*ptr!=(char *)0) {
+      if (strstr(*ptr,"v=spf1")==*ptr) {
+        char *dup;
+
+        dup=strdup(*ptr);
+        infspf=(char **)rou_addlist((void **)infspf,(void *)dup);
+        }
+      ptr++;
+      }
+    inftxt=(char **)rou_freelist((void **)inftxt,(freehandler_t)rou_freestr);
+    }
+  }
+return infspf;
 }
 /*
 ^L
@@ -342,6 +357,7 @@ while (proceed==true) {
           (void) printf("JMPDBG <%s>\n",*ptr);
           ptr++;
           }
+        list=(char **)rou_freelist((void **)list,(freehandler_t)rou_freestr);
         }
       break;
     default     :       //SAFE guard