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

📄 simufunc.c

📁 仿真测试接口程序。根据电总《用户接入网管理功能与管理接口技术规范》之《与112集中受理系统接口规范》
💻 C
字号:
/*   *  simufunc.c  --  Common functions */#include <poll.h>#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <string.h>#include "simdrv.h"#include "simu112.h"#include "simufunc.h"/* end of writeport *//*********************************************************Function:int writeport(int port_fd, char *str)Narrative:	Write messages to fd of socket.Param:	int port_fd	- socket id	char *str - a pointer to sending string.Return: >0	OK.	-1	Write failure.*********************************************************/int writeport(int port_fd, char *str){	int i, len, ret;	/* printf("send: %s\n",str); */	return (write(port_fd, str, strlen(str)));/*   len=strlen(str);   for (i=0;i<len;i++){   poll(0,0,200);   ret=write(port_fd,&str[i],1);   if (ret!=1)   return(ret);   } */}/* end of writeport *//*********************************************************Function:int writeport1(int port_fd, char *str)Narrative:	Write messages to fd of socket at interval of 320 ms between two charactors.Param:	int port_fd	- socket id	char *str - a pointer to sending string.Return: >0	OK.	-1	Write failure.*********************************************************/int writeport1(int port_fd, char *str){	int i, len, ret;	/* printf("send: %s\n",str); *//*  return(write(port_fd,str,strlen(str))); *//*  */	len = strlen(str);	for (i = 0; i < len; i++)	{		poll(0, 0, 320);		ret = write(port_fd, &str[i], 1);		if (ret != 1)			return (ret);	}/*  */}/* end of writeport1 *//*********************************************************Function:int writeport2(int port_fd, char *str)Narrative:	Write messages to fd of socket at interval of 10 ms between two charactors.Param:	int port_fd	- socket id	char *str - a pointer to sending string.Return: 1	OK.	-1	Write failure.*********************************************************/int writeport2(int port_fd, char *str){	int i, len, ret;	/* printf("send: %s\n",str); *//*  return(write(port_fd,str,strlen(str))); *//*  */	len = strlen(str);	for (i = 0; i < len; i++)	{		poll(0, 0, 10);		ret = write(port_fd, &str[i], 1);		if (ret != 1)			return (ret);	}/*  */}/* end of writeport3 *//*********************************************************Function:void f_show_msg(TESTMSG * testMsg)Narrative:	Display test result.Param:	TESTMSG * testmsg	- struct of test messageReturn: None.*********************************************************/void f_show_msg(TESTMSG * testMsg){/*   #ifdef DEBUG   printf("return TESTMSG : CommandType=%d\n\   CorrelationTag=%s\n\   Error=%s\n\   TestConclusion=%s\n\   A-Bres=%s\n\   A-Gres=%s\n\   B-Gres=%s\n\   A-Gdc=%s\n\   B-Gdc=%s\n\   A-Gac=%s\n\   B-Gac=%s\n\   A-Bcap=%s\n\   A-Gcap=%s\n\   B-Gcap=%s\n\   EndFlag=%c\n",   testMsg->CommandType,   testMsg->CorrelationTag,   testMsg->Error,   testMsg->TestResult.TestConclusion,   testMsg->TestResult.TR2_DCres,   testMsg->TestResult.TG2_DCres,   testMsg->TestResult.RG2_DCres,   testMsg->TestResult.TG2_DCvol,   testMsg->TestResult.RG2_DCvol,   testMsg->TestResult.TG_ACvol,   testMsg->TestResult.RG_ACvol,   testMsg->TestResult.TR_cap,   testMsg->TestResult.TG_cap,   testMsg->TestResult.RG_cap,   testMsg->EndFlag);   #endif  */}/*********************************************************Function:void f_trim_space(char *s)Narrative:	Remove bkank in the string.Param:	char *s - a pointer to stirng that will be trimedReturn: None.*********************************************************/void f_trim_space(char *s){	char *p, *q;	p = s;	q = s;	while (*p)	{		if (*p != ' ' && *p != '\t')		{			*q = *p;			++q;		}		++p;	}	*q = '\0';}/*********************************************************Function:FILE *backup_log(char *LogFile)Narrative:	Backup logFile while size of logFile large than LOGFILESIZE.Param:	char *LogFile - a pointer to logfileReturn: return a pointer to FILE fd.*********************************************************/FILE *backup_log(char *LogFile){	struct stat statbuf;	char BackupFile[20];	char *ptr;	stat(LogFile, &statbuf);	if (statbuf.st_size < LOGFILESIZE)		return (fopen(LogFile, "a+"));	strcpy(BackupFile, LogFile);	ptr = strstr(BackupFile, ".log");	if (ptr == NULL)		strcat(BackupFile, ".bak");	else	{		*ptr = 0;		strcat(ptr, ".bak");	}	remove(BackupFile);	rename(LogFile, BackupFile);	return (fopen(LogFile, "a+"));}

⌨️ 快捷键说明

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