summaryrefslogtreecommitdiff
path: root/examples/loadables/finfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/loadables/finfo.c')
-rw-r--r--examples/loadables/finfo.c96
1 files changed, 22 insertions, 74 deletions
diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c
index 6491ef0e..64a9e910 100644
--- a/examples/loadables/finfo.c
+++ b/examples/loadables/finfo.c
@@ -6,7 +6,7 @@
*/
/*
- Copyright (C) 1999-2009,2022 Free Software Foundation, Inc.
+ Copyright (C) 1999-2009,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -96,8 +96,7 @@ static int pmask;
#define OPTIONS "acdgiflmnopsuACGMP:U"
static int
-octal(s)
-char *s;
+octal(char *s)
{
int r;
@@ -108,9 +107,7 @@ char *s;
}
static int
-finfo_main(argc, argv)
-int argc;
-char **argv;
+finfo_main(int argc, char **argv)
{
register int i;
int mode, flags, opt;
@@ -162,8 +159,7 @@ char **argv;
}
static struct stat *
-getstat(f)
-char *f;
+getstat(char *f)
{
static struct stat st;
int fd, r;
@@ -190,8 +186,7 @@ char *f;
}
static int
-printfinfo(f)
-char *f;
+printfinfo(char *f)
{
struct stat *st;
@@ -200,15 +195,13 @@ char *f;
}
static int
-getperm(m)
-int m;
+getperm(int m)
{
return (m & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID));
}
static void
-perms(m)
-int m;
+perms(int m)
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;
@@ -251,8 +244,7 @@ int m;
}
static void
-printmode(mode)
-int mode;
+printmode(int mode)
{
if (S_ISBLK(mode))
printf("S_IFBLK ");
@@ -277,8 +269,7 @@ int mode;
}
static int
-printst(st)
-struct stat *st;
+printst(struct stat *st)
{
struct passwd *pw;
struct group *gr;
@@ -314,9 +305,7 @@ struct stat *st;
}
static int
-printsome(f, flags)
-char *f;
-int flags;
+printsome(char *f, int flags)
{
struct stat *st;
struct passwd *pw;
@@ -400,8 +389,7 @@ int flags;
#ifndef NOBUILTIN
int
-finfo_builtin(list)
- WORD_LIST *list;
+finfo_builtin(WORD_LIST *list)
{
int c, r;
char **v;
@@ -456,34 +444,26 @@ struct builtin finfo_struct = {
#endif
#ifdef NOBUILTIN
-#if defined (PREFER_STDARG)
-# include <stdarg.h>
-#else
-# if defined (PREFER_VARARGS)
-# include <varargs.h>
-# endif
-#endif
+#include <stdarg.h>
char *this_command_name;
-main(argc, argv)
-int argc;
-char **argv;
+int
+main(int argc, char **argv)
{
this_command_name = argv[0];
exit(finfo_main(argc, argv));
}
void
-builtin_usage()
+builtin_usage(void)
{
fprintf(stderr, "%s: usage: %s [-%s] [file ...]\n", prog, prog, OPTIONS);
}
#ifndef HAVE_STRERROR
char *
-strerror(e)
-int e;
+strerror(int e)
{
static char ebuf[40];
extern int sys_nerr;
@@ -497,23 +477,20 @@ int e;
}
#endif
-char *
-xmalloc(s)
-size_t s;
+PTR_T
+xmalloc(size_t s)
{
char *ret;
- extern char *malloc();
ret = malloc(s);
if (ret)
return (ret);
- fprintf(stderr, "%s: cannot malloc %d bytes\n", prog, s);
+ fprintf(stderr, "%s: cannot malloc %zu bytes\n", prog, s);
exit(1);
}
char *
-base_pathname(p)
-char *p;
+base_pathname(char *p)
{
char *t;
@@ -523,9 +500,7 @@ char *p;
}
int
-legal_number (string, result)
- char *string;
- long *result;
+legal_number (char *string, long result)
{
int sign;
long value;
@@ -584,9 +559,7 @@ extern int optind;
extern char *optarg;
int
-sh_getopt(c, v, o)
-int c;
-char **v, *o;
+sh_getopt(int c, char **v, char *o)
{
int r;
@@ -596,43 +569,18 @@ char **v, *o;
return r;
}
-#if defined (USE_VARARGS)
void
-#if defined (PREFER_STDARG)
builtin_error (const char *format, ...)
-#else
-builtin_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
-#if defined (PREFER_STDARG)
va_start (args, format);
-#else
- va_start (args);
-#endif
vfprintf (stderr, format, args);
va_end (args);
fprintf (stderr, "\n");
}
-#else
-void
-builtin_error (format, arg1, arg2, arg3, arg4, arg5)
- char *format, *arg1, *arg2, *arg3, *arg4, *arg5;
-{
- if (this_command_name && *this_command_name)
- fprintf (stderr, "%s: ", this_command_name);
-
- fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
- fprintf (stderr, "\n");
- fflush (stderr);
-}
-#endif /* !USE_VARARGS */
-
#endif