ldif'ize ldif library (ie: everything is now in the ldif_ namespace)

This commit is contained in:
Kurt Zeilenga 1998-12-20 22:28:33 +00:00
parent 362d6cbf2a
commit 5c6ad6c5b1
9 changed files with 33 additions and 32 deletions

View File

@ -251,7 +251,7 @@ process_ldif_rec( char *rbuf )
pmods = NULL;
dn = newrdn = NULL;
while ( rc == 0 && ( line = str_getline( &rbuf )) != NULL ) {
while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) {
++linenum;
if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) {
expect_sep = 0;
@ -259,7 +259,7 @@ process_ldif_rec( char *rbuf )
continue;
}
if ( str_parse_line( line, &type, &value, &vlen ) < 0 ) {
if ( ldif_parse_line( line, &type, &value, &vlen ) < 0 ) {
fprintf( stderr, "%s: invalid format (line %d of entry: %s\n",
prog, linenum, dn == NULL ? "" : dn );
rc = LDAP_PARAM_ERROR;

View File

@ -36,11 +36,12 @@ LDAP_BEGIN_DECL
((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
int str_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
char * str_getline LDAP_P(( char **next ));
void put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
int ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
char * ldif_getline LDAP_P(( char **next ));
void ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));
LDAP_END_DECL
#endif /* _LDIF_H */

View File

@ -41,14 +41,14 @@ static unsigned char b642nib[0x80] = {
};
/*
* str_parse_line - takes a line of the form "type:[:] value" and splits it
* ldif_parse_line - takes a line of the form "type:[:] value" and splits it
* into components "type" and "value". if a double colon separates type from
* value, then value is encoded in base 64, and parse_line un-decodes it
* (in place) before returning.
*/
int
str_parse_line(
ldif_parse_line(
char *line,
char **type,
char **value,
@ -155,7 +155,7 @@ str_parse_line(
}
/*
* str_getline - return the next "line" (minus newline) of input from a
* ldif_getline - return the next "line" (minus newline) of input from a
* string buffer of lines separated by newlines, terminated by \n\n
* or \0. this routine handles continued lines, bundling them into
* a single big line before returning. if a line begins with a white
@ -169,7 +169,7 @@ str_parse_line(
*/
char *
str_getline( char **next )
ldif_getline( char **next )
{
char *l;
char c;
@ -195,7 +195,7 @@ str_getline( char **next )
}
void
put_type_and_value( char **out, char *t, char *val, int vlen )
ldif_put_type_and_value( char **out, char *t, char *val, int vlen )
{
unsigned char *byte, *p, *stop;
unsigned char buf[3];
@ -305,7 +305,7 @@ ldif_type_and_value( char *type, char *val, int vlen )
}
p = buf;
put_type_and_value( &p, type, val, vlen );
ldif_put_type_and_value( &p, type, val, vlen );
*p = '\0';
return( buf );

View File

@ -54,7 +54,7 @@ str2entry( char *s )
next = s;
if ( isdigit( *s ) ) {
e->e_id = atoi( s );
if ( (s = str_getline( &next )) == NULL ) {
if ( (s = ldif_getline( &next )) == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"<= str2entry NULL (missing newline after id)\n",
0, 0, 0 );
@ -67,12 +67,12 @@ str2entry( char *s )
vals[0] = &bval;
vals[1] = NULL;
ptype[0] = '\0';
while ( (s = str_getline( &next )) != NULL ) {
while ( (s = ldif_getline( &next )) != NULL ) {
if ( *s == '\n' || *s == '\0' ) {
break;
}
if ( str_parse_line( s, &type, &value, &vlen ) != 0 ) {
if ( ldif_parse_line( s, &type, &value, &vlen ) != 0 ) {
Debug( LDAP_DEBUG_TRACE,
"<= str2entry NULL (parse_line)\n", 0, 0, 0 );
continue;
@ -164,7 +164,7 @@ entry2str(
/* put "dn: <dn>" */
tmplen = strlen( e->e_dn );
MAKE_SPACE( LDIF_SIZE_NEEDED( 2, tmplen ));
put_type_and_value( (char **) &ecur, "dn", e->e_dn, tmplen );
ldif_put_type_and_value( (char **) &ecur, "dn", e->e_dn, tmplen );
}
/* put the attributes */
@ -174,7 +174,7 @@ entry2str(
bv = a->a_vals[i];
tmplen = strlen( a->a_type );
MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
put_type_and_value( (char **) &ecur, a->a_type,
ldif_put_type_and_value( (char **) &ecur, a->a_type,
bv->bv_val, bv->bv_len );
}
}

View File

@ -76,7 +76,7 @@ replog(
buf = (char *) ch_malloc( len );
bufp = buf;
put_type_and_value( &bufp, mods->mod_type,
ldif_put_type_and_value( &bufp, mods->mod_type,
mods->mod_bvalues[i]->bv_val,
mods->mod_bvalues[i]->bv_len );
*bufp = '\0';

View File

@ -180,9 +180,9 @@ main( int argc, char **argv )
}
s = buf;
elineno = 0;
while ( (linep = str_getline( &s )) != NULL ) {
while ( (linep = ldif_getline( &s )) != NULL ) {
elineno++;
if ( str_parse_line( linep, &type, &val,
if ( ldif_parse_line( linep, &type, &val,
&vlen ) != 0 ) {
Debug( LDAP_DEBUG_PARSE,
"bad line %d in entry ending at line %d ignored\n",
@ -260,8 +260,8 @@ main( int argc, char **argv )
if ( * buf != '\n' ) {
id++;
s = buf;
while ( (linep = str_getline( &s )) != NULL ) {
if ( str_parse_line( linep, &type, &val,
while ( (linep = ldif_getline( &s )) != NULL ) {
if ( ldif_parse_line( linep, &type, &val,
&vlen ) != 0 ) {
Debug( LDAP_DEBUG_PARSE,
"bad line %d ignored\n",

View File

@ -165,9 +165,9 @@ main( int argc, char **argv )
}
s = buf;
elineno = 0;
while ( (linep = str_getline( &s )) != NULL ) {
while ( (linep = ldif_getline( &s )) != NULL ) {
elineno++;
if ( str_parse_line( linep, &type, &val,
if ( ldif_parse_line( linep, &type, &val,
&vlen ) != 0 ) {
Debug( LDAP_DEBUG_PARSE,
"bad line %d in entry ending at line %d ignored\n",

View File

@ -250,9 +250,9 @@ main( int argc, char **argv )
id++;
s = buf;
elineno = 0;
while ( (linep = str_getline( &s )) != NULL ) {
while ( (linep = ldif_getline( &s )) != NULL ) {
elineno++;
if ( str_parse_line( linep, &type, &val, &vlen )
if ( ldif_parse_line( linep, &type, &val, &vlen )
!= 0 ) {
Debug( LDAP_DEBUG_PARSE,
"bad line %d in entry ending at line %d ignored\n",

View File

@ -147,7 +147,7 @@ Re_parse(
re->re_refcnt = sglob->num_replicas;
for (;;) {
if (( state == GOT_ALL ) || ( buf = str_getline( &rp )) == NULL ) {
if (( state == GOT_ALL ) || ( buf = ldif_getline( &rp )) == NULL ) {
break;
}
/*
@ -159,7 +159,7 @@ Re_parse(
continue;
}
buflen = ( long ) strlen( buf );
if ( str_parse_line( buf, &type, &value, &len ) < 0 ) {
if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
Debug( LDAP_DEBUG_ANY,
"Error: Re_parse: malformed replog file\n",
0, 0, 0 );
@ -205,7 +205,7 @@ Re_parse(
}
for (;;) {
if (( buf = str_getline( &rp )) == NULL ) {
if (( buf = ldif_getline( &rp )) == NULL ) {
break;
}
buflen = ( long ) strlen( buf );
@ -213,7 +213,7 @@ Re_parse(
type = "-";
value = NULL;
} else {
if ( str_parse_line( buf, &type, &value, &len ) < 0 ) {
if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
Debug( LDAP_DEBUG_ANY,
"Error: malformed replog line \"%s\"\n",
buf, 0, 0 );
@ -278,7 +278,7 @@ get_repl_hosts(
for (;;) {
/* If this is a reject log, we need to skip over the ERROR: line */
if ( !strncmp( *r_rp, ERROR_STR, strlen( ERROR_STR ))) {
line = str_getline( r_rp );
line = ldif_getline( r_rp );
if ( line == NULL ) {
break;
}
@ -286,11 +286,11 @@ get_repl_hosts(
if ( strncasecmp( *r_rp, "replica:", 7 )) {
break;
}
line = str_getline( r_rp );
line = ldif_getline( r_rp );
if ( line == NULL ) {
break;
}
if ( str_parse_line( line, &type, &value, &len ) < 0 ) {
if ( ldif_parse_line( line, &type, &value, &len ) < 0 ) {
return( NULL );
}
port = 0;