mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-18 15:20:35 +08:00
minor cleanup
This commit is contained in:
parent
60ccde8f14
commit
b1fb7f824d
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user