aaf285a6 |
/* $Id$
*
* Copyright (C) 2006-2007 VozTelecom Sistemas S.L
*
* This file is part of openser, a free SIP server.
*
* openser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* openser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
|
d38650d3 |
return -1;
}else{
i+=j;
}
}
where[0]=flags;
where[1]=(unsigned char)j;
i+=encode_parameters(&where[i],(void *)body->param_lst,hdrstart,body,'t');
return i;
}
int print_encoded_to_body(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
{
int i=2;/* flags + urilength */
unsigned char flags=0;
flags=payload[0];
dprintf(fd,"%s",prefix);
for(i=0;i<paylen;i++)
dprintf(fd,"%s%d%s",i==0?"BODY CODE=[":":",payload[i],i==paylen-1?"]\n":"");
i=2;
if(flags & HAS_DISPLAY_F){
dprintf(fd,"%sDISPLAY NAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
i+=2;
}
if(flags & HAS_TAG_F){
dprintf(fd,"%sTAG=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
i+=2;
}
if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix," "))<0){
dprintf(fd,"Error parsing URI\n");
prefix[strlen(prefix)-2]=0;
return -1;
}
prefix[strlen(prefix)-2]=0;
print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
return 0;
}
/**
* dumps to FD a NBO int which is the header length, the header,
* an NBO int which is the payload length, and the payload.
*
* hdr is the header,
* hdrlen is the header length,
* payload is the payload,
* paylen is the payload length,
* fd is the file descriptor to which to dump,
* segregationLevel is wether only URIS must be dumped or all the header code.
*
* return 0 on success, <0 on error
*/
int dump_to_body_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int fd,char segregationLevel)
{
int i=2;/* flags + urilength */
unsigned char flags=0;
flags=payload[0];
if(!segregationLevel){
return dump_standard_hdr_test(hdr,hdrlen,payload,paylen,fd);
}
i=2;
if(flags & HAS_DISPLAY_F){
i+=2;
}
if(flags & HAS_TAG_F){
i+=2;
}
if(!(segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
return dump_standard_hdr_test(hdr,hdrlen,&payload[i],payload[1],fd);
}
if((segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,1,"");
}
return 0;
}
|