2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
12 #include <ac/socket.h>
13 #include <ac/unistd.h>
26 fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
31 main( int argc, char **argv )
37 if (argc < 2 || argc > 3 ) {
41 if ( strcmp( argv[1], "-b" ) != 0 ) {
48 if ( strcmp( argv[1], "-b" ) == 0 ) {
54 /* if the -b flag was used, read single binary value from stdin */
59 if (( val = (char *) malloc( BUFSIZ )) == NULL ) {
65 while ( (nread = read( 0, buf, BUFSIZ )) != 0 ) {
66 if ( nread + cur > max ) {
68 if (( val = (char *) realloc( val, max )) ==
74 memcpy( val + cur, buf, nread );
78 if (( out = ldif_put( LDIF_PUT_BINARY, type, val, cur )) == NULL ) {
79 perror( "ldif_type_and_value" );
89 /* not binary: one value per line... */
90 while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
91 if( buf[len=strlen(buf)] == '\n') buf[len] = '\0';
93 if (( out = ldif_put( LDIF_PUT_VALUE, type, buf, strlen( buf ) ))
95 perror( "ldif_type_and_value" );