- if ( ++icnt != val.bv_len ) {
- fprintf( stderr, _("%s: illegal trailing space after"
- " \"%s: %s\" trimmed (line %d of entry \"%s\")\n"),
- prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
- val.bv_val[icnt] = '\0';
- }
-#endif /* LIBERAL_CHANGETYPE_MODOP */
-
- if ( strcasecmp( val.bv_val, T_MODIFYCTSTR ) == 0 ) {
- new_entry = 0;
- expect_modop = 1;
- } else if ( strcasecmp( val.bv_val, T_ADDCTSTR ) == 0 ) {
- new_entry = 1;
- } else if ( strcasecmp( val.bv_val, T_MODRDNCTSTR ) == 0
- || strcasecmp( val.bv_val, T_MODDNCTSTR ) == 0
- || strcasecmp( val.bv_val, T_RENAMECTSTR ) == 0)
- {
- expect_newrdn = 1;
- } else if ( strcasecmp( val.bv_val, T_DELETECTSTR ) == 0 ) {
- got_all = delete_entry = 1;
- } else {
- fprintf( stderr,
- _("%s: unknown %s \"%s\" (line %d of entry \"%s\")\n"),
- prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
- rc = LDAP_PARAM_ERROR;
- }
- goto end_line;
- } else if ( ldapadd ) { /* missing changetype => add */
- new_entry = 1;
- modop = LDAP_MOD_ADD;
- } else {
- expect_modop = 1; /* missing changetype => modify */
- }
- }
-
- if ( expect_modop ) {
-#ifdef LIBERAL_CHANGETYPE_MODOP
- /* trim trailing spaces (and log warning ...) */
- int icnt;
- for ( icnt = val.bv_len; --icnt > 0; ) {
- if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) break;
- }
-
- if ( ++icnt != val.bv_len ) {
- fprintf( stderr, _("%s: illegal trailing space after"
- " \"%s: %s\" trimmed (line %d of entry \"%s\")\n"),
- prog, type, val.bv_val, linenum, dn );
- val.bv_val[icnt] = '\0';
- }
-#endif /* LIBERAL_CHANGETYPE_MODOP */
-
- expect_modop = 0;
- expect_sep = 1;
- if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) {
- modop = LDAP_MOD_ADD;
- goto end_line;
- } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) {
- modop = LDAP_MOD_REPLACE;
- addmodifyop( &pmods, modop, val.bv_val, NULL );
- goto end_line;
- } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) {
- modop = LDAP_MOD_DELETE;
- addmodifyop( &pmods, modop, val.bv_val, NULL );
- goto end_line;
- } else if ( strcasecmp( type, T_MODOPINCREMENTSTR ) == 0 ) {
- modop = LDAP_MOD_INCREMENT;
- addmodifyop( &pmods, modop, val.bv_val, NULL );
- goto end_line;
- } else { /* no modify op: use default */
- modop = ldapadd ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
- }
- }
-
- if ( expect_newrdn ) {
- if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
- if (( newrdn = ber_strdup( val.bv_val )) == NULL ) {
- perror( "strdup" );
- exit( EXIT_FAILURE );
- }
- expect_deleteoldrdn = 1;
- expect_newrdn = 0;
- } else {
- fprintf( stderr, _("%s: expecting \"%s:\" but saw"
- " \"%s:\" (line %d of entry \"%s\")\n"),
- prog, T_NEWRDNSTR, type, linenum, dn );
- rc = LDAP_PARAM_ERROR;
- }
- } else if ( expect_deleteoldrdn ) {
- if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) {
- deleteoldrdn = ( *val.bv_val == '0' ) ? 0 : 1;
- expect_deleteoldrdn = 0;
- expect_newsup = 1;
- got_all = 1;
- } else {
- fprintf( stderr, _("%s: expecting \"%s:\" but saw"
- " \"%s:\" (line %d of entry \"%s\")\n"),
- prog, T_DELETEOLDRDNSTR, type, linenum, dn );
- rc = LDAP_PARAM_ERROR;
- }
- } else if ( expect_newsup ) {
- if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
- if (( newsup = ber_strdup( val.bv_val )) == NULL ) {
- perror( "strdup" );
- exit( EXIT_FAILURE );
- }
- expect_newsup = 0;
- } else {
- fprintf( stderr, _("%s: expecting \"%s:\" but saw"
- " \"%s:\" (line %d of entry \"%s\")\n"),
- prog, T_NEWSUPSTR, type, linenum, dn );
- rc = LDAP_PARAM_ERROR;
- }
- } else if ( got_all ) {
- fprintf( stderr,
- _("%s: extra lines at end (line %d of entry \"%s\")\n"),
- prog, linenum, dn );
- rc = LDAP_PARAM_ERROR;
- } else {
- if ( new_entry && strcasecmp( type, T_DN_STR ) == 0 ) {
- fprintf( stderr, _("%s: attributeDescription \"%s\":"
- " (possible missing newline"
- " after line %d of entry \"%s\"?)\n"),
- prog, type, linenum - 1, dn );
- }
- addmodifyop( &pmods, modop, type, &val );
- }
-
-end_line:
- ber_memfree( type );
- ber_memfree( val.bv_val );