]> git.sur5r.net Git - openldap/blobdiff - contrib/whois++/command.c
Annoying little son of a `free' BUG fixed.
[openldap] / contrib / whois++ / command.c
index 2a59e32d8b53fd05a407dbe77eda0d724f6304c0..638442e897c180cd51a09280d0968c022eb29427 100644 (file)
@@ -29,8 +29,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  */
 
 #include "whois++.h"
-
-extern char    *index(), *rindex();
+#include <stdlib.h>
+extern int getdtablesize (void);
 
 #define        isspecial(c)    ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
 
@@ -38,9 +38,8 @@ static        char    **component = NULL;
 static int     numberOfComponents;
 static int     components = 10;
 
-static int getToken( token )
-char   *token;
-
+static int
+getToken( char *token )
 {
        static char     *buffer = NULL;
        static int      idx;
@@ -89,7 +88,7 @@ char  *token;
                if ( log )
                        syslog( LOG_INFO, "Whois++ Query: %s", buffer );
        }
-       while ( buffer[idx] != '\0' && isspace( buffer[idx] ) )
+       while ( buffer[idx] != '\0' && isspace( (unsigned char) buffer[idx] ) )
                idx++;
        token[0] = buffer[idx++];
        token[1] = '\0';
@@ -155,7 +154,8 @@ char        *token;
                                token[i++] = buffer[idx++];
                        else
                                token[i++] = ch;
-               } while ( ch != '\0' && !isspace( ch ) && !isspecial( ch ) );
+               } while ( ch != '\0' &&
+                         !isspace( (unsigned char) ch ) && !isspecial( ch ) );
                token[--i] = '\0';
                idx--;
 /**/           /*
@@ -208,10 +208,14 @@ char      *token;
        }
 }
 
-static int term( token, value, attribute, specifier, soundex )
-int    token;
-char   *value, *attribute;
-int    *specifier, *soundex;
+static int
+term(
+       int     token,
+       char    *value,
+       char    *attribute,
+       int     *specifier,
+       int     *soundex
+)
 {
        char    buffer[BUFSIZ], temp[BUFSIZ];
        int     iterations;
@@ -341,10 +345,14 @@ int       *specifier, *soundex;
        return token;
 }
 
-static int processTerm( specifier, soundex, buffer, attribute, value )
-int    specifier, soundex;
-char   *buffer, *attribute, *value;
-
+static int
+processTerm(
+       int     specifier,
+       int     soundex,
+       char    *buffer,
+       char    *attribute,
+       char    *value
+)
 {
        char    *s, *t;
        char    query[BUFSIZ];
@@ -367,17 +375,17 @@ char      *buffer, *attribute, *value;
                        sprintf( query, "(%s%s%s)", attribute,
                                (soundex)?"~=":"=", buffer );
                } else {
-                       if ( ( s = index( buffer, ',' ) ) != NULL ) {
+                       if ( ( s = strchr( buffer, ',' ) ) != NULL ) {
                                *s++ = '\0';
-                               while ( *s && isspace( *s ) )
+                               while ( *s && isspace( (unsigned char) *s ) )
                                        s++;
                                sprintf( query, "(sn%s%s)",
                                        (soundex)?"~=":"=", buffer );
                                component[numberOfComponents++] = strdup( query );
                                /* let's just make sure there is no title */
-                               if ( ( t = rindex( s, ',' ) ) != NULL ) {
+                               if ( ( t = strrchr( s, ',' ) ) != NULL ) {
                                        *t++ = '\0';
-                                       while ( *t && isspace( *t ) )
+                                       while ( *t && isspace( (unsigned char) *t ) )
                                                t++;
                                        sprintf( query, "(personalTitle%s%s)",
                                                (soundex)?"~=":"=", t );
@@ -389,7 +397,7 @@ char        *buffer, *attribute, *value;
                                sprintf( query, "%s *", &buffer[6] );
                                strcpy( buffer, query );
                        }
-                       if ( ( s = index( buffer, '@' ) ) != NULL ) {
+                       if ( ( s = strchr( buffer, '@' ) ) != NULL ) {
                                *s++ = '\0';
                                if ( *buffer == '\0' ) /* no username */
                                        sprintf( query, "(mail=*@%s)", s );
@@ -402,7 +410,7 @@ char        *buffer, *attribute, *value;
                                if ( soundex )
                                        printFormatted( lineLength, TRUE, stdout,
                                                "Fuzzy matching not supported on e-mail address queries" );
-                       } else if ( index( buffer, ' ' ) == NULL ) {
+                       } else if ( strchr( buffer, ' ' ) == NULL ) {
                                sprintf( query,
                                        "(|(sn%s%s)(userid%s%s)(l%s%s)(ou%s%s)\
 (&(cn%s%s)(!(objectClass=person))))",
@@ -529,8 +537,8 @@ char        *buffer, *attribute, *value;
        return SEARCH;
 }
 
-int    parseCommand( query )
-char   *query;
+int
+parseCommand( char *query )
 {
        /*
         * This procedure reads the string sent by the user and breaks it