Browse Source

* names.c: Merge ...
* utilvfs.c: ... here.
* names.h: Merge ...
* utilvfs.h: ... here.
* Makefile.am: Remove references to names.c and names.h.

Pavel Roskin 21 years ago
parent
commit
0b99804da2
10 changed files with 87 additions and 114 deletions
  1. 6 0
      vfs/ChangeLog
  2. 0 2
      vfs/Makefile.am
  3. 0 2
      vfs/cpio.c
  4. 0 89
      vfs/names.c
  5. 0 7
      vfs/names.h
  6. 0 1
      vfs/tar.c
  7. 65 4
      vfs/utilvfs.c
  8. 16 1
      vfs/utilvfs.h
  9. 0 1
      vfs/vfs.c
  10. 0 7
      vfs/vfs.h

+ 6 - 0
vfs/ChangeLog

@@ -1,5 +1,11 @@
 2003-10-16  Pavel Roskin  <proski@gnu.org>
 
+	* names.c: Merge ...
+	* utilvfs.c: ... here.
+	* names.h: Merge ...
+	* utilvfs.h: ... here.
+	* Makefile.am: Remove references to names.c and names.h.
+
 	* xdirentry.h: Rename vfs_s_data to vfs_s_subclass.
 	* cpio.c: Initialize only non-zero fields in vfs_s_subclass.
 	* fish.c: Likewise.

+ 0 - 2
vfs/Makefile.am

@@ -17,7 +17,6 @@ BASICFILES = 			\
 	direntry.c		\
 	extfs.c 		\
 	local.c 		\
-	names.c			\
 	tar.c			\
 	sfs.c			\
 	vfs.c
@@ -28,7 +27,6 @@ VFSHDRS = 			\
 	local.h			\
 	mcfs.h 			\
 	mcfsutil.h 		\
-	names.h 		\
 	smbfs.h			\
 	tar.h 			\
 	tcputil.h 		\

+ 0 - 2
vfs/cpio.c

@@ -25,8 +25,6 @@
 /* #include "utilvfs.h" */
 
 #include "../src/dialog.h"
-/* #include "cpio.h" */
-#include "names.h"
 
 enum {
     STATUS_START,

+ 0 - 89
vfs/names.c

@@ -1,89 +0,0 @@
-/* Look up user and/or group names.
-   Copyright (C) 1988, 1992 Free Software Foundation
-
-   From GNU Tar.
-   
-GNU Tar is free software; you can redistribute it and/or modify it
-under the terms of the GNU Library General Public License as published
-by the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Tar 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 Library General Public License for more details.
-
- * Namespace: finduname, finduid, findgname, findgid.
- */
-
-/*
- * Look up a user or group name from a uid/gid, maintaining a cache.
- * FIXME, for now it's a one-entry cache.
- * FIXME2, the "-993" is to reduce the chance of a hit on the first lookup.
- * This file should be modified for non-unix systems to do something
- * reasonable.
- */
-
-#include <config.h>
-#include <sys/types.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <pwd.h>
-#include <grp.h>
-
-#include "names.h"
-
-#ifndef TUNMLEN
-#define TUNMLEN 256
-#endif
-#ifndef TGNMLEN
-#define TGNMLEN 256
-#endif
-
-static int saveuid = -993;
-static char saveuname[TUNMLEN];
-static int my_uid = -993;
-
-static int savegid = -993;
-static char savegname[TGNMLEN];
-static int my_gid = -993;
-
-#define myuid	( my_uid < 0? (my_uid = getuid()): my_uid )
-#define	mygid	( my_gid < 0? (my_gid = getgid()): my_gid )
-
-int
-finduid (char *uname)
-{
-    struct passwd *pw;
-
-    if (uname[0] != saveuname[0]	/* Quick test w/o proc call */
-	||0 != strncmp (uname, saveuname, TUNMLEN)) {
-	strncpy (saveuname, uname, TUNMLEN);
-	pw = getpwnam (uname);
-	if (pw) {
-	    saveuid = pw->pw_uid;
-	} else {
-	    saveuid = myuid;
-	}
-    }
-    return saveuid;
-}
-
-int
-findgid (char *gname)
-{
-    struct group *gr;
-
-    if (gname[0] != savegname[0]	/* Quick test w/o proc call */
-	||0 != strncmp (gname, savegname, TUNMLEN)) {
-	strncpy (savegname, gname, TUNMLEN);
-	gr = getgrnam (gname);
-	if (gr) {
-	    savegid = gr->gr_gid;
-	} else {
-	    savegid = mygid;
-	}
-    }
-    return savegid;
-}

+ 0 - 7
vfs/names.h

@@ -1,7 +0,0 @@
-#ifndef __NAMES_H
-#define __NAMES_H
-
-int finduid (char *name);
-int findgid (char *name);
-
-#endif /* __NAMES_H */

+ 0 - 1
vfs/tar.c

@@ -29,7 +29,6 @@
 
 #include "../src/dialog.h"	/* For MSG_ERROR */
 #include "tar.h"
-#include "names.h"
 
 static struct vfs_class vfs_tarfs_ops;
 

+ 65 - 4
vfs/utilvfs.c

@@ -1,7 +1,6 @@
 /* Utilities for VFS modules.
 
-   Currently includes login and tcp open socket routines.
-   
+   Copyright (C) 1988, 1992 Free Software Foundation
    Copyright (C) 1995, 1996 Miguel de Icaza
    
    This program is free software; you can redistribute it and/or
@@ -18,8 +17,6 @@
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-/* Namespace: exports vfs_split_url */
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -36,6 +33,8 @@
 #include <arpa/inet.h>
 #endif
 #include <errno.h>
+#include <pwd.h>
+#include <grp.h>
 
 #include "utilvfs.h"
 
@@ -146,3 +145,65 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
     g_free (pcopy);
     return retval;
 }
+
+/*
+ * Look up a user or group name from a uid/gid, maintaining a cache.
+ * FIXME, for now it's a one-entry cache.
+ * FIXME2, the "-993" is to reduce the chance of a hit on the first lookup.
+ * This file should be modified for non-unix systems to do something
+ * reasonable.
+ */
+
+#ifndef TUNMLEN
+#define TUNMLEN 256
+#endif
+#ifndef TGNMLEN
+#define TGNMLEN 256
+#endif
+
+#define myuid	( my_uid < 0? (my_uid = getuid()): my_uid )
+#define	mygid	( my_gid < 0? (my_gid = getgid()): my_gid )
+
+int
+finduid (char *uname)
+{
+    static int saveuid = -993;
+    static char saveuname[TUNMLEN];
+    static int my_uid = -993;
+
+    struct passwd *pw;
+
+    if (uname[0] != saveuname[0]	/* Quick test w/o proc call */
+	||0 != strncmp (uname, saveuname, TUNMLEN)) {
+	strncpy (saveuname, uname, TUNMLEN);
+	pw = getpwnam (uname);
+	if (pw) {
+	    saveuid = pw->pw_uid;
+	} else {
+	    saveuid = myuid;
+	}
+    }
+    return saveuid;
+}
+
+int
+findgid (char *gname)
+{
+    static int savegid = -993;
+    static char savegname[TGNMLEN];
+    static int my_gid = -993;
+
+    struct group *gr;
+
+    if (gname[0] != savegname[0]	/* Quick test w/o proc call */
+	||0 != strncmp (gname, savegname, TUNMLEN)) {
+	strncpy (savegname, gname, TUNMLEN);
+	gr = getgrnam (gname);
+	if (gr) {
+	    savegid = gr->gr_gid;
+	} else {
+	    savegid = mygid;
+	}
+    }
+    return savegid;
+}

+ 16 - 1
vfs/utilvfs.h

@@ -1,6 +1,21 @@
+#ifndef __UTILVFS_H
+#define __UTILVFS_H
+
 #include "../src/global.h"
 
 #include "../src/tty.h"		/* enable/disable interrupt key */
 #include "../src/wtools.h"	/* MSG_ERROR */
-#include "../src/background.h"  /* message_1s */
+#include "../src/background.h"	/* message_1s */
 #include "../src/main.h"	/* print_vfs_message */
+
+/* Flags for vfs_split_url() */
+#define URL_ALLOW_ANON 1
+#define URL_NOSLASH 2
+
+char *vfs_split_url (const char *path, char **host, char **user, int *port,
+		     char **pass, int default_port, int flags);
+
+int finduid (char *name);
+int findgid (char *name);
+
+#endif				/* !__UTILVFS_H */

+ 0 - 1
vfs/vfs.c

@@ -49,7 +49,6 @@
 
 #include "vfs.h"
 #include "extfs.h"		/* FIXME: we should not know anything about our modules */
-#include "names.h"
 #ifdef USE_NETCODE
 #   include "tcputil.h"
 #endif

+ 0 - 7
vfs/vfs.h

@@ -201,13 +201,6 @@ int vfs_parse_filedate (int idx, time_t * t);
 void vfs_die (const char *msg);
 char *vfs_get_password (char *msg);
 
-/* Flags for vfs_split_url() */
-#define URL_ALLOW_ANON 1
-#define URL_NOSLASH 2
-
-char *vfs_split_url (const char *path, char **host, char **user, int *port,
-		     char **pass, int default_port, int flags);
-
 #ifdef WITH_SMBFS
 /* Interface for requesting SMB credentials.  */
 struct smb_authinfo {