mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
VFS source code cleanup.
MC now depends on glib (currently only the assertions are used). VFS structure declaration fixes. Uses the new icon list (it is dog slow, need to fix this tonight at home).
This commit is contained in:
parent
f699107608
commit
d6fcd9c2b7
@ -5,7 +5,7 @@ test -z "$srcdir" && srcdir=.
|
||||
cd $srcdir
|
||||
if test -d macros; then
|
||||
cat macros/gnome.m4 macros/gnome-vfs.m4 macros/gnome-undelfs.m4 \
|
||||
macros/linger.m4 mc-aclocal.m4 gettext.m4 > aclocal.m4
|
||||
macros/linger.m4 mc-aclocal.m4 gettext.m4 glib.m4 > aclocal.m4
|
||||
else
|
||||
echo macros directory not found, skipping generation of aclocal.m4
|
||||
fi
|
||||
|
12
config.h.in
12
config.h.in
@ -101,9 +101,9 @@
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
@ -113,6 +113,9 @@
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
#undef VERSION
|
||||
#undef PACKAGE
|
||||
|
||||
@ -405,9 +408,6 @@
|
||||
/* Define if you have the truncate function. */
|
||||
#undef HAVE_TRUNCATE
|
||||
|
||||
/* Define if you have the valloc function. */
|
||||
#undef HAVE_VALLOC
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
#undef HAVE_ARGZ_H
|
||||
|
||||
|
@ -117,6 +117,14 @@ if test "x$CCOPTS" = x; then
|
||||
fi
|
||||
CFLAGS="$CCOPTS"
|
||||
|
||||
|
||||
dnl
|
||||
dnl We now use glib
|
||||
dnl
|
||||
AM_PATH_GLIB
|
||||
LIBS="$LIBS $GLIB_LIBS"
|
||||
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
||||
|
||||
dnl
|
||||
dnl For A/UX. Do not move
|
||||
dnl
|
||||
|
188
glib.m4
Normal file
188
glib.m4
Normal file
@ -0,0 +1,188 @@
|
||||
# Configure paths for GLIB
|
||||
# Owen Taylor 97-11-3
|
||||
|
||||
dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
|
||||
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" is specified
|
||||
dnl in MODULES, feature the glib-config gmodule option.
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_GLIB,
|
||||
[dnl
|
||||
dnl Get the cflags and libraries from the glib-config script
|
||||
dnl
|
||||
AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)],
|
||||
glib_config_prefix="$withval", glib_config_prefix="")
|
||||
AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
|
||||
glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
|
||||
AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
|
||||
, enable_glibtest=yes)
|
||||
|
||||
if test x$glib_config_exec_prefix != x ; then
|
||||
glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
|
||||
if test x${GLIB_CONFIG+set} != xset ; then
|
||||
GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
|
||||
fi
|
||||
fi
|
||||
if test x$glib_config_prefix != x ; then
|
||||
glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
|
||||
if test x${GLIB_CONFIG+set} != xset ; then
|
||||
GLIB_CONFIG=$glib_config_prefix/bin/glib-config
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$4" in
|
||||
*gmodule*) glib_config_args="$glib_config_args gmodule";;
|
||||
esac
|
||||
|
||||
AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
|
||||
min_glib_version=ifelse([$1], ,0.99.7,$1)
|
||||
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
|
||||
no_glib=""
|
||||
if test "$GLIB_CONFIG" = "no" ; then
|
||||
no_glib=yes
|
||||
else
|
||||
GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
|
||||
GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
|
||||
glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "x$enable_glibtest" = "xyes" ; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
||||
LIBS="$LIBS $GLIB_LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
|
||||
dnl checks the results of glib-config to some extent
|
||||
dnl
|
||||
rm -f conf.glibtest
|
||||
AC_TRY_RUN([
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int major, minor, micro;
|
||||
char *tmp_version;
|
||||
|
||||
system ("touch conf.glibtest");
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = g_strdup("$min_glib_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_glib_version");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((glib_major_version != $glib_config_major_version) ||
|
||||
(glib_minor_version != $glib_config_minor_version) ||
|
||||
(glib_micro_version != $glib_config_micro_version))
|
||||
{
|
||||
printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
|
||||
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
|
||||
glib_major_version, glib_minor_version, glib_micro_version);
|
||||
printf ("*** was found! If glib-config was correct, then it is best\n");
|
||||
printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
|
||||
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
|
||||
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
|
||||
printf("*** required on your system.\n");
|
||||
printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
|
||||
printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
|
||||
printf("*** before re-running configure\n");
|
||||
}
|
||||
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
|
||||
(glib_minor_version != GLIB_MINOR_VERSION) ||
|
||||
(glib_micro_version != GLIB_MICRO_VERSION))
|
||||
{
|
||||
printf("*** GLIB header files (version %d.%d.%d) do not match\n",
|
||||
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
|
||||
printf("*** library (version %d.%d.%d)\n",
|
||||
glib_major_version, glib_minor_version, glib_micro_version);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((glib_major_version > major) ||
|
||||
((glib_major_version == major) && (glib_minor_version > minor)) ||
|
||||
((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
|
||||
glib_major_version, glib_minor_version, glib_micro_version);
|
||||
printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
|
||||
major, minor, micro);
|
||||
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
|
||||
printf("***\n");
|
||||
printf("*** If you have already installed a sufficiently new version, this error\n");
|
||||
printf("*** probably means that the wrong copy of the glib-config shell script is\n");
|
||||
printf("*** being found. The easiest way to fix this is to remove the old version\n");
|
||||
printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
|
||||
printf("*** correct copy of glib-config. (In this case, you will have to\n");
|
||||
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
|
||||
printf("*** so that the correct libraries are found at run-time))\n");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
if test "x$no_glib" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test "$GLIB_CONFIG" = "no" ; then
|
||||
echo "*** The glib-config script installed by GLIB could not be found"
|
||||
echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
|
||||
echo "*** your path, or set the GLIB_CONFIG environment variable to the"
|
||||
echo "*** full path to glib-config."
|
||||
else
|
||||
if test -f conf.glibtest ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run GLIB test program, checking why..."
|
||||
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
||||
LIBS="$LIBS $GLIB_LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
|
||||
[ echo "*** The test program compiled, but did not run. This usually means"
|
||||
echo "*** that the run-time linker is not finding GLIB or finding the wrong"
|
||||
echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system"
|
||||
echo "***"
|
||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
|
||||
echo "***"
|
||||
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
|
||||
echo "*** came with the system with the command"
|
||||
echo "***"
|
||||
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
|
||||
[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
||||
echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
|
||||
echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
|
||||
echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
GLIB_CFLAGS=""
|
||||
GLIB_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
rm -f conf.glibtest
|
||||
])
|
@ -1,3 +1,7 @@
|
||||
1998-10-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gscreen.c: Use the new icon list.
|
||||
|
||||
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gscreen.c: Hook to invoke the editor from the context menu.
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define PORT_LIST_MODE_NAME "gnome_list_mode"
|
||||
#define PORT_LIST_MODE_DEFAULT "icons"
|
||||
|
||||
#define ICONS_PER_ROW(x) (GNOME_ICON_LIST(x->icons)->icon_cols)
|
||||
#define ICONS_PER_ROW(x) (gnome_icon_list_get_items_per_line (GNOME_ICON_LIST(x->icons)))
|
||||
|
||||
#define mi_getch() fprintf (stderr, "mi_getch is not implemented in this port\n")
|
||||
#define frontend_run_dlg(x) gtkrundlg_event (x)
|
||||
|
@ -343,11 +343,11 @@ GnomeUIInfo gnome_panel_about_menu [] = {
|
||||
|
||||
GnomeUIInfo gnome_panel_menu [] = {
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_File"), NULL, &gnome_panel_file_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("Window"), NULL, &gnome_panel_panel_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("Commands"), NULL, &gnome_panel_commands_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("Options"), NULL, &gnome_panel_options_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("Desktop"), NULL, &gnome_panel_desktop_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_panel_about_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_Window"), NULL, &gnome_panel_panel_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_Commands"), NULL, &gnome_panel_commands_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_Options"), NULL, &gnome_panel_options_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_Desktop"), NULL, &gnome_panel_desktop_menu },
|
||||
{ GNOME_APP_UI_SUBTREE, N_("_Help"), NULL, &gnome_panel_about_menu },
|
||||
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
|
||||
};
|
||||
|
||||
@ -483,7 +483,7 @@ create_container (Dlg_head *h, char *name, char *geometry)
|
||||
} else if (!other_panel_ptr)
|
||||
other_panel_ptr = container;
|
||||
|
||||
bind_gtk_keys (GTK_WIDGET (app), h);
|
||||
/* bind_gtk_keys (GTK_WIDGET (app), h); */
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ char *default_edition_colors =
|
||||
"reverse=black,lightcyan:"
|
||||
"special=black";
|
||||
|
||||
int dialog_panel_callback (struct Dlg_head *h, int id, int msg);
|
||||
|
||||
/* The Dlg_head for the whole desktop */
|
||||
Dlg_head *desktop_dlg;
|
||||
|
||||
@ -174,8 +176,10 @@ xtoolkit_create_dialog (Dlg_head *h, int flags)
|
||||
|
||||
bind_gtk_keys (GTK_WIDGET (ted), h);
|
||||
}
|
||||
if (win)
|
||||
bind_gtk_keys (GTK_WIDGET (win), h);
|
||||
if (win){
|
||||
if (h->callback != dialog_panel_callback)
|
||||
bind_gtk_keys (GTK_WIDGET (win), h);
|
||||
}
|
||||
return (widget_data) win;
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,8 @@ panel_fill_panel_icons (WPanel *panel)
|
||||
}
|
||||
/* This is needed as the gtk_clist_append changes selected under us :-( */
|
||||
panel->selected = selected;
|
||||
select_item (panel);
|
||||
gnome_icon_list_thaw (icons);
|
||||
select_item (panel);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -318,7 +318,7 @@ x_select_item (WPanel *panel)
|
||||
display_mini_info (panel);
|
||||
gnome_icon_list_select_icon (list, panel->selected);
|
||||
|
||||
if (list->icon_rows){
|
||||
if (list->icon_list){
|
||||
if (gnome_icon_list_icon_is_visible (list, panel->selected) != GTK_VISIBILITY_FULL)
|
||||
gnome_icon_list_moveto (list, panel->selected, 0.5);
|
||||
}
|
||||
@ -1124,7 +1124,7 @@ panel_icon_list_drag_begin (GtkWidget *widget, GdkEvent *event, WPanel *panel)
|
||||
{
|
||||
GnomeIconList *icons = GNOME_ICON_LIST (panel->icons);
|
||||
|
||||
icons->last_clicked = -1;
|
||||
icons->last_clicked = NULL;
|
||||
panel_drag_begin (widget, event, panel);
|
||||
}
|
||||
|
||||
@ -1303,9 +1303,7 @@ load_imlib_icons (void)
|
||||
static void
|
||||
panel_icon_list_artificial_drag_start (GtkObject *obj, GdkEventMotion *event)
|
||||
{
|
||||
GnomeIconList *ilist = GNOME_ICON_LIST (obj);
|
||||
|
||||
artificial_drag_start (ilist->ilist_window, event->x, event->y);
|
||||
artificial_drag_start (GTK_WIDGET (obj)->window, event->x, event->y);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1314,14 +1312,13 @@ panel_icon_list_artificial_drag_start (GtkObject *obj, GdkEventMotion *event)
|
||||
static void
|
||||
panel_icon_list_drag_request (GtkWidget *widget, GdkEventDragRequest *event, WPanel *panel)
|
||||
{
|
||||
GnomeIconList *ilist = GNOME_ICON_LIST (widget);
|
||||
char *data;
|
||||
int len;
|
||||
|
||||
panel_drag_request (widget, event, panel, &len, &data);
|
||||
|
||||
if (len && data){
|
||||
gdk_window_dnd_data_set (ilist->ilist_window, (GdkEvent *) event, data, len);
|
||||
gdk_window_dnd_data_set (widget->window, (GdkEvent *) event, data, len);
|
||||
free (data);
|
||||
}
|
||||
}
|
||||
@ -1335,7 +1332,7 @@ panel_icon_list_drop_data_available (GtkWidget *widget, GdkEventDropDataAvailabl
|
||||
gint item;
|
||||
char *drop_dir;
|
||||
|
||||
gdk_window_get_origin (ilist->ilist_window, &winx, &winy);
|
||||
gdk_window_get_origin (widget->window, &winx, &winy);
|
||||
dropx = data->coords.x - winx;
|
||||
dropy = data->coords.y - winy;
|
||||
|
||||
@ -1376,7 +1373,8 @@ panel_icon_list_realized (GtkObject *obj, WPanel *panel)
|
||||
/* DND: Drag setup */
|
||||
gtk_signal_connect (obj, "drag_request_event", GTK_SIGNAL_FUNC (panel_icon_list_drag_request), panel);
|
||||
gtk_signal_connect (obj, "drag_begin_event", GTK_SIGNAL_FUNC (panel_icon_list_drag_begin), panel);
|
||||
gdk_window_dnd_drag_set (icon->ilist_window, TRUE, drag_types, ELEMENTS (drag_types));
|
||||
gdk_window_dnd_drag_set (GTK_WIDGET (icon)->window,
|
||||
TRUE, drag_types, ELEMENTS (drag_types));
|
||||
|
||||
/* DND: Drop setup */
|
||||
gtk_signal_connect (obj, "drop_data_available_event",
|
||||
@ -1384,7 +1382,7 @@ panel_icon_list_realized (GtkObject *obj, WPanel *panel)
|
||||
|
||||
gtk_signal_connect (obj, "motion_notify_event",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_artificial_drag_start), panel);
|
||||
gdk_window_dnd_drop_set (icon->ilist_window, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
gdk_window_dnd_drop_set (GTK_WIDGET (icon)->window, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1395,24 +1393,29 @@ panel_create_icon_display (WPanel *panel)
|
||||
{
|
||||
GnomeIconList *icon_field;
|
||||
|
||||
icon_field = GNOME_ICON_LIST (gnome_icon_list_new ());
|
||||
icon_field = GNOME_ICON_LIST (gnome_icon_list_new (100, NULL, TRUE));
|
||||
gnome_icon_list_set_separators (icon_field, " /-_.");
|
||||
gnome_icon_list_set_row_spacing (icon_field, 2);
|
||||
gnome_icon_list_set_col_spacing (icon_field, 2);
|
||||
gnome_icon_list_set_icon_border (icon_field, 4);
|
||||
gnome_icon_list_set_icon_border (icon_field, 2);
|
||||
gnome_icon_list_set_text_spacing (icon_field, 2);
|
||||
|
||||
icon_field->desired_text_width = 100;
|
||||
|
||||
gnome_icon_list_set_selection_mode (icon_field, GTK_SELECTION_MULTIPLE);
|
||||
GTK_WIDGET_SET_FLAGS (icon_field, GTK_CAN_FOCUS);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (icon_field), "select_icon",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_select_icon), panel);
|
||||
gtk_signal_connect (GTK_OBJECT (icon_field), "unselect_icon",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_unselect_icon), panel);
|
||||
gtk_signal_connect (
|
||||
GTK_OBJECT (icon_field), "select_icon",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_select_icon), panel);
|
||||
gtk_signal_connect (
|
||||
GTK_OBJECT (icon_field), "unselect_icon",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_unselect_icon), panel);
|
||||
|
||||
gtk_signal_connect (
|
||||
GTK_OBJECT (icon_field), "realize",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_realized), panel);
|
||||
|
||||
gnome_icon_list_thaw (icon_field);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (icon_field), "realize",
|
||||
GTK_SIGNAL_FUNC (panel_icon_list_realized), panel);
|
||||
return GTK_WIDGET (icon_field);
|
||||
}
|
||||
|
||||
@ -1787,12 +1790,16 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
GtkWidget *status_line, *filter, *vbox;
|
||||
GtkWidget *frame, *cwd, *back_p, *fwd_p;
|
||||
GtkWidget *display;
|
||||
GtkWidget *scrollbar;
|
||||
|
||||
panel->xwindow = gtk_widget_get_toplevel (GTK_WIDGET (panel->widget.wdata));
|
||||
|
||||
panel->table = gtk_table_new (2, 1, 0);
|
||||
|
||||
panel->icons = panel_create_icon_display (panel);
|
||||
scrollbar = gtk_vscrollbar_new (GNOME_ICON_LIST (panel->icons)->adj);
|
||||
gtk_widget_show (scrollbar);
|
||||
|
||||
panel->list = panel_create_file_list (panel);
|
||||
gtk_widget_ref (panel->icons);
|
||||
gtk_widget_ref (panel->list);
|
||||
@ -1861,6 +1868,10 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
0, 0);
|
||||
gtk_table_attach (GTK_TABLE (panel->table), scrollbar, 1, 2, 1, 2,
|
||||
0,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
0, 0);
|
||||
gtk_table_attach (GTK_TABLE (panel->table), panel->list, 0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
||||
|
@ -1,3 +1,8 @@
|
||||
1998-10-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* vfs.c, vfs.h: Indentation chages, ugly macros removed. I am
|
||||
going to split this file in the future.
|
||||
|
||||
Tue Oct 13 18:43:18 1998 Pavel Machek <pavel@lomikel.karlin.mff.cuni.cz>
|
||||
|
||||
* vfs.c (vfs_add_noncurrent_stamps): Fixed typo reported by Andrej
|
||||
|
48
vfs/ftpfs.c
48
vfs/ftpfs.c
@ -73,6 +73,9 @@
|
||||
# include <sys/time.h> /* alex: this redefines struct timeval */
|
||||
#endif /* SCO_FLAVOR */
|
||||
#include <sys/param.h>
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef USE_TERMNET
|
||||
#include <termnet.h>
|
||||
@ -101,9 +104,9 @@ int ftpfs_retry_seconds = 30;
|
||||
int ftpfs_use_passive_connections = 1;
|
||||
|
||||
/* Method used to get directory listings:
|
||||
1: try 'LIST -la <path>', if it fails
|
||||
fall back to CWD <path>; LIST
|
||||
0: always use CWD <path>; LIST
|
||||
* 1: try 'LIST -la <path>', if it fails
|
||||
* fall back to CWD <path>; LIST
|
||||
* 0: always use CWD <path>; LIST
|
||||
*/
|
||||
int ftpfs_use_unix_list_options = 1;
|
||||
|
||||
@ -139,33 +142,42 @@ static struct linklist *connections_list;
|
||||
#define WANT_STRING 0x02
|
||||
static char reply_str [80];
|
||||
|
||||
static char *ftpfs_get_current_directory(struct connection *bucket);
|
||||
static int __ftpfs_chdir (struct connection *bucket ,char *remote_path);
|
||||
static struct direntry *_get_file_entry(struct connection *bucket,
|
||||
char *file_name, int op, int flags);
|
||||
static void free_bucket (void *data);
|
||||
static void connection_destructor(void *data);
|
||||
static void flush_all_directory(struct connection *bucket);
|
||||
static int get_line (int sock, char *buf, int buf_len, char term);
|
||||
static char *get_path (struct connection **bucket, char *path);
|
||||
|
||||
static char *ftpfs_get_current_directory (struct connection *bucket);
|
||||
static int ftpfs_chdir_internal (struct connection *bucket,
|
||||
char *remote_path);
|
||||
static void free_bucket (void *data);
|
||||
static void connection_destructor (void *data);
|
||||
static void flush_all_directory (struct connection *bucket);
|
||||
static int get_line (int sock, char *buf, int buf_len,
|
||||
char term);
|
||||
static char *get_path (struct connection **bucket,
|
||||
char *path);
|
||||
|
||||
/* Extract the hostname and username from the path */
|
||||
/* path is in the form: [user@]hostname:port/remote-dir, e.g.:
|
||||
|
||||
/*
|
||||
* path is in the form: [user@]hostname:port/remote-dir, e.g.:
|
||||
* ftp://sunsite.unc.edu/pub/linux
|
||||
* ftp://miguel@sphinx.nuclecu.unam.mx/c/nc
|
||||
* ftp://tsx-11.mit.edu:8192/
|
||||
* ftp://joe@foo.edu:11321/private
|
||||
* If the user is empty, e.g. ftp://@roxanne/private, then your login name
|
||||
* is supplied.
|
||||
* */
|
||||
*
|
||||
*/
|
||||
|
||||
static char *my_get_host_and_username (char *path, char **host, char **user, int *port, char **pass)
|
||||
static char *
|
||||
my_get_host_and_username (char *path, char **host, char **user, int *port, char **pass)
|
||||
{
|
||||
return vfs_get_host_and_username (path, host, user, port, 21, 1, pass);
|
||||
}
|
||||
|
||||
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
|
||||
static int get_reply (int sock, char *string_buf, int string_len)
|
||||
static int
|
||||
get_reply (int sock, char *string_buf, int string_len)
|
||||
{
|
||||
char answer[1024];
|
||||
int i;
|
||||
@ -208,8 +220,8 @@ static int get_reply (int sock, char *string_buf, int string_len)
|
||||
}
|
||||
}
|
||||
|
||||
static int command (struct connection *bucket, int wait_reply,
|
||||
char *fmt, ...)
|
||||
static int
|
||||
command (struct connection *bucket, int wait_reply, char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[2048]; /* FIXME: buffer exceed ?? */
|
||||
@ -1139,7 +1151,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
else
|
||||
print_vfs_message("ftpfs: Reading FTP directory...");
|
||||
if (has_spaces || bucket->strict_rfc959_list_cmd)
|
||||
if (__ftpfs_chdir(bucket, remote_path) != COMPLETE) {
|
||||
if (ftpfs_chdir_internal (bucket, remote_path) != COMPLETE) {
|
||||
my_errno = ENOENT;
|
||||
print_vfs_message("ftpfs: CWD failed.");
|
||||
return NULL;
|
||||
@ -1528,7 +1540,7 @@ is_same_dir (char *path, struct connection *bucket)
|
||||
}
|
||||
|
||||
static int
|
||||
__ftpfs_chdir (struct connection *bucket ,char *remote_path)
|
||||
ftpfs_chdir_internal (struct connection *bucket ,char *remote_path)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
282
vfs/vfs.c
282
vfs/vfs.c
@ -27,6 +27,10 @@
|
||||
parse_ls_lga and friends which do not have that prefix. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* For atol() */
|
||||
#include <stdarg.h>
|
||||
@ -80,14 +84,16 @@ static int current_year;
|
||||
uid_t vfs_uid = 0;
|
||||
gid_t vfs_gid = 0;
|
||||
|
||||
/* Open files managed by the vfs layer */
|
||||
/* FIXME: Open files managed by the vfs layer, should be dynamical */
|
||||
#define MAX_VFS_FILES 100
|
||||
|
||||
static struct {
|
||||
void *fs_info;
|
||||
vfs *operations;
|
||||
} vfs_file_table [MAX_VFS_FILES];
|
||||
|
||||
static int get_bucket (void)
|
||||
static int
|
||||
get_bucket (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -96,30 +102,39 @@ static int get_bucket (void)
|
||||
if (!vfs_file_table [i].fs_info)
|
||||
return i;
|
||||
}
|
||||
|
||||
vfs_die ("No more virtual file handles");
|
||||
return 0; /* Shut up, stupid gcc */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static vfs *vfs_list = &vfs_local_ops; /* It _has_ to be the first */
|
||||
/* vfs_local_ops needs to be the first one */
|
||||
static vfs *vfs_list = &vfs_local_ops;
|
||||
|
||||
#define FOR_ALL_VFS for (vfs=vfs_list; vfs; vfs=vfs->next)
|
||||
|
||||
int vfs_register( vfs *vfs )
|
||||
int
|
||||
vfs_register (vfs *vfs)
|
||||
{
|
||||
int res = (vfs->init) ? (*vfs->init)(vfs) : 1;
|
||||
int res;
|
||||
|
||||
g_return_if_fail (vfs != NULL);
|
||||
|
||||
res = (vfs->init) ? (*vfs->init)(vfs) : 1;
|
||||
|
||||
if (!res) return 0;
|
||||
|
||||
vfs->next = vfs_list;
|
||||
vfs_list = vfs;
|
||||
#if 0
|
||||
fprintf( stderr, "VFS %s successfully registered\n", vfs->name );
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
vfs *vfs_type_from_op (char *path)
|
||||
vfs *
|
||||
vfs_type_from_op (char *path)
|
||||
{
|
||||
vfs *vfs;
|
||||
FOR_ALL_VFS {
|
||||
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
for (vfs = vfs_list; vfs; vfs = vfs->next){
|
||||
if (vfs == &vfs_local_ops) /* local catches all */
|
||||
return NULL;
|
||||
if (vfs->which) {
|
||||
@ -131,14 +146,17 @@ vfs *vfs_type_from_op (char *path)
|
||||
if (!strncmp (path, vfs->prefix, strlen (vfs->prefix)))
|
||||
return vfs;
|
||||
}
|
||||
vfs_die( "No local in vfs list?" );
|
||||
vfs_die ("No local in vfs list?");
|
||||
return NULL; /* shut up stupid gcc */
|
||||
}
|
||||
|
||||
static int path_magic( char *path )
|
||||
static int
|
||||
path_magic (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
if (vfs_flags & FL_ALWAYS_MAGIC)
|
||||
return 1;
|
||||
|
||||
@ -153,29 +171,39 @@ static int path_magic( char *path )
|
||||
* What is left in path is p1. You still want to free(path), you DON'T
|
||||
* want to free neither *inpath nor *op
|
||||
*/
|
||||
vfs *vfs_split (char *path, char **inpath, char **op)
|
||||
vfs *
|
||||
vfs_split (char *path, char **inpath, char **op)
|
||||
{
|
||||
char *semi = strrchr (path, '#');
|
||||
char *semi;
|
||||
char *slash;
|
||||
vfs *ret;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
semi = strrchr (path, '#');
|
||||
if (!semi || !path_magic(path))
|
||||
return NULL;
|
||||
|
||||
slash = strchr (semi, '/');
|
||||
*semi = 0;
|
||||
|
||||
if (op)
|
||||
*op = NULL;
|
||||
|
||||
if (inpath)
|
||||
*inpath = NULL;
|
||||
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
|
||||
if ((ret = vfs_type_from_op (semi+1))){
|
||||
if (op)
|
||||
*op = semi+1;
|
||||
*op = semi + 1;
|
||||
if (inpath)
|
||||
*inpath = slash?slash+1:NULL;
|
||||
*inpath = slash ? slash + 1 : NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
ret = vfs_split (path, inpath, op);
|
||||
@ -186,47 +214,65 @@ vfs *vfs_split (char *path, char **inpath, char **op)
|
||||
vfs *
|
||||
vfs_rosplit (char *path)
|
||||
{
|
||||
char *semi = strrchr (path, '#');
|
||||
char *semi;
|
||||
char *slash;
|
||||
vfs *ret;
|
||||
|
||||
if (!semi || !path_magic(path))
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
semi = strrchr (path, '#');
|
||||
|
||||
if (!semi || !path_magic (path))
|
||||
return NULL;
|
||||
|
||||
slash = strchr (semi, '/');
|
||||
*semi = 0;
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
|
||||
ret = vfs_type_from_op (semi+1);
|
||||
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
if (!ret)
|
||||
ret = vfs_rosplit (path);
|
||||
|
||||
*semi = '#';
|
||||
return ret;
|
||||
}
|
||||
|
||||
vfs *vfs_type (char *path)
|
||||
vfs *
|
||||
vfs_type (char *path)
|
||||
{
|
||||
vfs *vfs = vfs_rosplit(path);
|
||||
vfs *vfs;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
vfs = vfs_rosplit(path);
|
||||
|
||||
if (!vfs)
|
||||
vfs = &vfs_local_ops;
|
||||
|
||||
return vfs;
|
||||
}
|
||||
|
||||
static struct vfs_stamping *stamps;
|
||||
|
||||
/* Returns the number of seconds remaining to the vfs timeout
|
||||
/*
|
||||
* Returns the number of seconds remaining to the vfs timeout
|
||||
*
|
||||
* FIXME: currently this is set to 10 seconds. We should compute this.
|
||||
*/
|
||||
int vfs_timeouts ()
|
||||
int
|
||||
vfs_timeouts ()
|
||||
{
|
||||
return stamps ? 10 : 0;
|
||||
}
|
||||
|
||||
void vfs_addstamp (vfs *v, vfsid id, struct vfs_stamping *parent)
|
||||
void
|
||||
vfs_addstamp (vfs *v, vfsid id, struct vfs_stamping *parent)
|
||||
{
|
||||
g_return_if_fail (v != NULL);
|
||||
|
||||
if (v != &vfs_local_ops && id != (vfsid)-1){
|
||||
struct vfs_stamping *stamp, *st1;
|
||||
|
||||
@ -250,8 +296,10 @@ void vfs_addstamp (vfs *v, vfsid id, struct vfs_stamping *parent)
|
||||
}
|
||||
else
|
||||
stamp->parent = 0;
|
||||
|
||||
gettimeofday (&(stamp->time), NULL);
|
||||
stamp->next = 0;
|
||||
|
||||
if (stamps)
|
||||
st1->next = stamp;
|
||||
else
|
||||
@ -259,30 +307,39 @@ void vfs_addstamp (vfs *v, vfsid id, struct vfs_stamping *parent)
|
||||
}
|
||||
}
|
||||
|
||||
void vfs_stamp (vfs *v, vfsid id)
|
||||
void
|
||||
vfs_stamp (vfs *v, vfsid id)
|
||||
{
|
||||
struct vfs_stamping *stamp;
|
||||
|
||||
g_return_if_fail (v != NULL);
|
||||
|
||||
for (stamp = stamps; stamp != NULL; stamp = stamp->next)
|
||||
if (stamp->v == v && stamp->id == id){
|
||||
|
||||
gettimeofday (&(stamp->time), NULL);
|
||||
if (stamp->parent != NULL)
|
||||
vfs_stamp (stamp->parent->v, stamp->parent->id);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void vfs_rm_parents (struct vfs_stamping *stamp)
|
||||
void
|
||||
vfs_rm_parents (struct vfs_stamping *stamp)
|
||||
{
|
||||
struct vfs_stamping *st2, *st3;
|
||||
|
||||
if (stamp){
|
||||
for (st2 = stamp, st3 = st2->parent; st3 != NULL; st2 = st3, st3 = st3->parent)
|
||||
free (st2);
|
||||
|
||||
free (st2);
|
||||
}
|
||||
}
|
||||
|
||||
void vfs_rmstamp (vfs *v, vfsid id, int removeparents)
|
||||
void
|
||||
vfs_rmstamp (vfs *v, vfsid id, int removeparents)
|
||||
{
|
||||
struct vfs_stamping *stamp, *st1;
|
||||
|
||||
@ -299,6 +356,7 @@ void vfs_rmstamp (vfs *v, vfsid id, int removeparents)
|
||||
st1->next = stamp->next;
|
||||
}
|
||||
free (stamp);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -310,7 +368,8 @@ ferrno (vfs *vfs)
|
||||
/* Hope that error message is obscure enough ;-) */
|
||||
}
|
||||
|
||||
int mc_open (char *file, int flags, ...)
|
||||
int
|
||||
mc_open (char *file, int flags, ...)
|
||||
{
|
||||
int handle;
|
||||
int mode;
|
||||
@ -327,7 +386,8 @@ int mc_open (char *file, int flags, ...)
|
||||
va_end (ap);
|
||||
|
||||
if (!vfs->open)
|
||||
vfs_die( "VFS must support open.\n" );
|
||||
return -1;
|
||||
|
||||
info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */
|
||||
free (file);
|
||||
if (!info){
|
||||
@ -366,7 +426,8 @@ int mc_open (char *file, int flags, ...)
|
||||
|
||||
MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) );
|
||||
|
||||
int mc_ctl (int handle, int ctlop, int arg)
|
||||
int
|
||||
mc_ctl (int handle, int ctlop, int arg)
|
||||
{
|
||||
vfs *vfs;
|
||||
int result;
|
||||
@ -376,7 +437,8 @@ int mc_ctl (int handle, int ctlop, int arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
int mc_setctl (char *path, int ctlop, char *arg)
|
||||
int
|
||||
mc_setctl (char *path, int ctlop, char *arg)
|
||||
{
|
||||
vfs *vfs;
|
||||
int result;
|
||||
@ -388,7 +450,8 @@ int mc_setctl (char *path, int ctlop, char *arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
int mc_close (int handle)
|
||||
int
|
||||
mc_close (int handle)
|
||||
{
|
||||
vfs *vfs;
|
||||
int result;
|
||||
@ -401,7 +464,7 @@ int mc_close (int handle)
|
||||
return close (handle);
|
||||
|
||||
if (!vfs->close)
|
||||
vfs_die( "VFS must support close.\n" );
|
||||
vfs_die ("VFS must support close.\n");
|
||||
result = (*vfs->close)(vfs_info (handle));
|
||||
vfs_free_bucket (handle);
|
||||
if (result == -1)
|
||||
@ -410,7 +473,8 @@ int mc_close (int handle)
|
||||
return result;
|
||||
}
|
||||
|
||||
DIR *mc_opendir (char *dirname)
|
||||
DIR *
|
||||
mc_opendir (char *dirname)
|
||||
{
|
||||
int handle, *handlep;
|
||||
void *info;
|
||||
@ -448,7 +512,8 @@ DIR *mc_opendir (char *dirname)
|
||||
/* This should strip the non needed part of a path name */
|
||||
#define vfs_name(x) x
|
||||
|
||||
void mc_seekdir (DIR *dirp, int offset)
|
||||
void
|
||||
mc_seekdir (DIR *dirp, int offset)
|
||||
{
|
||||
int handle;
|
||||
vfs *vfs;
|
||||
@ -487,7 +552,8 @@ type mc_##name (DIR *dirp) \
|
||||
MC_DIROP (readdir, struct dirent *, NULL)
|
||||
MC_DIROP (telldir, int, -1)
|
||||
|
||||
int mc_closedir (DIR *dirp)
|
||||
int
|
||||
mc_closedir (DIR *dirp)
|
||||
{
|
||||
int handle = *(int *) dirp;
|
||||
vfs *vfs = vfs_op (handle);
|
||||
@ -507,7 +573,8 @@ MC_HANDLEOP (fstat, (int handle, struct stat *buf), (vfs_info (handle), buf))
|
||||
* You must strdup whatever this function returns, static buffers are in use
|
||||
*/
|
||||
|
||||
char *mc_return_cwd (void)
|
||||
char *
|
||||
mc_return_cwd (void)
|
||||
{
|
||||
char *p;
|
||||
struct stat my_stat, my_stat2;
|
||||
@ -533,12 +600,14 @@ char *mc_return_cwd (void)
|
||||
return current_dir;
|
||||
}
|
||||
|
||||
char *mc_get_current_wd (char *buffer, int size)
|
||||
char *
|
||||
mc_get_current_wd (char *buffer, int size)
|
||||
{
|
||||
char *cwd = mc_return_cwd();
|
||||
if (strlen (cwd) > size){
|
||||
|
||||
if (strlen (cwd) > size)
|
||||
vfs_die ("Current_dir size overflow.\n");
|
||||
}
|
||||
|
||||
strcpy (buffer, cwd);
|
||||
return buffer;
|
||||
}
|
||||
@ -600,9 +669,13 @@ off_t mc_lseek (int fd, off_t offset, int whence)
|
||||
|
||||
#define ISSLASH(a) (!a || (a == '/'))
|
||||
|
||||
char *vfs_canon (char *path)
|
||||
char *
|
||||
vfs_canon (char *path)
|
||||
{
|
||||
if (*path == '~'){ /* Tilde expansion */
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
/* Tilde expansion */
|
||||
if (*path == '~'){
|
||||
char *local, *result;
|
||||
|
||||
local = tilde_expand (path);
|
||||
@ -614,7 +687,8 @@ char *vfs_canon (char *path)
|
||||
return strdup (path);
|
||||
}
|
||||
|
||||
if (*path != '/'){ /* Relative to current directory */
|
||||
/* Relative to current directory */
|
||||
if (*path != '/'){
|
||||
char *local, *result;
|
||||
|
||||
if (current_dir [strlen (current_dir) - 1] == '/')
|
||||
@ -626,7 +700,9 @@ char *vfs_canon (char *path)
|
||||
free (local);
|
||||
return result;
|
||||
}
|
||||
/* So we have path of following form:
|
||||
|
||||
/*
|
||||
* So we have path of following form:
|
||||
* /p1/p2#op/.././././p3#op/p4. Good luck.
|
||||
*/
|
||||
canonicalize_pathname (path);
|
||||
@ -634,7 +710,8 @@ char *vfs_canon (char *path)
|
||||
return strdup (path);
|
||||
}
|
||||
|
||||
vfsid vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
vfsid
|
||||
vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
{
|
||||
vfsid nvfsid;
|
||||
int freeit = 0;
|
||||
@ -642,6 +719,7 @@ vfsid vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
if (dir [strlen (dir) - 1] != '/'){
|
||||
dir = copy_strings (dir, "/", NULL);
|
||||
freeit = 1;
|
||||
|
||||
}
|
||||
nvfsid = (*nvfs->getid)(nvfs, dir, par);
|
||||
if (freeit)
|
||||
@ -649,16 +727,20 @@ vfsid vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
return nvfsid;
|
||||
}
|
||||
|
||||
static int is_parent (vfs * nvfs, vfsid nvfsid, struct vfs_stamping *parent)
|
||||
static int
|
||||
is_parent (vfs * nvfs, vfsid nvfsid, struct vfs_stamping *parent)
|
||||
{
|
||||
struct vfs_stamping *stamp;
|
||||
|
||||
for (stamp = parent; stamp; stamp = stamp->parent)
|
||||
if (stamp->v == nvfs && stamp->id == nvfsid)
|
||||
break;
|
||||
|
||||
return (stamp ? 1 : 0);
|
||||
}
|
||||
|
||||
void vfs_add_noncurrent_stamps (vfs * oldvfs, vfsid oldvfsid, struct vfs_stamping *parent)
|
||||
void
|
||||
vfs_add_noncurrent_stamps (vfs * oldvfs, vfsid oldvfsid, struct vfs_stamping *parent)
|
||||
{
|
||||
#ifndef VFS_STANDALONE
|
||||
vfs *nvfs, *n2vfs, *n3vfs;
|
||||
@ -741,7 +823,8 @@ void vfs_add_noncurrent_stamps (vfs * oldvfs, vfsid oldvfsid, struct vfs_stampin
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vfs_stamp_path (char *path)
|
||||
static void
|
||||
vfs_stamp_path (char *path)
|
||||
{
|
||||
vfs *vfs;
|
||||
vfsid id;
|
||||
@ -757,7 +840,8 @@ static void vfs_stamp_path (char *path)
|
||||
}
|
||||
|
||||
#ifndef VFS_STANDALONE
|
||||
void vfs_add_current_stamps (void)
|
||||
void
|
||||
vfs_add_current_stamps (void)
|
||||
{
|
||||
vfs_stamp_path (current_dir);
|
||||
if (get_current_type () == view_listing)
|
||||
@ -768,7 +852,8 @@ void vfs_add_current_stamps (void)
|
||||
#endif
|
||||
|
||||
/* This function is really broken */
|
||||
int mc_chdir (char *path)
|
||||
int
|
||||
mc_chdir (char *path)
|
||||
{
|
||||
char *a, *b;
|
||||
int result;
|
||||
@ -815,25 +900,29 @@ int mc_chdir (char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
int vfs_current_is_local (void)
|
||||
int
|
||||
vfs_current_is_local (void)
|
||||
{
|
||||
return current_vfs == &vfs_local_ops;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* External world should not do differences between VFS-s */
|
||||
int vfs_current_is_extfs (void)
|
||||
int
|
||||
vfs_current_is_extfs (void)
|
||||
{
|
||||
return current_vfs == &vfs_extfs_ops;
|
||||
}
|
||||
|
||||
int vfs_current_is_tarfs (void)
|
||||
int
|
||||
vfs_current_is_tarfs (void)
|
||||
{
|
||||
return current_vfs == &vfs_tarfs_ops;
|
||||
}
|
||||
#endif
|
||||
|
||||
int vfs_file_is_local (char *filename)
|
||||
int
|
||||
vfs_file_is_local (char *filename)
|
||||
{
|
||||
vfs *vfs;
|
||||
|
||||
@ -843,7 +932,8 @@ int vfs_file_is_local (char *filename)
|
||||
return vfs == &vfs_local_ops;
|
||||
}
|
||||
|
||||
int vfs_file_is_ftp (char *filename)
|
||||
int
|
||||
vfs_file_is_ftp (char *filename)
|
||||
{
|
||||
#ifdef USE_NETCODE
|
||||
vfs *vfs;
|
||||
@ -911,7 +1001,8 @@ mc_mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
return result;
|
||||
}
|
||||
|
||||
int mc_munmap (caddr_t addr, size_t len)
|
||||
int
|
||||
mc_munmap (caddr_t addr, size_t len)
|
||||
{
|
||||
struct mc_mmapping *mcm, *mcm2 = NULL;
|
||||
|
||||
@ -932,7 +1023,8 @@ int mc_munmap (caddr_t addr, size_t len)
|
||||
|
||||
#endif
|
||||
|
||||
char *mc_def_getlocalcopy (vfs *vfs, char *filename)
|
||||
char *
|
||||
mc_def_getlocalcopy (vfs *vfs, char *filename)
|
||||
{
|
||||
char *tmp;
|
||||
int fdin, fdout, i;
|
||||
@ -962,7 +1054,8 @@ char *mc_def_getlocalcopy (vfs *vfs, char *filename)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
char *mc_getlocalcopy (char *path)
|
||||
char *
|
||||
mc_getlocalcopy (char *path)
|
||||
{
|
||||
vfs *vfs;
|
||||
char *result;
|
||||
@ -977,7 +1070,8 @@ char *mc_getlocalcopy (char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
void mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed)
|
||||
void
|
||||
mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed)
|
||||
{
|
||||
if (has_changed){
|
||||
int fdin, fdout, i;
|
||||
@ -1008,7 +1102,8 @@ void mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_chang
|
||||
free (local);
|
||||
}
|
||||
|
||||
void mc_ungetlocalcopy (char *path, char *local, int has_changed)
|
||||
void
|
||||
mc_ungetlocalcopy (char *path, char *local, int has_changed)
|
||||
{
|
||||
vfs *vfs;
|
||||
|
||||
@ -1022,19 +1117,22 @@ void mc_ungetlocalcopy (char *path, char *local, int has_changed)
|
||||
/*
|
||||
* Hmm, as timeout is minute or so, do we need to care about usecs?
|
||||
*/
|
||||
inline int timeoutcmp (struct timeval *t1, struct timeval *t2)
|
||||
inline int
|
||||
timeoutcmp (struct timeval *t1, struct timeval *t2)
|
||||
{
|
||||
return ((t1->tv_sec < t2->tv_sec)
|
||||
|| ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec <= t2->tv_usec)));
|
||||
}
|
||||
|
||||
void vfs_timeout_handler (void)
|
||||
void
|
||||
vfs_timeout_handler (void)
|
||||
{
|
||||
struct timeval time;
|
||||
struct vfs_stamping *stamp, *st;
|
||||
|
||||
gettimeofday (&time, NULL);
|
||||
time.tv_sec -= vfs_timeout;
|
||||
|
||||
for (stamp = stamps; stamp != NULL;){
|
||||
if (timeoutcmp (&stamp->time, &time)){
|
||||
st = stamp->next;
|
||||
@ -1046,7 +1144,8 @@ void vfs_timeout_handler (void)
|
||||
}
|
||||
}
|
||||
|
||||
void vfs_init (void)
|
||||
void
|
||||
vfs_init (void)
|
||||
{
|
||||
time_t current_time;
|
||||
struct tm *t;
|
||||
@ -1078,7 +1177,8 @@ void vfs_init (void)
|
||||
vfs_setup_wd ();
|
||||
}
|
||||
|
||||
void vfs_free_resources (char *path)
|
||||
void
|
||||
vfs_free_resources (char *path)
|
||||
{
|
||||
vfs *vfs;
|
||||
vfsid vid;
|
||||
@ -1093,7 +1193,8 @@ void vfs_free_resources (char *path)
|
||||
|
||||
#if 0
|
||||
/* Shutdown a vfs given a path name */
|
||||
void vfs_shut_path (char *p)
|
||||
void
|
||||
vfs_shut_path (char *p)
|
||||
{
|
||||
vfs *the_vfs;
|
||||
struct vfs_stamping *par;
|
||||
@ -1105,7 +1206,8 @@ void vfs_shut_path (char *p)
|
||||
}
|
||||
#endif
|
||||
|
||||
void vfs_shut (void)
|
||||
void
|
||||
vfs_shut (void)
|
||||
{
|
||||
struct vfs_stamping *stamp, *st;
|
||||
vfs *vfs;
|
||||
@ -1123,18 +1225,22 @@ void vfs_shut (void)
|
||||
if (current_dir)
|
||||
free (current_dir);
|
||||
|
||||
FOR_ALL_VFS
|
||||
|
||||
for (vfs=vfs_list; vfs; vfs=vfs->next)
|
||||
if (vfs->done)
|
||||
(*vfs->done) (vfs);
|
||||
}
|
||||
|
||||
/* These ones grab information from the VFS
|
||||
/*
|
||||
* These ones grab information from the VFS
|
||||
* and handles them to an upper layer
|
||||
*/
|
||||
void vfs_fill_names (void (*func)(char *))
|
||||
void
|
||||
vfs_fill_names (void (*func)(char *))
|
||||
{
|
||||
vfs *vfs;
|
||||
FOR_ALL_VFS
|
||||
|
||||
for (vfs=vfs_list; vfs; vfs=vfs->next)
|
||||
if (vfs->fill_names)
|
||||
(*vfs->fill_names) (vfs, func);
|
||||
}
|
||||
@ -1145,7 +1251,8 @@ void vfs_fill_names (void (*func)(char *))
|
||||
static char *columns [MAXCOLS]; /* Points to the string in column n */
|
||||
static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */
|
||||
|
||||
int vfs_split_text (char *p)
|
||||
int
|
||||
vfs_split_text (char *p)
|
||||
{
|
||||
char *original = p;
|
||||
int numcols;
|
||||
@ -1164,14 +1271,16 @@ int vfs_split_text (char *p)
|
||||
return numcols;
|
||||
}
|
||||
|
||||
static int is_num (int idx)
|
||||
static int
|
||||
is_num (int idx)
|
||||
{
|
||||
if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9')
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int is_time (char *str, struct tm *tim)
|
||||
static int
|
||||
is_time (char *str, struct tm *tim)
|
||||
{
|
||||
char *p, *p2;
|
||||
|
||||
@ -1193,28 +1302,33 @@ static int is_time (char *str, struct tm *tim)
|
||||
|
||||
static int is_year(char *str, struct tm *tim)
|
||||
{
|
||||
/* Old code recognized 02904baa as year identification :-( */
|
||||
long year;
|
||||
|
||||
if (strchr(str,':'))
|
||||
return 0;
|
||||
|
||||
if (strlen(str)!=4)
|
||||
return 0;
|
||||
|
||||
if (sscanf(str, "%ld", &year) != 1)
|
||||
return 0;
|
||||
|
||||
if (year < 1900 || year > 3000)
|
||||
return 0;
|
||||
|
||||
tim->tm_year = (int) (year - 1900);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: this is broken. Consider following entry:
|
||||
-rwx------ 1 root root 1 Aug 31 10:04 2904 1234
|
||||
where "2904 1234" is filename. Well, this code decodes it as year :-(.
|
||||
* -rwx------ 1 root root 1 Aug 31 10:04 2904 1234
|
||||
* where "2904 1234" is filename. Well, this code decodes it as year :-(.
|
||||
*/
|
||||
|
||||
int vfs_parse_filetype (char c)
|
||||
int
|
||||
vfs_parse_filetype (char c)
|
||||
{
|
||||
switch (c){
|
||||
case 'd': return S_IFDIR;
|
||||
@ -1367,7 +1481,9 @@ int vfs_parse_filedate(int idx, time_t *t)
|
||||
}
|
||||
|
||||
#define free_and_return(x) { free (p_copy); return (x); }
|
||||
int vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
|
||||
int
|
||||
vfs_parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname)
|
||||
{
|
||||
int idx, idx2, num_cols, isconc = 0;
|
||||
int i;
|
||||
@ -1558,8 +1674,10 @@ vfs_get_password (char *msg)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Returns vfs path corresponding to given url. If passed string is
|
||||
* not recognized as url, strdup(url) is returned. */
|
||||
/*
|
||||
* Returns vfs path corresponding to given url. If passed string is
|
||||
* not recognized as url, strdup(url) is returned.
|
||||
*/
|
||||
char *
|
||||
vfs_translate_url (char *url)
|
||||
{
|
||||
|
140
vfs/vfs.h
140
vfs/vfs.h
@ -34,12 +34,16 @@ struct utimbuf {
|
||||
|
||||
struct vfs_stamping;
|
||||
|
||||
/* Notice: Andrej Borsenkow <borsenkow.msk@sni.de> reports system
|
||||
(RelianUNIX), where it is bad idea to define struct vfs. That system
|
||||
mas include called <sys/vfs.h>, which contains things like vfs_t.
|
||||
/*
|
||||
* Notice: Andrej Borsenkow <borsenkow.msk@sni.de> reports system
|
||||
* (RelianUNIX), where it is bad idea to define struct vfs. That system
|
||||
* umust include called <sys/vfs.h>, which contains things like vfs_t.
|
||||
*/
|
||||
typedef struct vfs_struct {
|
||||
struct vfs_struct *next;
|
||||
|
||||
typedef struct _vfs vfs;
|
||||
|
||||
struct _vfs {
|
||||
vfs *next;
|
||||
char *name; /* "FIles over SHell" */
|
||||
int flags;
|
||||
#define F_EXEC 1
|
||||
@ -47,57 +51,64 @@ mas include called <sys/vfs.h>, which contains things like vfs_t.
|
||||
char *prefix; /* "#fish:" */
|
||||
void *data; /* this is for filesystem's own use */
|
||||
int verrno; /* can't use errno because glibc2 might define errno as function */
|
||||
int (*init)(struct vfs *me); /* 1..initialized succesfully */
|
||||
void (*done)(struct vfs *me);
|
||||
void (*fill_names)(struct vfs *me, void (*)(char *));
|
||||
int (*which)(struct vfs *me, char *path); /* Returns '-1' if this path does not belong to this filesystem */
|
||||
|
||||
void *(*open)(struct vfs *me, char *fname, int flags, int mode);
|
||||
int (*close)(void *vfs_info);
|
||||
int (*read)(void *vfs_info, char *buffer, int count);
|
||||
int (*write)(void *vfs_info, char *buf, int count);
|
||||
int (*init) (vfs *me);
|
||||
void (*done) (vfs *me);
|
||||
void (*fill_names) (vfs *me, void (*)(char *));
|
||||
|
||||
void *(*opendir)(struct vfs *me, char *dirname);
|
||||
void *(*readdir)(void *vfs_info);
|
||||
int (*closedir)(void *vfs_info);
|
||||
int (*telldir)(void *vfs_info);
|
||||
void (*seekdir)(void *vfs_info, int offset);
|
||||
int (*which) (vfs *me, char *path);
|
||||
|
||||
int (*stat)(struct vfs *me, char *path, struct stat *buf);
|
||||
int (*lstat)(struct vfs *me, char *path, struct stat *buf);
|
||||
int (*fstat)(void *vfs_info, struct stat *buf);
|
||||
void *(*open) (vfs *me, char *fname, int flags, int mode);
|
||||
int (*close) (void *vfs_info);
|
||||
int (*read) (void *vfs_info, char *buffer, int count);
|
||||
int (*write) (void *vfs_info, char *buf, int count);
|
||||
|
||||
int (*chmod)(struct vfs *me, char *path, int mode);
|
||||
int (*chown)(struct vfs *me, char *path, int owner, int group);
|
||||
int (*utime)(struct vfs *me, char *path, struct utimbuf *times);
|
||||
void *(*opendir) (vfs *me, char *dirname);
|
||||
void *(*readdir) (void *vfs_info);
|
||||
int (*closedir) (void *vfs_info);
|
||||
int (*telldir) (void *vfs_info);
|
||||
void (*seekdir) (void *vfs_info, int offset);
|
||||
|
||||
int (*readlink)(struct vfs *me, char *path, char *buf, int size);
|
||||
int (*symlink)(struct vfs *me, char *n1, char *n2);
|
||||
int (*link)(struct vfs *me, char *p1, char *p2);
|
||||
int (*unlink)(struct vfs *me, char *path);
|
||||
int (*rename)(struct vfs *me, char *p1, char *p2);
|
||||
int (*chdir)(struct vfs *me, char *path);
|
||||
int (*ferrno)(struct vfs *me);
|
||||
int (*lseek)(void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod)(struct vfs *me, char *path, int mode, int dev);
|
||||
int (*stat) (vfs *me, char *path, struct stat *buf);
|
||||
int (*lstat) (vfs *me, char *path, struct stat *buf);
|
||||
int (*fstat) (void *vfs_info, struct stat *buf);
|
||||
|
||||
vfsid (*getid)(struct vfs *me, char *path, struct vfs_stamping **parent);
|
||||
int (*nothingisopen)(vfsid id);
|
||||
void (*free)(vfsid id);
|
||||
int (*chmod) (vfs *me, char *path, int mode);
|
||||
int (*chown) (vfs *me, char *path, int owner, int group);
|
||||
int (*utime) (vfs *me, char *path, struct utimbuf *times);
|
||||
|
||||
char *(*getlocalcopy)(struct vfs *me, char *filename);
|
||||
void (*ungetlocalcopy)(struct vfs *me, char *filename, char *local, int has_changed);
|
||||
int (*readlink) (vfs *me, char *path, char *buf, int size);
|
||||
int (*symlink) (vfs *me, char *n1, char *n2);
|
||||
int (*link) (vfs *me, char *p1, char *p2);
|
||||
int (*unlink) (vfs *me, char *path);
|
||||
int (*rename) (vfs *me, char *p1, char *p2);
|
||||
int (*chdir) (vfs *me, char *path);
|
||||
int (*ferrno) (vfs *me);
|
||||
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod) (vfs *me, char *path, int mode, int dev);
|
||||
|
||||
int (*mkdir)(struct vfs *me, char *path, mode_t mode);
|
||||
int (*rmdir)(struct vfs *me, char *path);
|
||||
vfsid (*getid) (vfs *me, char *path, struct vfs_stamping **
|
||||
parent);
|
||||
|
||||
int (*ctl)(void *vfs_info, int ctlop, int arg);
|
||||
int (*setctl)(struct vfs *me, char *path, int ctlop, char *arg);
|
||||
int (*nothingisopen) (vfsid id);
|
||||
void (*free) (vfsid id);
|
||||
|
||||
char *(*getlocalcopy) (vfs *me, char *filename);
|
||||
void (*ungetlocalcopy) (vfs *me, char *filename, char *local,
|
||||
int has_changed);
|
||||
|
||||
int (*mkdir) (vfs *me, char *path, mode_t mode);
|
||||
int (*rmdir) (vfs *me, char *path);
|
||||
|
||||
int (*ctl) (void *vfs_info, int ctlop, int arg);
|
||||
int (*setctl) (vfs *me, char *path, int ctlop, char *arg);
|
||||
#ifdef HAVE_MMAP
|
||||
caddr_t (*mmap)(struct vfs *me, caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset);
|
||||
int (*munmap)(struct vfs *me, caddr_t addr, size_t len, void *vfs_info);
|
||||
caddr_t (*mmap) (vfs *me, caddr_t addr, size_t len, int prot,
|
||||
int flags, void *vfs_info, off_t offset);
|
||||
int (*munmap) (vfs *me, caddr_t addr, size_t len,
|
||||
void *vfs_info);
|
||||
#endif
|
||||
} vfs;
|
||||
};
|
||||
|
||||
/* Other file systems */
|
||||
extern vfs vfs_local_ops;
|
||||
@ -163,35 +174,36 @@ mas include called <sys/vfs.h>, which contains things like vfs_t.
|
||||
|
||||
/* Only the routines outside of the VFS module need the emulation macros */
|
||||
|
||||
int mc_open (char *file, int flags, ...);
|
||||
int mc_close (int handle);
|
||||
int mc_read (int handle, char *buffer, int count);
|
||||
int mc_write (int hanlde, char *buffer, int count);
|
||||
int mc_open (char *file, int flags, ...);
|
||||
int mc_close (int handle);
|
||||
int mc_read (int handle, char *buffer, int count);
|
||||
int mc_write (int hanlde, char *buffer, int count);
|
||||
off_t mc_lseek (int fd, off_t offset, int whence);
|
||||
int mc_chdir (char *);
|
||||
int mc_chdir (char *);
|
||||
|
||||
DIR *mc_opendir (char *dirname);
|
||||
DIR *mc_opendir (char *dirname);
|
||||
struct dirent *mc_readdir(DIR *dirp);
|
||||
int mc_closedir (DIR *dir);
|
||||
int mc_telldir (DIR *dir);
|
||||
void mc_seekdir (DIR *dir, int offset);
|
||||
|
||||
int mc_stat (char *path, struct stat *buf);
|
||||
int mc_stat (char *path, struct stat *buf);
|
||||
int mc_lstat (char *path, struct stat *buf);
|
||||
int mc_fstat (int fd, struct stat *buf);
|
||||
|
||||
int mc_chmod (char *path, int mode);
|
||||
int mc_chown (char *path, int owner, int group);
|
||||
int mc_utime (char *path, struct utimbuf *times);
|
||||
int mc_readlink(char *path, char *buf, int bufsiz);
|
||||
int mc_unlink (char *path);
|
||||
int mc_symlink (char *name1, char *name2);
|
||||
int mc_link (char *name1, char *name2);
|
||||
int mc_mknod (char *, int, int);
|
||||
int mc_rename (char *original, char *target);
|
||||
int mc_write (int fd, char *buf, int nbyte);
|
||||
int mc_rmdir (char *path);
|
||||
int mc_mkdir (char *path, mode_t mode);
|
||||
int mc_chmod (char *path, int mode);
|
||||
int mc_chown (char *path, int owner, int group);
|
||||
int mc_utime (char *path, struct utimbuf *times);
|
||||
int mc_readlink (char *path, char *buf, int bufsiz);
|
||||
int mc_unlink (char *path);
|
||||
int mc_symlink (char *name1, char *name2);
|
||||
int mc_link (char *name1, char *name2);
|
||||
int mc_mknod (char *, int, int);
|
||||
int mc_rename (char *original, char *target);
|
||||
int mc_write (int fd, char *buf, int nbyte);
|
||||
int mc_rmdir (char *path);
|
||||
int mc_mkdir (char *path, mode_t mode);
|
||||
|
||||
char *mc_getlocalcopy (char *filename);
|
||||
void mc_ungetlocalcopy (char *filename, char *local, int has_changed);
|
||||
char *mc_def_getlocalcopy (vfs *vfs, char *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user