[Osip] It's unbelievable! Is it a bug ?
=?GB2312?B?us7N8s/p?=
hewanxiang at gmail.com
Tue Nov 6 15:10:20 CET 2007
Please see my code below.
###########################################
ev = eXosip_event_wait(0, 50);
if (ev == NULL) {
ped->et=REPORT_NO_EVENT;
return 0;
}
switch (ev->type) {
case EXOSIP_MESSAGE_NEW:
{
if((ev->request) != NULL && MSG_IS_REGISTER(ev->request)){
char *uri_str;
osip_uri_to_str(ev->request->from->url, &uri_str);
string uri = uri_str;
osip_free(uri_str);
osip_uri_param_t *param;
osip_contact_t *contact;
osip_message_get_contact(ev->request, 0, &contact);
osip_contact_param_get_byname(contact, "expires", ¶m);
Mark ! Look here ----------> int whatever = 0;
if(param && !strcmp(param->gvalue, "0")){
osip_message_t *ok200;
eXosip_message_build_answer(ev->tid, 200, &ok200);
eXosip_message_send_answer(ev->tid, 200, ok200);
}
if(param == NULL){
osip_authorization_t *h_auth;
osip_message_get_authorization(ev->request, 0, &h_auth);
if(!h_auth){
osip_message_t *answer401;
eXosip_message_build_answer(ev->tid, 401, &answer401);
char rand_str[64];
eXosip_generate_random(rand_str, 64);
rand_str[64] = '\0';
char www_auth_body[256];
snprintf(www_auth_body, sizeof(www_auth_body),"Digest
realm=\"%s\",algorithm=md5,nonce=\"%s\",stale=false", "bupt506.com",
rand_str);
osip_message_set_header(answer401, "WWW-Authenticate", www_auth_body);
eXosip_message_send_answer(ev->tid, 401, answer401);
}else{
if(-1 == auth_check(h_auth)){
osip_message_t *answer401;
eXosip_message_build_answer(ev->tid, 401, &answer401);
char rand_str[64];
eXosip_generate_random(rand_str, 64);
rand_str[64] = '\0';
char www_auth_body[1024];
snprintf(www_auth_body, sizeof(www_auth_body),"Digest
realm=\"%s\",algorithm=MD5,nonce=\"%s\",stale=false", "bupt506.com",
rand_str);
osip_message_set_header(answer401, "WWW-Authenticate", www_auth_body);
eXosip_message_send_answer(ev->tid, 401, answer401);
}else if(0 == auth_check(h_auth)){
osip_message_t *ok200;
eXosip_message_build_answer(ev->tid, 200, &ok200);
eXosip_message_send_answer(ev->tid, 200, ok200);
}
}
}
}
if ((ev->request) != NULL && MSG_IS_MESSAGE(ev->request))
{
}
}
default: {
}
}
If I quote the mark line, a crash happened. If not ,it will be ok.And
I'm sure the variable "whatever" will never be used, that is mean it
is useless, but it should be there. If I replace that line with
whatever, such as " char a = 'a' ; " it is also OK.
I'm totally confused, is it a bug ???
--
Best Regards.
More information about the Osip
mailing list