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