2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2000-2007 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This work was initially developed by Pierangelo Masarati for
17 * inclusion in OpenLDAP Software.
24 #include "rewrite-int.h"
35 int in_quoted_field = 0, cnt = 0;
38 for ( p = buf; isspace( (unsigned char) p[ 0 ] ); p++ );
40 if ( p[ 0 ] == '#' ) {
44 for ( begin = p; p[ 0 ] != '\0'; p++ ) {
45 if ( p[ 0 ] == '\\' && p[ 1 ] != '\0' ) {
47 } else if ( p[ 0 ] == '\'' || p[ 0 ] == '\"') {
48 if ( in_quoted_field && p[ 0 ] == quote ) {
49 in_quoted_field = 1 - in_quoted_field;
53 if ( ++cnt == maxargs ) {
57 for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
61 } else if ( !in_quoted_field ) {
66 in_quoted_field = 1 - in_quoted_field;
69 } else if ( isspace( (unsigned char) p[ 0 ] ) && !in_quoted_field ) {
73 if ( ++cnt == maxargs ) {
78 for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
92 struct rewrite_info *info
100 * Empty rule at the beginning of the context
103 for ( lineno = 0; fgets( buf, sizeof( buf ), fin ); lineno++ ) {
104 switch ( parse_line( argv, &argc, sizeof( argv ) - 1, buf ) ) {
110 if ( strncasecmp( argv[ 0 ], "rewrite", 7 ) == 0 ) {
112 rc = rewrite_parse( info, "file", lineno,
114 if ( rc != REWRITE_SUCCESS ) {
122 return REWRITE_SUCCESS;