Re: sscanf question
- From: sieg1974@xxxxxxxxx
- Date: 23 Nov 2006 09:20:26 -0800
Hi,
The following is the piece of code I'm using, and it's output.
Thanks,
Andre
#include <stdio.h>
char buf1[] = "c0a80174.13e1;received=207.81.158.209\r\nVia:
SIP/2.0/UDP\r\n192.168.1.116:5089;branch=z9hG4bK20445d6f-8279-db11-9cdf-00112f2f2fed;rport\r\nFrom:
<sip:102@xxxxxxxxxxxxx>;tag=fa375d6f-8279-db11-9cdf-00112f2f2fed\r\nTo:
<sip:102@xxxxxxxxxxxxx>\r\nCall-ID:
f6ff5c6f-8279-db11-9cdf-00112f2f2fed@dilbert\r\nCSeq: 2363
REGISTER\r\nUser-Agent: Asterisk PBX\r\nAllow: INVITE, ACK, CANCEL,
OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY\r\nContact:
<sip:102@xxxxxxxxxxxxxx\r\nContent-Length: 0\r\n";
char buf2[] = "z9hG4bK3c36655c;rport\r\nFrom: \"asterisk\"
<sip:asterisk@xxxxxxxxxxxxxx>;tag=as41da1dfe\r\nTo:
<sip:102@xxxxxxxxxxxxx:5089;transport=udp>\r\nContact:
<sip:asterisk@xxxxxxxxxxxxxx>\r\nCall-ID:
3d1983143939d5141ccd181f2db26e19@xxxxxxxxxxxxxx\r\nCSeq: 102
OPTIONS\r\nUser-Agent: Asterisk PBX\r\nMax-Forwards: 70\r\nDate: Thu,
23 Nov 2006 17:02:40 GMT\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE,
REFER, SUBSCRIBE, NOTIFY\r\nContent-Length: 0\r\n";
int main()
{
int ip = 0;
int port = 0;
sscanf(buf1, "%x.%x", &ip, &port);
printf("buf1: ip=%d port=%d\n", ip, port);
ip = 0;
port = 0;
sscanf(buf2, "%x.%x", &ip, &port);
printf("buf2: ip=%d port=%d\n", ip, port);
return 0;
}
Output:
buf1: ip=-1062731404 port=5089
buf2: ip=0 port=0
.
- Follow-Ups:
- Re: sscanf question
- From: attn.steven.kuo@xxxxxxxxx
- Re: sscanf question
- References:
- sscanf question
- From: sieg1974
- Re: sscanf question
- From: sieg1974
- sscanf question
- Prev by Date: Re: function overloading
- Next by Date: _Complex constant
- Previous by thread: Re: sscanf question
- Next by thread: Re: sscanf question
- Index(es):
Relevant Pages
|