3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 /* ldapmodify.c - generic program to modify or add entries using LDAP */
12 #include <ac/stdlib.h>
14 #include <ac/string.h>
15 #include <ac/unistd.h>
17 #ifdef HAVE_SYS_STAT_H
21 #ifdef HAVE_SYS_FILE_H
31 #include "lutil_ldap.h"
33 #include "ldap_defaults.h"
40 static int ldapadd, force = 0;
41 static char *rejfile = NULL;
42 static LDAP *ld = NULL;
44 #define LDAPMOD_MAXLINE 4096
46 /* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */
47 #define T_VERSION_STR "version"
48 #define T_REPLICA_STR "replica"
50 #define T_CONTROL_STR "control"
51 #define T_CHANGETYPESTR "changetype"
52 #define T_ADDCTSTR "add"
53 #define T_MODIFYCTSTR "modify"
54 #define T_DELETECTSTR "delete"
55 #define T_MODRDNCTSTR "modrdn"
56 #define T_MODDNCTSTR "moddn"
57 #define T_RENAMECTSTR "rename"
58 #define T_MODOPADDSTR "add"
59 #define T_MODOPREPLACESTR "replace"
60 #define T_MODOPDELETESTR "delete"
61 #define T_MODSEPSTR "-"
62 #define T_NEWRDNSTR "newrdn"
63 #define T_DELETEOLDRDNSTR "deleteoldrdn"
64 #define T_NEWSUPSTR "newsuperior"
67 static int process_ldif_rec LDAP_P(( char *rbuf, int count ));
68 static int parse_ldif_control LDAP_P(( char *line, LDAPControl ***pctrls ));
69 static void addmodifyop LDAP_P((
70 LDAPMod ***pmodsp, int modop,
72 struct berval *value ));
73 static int domodify LDAP_P((
78 static int dodelete LDAP_P((
80 LDAPControl **pctrls ));
81 static int dorename LDAP_P((
86 LDAPControl **pctrls ));
87 static char *read_one_record LDAP_P(( FILE *fp ));
92 fprintf( stderr, _("Add or modify entries from an LDAP server\n\n"));
93 fprintf( stderr, _("usage: %s [options]\n"), prog);
94 fprintf( stderr, _(" The list of desired operations are read from stdin or from the file\n"));
95 fprintf( stderr, _(" specified by \"-f file\".\n"));
96 fprintf( stderr, _("Add or modify options:\n"));
97 fprintf( stderr, _(" -a add values (default%s)\n"), (ldapadd ? "" : _(" is to replace")));
98 fprintf( stderr, _(" -F force all changes records to be used\n"));
99 fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
101 exit( EXIT_FAILURE );
105 const char options[] = "aFrS:"
106 "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
109 handle_private_option( int i )
113 char *control, *cvalue;
115 case 'E': /* modify controls */
116 if( protocol == LDAP_VERSION2 ) {
117 fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
119 exit( EXIT_FAILURE );
122 /* should be extended to support comma separated list of
123 * [!]key[=value] parameters, e.g. -E !foo,bar=567
128 if( optarg[0] == '!' ) {
133 control = ber_strdup( optarg );
134 if ( (cvalue = strchr( control, '=' )) != NULL ) {
137 fprintf( stderr, _("Invalid modify control name: %s\n"), control );
145 case 'F': /* force all changes records to be used */
149 case 'r': /* replace (obsolete) */
152 case 'S': /* skipped modifications to file */
153 if( rejfile != NULL ) {
154 fprintf( stderr, _("%s: -S previously specified\n"), prog );
155 exit( EXIT_FAILURE );
157 rejfile = ber_strdup( optarg );
168 main( int argc, char **argv )
170 char *rbuf, *start, *rejbuf = NULL;
172 char *matched_msg, *error_msg;
177 prog = lutil_progname( "ldapmodify", argc, argv );
179 /* strncmp instead of strcmp since NT binaries carry .exe extension */
180 ldapadd = ( strncasecmp( prog, "ldapadd", sizeof("ldapadd")-1 ) == 0 );
182 /* Print usage when no parameters */
183 if( argc < 2 ) usage();
185 tool_args( argc, argv );
187 if ( argc != optind )
190 if ( rejfile != NULL ) {
191 if (( rejfp = fopen( rejfile, "w" )) == NULL ) {
193 return( EXIT_FAILURE );
199 if ( infile != NULL ) {
200 if (( fp = fopen( infile, "r" )) == NULL ) {
202 return( EXIT_FAILURE );
211 ld = tool_conn_setup( not, 0 );
214 if ( pw_file || want_bindpw ) {
216 rc = lutil_get_filed_password( pw_file, &passwd );
217 if( rc ) return EXIT_FAILURE;
219 passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
220 passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
229 if ( authzid || manageDSAit || noop )
230 tool_server_controls( ld, NULL, 0 );
234 while (( rc == 0 || contoper ) &&
235 ( rbuf = read_one_record( fp )) != NULL ) {
241 len = strlen( rbuf );
242 if (( rejbuf = (char *)ber_memalloc( len+1 )) == NULL ) {
244 exit( EXIT_FAILURE );
246 memcpy( rejbuf, rbuf, len+1 );
249 rc = process_ldif_rec( start, count );
254 fprintf(rejfp, _("# Error: %s (%d)"), ldap_err2string(rc), rc);
257 ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &matched_msg);
258 if ( matched_msg != NULL ) {
259 if ( *matched_msg != '\0' )
260 fprintf( rejfp, _(", matched DN: %s"), matched_msg );
261 ldap_memfree( matched_msg );
265 ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error_msg);
266 if ( error_msg != NULL ) {
267 if ( *error_msg != '\0' )
268 fprintf( rejfp, _(", additional info: %s"), error_msg );
269 ldap_memfree( error_msg );
271 fprintf( rejfp, "\n%s\n", rejbuf );
282 if ( rejfp != NULL ) {
291 process_ldif_rec( char *rbuf, int count )
293 char *line, *dn, *type, *newrdn, *newsup, *p;
294 int rc, linenum, modop, replicaport;
295 int expect_modop, expect_sep, expect_ct, expect_newrdn, expect_newsup;
296 int expect_deleteoldrdn, deleteoldrdn;
297 int saw_replica, use_record, new_entry, delete_entry, got_all;
301 LDAPControl **pctrls;
305 rc = got_all = saw_replica = delete_entry = modop = expect_modop = 0;
306 expect_deleteoldrdn = expect_newrdn = expect_newsup = 0;
307 expect_sep = expect_ct = 0;
314 dn = newrdn = newsup = NULL;
316 while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) {
319 if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) {
325 if ( ldif_parse_line( line, &type, &val.bv_val, &val.bv_len ) < 0 ) {
326 fprintf( stderr, _("%s: invalid format (line %d) entry: \"%s\"\n"),
327 prog, linenum, dn == NULL ? "" : dn );
328 rc = LDAP_PARAM_ERROR;
333 if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) {
335 if (( p = strchr( val.bv_val, ':' )) == NULL ) {
339 replicaport = atoi( p );
341 if ( ldaphost != NULL && strcasecmp( val.bv_val, ldaphost ) == 0 &&
342 replicaport == ldapport ) {
345 } else if ( count == 1 && linenum == 1 &&
346 strcasecmp( type, T_VERSION_STR ) == 0 )
348 if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) {
349 fprintf( stderr, _("%s: invalid version %s, line %d (ignored)\n"),
350 prog, val.bv_val, linenum );
354 } else if ( strcasecmp( type, T_DN_STR ) == 0 ) {
355 if (( dn = ber_strdup( val.bv_val )) == NULL ) {
357 exit( EXIT_FAILURE );
361 goto end_line; /* skip all lines until we see "dn:" */
366 /* Check for "control" tag after dn and before changetype. */
367 if (strcasecmp(type, T_CONTROL_STR) == 0) {
368 /* Parse and add it to the list of controls */
369 rc = parse_ldif_control( line, &pctrls );
371 fprintf( stderr, _("%s: Error processing %s line, line %d: %s\n"),
372 prog, T_CONTROL_STR, linenum, ldap_err2string(rc) );
378 if ( !use_record && saw_replica ) {
379 printf(_("%s: skipping change record for entry: %s\n"), prog, dn);
380 printf(_("\t(LDAP host/port does not match replica: lines)\n"));
383 ber_memfree( val.bv_val );
387 if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) {
388 #ifdef LIBERAL_CHANGETYPE_MODOP
389 /* trim trailing spaces (and log warning ...) */
392 for ( icnt = val.bv_len; --icnt > 0; ) {
393 if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
398 if ( ++icnt != val.bv_len ) {
399 fprintf( stderr, _("%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n"),
400 prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
401 val.bv_val[icnt] = '\0';
403 #endif /* LIBERAL_CHANGETYPE_MODOP */
405 if ( strcasecmp( val.bv_val, T_MODIFYCTSTR ) == 0 ) {
408 } else if ( strcasecmp( val.bv_val, T_ADDCTSTR ) == 0 ) {
410 } else if ( strcasecmp( val.bv_val, T_MODRDNCTSTR ) == 0
411 || strcasecmp( val.bv_val, T_MODDNCTSTR ) == 0
412 || strcasecmp( val.bv_val, T_RENAMECTSTR ) == 0)
415 } else if ( strcasecmp( val.bv_val, T_DELETECTSTR ) == 0 ) {
416 got_all = delete_entry = 1;
419 _("%s: unknown %s \"%s\" (line %d of entry \"%s\")\n"),
420 prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
421 rc = LDAP_PARAM_ERROR;
424 } else if ( ldapadd ) { /* missing changetype => add */
426 modop = LDAP_MOD_ADD;
428 expect_modop = 1; /* missing changetype => modify */
432 if ( expect_modop ) {
433 #ifdef LIBERAL_CHANGETYPE_MODOP
434 /* trim trailing spaces (and log warning ...) */
437 for ( icnt = val.bv_len; --icnt > 0; ) {
438 if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
443 if ( ++icnt != val.bv_len ) {
444 fprintf( stderr, _("%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n"),
445 prog, type, val.bv_val, linenum, dn );
446 val.bv_val[icnt] = '\0';
448 #endif /* LIBERAL_CHANGETYPE_MODOP */
452 if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) {
453 modop = LDAP_MOD_ADD;
455 } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) {
456 modop = LDAP_MOD_REPLACE;
457 addmodifyop( &pmods, modop, val.bv_val, NULL );
459 } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) {
460 modop = LDAP_MOD_DELETE;
461 addmodifyop( &pmods, modop, val.bv_val, NULL );
463 } else { /* no modify op: use default */
464 modop = ldapadd ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
468 if ( expect_newrdn ) {
469 if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
470 if (( newrdn = ber_strdup( val.bv_val )) == NULL ) {
472 exit( EXIT_FAILURE );
474 expect_deleteoldrdn = 1;
477 fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"),
478 prog, T_NEWRDNSTR, type, linenum, dn );
479 rc = LDAP_PARAM_ERROR;
481 } else if ( expect_deleteoldrdn ) {
482 if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) {
483 deleteoldrdn = ( *val.bv_val == '0' ) ? 0 : 1;
484 expect_deleteoldrdn = 0;
488 fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"),
489 prog, T_DELETEOLDRDNSTR, type, linenum, dn );
490 rc = LDAP_PARAM_ERROR;
492 } else if ( expect_newsup ) {
493 if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
494 if (( newsup = ber_strdup( val.bv_val )) == NULL ) {
496 exit( EXIT_FAILURE );
500 fprintf( stderr, _("%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n"),
501 prog, T_NEWSUPSTR, type, linenum, dn );
502 rc = LDAP_PARAM_ERROR;
504 } else if ( got_all ) {
506 _("%s: extra lines at end (line %d of entry \"%s\")\n"),
508 rc = LDAP_PARAM_ERROR;
510 addmodifyop( &pmods, modop, type, &val );
515 ber_memfree( val.bv_val );
522 if( version && linenum == 1 ) {
526 /* If default controls are set (as with -M option) and controls are
527 specified in the LDIF file, we must add the default controls to
528 the list of controls sent with the ldap operation.
532 LDAPControl **defctrls = NULL; /* Default server controls */
533 LDAPControl **newctrls = NULL;
534 ldap_get_option(ld, LDAP_OPT_SERVER_CONTROLS, &defctrls);
536 int npc=0; /* Number of LDIF controls */
537 int ndefc=0; /* Number of default controls */
538 while (pctrls[npc]) /* Count LDIF controls */
540 while (defctrls[ndefc]) /* Count default controls */
542 newctrls = ber_memrealloc(pctrls, (npc+ndefc+1)*sizeof(LDAPControl*));
543 if (newctrls == NULL)
548 for (i=npc; i<npc+ndefc; i++) {
549 pctrls[i] = ldap_control_dup(defctrls[i-npc]);
550 if (pctrls[i] == NULL) {
555 pctrls[npc+ndefc] = NULL;
557 ldap_controls_free(defctrls); /* Must be freed by library */
564 if ( delete_entry ) {
565 rc = dodelete( dn, pctrls );
566 } else if ( newrdn != NULL ) {
567 rc = dorename( dn, newrdn, newsup, deleteoldrdn, pctrls );
569 rc = domodify( dn, pmods, pctrls, new_entry );
572 if ( rc == LDAP_SUCCESS ) {
580 if ( newrdn != NULL ) {
583 if ( pmods != NULL ) {
584 ldap_mods_free( pmods, 1 );
587 if (pctrls != NULL) {
588 ldap_controls_free( pctrls );
594 /* Parse an LDIF control line of the form
595 control: oid [true/false] [: value] or
596 control: oid [true/false] [:: base64-value] or
597 control: oid [true/false] [:< url]
598 The control is added to the list of controls in *ppctrls.
601 parse_ldif_control( char *line,
602 LDAPControl ***ppctrls )
605 int criticality = 0; /* Default is false if not present */
608 ber_len_t value_len = 0;
610 char *s, *oidStart, *pcolon;
611 LDAPControl *newctrl = NULL;
612 LDAPControl **pctrls = NULL;
617 s = line + strlen(T_CONTROL_STR); /* Skip over "control" */
618 pcolon = s; /* Save this position for later */
619 if (*s++ != ':') /* Make sure colon follows */
620 return ( LDAP_PARAM_ERROR );
621 while (*s && isspace((unsigned char)*s))
622 s++; /* Skip white space before OID */
624 /* OID should come next. Validate and extract it. */
626 return ( LDAP_PARAM_ERROR );
628 while (isdigit((unsigned char)*s) || *s == '.')
629 s++; /* OID should be digits or . */
631 return ( LDAP_PARAM_ERROR ); /* OID was not present */
632 if (*s) { /* End of OID should be space or NULL */
633 if (!isspace((unsigned char)*s))
634 return ( LDAP_PARAM_ERROR ); /* else OID contained invalid chars */
635 *s++ = 0; /* Replace space with null to terminate */
639 oid = ber_strdup(oidStart);
641 return ( LDAP_NO_MEMORY );
643 /* Optional Criticality field is next. */
644 while (*s && isspace((unsigned char)*s))
645 s++; /* Skip white space before criticality */
646 if (strncasecmp(s, "true", 4) == 0) {
650 else if (strncasecmp(s, "false", 5) == 0) {
655 /* Optional value field is next */
656 while (*s && isspace((unsigned char)*s))
657 s++; /* Skip white space before value */
659 if (*s != ':') { /* If value is present, must start with : */
660 rc = LDAP_PARAM_ERROR;
664 /* Shift value down over OID and criticality so it's in the form
666 control:: base64-value
668 Then we can use ldif_parse_line to extract and decode the value
670 while ( (*pcolon++ = *s++) != 0) /* Shift value */
672 rc = ldif_parse_line(line, &type, &val, &value_len);
673 if (type) ber_memfree(type); /* Don't need this field*/
675 rc = LDAP_PARAM_ERROR;
680 /* Create a new LDAPControl structure. */
681 newctrl = (LDAPControl *)ber_memalloc(sizeof(LDAPControl));
682 if ( newctrl == NULL ) {
686 newctrl->ldctl_oid = oid;
688 newctrl->ldctl_iscritical = criticality;
689 newctrl->ldctl_value.bv_len = value_len;
690 newctrl->ldctl_value.bv_val = val;
693 /* Add the new control to the passed-in list of controls. */
696 while ( pctrls[i] ) /* Count the # of controls passed in */
699 /* Allocate 1 more slot for the new control and 1 for the NULL. */
700 pctrls = (LDAPControl **)ber_memrealloc(pctrls, (i+2)*(sizeof(LDAPControl *)));
701 if (pctrls == NULL) {
712 if (newctrl->ldctl_oid)
713 ber_memfree(newctrl->ldctl_oid);
714 if (newctrl->ldctl_value.bv_val)
715 ber_memfree(newctrl->ldctl_value.bv_val);
716 ber_memfree(newctrl);
738 modop |= LDAP_MOD_BVALUES;
741 if ( pmods != NULL ) {
742 for ( ; pmods[ i ] != NULL; ++i ) {
743 if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
744 pmods[ i ]->mod_op == modop )
751 if ( pmods == NULL || pmods[ i ] == NULL ) {
752 if (( pmods = (LDAPMod **)ber_memrealloc( pmods, (i + 2) *
753 sizeof( LDAPMod * ))) == NULL )
756 exit( EXIT_FAILURE );
760 pmods[ i + 1 ] = NULL;
762 pmods[ i ] = (LDAPMod *)ber_memcalloc( 1, sizeof( LDAPMod ));
763 if ( pmods[ i ] == NULL ) {
765 exit( EXIT_FAILURE );
768 pmods[ i ]->mod_op = modop;
769 pmods[ i ]->mod_type = ber_strdup( attr );
770 if ( pmods[ i ]->mod_type == NULL ) {
772 exit( EXIT_FAILURE );
778 if ( pmods[ i ]->mod_bvalues != NULL ) {
779 for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
784 pmods[ i ]->mod_bvalues = (struct berval **) ber_memrealloc(
785 pmods[ i ]->mod_bvalues, (j + 2) * sizeof( struct berval * ));
786 if ( pmods[ i ]->mod_bvalues == NULL ) {
787 perror( "ber_realloc" );
788 exit( EXIT_FAILURE );
791 pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
792 pmods[ i ]->mod_bvalues[ j ] = ber_bvdup( val );
793 if ( pmods[ i ]->mod_bvalues[ j ] == NULL ) {
794 perror( "ber_bvdup" );
795 exit( EXIT_FAILURE );
805 LDAPControl **pctrls,
808 int i, j, k, notascii, op;
811 if ( pmods == NULL ) {
812 fprintf( stderr, _("%s: no attributes to change or add (entry=\"%s\")\n"),
814 return( LDAP_PARAM_ERROR );
817 for ( i = 0; pmods[ i ] != NULL; ++i ) {
818 op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES;
819 if( op == LDAP_MOD_ADD && ( pmods[i]->mod_bvalues == NULL )) {
821 _("%s: attribute \"%s\" has no values (entry=\"%s\")\n"),
822 prog, pmods[i]->mod_type, dn );
823 return LDAP_PARAM_ERROR;
828 for ( i = 0; pmods[ i ] != NULL; ++i ) {
829 op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES;
830 printf( "%s %s:\n", op == LDAP_MOD_REPLACE ?
831 _("replace") : op == LDAP_MOD_ADD ?
832 _("add") : _("delete"), pmods[ i ]->mod_type );
833 if ( pmods[ i ]->mod_bvalues != NULL ) {
834 for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
835 bvp = pmods[ i ]->mod_bvalues[ j ];
837 for ( k = 0; (unsigned long) k < bvp->bv_len; ++k ) {
838 if ( !isascii( bvp->bv_val[ k ] )) {
844 printf( _("\tNOT ASCII (%ld bytes)\n"), bvp->bv_len );
846 printf( "\t%s\n", bvp->bv_val );
854 printf( "%sadding new entry \"%s\"\n", not ? "!" : "", dn );
856 printf( "%smodifying entry \"%s\"\n", not ? "!" : "", dn );
861 i = ldap_add_ext_s( ld, dn, pmods, pctrls, NULL );
863 i = ldap_modify_ext_s( ld, dn, pmods, pctrls, NULL );
865 if ( i != LDAP_SUCCESS ) {
866 /* print error message about failed update including DN */
867 fprintf( stderr, _("%s: update failed: %s\n"), prog, dn );
868 ldap_perror( ld, newentry ? "ldap_add" : "ldap_modify" );
869 } else if ( verbose ) {
870 printf( _("modify complete\n") );
885 LDAPControl **pctrls )
889 printf( _("%sdeleting entry \"%s\"\n"), not ? "!" : "", dn );
891 if (( rc = ldap_delete_ext_s( ld, dn, pctrls, NULL )) != LDAP_SUCCESS ) {
892 fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn );
893 ldap_perror( ld, "ldap_delete" );
894 } else if ( verbose ) {
895 printf( _("delete complete") );
913 LDAPControl **pctrls )
918 printf( _("%smodifying rdn of entry \"%s\"\n"), not ? "!" : "", dn );
920 printf( _("\tnew RDN: \"%s\" (%skeep existing values)\n"),
921 newrdn, deleteoldrdn ? _("do not ") : "" );
924 if (( rc = ldap_rename_s( ld, dn, newrdn, newsup, deleteoldrdn, pctrls, NULL ))
926 fprintf( stderr, _("%s: rename failed: %s\n"), prog, dn );
927 ldap_perror( ld, "ldap_modrdn" );
929 printf( _("modrdn completed\n") );
942 read_one_record( FILE *fp )
944 char *buf, line[ LDAPMOD_MAXLINE ];
950 while ( fgets( line, sizeof(line), fp ) != NULL ) {
951 int len = strlen( line );
953 if( len < 2 || ( len == 2 && *line == '\r' )) {
961 if ( lcur + len + 1 > lmax ) {
962 lmax = LDAPMOD_MAXLINE
963 * (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 );
965 if (( buf = (char *)ber_memrealloc( buf, lmax )) == NULL ) {
967 exit( EXIT_FAILURE );
971 strcpy( buf + lcur, line );