From 5c6ad6c5b160c26108bfd0c1fa3c3f27c4d6c8d8 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 20 Dec 1998 22:28:33 +0000 Subject: [PATCH] ldif'ize ldif library (ie: everything is now in the ldif_ namespace) --- clients/tools/ldapmodify.c | 4 ++-- include/ldif.h | 7 ++++--- libraries/libldif/line64.c | 12 ++++++------ servers/slapd/entry.c | 10 +++++----- servers/slapd/repl.c | 2 +- servers/slapd/tools/ldif2id2children.c | 8 ++++---- servers/slapd/tools/ldif2index.c | 4 ++-- servers/slapd/tools/ldif2ldbm.c | 4 ++-- servers/slurpd/re.c | 14 +++++++------- 9 files changed, 33 insertions(+), 32 deletions(-) diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 12d4ad0255..48b2524975 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -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; diff --git a/include/ldif.h b/include/ldif.h index 217fe7a678..d89b7da8cc 100644 --- a/include/ldif.h +++ b/include/ldif.h @@ -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 */ diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index d77765167b..14037b5379 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -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 ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 5e7ee6d31b..726eaf675f 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -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: " */ 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 ); } } diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index ecea75af7a..0961e30f25 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -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'; diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index 9ff967dfa8..08d62dfe53 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -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", diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c index 15979b7e7d..893420c10c 100644 --- a/servers/slapd/tools/ldif2index.c +++ b/servers/slapd/tools/ldif2index.c @@ -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", diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index 7f759367cc..ef3a1ba203 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -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", diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index 5792850d7e..02e558116b 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -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; -- 2.39.5