]> git.sur5r.net Git - openldap/blobdiff - clients/rcpt500/main.c
Don't try to free NULL idl. Did not cause a problem, though, as
[openldap] / clients / rcpt500 / main.c
index b29920ff4003a7724d8a427d30d6e814158ef938..2ea4d740f28604ebe8824dee664e4825ce5ddc61 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
 
-#include <ac/syslog.h>
+#include <ac/ctype.h>
+#include <ac/signal.h>
 #include <ac/string.h>
-
+#include <ac/syslog.h>
+#include <ac/unistd.h>
 
 #include "ldapconfig.h"
 #include "rcpt500.h"
@@ -28,38 +29,34 @@ int derefaliases = 1;
 int sizelimit = RCPT500_SIZELIMIT;
 int rdncount = RCPT500_RDNCOUNT;
 int ldapport = 0;
-char *ldaphost = LDAPHOST;
-char *searchbase = RCPT500_BASE;
-char *dapuser = RCPT500_BINDDN;
+char *ldaphost = NULL;
+char *searchbase = NULL;
+char *dapuser = NULL;
 char *filterfile = FILTERFILE;
 char *templatefile = TEMPLATEFILE;
-char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
-
+static char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
 
 
 /*
  * functions
  */
-int    read_msg();
-char   *read_hdr();
-int    send_reply();
+static int  read_msg(FILE *fp, struct msginfo *msgp);
+static char *read_hdr(FILE *fp, int off, char *buf, int MAXSIZEe, char **ln_p);
+static int  send_reply(struct msginfo *msgp, char *body);
+static int  find_command(char *text, char **argp);
 
 /*
  * main is invoked by sendmail via the alias file
  * the entire incoming message gets piped to our standard input
  */
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
     char               *prog, *usage = "%s [-l] [-U] [-h ldaphost] [-p ldapport] [-b searchbase] [-a] [-z sizelimit] [-u dapuser] [-f filterfile] [-t templatefile] [-c rdncount]\n";
     struct msginfo     msg;
     int                        c, errflg;
     char               *replytext;
 
-    extern int         optind;
-    extern char                *optarg;
-
     *reply = '\0';
 
     if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
@@ -118,6 +115,10 @@ main( argc, argv )
        exit( 1 );
     }
 
+#ifdef SIGPIPE
+       (void) SIGNAL( SIGPIPE, SIG_IGN );
+#endif
+
     if ( dosyslog ) {
        /*
         * if syslogging requested, initialize
@@ -169,10 +170,8 @@ main( argc, argv )
 }
 
 
-int
-read_msg( fp, msgp )
-    FILE               *fp;
-    struct msginfo     *msgp;
+static int
+read_msg( FILE *fp, struct msginfo *msgp )
 {
     char       buf[ MAXSIZE ], *line;
     int                command = -1;
@@ -232,13 +231,8 @@ read_msg( fp, msgp )
 }
 
 
-char *
-read_hdr( fp, offset, buf, MAXSIZEe, linep )
-    FILE       *fp;
-    int                offset;
-    char       *buf;
-    int                MAXSIZEe;
-    char       **linep;
+static char *
+read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
 {
     char       *hdr;
 
@@ -273,10 +267,8 @@ read_hdr( fp, offset, buf, MAXSIZEe, linep )
 }
 
 
-int
-send_reply( msgp, body )
-    struct msginfo     *msgp;
-    char               *body;
+static int
+send_reply( struct msginfo *msgp, char *body )
 {
     char       buf[ MAXSIZE ];
     FILE       *cmdpipe;
@@ -354,10 +346,8 @@ send_reply( msgp, body )
 }
 
 
-int
-find_command( text, argp )
-    char       *text;
-    char       **argp;
+static int
+find_command( char *text, char **argp )
 {
     int                i;
     char       *s, *p;
@@ -365,7 +355,7 @@ find_command( text, argp )
 
     p = text;
     for ( s = argbuf; *p != '\0'; ++p ) {
-       *s++ = tolower( *p );
+       *s++ = TOLOWER( *p );
     }
     *s = '\0';