mongrel 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +504 -0
- data/LICENSE +504 -0
- data/README +117 -0
- data/Rakefile +30 -0
- data/doc/rdoc/classes/Mongrel.html +144 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000023.html +18 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000024.html +18 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +167 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000013.html +18 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html +21 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +159 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000019.html +17 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.html +271 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html +29 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html +29 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html +41 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html +27 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html +27 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +177 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000025.html +30 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +202 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000020.html +21 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000021.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000022.html +25 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.html +336 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +26 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html +58 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html +22 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +257 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000015.html +54 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000016.html +50 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000017.html +36 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000018.html +73 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +756 -0
- data/doc/rdoc/files/LICENSE.html +756 -0
- data/doc/rdoc/files/README.html +273 -0
- data/doc/rdoc/files/ext/http11/http11_c.html +101 -0
- data/doc/rdoc/files/lib/mongrel_rb.html +111 -0
- data/doc/rdoc/fr_class_index.html +35 -0
- data/doc/rdoc/fr_file_index.html +31 -0
- data/doc/rdoc/fr_method_index.html +51 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/camping/blog.rb +300 -0
- data/examples/camping/tepee.rb +168 -0
- data/examples/simpletest.rb +16 -0
- data/examples/webrick_compare.rb +20 -0
- data/ext/http11/MANIFEST +0 -0
- data/ext/http11/ext_help.h +14 -0
- data/ext/http11/extconf.rb +6 -0
- data/ext/http11/http11.c +436 -0
- data/ext/http11/http11_parser.c +918 -0
- data/ext/http11/http11_parser.h +37 -0
- data/ext/http11/tst.h +40 -0
- data/ext/http11/tst_cleanup.c +24 -0
- data/ext/http11/tst_delete.c +146 -0
- data/ext/http11/tst_grow_node_free_list.c +38 -0
- data/ext/http11/tst_init.c +41 -0
- data/ext/http11/tst_insert.c +192 -0
- data/ext/http11/tst_search.c +54 -0
- data/lib/mongrel.rb +298 -0
- data/setup.rb +1360 -0
- data/test/test_http11.rb +38 -0
- data/test/test_response.rb +44 -0
- data/test/test_uriclassifier.rb +104 -0
- data/test/test_ws.rb +33 -0
- data/tools/rakehelp.rb +99 -0
- metadata +132 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
#ifndef http11_parser_h
|
2
|
+
#define http11_parser_h
|
3
|
+
|
4
|
+
#include <sys/types.h>
|
5
|
+
|
6
|
+
typedef void (*element_cb)(void *data, const char *at, size_t length);
|
7
|
+
typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
|
8
|
+
|
9
|
+
typedef struct http_parser {
|
10
|
+
int cs;
|
11
|
+
const char *body_start;
|
12
|
+
int content_len;
|
13
|
+
size_t nread;
|
14
|
+
const char *mark;
|
15
|
+
const char *field_start;
|
16
|
+
size_t field_len;
|
17
|
+
|
18
|
+
void *data;
|
19
|
+
|
20
|
+
field_cb http_field;
|
21
|
+
element_cb request_method;
|
22
|
+
element_cb path_info;
|
23
|
+
element_cb query_string;
|
24
|
+
element_cb http_version;
|
25
|
+
|
26
|
+
} http_parser;
|
27
|
+
|
28
|
+
int http_parser_init(http_parser *parser);
|
29
|
+
int http_parser_finish(http_parser *parser);
|
30
|
+
size_t http_parser_execute(http_parser *parser, const char *data, size_t len );
|
31
|
+
int http_parser_has_error(http_parser *parser);
|
32
|
+
int http_parser_is_finished(http_parser *parser);
|
33
|
+
void http_parser_destroy(http_parser *parser);
|
34
|
+
|
35
|
+
#define http_parser_nread(parser) (parser)->nread
|
36
|
+
|
37
|
+
#endif
|
data/ext/http11/tst.h
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
struct node
|
4
|
+
{
|
5
|
+
unsigned char value;
|
6
|
+
struct node *left;
|
7
|
+
struct node *middle;
|
8
|
+
struct node *right;
|
9
|
+
};
|
10
|
+
|
11
|
+
struct tst
|
12
|
+
{
|
13
|
+
int node_line_width;
|
14
|
+
struct node_lines *node_lines;
|
15
|
+
struct node *free_list;
|
16
|
+
struct node *head[127];
|
17
|
+
};
|
18
|
+
|
19
|
+
struct node_lines
|
20
|
+
{
|
21
|
+
struct node *node_line;
|
22
|
+
struct node_lines *next;
|
23
|
+
};
|
24
|
+
|
25
|
+
enum tst_constants
|
26
|
+
{
|
27
|
+
TST_OK, TST_ERROR, TST_NULL_KEY, TST_DUPLICATE_KEY, TST_REPLACE
|
28
|
+
};
|
29
|
+
|
30
|
+
struct tst *tst_init(int node_line_width);
|
31
|
+
|
32
|
+
int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr);
|
33
|
+
|
34
|
+
void *tst_search(unsigned char *key, struct tst *tst, int *prefix_len);
|
35
|
+
|
36
|
+
void *tst_delete(unsigned char *key, struct tst *tst);
|
37
|
+
|
38
|
+
void tst_cleanup(struct tst *tst);
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
#include "tst.h"
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
void tst_cleanup(struct tst *tst)
|
7
|
+
{
|
8
|
+
struct node_lines *current_line;
|
9
|
+
struct node_lines *next_line;
|
10
|
+
|
11
|
+
next_line = tst->node_lines;
|
12
|
+
|
13
|
+
do
|
14
|
+
{
|
15
|
+
current_line = next_line;
|
16
|
+
next_line = current_line->next;
|
17
|
+
free(current_line->node_line);
|
18
|
+
free(current_line);
|
19
|
+
}
|
20
|
+
while(next_line != NULL);
|
21
|
+
|
22
|
+
free(tst);
|
23
|
+
}
|
24
|
+
|
@@ -0,0 +1,146 @@
|
|
1
|
+
|
2
|
+
#include "tst.h"
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
void *tst_delete(unsigned char *key, struct tst *tst)
|
7
|
+
{
|
8
|
+
struct node *current_node;
|
9
|
+
struct node *current_node_parent;
|
10
|
+
struct node *last_branch;
|
11
|
+
struct node *last_branch_parent;
|
12
|
+
struct node *next_node;
|
13
|
+
struct node *last_branch_replacement;
|
14
|
+
struct node *last_branch_dangling_child;
|
15
|
+
int key_index;
|
16
|
+
|
17
|
+
|
18
|
+
if(key[0] == 0)
|
19
|
+
return NULL;
|
20
|
+
if(tst->head[(int)key[0]] == NULL)
|
21
|
+
return NULL;
|
22
|
+
|
23
|
+
last_branch = NULL;
|
24
|
+
last_branch_parent = NULL;
|
25
|
+
current_node = tst->head[(int)key[0]];
|
26
|
+
current_node_parent = NULL;
|
27
|
+
key_index = 1;
|
28
|
+
while(current_node != NULL)
|
29
|
+
{
|
30
|
+
if(key[key_index] == current_node->value)
|
31
|
+
{
|
32
|
+
|
33
|
+
if( (current_node->left != NULL) || (current_node->right != NULL) )
|
34
|
+
{
|
35
|
+
last_branch = current_node;
|
36
|
+
last_branch_parent = current_node_parent;
|
37
|
+
}
|
38
|
+
if(key[key_index] == 0)
|
39
|
+
break;
|
40
|
+
else
|
41
|
+
{
|
42
|
+
current_node_parent = current_node;
|
43
|
+
current_node = current_node->middle;
|
44
|
+
key_index++;
|
45
|
+
continue;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
else if( ((current_node->value == 0) && (key[key_index] < 64)) ||
|
49
|
+
((current_node->value != 0) && (key[key_index] <
|
50
|
+
current_node->value)) )
|
51
|
+
{
|
52
|
+
last_branch_parent = current_node;
|
53
|
+
current_node_parent = current_node;
|
54
|
+
current_node = current_node->left;
|
55
|
+
last_branch = current_node;
|
56
|
+
continue;
|
57
|
+
}
|
58
|
+
else
|
59
|
+
{
|
60
|
+
last_branch_parent = current_node;
|
61
|
+
current_node_parent = current_node;
|
62
|
+
current_node = current_node->right;
|
63
|
+
last_branch = current_node;
|
64
|
+
continue;
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
if(current_node == NULL)
|
69
|
+
return NULL;
|
70
|
+
|
71
|
+
if(last_branch == NULL)
|
72
|
+
{
|
73
|
+
|
74
|
+
next_node = tst->head[(int)key[0]];
|
75
|
+
tst->head[(int)key[0]] = NULL;
|
76
|
+
}
|
77
|
+
else if( (last_branch->left == NULL) && (last_branch->right == NULL) )
|
78
|
+
{
|
79
|
+
|
80
|
+
if(last_branch_parent->left == last_branch)
|
81
|
+
last_branch_parent->left = NULL;
|
82
|
+
else
|
83
|
+
last_branch_parent->right = NULL;
|
84
|
+
|
85
|
+
next_node = last_branch;
|
86
|
+
}
|
87
|
+
else
|
88
|
+
{
|
89
|
+
|
90
|
+
if( (last_branch->left != NULL) && (last_branch->right != NULL) )
|
91
|
+
{
|
92
|
+
last_branch_replacement = last_branch->right;
|
93
|
+
last_branch_dangling_child = last_branch->left;
|
94
|
+
}
|
95
|
+
else if(last_branch->right != NULL)
|
96
|
+
{
|
97
|
+
last_branch_replacement = last_branch->right;
|
98
|
+
last_branch_dangling_child = NULL;
|
99
|
+
}
|
100
|
+
else
|
101
|
+
{
|
102
|
+
last_branch_replacement = last_branch->left;
|
103
|
+
last_branch_dangling_child = NULL;
|
104
|
+
}
|
105
|
+
|
106
|
+
if(last_branch_parent == NULL)
|
107
|
+
tst->head[(int)key[0]]=last_branch_replacement;
|
108
|
+
else
|
109
|
+
{
|
110
|
+
if (last_branch_parent->left == last_branch)
|
111
|
+
last_branch_parent->left = last_branch_replacement;
|
112
|
+
else if (last_branch_parent->right == last_branch)
|
113
|
+
last_branch_parent->right = last_branch_replacement;
|
114
|
+
else
|
115
|
+
last_branch_parent->middle = last_branch_replacement;
|
116
|
+
}
|
117
|
+
|
118
|
+
if(last_branch_dangling_child != NULL)
|
119
|
+
{
|
120
|
+
current_node = last_branch_replacement;
|
121
|
+
|
122
|
+
while (current_node->left != NULL)
|
123
|
+
current_node = current_node->left;
|
124
|
+
|
125
|
+
current_node->left = last_branch_dangling_child;
|
126
|
+
}
|
127
|
+
|
128
|
+
next_node = last_branch;
|
129
|
+
}
|
130
|
+
|
131
|
+
do
|
132
|
+
{
|
133
|
+
current_node = next_node;
|
134
|
+
next_node = current_node->middle;
|
135
|
+
|
136
|
+
current_node->left = NULL;
|
137
|
+
current_node->right = NULL;
|
138
|
+
current_node->middle = tst->free_list;
|
139
|
+
tst->free_list = current_node;
|
140
|
+
}
|
141
|
+
while(current_node->value != 0);
|
142
|
+
|
143
|
+
return next_node;
|
144
|
+
|
145
|
+
}
|
146
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
#include "tst.h"
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
int tst_grow_node_free_list(struct tst *tst)
|
7
|
+
{
|
8
|
+
struct node *current_node;
|
9
|
+
struct node_lines *new_line;
|
10
|
+
int i;
|
11
|
+
|
12
|
+
|
13
|
+
if((new_line = (struct node_lines *) malloc(sizeof(struct node_lines))) == NULL)
|
14
|
+
return TST_ERROR;
|
15
|
+
|
16
|
+
if((new_line->node_line = (struct node *)
|
17
|
+
calloc(tst->node_line_width, sizeof(struct node))) == NULL)
|
18
|
+
{
|
19
|
+
free(new_line);
|
20
|
+
return TST_ERROR;
|
21
|
+
}
|
22
|
+
else
|
23
|
+
{
|
24
|
+
new_line->next = tst->node_lines;
|
25
|
+
tst->node_lines = new_line;
|
26
|
+
}
|
27
|
+
|
28
|
+
current_node = tst->node_lines->node_line;
|
29
|
+
tst->free_list = current_node;
|
30
|
+
for (i = 1; i < tst->node_line_width; i++)
|
31
|
+
{
|
32
|
+
current_node->middle = &(tst->node_lines->node_line[i]);
|
33
|
+
current_node = current_node->middle;
|
34
|
+
}
|
35
|
+
current_node->middle = NULL;
|
36
|
+
return 1;
|
37
|
+
}
|
38
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
#include "tst.h"
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
struct tst *tst_init(int width)
|
7
|
+
{
|
8
|
+
struct tst *tst;
|
9
|
+
struct node *current_node;
|
10
|
+
int i;
|
11
|
+
|
12
|
+
|
13
|
+
if((tst = (struct tst *) calloc(1, sizeof(struct tst))) == NULL)
|
14
|
+
return NULL;
|
15
|
+
|
16
|
+
if ((tst->node_lines = (struct node_lines *) calloc(1, sizeof(struct node_lines))) == NULL)
|
17
|
+
{
|
18
|
+
free(tst);
|
19
|
+
return NULL;
|
20
|
+
}
|
21
|
+
|
22
|
+
tst->node_line_width = width;
|
23
|
+
tst->node_lines->next = NULL;
|
24
|
+
if ((tst->node_lines->node_line = (struct node *) calloc(width, sizeof(struct node))) == NULL)
|
25
|
+
{
|
26
|
+
free(tst->node_lines);
|
27
|
+
free(tst);
|
28
|
+
return NULL;
|
29
|
+
}
|
30
|
+
|
31
|
+
current_node = tst->node_lines->node_line;
|
32
|
+
tst->free_list = current_node;
|
33
|
+
for (i = 1; i < width; i++)
|
34
|
+
{
|
35
|
+
current_node->middle = &(tst->node_lines->node_line[i]);
|
36
|
+
current_node = current_node->middle;
|
37
|
+
}
|
38
|
+
current_node->middle = NULL;
|
39
|
+
return tst;
|
40
|
+
}
|
41
|
+
|
@@ -0,0 +1,192 @@
|
|
1
|
+
|
2
|
+
#include "tst.h"
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
|
7
|
+
int tst_grow_node_free_list(struct tst *tst);
|
8
|
+
int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr)
|
9
|
+
{
|
10
|
+
struct node *current_node;
|
11
|
+
struct node *new_node_tree_begin = NULL;
|
12
|
+
int key_index;
|
13
|
+
int perform_loop = 1;
|
14
|
+
|
15
|
+
|
16
|
+
if (key == NULL)
|
17
|
+
return TST_NULL_KEY;
|
18
|
+
|
19
|
+
if(key[0] == 0)
|
20
|
+
return TST_NULL_KEY;
|
21
|
+
|
22
|
+
if(tst->head[(int)key[0]] == NULL)
|
23
|
+
{
|
24
|
+
|
25
|
+
if(tst->free_list == NULL)
|
26
|
+
{
|
27
|
+
if(tst_grow_node_free_list(tst) != 1)
|
28
|
+
return TST_ERROR;
|
29
|
+
}
|
30
|
+
tst->head[(int)key[0]] = tst->free_list;
|
31
|
+
|
32
|
+
tst->free_list = tst->free_list->middle;
|
33
|
+
current_node = tst->head[(int)key[0]];
|
34
|
+
current_node->value = key[1];
|
35
|
+
if(key[1] == 0)
|
36
|
+
{
|
37
|
+
current_node->middle = data;
|
38
|
+
return TST_OK;
|
39
|
+
}
|
40
|
+
else
|
41
|
+
perform_loop = 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
current_node = tst->head[(int)key[0]];
|
45
|
+
key_index = 1;
|
46
|
+
while(perform_loop == 1)
|
47
|
+
{
|
48
|
+
if(key[key_index] == current_node->value)
|
49
|
+
{
|
50
|
+
|
51
|
+
if(key[key_index] == 0)
|
52
|
+
{
|
53
|
+
if (option == TST_REPLACE)
|
54
|
+
{
|
55
|
+
if (exist_ptr != NULL)
|
56
|
+
*exist_ptr = current_node->middle;
|
57
|
+
|
58
|
+
current_node->middle = data;
|
59
|
+
return TST_OK;
|
60
|
+
}
|
61
|
+
else
|
62
|
+
{
|
63
|
+
if (exist_ptr != NULL)
|
64
|
+
*exist_ptr = current_node->middle;
|
65
|
+
return TST_DUPLICATE_KEY;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
else
|
69
|
+
{
|
70
|
+
if(current_node->middle == NULL)
|
71
|
+
{
|
72
|
+
|
73
|
+
if(tst->free_list == NULL)
|
74
|
+
{
|
75
|
+
if(tst_grow_node_free_list(tst) != 1)
|
76
|
+
return TST_ERROR;
|
77
|
+
}
|
78
|
+
current_node->middle = tst->free_list;
|
79
|
+
|
80
|
+
tst->free_list = tst->free_list->middle;
|
81
|
+
new_node_tree_begin = current_node;
|
82
|
+
current_node = current_node->middle;
|
83
|
+
current_node->value = key[key_index];
|
84
|
+
break;
|
85
|
+
}
|
86
|
+
else
|
87
|
+
{
|
88
|
+
current_node = current_node->middle;
|
89
|
+
key_index++;
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
if( ((current_node->value == 0) && (key[key_index] < 64)) ||
|
96
|
+
((current_node->value != 0) && (key[key_index] <
|
97
|
+
current_node->value)) )
|
98
|
+
{
|
99
|
+
|
100
|
+
if (current_node->left == NULL)
|
101
|
+
{
|
102
|
+
|
103
|
+
if(tst->free_list == NULL)
|
104
|
+
{
|
105
|
+
if(tst_grow_node_free_list(tst) != 1)
|
106
|
+
return TST_ERROR;
|
107
|
+
}
|
108
|
+
current_node->left = tst->free_list;
|
109
|
+
|
110
|
+
tst->free_list = tst->free_list->middle;
|
111
|
+
new_node_tree_begin = current_node;
|
112
|
+
current_node = current_node->left;
|
113
|
+
current_node->value = key[key_index];
|
114
|
+
if(key[key_index] == 0)
|
115
|
+
{
|
116
|
+
current_node->middle = data;
|
117
|
+
return TST_OK;
|
118
|
+
}
|
119
|
+
else
|
120
|
+
break;
|
121
|
+
}
|
122
|
+
else
|
123
|
+
{
|
124
|
+
current_node = current_node->left;
|
125
|
+
continue;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
else
|
129
|
+
{
|
130
|
+
|
131
|
+
if (current_node->right == NULL)
|
132
|
+
{
|
133
|
+
|
134
|
+
if(tst->free_list == NULL)
|
135
|
+
{
|
136
|
+
if(tst_grow_node_free_list(tst) != 1)
|
137
|
+
return TST_ERROR;
|
138
|
+
}
|
139
|
+
current_node->right = tst->free_list;
|
140
|
+
|
141
|
+
tst->free_list = tst->free_list->middle;
|
142
|
+
new_node_tree_begin = current_node;
|
143
|
+
current_node = current_node->right;
|
144
|
+
current_node->value = key[key_index];
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
else
|
148
|
+
{
|
149
|
+
current_node = current_node->right;
|
150
|
+
continue;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
do
|
156
|
+
{
|
157
|
+
key_index++;
|
158
|
+
|
159
|
+
if(tst->free_list == NULL)
|
160
|
+
{
|
161
|
+
if(tst_grow_node_free_list(tst) != 1)
|
162
|
+
{
|
163
|
+
current_node = new_node_tree_begin->middle;
|
164
|
+
|
165
|
+
while (current_node->middle != NULL)
|
166
|
+
current_node = current_node->middle;
|
167
|
+
|
168
|
+
current_node->middle = tst->free_list;
|
169
|
+
tst->free_list = new_node_tree_begin->middle;
|
170
|
+
new_node_tree_begin->middle = NULL;
|
171
|
+
|
172
|
+
return TST_ERROR;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
if(tst->free_list == NULL)
|
178
|
+
{
|
179
|
+
if(tst_grow_node_free_list(tst) != 1)
|
180
|
+
return TST_ERROR;
|
181
|
+
}
|
182
|
+
current_node->middle = tst->free_list;
|
183
|
+
|
184
|
+
tst->free_list = tst->free_list->middle;
|
185
|
+
current_node = current_node->middle;
|
186
|
+
current_node->value = key[key_index];
|
187
|
+
} while(key[key_index] !=0);
|
188
|
+
|
189
|
+
current_node->middle = data;
|
190
|
+
return TST_OK;
|
191
|
+
}
|
192
|
+
|