+/* $OpenLDAP$ */
/*
shellutil.c - common routines useful when building shell-based backends
for the standalone ldap server
#include <stdio.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
+#include <ac/stdlib.h>
+#include <ac/stdarg.h>
#include <pwd.h>
+#include <ac/ctype.h>
#include <ac/string.h>
#include <lber.h>
int
test_filter( struct ldop *op, struct ldentry *entry )
{
- return (( random() & 0x07 ) == 0x07 ); /* XXX random for now */
+ return ((random() & 0x07 ) == 0x07) /* XXX random for now */
+ ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE;
}
struct inputparams *ip;
if ( fgets( line, MAXLINELEN, ifp ) == NULL ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Empty Input" );
+ write_result( ofp, LDAP_OTHER, NULL, "Empty Input" );
}
line[ strlen( line ) - 1 ] = '\0';
if ( strncasecmp( line, STR_OP_SEARCH, sizeof( STR_OP_SEARCH ) - 1 )
if (( op->ldop_srch.ldsp_scope = atoi( args )) != LDAP_SCOPE_BASE &&
op->ldop_srch.ldsp_scope != LDAP_SCOPE_ONELEVEL &&
op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Bad scope" );
+ write_result( ofp, LDAP_OTHER, NULL, "Bad scope" );
return( -1 );
}
break;
while ( args != NULL ) {
if (( p = strchr( args, ' ' )) != NULL ) {
*p++ = '\0';
- while ( isspace( *p )) {
+ while ( isspace( (unsigned char) *p )) {
++p;
}
}
if ( op->ldop_suffixes == NULL || op->ldop_dn == NULL ||
op->ldop_srch.ldsp_filter == NULL ) {
- write_result( ofp, LDAP_OPERATIONS_ERROR, NULL,
+ write_result( ofp, LDAP_OTHER, NULL,
"Required suffix:, base:, or filter: missing" );
return( -1 );
}
for ( i = 0; ips[ i ].ip_type != 0; ++i ) {
if ( strncasecmp( *linep, ips[ i ].ip_tag, p - *linep ) == 0 ) {
- while ( isspace( *(++p) )) {
+ while ( isspace( (unsigned char) *(++p) )) {
;
}
*linep = p;
if (( p = strdup( s )) == NULL ) {
debug_printf( "strdup failed\n" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
if ( p == NULL ) {
debug_printf( "realloc( p, %d ) failed\n", size );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
if (( p = calloc( nelem, elsize )) == NULL ) {
debug_printf( "calloc( %d, %d ) failed\n", nelem, elsize );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
return( p );
/* VARARGS */
void
-debug_printf
-#ifdef STDC_HEADERS
- ( char *fmt, ... )
-#else
- ( va_alist )
- va_dcl
-#endif
+debug_printf( const char *fmt, ... )
{
va_list ap;
-#ifndef STDC_HEADERS
- char *fmt;
-#endif
if ( debugflg ) {
-#ifdef STDC_HEADERS
va_start( ap, fmt );
-#else
- va_start( ap );
- fmt = va_arg( ap, char * );
-#endif
fprintf( stderr, "%s: ", progname );
vfprintf( stderr, fmt, ap );
va_end( ap );