]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - os_win32/daemon_win32.h
Imported Upstream version 6.1+svn3812
[mirror_smartmontools-debian.git] / os_win32 / daemon_win32.h
1 /*
2 * os_win32/daemon_win32.h
3 *
4 * Home page of code is: http://smartmontools.sourceforge.net
5 *
6 * Copyright (C) 2004-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * You should have received a copy of the GNU General Public License
14 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 #ifndef DAEMON_WIN32_H
19 #define DAEMON_WIN32_H
20
21 #define DAEMON_WIN32_H_CVSID "$Id: daemon_win32.h 3584 2012-08-05 17:05:32Z chrfranke $"
22
23 #include <signal.h>
24
25 // Additional non-ANSI signals
26 #define SIGHUP (NSIG+1)
27 #define SIGUSR1 (NSIG+2)
28 #define SIGUSR2 (NSIG+3)
29
30
31 // Options for Windows service
32 typedef struct daemon_winsvc_options_s {
33 const char * cmd_opt; // argv[1] option for services
34 // For service "install" command only:
35 const char * svcname; // Service name
36 const char * dispname; // Service display name
37 const char * descript; // Service description
38 } daemon_winsvc_options;
39
40
41 // This function must be called from main()
42 int daemon_main(const char * ident, const daemon_winsvc_options * svc_opts,
43 int (*main_func)(int, char **), int argc, char **argv );
44
45 // exit(code) returned by a service
46 extern int daemon_winsvc_exitcode;
47
48 // Simulate signal()
49 void (*daemon_signal(int sig, void (*func)(int)))(int);
50 const char * daemon_strsignal(int sig);
51
52 // Simulate sleep()
53 void daemon_sleep(int seconds);
54
55 // Disable/Enable console
56 void daemon_disable_console(void);
57 int daemon_enable_console(const char * title);
58
59 // Detach from console
60 int daemon_detach(const char * ident);
61
62 // Spawn a process and redirect stdio
63 int daemon_spawn(const char * cmd,
64 const char * inpbuf, int inpsize,
65 char * outbuf, int outsize );
66
67 #endif // DAEMON_WIN32_H