Browse Source

Fixup of conditions for networking VFS.

Clean up of code duplicate in configure.ac.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 14 years ago
parent
commit
11c00959f3
6 changed files with 38 additions and 52 deletions
  1. 0 15
      configure.ac
  2. 2 2
      lib/vfs/mc-vfs/direntry.c
  3. 2 2
      lib/vfs/mc-vfs/vfs.c
  4. 26 25
      m4.include/mc-vfs.m4
  5. 5 5
      src/cmd.c
  6. 3 3
      src/main.c

+ 0 - 15
configure.ac

@@ -280,14 +280,6 @@ if test x$with_glib_static = xyes; then
     GLIB_LIBS="$new_GLIB_LIBS"
 fi
 
-
-dnl
-dnl Network related functions
-dnl
-
-AC_SEARCH_LIBS([socket], [socket])
-AC_SEARCH_LIBS([gethostbyname], [nsl])
-
 dnl
 dnl Sequent wants getprocessstats
 dnl
@@ -299,12 +291,6 @@ have to use that instead of gettimeofday])])
 
 AC_MC_VFS_CHECKS
 
-vfs_type="normal"
-if test x$enable_vfs = xyes; then
-	AC_MSG_NOTICE([enabling VFS code])
-	vfs_type="Midnight Commander Virtual File System"
-fi
-
 dnl
 dnl Check for gpm mouse support (Linux only)
 dnl
@@ -539,7 +525,6 @@ AM_CONDITIONAL(USE_MAINTAINER_MODE, [test x"$USE_MAINTAINER_MODE" = xyes])
 AM_CONDITIONAL(USE_SCREEN_SLANG, [test x"$with_screen" = xslang])
 AM_CONDITIONAL(USE_EDIT, [test -n "$use_edit"])
 AM_CONDITIONAL(USE_DIFF, [test -n "$use_diff"])
-AM_CONDITIONAL(ENABLE_VFS_NET, [test x"$use_net_code" = xtrue])
 AM_CONDITIONAL(CHARSET, [test -n "$have_charset"])
 AM_CONDITIONAL(CONS_SAVER, [test -n "$cons_saver"])
 

+ 2 - 2
lib/vfs/mc-vfs/direntry.c

@@ -1232,7 +1232,7 @@ vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub)
 
 /* ----------- Utility functions for networked filesystems  -------------- */
 
-#ifdef USE_NETCODE
+#ifdef ENABLE_VFS_NET
 int
 vfs_s_select_on_two (int fd1, int fd2)
 {
@@ -1330,4 +1330,4 @@ vfs_s_get_line_interruptible (struct vfs_class *me, char *buffer, int size, int
     buffer[size - 1] = 0;
     return 0;
 }
-#endif /* USE_NETCODE */
+#endif /* ENABLE_VFS_NET */

+ 2 - 2
lib/vfs/mc-vfs/vfs.c

@@ -62,8 +62,8 @@
 #include "utilvfs.h"
 #include "gc.h"
 #include "vfs.h"
-#ifdef USE_NETCODE
-#   include "netutil.h"
+#ifdef ENABLE_VFS_NET
+#include "netutil.h"
 #endif
 #ifdef ENABLE_VFS_FTP
 #include "ftpfs.h"

+ 26 - 25
m4.include/mc-vfs.m4

@@ -27,45 +27,37 @@ dnl     Sets shell variable enable_vfs to yes (default, --with-vfs) or
 dnl        "no" (--without-vfs).
 
 dnl Private define
-AC_DEFUN([MC_WITH_VFS],
+AC_DEFUN([MC_ENABLE_VFS_NET],
 [
-    use_net_code=false
-
-    AC_ARG_ENABLE([netcode],
-		[  --enable-netcode        Support for networking [[yes]]])
-
-    if test "x$enable_netcode" != xno; then
-	dnl FIXME: network checks should probably be in their own macro.
-	AC_SEARCH_LIBS(socket, [xnet bsd socket inet], [have_socket=yes])
-	if test x"$have_socket" = xyes; then
-	    AC_SEARCH_LIBS(gethostbyname, [bsd socket inet netinet])
-	    AC_CHECK_MEMBERS([struct linger.l_linger], , , [
+    dnl FIXME: network checks should probably be in their own macro.
+    AC_REQUIRE_SOCKET
+    if test x"$have_socket" = xyes; then
+	AC_CHECK_TYPE(nlink_t, unsigned int)
+	AC_CHECK_TYPES([socklen_t],,,
+	    [
 #include <sys/types.h>
 #include <sys/socket.h>
 	    ])
 
-	    AC_CHECK_RPC
-	    AC_REQUIRE_SOCKET
+	AC_CHECK_RPC
 
-      use_net_code=true
+	enable_vfs_net=yes
     fi
-  fi
-
-  AC_DEFINE(ENABLE_VFS, 1, [Define to enable VFS support])
-  if $use_net_code; then
-    AC_DEFINE(USE_NETCODE, 1, [Define to use networked VFS])
-  fi
 ])
 
-AC_DEFUN([AC_MC_VFS_CHECKS],[
+AC_DEFUN([AC_MC_VFS_CHECKS],
+[
+    vfs_type="normal"
+    enable_vfs_net=no
+
     AC_ARG_ENABLE([vfs],
-                  [  --disable-vfs           Disable VFS])
+		AC_HELP_STRING([--disable-vfs], [Disable VFS]))
+
     if test x"$enable_vfs" != x"no" ; then
 	enable_vfs="yes"
 	vfs_type="Midnight Commander Virtual Filesystem"
-
 	AC_MSG_NOTICE([Enabling VFS code])
-	MC_WITH_VFS
+	AC_DEFINE(ENABLE_VFS, [1], [Define to enable VFS support])
     fi
 
     AC_MC_VFS_CPIOFS
@@ -78,4 +70,13 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[
     AC_MC_VFS_SMB
 
     AM_CONDITIONAL(ENABLE_VFS, [test x"$enable_vfs" = x"yes"])
+
+    if test x"$enable_vfs_ftp" = x"yes" -o x"$enable_vfs_fish" = x"yes" -o x"$enable_vfs_smb" = x"yes"; then
+	MC_ENABLE_VFS_NET
+	if test x"$enable_vfs_net" = x"yes"; then
+	    AC_DEFINE([ENABLE_VFS_NET], [1], [Support for network filesystems])
+	fi
+    fi
+
+    AM_CONDITIONAL([ENABLE_VFS_NET], [test x"$enable_vfs_net" = x"yes"])
 ])

+ 5 - 5
src/cmd.c

@@ -35,7 +35,7 @@
 #ifdef HAVE_MMAP
 #   include <sys/mman.h>
 #endif
-#ifdef USE_NETCODE
+#ifdef ENABLE_VFS_NET
 #include <netdb.h>
 #endif
 #include <unistd.h>
@@ -1222,7 +1222,7 @@ get_random_hint (int force)
     return result;
 }
 
-#if defined(USE_NETCODE) || defined(ENABLE_VFS_UNDELFS)
+#if defined(ENABLE_VFS_UNDELFS) || defined(ENABLE_VFS_NET)
 static void
 nice_cd (const char *text, const char *xtext, const char *help,
          const char *history_name, const char *prefix, int to_home)
@@ -1252,10 +1252,10 @@ nice_cd (const char *text, const char *xtext, const char *help,
     g_free (cd_path);
     g_free (machine);
 }
-#endif /* USE_NETCODE || ENABLE_VFS_UNDELFS */
+#endif /* ENABLE_VFS_UNDELFS || ENABLE_VFS_NET*/
 
 
-#if defined (ENABLE_VFS_FTP) || defined (ENABLE_VFS_FISH) || defined (ENABLE_VFS_SMB)
+#ifdef ENABLE_VFS_NET
 
 static const char *machine_str = N_("Enter machine name (F1 for details):");
 
@@ -1286,7 +1286,7 @@ smblink_cmd (void)
              "[SMB File System]", ":smblink_cmd: SMB link to machine ", "/#smb:", 0);
 }
 #endif /* ENABLE_VFS_SMB */
-#endif /* ENABLE_VFS_FTP || ENABLE_VFS_FISH || ENABLE_VFS_SMB */
+#endif /* ENABLE_VFS_NET */
 
 #ifdef ENABLE_VFS_UNDELFS
 void

+ 3 - 3
src/main.c

@@ -672,7 +672,7 @@ create_panel_menu (void)
 #ifdef HAVE_CHARSET
     entries = g_list_append (entries, menu_entry_create (_("&Encoding..."),     CK_PanelSetPanelEncoding));
 #endif
-#if defined(ENABLE_VFS_FTP) || defined(ENABLE_VFS_FISH) || defined(ENABLE_VFS_SMB)
+#ifdef ENABLE_VFS_NET
     entries = g_list_append (entries, menu_separator_create ());
 #ifdef ENABLE_VFS_FTP
     entries = g_list_append (entries, menu_entry_create (_("FT&P link..."), CK_FtplinkCmd));
@@ -682,8 +682,8 @@ create_panel_menu (void)
 #endif
 #ifdef ENABLE_VFS_SMB
     entries = g_list_append (entries, menu_entry_create (_("SM&B link..."), CK_SmblinkCmd));
-#endif /* ENABLE_VFS_SMB */
-#endif /* ENABLE_VFS_FTP || ENABLE_VFS_FISH || ENABLE_VFS_SMB */
+#endif
+#endif /* ENABLE_VFS_NET */
     entries = g_list_append (entries, menu_separator_create ());
     entries = g_list_append (entries, menu_entry_create (_("&Rescan"), CK_RereadCmd));