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