xref: /illumos-gate/usr/src/cmd/hal/hald/hald_runner.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
1 /***************************************************************************
2  *
3  * CVSID: $Id$
4  *
5  * hald_runner.h - Interface to the hal runner helper daemon
6  *
7  * Copyright (C) 2006 Sjoerd Simons <sjoerd@luon.net>
8  *
9  * Licensed under the Academic Free License version 2.1
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  **************************************************************************/
26 
27 #ifndef HALD_RUNNER_H
28 #define HALD_RUNNER_H
29 
30 #include "device.h"
31 
32 /* Successful run of the program */
33 #define HALD_RUN_SUCCESS 0x0
34 /* Process was killed because of running too long */
35 #define  HALD_RUN_TIMEOUT 0x1
36 /* Failed to start for some reason */
37 #define HALD_RUN_FAILED 0x2
38 /* Killed on purpose, e.g. hal_runner_kill_device */
39 #define HALD_RUN_KILLED 0x4
40 
41 /* Default sane timeout */
42 #define HAL_HELPER_TIMEOUT 10000
43 
44 typedef void (*HalRunTerminatedCB) (HalDevice *d, guint32 exit_type,
45                                        gint return_code, gchar **error,
46                                        gpointer data1, gpointer data2);
47 
48 /* Start the runner daemon */
49 gboolean
50 hald_runner_start_runner(void);
51 
52 /* Start a helper, returns true on a successfull start.
53  * cb will be called on abnormal or premature termination
54  * only
55  */
56 gboolean
57 hald_runner_start (HalDevice *device, const gchar *command_line, char **extra_env,
58 		   HalRunTerminatedCB cb, gpointer data1, gpointer data2);
59 
60 /* Run a helper program using the commandline, with input as infomation on
61  * stdin */
62 void
63 hald_runner_run(HalDevice *device,
64                const gchar *command_line, char **extra_env,
65                guint32 timeout,
66                HalRunTerminatedCB cb,
67                gpointer data1, gpointer data2);
68 void
69 hald_runner_run_method(HalDevice *device,
70 		       const gchar *command_line, char **extra_env,
71                        gchar *input, gboolean error_on_stderr,
72                        guint32 timeout,
73                        HalRunTerminatedCB  cb,
74                        gpointer data1, gpointer data2);
75 
76 void hald_runner_kill_device(HalDevice *device);
77 void hald_runner_kill_all();
78 
79 /* called by the core to tell the runner a device was finalized */
80 void runner_device_finalized (HalDevice *device);
81 
82 #endif
83