8 #include <ac/unistd.h> /* Get read() */
17 fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
22 main( int argc, char **argv )
28 if (argc < 2 || argc > 3 ) {
32 if ( strcmp( argv[1], "-b" ) != 0 ) {
39 if ( strcmp( argv[1], "-b" ) == 0 ) {
45 /* if the -b flag was used, read single binary value from stdin */
50 if (( val = (char *) malloc( BUFSIZ )) == NULL ) {
56 while ( (nread = read( 0, buf, BUFSIZ )) != 0 ) {
57 if ( nread + cur > max ) {
59 if (( val = (char *) realloc( val, max )) ==
65 memcpy( val + cur, buf, nread );
69 if (( out = ldif_type_and_value( type, val, cur )) == NULL ) {
70 perror( "ldif_type_and_value" );
80 /* not binary: one value per line... */
81 while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
82 if( buf[len=strlen(buf)] == '\n') buf[len] = '\0';
84 if (( out = ldif_type_and_value( type, buf, strlen( buf ) ))
86 perror( "ldif_type_and_value" );