common.h 1.3 KB
Newer Older
1 2 3
#ifndef WIN64SVC_COMMON_H
#define WIN64SVC_COMMON_H

4 5
#include <windows.h>
#include <stdio.h>
6 7 8 9 10 11

#define E_CREATE_SERVICE 101
#define E_ACCESS_DENIED  102
#define E_SERVICE_MANAGER 103
#define E_OPEN_SERVICE 104
#define E_DELETE_SERVICE 105
V
Vlad Ilyushchenko 已提交
12
#define E_CONTROL_SERVICE 106
13 14 15 16 17

#define eprintf(format, ...) fprintf(stderr, format, ##__VA_ARGS__)
#define SVC_NAME_PREFIX "QuestDB"
#define SVC_DISPLAY_NAME "QuestDB Server"

18 19 20 21 22 23 24 25 26
// configuration error codes

#define ECONFIG_OK                0
#define ECONFIG_UNKNOWN_OPTION    1
#define ECONFIG_JAVA_HOME         2
#define ECONFIG_UNKNOWN_COMMAND   3
#define ECONFIG_TOO_MANY_COMMANDS 4


27 28 29 30
typedef struct {
    int command;
    BOOL forceCopy;
    LPSTR dir;
31
    int errorCode;
32 33 34
    LPSTR javaExec;
    LPSTR javaArgs;
    LPSTR exeName;
35
    LPSTR serviceName;
36
    LPSTR serviceDisplayName;
37 38
} CONFIG;

39
int qdbRun(int argc, char **argv);
40

41 42 43 44 45 46 47 48
void qdbDispatchService(CONFIG *config);

void initAndParseConfig(int argc, char **argv, CONFIG *config);

int makeDir(const char *dir);

FILE *redirectStdout(CONFIG *config);

49 50 51
BOOL svcInstall(CONFIG *config);

int svcRemove(CONFIG *config);
52

53 54 55 56 57 58
int svcStatus(CONFIG *config);

int svcStart(CONFIG *config);

int svcStop(CONFIG *config);

59 60 61
void log_event(WORD logType, char* serviceName, char *message);

#endif //WIN64SVC_COMMON_H