⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abnf.c

📁 mgcp协议源代码和测试程序,还有一个编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
  /* AUEP */  if (ParseString(ctx, 1, 1, "AUEP") == OK)  {    MGCPVerb->iType = MGCPVerb_AUEP;    return OK;  }  CtxRestore(ctx, MGCPVerb);  /* AUCX */  if (ParseString(ctx, 1, 1, "AUCX") == OK)  {    MGCPVerb->iType = MGCPVerb_AUCX;    return OK;  }  CtxRestore(ctx, MGCPVerb);  /* RSIP */  if (ParseString(ctx, 1, 1, "RSIP") == OK)  {    MGCPVerb->iType = MGCPVerb_RSIP;    return OK;  }  CtxRestore(ctx, MGCPVerb);  /* ExtensionVerb */  if (ParseStrRule(ctx, &MGCPVerb->u.ExtensionVerb, 1, 1, DE_ExtensionVerb) == OK)  {    MGCPVerb->iType = MGCPVerb_ExtensionVerb;    return OK;  }  return FAIL;}int EN_MGCPVerb(TCtx *ctx, TMGCPVerb *MGCPVerb){  switch (MGCPVerb->iType)  {    /* EPCF */    case MGCPVerb_EPCF:      return EncodeString(ctx, 1, "EPCF");    /* CRCX */    case MGCPVerb_CRCX:      return EncodeString(ctx, 1, "CRCX");    /* MDCX */    case MGCPVerb_MDCX:      return EncodeString(ctx, 1, "MDCX");    /* DLCX */    case MGCPVerb_DLCX:      return EncodeString(ctx, 1, "DLCX");    /* RQNT */    case MGCPVerb_RQNT:      return EncodeString(ctx, 1, "RQNT");    /* NTFY */    case MGCPVerb_NTFY:      return EncodeString(ctx, 1, "NTFY");    /* AUEP */    case MGCPVerb_AUEP:      return EncodeString(ctx, 1, "AUEP");    /* AUCX */    case MGCPVerb_AUCX:      return EncodeString(ctx, 1, "AUCX");    /* RSIP */    case MGCPVerb_RSIP:      return EncodeString(ctx, 1, "RSIP");    /* ExtensionVerb */    case MGCPVerb_ExtensionVerb:      return EncodeString(ctx, 1, MGCPVerb->u.ExtensionVerb);  }  return FAIL;}void Free_MGCPVerb(TMGCPVerb *MGCPVerb){  switch (MGCPVerb->iType)  {    /* String Concat: "EPCF", Nothing need free */    case MGCPVerb_EPCF:    break;    /* String Concat: "CRCX", Nothing need free */    case MGCPVerb_CRCX:    break;    /* String Concat: "MDCX", Nothing need free */    case MGCPVerb_MDCX:    break;    /* String Concat: "DLCX", Nothing need free */    case MGCPVerb_DLCX:    break;    /* String Concat: "RQNT", Nothing need free */    case MGCPVerb_RQNT:    break;    /* String Concat: "NTFY", Nothing need free */    case MGCPVerb_NTFY:    break;    /* String Concat: "AUEP", Nothing need free */    case MGCPVerb_AUEP:    break;    /* String Concat: "AUCX", Nothing need free */    case MGCPVerb_AUCX:    break;    /* String Concat: "RSIP", Nothing need free */    case MGCPVerb_RSIP:    break;    /* Free ExtensionVerb */    case MGCPVerb_ExtensionVerb:      free(MGCPVerb->u.ExtensionVerb);    break;    default:      Assert(0);  }}int DE_ExtensionVerb(TCtx *ctx){  /* Token Element: ALPHA */  if (ParseToken(ctx, 1, 1, DE_ALPHA) != OK)    return FAIL;  /* Token Element: ALPHA_DIGIT */  if (ParseToken(ctx, 3, 3, DE_ALPHA_DIGIT) != OK)    return FAIL;  return OK;}int DE_ALPHA_DIGIT(TCtx *ctx){  CtxSave(ALPHA_DIGIT,ctx);  /* Token Element: ALPHA */  if (ParseToken(ctx, 1, 1, DE_ALPHA) == OK)    return OK;  CtxRestore(ctx, ALPHA_DIGIT);  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 1, DE_DIGIT) == OK)    return OK;  return FAIL;}int EN_ALPHA_DIGIT(TCtx *ctx){  /* Token Element: ALPHA */  if (EncodeToken(ctx, 1, EN_ALPHA) != OK)    return FAIL;  return OK;}int DE_Transaction_id(TCtx *ctx){  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 9, DE_DIGIT) != OK)    return FAIL;  return OK;}int DE_EndpointName(TCtx *ctx, TEndpointName *EndpointName){  /* Rule Element: LocalEndpointName */  if (ParseStrRule(ctx, &EndpointName->LocalEndpointName, 1, 1, DE_LocalEndpointName) != OK)    return FAIL;  /* String Element: @ */  if (ParseString(ctx, 1, 1, "@") != OK)    return FAIL;  /* Rule Element: DomainName */  if (ParseStrRule(ctx, &EndpointName->DomainName, 1, 1, DE_DomainName) != OK)    return FAIL;  return OK;}int EN_EndpointName(TCtx *ctx, TEndpointName *EndpointName){  /* Rule Element: LocalEndpointName */  if (EncodeString(ctx, 1, EndpointName->LocalEndpointName) != OK)    return FAIL;  /* String Element: @ */  if (EncodeString(ctx, 1, "@") != OK)    return FAIL;  /* Rule Element: DomainName */  if (EncodeString(ctx, 1, EndpointName->DomainName) != OK)    return FAIL;  return OK;}void Free_EndpointName(TEndpointName *EndpointName){  /* Free String: LocalEndpointName */  free(EndpointName->LocalEndpointName);  /* Free String: DomainName */  free(EndpointName->DomainName);}int DE_LocalEndpointName(TCtx *ctx){  /* Token Element: LOCALNAMEPART */  if (ParseToken(ctx, 1, 1, DE_LocalNamePart) != OK)    return FAIL;  /* Token Element: LOCALNAMEPARTS */  if (ParseToken(ctx, 0, 655, DE_LocalNameparts) != OK)    return FAIL;  return OK;}int DE_LocalNameparts(TCtx *ctx){  /* String Element: / */  if (ParseString(ctx, 1, 1, "/") != OK)    return FAIL;  /* Token Element: LOCALNAMEPART */  if (ParseToken(ctx, 1, 1, DE_LocalNamePart) != OK)    return FAIL;  return OK;}int DE_LocalNamePart(TCtx *ctx){  CtxSave(LocalNamePart,ctx);  /* Token Element: ANYNAME */  if (ParseToken(ctx, 1, 1, DE_AnyName) == OK)    return OK;  CtxRestore(ctx, LocalNamePart);  /* Token Element: ALLNAME */  if (ParseToken(ctx, 1, 1, DE_AllName) == OK)    return OK;  CtxRestore(ctx, LocalNamePart);  /* Token Element: NAMESTRING */  if (ParseToken(ctx, 1, 1, DE_NameString) == OK)    return OK;  return FAIL;}int DE_AnyName(TCtx *ctx){  /* String Element: $ */  if (ParseString(ctx, 1, 1, "$") != OK)    return FAIL;  return OK;}int DE_AllName(TCtx *ctx){  /* String Element: * */  if (ParseString(ctx, 1, 1, "*") != OK)    return FAIL;  return OK;}int DE_NameString(TCtx *ctx){  /* Token Element: RANGE_OF_ALLOWED_CHARACTERS */  if (ParseToken(ctx, 1, 655, DE_range_of_allowed_characters) != OK)    return FAIL;  return OK;}int DE_range_of_allowed_characters(TCtx *ctx){  CtxSave(range_of_allowed_characters,ctx);  /* Value Element */  if (ParseChar(ctx, 1, 1, 33, 35) == OK)    return OK;  CtxRestore(ctx, range_of_allowed_characters);  /* Value Element */  if (ParseChar(ctx, 1, 1, 37, 41) == OK)    return OK;  CtxRestore(ctx, range_of_allowed_characters);  /* Value Element */  if (ParseChar(ctx, 1, 1, 43, 46) == OK)    return OK;  CtxRestore(ctx, range_of_allowed_characters);  /* Value Element */  if (ParseChar(ctx, 1, 1, 48, 63) == OK)    return OK;  CtxRestore(ctx, range_of_allowed_characters);  /* Value Element */  if (ParseChar(ctx, 1, 1, 65, 126) == OK)    return OK;  return FAIL;}int DE_DomainName(TCtx *ctx){  CtxSave(DomainName,ctx);  /* Token Element: RFC821NAME */  if (ParseToken(ctx, 1, 1, DE_RFC821Name) == OK)    return OK;  CtxRestore(ctx, DomainName);  /* Token Element: DOMAINNUMNAME */  if (ParseToken(ctx, 1, 1, DE_DomainNumName) == OK)    return OK;  CtxRestore(ctx, DomainName);  /* Token Element: DOMAINIPADDRESS */  if (ParseToken(ctx, 1, 1, DE_DomainIPAddress) == OK)    return OK;  return FAIL;}int DE_RFC821Name(TCtx *ctx){  /* Token Element: ALPHA_DIGIT_DOT_DASH */  if (ParseToken(ctx, 1, 255, DE_ALPHA_DIGIT_DOT_DASH) != OK)    return FAIL;  return OK;}int DE_ALPHA_DIGIT_DOT_DASH(TCtx *ctx){  CtxSave(ALPHA_DIGIT_DOT_DASH,ctx);  /* Token Element: ALPHA */  if (ParseToken(ctx, 1, 1, DE_ALPHA) == OK)    return OK;  CtxRestore(ctx, ALPHA_DIGIT_DOT_DASH);  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 1, DE_DIGIT) == OK)    return OK;  CtxRestore(ctx, ALPHA_DIGIT_DOT_DASH);  /* String Element: . */  if (ParseString(ctx, 1, 1, ".") == OK)    return OK;  CtxRestore(ctx, ALPHA_DIGIT_DOT_DASH);  /* String Element: - */  if (ParseString(ctx, 1, 1, "-") == OK)    return OK;  return FAIL;}int EN_ALPHA_DIGIT_DOT_DASH(TCtx *ctx){  /* Token Element: ALPHA */  if (EncodeToken(ctx, 1, EN_ALPHA) != OK)    return FAIL;  return OK;}int DE_DomainNumName(TCtx *ctx){  /* String Element: # */  if (ParseString(ctx, 1, 1, "#") != OK)    return FAIL;  /* Token Element: NUMBER */  if (ParseToken(ctx, 1, 1, DE_number) != OK)    return FAIL;  return OK;}int DE_DomainIPAddress(TCtx *ctx){  /* String Element: [ */  if (ParseString(ctx, 1, 1, "[") != OK)    return FAIL;  /* Token Element: IPADDRESS */  if (ParseToken(ctx, 1, 1, DE_IPAddress) != OK)    return FAIL;  /* String Element: ] */  if (ParseString(ctx, 1, 1, "]") != OK)    return FAIL;  return OK;}int DE_IPAddress(TCtx *ctx){  CtxSave(IPAddress,ctx);  /* Token Element: IPV4ADDRESS */  if (ParseToken(ctx, 1, 1, DE_IPv4address) == OK)    return OK;  CtxRestore(ctx, IPAddress);  /* Token Element: IPV6ADDRESS */  if (ParseToken(ctx, 1, 1, DE_IPv6address) == OK)    return OK;  return FAIL;}int DE_IPv4address(TCtx *ctx){  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 3, DE_DIGIT) != OK)    return FAIL;  /* String Element: . */  if (ParseString(ctx, 1, 1, ".") != OK)    return FAIL;  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 3, DE_DIGIT) != OK)    return FAIL;  /* String Element: . */  if (ParseString(ctx, 1, 1, ".") != OK)    return FAIL;  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 3, DE_DIGIT) != OK)    return FAIL;  /* String Element: . */  if (ParseString(ctx, 1, 1, ".") != OK)    return FAIL;  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 3, DE_DIGIT) != OK)    return FAIL;  return OK;}int DE_number(TCtx *ctx){  /* Token Element: DIGIT */  if (ParseToken(ctx, 1, 655, DE_DIGIT) != OK)    return FAIL;  return OK;}int DE_IPv6address(TCtx *ctx){  /* Token Element: HEXPART */  if (ParseToken(ctx, 1, 1, DE_hexpart) != OK)    return FAIL;  /* Token Element: IPV4ADDRESS_PART */  if (ParseToken(ctx, 0, 1, DE_Ipv4Address_Part) != OK)    return FAIL;  return OK;}int DE_Ipv4Address_Part(TCtx *ctx){  /* String Element: : */  if (ParseString(ctx, 1, 1, ":") != OK)    return FAIL;  /* Token Element: IPV4ADDRESS */  if (ParseToken(ctx, 1, 1, DE_IPv4address) != OK)    return FAIL;  return OK;}int DE_hexpart(TCtx *ctx){  CtxSave(hexpart,ctx);  /* Token Element: HEXSEQ */  if (ParseToken(ctx, 1, 1, DE_Hexseq) == OK)    return OK;  CtxRestore(ctx, hexpart);  /* Token Element: HEXSEQ_HEXSEQ */  if (ParseToken(ctx, 1, 1, DE_Hexseq_Hexseq) == OK)    return OK;  CtxRestore(ctx, hexpart);  /* Token Element: COLON_HEXSEQ */  if (ParseToken(ctx, 1, 1, DE_Colon_Hexseq) == OK)    return OK;  return FAIL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -