1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * anjuta-launcher.h
4  * Copyright (C) 2003 Naba Kumar  <naba@gnome.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 #ifndef __ANJUTA_LAUNCHER_H__
21 #define __ANJUTA_LAUNCHER_H__
22 
23 #include <sys/types.h>
24 #include <glib.h>
25 #include <glib-object.h>
26 
27 G_BEGIN_DECLS
28 
29 typedef struct _AnjutaLauncher      AnjutaLauncher;
30 typedef struct _AnjutaLauncherClass AnjutaLauncherClass;
31 typedef struct _AnjutaLauncherPriv  AnjutaLauncherPriv;
32 
33 #define ANJUTA_TYPE_LAUNCHER            (anjuta_launcher_get_type ())
34 
35 #define ANJUTA_LAUNCHER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_LAUNCHER, AnjutaLauncher))
36 #define ANJUTA_LAUNCHER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_LAUNCHER, AnjutaLauncherClass))
37 
38 #define ANJUTA_IS_LAUNCHER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_LAUNCHER))
39 #define ANJUTA_IS_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_LAUNCHER))
40 
41 typedef enum {
42 	ANJUTA_LAUNCHER_OUTPUT_STDOUT,
43 	ANJUTA_LAUNCHER_OUTPUT_STDERR,
44 	ANJUTA_LAUNCHER_OUTPUT_PTY
45 } AnjutaLauncherOutputType;
46 
47 /**
48 * AnjutaLauncherOutputCallback:
49 * @launcher: a #AnjutaLauncher object
50 * @output_type: Type of the output
51 * @chars: Characters being outputed
52 * @user_data: User data passed back to the user
53 *
54 * This callback is called when new characters arrive from the launcher
55 * execution.
56 */
57 typedef void (*AnjutaLauncherOutputCallback) (AnjutaLauncher *launcher,
58 										  AnjutaLauncherOutputType output_type,
59 											  const gchar *chars,
60 											  gpointer user_data);
61 
62 struct _AnjutaLauncher
63 {
64     GObject parent;
65 	AnjutaLauncherPriv *priv;
66 };
67 
68 struct _AnjutaLauncherClass
69 {
70     GObjectClass parent_class;
71 
72 	/* Signals */
73 	void (*child_exited) (AnjutaLauncher *launcher,
74 						  int child_pid, int exit_status,
75 						  gulong time_taken_in_seconds);
76 	void (*busy) (AnjutaLauncher *launcher, gboolean busy_flag);
77 };
78 
79 GType anjuta_launcher_get_type (void);
80 AnjutaLauncher* anjuta_launcher_new (void);
81 gboolean anjuta_launcher_is_busy (AnjutaLauncher *launcher);
82 gboolean anjuta_launcher_execute (AnjutaLauncher *launcher,
83 								  const gchar *command_str,
84 								  AnjutaLauncherOutputCallback callback,
85 								  gpointer callback_data);
86 gboolean anjuta_launcher_execute_v (AnjutaLauncher *launcher,
87 									gchar *const dir,
88 									gchar *const argv[],
89 									gchar *const envp[],
90 									AnjutaLauncherOutputCallback callback,
91 									gpointer callback_data);
92 void anjuta_launcher_set_encoding (AnjutaLauncher *launcher,
93 									   const gchar *charset);
94 
95 void anjuta_launcher_send_stdin (AnjutaLauncher *launcher,
96 								 const gchar *input_str);
97 void anjuta_launcher_send_stdin_eof (AnjutaLauncher *launcher);
98 
99 void anjuta_launcher_send_ptyin (AnjutaLauncher *launcher,
100 								 const gchar *input_str);
101 pid_t anjuta_launcher_get_child_pid (AnjutaLauncher *launcher);
102 void anjuta_launcher_reset (AnjutaLauncher *launcher);
103 void anjuta_launcher_signal (AnjutaLauncher *launcher, int sig);
104 gboolean anjuta_launcher_set_buffered_output (AnjutaLauncher *launcher,
105 										  gboolean buffered);
106 gboolean anjuta_launcher_set_check_passwd_prompt (AnjutaLauncher *launcher,
107 											  gboolean check_passwd);
108 /* Returns old value */
109 gboolean anjuta_launcher_set_terminal_echo (AnjutaLauncher *launcher,
110 											gboolean echo_on);
111 gboolean anjuta_launcher_set_terminate_on_exit (AnjutaLauncher *launcher,
112 		gboolean terminate_on_exit);
113 
114 G_END_DECLS
115 
116 #endif				/* __ANJUTA_LAUNCHER_H__ */
117