*/
#include "whois++.h"
-
-extern char *index(), *rindex();
+#include <stdlib.h>
+extern int getdtablesize (void);
#define isspecial(c) ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
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;
if ( buffer == NULL ) {
tablesize = getdtablesize();
+
+#ifdef FD_SETSIZE
+ if ( tablesize > FD_SETSIZE ) {
+ tablesize = FD_SETSIZE;
+ }
+#endif /* FD_SETSIZE */
+
timeout.tv_sec = 60;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
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';
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--;
/**/ /*
}
}
-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;
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];
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 );
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 );
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))))",
return SEARCH;
}
-int parseCommand( query )
-char *query;
+int
+parseCommand( char *query )
{
/*
* This procedure reads the string sent by the user and breaks it