From 3979e2f3853f12790706065b1aff48814d6c66fe Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 3 Nov 1999 09:25:29 +0000 Subject: [PATCH] r103: Added config.h.in autoconf header file. Mount point code should be autodetected now. --- ROX-Filer/src/Makefile.in | 2 +- ROX-Filer/src/config.h.in | 4 ++++ ROX-Filer/src/configure.in | 10 ++++++++- ROX-Filer/src/menu.c | 8 ++++++++ ROX-Filer/src/mount.c | 51 ++++++++++++++++++++++++---------------------- ROX-Filer/src/mount.h | 4 ++++ 6 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 ROX-Filer/src/config.h.in diff --git a/ROX-Filer/src/Makefile.in b/ROX-Filer/src/Makefile.in index c6c92547..5fba5da3 100644 --- a/ROX-Filer/src/Makefile.in +++ b/ROX-Filer/src/Makefile.in @@ -8,7 +8,7 @@ GTK_LIBS = @GTK_LIBS@ .SUFFIXES: .c .o CC = @CC@ -CFLAGS = @CFLAGS@ `gtk-config --cflags` +CFLAGS = @CFLAGS@ `gtk-config --cflags` -I. LDFLAGS = @LDFLAGS@ `gtk-config --libs` EXEC = ${PLATFORM_DIR}/${PROG} diff --git a/ROX-Filer/src/config.h.in b/ROX-Filer/src/config.h.in new file mode 100644 index 00000000..4e7f3acf --- /dev/null +++ b/ROX-Filer/src/config.h.in @@ -0,0 +1,4 @@ +/* The configure script will auto-generate config.h from config.h.in */ + +#undef HAVE_SYS_UCRED_H +#undef HAVE_MNTENT_H diff --git a/ROX-Filer/src/configure.in b/ROX-Filer/src/configure.in index e3308fdf..9a2f5d7f 100644 --- a/ROX-Filer/src/configure.in +++ b/ROX-Filer/src/configure.in @@ -1,9 +1,9 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(main.c) +AC_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC -AC_PROG_MAKE_SET dnl Use -Wall if possible changequote(,)dnl @@ -16,10 +16,18 @@ fi changequote([,])dnl dnl Checks for header files. +AC_PATH_X +AC_HEADER_DIRENT AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h mntent.h sys/ucred.h) dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_UID_T +AC_TYPE_SIZE_T dnl Checks for library functions. +AC_CHECK_FUNCS(gethostname mkdir rmdir strdup strtol) AC_OUTPUT(Makefile) diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index f478f4bf..07d4b71d 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -7,6 +7,7 @@ /* menu.c - code for handling the popup menu */ +#include #include #include #include @@ -30,6 +31,7 @@ #include "options.h" #include "choices.h" #include "savebox.h" +#include "mount.h" #define C_ "" @@ -792,6 +794,7 @@ static void help(gpointer data, guint action, GtkWidget *widget) static void mount(gpointer data, guint action, GtkWidget *widget) { +#ifdef DO_MOUNT_POINTS FileItem *item; int i; Collection *collection; @@ -830,6 +833,11 @@ static void mount(gpointer data, guint action, GtkWidget *widget) if (error) report_error("ROX-Filer", error); +#else + report_error("ROX-Filer", + "ROX-Filer does not yet support mount points on your " + "system. Sorry."); +#endif /* DO_MOUNT_POINTS */ } static void select_all(gpointer data, guint action, GtkWidget *widget) diff --git a/ROX-Filer/src/mount.c b/ROX-Filer/src/mount.c index 77a2b113..6b488406 100644 --- a/ROX-Filer/src/mount.c +++ b/ROX-Filer/src/mount.c @@ -7,19 +7,13 @@ /* mount.c - code for handling mount points */ -/* Note: changes for NetBSD may also apply to Solaris... */ - -/* mtab_time not needed under NetBSD as there is no mtab file to - * check the only solution is to ask the kernel. - */ -#ifndef __NetBSD__ -# define HAVE_MTAB -#endif - +#include #include -#ifdef HAVE_MTAB +#ifdef HAVE_MNTENT_H + /* Linux, etc */ # include -#else +#elif HAVE_SYS_UCRED_H + /* NetBSD, etc */ # include # include # include @@ -39,38 +33,42 @@ GHashTable *fstab_mounts = NULL; GHashTable *mtab_mounts = NULL; time_t fstab_time; -#ifdef HAVE_MTAB +#ifdef HAVE_MNTENT_H time_t mtab_time; #endif /* Static prototypes */ -#ifndef HAVE_MTAB +#ifdef HAVE_SYS_UCRED_H static GHashTable *build_mtab_table(GHashTable *mount_points); #endif +#ifdef DO_MOUNT_POINTS static GHashTable *read_table(GHashTable *mount_points, char *path); -static time_t read_time(char *path); -static gboolean free_mp(gpointer key, gpointer value, gpointer data); static void clear_table(GHashTable *table); static time_t read_time(char *path); +static gboolean free_mp(gpointer key, gpointer value, gpointer data); +#endif void mount_init() { fstab_mounts = g_hash_table_new(g_str_hash, g_str_equal); mtab_mounts = g_hash_table_new(g_str_hash, g_str_equal); +#ifdef DO_MOUNT_POINTS fstab_time = read_time("/etc/fstab"); read_table(fstab_mounts, "/etc/fstab"); -#ifdef HAVE_MTAB +# ifdef HAVE_MNTENT_H mtab_time = read_time("/etc/mtab"); read_table(mtab_mounts, "/etc/mtab"); -#else +# elif HAVE_SYS_UCRED_H /* mtab_time not used */ build_mtab_table(mtab_mounts); -#endif +# endif +#endif /* DO_MOUNT_POINTS */ } void mount_update() { +#ifdef DO_MOUNT_POINTS time_t time; /* Ensure everything is uptodate */ @@ -80,19 +78,22 @@ void mount_update() fstab_time = time; read_table(fstab_mounts, "/etc/fstab"); } -#ifdef HAVE_MTAB +# ifdef HAVE_MNTENT_H time = read_time("/etc/mtab"); if (time != mtab_time) { mtab_time = time; read_table(mtab_mounts, "/etc/mtab"); } -#else +# else build_mtab_table(mtab_mounts); -#endif +# endif +#endif /* DO_MOUNT_POINTS */ } +#ifdef DO_MOUNT_POINTS + static gboolean free_mp(gpointer key, gpointer value, gpointer data) { MountPoint *mp = (MountPoint *) value; @@ -120,7 +121,9 @@ static time_t read_time(char *path) return info.st_mtime; } -#ifdef HAVE_MTAB +#endif + +#ifdef HAVE_MNTENT_H static GHashTable *read_table(GHashTable *mount_points, char *path) { FILE *tab; @@ -149,7 +152,7 @@ static GHashTable *read_table(GHashTable *mount_points, char *path) return mount_points; } -#else /* We don't have /etc/mtab */ +#elif HAVE_SYS_UCRED_H /* We don't have /etc/mtab */ static GHashTable *read_table(GHashTable *mount_points, char *path) { @@ -222,4 +225,4 @@ static GHashTable *build_mtab_table(GHashTable *mount_points) return mount_points; } -#endif /* HAVE_MTAB */ +#endif diff --git a/ROX-Filer/src/mount.h b/ROX-Filer/src/mount.h index 5b0f42f7..450c8277 100644 --- a/ROX-Filer/src/mount.h +++ b/ROX-Filer/src/mount.h @@ -8,6 +8,10 @@ #ifndef _MOUNT_H #define _MOUNT_H +# if defined(HAVE_MNTENT_H) || defined(HAVE_SYS_UCRED_H) +# define DO_MOUNT_POINTS +# endif + extern GHashTable *fstab_mounts; extern GHashTable *mtab_mounts; -- 2.11.4.GIT