Project

General

Profile

Feature #1194 » mod_evhost_dot_notation.patch

Patch for 1.4.x branch - admin, 2007-05-25 12:03

View differences:

src/mod_evhost.c (working copy)
83 83
			s->path_pieces[s->len+1] = buffer_init();
84 84

  
85 85
			buffer_copy_string_len(s->path_pieces[s->len],pos,ptr-pos);
86
			pos = ptr + 2;
87 86

  
88
			buffer_copy_string_len(s->path_pieces[s->len+1],ptr++,2);
87
			if(*(ptr+2) == '.') {
88
				pos = ptr + 4;
89
				buffer_copy_string_len(s->path_pieces[s->len+1],ptr++,4);
90
			} else {
91
				pos = ptr + 2;
92
				buffer_copy_string_len(s->path_pieces[s->len+1],ptr++,2);
93
			}
89 94

  
90 95
			s->len += 2;
91 96
		}
......
287 292
			if (*(ptr+1) == '%') {
288 293
				/* %% */
289 294
				BUFFER_APPEND_STRING_CONST(p->tmp_buf,"%");
295
			} else if (*(ptr+2) == '.') {
296
				/* dot notation in pattern, ie %3.1 insert 1st char of %3 */
297
				char key[3];
298
				int poffset = 0;
299
				strncpy(key, p->conf.path_pieces[i]->ptr, 2);
300
				key[2] = NULL;
301
				ds = (data_string *)array_get_element(parsed_host,key);
302

  
303
				/* check if the index is outside the string, indexing starts at 1 in config */
304
				poffset = atoi(ptr+3)-1;
305

  
306
				if (ds != NULL && (poffset >= 0 && poffset < ds->value->used)) {
307
					buffer_append_string_len(p->tmp_buf,ds->value->ptr+poffset, 1);
308
				}
290 309
			} else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) {
291 310
				if (ds->value->used) {
292 311
					buffer_append_string_buffer(p->tmp_buf,ds->value);
(1-1/3)