* util.c: Remove unused functions.

* utilunix.c: Likewise.
* util.h: Update to match.
This commit is contained in:
Pavel Roskin 2002-07-29 23:12:31 +00:00
parent 0d360dca23
commit 6c7e1a46c8
4 changed files with 19 additions and 201 deletions

View File

@ -1,5 +1,9 @@
2002-07-29 Pavel Roskin <proski@gnu.org> 2002-07-29 Pavel Roskin <proski@gnu.org>
* util.c: Remove unused functions.
* utilunix.c: Likewise.
* util.h: Update to match.
* cons.saver.c: Use SEEK_SET instead of 0 in lseek(). * cons.saver.c: Use SEEK_SET instead of 0 in lseek().
* view.c: Likewise. * view.c: Likewise.

View File

@ -55,10 +55,8 @@
/* "$Id$" */ /* "$Id$" */
const char app_text [] = "Midnight-Commander"; static const char app_text [] = "Midnight-Commander";
int easy_patterns = 1; int easy_patterns = 1;
int tilde_trunc = 1;
#ifndef VFS_STANDALONE #ifndef VFS_STANDALONE
int is_printable (int c) int is_printable (int c)
@ -199,6 +197,7 @@ char *name_trunc (char *txt, int trunc_len)
static char x [MC_MAXPATHLEN+MC_MAXPATHLEN]; static char x [MC_MAXPATHLEN+MC_MAXPATHLEN];
int txt_len; int txt_len;
char *p; char *p;
const int tilde_trunc = 1;
if (!txt) if (!txt)
txt = PATH_SEP_STR; txt = PATH_SEP_STR;
@ -680,13 +679,6 @@ char *file_date (time_t when)
return timebuf; return timebuf;
} }
/* Like file_date, but packs the data to fit in 10 columns */
char *file_date_pck (time_t when)
{
/* FIXME: Should return only 10 chars, not 14 */
return file_date (when);
}
char *extract_line (char *s, char *top) char *extract_line (char *s, char *top)
{ {
static char tmp_line [BUF_MEDIUM]; static char tmp_line [BUF_MEDIUM];
@ -760,16 +752,6 @@ char *unix_error_string (int error_num)
} }
#ifndef VFS_STANDALONE #ifndef VFS_STANDALONE
long blocks2kilos (int blocks, int bsize)
{
if (bsize > 1024){
return blocks * (bsize / 1024);
} else if (bsize < 1024){
return blocks / (1024 /bsize);
} else
return blocks;
}
char *skip_separators (char *s) char *skip_separators (char *s)
{ {
for (;*s; s++) for (;*s; s++)
@ -910,51 +892,6 @@ decompress_extension (int type)
return 0; return 0;
} }
char *
decompress_command (int type)
{
switch (type){
case COMPRESSION_GZIP:
return "gzip -cdf";
case COMPRESSION_BZIP:
return "bzip -d";
case COMPRESSION_BZIP2:
return "bzip2 -d";
}
/* Should never reach this place */
fprintf (stderr, "Fatal: decompress_command called with an unknown argument\n");
return 0;
}
void
decompress_command_and_arg (int type, char **cmd, char **flags)
{
switch (type){
case COMPRESSION_GZIP:
*cmd = "gzip";
*flags = "-cdf";
return;
case COMPRESSION_BZIP:
*cmd = "bzip";
*flags = "-d";
return;
case COMPRESSION_BZIP2:
*cmd = "bzip2";
*flags = "-d";
return;
}
*cmd = 0;
*flags = 0;
/* Should never reach this place */
fprintf (stderr, "Fatal: decompress_command called with an unknown argument\n");
}
#ifndef VFS_STANDALONE #ifndef VFS_STANDALONE
/* Hooks */ /* Hooks */
void add_hook (Hook **hook_list, void (*hook_fn)(void *), void *data) void add_hook (Hook **hook_list, void (*hook_fn)(void *), void *data)
@ -1083,7 +1020,7 @@ char *reverse_string (char *string)
return string; return string;
} }
char *resolve_symlinks (char *path) static char *resolve_symlinks (char *path)
{ {
char *buf, *buf2, *p, *q, *r, c; char *buf, *buf2, *p, *q, *r, c;
int len; int len;
@ -1203,44 +1140,6 @@ char *diff_two_paths (char *first, char *second)
g_free (second); g_free (second);
return buf; return buf;
} }
#ifndef HAVE_TRUNCATE
/* On SCO and Windows NT systems */
int my_ftruncate (int fd, long size)
{
#ifdef OS2_NT
if(_chsize(fd, size))
return -1;
else
return 0;
#else
struct flock lk;
lk.l_whence = 0;
lk.l_start = size;
lk.l_len = 0;
return fcntl (fd, F_FREESP, &lk);
#endif /* !OS2_NT */
}
int truncate (const char *path, long size)
{
int fd;
int res;
fd = open (path, O_RDWR, 0);
if (fd < 0)
return fd;
res = my_ftruncate (fd, size);
close (fd);
if (res < 0)
return res;
return 0;
}
#endif /* !HAVE_TRUNCATE */
#endif /* !VFS_STANDALONE */ #endif /* !VFS_STANDALONE */
/* If filename is NULL, then we just append PATH_SEP to the dir */ /* If filename is NULL, then we just append PATH_SEP to the dir */

View File

@ -6,10 +6,6 @@
/* String managing functions */ /* String managing functions */
#if defined(SCO_FLAVOR) && defined(__GNUC__)
extern char*g_strdup (const char*);
#endif
int is_printable (int c); int is_printable (int c);
int msglen (char *text, int *lines); int msglen (char *text, int *lines);
char *trim (char *s, char *d, int len); char *trim (char *s, char *d, int len);
@ -32,12 +28,9 @@ char *strip_ctrl_codes (char *s);
char *convert_controls (char *s); char *convert_controls (char *s);
void wipe_password (char *passwd); void wipe_password (char *passwd);
char *reverse_string (char *string); char *reverse_string (char *string);
char *resolve_symlinks (char *path);
char *diff_two_paths (char *first, char *second); char *diff_two_paths (char *first, char *second);
int set_nonblocking (int fd);
char *x_basename (char *s); char *x_basename (char *s);
char *g_readlink (char *path);
/* Profile managing functions */ /* Profile managing functions */
int set_int (char *, char *, int); int set_int (char *, char *, int);
@ -62,7 +55,6 @@ char *get_owner (int);
size_t i18n_checktimelength (void); size_t i18n_checktimelength (void);
char *file_date (time_t); char *file_date (time_t);
char *file_date_pck (time_t);
int exist_file (char *name); int exist_file (char *name);
/* Returns a copy of *s until a \n is found and is below top */ /* Returns a copy of *s until a \n is found and is below top */
@ -89,7 +81,6 @@ void my_putenv (char*, char*);
#define EXECUTE_SETUID 8 #define EXECUTE_SETUID 8
#define EXECUTE_WAIT 16 #define EXECUTE_WAIT 16
int my_system (int flags, const char *shell, const char *command); int my_system (int flags, const char *shell, const char *command);
int my_system_get_child_pid (int flags, const char *shell, const char *command, pid_t *pid);
void save_stop_handler (void); void save_stop_handler (void);
extern struct sigaction startup_handler; extern struct sigaction startup_handler;
@ -100,7 +91,6 @@ char *tilde_expand (const char *);
char *canonicalize_pathname (char *); char *canonicalize_pathname (char *);
/* Misc Unix functions */ /* Misc Unix functions */
long blocks2kilos (int blocks, int bsize);
char *get_current_wd (char *buffer, int size); char *get_current_wd (char *buffer, int size);
int my_mkdir (char *s, mode_t mode); int my_mkdir (char *s, mode_t mode);
int my_rmdir (char *s); int my_rmdir (char *s);
@ -124,9 +114,7 @@ enum {
}; };
int get_compression_type (int fd); int get_compression_type (int fd);
char *decompress_command (int type);
char *decompress_extension (int type); char *decompress_extension (int type);
void decompress_command_and_arg (int type, char **cmd, char **flags);
int mc_doublepopen (int inhandle, int inlen, pid_t *tp, char *command, ...); int mc_doublepopen (int inhandle, int inlen, pid_t *tp, char *command, ...);
int mc_doublepclose (int pipehandle, pid_t pid); int mc_doublepclose (int pipehandle, pid_t pid);
@ -144,8 +132,6 @@ void execute_hooks (Hook *hook_list);
void delete_hook (Hook **hook_list, void (*hook_fn)(void *)); void delete_hook (Hook **hook_list, void (*hook_fn)(void *));
int hook_present (Hook *hook_list, void (*hook_fn)(void *)); int hook_present (Hook *hook_list, void (*hook_fn)(void *));
int max_open_files (void);
#ifdef OS2_NT #ifdef OS2_NT
# define PATH_SEP '\\' # define PATH_SEP '\\'
# define PATH_SEP_STR "\\" # define PATH_SEP_STR "\\"

View File

@ -44,31 +44,11 @@
struct sigaction startup_handler; struct sigaction startup_handler;
int
max_open_files (void)
{
static int files;
if (files)
return files;
#ifdef HAVE_SYSCONF
files = sysconf (_SC_OPEN_MAX);
if (files != -1)
return files;
#endif
#ifdef OPEN_MAX
return files = OPEN_MAX;
#else
return files = 256;
#endif
}
#ifndef VFS_STANDALONE #ifndef VFS_STANDALONE
/* uid of the MC user */ /* uid of the MC user */
uid_t current_user_uid = -1; static uid_t current_user_uid = -1;
/* List of the gids of the user */ /* List of the gids of the user */
GTree *current_user_gid = NULL; static GTree *current_user_gid = NULL;
/* Helper function to compare 2 gids */ /* Helper function to compare 2 gids */
static gint static gint
@ -335,15 +315,6 @@ char *tilde_expand (const char *directory)
} }
#ifndef VFS_STANDALONE #ifndef VFS_STANDALONE
int
set_nonblocking (int fd)
{
int val;
val = fcntl (fd, F_GETFL, 0);
val |= O_NONBLOCK;
return fcntl (fd, F_SETFL, val) != -1;
}
/* Pipes are guaranteed to be able to hold at least 4096 bytes */ /* Pipes are guaranteed to be able to hold at least 4096 bytes */
/* More than that would be unportable */ /* More than that would be unportable */
@ -675,6 +646,15 @@ int gettimeofday( struct timeval * tv, struct timezone * tz)
} }
#endif /* SCO_FLAVOR */ #endif /* SCO_FLAVOR */
#ifdef HAVE_GET_PROCESS_STATS
# include <sys/procstats.h>
int gettimeofday (struct timeval *tp, void *tzp)
{
return get_process_stats(tp, PS_SELF, 0, 0);
}
#endif /* HAVE_GET_PROCESS_STATS */
#ifndef HAVE_PUTENV #ifndef HAVE_PUTENV
/* The following piece of code was copied from the GNU C Library */ /* The following piece of code was copied from the GNU C Library */
@ -738,15 +718,6 @@ putenv (const char *string)
} }
#endif /* !HAVE_PUTENV */ #endif /* !HAVE_PUTENV */
#ifdef HAVE_GET_PROCESS_STATS
# include <sys/procstats.h>
int gettimeofday (struct timeval *tp, void *tzp)
{
return get_process_stats(tp, PS_SELF, 0, 0);
}
#endif
#ifdef SCO_FLAVOR #ifdef SCO_FLAVOR
/* Define this only for SCO */ /* Define this only for SCO */
#ifdef USE_NETCODE #ifdef USE_NETCODE
@ -783,7 +754,7 @@ int gettimeofday (struct timeval *tp, void *tzp)
/* s_pipe returns 0 if OK, -1 on error */ /* s_pipe returns 0 if OK, -1 on error */
/* two file descriptors are returned */ /* two file descriptors are returned */
int s_pipe(int fd[2]) static int s_pipe(int fd[2])
{ {
struct strfdinsert ins; /* stream I_FDINSERT ioctl format */ struct strfdinsert ins; /* stream I_FDINSERT ioctl format */
queue_t *pointer; queue_t *pointer;
@ -847,45 +818,3 @@ int socketpair(int dummy1, int dummy2, int dummy3, int fd[2])
#endif /* ifdef USE_NETCODE */ #endif /* ifdef USE_NETCODE */
#endif /* SCO_FLAVOR */ #endif /* SCO_FLAVOR */
#endif /* VFS_STANDALONE */ #endif /* VFS_STANDALONE */
char *
g_readlink (char *path)
{
char small_buffer [80];
char *str;
int n, size;
n = readlink (path, small_buffer, sizeof (small_buffer)-1);
if (n == -1)
return NULL;
if (n < sizeof (small_buffer)-1){
small_buffer [n] = 0;
return g_strdup (small_buffer);
}
str = NULL;
for (size = 256; size < 8192; size += 128){
if (str)
g_free (str);
str = g_malloc (size);
n = readlink (path, str, size-1);
if (n == -1){
g_free (str);
return NULL;
}
if (n < size-1){
char *s;
str [n] = 0;
s = g_strdup (str);
g_free (str);
return s;
}
}
str [n] = 0;
return str;
}