blob: 836b4c60e65d7ce2f63b3dc0ed94a15c24ce96c8 (
plain)
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
|
#include "commonheaders.h"
extern std::list<service*> services;
extern boost::mutex service_list_mutex;
int ServiceExists(const char *name);
void CreateServiceFunction(const char* name, SERVICE svc)
{
if(!ServiceExists(name))
services.push_back(new service(name, svc));
}
void* CallService(const char *name,void* data)
{
if(!services.empty())
{
service_list_mutex.lock();
std::list<service*>::iterator end = services.end();
for(std::list<service*>::iterator i = services.begin(); i != end; ++i)
{
if(!strcmp((*i)->getName(), name))
return (*i)->getService()(data);
}
service_list_mutex.unlock();
}
return 0;
}
int ServiceExists(const char *name)
{
service_list_mutex.lock();
if(!services.empty())
{
std::list<service*>::iterator end = services.end();
for(std::list<service*>::iterator i = services.begin(); i != end; ++i)
if(!strcmp((*i)->getName(), name))
return 1;
}
service_list_mutex.unlock();
return 0;
}
service::service(const char* name, SERVICE svc)
{
pService = svc;
szName = strdup(name);
}
const char* service::getName()
{
return szName;
}
const SERVICE service::getService()
{
return pService;
}
service::~service()
{
free(szName);
}
|