8 #include <ac/unistd.h> /* Get read() */
15 int ldap_syslog_level;
21 fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
26 main( int argc, char **argv )
32 if (argc < 2 || argc > 3 ) {
36 if ( strcmp( argv[1], "-b" ) != 0 ) {
43 if ( strcmp( argv[1], "-b" ) == 0 ) {
49 /* if the -b flag was used, read single binary value from stdin */
54 if (( val = (char *) malloc( BUFSIZ )) == NULL ) {
60 while ( (nread = read( 0, buf, BUFSIZ )) != 0 ) {
61 if ( nread + cur > max ) {
63 if (( val = (char *) realloc( val, max )) ==
69 memcpy( val + cur, buf, nread );
73 if (( out = ldif_type_and_value( type, val, cur )) == NULL ) {
74 perror( "ldif_type_and_value" );
84 /* not binary: one value per line... */
85 while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
86 if( buf[len=strlen(buf)] == '\n') buf[len] = '\0';
88 if (( out = ldif_type_and_value( type, buf, strlen( buf ) ))
90 perror( "ldif_type_and_value" );