X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldif%2Fline64.c;h=65ec9a750e5e82849167538258b57372ad0aaab7;hb=dc07e765f263ef459dcd2afd1ece01cfc85a0edd;hp=b4f8968e7424f85429c0062d295792e956ffe23b;hpb=321354ecff5571b92cda1bf4b0299e33218d9be8;p=openldap diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index b4f8968e74..65ec9a750e 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -20,10 +20,10 @@ int ldif_debug = 0; #define RIGHT4 0x0f #define CONTINUED_LINE_MARKER '\001' -static char nib2b64[0x40f] = +static const char nib2b64[0x40f] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static unsigned char b642nib[0x80] = { +static const unsigned char b642nib[0x80] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -51,7 +51,7 @@ static unsigned char b642nib[0x80] = { int ldif_parse_line( - char *line, + LDAP_CONST char *line, char **type, char **value, int *vlen @@ -62,7 +62,7 @@ ldif_parse_line( int i, b64; /* skip any leading space */ - while ( isspace( *line ) ) { + while ( isspace( (unsigned char) *line ) ) { line++; } *type = line; @@ -70,13 +70,13 @@ ldif_parse_line( for ( s = line; *s && *s != ':'; s++ ) ; /* NULL */ if ( *s == '\0' ) { - lber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, + ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, "ldif_parse_line missing ':'\n"); return( -1 ); } /* trim any space between type and : */ - for ( p = s - 1; p > line && isspace( *p ); p-- ) { + for ( p = s - 1; p > line && isspace( (unsigned char) *p ); p-- ) { *p = '\0'; } *s++ = '\0'; @@ -92,13 +92,13 @@ ldif_parse_line( } /* skip space between : and value */ - while ( isspace( *s ) ) { + while ( isspace( (unsigned char) *s ) ) { s++; } /* if no value is present, error out */ if ( *s == '\0' ) { - lber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, + ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, "ldif_parse_line missing value\n"); return( -1 ); } @@ -118,7 +118,7 @@ ldif_parse_line( for ( i = 0; i < 4; i++ ) { if ( p[i] != '=' && (p[i] & 0x80 || b642nib[ p[i] & 0x7f ] > 0x3f) ) { - lber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, + ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, "ldif_parse_line: invalid base 64 encoding char (%c) 0x%x\n", p[i], p[i] ); return( -1 ); @@ -175,8 +175,7 @@ ldif_parse_line( char * ldif_getline( char **next ) { - char *l; - char c; + char *l; if ( *next == NULL || **next == '\n' || **next == '\0' ) { return( NULL ); @@ -184,7 +183,7 @@ ldif_getline( char **next ) l = *next; while ( (*next = strchr( *next, '\n' )) != NULL ) { - c = *(*next + 1); + unsigned char c = *(*next + 1); if ( isspace( c ) && c != '\n' ) { **next = CONTINUED_LINE_MARKER; *(*next+1) = CONTINUED_LINE_MARKER; @@ -199,7 +198,11 @@ ldif_getline( char **next ) } void -ldif_put_type_and_value( char **out, char *t, char *val, int vlen ) +ldif_put_type_and_value( + char **out, + LDAP_CONST char *t, + LDAP_CONST char *val, + int vlen ) { unsigned char *byte, *p, *stop; unsigned char buf[3]; @@ -229,7 +232,7 @@ ldif_put_type_and_value( char **out, char *t, char *val, int vlen ) b64 = 1; break; } - if ( len > LINE_WIDTH ) { + if ( len > LDIF_LINE_WIDTH ) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; @@ -250,7 +253,7 @@ ldif_put_type_and_value( char **out, char *t, char *val, int vlen ) bits |= (byte[2] & 0xff); for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { - if ( len > LINE_WIDTH ) { + if ( len > LDIF_LINE_WIDTH ) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; @@ -275,7 +278,7 @@ ldif_put_type_and_value( char **out, char *t, char *val, int vlen ) bits |= (byte[2] & 0xff); for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { - if ( len > LINE_WIDTH ) { + if ( len > LDIF_LINE_WIDTH ) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; @@ -295,7 +298,7 @@ ldif_put_type_and_value( char **out, char *t, char *val, int vlen ) char * -ldif_type_and_value( char *type, char *val, int vlen ) +ldif_type_and_value( LDAP_CONST char *type, LDAP_CONST char *val, int vlen ) /* * return malloc'd, zero-terminated LDIF line */ @@ -307,7 +310,7 @@ ldif_type_and_value( char *type, char *val, int vlen ) if (( buf = (char *) malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) == NULL ) { - lber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, + ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, "ldif_type_and_value: malloc failed!" ); return NULL; }