1998-02-27 07:54:42 +03:00
|
|
|
/* Extension dependent execution.
|
|
|
|
Copyright (C) 1994, 1995 The Free Software Foundation
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
Written by: 1995 Jakub Jelinek
|
|
|
|
1994 Miguel de Icaza
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
This program 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
This program 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 this program; if not, write to the Free Software
|
2000-08-23 02:50:00 +04:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
1999-01-19 05:34:37 +03:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
#include "global.h"
|
2001-09-03 09:07:40 +04:00
|
|
|
#include "tty.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "user.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "dialog.h"
|
|
|
|
#include "ext.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "../vfs/vfs.h"
|
|
|
|
|
|
|
|
#include "cons.saver.h"
|
|
|
|
#include "layout.h"
|
|
|
|
|
|
|
|
/* If set, we execute the file command to check the file type */
|
|
|
|
int use_file_to_check_type = 1;
|
|
|
|
|
|
|
|
/* This variable points to a copy of the mc.ext file in memory
|
1999-08-27 09:01:08 +04:00
|
|
|
* With this we avoid loading/parsing the file each time we
|
|
|
|
* need it
|
1998-02-27 07:54:42 +03:00
|
|
|
*/
|
|
|
|
static char *data = NULL;
|
|
|
|
|
|
|
|
void
|
|
|
|
flush_extension_file (void)
|
|
|
|
{
|
|
|
|
if (data){
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (data);
|
1998-02-27 07:54:42 +03:00
|
|
|
data = NULL;
|
|
|
|
}
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-03-19 05:57:01 +03:00
|
|
|
typedef char *(*quote_func_t)(const char *name, int i);
|
|
|
|
|
2002-08-10 04:14:01 +04:00
|
|
|
static void
|
2002-08-10 04:37:55 +04:00
|
|
|
exec_extension (const char *filename, const char *data, int *move_dir, int start_line)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *file_name;
|
1998-04-23 23:31:32 +04:00
|
|
|
int cmd_file_fd;
|
1998-02-27 07:54:42 +03:00
|
|
|
FILE *cmd_file;
|
|
|
|
int expand_prefix_found = 0;
|
1998-04-23 23:31:32 +04:00
|
|
|
int parameter_found = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
char prompt [80];
|
1998-04-23 23:31:32 +04:00
|
|
|
int run_view = 0;
|
|
|
|
int def_hex_mode = default_hex_mode, changed_hex_mode = 0;
|
|
|
|
int def_nroff_flag = default_nroff_flag, changed_nroff_flag = 0;
|
|
|
|
int written_nonspace = 0;
|
|
|
|
int is_cd = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
char buffer [1024];
|
|
|
|
char *p = 0;
|
|
|
|
char *localcopy = NULL;
|
1998-04-23 23:31:32 +04:00
|
|
|
int do_local_copy;
|
1998-02-27 07:54:42 +03:00
|
|
|
time_t localmtime = 0;
|
|
|
|
struct stat mystat;
|
1998-03-19 05:57:01 +03:00
|
|
|
quote_func_t quote_func = name_quote;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
g_return_if_fail (filename != NULL);
|
|
|
|
g_return_if_fail (data != NULL);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Avoid making a local copy if we are doing a cd */
|
|
|
|
if (!vfs_file_is_local(filename))
|
|
|
|
do_local_copy = 1;
|
|
|
|
else
|
|
|
|
do_local_copy = 0;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
2001-07-18 07:06:57 +04:00
|
|
|
/*
|
|
|
|
* All commands should be run in /bin/sh regardless of user shell.
|
|
|
|
* To do that, create temporary shell script and run it.
|
|
|
|
* Sometimes it's not needed (e.g. for %cd and %view commands),
|
|
|
|
* but it's easier to create it anyway.
|
|
|
|
*/
|
2001-05-21 20:21:07 +04:00
|
|
|
cmd_file_fd = mc_mkstemps(&file_name, "mcext", SCRIPT_SUFFIX);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-05-21 20:21:07 +04:00
|
|
|
if (cmd_file_fd == -1){
|
2001-08-14 04:55:34 +04:00
|
|
|
message (1, MSG_ERROR, _(" Cannot create temporary command file \n %s "),
|
1998-02-27 07:54:42 +03:00
|
|
|
unix_error_string (errno));
|
|
|
|
return;
|
|
|
|
}
|
1998-04-23 23:31:32 +04:00
|
|
|
cmd_file = fdopen (cmd_file_fd, "w");
|
2002-02-21 17:37:51 +03:00
|
|
|
fputs ("#! /bin/sh\n", cmd_file);
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
prompt [0] = 0;
|
|
|
|
for (;*data && *data != '\n'; data++){
|
|
|
|
if (parameter_found){
|
|
|
|
if (*data == '}'){
|
|
|
|
char *parameter;
|
|
|
|
parameter_found = 0;
|
1998-03-25 08:16:00 +03:00
|
|
|
parameter = input_dialog (_(" Parameter "), prompt, "");
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!parameter){
|
|
|
|
/* User canceled */
|
|
|
|
fclose (cmd_file);
|
|
|
|
unlink (file_name);
|
|
|
|
if (localcopy) {
|
|
|
|
mc_ungetlocalcopy (filename, localcopy, 0);
|
|
|
|
}
|
2001-05-22 11:10:43 +04:00
|
|
|
g_free (file_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
fputs (parameter, cmd_file);
|
|
|
|
written_nonspace = 1;
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (parameter);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
|
|
|
int len = strlen (prompt);
|
|
|
|
|
|
|
|
if (len < sizeof (prompt) - 1){
|
|
|
|
prompt [len] = *data;
|
|
|
|
prompt [len+1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (expand_prefix_found){
|
|
|
|
expand_prefix_found = 0;
|
|
|
|
if (*data == '{')
|
|
|
|
parameter_found = 1;
|
|
|
|
else {
|
|
|
|
int i = check_format_view (data);
|
|
|
|
char *v;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (i){
|
|
|
|
data += i - 1;
|
|
|
|
run_view = 1;
|
|
|
|
} else if ((i = check_format_cd (data)) > 0) {
|
|
|
|
is_cd = 1;
|
|
|
|
quote_func = fake_name_quote;
|
|
|
|
do_local_copy = 0;
|
|
|
|
p = buffer;
|
|
|
|
data += i - 1;
|
|
|
|
} else if ((i = check_format_var (data, &v)) > 0 && v){
|
|
|
|
fputs (v, cmd_file);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (v);
|
1998-02-27 07:54:42 +03:00
|
|
|
data += i;
|
|
|
|
} else {
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
if (*data == 'f'){
|
|
|
|
if (do_local_copy){
|
|
|
|
localcopy = mc_getlocalcopy (filename);
|
|
|
|
if (localcopy == NULL) {
|
|
|
|
fclose(cmd_file);
|
|
|
|
unlink(file_name);
|
2001-05-22 11:10:43 +04:00
|
|
|
g_free (file_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
mc_stat (localcopy, &mystat);
|
|
|
|
localmtime = mystat.st_mtime;
|
|
|
|
text = (*quote_func) (localcopy, 0);
|
|
|
|
} else {
|
|
|
|
text = (*quote_func) (filename, 0);
|
|
|
|
}
|
|
|
|
} else
|
2001-07-24 02:50:54 +04:00
|
|
|
text = expand_format (NULL, *data, !is_cd);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!is_cd)
|
|
|
|
fputs (text, cmd_file);
|
|
|
|
else {
|
|
|
|
strcpy (p, text);
|
|
|
|
p = strchr (p, 0);
|
|
|
|
}
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (text);
|
1998-02-27 07:54:42 +03:00
|
|
|
written_nonspace = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*data == '%')
|
|
|
|
expand_prefix_found = 1;
|
|
|
|
else {
|
|
|
|
if (*data != ' ' && *data != '\t')
|
|
|
|
written_nonspace = 1;
|
|
|
|
if (is_cd)
|
|
|
|
*(p++) = *data;
|
|
|
|
else
|
|
|
|
fputc (*data, cmd_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* for */
|
2001-07-18 07:06:57 +04:00
|
|
|
|
|
|
|
/* Make sure that the file removes itself when it finishes */
|
|
|
|
fprintf (cmd_file, "\n/bin/rm -f %s\n", file_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
fclose (cmd_file);
|
2001-07-07 03:06:45 +04:00
|
|
|
|
|
|
|
if ((run_view && !written_nonspace) || is_cd) {
|
|
|
|
unlink (file_name);
|
|
|
|
g_free (file_name);
|
|
|
|
file_name = NULL;
|
|
|
|
} else {
|
|
|
|
chmod (file_name, S_IRWXU);
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (run_view){
|
|
|
|
altered_hex_mode = 0;
|
|
|
|
altered_nroff_flag = 0;
|
|
|
|
if (def_hex_mode != default_hex_mode)
|
|
|
|
changed_hex_mode = 1;
|
|
|
|
if (def_nroff_flag != default_nroff_flag)
|
|
|
|
changed_nroff_flag = 1;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* If we've written whitespace only, then just load filename
|
|
|
|
* into view
|
|
|
|
*/
|
1999-08-27 09:01:08 +04:00
|
|
|
if (written_nonspace)
|
1998-02-27 07:54:42 +03:00
|
|
|
view (file_name, filename, move_dir, start_line);
|
|
|
|
else
|
|
|
|
view (0, filename, move_dir, start_line);
|
|
|
|
if (changed_hex_mode && !altered_hex_mode)
|
|
|
|
default_hex_mode = def_hex_mode;
|
|
|
|
if (changed_nroff_flag && !altered_nroff_flag)
|
|
|
|
default_nroff_flag = def_nroff_flag;
|
|
|
|
repaint_screen ();
|
|
|
|
} else if (is_cd) {
|
|
|
|
char *q;
|
|
|
|
*p = 0;
|
|
|
|
p = buffer;
|
2002-07-31 04:28:07 +04:00
|
|
|
/* while (*p == ' ' && *p == '\t')
|
|
|
|
* p++;
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Search last non-space character. Start search at the end in order
|
|
|
|
not to short filenames containing spaces. */
|
|
|
|
q = p + strlen (p) - 1;
|
|
|
|
while (q >= p && (*q == ' ' || *q == '\t'))
|
|
|
|
q--;
|
|
|
|
q[1] = 0;
|
|
|
|
do_cd (p, cd_parse_command);
|
|
|
|
} else {
|
2002-08-20 03:41:21 +04:00
|
|
|
shell_execute (file_name, EXECUTE_INTERNAL);
|
2001-09-16 04:53:43 +04:00
|
|
|
if (console_flag) {
|
1998-04-23 23:31:32 +04:00
|
|
|
handle_console (CONSOLE_SAVE);
|
2001-09-16 04:53:43 +04:00
|
|
|
if (output_lines && keybar_visible) {
|
1998-04-23 23:31:32 +04:00
|
|
|
show_console_contents (output_start_y,
|
1998-02-27 07:54:42 +03:00
|
|
|
LINES-keybar_visible-output_lines-1,
|
|
|
|
LINES-keybar_visible-1);
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-04-23 23:31:32 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
2001-07-07 03:06:45 +04:00
|
|
|
if (file_name) {
|
|
|
|
g_free (file_name);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
if (localcopy) {
|
|
|
|
mc_stat (localcopy, &mystat);
|
|
|
|
mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FILE_L
|
|
|
|
# define FILE_CMD "file -L "
|
|
|
|
#else
|
|
|
|
# define FILE_CMD "file "
|
|
|
|
#endif
|
|
|
|
|
2002-08-10 04:37:55 +04:00
|
|
|
/* The second argument is action, i.e. Open, View or Edit
|
1998-02-27 07:54:42 +03:00
|
|
|
*
|
|
|
|
* This function returns:
|
|
|
|
*
|
2002-08-10 04:37:55 +04:00
|
|
|
* 1 if it ran some command or 0 otherwise.
|
1998-02-27 07:54:42 +03:00
|
|
|
*
|
|
|
|
* If action == "View" then a parameter is checked in the form of "View:%d",
|
|
|
|
* if the value for %d exists, then the viewer is started up at that line number.
|
|
|
|
*/
|
2002-08-10 04:37:55 +04:00
|
|
|
int
|
|
|
|
regex_command (char *filename, char *action, int *move_dir)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *p, *q, *r, c;
|
|
|
|
int file_len = strlen (filename);
|
|
|
|
int found = 0;
|
|
|
|
char content_string [2048];
|
|
|
|
int content_shift = 0;
|
2002-08-10 04:37:55 +04:00
|
|
|
int ret = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
int old_patterns;
|
|
|
|
struct stat mystat;
|
|
|
|
int asked_file;
|
|
|
|
int view_at_line_number;
|
|
|
|
char *include_target;
|
|
|
|
int include_target_len;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef FILE_STDIN
|
|
|
|
int file_supports_stdin = 1;
|
|
|
|
#else
|
|
|
|
int file_supports_stdin = 0;
|
1999-08-27 09:01:08 +04:00
|
|
|
#endif
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Check for the special View:%d parameter */
|
2002-08-10 04:37:55 +04:00
|
|
|
if (strncmp (action, "View:", 5) == 0){
|
1998-02-27 07:54:42 +03:00
|
|
|
view_at_line_number = atoi (action + 5);
|
|
|
|
action [4] = 0;
|
|
|
|
} else {
|
|
|
|
view_at_line_number = 0;
|
|
|
|
}
|
|
|
|
/* Have we asked file for the file contents? */
|
|
|
|
asked_file = 0;
|
|
|
|
|
|
|
|
if (data == NULL) {
|
2000-05-25 20:21:42 +04:00
|
|
|
char *extension_file;
|
|
|
|
int mc_user_ext = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
int home_error = 0;
|
|
|
|
|
2000-05-25 20:21:42 +04:00
|
|
|
extension_file = concat_dir_and_file (home_dir, MC_USER_EXT);
|
|
|
|
if (!exist_file (extension_file)) {
|
|
|
|
g_free (extension_file);
|
1998-02-27 07:54:42 +03:00
|
|
|
check_stock_mc_ext:
|
|
|
|
extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
|
2000-05-25 20:21:42 +04:00
|
|
|
mc_user_ext = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2000-05-25 20:21:42 +04:00
|
|
|
data = load_file (extension_file);
|
|
|
|
g_free (extension_file);
|
|
|
|
if (data == NULL)
|
|
|
|
return 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!strstr (data, "default/")) {
|
|
|
|
if (!strstr (data, "regex/") && !strstr (data, "shell/") &&
|
|
|
|
!strstr (data, "type/")) {
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (data);
|
1998-02-27 07:54:42 +03:00
|
|
|
data = NULL;
|
2000-05-25 20:21:42 +04:00
|
|
|
if (mc_user_ext) {
|
1998-02-27 07:54:42 +03:00
|
|
|
home_error = 1;
|
1999-08-27 09:01:08 +04:00
|
|
|
goto check_stock_mc_ext;
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
|
|
|
char *msg;
|
|
|
|
char *msg2;
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
msg = g_strconcat (" ", mc_home, MC_LIB_EXT, _(" file error"), NULL);
|
1999-08-27 09:01:08 +04:00
|
|
|
msg2 = g_strconcat (_("Format of the "),
|
|
|
|
mc_home,
|
2000-05-25 20:21:42 +04:00
|
|
|
_("mc.ext file has changed\n\
|
1998-02-27 07:54:42 +03:00
|
|
|
with version 3.0. It seems that installation\n\
|
|
|
|
failed. Please fetch a fresh new copy from the\n\
|
2001-05-18 22:44:51 +04:00
|
|
|
Midnight Commander package."), NULL);
|
1998-02-27 07:54:42 +03:00
|
|
|
message (1, msg, msg2);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (msg);
|
|
|
|
g_free (msg2);
|
1998-02-27 07:54:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (home_error) {
|
|
|
|
char *msg;
|
|
|
|
char *msg2;
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
msg = g_strconcat (" ~/", MC_USER_EXT, _(" file error "), NULL);
|
|
|
|
msg2 = g_strconcat (_("Format of the ~/"), MC_USER_EXT, _(" file has changed\n\
|
1998-02-27 07:54:42 +03:00
|
|
|
with version 3.0. You may want either to\n\
|
1998-03-25 08:16:00 +03:00
|
|
|
copy it from "), mc_home, _("mc.ext or use that\n\
|
1998-02-27 07:54:42 +03:00
|
|
|
file as an example of how to write it.\n\
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
"), mc_home, _("mc.ext will be used for this moment."), NULL);
|
1998-02-27 07:54:42 +03:00
|
|
|
message (1, msg, msg2);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (msg);
|
|
|
|
g_free (msg2);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mc_stat (filename, &mystat);
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
old_patterns = easy_patterns;
|
|
|
|
easy_patterns = 0; /* Real regular expressions are needed :) */
|
|
|
|
include_target = NULL;
|
2001-06-15 03:28:54 +04:00
|
|
|
include_target_len = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
for (p = data; *p; p++) {
|
|
|
|
for (q = p; *q == ' ' || *q == '\t'; q++)
|
|
|
|
;
|
|
|
|
if (*q == '\n' || !*q)
|
|
|
|
p = q; /* empty line */
|
|
|
|
if (*p == '#') /* comment */
|
|
|
|
while (*p && *p != '\n')
|
|
|
|
p++;
|
|
|
|
if (*p == '\n')
|
|
|
|
continue;
|
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
if (p == q) { /* i.e. starts in the first column, should be
|
|
|
|
* keyword/descNL
|
|
|
|
*/
|
|
|
|
found = 0;
|
1999-08-27 09:01:08 +04:00
|
|
|
q = strchr (p, '\n');
|
1998-02-27 07:54:42 +03:00
|
|
|
if (q == NULL)
|
|
|
|
q = strchr (p, 0);
|
|
|
|
c = *q;
|
|
|
|
*q = 0;
|
|
|
|
if (include_target){
|
|
|
|
if ((strncmp (p, "include/", 8) == 0) &&
|
|
|
|
(strncmp (p+8, include_target, include_target_len) == 0))
|
|
|
|
found = 1;
|
|
|
|
} else if (!strncmp (p, "regex/", 6)) {
|
|
|
|
p += 6;
|
|
|
|
/* Do not transform shell patterns, you can use shell/ for
|
|
|
|
* that
|
|
|
|
*/
|
|
|
|
if (regexp_match (p, filename, match_normal))
|
|
|
|
found = 1;
|
|
|
|
} else if (!strncmp (p, "directory/", 10)) {
|
|
|
|
if (S_ISDIR (mystat.st_mode) && regexp_match (p+10, filename, match_normal))
|
|
|
|
found = 1;
|
|
|
|
} else if (!strncmp (p, "shell/", 6)) {
|
|
|
|
p += 6;
|
2002-07-31 04:28:07 +04:00
|
|
|
if (*p == '.' && file_len >= (q - p)) {
|
|
|
|
if (!strncmp (p, filename + file_len - (q - p),
|
|
|
|
q - p))
|
1998-02-27 07:54:42 +03:00
|
|
|
found = 1;
|
|
|
|
} else {
|
|
|
|
if (q - p == file_len && !strncmp (p, filename, q - p))
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
} else if (!strncmp (p, "type/", 5)) {
|
|
|
|
int islocal = vfs_file_is_local (filename);
|
|
|
|
p += 5;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (islocal || file_supports_stdin) {
|
|
|
|
char *pp;
|
|
|
|
int hasread = use_file_to_check_type;
|
|
|
|
|
|
|
|
if (asked_file || !use_file_to_check_type)
|
|
|
|
goto match_file_output;
|
|
|
|
|
|
|
|
hasread = 0;
|
|
|
|
if (islocal) {
|
|
|
|
char *tmp = name_quote (filename, 0);
|
|
|
|
char *command =
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_strconcat (FILE_CMD, tmp, NULL);
|
1998-02-27 07:54:42 +03:00
|
|
|
FILE *f = popen (command, "r");
|
1999-08-27 09:01:08 +04:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (tmp);
|
|
|
|
g_free (command);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (f != NULL) {
|
1999-08-27 09:01:08 +04:00
|
|
|
hasread = (fgets (content_string, 2047, f)
|
1998-02-27 07:54:42 +03:00
|
|
|
!= NULL);
|
|
|
|
if (!hasread)
|
|
|
|
content_string [0] = 0;
|
|
|
|
pclose (f);
|
|
|
|
#ifdef SCO_FLAVOR
|
1999-08-27 09:01:08 +04:00
|
|
|
/*
|
|
|
|
** SCO 3.2 does has a buggy pclose(), so
|
1998-02-27 07:54:42 +03:00
|
|
|
** <command> become zombie (alex)
|
|
|
|
*/
|
|
|
|
waitpid(-1,NULL,WNOHANG);
|
|
|
|
#endif /* SCO_FLAVOR */
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
#ifdef _OS_NT
|
|
|
|
message (1, " Win32 ", " Unimplemented file prediction ");
|
|
|
|
#else
|
|
|
|
int pipehandle, remotehandle;
|
|
|
|
pid_t p;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
remotehandle = mc_open (filename, O_RDONLY);
|
|
|
|
if (remotehandle != -1) {
|
|
|
|
/* 8192 is HOWMANY hardcoded value in the file-3.14
|
|
|
|
* sources. Tell me if any other file uses larger
|
1999-08-27 09:01:08 +04:00
|
|
|
* chunk from beginning
|
1998-02-27 07:54:42 +03:00
|
|
|
*/
|
|
|
|
pipehandle = mc_doublepopen
|
|
|
|
(remotehandle, 8192, &p,"file", "file", "-", NULL);
|
|
|
|
if (pipehandle != -1) {
|
|
|
|
int i;
|
1999-08-27 09:01:08 +04:00
|
|
|
while ((i = read (pipehandle, content_string
|
1998-02-27 07:54:42 +03:00
|
|
|
+ hasread, 2047 - hasread)) > 0)
|
|
|
|
hasread += i;
|
|
|
|
mc_doublepclose (pipehandle, p);
|
|
|
|
content_string [hasread] = 0;
|
|
|
|
}
|
|
|
|
mc_close (remotehandle);
|
|
|
|
}
|
|
|
|
#endif /* _OS_NT */
|
|
|
|
}
|
|
|
|
asked_file = 1;
|
|
|
|
match_file_output:
|
|
|
|
if (hasread) {
|
|
|
|
if ((pp = strchr (content_string, '\n')) != 0)
|
|
|
|
*pp = 0;
|
1999-08-27 09:01:08 +04:00
|
|
|
if (islocal && !strncmp (content_string,
|
1998-02-27 07:54:42 +03:00
|
|
|
filename, file_len)) {
|
|
|
|
content_shift = file_len;
|
|
|
|
if (content_string [content_shift] == ':')
|
1999-08-27 09:01:08 +04:00
|
|
|
for (content_shift++;
|
|
|
|
content_string [content_shift] == ' ';
|
1998-02-27 07:54:42 +03:00
|
|
|
content_shift++);
|
1999-08-27 09:01:08 +04:00
|
|
|
} else if (!islocal
|
|
|
|
&& !strncmp (content_string,
|
1998-02-27 07:54:42 +03:00
|
|
|
"standard input:", 15)) {
|
|
|
|
for (content_shift = 15;
|
|
|
|
content_string [content_shift] == ' ';
|
|
|
|
content_shift++);
|
|
|
|
}
|
1999-08-27 09:01:08 +04:00
|
|
|
if (content_string &&
|
|
|
|
regexp_match (p, content_string +
|
1998-02-27 07:54:42 +03:00
|
|
|
content_shift, match_normal)){
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!strncmp (p, "default/", 8)) {
|
|
|
|
p += 8;
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
*q = c;
|
|
|
|
p = q;
|
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
} else { /* List of actions */
|
|
|
|
p = q;
|
|
|
|
q = strchr (p, '\n');
|
|
|
|
if (q == NULL)
|
|
|
|
q = strchr (p, 0);
|
|
|
|
if (found) {
|
|
|
|
r = strchr (p, '=');
|
|
|
|
if (r != NULL) {
|
|
|
|
c = *r;
|
|
|
|
*r = 0;
|
|
|
|
if (strcmp (p, "Include") == 0){
|
|
|
|
char *t;
|
|
|
|
|
|
|
|
include_target = p + 8;
|
|
|
|
t = strchr (include_target, '\n');
|
|
|
|
if (t) *t = 0;
|
|
|
|
include_target_len = strlen (include_target);
|
|
|
|
if (t) *t = '\n';
|
|
|
|
|
|
|
|
*r = c;
|
|
|
|
p = q;
|
|
|
|
found = 0;
|
1999-08-27 09:01:08 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
}
|
2002-08-10 04:37:55 +04:00
|
|
|
if (!strcmp (action, p)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
*r = c;
|
|
|
|
for (p = r + 1; *p == ' ' || *p == '\t'; p++)
|
|
|
|
;
|
|
|
|
|
|
|
|
/* Empty commands just stop searching
|
|
|
|
* through, they don't do anything
|
|
|
|
*
|
|
|
|
* We need to copy the filename because exec_extension
|
|
|
|
* may end up invoking update_panels thus making the
|
|
|
|
* filename parameter invalid (ie, most of the time,
|
|
|
|
* we get filename as a pointer from cpanel->dir).
|
|
|
|
*/
|
1999-08-27 09:01:08 +04:00
|
|
|
if (p < q) {
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
char *filename_copy = g_strdup (filename);
|
1999-08-27 09:01:08 +04:00
|
|
|
|
2002-08-10 04:37:55 +04:00
|
|
|
exec_extension (filename_copy, r + 1, move_dir, view_at_line_number);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (filename_copy);
|
1999-08-27 09:01:08 +04:00
|
|
|
|
2002-08-10 04:37:55 +04:00
|
|
|
ret = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
*r = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p = q;
|
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
easy_patterns = old_patterns;
|
2002-08-10 04:37:55 +04:00
|
|
|
return ret;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|