summaryrefslogtreecommitdiff
path: root/src/data_fastcgi.c
blob: 714b2905e53df3499821e7564fca52fa299c8d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "array.h"
#include "fastcgi.h"

static data_unset *data_fastcgi_copy(const data_unset *s) {
	data_fastcgi *src = (data_fastcgi *)s;
	data_fastcgi *ds = data_fastcgi_init();

	buffer_copy_string_buffer(ds->key, src->key);
	buffer_copy_string_buffer(ds->host, src->host);
	ds->is_index_key = src->is_index_key;
	return (data_unset *)ds;
}

static void data_fastcgi_free(data_unset *d) {
	data_fastcgi *ds = (data_fastcgi *)d;
	
	buffer_free(ds->key);
	buffer_free(ds->host);
	
	free(d);
}

static void data_fastcgi_reset(data_unset *d) {
	data_fastcgi *ds = (data_fastcgi *)d;
	
	buffer_reset(ds->key);
	buffer_reset(ds->host);
	
}

static int data_fastcgi_insert_dup(data_unset *dst, data_unset *src) {
	UNUSED(dst);

	src->free(src);
	
	return 0;
}

static void data_fastcgi_print(const data_unset *d, int depth) {
	data_fastcgi *ds = (data_fastcgi *)d;
	UNUSED(depth);
	
	fprintf(stderr, "fastcgi(%s)", ds->host->ptr);
}


data_fastcgi *data_fastcgi_init(void) {
	data_fastcgi *ds;
	
	ds = calloc(1, sizeof(*ds));
	
	ds->key = buffer_init();
	ds->host = buffer_init();
	ds->port = 0;
	ds->is_disabled = 0;
	
	ds->copy = data_fastcgi_copy;
	ds->free = data_fastcgi_free;
	ds->reset = data_fastcgi_reset;
	ds->insert_dup = data_fastcgi_insert_dup;
	ds->print = data_fastcgi_print;
	ds->type = TYPE_FASTCGI;
	
	return ds;
}