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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* Copyright (C) 2014-2017 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WEECHAT_EXEC_H
#define WEECHAT_EXEC_H 1
#include <unistd.h>
#include <time.h>
#define weechat_plugin weechat_exec_plugin
#define EXEC_PLUGIN_NAME "exec"
#define EXEC_STDOUT 0
#define EXEC_STDERR 1
enum t_exec_color
{
EXEC_COLOR_ANSI = 0,
EXEC_COLOR_AUTO,
EXEC_COLOR_IRC,
EXEC_COLOR_WEECHAT,
EXEC_COLOR_STRIP,
/* number of color actions */
EXEC_NUM_COLORS,
};
struct t_exec_cmd
{
/* command/process */
int number; /* command number */
char *name; /* name of command */
struct t_hook *hook; /* pointer to process hook */
char *command; /* command (with arguments) */
pid_t pid; /* process id */
int detached; /* 1 if command is detached */
time_t start_time; /* start time */
time_t end_time; /* end time */
/* display */
int output_to_buffer; /* 1 if output is sent to buffer */
int output_to_buffer_exec_cmd; /* 1 if commands are executed */
char *buffer_full_name; /* buffer where output is displayed */
int line_numbers; /* 1 if lines numbers are displayed */
int color; /* what to do with ANSI colors */
int display_rc; /* 1 if return code is displayed */
/* command output */
int output_line_nb; /* line number */
int output_size[2]; /* number of bytes in stdout/stderr */
char *output[2]; /* stdout/stderr of command */
int return_code; /* command return code */
/* pipe/hsignal */
char *pipe_command; /* output piped to WeeChat/plugin cmd*/
char *hsignal; /* send a hsignal with output */
struct t_exec_cmd *prev_cmd; /* link to previous command */
struct t_exec_cmd *next_cmd; /* link to next command */
};
extern struct t_weechat_plugin *weechat_exec_plugin;
extern struct t_exec_cmd *exec_cmds;
extern struct t_exec_cmd *last_exec_cmd;
extern int exec_cmds_count;
extern int exec_search_color (const char *color);
extern struct t_exec_cmd *exec_search_by_id (const char *id);
extern struct t_exec_cmd *exec_add ();
extern int exec_process_cb (const void *pointer, void *data,
const char *command, int return_code,
const char *out, const char *err);
extern void exec_free (struct t_exec_cmd *exec_cmd);
extern void exec_free_all ();
#endif /* WEECHAT_EXEC_H */
|