Project

General

Profile

mod_dirlisting_extra_head_confvar.patch

Patch for 1.4.19 - jcak77, 2008-03-19 21:40

View differences:

lighttpd-1.4.19/src/mod_dirlisting.c 2008-03-19 22:27:11.000000000 +0100
60 60
	buffer *external_css;
61 61
	buffer *encoding;
62 62
	buffer *set_footer;
63
	buffer *extra_head;
63 64
} plugin_config;
64 65

  
65 66
typedef struct {
......
175 176
			buffer_free(s->external_css);
176 177
			buffer_free(s->encoding);
177 178
			buffer_free(s->set_footer);
179
			buffer_free(s->extra_head);
178 180

  
179 181
			free(s);
180 182
		}
......
243 245
#define CONFIG_HIDE_HEADER_FILE "dir-listing.hide-header-file"
244 246
#define CONFIG_DIR_LISTING      "server.dir-listing"
245 247
#define CONFIG_SET_FOOTER       "dir-listing.set-footer"
248
#define CONFIG_EXTRA_HEAD       "dir-listing.extra-head"
246 249

  
247 250

  
248 251
SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
......
261 264
		{ CONFIG_HIDE_HEADER_FILE, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
262 265
		{ CONFIG_DIR_LISTING,      NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
263 266
		{ CONFIG_SET_FOOTER,       NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
267
		{ CONFIG_EXTRA_HEAD,       NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 11*/
264 268

  
265 269
		{ NULL,                          NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
266 270
	};
......
284 288
		s->hide_header_file = 0;
285 289
		s->encoding = buffer_init();
286 290
		s->set_footer = buffer_init();
291
		s->extra_head = buffer_init();
287 292

  
288 293
		cv[0].destination = s->excludes;
289 294
		cv[1].destination = &(s->dir_listing);
......
296 301
		cv[8].destination = &(s->hide_header_file);
297 302
		cv[9].destination = &(s->dir_listing); /* old name */
298 303
		cv[10].destination = s->set_footer;
304
		cv[11].destination = s->extra_head;
299 305

  
300 306
		p->config_storage[i] = s;
301 307
		ca = ((data_config *)srv->config_context->data[i])->value;
......
326 332
	PATCH(hide_header_file);
327 333
	PATCH(excludes);
328 334
	PATCH(set_footer);
335
	PATCH(extra_head);
329 336

  
330 337
	/* skip the first, the global context */
331 338
	for (i = 1; i < srv->config_context->used; i++) {
......
358 365
				PATCH(hide_header_file);
359 366
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SET_FOOTER))) {
360 367
				PATCH(set_footer);
368
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXTRA_HEAD))) {
369
				PATCH(extra_head);
361 370
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXCLUDE))) {
362 371
				PATCH(excludes);
363 372
			}
......
504 513
			"</style>\n"
505 514
		);
506 515
	}
507

  
516
	if (p->conf.extra_head->used > 1) {
517
		stream s;
518
		if (-1 != stream_open(&s, p->conf.extra_head)) {
519
			buffer_append_string_len(out, s.start, s.size);
520
		}
521
		stream_close(&s);
522
	}
508 523
	BUFFER_APPEND_STRING_CONST(out, "</head>\n<body>\n");
509 524

  
510 525
	/* HEADER.txt */