|
Lines 22-27
$Id: jcr_elements.c,v 1.19 2004/07/21 15
Link Here
|
| 22 |
|
22 |
|
| 23 |
#include "jcomp.h" |
23 |
#include "jcomp.h" |
| 24 |
|
24 |
|
|
|
25 |
static int check_tag_name(char *name, char* needle, int size) |
| 26 |
{ |
| 27 |
if(strlen(name) != strlen(needle)) |
| 28 |
return strlen(name) - strlen(needle); |
| 29 |
|
| 30 |
return strncasecmp(name, needle, strlen(needle)); |
| 31 |
} |
| 32 |
|
| 25 |
void jcr_start_element(void *m, const char *name, const char **attrib) { |
33 |
void jcr_start_element(void *m, const char *name, const char **attrib) { |
| 26 |
extern jcr_instance jcr; |
34 |
extern jcr_instance jcr; |
| 27 |
pool p; |
35 |
pool p; |
|
Lines 31-42
void jcr_start_element(void *m, const ch
Link Here
|
| 31 |
switch (jcr->stream_state) { |
39 |
switch (jcr->stream_state) { |
| 32 |
|
40 |
|
| 33 |
case _STREAM_INIT_STATE: |
41 |
case _STREAM_INIT_STATE: |
| 34 |
if (strncasecmp(name, "stream:stream", 13) == 0) { |
42 |
if (check_tag_name(name, "stream:stream", 13) == 0) { |
| 35 |
char *pass = xmlnode_get_data(xmlnode_get_tag(jcr->config,"secret")); |
43 |
char *pass = xmlnode_get_data(xmlnode_get_tag(jcr->config,"secret")); |
| 36 |
int i = 0; |
44 |
int i = 0; |
| 37 |
if (attrib == NULL) return; |
45 |
if (attrib == NULL) return; |
| 38 |
while (attrib[i] != '\0') { |
46 |
while (attrib[i] != '\0') { |
| 39 |
if (strncasecmp(attrib[i], "id", 2) == 0) |
47 |
if (check_tag_name(attrib[i], "id", 2) == 0) |
| 40 |
break; |
48 |
break; |
| 41 |
i += 2; |
49 |
i += 2; |
| 42 |
} |
50 |
} |
|
Lines 89-95
void jcr_end_element(void *m, const char
Link Here
|
| 89 |
|
97 |
|
| 90 |
case _STREAM_INIT_STATE: |
98 |
case _STREAM_INIT_STATE: |
| 91 |
case _STREAM_AUTH_SENT: |
99 |
case _STREAM_AUTH_SENT: |
| 92 |
if (strncasecmp(name, "handshake", 9) == 0) { |
100 |
if (check_tag_name(name, "handshake", 9) == 0) { |
| 93 |
jcr->stream_state = _STREAM_CONNECTED; |
101 |
jcr->stream_state = _STREAM_CONNECTED; |
| 94 |
log_debug(JDBG, "<handshake> received"); |
102 |
log_debug(JDBG, "<handshake> received"); |
| 95 |
} |
103 |
} |
|
Lines 99-117
void jcr_end_element(void *m, const char
Link Here
|
| 99 |
log_warn(JDBG, "jcr->current == NULL, closing stream"); |
107 |
log_warn(JDBG, "jcr->current == NULL, closing stream"); |
| 100 |
jcr_main_close_stream(); |
108 |
jcr_main_close_stream(); |
| 101 |
} else { |
109 |
} else { |
| 102 |
if (strncasecmp(name, "stream:error", 12) == 0) { |
110 |
if (check_tag_name(name, "stream:error", 12) == 0) { |
| 103 |
log_warn(JDBG, "'stream:error' on server stream: '%s'", xmlnode2str(jcr->current)); |
111 |
log_warn(JDBG, "'stream:error' on server stream: '%s'", xmlnode2str(jcr->current)); |
| 104 |
// jcr_main_close_stream(); |
112 |
// jcr_main_close_stream(); |
| 105 |
return; |
113 |
return; |
| 106 |
} |
114 |
} |
| 107 |
|
115 |
|
| 108 |
if (strncasecmp(name, "stream", 6) == 0) { |
116 |
if (check_tag_name(name, "stream", 6) == 0) { |
| 109 |
log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); |
117 |
log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); |
| 110 |
jcr_main_close_stream(); |
118 |
jcr_main_close_stream(); |
| 111 |
return; |
119 |
return; |
| 112 |
} |
120 |
} |
| 113 |
|
121 |
|
| 114 |
if (strncasecmp(name, "stream:stream", 13) == 0) { |
122 |
if (check_tag_name(name, "stream:stream", 13) == 0) { |
| 115 |
log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); |
123 |
log_warn(JDBG, "End of Stream from server: '%s'", xmlnode2str(jcr->current)); |
| 116 |
jcr_main_close_stream(); |
124 |
jcr_main_close_stream(); |
| 117 |
return; |
125 |
return; |