+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <stdlib.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h> /* Get read() */
+
#include "lber.h"
#include "ldap.h"
#include "ldif.h"
int ldap_syslog_level;
-usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
exit( 1 );
}
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char buf[BUFSIZ];
char *type, *out;
- int binary = 0;
+ int len, binary = 0;
if (argc < 2 || argc > 3 ) {
usage( argv[0] );
}
/* not binary: one value per line... */
- while ( gets( buf ) != NULL ) {
+ while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
+ if( buf[len=strlen(buf)] == '\n') buf[len] = '\0';
+
if (( out = ldif_type_and_value( type, buf, strlen( buf ) ))
== NULL ) {
perror( "ldif_type_and_value" );