Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00036 #include "../comp_defs.h"
00037 #include "parse_cseq.h"
00038 #include "parser_f.h"
00039 #include "../dprint.h"
00040 #include "parse_def.h"
00041 #include "parse_methods.h"
00042 #include "../mem/mem.h"
00043
00044
00045 char* parse_cseq(char *buf, char* end, struct cseq_body* cb)
00046 {
00047 char *t, *m, *m_end;
00048
00049 cb->error=PARSE_ERROR;
00050 t=buf;
00051
00052 cb->number.s=t;
00053 t=eat_token_end(t, end);
00054 if (t>=end) goto error;
00055 cb->number.len=t-cb->number.s;
00056
00057 m=eat_space_end(t, end);
00058 m_end=eat_token_end(m, end);
00059
00060 if (m_end>=end) {
00061 LOG(L_ERR, "ERROR: parse_cseq: "
00062 "method terminated unexpectedly\n");
00063 goto error;
00064 }
00065 if (m_end==m){
00066
00067 LOG(L_ERR, "ERROR:parse_cseq: no method found\n");
00068 goto error;
00069 }
00070 cb->method.s=m;
00071 t=m_end;
00072 cb->method.len=t-cb->method.s;
00073
00074
00075 if (parse_method_name(&cb->method, &cb->method_id)!=0){
00076 LOG(L_ERR, "Cannot parse method string\n");
00077 goto error;
00078 }
00079
00080
00081
00082
00083 t=eat_lws_end(t, end);
00084
00085 if (t>=end) {
00086 LOG(L_ERR, "ERROR: parse_cseq: strange EoHF\n");
00087 goto error;
00088 }
00089 if (*t=='\r' && t+1<end && *(t+1)=='\n') {
00090 cb->error=PARSE_OK;
00091 return t+2;
00092 }
00093 if (*t=='\n') {
00094 cb->error=PARSE_OK;
00095 return t+1;
00096 }
00097 LOG(L_ERR, "ERROR: CSeq EoL expected\n");
00098
00099 error:
00100 LOG(L_ERR, "ERROR: parse_cseq: bad cseq\n");
00101 return t;
00102 }
00103
00104
00105 void free_cseq(struct cseq_body* cb)
00106 {
00107 pkg_free(cb);
00108 }