Top | ![]() |
![]() |
![]() |
![]() |
GQuark | gcut_egg_error_quark () |
GCutEgg * | gcut_egg_new () |
GCutEgg * | gcut_egg_new_va_list () |
GCutEgg * | gcut_egg_new_argv () |
GCutEgg * | gcut_egg_new_strings () |
GCutEgg * | gcut_egg_new_array () |
void | gcut_egg_set_flags () |
GSpawnFlags | gcut_egg_get_flags () |
void | gcut_egg_set_env () |
gchar ** | gcut_egg_get_env () |
gboolean | gcut_egg_hatch () |
void | gcut_egg_close () |
gboolean | gcut_egg_write () |
GPid | gcut_egg_get_pid () |
gint | gcut_egg_wait () |
void | gcut_egg_kill () |
GIOChannel * | gcut_egg_get_input () |
GIOChannel * | gcut_egg_get_output () |
GIOChannel * | gcut_egg_get_error () |
guint | gcut_egg_get_forced_termination_wait_time () |
void | gcut_egg_set_forced_termination_wait_time () |
void | error | Run Last |
void | error-received | Run Last |
void | output-received | Run Last |
void | reaped | Run Last |
GCutEggは外部コマンドの実行・通信・終了をカプセル化します。GCutEggはエラーをGErrorとして報告します。エラーはgcut_assert_error()
を使うことにより簡単に検証できます。
外部コマンドはgcut_egg_new()
、gcut_egg_new_strings()
などのようなコンストラクタで指定します。この時点では外部コマンドは実行されません。gcut_egg_hatch()
で指定された外部コマンドが実行されます。
外部コマンドの標準出力・エラー出力は"output-received"シグナル・"error-received"シグナル、あるいは、gcut_egg_get_output()
・gcut_egg_get_error()
が返すGIOChannelで取得できます。gcut_egg_write()
は外部コマンドの標準入力にデータを書き込みます。
外部コマンドの終了を待つためにはgcut_egg_wait()
を使うことができます。無限待ちを避けるために、タイムアウトを指定することができます。
例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
static GString *output_string; static GCutEgg *egg; void cut_setup (void) { output_string = g_string_new(NULL); egg = NULL; } void cut_teardown (void) { if (output_string) g_string_free(output_string, TRUE); if (egg) g_object_unref(egg); } static void cb_output_received (GCutEgg *egg, const gchar *chunk, gsize size, gpointer user_data) { g_string_append_len(output_string, chunk, size); } void test_echo (void) { GError *error = NULL; egg = gcut_egg_new("echo", "XXX", NULL); g_signal_connect(egg, "output-received", G_CALLBACK(cb_output_received), NULL); gcut_egg_hatch(egg, &error); gcut_assert_error(error); gcut_egg_wait(egg, 1000, &error); gcut_assert_error(error); cut_assert_equal_string("XXX\n", output_string->str); } |
GQuark
gcut_egg_error_quark (void
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
GCutEgg * gcut_egg_new (const gchar *command
,...
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
追加メッセージ(省略可能)。詳細はcut_message()
を見てください。
command
を実行する新しいGCutEggオブジェクトを生成します。
Since: 1.0.6
GCutEgg * gcut_egg_new_va_list (const gchar *command
,va_list args
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
command
を実行する新しいGCutEggオブジェクトを生成します。
Since: 1.0.6
GCutEgg * gcut_egg_new_argv (gint argc
,gchar **argv
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
command
を実行する新しいGCutEggオブジェクトを生成します。
Since: 1.0.6
GCutEgg *
gcut_egg_new_strings (const gchar **command
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
使用例はcut_assert_equal_string()
を見てください。
command
を実行する新しいGCutEggオブジェクトを生成します。
Since: 1.0.6
GCutEgg *
gcut_egg_new_array (GArray *command
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
command
を実行する新しいGCutEggオブジェクトを生成します。
Since: 1.0.6
void gcut_egg_set_flags (GCutEgg *egg
,GSpawnFlags flags
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部コマンドを実行するときのflags
を設定します。
Since: 1.0.6
GSpawnFlags
gcut_egg_get_flags (GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部コマンドを実行する時のflags
を取得します。
Since: 1.0.6
void gcut_egg_set_env (GCutEgg *egg
,const gchar *name
,...
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_expected()
も見てください。
外部コマンドの環境変数を設定します。
Since: 1.0.6
gchar **
gcut_egg_get_env (GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_expected()
も見てください。
外部コマンドの環境変数を取得します。
新しく割り当てられたNULL
終端の環境変数のリスト("名前1=値1", "名前2=値2", ..., NULL
)を返します。必要がなくなったらg_strfreev()
で開放してください。
Since: 1.0.6
gboolean gcut_egg_hatch (GCutEgg *egg
,GError **error
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
新しい外部プロセスを実行します。
Since: 1.0.6
比較するguintのGList。
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
GCutProcessオブジェクト。
実行した外部コマンドのリソースを回収します。破棄されるときに暗黙的に回収されます。
Since: 1.0.6
gboolean gcut_egg_write (GCutEgg *egg
,const gchar *chunk
,gsize size
,GError **error
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_expected()
も見てください。
外部プロセスの標準入力にchunk
を書き込みます。
Since: 1.0.6
比較するguintのGList。
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_expected()
も見てください。
実行している外部プロセスのプロセスIDを取得します。外部コマンドが実行されていない場合は0が返ります。
Since: 1.0.6
gint gcut_egg_wait (GCutEgg *egg
,guint timeout
,GError **error
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
実行中の外部プロセスが終了することをtimeout
ミリ秒待ちます。外部コマンドがtimeout
ミリ秒以内に終了しなかった場合は、GCUT_EGG_ERROR_TIMEOUT
エラーが設定され、-1が返ります。外部プロセスが実行されていない場合は、GCUT_EGG_ERROR_NOT_RUNNING
エラーが設定され、-1が返ります。
Since: 1.0.6
void gcut_egg_kill (GCutEgg *egg
,gint signal_number
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部プロセスにsignal_number
シグナルを送ります。
Since: 1.0.6
GIOChannel *
gcut_egg_get_input (GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部プロセスの標準入力と結びついたGIOChannelを取得します。
Since: 1.0.6
GIOChannel *
gcut_egg_get_output (GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部プロセスの標準出力と結びついたGIOChannelを取得します。
Since: 1.0.6
GIOChannel *
gcut_egg_get_error (GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
cut_set_actual()
も見てください。
外部プロセスのエラー出力に結びついたGIOChannelを返します。
Since: 1.0.6
guint
gcut_egg_get_forced_termination_wait_time
(GCutEgg *egg
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
gcut_egg_get_forced_termination_wait_time
はバージョン1.1.5から非推奨になりました。新しく書くコードでは使わないでください。代わりにgcut_process_get_forced_termination_wait_time()
を使ってください。
オブジェクトが破棄されるときに行われる外部コマンド強制終了後に待つ時間(ミリ秒)を取得します。
Since: 1.0.6
void gcut_egg_set_forced_termination_wait_time (GCutEgg *egg
,guint timeout
);
gcut_egg_error_quark
は非推奨です。新しいコードでは使わないでください。
gcut_egg_set_forced_termination_wait_time
はバージョン1.1.5から非推奨になりました。新しく書くコードでは使わないでください。代わりにgcut_egg_set_forced_termination_wait_time()
を使ってください。
オブジェクトが破棄されるときに行われる外部コマンド強制終了時に待つ時間(ミリ秒)を設定します。timeout
が0なら外部コマンドの終了を待ちません。デフォルト値は10です。
Since: 1.0.6
#define GCUT_EGG_ERROR (gcut_egg_error_quark())
GCUT_EGG_ERROR
は非推奨です。新しいコードでは使わないでください。
"error"
シグナルvoid user_function (GCutEgg *egg, gpointer error, gpointer user_data)
It is emitted each time an external process causes an error. (e.g. IO error)
egg |
the object which received the signal. |
|
error |
the error of an external process. ( |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.0.6
"error-received"
シグナルvoid user_function (GCutEgg *egg, gchar *chunk, guint64 size, gpointer user_data)
It is emitted each time an external process outputs something to its standard error output and it is read.
Note that you need to run GLib's main loop by g_main_loop_run()
, g_main_context_iteration()
and so on for detecting an external process's output is readable.
egg |
the object which received the signal. |
|
chunk |
the chunk read from an external process's standard error output. |
|
size |
the size of |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.0.6
"output-received"
シグナルvoid user_function (GCutEgg *egg, gchar *chunk, guint64 size, gpointer user_data)
It is emitted each time an external process outputs something to its standard output and it is read.
Note that you need to run GLib's main loop by g_main_loop_run()
, g_main_context_iteration()
and so on for detecting an external process's output is readable.
egg |
the object which received the signal. |
|
chunk |
the chunk read from an external process's standard output. |
|
size |
the size of |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.0.6
"reaped"
シグナルvoid user_function (GCutEgg *egg, gint status, gpointer user_data)
It is emitted when an external process is exited.
Note that you need to run GLib's main loop by g_main_loop_run()
, g_main_context_iteration()
and so on for detecting an external process is exited.
egg |
the object which received the signal. |
|
status |
the exit status of an external process. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.0.6