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

📄 gatepars.c

📁 ipt网关源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      if(strncmp(p,"coder",5) == 0) {
		  stage = 3;
		  return(0);
	  }

	  /* Get Calling DISPLAY 
         only the first 4 letters must match here */
      if(strncmp(p,"display",4) == 0) {
         /* get this call string */
         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.display,lname);
		 }

         return (0);         
      }

      /* Get UUI */
      if(strncmp(p,"ipt_uui",3) == 0) {
         /* get this UUI string */
         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.IPT_UUI,lname);
		 }

         return (0);         
      }


      if(strncmp(p,"nonstdcmd",9) == 0) {
         /* get this call string */
         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.NonStdCmd.CmdVal,lname);
		 }

         return (0);         
      }

      if(strncmp(p,"uii",3) == 0) {
         /* get this call string */
         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.UII.Val,lname);
		 }

         return (0);         
      }

     /* Get outgoing phone number if any */
      if(strncmp(p,"localphonenumber",5) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.localPhoneNumber,lname);
		 }

         return (0);        
      }


      /* Get local phone number if any */
      if(strncmp(p,"remotephonenumber",6) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.phoneList,lname);
		 }

         return (0);        
      }


      /* check if done with this channel return to stage 0 of check */
      if(*p == '}') {
         stage = 0;
         return(0);
      }

   } /* if on-channel==2 */

   if(stage == 4) {

	   /* Get coder Type */
      if(strncmp(p,"type",4) == 0) {
         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);

            return(-1);
         }

         ii=0;
         while(ii<IPT_NUMBER_OF_CODERS) {

            if(strcmp(lname,IPTCoderListing[ii])==0) {

               break;
            }
            ii++;
         }

		 if(strcmp(lname,"don't_care") == 0) {
			 ii = NetTSC_Coder_CoderType_DONT_CARE;
		 }
		 else {

			 /* Check if valid coder */
			 if(ii>=IPT_NUMBER_OF_CODERS) {

				printf("\tUnknown coder in .cfg file\n");
				return(-2);
			 }
		 }


         /* Save coder type */
         for(index = firstSession; index <= lastSession; index++) {
			 maxCoders = (++Session[index].ConfigFileParm.maxTxCoders)-1;
             Session[index].ConfigFileParm.TxCoder[maxCoders].CoderType = ii;
		 }
         return (0);       
      }

      /* Get Coder Frame Per Packet */
      if(strncmp(p,"framesperpkt",11) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);

            return(-1);
         }

		 if(strcmp(lname,"don't_care") == 0) {
			 (USHORT) *ans = NetTSC_Coder_FramesPerPkt_DONT_CARE;
		 }
		 else {
			 (USHORT) *ans = (USHORT)atoi(lname);
		 }

         /* Save frame size */
         for(index = firstSession; index <= lastSession; index++) {
			 Session[index].ConfigFileParm.TxCoder[maxCoders].FramesPerPkt = (USHORT) *ans;
		 }

         return (0);        
      }

      /* Get Coder Frame Size */
      if(strncmp(p,"framesize",5) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);

            return(-1);
         }

		 if(strcmp(lname,"don't_care") == 0) {
			 (USHORT) *ans = NetTSC_Coder_FrameSize_DONT_CARE;
		 }
		 else {
			 (USHORT) *ans = (USHORT)atoi(lname);
		 }

         /* Save frame size */
         for(index = firstSession; index <= lastSession; index++) {
			 Session[index].ConfigFileParm.TxCoder[maxCoders].FrameSize = (USHORT) *ans;
		 }

         return (0);        
      }


      /* Get Coder Rate */
      if(strncmp(p,"rate",4) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);
            return(-1);
         }

         
         /* Save coder rate */
		 if(strcmp(lname,"don't_care") == 0) {
			 for(index = firstSession; index <= lastSession; index++) {
				 Session[index].ConfigFileParm.TxCoder[maxCoders].Rate = NetTSC_Coder_Rate_DONT_CARE;
			 }
		 }
         else {
			 (USHORT) *ans = (USHORT)atoi(lname);
			 if(((USHORT) *ans) == 1) {
                for(index = firstSession; index <= lastSession; index++) {
					Session[index].ConfigFileParm.TxCoder[maxCoders].Rate = NetTSC_Coder_Rate_R5_3;
				}

			 } /* if (USHORT) *ans == 0 */
			 else {

                for(index = firstSession; index <= lastSession; index++) {
					Session[index].ConfigFileParm.TxCoder[maxCoders].Rate = NetTSC_Coder_Rate_R6_3; 
				}
			 }
		 }


         return (0);       

      }


      /* Get VAD enable/disable */
      if(strncmp(p,"vad",3) == 0) {

         if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);
            return(-1);
         }

		 if(strcmp(lname,"don't_care") == 0) {
             for(index = firstSession; index <= lastSession; index++) {
				 Session[index].ConfigFileParm.TxCoder[maxCoders].VadEnable = NetTSC_Coder_VadEnable_DONT_CARE;
			 }
		 }
         else {
			 (USHORT) *ans = (USHORT)atoi(lname);
			 if(((USHORT) *ans) == 0) {

                for(index = firstSession; index <= lastSession; index++) {
					Session[index].ConfigFileParm.TxCoder[maxCoders].VadEnable = NetTSC_Coder_VadEnable_VAD_DISABLE;
				}

			 } 
			 else {

                for(index = firstSession; index <= lastSession; index++) {
					Session[index].ConfigFileParm.TxCoder[maxCoders].VadEnable = NetTSC_Coder_VadEnable_VAD_ENABLE; 
				}
			 }
		 }



         return (0);        
      }

      /* check if done with this coder return to stage 2 */
      if(*p == '}') {
         stage = 2;
         return(0);
      }
} /* if stage == 4 */


   /* Get self id as string */
   if(strncmp(p,"source",3) == 0) {

      if((rc = skip(TRUE,p,(long *)ans,0,(char *)lname)) != 1) {
         return(-1);
      }

      for(index = firstSession; index <= lastSession; index++) {
		  strcpy(Session[index].ConfigFileParm.srcAddr,lname);
	  }

      return(0);
   }


   /* stage 0 checks for channel -- first 4 letters enough */
   if(strncmp(p,"channel",4) == 0) {
      if((rc = skip(TRUE,p,(long *)ans,2,(char *)lname)) == -1) {
         return(-1);
      }
      switch(rc) {
		  case 1:

			 stage = 1; /* ready to begin */
			 firstSession = ans[0];
			 lastSession = ans[0];
			 return(0);

		  case 2:

			 stage = 1; /* ready to begin */
			 firstSession = ans[0];
			 lastSession = ans[1];

			 return(0);

		  default:
			 printf("Illegal channels (%d) in .cfg FILE\n",*ans);

			 return(-1);
      } /* end of switch(rc) */

   } /* end of if(strncmp(p,"channel",4) == 0) */



} /* function parse_line */


⌨️ 快捷键说明

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