From: Pierangelo Masarati Date: Fri, 6 Jan 2006 16:20:24 +0000 (+0000) Subject: minor cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~444 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1fb7f824d4f01bf944901f20b5aab5622bd3547;p=openldap minor cleanup --- diff --git a/clients/tools/common.c b/clients/tools/common.c index 4886f76e30..ceaf0dfe7c 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -1511,3 +1511,34 @@ tool_write_ldif( int type, char *name, char *value, ber_len_t vallen ) return( 0 ); } +int +tool_is_oid( const char *s ) +{ + int first = 1; + + if ( !isdigit( s[ 0 ] ) ) { + return 0; + } + + for ( ; s[ 0 ]; s++ ) { + if ( s[ 0 ] == '.' ) { + if ( s[ 1 ] == '\0' ) { + return 0; + } + first = 1; + continue; + } + + if ( !isdigit( s[ 0 ] ) ) { + return 0; + } + + if ( first == 1 && s[ 0 ] == '0' && s[ 1 ] != '.' ) { + return 0; + } + first = 0; + } + + return 1; +} + diff --git a/clients/tools/common.h b/clients/tools/common.h index 1b56b3e23f..b78c28cd21 100644 --- a/clients/tools/common.h +++ b/clients/tools/common.h @@ -93,6 +93,7 @@ void tool_perror LDAP_P(( char **refs )); void tool_print_ctrls LDAP_P(( LDAP *ld, LDAPControl **ctrls )); int tool_write_ldif LDAP_P(( int type, char *name, char *value, ber_len_t vallen )); +int tool_is_oid LDAP_P(( const char *s )); LDAP_END_DECL diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index c65ddafc93..c75b22dfcd 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -237,37 +237,6 @@ ctrl_add( void ) return 0; } -static int -is_oid( const char *s ) -{ - int first = 1; - - if ( !isdigit( s[ 0 ] ) ) { - return 0; - } - - for ( ; s[ 0 ]; s++ ) { - if ( s[ 0 ] == '.' ) { - if ( s[ 1 ] == '\0' ) { - return 0; - } - first = 1; - continue; - } - - if ( !isdigit( s[ 0 ] ) ) { - return 0; - } - - if ( first == 1 && s[ 0 ] == '0' && s[ 1 ] != '.' ) { - return 0; - } - first = 0; - } - - return 1; -} - static int parse_page_control( LDAP *ld, LDAPMessage *result, @@ -498,7 +467,7 @@ handle_private_option( int i ) } if ( crit ) ldapsync *= -1; - } else if ( is_oid( control ) ) { + } else if ( tool_is_oid( control ) ) { if ( ctrl_add() ) { exit( EXIT_FAILURE ); }