-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathServerMain.cpp
More file actions
92 lines (83 loc) · 2.5 KB
/
ServerMain.cpp
File metadata and controls
92 lines (83 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright (C) 2012 Yee Young Han <websearch@naver.com> (http://blog.naver.com/websearch)
*
* 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 3 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
*/
#include "SipUdp.h"
#include "ServerServicePrivate.h"
#include "ServerUtility.h"
#include "FileUtility.h"
#include <stdio.h>
#include "MemoryDebug.h"
CServerService gclsService;
ServerFunc gpServerFunc;
/**
* @ingroup ServerPlatform
* @brief 서버 서비스 main function
* @param argc 터미널 입력 인자 개수
* @param argv 터미널 입력 인자
* @param clsService 서비스 정의 객체
* @param pFunc 서비스 main 함수
* @returns 정상 종료하면 0 을 리턴하고 오류가 발생하면 -1 를 리턴한다.
*/
int ServerMain( int argc, char * argv[], CServerService & clsService, ServerFunc pFunc )
{
gclsService = clsService;
gpServerFunc = pFunc;
#ifdef WIN32
if( argc == 1 )
{
const char * pszConfigFileName = GetConfigFileName();
if( IsExistFile( pszConfigFileName ) == false )
{
printf( "setup file(%s) is not exist", pszConfigFileName );
return -1;
}
ServiceStart();
return 0;
}
#endif
if( argc == 1 )
{
printf( "[Usage] %s {config filename}\n", argv[0] );
return -1;
}
gclsService.m_strConfigFileName = argv[1];
if( !strcmp( argv[1], "-h" ) || !strcmp( argv[1], "-v" ) )
{
printf( "%s version-%s ( build %s )\n", argv[0], gclsService.m_strVersion.c_str(), gclsService.m_strBuildDate.c_str() );
printf( "[Usage] %s {config filename}\n", argv[0] );
#ifdef WIN32
printf( " %s -i : install service\n", argv[0] );
printf( " %s -u : uninstall service\n", argv[0] );
#endif
return 0;
}
#ifdef WIN32
if( !strcmp( argv[1], "-i" ) )
{
InstallService();
return 0;
}
else if( !strcmp( argv[1], "-u" ) )
{
InitNetwork();
UninstallService();
return 0;
}
#endif
gpServerFunc( );
return 0;
}