-
Notifications
You must be signed in to change notification settings - Fork 27
/
cmd.h
43 lines (31 loc) · 860 Bytes
/
cmd.h
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
#pragma once
#include "xfsapi.h"
#include <string>
#define WFSC_BAD_CMD 0x42
#define APPID "xfsc"
#define CMD_COUNT(x) (sizeof(x)/sizeof(cmd_t))
typedef HRESULT(*handler_t)(int, char**);
typedef void(*help_fn)();
typedef struct cmd_ {
const char* name;
const char* help;
handler_t func;
help_fn more;
} cmd_t;
class Service {
public:
std::string name;
// TODO: Other metadata...
HSERVICE handle;
Service(std::string name, HSERVICE h) : name(name), handle(h) {}
~Service() {
if (handle) WFSClose(handle);
}
};
void handle(char* args);
HRESULT dispatch(cmd_t* fdt, int count, int argc, char** argv);
void check(HRESULT res);
Service* get_service(HSERVICE id);
void del_service(Service* svc);
void lock(Service* svc);
void unlock(Service* svc);