📄 rvsdpprs.syn
字号:
{
/************************************************************************
Filename : rvsdpprs.syn/rvsdpprs.c
Description : Sdp syntax and parser. C file is generated by AnaGram tool
************************************************************************
Copyright (c) 1999 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever
without written prior approval by RADVision LTD..
RADVision LTD. reserves the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
************************************************************************
************************************************************************
$Revision: 1.0$
$Date:5/3/00$
$Author:Dan E.$
************************************************************************/
#include "rvsdpmsg.h"
#include "rvsdpsymb.h"
#include "rvsdpprsaux.h"
#define PRS_STATE (&(PCB.sdp_prs_state))
#define SDP_MSG (PCB.sdp_msg)
#define BEGIN_TOKEN() (PRS_STATE->cur_token=(char *)PCB.pointer)
#define TOKEN_START PRS_STATE->cur_token
#define TOKEN_LENGTH ((char *)PCB.pointer-TOKEN_START)
#define PRS_ALLOC PCB.sdp_msg->alloc
#define CUR_STRING() CurString_(TOKEN_START,TOKEN_LENGTH)
#define CUR_INT() AsciiToInt(&(PCB),TOKEN_START,TOKEN_LENGTH)
#define CUR_INT16() AsciiToInt16(&(PCB),TOKEN_START,TOKEN_LENGTH)
#define SYNTAX_ERROR rvSdpParseSetSyntaxErr(&(PCB))
#define VALIDATE_LENGTH(l) rvSdpParserAuxValidateFieldLength(&(PCB),TOKEN_LENGTH,l)
static char empty_str[] = {""};
static RvpStrPtrN CurString_(char * s,int len) {
RvpStrPtrN x;
x.buf = s;
x.len = len;
return x;
}
static unsigned int AsciiToInt(void * pcb_,char * s,int len) {
unsigned int acc= *(s+len-1)-'0';
unsigned int digit10,digit,old_acc = acc;
unsigned int power=1;
int i;
for(i=len-2;i>=0;i--) {
digit10 = (*(s+i)-'0')*power;
digit = digit10*10;
if(digit/10 != digit10)/* Check for int rollover - field too big */
rvSdpParseSetSemErr(pcb_,"Field too long");
acc+=digit;
power*=10;
if(old_acc>acc) /* Check for int rollover - field too big */
rvSdpParseSetSemErr(pcb_,"Field too long");
old_acc = acc;
}
return acc;
}
static unsigned int AsciiToInt16(void * pcb_,char * s,int len) {
unsigned int max = 0xFFFF;
unsigned int value = AsciiToInt(pcb_,s,len);
if(value>max)
rvSdpParseSetSemErr(pcb_,"Field larger than 0xFFFF");
return value;
}
}
// -- CONFIGURATION SECTION ----------------------------
[
grammar token = announcement
default token type = void
pointer input // Take input from array in memory
parser name = rvSdpParser // Name parser function
parser file name = "#.c" // Name parser file
line numbers = off // Generate #line directives - on for debug
reentrant parser // Make parser reentrant
parser stack size = 8
allow macros = on // off for debug
case sensitive = off
extend pcb {
RvSdpMsg * sdp_msg;
RvSdpParserState_ sdp_prs_state;
}
]
// -- LEXICAL UNITS ------------------------------------
ALPHA_NUMERIC = ALPHA + DIGIT
DIGIT = '0' + POS_DIGIT
POS_DIGIT = '1-9'
ALPHA = 'a-z' + 'A-Z'
EMAIL_SAFE = SAFE + SPACE + TAB
SAFE = ALPHA_NUMERIC +
'\'' + '-' + '.' + '/' + ':' + '?' + '"' +
'#' + '$' + '&' + '*' + ';' + '=' + '@' + '[' +
']' + '^' + '_' + '`' + '{' + '|' + '}' + '+' +
'~'
// Note : What is this ??? : + "
SPACE = ' ' // 32
TAB = 9
ANY_BYTE = 0x01..0x09 + 0x0b + 0x0c + 0x0e..0xff -'\n' // any byte except NUL, CR or LF
// Must be in quoted-string, to use within a word.
EMAIL_SPECIALS = '(' + ')' + '<' + '>' + '@' +
',' + ';' + ':' + '\\' + '"' +
'.' + '[' + ']'
// 1*<any CHAR except specials, SPACE and CTLs>
EMAIL_ATOM = 0x21..0xff - EMAIL_SPECIALS
// Sets used to resolve conflicts between email-safe and email-atom
EMAIL_SPEC_N_SAFE = '@' + ';' + ':' + '"' + '.' + '[' + ']'
EMAIL_ATOM_N_SAFE = EMAIL_SAFE - EMAIL_SPEC_N_SAFE
EMAIL_SAFE_ONLY = '@' + ';' + ':' + '"' + '.' + '[' + ']'
EMAIL_ATOM_ONLY = EMAIL_ATOM - EMAIL_SAFE
CHAR = 0x01..0xff
URI_SAFE = '$' + '-' + '_' + '@' + '.' + '&'
URI_EXTRA = '!'+ '*' + '"' + '\'' + '(' + ')' + ','
HEX = DIGIT + 'a-f' + 'A-F'
CR = 13
LF = 10
LET_DIG_HYP = ALPHA_NUMERIC + '-'
EOF = 0
//--------------- Low level productions ----------------------------------------
// default is to interpret this as IS0-10646 UTF8
// ISO 8859-1 requires a "a=charset:ISO-8859-1"
// session_level attribute to be used
(RvpStrPtrN) text
-> byte_string = CUR_STRING();
// any byte except NUL, CR or LF
byte_string // 1*(0x01..0x09|0x0b|0x0c|0x0e..0xff)
-> ANY_BYTE...
decimal_uchar
-> DIGIT
-> POS_DIGIT,DIGIT
// -> '1',DIGIT?
// -> '2',DIGIT?
-> '1',DIGIT,DIGIT
-> '2', {'0'|'1'|'2'|'3'|'4'}, DIGIT
-> '2', '5', {'0'|'1'|'2'|'3'|'4'|'5'}
integer // POS_DIGIT *(DIGIT)
-> DIGIT
-> POS_DIGIT, DIGIT...
//(int) integer
// -> '0-9':d =d-'0';
// -> integer:n, '0-9':d =10*n+d-'0';
//(int)pos_integer // POS_DIGIT *(DIGIT)
// -> POS_DIGIT:d =d-'0';
// -> number:n,DIGIT:d =10*n+d-'0';
//(int)pos_integer // POS_DIGIT *(DIGIT)
// -> POS_DIGIT
// -> integer,DIGIT
(RvpStrPtrN)email_safe_string
// -> EMAIL_SAFE... = CUR_STRING();
-> EMAIL_SAFE_ONLY,[EMAIL_SAFE_ONLY | EMAIL_ATOM_N_SAFE]... = CUR_STRING();
-> EMAIL_ATOM_N_SAFE...= CUR_STRING();
-> EMAIL_ATOM_N_SAFE...,EMAIL_SAFE_ONLY,[EMAIL_SAFE_ONLY | EMAIL_ATOM_N_SAFE]...= CUR_STRING();
EOL
-> 13,10 | '\n'
eol
// -> CRLF = { BEGIN_TOKEN(); }
-> CR , LF = { PRS_STATE->cur_line = PRS_STATE->cur_token = (char*)PCB.pointer; }
-> LF = { PRS_STATE->cur_line = PRS_STATE->cur_token = (char*)PCB.pointer; }
space
-> SPACE = BEGIN_TOKEN();
//at
// -> '@' = { BEGIN_TOKEN(); }
//or
// -> "|" = { BEGIN_TOKEN(); }
fwdslash
-> '/' = BEGIN_TOKEN();
opar
-> '(' = BEGIN_TOKEN();
clpar
-> ')' = BEGIN_TOKEN();
obrkt
-> '<' = BEGIN_TOKEN();
clbrkt
-> '>' = BEGIN_TOKEN();
colon
-> ':' = BEGIN_TOKEN();
//semicolon
// -> ';' = BEGIN_TOKEN();
equal
-> '=' = BEGIN_TOKEN();
minus
-> "-" = BEGIN_TOKEN();
// End of message
omwsp
-> SPACE?...
// Note: check that the parser returns the rigth pointer (i.e. ,after of before '}')
EOM
-> EOF = PRS_STATE->stat = RV_SDPPARSER_STOP_ZERO;
-> '.',omwsp,EOL = PRS_STATE->stat = RV_SDPPARSER_STOP_DOTLINE;
-> omwsp,EOL = PRS_STATE->stat = RV_SDPPARSER_STOP_BLANKLINE;
-> omwsp,'}' = PRS_STATE->stat = RV_SDPPARSER_STOP_CLOSEBRACE;
//--------------- SDP Productions --------------------------------------------------
// Note: origin_field, session_name_field May be optional in MGCP
// time_fields may be optional in MGCP
announcement
-> proto_version,
[origin_field],
[session_name_field],
[information_field],
[uri_field],
[email_field]...,
[phone_field]...,
[connection_field],
[bandwidth_field],
[time_fields],
[key_field],
[attribute]...,
[media_description]...,
EOM
proto_version // "v=" 1*DIGIT CRLF ;this memo describes version 0
-> "v", equal, sdp_version, eol
sdp_version
-> integer = {
VALIDATE_LENGTH(RV_SDPMAX_VERSION_SIZE);
rvSdpMsgSetVersionN(SDP_MSG,TOKEN_START,TOKEN_LENGTH);
}
origin_field
-> "o",equal, username:u, space,sess_id:i,space,sess_version:v,space,net_type_addr,eol = {
rvSdpParserAuxSetOriginN(PRS_STATE,SDP_MSG,u.buf,u.len,i.buf,i.len,v.buf,v.len);
}
session_name_field
-> "s", equal, text:s, eol = rvSdpMsgSetSessionNameN(SDP_MSG,s.buf,s.len);
information_field // ["i=" text CRLF]
-> "i", equal, text:s, eol = rvSdpCommonFieldsSetInformationN(PRS_STATE->cur_sdp_fields,s.buf,s.len);
uri_field // ["u=" uri CRLF]
-> "u", equal, uri:u, eol = rvSdpMsgSetURIN(SDP_MSG,u.buf,u.len);
email_field // *("e=" email_address eol)
-> "e",equal, email_address, eol
phone_field // *("p=" phone-number eol)
-> "p",equal, phone_number, eol
connection_field
// -> "c", equal, nettype:n, space, addrtype:a, space, connection_address:ca, eol = {
// rvSdpParserAuxSaveAddr(PRS_STATE,n.buf,n.len,a.buf,a.len,ca.buf,ca.len);
// }
-> "c", equal, net_type_addr, eol = {
rvSdpParserAuxSetConnectionN(PRS_STATE);
}
net_type_addr
// other type
-> "-", space, other_addr_type:a, space, other_addr_all:ca ={
rvSdpParserAuxSaveAddr(PRS_STATE, "-", 1, a.buf, a.len, ca.buf, ca.len);
}
-> "$", space, other_addr_type:a, space, other_addr_all:ca ={
rvSdpParserAuxSaveAddr(PRS_STATE, "$", 1, a.buf, a.len, ca.buf, ca.len);
}
-> "IN", space, other_addr_type:a, space, other_addr_all:ca ={
rvSdpParserAuxSaveAddr(PRS_STATE, "IN", 2, a.buf, a.len, ca.buf, ca.len);
}
-> "TN", space, other_addr_type:a, space, other_addr_all:ca ={
rvSdpParserAuxSaveAddr(PRS_STATE, "TN", 2, a.buf, a.len, ca.buf, ca.len);
}
-> "ATM", space, other_addr_type:a, space, other_addr_all:ca ={
rvSdpParserAuxSaveAddr(PRS_STATE, "ATM", 3, a.buf, a.len, ca.buf, ca.len);
}
// atm type
-> "ATM", space, "NSAP", space, nsap_addr_all:ca = {
rvSdpParserAuxSaveAddr(PRS_STATE, "ATM", 3, "NSAP", 4, ca.buf, ca.len);
}
-> "ATM", space, "E164", space, e164_addr_all:ca = {
rvSdpParserAuxSaveAddr(PRS_STATE, "ATM", 3, "E164", 4, ca.buf, ca.len);
}
-> "ATM", space, "GWID", space, alias_addr_all:ca = {
rvSdpParserAuxSaveAddr(PRS_STATE, "ATM", 3, "GWID", 4, ca.buf, ca.len);
}
-> "ATM", space, "ALIAS", space, alias_addr_all:ca = {
rvSdpParserAuxSaveAddr(PRS_STATE, "ATM", 3, "ALIAS", 5, ca.buf, ca.len);
}
// in type
-> "IN", space, "IP4", space, ip4_addr_all:a = {
rvSdpParserAuxSaveAddr(PRS_STATE, "IN", 2, "IP4", 3, a.buf, a.len);
}
-> "IN", space, "IP6", space, ip6_addr_all:a = {
rvSdpParserAuxSaveAddr(PRS_STATE, "IN", 2, "IP6", 3, a.buf, a.len);
}
// tn type
-> "TN",space, "RFC2543", space, tn_addr_all:a ={
rvSdpParserAuxSaveAddr(PRS_STATE, "TN", 2, "RFC2543", 7, a.buf, a.len);
}
-> "TN",space, tn_other_type:tn, space, tn_other_all:a ={
rvSdpParserAuxSaveAddr(PRS_STATE, "TN", 2, tn.buf, tn.len, a.buf, a.len);
}
(RvpStrPtrN)nsap_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> nsap_str =CUR_STRING();
(RvpStrPtrN)e164_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> e164_str=CUR_STRING();
(RvpStrPtrN)alias_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> alias_str=CUR_STRING();
(RvpStrPtrN)other_addr_type
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
(RvpStrPtrN)other_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> other_str = CUR_STRING();
(RvpStrPtrN)ip4_addr_all
-> "-" = CUR_STRING();
// -> "$" = CUR_STRING(); // define "$" at connection_address for megaco
-> ip4_str
(RvpStrPtrN)ip6_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> ip6_str = CUR_STRING();
(RvpStrPtrN)tn_addr_all
-> "-" = CUR_STRING();
-> "$" = CUR_STRING();
-> tn_str = CUR_STRING();
(RvpStrPtrN)tn_other_type
-> tnothertype = CUR_STRING();
(RvpStrPtrN)tn_other_all
-> xalpha... = CUR_STRING();
bandwidth_field // *("b=" bwtype ":" bandwidth CRLF)
-> 'b',equal, bwtype:t, colon,bandwidth:b, eol = rvSdpCommonFieldsSetBandwidthN(PRS_STATE->cur_sdp_fields,t.buf,t.len,b,PRS_ALLOC);
time_fields // 1*( "t=" start_time SPACE stop_time *(CRLF repeat_fields) CRLF) [zone_adjustments CRLF]
-> {'t',equal,time_description}...,[zone_adjustments,eol]
time_description
-> session_time,eol,repeat_lines
-> session_time,eol
repeat_lines
-> {repeat_fields,eol}...
session_time
-> start_time:start,space,stop_time:stop = rvSdpParseAuxAddSessionTime(PRS_STATE,start,stop);
repeat_fields // "r=" repeat_interval SPACE typed_time 1*(SPACE typed_time)
// r=<repeat interval> <active duration> <list of offsets from start-time>
-> 'r',equal, repeat_interval, space, active_duration, {space, time_offset}...
repeat_interval // typed_time
-> typed_time : t = rvSdpParseAuxAddSessionRepeatField(PRS_STATE,t);
active_duration
-> typed_time:t = rvSdpParseAuxSetRepeatActiveDuration(PRS_STATE,t);
time_offset
-> typed_time:t = rvSdpParseAuxAddRepeatOffset(PRS_STATE,t);
zone_adjustments // time SPACE ["-"] typed_time *(SPACE time SPACE ["-"] typed_time)
-> 'z',equal,zone_adjustment,[space,zone_adjustment]...
zone_adjustment
-> time:t, space, typed_time:tt = rvSdpParseAuxAddZoneAdjustment(PRS_STATE,t,tt.time,tt.type);
-> time:t, space, minus, typed_time:tt = rvSdpParseAuxAddZoneAdjustment(PRS_STATE,t,tt.time*(-1),tt.type);
key_field // ["k=" key-type eol]
-> 'k',equal,sdp_key,eol
//(RvSdpKey_) sdp_key
// -> key_type: t = {
// RvSdpKey_ key;
// key.type = t;
// key.key_data = (t==RV_SDPENCRMTHD_PROMPT)? empty_str :TOKEN_START;
// key.key_len = (t==RV_SDPENCRMTHD_PROMPT)? 0 :TOKEN_LENGTH;
// return key;
// }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -