summaryrefslogtreecommitdiff
path: root/open-vm-tools/vgauth/service/service.h
blob: 5a22f89b69e6049e34f62c4bc69da99509bd09f2 (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
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
93
94
95
96
97
98
99
100
101
102
/*********************************************************
 * Copyright (C) 2011-2015 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation version 2.1 and no 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 Lesser GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *********************************************************/

/**
 * @file service.h --
 *
 *    Stand-alone service functions and data types.
 */

#ifndef _SERVICE_H_
#define _SERVICE_H_

#ifdef _WIN32
#include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <glib.h>
#include <glib/gstdio.h>

#include "VGAuthError.h"
#include "VGAuthLog.h"
#include "serviceInt.h"
#include "audit.h"


#define VGAUTH_SERVICE_NAME "VGAuthService"

VGAuthError ServiceIOStartListen(ServiceConnection *conn);

VGAuthError ServiceIOPrepareMainLoop(void);

VGAuthError ServiceIOMainLoop(void);

VGAuthError ServiceStopIO(ServiceConnection *conn);

#ifdef _WIN32
VGAuthError ServiceIORegisterQuitEvent(HANDLE hQuitEvent);

gboolean ServiceRegisterService(gboolean bRegister,
                                const gchar *name,
                                const gchar *displayName,
                                const gchar *description,
                                const gchar *binaryPath,
                                gchar **errString);

gboolean ServiceInitStdioConsole(void);
#endif

#ifndef _WIN32
typedef enum ServiceDaemonizeFlags {
   SERVICE_DAEMONIZE_DEFAULT = 0,
   SERVICE_DAEMONIZE_LOCKPID = (1 << 0),
} ServiceDaemonizeFlags;

gboolean ServiceDaemonize(const char *path,
                          char * const *args,
                          ServiceDaemonizeFlags flags,
                          const char *pidPath);

GSource *ServiceNewSignalSource(int signum);

void ServiceSetSignalHandlers(void);

gboolean ServiceSuicide(const char *pidPath);
#endif

#ifdef _WIN32
#define LOGFILENAME_DEFAULT "vgauthsvclog.txt"
#define LOGFILENAME_PATH_DEFAULT "c:\\temp\\" LOGFILENAME_DEFAULT
#else
#define LOGFILENAME_PATH_DEFAULT "/tmp/vgauthsvclog.txt"
#endif

void Service_SetLogOnStdout(gboolean flag);
void Service_InitLogging(gboolean haveDebugConsole, gboolean restart);
void *ServiceFileLogger_Init(void);
gboolean ServiceFileLogger_Log(const gchar *domain,
                               GLogLevelFlags level,
                               const gchar *message,
                               gpointer data);

#endif   // _SERVICE_H_