MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / xode_stream_eat

Function xode_stream_eat

modules/xmpp/xstream.c:147–188  ·  view source on GitHub ↗

attempts to parse the buff onto this stream firing events to the handler, returns the last known status */

Source from the content-addressed store, hash-verified

145
146/* attempts to parse the buff onto this stream firing events to the handler, returns the last known status */
147int xode_stream_eat(xode_stream xs, char *buff, int len)
148{
149 char *err;
150 xode xerr;
151 static char maxerr[] = "maximum node size reached";
152 static char deeperr[] = "maximum node depth reached";
153
154 if(xs == NULL)
155 {
156 fprintf(stderr,"Fatal Programming Error: xode_streameat() was improperly called with NULL.\n");
157 return XODE_STREAM_ERROR;
158 }
159
160 if(len == 0 || buff == NULL)
161 return xs->status;
162
163 if(len == -1) /* easy for hand-fed eat calls */
164 len = strlen(buff);
165
166 if(!XML_Parse(xs->parser, buff, len, 0))
167 {
168 err = (char *)XML_ErrorString(XML_GetErrorCode(xs->parser));
169 xs->status = XODE_STREAM_ERROR;
170 }else if(xode_pool_size(xode_get_pool(xs->node)) > XODE_STREAM_MAXNODE || xs->cdata_len > XODE_STREAM_MAXNODE){
171 err = maxerr;
172 xs->status = XODE_STREAM_ERROR;
173 }else if(xs->status == XODE_STREAM_ERROR){ /* set within expat handlers */
174 err = deeperr;
175 }else{
176 err = deeperr;
177 }
178
179 /* fire parsing error event, make a node containing the error string */
180 if(xs->status == XODE_STREAM_ERROR)
181 {
182 xerr = xode_new("error");
183 xode_insert_cdata(xerr,err,-1);
184 (xs->f)(XODE_STREAM_ERROR, xerr, xs->arg);
185 }
186
187 return xs->status;
188}

Callers 2

Calls 4

xode_pool_sizeFunction · 0.70
xode_get_poolFunction · 0.70
xode_newFunction · 0.70
xode_insert_cdataFunction · 0.70

Tested by

no test coverage detected