-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvc.cpp
More file actions
63 lines (51 loc) · 1.13 KB
/
svc.cpp
File metadata and controls
63 lines (51 loc) · 1.13 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
#include<iostream>
#include "nskernel/server.h"
#include "svc.h"
#include "demo.h"
using namespace std;
SVC_EXPORT GHANDLE * svc_create(const char *config_file,char * errormsg,unsigned msgsize)
{
DemoSvr * p = new DemoSvr;
try
{
p->init(config_file);
}
catch(std::exception& e)
{
snprintf(errormsg,msgsize-1,"svc init fail:%s",e.what());
delete p;
p = NULL;
}
return (GHANDLE *)p;
}
SVC_EXPORT void svc_run(GHANDLE * ghandle)
{
((Server *)ghandle)->run();
}
SVC_EXPORT void svc_run_thread(GHANDLE * ghandle)
{
((Server *)ghandle)->run_thread();
}
SVC_EXPORT void svc_destory(GHANDLE * ghandle)
{
delete ((Server *)ghandle);
}
// 版本信息
SVC_EXPORT void svc_version(char * version,unsigned versionsize)
{
strncpy(version,Server::version().c_str(),versionsize);
}
// msgsize最大4096
SVC_EXPORT void svc_info(GHANDLE * ghandle,char * msg,unsigned msgsize)
{
strncpy(msg,((Server *)ghandle)->info().c_str(),msgsize);
}
// 运行过程中重新加载配置
SVC_EXPORT void svc_reload(GHANDLE * ghandle)
{
((Server *)ghandle)->reload();
}
SVC_EXPORT void svc_quit(GHANDLE * ghandle)
{
((Server *)ghandle)->quit();
}