1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2007-2012 Richard Hughes <richard@hughsie.com> 4 * 5 * Licensed under the GNU General Public License Version 2 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 21 22 #ifndef __CD_SPAWN_H 23 #define __CD_SPAWN_H 24 25 #include <glib-object.h> 26 27 G_BEGIN_DECLS 28 29 #define CD_TYPE_SPAWN (cd_spawn_get_type ()) 30 #define CD_SPAWN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CD_TYPE_SPAWN, CdSpawn)) 31 #define CD_SPAWN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CD_TYPE_SPAWN, CdSpawnClass)) 32 #define CD_IS_SPAWN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CD_TYPE_SPAWN)) 33 #define CD_IS_SPAWN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CD_TYPE_SPAWN)) 34 #define CD_SPAWN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CD_TYPE_SPAWN, CdSpawnClass)) 35 #define CD_SPAWN_ERROR (cd_spawn_error_quark ()) 36 #define CD_SPAWN_TYPE_ERROR (cd_spawn_error_get_type ()) 37 38 typedef struct CdSpawnPrivate CdSpawnPrivate; 39 40 typedef struct 41 { 42 GObject parent; 43 CdSpawnPrivate *priv; 44 } CdSpawn; 45 46 typedef struct 47 { 48 GObjectClass parent_class; 49 } CdSpawnClass; 50 51 /** 52 * CdSpawnExitType: 53 * 54 * How the spawned file exited 55 **/ 56 typedef enum { 57 CD_SPAWN_EXIT_TYPE_SUCCESS, /* script run, without any problems */ 58 CD_SPAWN_EXIT_TYPE_FAILED, /* script failed to run */ 59 CD_SPAWN_EXIT_TYPE_SIGQUIT, /* we killed the instance (SIGQUIT) */ 60 CD_SPAWN_EXIT_TYPE_SIGKILL, /* we killed the instance (SIGKILL) */ 61 CD_SPAWN_EXIT_TYPE_UNKNOWN 62 } CdSpawnExitType; 63 64 GType cd_spawn_get_type (void); 65 CdSpawn *cd_spawn_new (void); 66 67 gboolean cd_spawn_argv (CdSpawn *spawn, 68 gchar **argv, 69 gchar **envp, 70 GError **error) 71 G_GNUC_WARN_UNUSED_RESULT; 72 gboolean cd_spawn_is_running (CdSpawn *spawn); 73 gboolean cd_spawn_kill (CdSpawn *spawn); 74 gboolean cd_spawn_send_stdin (CdSpawn *spawn, 75 const gchar *command); 76 77 G_END_DECLS 78 79 #endif /* __CD_SPAWN_H */ 80