mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 23:36:37 +02:00
exec: add exec plugin
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* exec-config.c - exec configuration options (file exec.conf)
|
||||
*
|
||||
* Copyright (C) 2014 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/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "exec.h"
|
||||
#include "exec-config.h"
|
||||
|
||||
|
||||
struct t_config_file *exec_config_file = NULL;
|
||||
|
||||
/* exec config, command section */
|
||||
|
||||
struct t_config_option *exec_config_command_purge_delay;
|
||||
|
||||
/* exec config, color section */
|
||||
|
||||
struct t_config_option *exec_config_color_flag_running;
|
||||
struct t_config_option *exec_config_color_flag_finished;
|
||||
|
||||
/*
|
||||
* Reloads exec configuration file.
|
||||
*/
|
||||
|
||||
int
|
||||
exec_config_reload_cb (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes exec configuration file.
|
||||
*
|
||||
* Returns:
|
||||
* 1: OK
|
||||
* 0: error
|
||||
*/
|
||||
|
||||
int
|
||||
exec_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
exec_config_file = weechat_config_new (EXEC_CONFIG_NAME,
|
||||
&exec_config_reload_cb, NULL);
|
||||
if (!exec_config_file)
|
||||
return 0;
|
||||
|
||||
/* command */
|
||||
ptr_section = weechat_config_new_section (exec_config_file, "command",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (exec_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
exec_config_command_purge_delay = weechat_config_new_option (
|
||||
exec_config_file, ptr_section,
|
||||
"purge_delay", "integer",
|
||||
N_("delay for purging finished commands (in seconds, 0 = purge "
|
||||
"commands immediately, -1 = never purge)"),
|
||||
NULL, -1, 36000 * 24 * 30, "0", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* color */
|
||||
ptr_section = weechat_config_new_section (exec_config_file, "color",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (exec_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
exec_config_color_flag_running = weechat_config_new_option (
|
||||
exec_config_file, ptr_section,
|
||||
"flag_running", "color",
|
||||
N_("text color for a running command flag (in exec buffer and "
|
||||
"/exec -list)"),
|
||||
NULL, 0, 0, "lightgreen", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
exec_config_color_flag_finished = weechat_config_new_option (
|
||||
exec_config_file, ptr_section,
|
||||
"flag_finished", "color",
|
||||
N_("text color for a finished command flag (in exec buffer and "
|
||||
"/exec -list)"),
|
||||
NULL, 0, 0, "lightred", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads exec configuration file.
|
||||
*/
|
||||
|
||||
int
|
||||
exec_config_read ()
|
||||
{
|
||||
return weechat_config_read (exec_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes exec configuration file.
|
||||
*/
|
||||
|
||||
int
|
||||
exec_config_write ()
|
||||
{
|
||||
return weechat_config_write (exec_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees exec configuration.
|
||||
*/
|
||||
|
||||
void
|
||||
exec_config_free ()
|
||||
{
|
||||
weechat_config_free (exec_config_file);
|
||||
}
|
||||
Reference in New Issue
Block a user