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

📄 varserver.c

📁 变量
💻 C
字号:
/*************************************************************************** *   Copyright (C) 2006 by f117cdh                                         * *   f117cdh@tom.com                                                       * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdio.h>#include <stdlib.h>#include <sys/wait.h> #include"../../../../adapi/src/adapi.h"#include"../../../server/src/varserver.h"int MYAPI VarServerCall(int nCode,char *szMsg){	printf(szMsg);	return 0;}int main(int argc, char *argv[]){		pid_t  pid;	char 	szPathIni[]="/opt/varserver/varserver.ini";	char 	szVarPathDefault[]="/opt/varserver/var/";	char 	szBufIni[1024];	int	nPort;	char	szVarPath[300];	int nRet;	nRet=FileReadEx(szPathIni,0,szBufIni,1024);		if(nRet>0)	{		szBufIni[nRet]=0;	}	else	{		szBufIni[0]=0;	}	GetValueFromString(szBufIni,"PORT",szVarPath,300,"=","\n\r\t");	//printf("%s\n",szVarPath);	nPort=atoi(StrTrimLeft(StrTrimRight(szVarPath)));	GetValueFromString(szBufIni,"VAR_PATH",szVarPath,300,"=","\n\r\t");		//printf("%d\n",nPort);	if(nPort==0)nPort=7061;		if(*szVarPath==0)	{		strcpyn(szVarPath,szVarPathDefault,298);	} 			if((pid=fork())==0)	{		VarServerSetPort(nPort);			VarServerSetVarPath(StrTrimLeft(StrTrimRight(szVarPath)));			if(VarServerMain(0)!=0)		{						return 1;		}		else		{			return 0;		}	}		if(pid==waitpid(pid,0,WNOHANG ))	{		fprintf(stderr,"varserver PORT %d maybe in use!!!\n",nPort);		return 1;	}	else	{		fprintf(stdout,"PORT=%d;VAR_PATH=%s",nPort,szVarPath);		return 0;	}  	}

⌨️ 快捷键说明

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