Added new command line argument for setting WeeChat homedir (-d or --dir) (patch from Gwenn)

This commit is contained in:
Sebastien Helleu 2006-01-25 08:55:24 +00:00
parent 6972b057d9
commit 364d774ded
40 changed files with 2744 additions and 2396 deletions

View File

@ -5,6 +5,8 @@ ChangeLog - 2006-01-24
Version 0.1.8 (under dev!):
* added new command line argument for setting WeeChat homedir (-d or --dir)
(patch from Gwenn)
* fixed bug with charset in infobar highlights
* fixed bug with buffer detection in plugins/scripts commands
* fixed bug with /history command

11
NEWS
View File

@ -1,6 +1,17 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
* FlashCode, 2006-01-24 (draft)
Important release notes for 0.1.8 (draft):
- it is recommended for users of version 0.1.7 (or any older), to
replace values in setup file (~/.weechat/weechat.rc) :
- option: log_path: replace "~/.weechat/logs" by "%h/logs"
- option: plugins_path: replace "~/.weechat/plugins" by "%h/plugins"
"%h" is replaced by WeeChat home (default: ~/.weechat, may be overriden
by new command line arg --dir)
* FlashCode, 2006-01-14
WeeChat 0.1.7 released.

View File

@ -739,7 +739,7 @@
<entry>string</entry>
<entry>any string</entry>
<entry></entry>
<entry>Path for WeeChat log files</entry>
<entry>Path for WeeChat log files ('%h' will be replaced by WeeChat home, ~/.weechat by default)</entry>
</row>
<row>
<entry><option>log_timestamp</option></entry>
@ -977,7 +977,7 @@
<entry>string</entry>
<entry>any string</entry>
<entry></entry>
<entry>Path for searching plugins</entry>
<entry>Path for searching plugins ('%h' will be replaced by WeeChat home, ~/.weechat by default)</entry>
</row>
<row>
<entry><option>plugins_autoload</option></entry>

View File

@ -330,6 +330,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Display config help (list of options)
</entry>
</row>
<row>
<entry><literal>-d, --dir &lt;path&gt;</literal></entry>
<entry>
Set path as home for WeeChat (used for configuration files,
logs, user plugins and scripts). Default value is
"<literal>~/.weechat</literal>". Please note that directory
is created if not found by WeeChat.
</entry>
</row>
<row>
<entry><literal>-f, --key-functions</literal></entry>
<entry>
@ -3593,6 +3602,12 @@ Weechat.set_plugin_config ("my_var", "value")
patches
</para>
</listitem>
<listitem>
<para>
<emphasis>Gwenn</emphasis> -
patches
</para>
</listitem>
</itemizedlist>
</para>

View File

@ -738,8 +738,8 @@
<entry><option>log_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat</entry>
<entry>'%h/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>log_timestamp</option></entry>
@ -976,8 +976,8 @@
<entry><option>plugins_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/plugins'</entry>
<entry>Chemin de recherche des extensions</entry>
<entry>'%h/plugins'</entry>
<entry>Chemin de recherche des extensions ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>plugins_autoload</option></entry>

View File

@ -336,6 +336,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Afficher l'aide sur le fichier de config (liste des options)
</entry>
</row>
<row>
<entry><literal>-d, --dir &lt;répertoire&gt;</literal></entry>
<entry>
Définir le répertoire comme étant la base de WeeChat
(utilisé pour les fichiers de configuration, logs, extensions
et scripts de l'utilisateur). La valeur par défaut est
"<literal>~/.weechat</literal>". NB: le répertoire est créé
s'il n'est pas trouvé par WeeChat.
</entry>
</row>
<row>
<entry><literal>-f, --key-functions</literal></entry>
<entry>
@ -3654,6 +3664,12 @@ Weechat.set_plugin_config ("ma_variable", "valeur")
patchs
</para>
</listitem>
<listitem>
<para>
<emphasis>Gwenn</emphasis> -
patchs
</para>
</listitem>
</itemizedlist>
</para>

View File

@ -27,6 +27,10 @@ disable auto-connect to servers at startup
.br
display config file help (list of options)
.TP
.B \-d, \-\-dir <dir>
.br
set WeeChat home dir
.TP
.B \-f, \-\-key\-functions
.br
display internal functions for keys

572
po/cs.po

File diff suppressed because it is too large Load Diff

580
po/es.po

File diff suppressed because it is too large Load Diff

565
po/fr.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3142,7 +3142,7 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
t_irc_server *ptr_server;
int filename_length;
char *filename;
char *exec_args[5] = { NULL, "-a", "--session", NULL, NULL };
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--session", NULL, NULL };
/* make gcc happy */
(void) server;
@ -3196,7 +3196,8 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
}
exec_args[0] = strdup (weechat_argv0);
exec_args[3] = strdup (filename);
exec_args[3] = strdup (weechat_home);
exec_args[5] = strdup (filename);
/* unload plugins, save config, then upgrade */
#ifdef PLUGINS

View File

@ -54,7 +54,7 @@ fifo_create ()
if (cfg_irc_fifo_pipe)
{
/* build FIFO filename: "~/.weechat/weechat_fifo_" + process PID */
/* build FIFO filename: "<weechat_home>/weechat_fifo_" + process PID */
if (!weechat_fifo_filename)
{
filename_length = strlen (weechat_home) + 64;

View File

@ -107,29 +107,36 @@ void
log_start (t_gui_buffer *buffer)
{
int length;
char *ptr_home;
char *ptr_home, *log_path, *log_path2, *ptr_path;
ptr_home = getenv ("HOME");
length = strlen (cfg_log_path) +
((cfg_log_path[0] == '~') ? strlen (ptr_home) : 0) +
64;
log_path = weechat_strreplace (cfg_log_path, "~", ptr_home);
log_path2 = weechat_strreplace ((log_path) ?
log_path : cfg_log_path,
"%h", weechat_home);
ptr_path = (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path);
length = strlen (ptr_path) + 64;
if (SERVER(buffer))
length += strlen (SERVER(buffer)->name);
if (CHANNEL(buffer))
length += strlen (CHANNEL(buffer)->name);
buffer->log_filename = (char *) malloc (length);
if (!buffer->log_filename)
{
weechat_log_printf (_("Not enough memory to write log file for a buffer\n"));
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
return;
}
if (cfg_log_path[0] == '~')
{
strcpy (buffer->log_filename, ptr_home);
strcat (buffer->log_filename, cfg_log_path + 1);
}
else
strcpy (buffer->log_filename, cfg_log_path);
strcpy (buffer->log_filename, ptr_path);
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
if (buffer->log_filename[strlen (buffer->log_filename) - 1] != DIR_SEPARATOR_CHAR)
strcat (buffer->log_filename, DIR_SEPARATOR);

View File

@ -474,10 +474,12 @@ session_crash (FILE *file, char *message, ...)
session_last_read_pos,
session_last_read_length);
fprintf (stderr,
_("Please send ~/.weechat/%s, ~/.weechat/%s and "
_("Please send %s/%s, %s/%s and "
"above messages to WeeChat developers for support.\n"
"Be careful, private info may be in these files.\n"),
weechat_home,
WEECHAT_LOG_NAME,
weechat_home,
WEECHAT_SESSION_NAME);
exit (EXIT_FAILURE);
}

View File

@ -166,7 +166,7 @@ ascii_strncasecmp (char *string1, char *string2, int max)
}
/*
* weechat_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log)
* weechat_log_printf: displays a message in WeeChat log (<weechat_home>/weechat.log)
*/
void
@ -262,6 +262,59 @@ weechat_iconv (char *from_code, char *to_code, char *string)
return outbuf;
}
/*
* weechat_strreplace: replace a string by new one in a string
* note: returned value has to be free() after use
*/
char *
weechat_strreplace (char *string, char *search, char *replace)
{
char *pos, *new_string;
int length1, length2, length_new, count;
length1 = strlen (search);
length2 = strlen (replace);
/* count number of strings to replace */
count = 0;
pos = string;
while (pos && pos[0] && (pos = strstr (pos, search)))
{
count++;
pos += length1;
}
/* easy: no string to replace! */
if (count == 0)
return strdup (string);
/* compute needed memory for new string */
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
/* allocate new string */
new_string = (char *)malloc (length_new * sizeof (char));
if (!new_string)
return strdup (string);
/* replace all occurences */
new_string[0] = '\0';
while (string && string[0])
{
pos = strstr (string, search);
if (pos)
{
strncat (new_string, string, pos - string);
strcat (new_string, replace);
pos += length1;
}
else
strcat (new_string, string);
string = pos;
}
return new_string;
}
/*
* get_timeval_diff: calculates difference between two times (return in milliseconds)
*/
@ -300,6 +353,7 @@ weechat_display_usage (char *exec_name)
printf ("\n\n");
printf (_(" -a, --no-connect disable auto-connect to servers at startup\n"
" -c, --config display config file options\n"
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
" -f, --key-functions display WeeChat internal functions for keys\n"
" -h, --help this help\n"
" -i, --irc-commands display IRC commands\n"
@ -320,7 +374,7 @@ weechat_display_config_options ()
{
int i, j, k;
printf (_("WeeChat configuration options (~/.weechat/weechat.rc):\n\n"));
printf (_("WeeChat configuration options (<weechat_home>/weechat.rc):\n\n"));
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if (weechat_options[i])
@ -498,6 +552,7 @@ weechat_parse_args (int argc, char *argv[])
weechat_argv0 = strdup (argv[0]);
weechat_session = NULL;
weechat_home = NULL;
server_cmd_line = 0;
auto_connect = 1;
auto_load_plugins = 1;
@ -513,6 +568,19 @@ weechat_parse_args (int argc, char *argv[])
weechat_display_config_options ();
weechat_shutdown (EXIT_SUCCESS, 0);
}
else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--dir") == 0))
{
if (i + 1 < argc)
weechat_home = strdup (argv[++i]);
else
{
fprintf (stderr,
_("%s missing argument for --dir option\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
else if ((strcmp (argv[i], "-f") == 0)
|| (strcmp (argv[i], "--key-functions") == 0))
{
@ -634,44 +702,47 @@ weechat_create_home_dirs ()
{
char *ptr_home, *dir_name;
int dir_length;
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
/* create home directory "~/.weechat" ; error is fatal */
/* create home directory; error is fatal */
if (!weechat_create_dir (weechat_home))
{
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
WEECHAT_ERROR);
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_ERROR, weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (weechat_home) + 64;
dir_name = (char *) malloc (dir_length * sizeof (char));
/* create "~/.weechat/logs" */
/* create "<weechat_home>/logs" */
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR,
"logs");
if (!weechat_create_dir (dir_name))
{
fprintf (stderr, _("%s unable to create ~/.weechat/logs directory\n"),
WEECHAT_WARNING);
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir_name);
}
chmod (dir_name, 0700);
@ -716,8 +787,8 @@ weechat_init_log ()
snprintf (filename, filename_length, "%s/" WEECHAT_LOG_NAME, weechat_home);
if ((weechat_log_file = fopen (filename, "wt")) == NULL)
fprintf (stderr,
_("%s unable to create/append to log file (~/.weechat/%s)"),
WEECHAT_WARNING, WEECHAT_LOG_NAME);
_("%s unable to create/append to log file (%s/%s)"),
WEECHAT_WARNING, weechat_home, WEECHAT_LOG_NAME);
free (filename);
}
@ -921,7 +992,7 @@ weechat_dump (int crash)
}
/*
* weechat_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit
* weechat_sigsegv: SIGSEGV handler: save crash log to <weechat_home>/weechat.log and exit
*/
void
@ -933,7 +1004,7 @@ weechat_sigsegv ()
gui_end ();
fprintf (stderr, "\n");
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n");
fprintf (stderr, "*** Full crash dump was saved to ~/.weechat/weechat.log file\n");
fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file\n", weechat_home);
fprintf (stderr, "*** Please send this file to WeeChat developers.\n");
fprintf (stderr, "*** (be careful, private info may be in this file since\n");
fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");

View File

@ -108,8 +108,9 @@ extern gnutls_certificate_credentials gnutls_xcred;
extern int ascii_strcasecmp (char *, char *);
extern int ascii_strncasecmp (char *, char *, int);
extern void weechat_log_printf (char *, ...);
extern void weechat_dump (int);
extern char *weechat_iconv (char *, char *, char *);
extern char *weechat_strreplace (char *, char *, char *);
extern void weechat_dump (int);
extern long get_timeval_diff (struct timeval *, struct timeval *);
extern void weechat_shutdown (int, int);

View File

@ -633,9 +633,10 @@ t_config_option weechat_options_log[] =
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_log_plugin_msg, NULL, &config_change_noop },
{ "log_path", N_("path for log files"),
N_("path for WeeChat log files"),
N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
"%h/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
{ "log_timestamp", N_("timestamp for log"),
N_("timestamp for log (see man strftime for date/time specifiers)"),
OPTION_TYPE_STRING, 0, 0, 0,
@ -842,9 +843,10 @@ char *cfg_plugins_extension;
t_config_option weechat_options_plugins[] =
{ { "plugins_path", N_("path for searching plugins"),
N_("path for searching plugins"),
N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
"%h/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
{ "plugins_autoload", N_("list of plugins to load automatically"),
N_("comma separated list of plugins to load automatically at startup, "
"\"*\" means all plugins found "

View File

@ -1445,7 +1445,7 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_gui_buffer *buffer;
char *channel_name, *pos_args, *ptr_arg, *pos, buf[4096];
char *channel_name, *pos_args, *ptr_arg, *buf;
t_irc_channel *ptr_channel;
irc_find_context (server, channel, NULL, &buffer);
@ -1507,19 +1507,11 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
pos = strstr (ptr_arg, "%v");
if (pos)
{
pos[0] = '\0';
snprintf (buf, sizeof (buf), "%s%s%s",
ptr_arg, PACKAGE_VERSION, pos + 2);
pos[0] = '%';
}
else
snprintf (buf, sizeof (buf), "%s",
ptr_arg);
server_sendf (server, "PART %s :%s\r\n",
channel_name, buf);
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
@ -1643,7 +1635,7 @@ irc_cmd_send_quit (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_irc_server *ptr_server;
char *ptr_arg, *pos, buffer[4096];
char *ptr_arg, *buf;
/* make gcc happy */
(void) server;
@ -1659,18 +1651,11 @@ irc_cmd_send_quit (t_irc_server *server, t_irc_channel *channel,
{
if (ptr_arg)
{
pos = strstr (ptr_arg, "%v");
if (pos)
{
pos[0] = '\0';
snprintf (buffer, sizeof (buffer), "%s%s%s",
ptr_arg, PACKAGE_VERSION, pos + 2);
pos[0] = '%';
}
else
snprintf (buffer, sizeof (buffer), "%s",
ptr_arg);
server_sendf (ptr_server, "QUIT :%s\r\n", buffer);
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (ptr_server, "QUIT :%s\r\n",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (ptr_server, "QUIT\r\n");

View File

@ -716,7 +716,8 @@ int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
void plugin_auto_load ()
{
char *ptr_home, *dir_name, *list_plugins, *pos, *pos2;
char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
char *list_plugins, *pos, *pos2;
if (cfg_plugins_autoload && cfg_plugins_autoload[0])
{
@ -725,20 +726,20 @@ void plugin_auto_load ()
/* auto-load plugins in WeeChat home dir */
if (cfg_plugins_path && cfg_plugins_path[0])
{
if (cfg_plugins_path[0] == '~')
{
ptr_home = getenv ("HOME");
dir_name = (char *)malloc (strlen (cfg_plugins_path) + strlen (ptr_home) + 2);
if (dir_name)
{
strcpy (dir_name, ptr_home);
strcat (dir_name, cfg_plugins_path + 1);
plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file);
free (dir_name);
}
}
else
plugin_exec_on_files (NULL, cfg_plugins_path, &plugin_auto_load_file);
ptr_home = getenv ("HOME");
plugins_path = weechat_strreplace (cfg_plugins_path, "~", ptr_home);
plugins_path2 = weechat_strreplace ((plugins_path) ?
plugins_path : cfg_plugins_path,
"%h", weechat_home);
plugin_exec_on_files (NULL,
(plugins_path2) ?
plugins_path2 : ((plugins_path) ?
plugins_path : cfg_plugins_path),
&plugin_auto_load_file);
if (plugins_path)
free (plugins_path);
if (plugins_path2)
free (plugins_path2);
}
/* auto-load plugins in WeeChat global lib dir */

View File

@ -5,6 +5,8 @@ ChangeLog - 2006-01-24
Version 0.1.8 (under dev!):
* added new command line argument for setting WeeChat homedir (-d or --dir)
(patch from Gwenn)
* fixed bug with charset in infobar highlights
* fixed bug with buffer detection in plugins/scripts commands
* fixed bug with /history command

View File

@ -1,6 +1,17 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
* FlashCode, 2006-01-24 (draft)
Important release notes for 0.1.8 (draft):
- it is recommended for users of version 0.1.7 (or any older), to
replace values in setup file (~/.weechat/weechat.rc) :
- option: log_path: replace "~/.weechat/logs" by "%h/logs"
- option: plugins_path: replace "~/.weechat/plugins" by "%h/plugins"
"%h" is replaced by WeeChat home (default: ~/.weechat, may be overriden
by new command line arg --dir)
* FlashCode, 2006-01-14
WeeChat 0.1.7 released.

View File

@ -739,7 +739,7 @@
<entry>string</entry>
<entry>any string</entry>
<entry></entry>
<entry>Path for WeeChat log files</entry>
<entry>Path for WeeChat log files ('%h' will be replaced by WeeChat home, ~/.weechat by default)</entry>
</row>
<row>
<entry><option>log_timestamp</option></entry>
@ -977,7 +977,7 @@
<entry>string</entry>
<entry>any string</entry>
<entry></entry>
<entry>Path for searching plugins</entry>
<entry>Path for searching plugins ('%h' will be replaced by WeeChat home, ~/.weechat by default)</entry>
</row>
<row>
<entry><option>plugins_autoload</option></entry>

View File

@ -330,6 +330,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Display config help (list of options)
</entry>
</row>
<row>
<entry><literal>-d, --dir &lt;path&gt;</literal></entry>
<entry>
Set path as home for WeeChat (used for configuration files,
logs, user plugins and scripts). Default value is
"<literal>~/.weechat</literal>". Please note that directory
is created if not found by WeeChat.
</entry>
</row>
<row>
<entry><literal>-f, --key-functions</literal></entry>
<entry>
@ -3593,6 +3602,12 @@ Weechat.set_plugin_config ("my_var", "value")
patches
</para>
</listitem>
<listitem>
<para>
<emphasis>Gwenn</emphasis> -
patches
</para>
</listitem>
</itemizedlist>
</para>

View File

@ -738,8 +738,8 @@
<entry><option>log_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat</entry>
<entry>'%h/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>log_timestamp</option></entry>
@ -976,8 +976,8 @@
<entry><option>plugins_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/plugins'</entry>
<entry>Chemin de recherche des extensions</entry>
<entry>'%h/plugins'</entry>
<entry>Chemin de recherche des extensions ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>plugins_autoload</option></entry>

View File

@ -336,6 +336,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Afficher l'aide sur le fichier de config (liste des options)
</entry>
</row>
<row>
<entry><literal>-d, --dir &lt;répertoire&gt;</literal></entry>
<entry>
Définir le répertoire comme étant la base de WeeChat
(utilisé pour les fichiers de configuration, logs, extensions
et scripts de l'utilisateur). La valeur par défaut est
"<literal>~/.weechat</literal>". NB: le répertoire est créé
s'il n'est pas trouvé par WeeChat.
</entry>
</row>
<row>
<entry><literal>-f, --key-functions</literal></entry>
<entry>
@ -3654,6 +3664,12 @@ Weechat.set_plugin_config ("ma_variable", "valeur")
patchs
</para>
</listitem>
<listitem>
<para>
<emphasis>Gwenn</emphasis> -
patchs
</para>
</listitem>
</itemizedlist>
</para>

View File

@ -27,6 +27,10 @@ disable auto-connect to servers at startup
.br
display config file help (list of options)
.TP
.B \-d, \-\-dir <dir>
.br
set WeeChat home dir
.TP
.B \-f, \-\-key\-functions
.br
display internal functions for keys

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3142,7 +3142,7 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
t_irc_server *ptr_server;
int filename_length;
char *filename;
char *exec_args[5] = { NULL, "-a", "--session", NULL, NULL };
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--session", NULL, NULL };
/* make gcc happy */
(void) server;
@ -3196,7 +3196,8 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
}
exec_args[0] = strdup (weechat_argv0);
exec_args[3] = strdup (filename);
exec_args[3] = strdup (weechat_home);
exec_args[5] = strdup (filename);
/* unload plugins, save config, then upgrade */
#ifdef PLUGINS

View File

@ -54,7 +54,7 @@ fifo_create ()
if (cfg_irc_fifo_pipe)
{
/* build FIFO filename: "~/.weechat/weechat_fifo_" + process PID */
/* build FIFO filename: "<weechat_home>/weechat_fifo_" + process PID */
if (!weechat_fifo_filename)
{
filename_length = strlen (weechat_home) + 64;

View File

@ -107,29 +107,36 @@ void
log_start (t_gui_buffer *buffer)
{
int length;
char *ptr_home;
char *ptr_home, *log_path, *log_path2, *ptr_path;
ptr_home = getenv ("HOME");
length = strlen (cfg_log_path) +
((cfg_log_path[0] == '~') ? strlen (ptr_home) : 0) +
64;
log_path = weechat_strreplace (cfg_log_path, "~", ptr_home);
log_path2 = weechat_strreplace ((log_path) ?
log_path : cfg_log_path,
"%h", weechat_home);
ptr_path = (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path);
length = strlen (ptr_path) + 64;
if (SERVER(buffer))
length += strlen (SERVER(buffer)->name);
if (CHANNEL(buffer))
length += strlen (CHANNEL(buffer)->name);
buffer->log_filename = (char *) malloc (length);
if (!buffer->log_filename)
{
weechat_log_printf (_("Not enough memory to write log file for a buffer\n"));
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
return;
}
if (cfg_log_path[0] == '~')
{
strcpy (buffer->log_filename, ptr_home);
strcat (buffer->log_filename, cfg_log_path + 1);
}
else
strcpy (buffer->log_filename, cfg_log_path);
strcpy (buffer->log_filename, ptr_path);
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
if (buffer->log_filename[strlen (buffer->log_filename) - 1] != DIR_SEPARATOR_CHAR)
strcat (buffer->log_filename, DIR_SEPARATOR);

View File

@ -474,10 +474,12 @@ session_crash (FILE *file, char *message, ...)
session_last_read_pos,
session_last_read_length);
fprintf (stderr,
_("Please send ~/.weechat/%s, ~/.weechat/%s and "
_("Please send %s/%s, %s/%s and "
"above messages to WeeChat developers for support.\n"
"Be careful, private info may be in these files.\n"),
weechat_home,
WEECHAT_LOG_NAME,
weechat_home,
WEECHAT_SESSION_NAME);
exit (EXIT_FAILURE);
}

View File

@ -166,7 +166,7 @@ ascii_strncasecmp (char *string1, char *string2, int max)
}
/*
* weechat_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log)
* weechat_log_printf: displays a message in WeeChat log (<weechat_home>/weechat.log)
*/
void
@ -262,6 +262,59 @@ weechat_iconv (char *from_code, char *to_code, char *string)
return outbuf;
}
/*
* weechat_strreplace: replace a string by new one in a string
* note: returned value has to be free() after use
*/
char *
weechat_strreplace (char *string, char *search, char *replace)
{
char *pos, *new_string;
int length1, length2, length_new, count;
length1 = strlen (search);
length2 = strlen (replace);
/* count number of strings to replace */
count = 0;
pos = string;
while (pos && pos[0] && (pos = strstr (pos, search)))
{
count++;
pos += length1;
}
/* easy: no string to replace! */
if (count == 0)
return strdup (string);
/* compute needed memory for new string */
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
/* allocate new string */
new_string = (char *)malloc (length_new * sizeof (char));
if (!new_string)
return strdup (string);
/* replace all occurences */
new_string[0] = '\0';
while (string && string[0])
{
pos = strstr (string, search);
if (pos)
{
strncat (new_string, string, pos - string);
strcat (new_string, replace);
pos += length1;
}
else
strcat (new_string, string);
string = pos;
}
return new_string;
}
/*
* get_timeval_diff: calculates difference between two times (return in milliseconds)
*/
@ -300,6 +353,7 @@ weechat_display_usage (char *exec_name)
printf ("\n\n");
printf (_(" -a, --no-connect disable auto-connect to servers at startup\n"
" -c, --config display config file options\n"
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
" -f, --key-functions display WeeChat internal functions for keys\n"
" -h, --help this help\n"
" -i, --irc-commands display IRC commands\n"
@ -320,7 +374,7 @@ weechat_display_config_options ()
{
int i, j, k;
printf (_("WeeChat configuration options (~/.weechat/weechat.rc):\n\n"));
printf (_("WeeChat configuration options (<weechat_home>/weechat.rc):\n\n"));
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if (weechat_options[i])
@ -498,6 +552,7 @@ weechat_parse_args (int argc, char *argv[])
weechat_argv0 = strdup (argv[0]);
weechat_session = NULL;
weechat_home = NULL;
server_cmd_line = 0;
auto_connect = 1;
auto_load_plugins = 1;
@ -513,6 +568,19 @@ weechat_parse_args (int argc, char *argv[])
weechat_display_config_options ();
weechat_shutdown (EXIT_SUCCESS, 0);
}
else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--dir") == 0))
{
if (i + 1 < argc)
weechat_home = strdup (argv[++i]);
else
{
fprintf (stderr,
_("%s missing argument for --dir option\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
else if ((strcmp (argv[i], "-f") == 0)
|| (strcmp (argv[i], "--key-functions") == 0))
{
@ -634,44 +702,47 @@ weechat_create_home_dirs ()
{
char *ptr_home, *dir_name;
int dir_length;
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
/* create home directory "~/.weechat" ; error is fatal */
/* create home directory; error is fatal */
if (!weechat_create_dir (weechat_home))
{
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
WEECHAT_ERROR);
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_ERROR, weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (weechat_home) + 64;
dir_name = (char *) malloc (dir_length * sizeof (char));
/* create "~/.weechat/logs" */
/* create "<weechat_home>/logs" */
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR,
"logs");
if (!weechat_create_dir (dir_name))
{
fprintf (stderr, _("%s unable to create ~/.weechat/logs directory\n"),
WEECHAT_WARNING);
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir_name);
}
chmod (dir_name, 0700);
@ -716,8 +787,8 @@ weechat_init_log ()
snprintf (filename, filename_length, "%s/" WEECHAT_LOG_NAME, weechat_home);
if ((weechat_log_file = fopen (filename, "wt")) == NULL)
fprintf (stderr,
_("%s unable to create/append to log file (~/.weechat/%s)"),
WEECHAT_WARNING, WEECHAT_LOG_NAME);
_("%s unable to create/append to log file (%s/%s)"),
WEECHAT_WARNING, weechat_home, WEECHAT_LOG_NAME);
free (filename);
}
@ -921,7 +992,7 @@ weechat_dump (int crash)
}
/*
* weechat_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit
* weechat_sigsegv: SIGSEGV handler: save crash log to <weechat_home>/weechat.log and exit
*/
void
@ -933,7 +1004,7 @@ weechat_sigsegv ()
gui_end ();
fprintf (stderr, "\n");
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n");
fprintf (stderr, "*** Full crash dump was saved to ~/.weechat/weechat.log file\n");
fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file\n", weechat_home);
fprintf (stderr, "*** Please send this file to WeeChat developers.\n");
fprintf (stderr, "*** (be careful, private info may be in this file since\n");
fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");

View File

@ -108,8 +108,9 @@ extern gnutls_certificate_credentials gnutls_xcred;
extern int ascii_strcasecmp (char *, char *);
extern int ascii_strncasecmp (char *, char *, int);
extern void weechat_log_printf (char *, ...);
extern void weechat_dump (int);
extern char *weechat_iconv (char *, char *, char *);
extern char *weechat_strreplace (char *, char *, char *);
extern void weechat_dump (int);
extern long get_timeval_diff (struct timeval *, struct timeval *);
extern void weechat_shutdown (int, int);

View File

@ -633,9 +633,10 @@ t_config_option weechat_options_log[] =
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_log_plugin_msg, NULL, &config_change_noop },
{ "log_path", N_("path for log files"),
N_("path for WeeChat log files"),
N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
"%h/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
{ "log_timestamp", N_("timestamp for log"),
N_("timestamp for log (see man strftime for date/time specifiers)"),
OPTION_TYPE_STRING, 0, 0, 0,
@ -842,9 +843,10 @@ char *cfg_plugins_extension;
t_config_option weechat_options_plugins[] =
{ { "plugins_path", N_("path for searching plugins"),
N_("path for searching plugins"),
N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
"%h/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
{ "plugins_autoload", N_("list of plugins to load automatically"),
N_("comma separated list of plugins to load automatically at startup, "
"\"*\" means all plugins found "

View File

@ -1445,7 +1445,7 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_gui_buffer *buffer;
char *channel_name, *pos_args, *ptr_arg, *pos, buf[4096];
char *channel_name, *pos_args, *ptr_arg, *buf;
t_irc_channel *ptr_channel;
irc_find_context (server, channel, NULL, &buffer);
@ -1507,19 +1507,11 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
pos = strstr (ptr_arg, "%v");
if (pos)
{
pos[0] = '\0';
snprintf (buf, sizeof (buf), "%s%s%s",
ptr_arg, PACKAGE_VERSION, pos + 2);
pos[0] = '%';
}
else
snprintf (buf, sizeof (buf), "%s",
ptr_arg);
server_sendf (server, "PART %s :%s\r\n",
channel_name, buf);
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
@ -1643,7 +1635,7 @@ irc_cmd_send_quit (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_irc_server *ptr_server;
char *ptr_arg, *pos, buffer[4096];
char *ptr_arg, *buf;
/* make gcc happy */
(void) server;
@ -1659,18 +1651,11 @@ irc_cmd_send_quit (t_irc_server *server, t_irc_channel *channel,
{
if (ptr_arg)
{
pos = strstr (ptr_arg, "%v");
if (pos)
{
pos[0] = '\0';
snprintf (buffer, sizeof (buffer), "%s%s%s",
ptr_arg, PACKAGE_VERSION, pos + 2);
pos[0] = '%';
}
else
snprintf (buffer, sizeof (buffer), "%s",
ptr_arg);
server_sendf (ptr_server, "QUIT :%s\r\n", buffer);
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (ptr_server, "QUIT :%s\r\n",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (ptr_server, "QUIT\r\n");

View File

@ -716,7 +716,8 @@ int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
void plugin_auto_load ()
{
char *ptr_home, *dir_name, *list_plugins, *pos, *pos2;
char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
char *list_plugins, *pos, *pos2;
if (cfg_plugins_autoload && cfg_plugins_autoload[0])
{
@ -725,20 +726,20 @@ void plugin_auto_load ()
/* auto-load plugins in WeeChat home dir */
if (cfg_plugins_path && cfg_plugins_path[0])
{
if (cfg_plugins_path[0] == '~')
{
ptr_home = getenv ("HOME");
dir_name = (char *)malloc (strlen (cfg_plugins_path) + strlen (ptr_home) + 2);
if (dir_name)
{
strcpy (dir_name, ptr_home);
strcat (dir_name, cfg_plugins_path + 1);
plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file);
free (dir_name);
}
}
else
plugin_exec_on_files (NULL, cfg_plugins_path, &plugin_auto_load_file);
ptr_home = getenv ("HOME");
plugins_path = weechat_strreplace (cfg_plugins_path, "~", ptr_home);
plugins_path2 = weechat_strreplace ((plugins_path) ?
plugins_path : cfg_plugins_path,
"%h", weechat_home);
plugin_exec_on_files (NULL,
(plugins_path2) ?
plugins_path2 : ((plugins_path) ?
plugins_path : cfg_plugins_path),
&plugin_auto_load_file);
if (plugins_path)
free (plugins_path);
if (plugins_path2)
free (plugins_path2);
}
/* auto-load plugins in WeeChat global lib dir */