declare lots of functions static.
#include "system.h"
char *basename ();
-void remove_suffix ();
void strip_trailing_slashes ();
+static void remove_suffix ();
+
void
main (argc, argv)
int argc;
/* Remove SUFFIX from the end of NAME if it is there, unless NAME
consists entirely of SUFFIX. */
-void
+static void
remove_suffix (name, suffix)
register char *name, *suffix;
{
time_t get_date ();
time_t posixtime ();
void error ();
-void show_date ();
-void usage ();
+
+static void show_date ();
+static void usage ();
/* putenv string to use Universal Coordinated Time.
POSIX.2 says it should be "TZ=UCT0" or "TZ=GMT0". */
in FORMAT, followed by a newline. If FORMAT is NULL, use the
standard output format (ctime style but with a timezone inserted). */
-void
+static void
show_date (format, when)
char *format;
time_t when;
free (out);
}
-void
+static void
usage ()
{
fprintf (stderr, "\
register char *s = argv[0];
register int c;
- while (c = *s++)
+ while ((c = *s++))
{
if (c == '\\' && *s)
{
int putenv ();
void error ();
-void usage ();
+
+static void usage ();
extern char **environ;
/* The name by which this program was run. */
char *program_name;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"ignore-environment", 0, NULL, 'i'},
{"unset", 1, NULL, 'u'},
error (errno == ENOENT ? 127 : 126, errno, "%s", argv[optind]);
}
-void
+static void
usage ()
{
fprintf (stderr, "\
/* The name this program was run with. */
char *program_name;
-VALUE *docolon ();
-VALUE *eval ();
-VALUE *int_value ();
-VALUE *str_value ();
+void error ();
char *xstrdup ();
char *strstr ();
char *xmalloc ();
-int isstring ();
-int nextarg ();
-int nomoreargs ();
-int null ();
-int toarith ();
-void error ();
-void freev ();
-void printv ();
-void tostring ();
-void trace ();
+
+static VALUE *docolon ();
+static VALUE *eval ();
+static VALUE *int_value ();
+static VALUE *str_value ();
+static int isstring ();
+static int nextarg ();
+static int nomoreargs ();
+static int null ();
+static int toarith ();
+static void freev ();
+static void printv ();
+static void tostring ();
+
+#ifdef EVAL_TRACE
+static void trace ();
+#endif
void
main (argc, argv)
/* Return a VALUE for I. */
-VALUE *
+static VALUE *
int_value (i)
int i;
{
/* Return a VALUE for S. */
-VALUE *
+static VALUE *
str_value (s)
char *s;
{
/* Free VALUE V, including structure components. */
-void
+static void
freev (v)
VALUE *v;
{
/* Print VALUE V. */
-void
+static void
printv (v)
VALUE *v;
{
/* Return nonzero if V is a null-string or zero-number. */
-int
+static int
null (v)
VALUE *v;
{
/* Return nonzero if V is a string value. */
-int
+static int
isstring (v)
VALUE *v;
{
/* Coerce V to a string value (can't fail). */
-void
+static void
tostring (v)
VALUE *v;
{
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
-int
+static int
toarith (v)
VALUE *v;
{
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
-int
+static int
nextarg (str)
char *str;
{
/* Return nonzero if there no more tokens. */
-int
+static int
nomoreargs ()
{
return *args == 0;
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
+static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (isstring (l) || isstring (r)) \
else \
return l->u.i rel r->u.i; \
}
-
cmpf (less_than, <)
cmpf (less_equal, <=)
cmpf (equal, ==)
/* The arithmetic operator handling functions. */
#define arithf(name, op) \
+static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
#ifdef EVAL_TRACE
/* Print evaluation trace and args remaining. */
-void
+static void
trace (fxn)
char *fxn;
{
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
-VALUE *
+static VALUE *
docolon (sv, pv)
VALUE *sv;
VALUE *pv;
/* Handle bare operands and ( expr ) syntax. */
-VALUE *
+static VALUE *
eval7 ()
{
VALUE *v;
/* Handle match, substr, index, and length keywords. */
-VALUE *
+static VALUE *
eval6 ()
{
VALUE *l;
/* Handle : operator (pattern matching).
Calls docolon to do the real work. */
-VALUE *
+static VALUE *
eval5 ()
{
VALUE *l;
/* Handle *, /, % operators. */
-VALUE *
+static VALUE *
eval4 ()
{
VALUE *l;
/* Handle +, - operators. */
-VALUE *
+static VALUE *
eval3 ()
{
VALUE *l;
/* Handle comparisons. */
-VALUE *
+static VALUE *
eval2 ()
{
VALUE *l;
/* Handle &. */
-VALUE *
+static VALUE *
eval1 ()
{
VALUE *l;
/* Handle |. */
-VALUE *
+static VALUE *
eval ()
{
VALUE *l;
char *xmalloc ();
int getugroups ();
void error ();
-void print_user ();
-void print_group ();
-void print_group_list ();
-void print_full_info ();
-void usage ();
+
+static void print_user ();
+static void print_group ();
+static void print_group_list ();
+static void print_full_info ();
+static void usage ();
/* The name this program was run with. */
char *program_name;
/* The number of errors encountered so far. */
static int problems = 0;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"group", 0, NULL, 'g'},
{"name", 0, NULL, 'n'},
/* Print the name or value of user ID UID. */
-void
+static void
print_user (uid)
int uid;
{
/* Print the name or value of group ID GID. */
-void
+static void
print_group (gid)
int gid;
{
/* Print all of the distinct groups the user is in . */
-void
+static void
print_group_list (username)
char *username;
{
/* Print all of the info about the user's user and group IDs. */
-void
+static void
print_full_info (username)
char *username;
{
#endif
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#endif
#include "system.h"
-int isinteger ();
void error ();
-void usage ();
+
+static int isinteger ();
+static void usage ();
/* The name this program was run with. */
char *program_name;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"adjustment", 1, NULL, 'n'},
{NULL, 0, NULL, 0}
/* Return nonzero if S represents a (possibly signed) decimal integer,
zero if not. */
-int
+static int
isinteger (s)
char *s;
{
return 1;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#endif
char *xstrdup();
-int validate_path ();
void error ();
-void usage ();
+
+static int validate_path ();
+static void usage ();
/* The name this program was run with. */
char *program_name;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"portability", 0, NULL, 'p'},
{NULL, 0, NULL, 0}
/* Each element is nonzero if the corresponding ASCII character is
in the POSIX portable character set, and zero if it is not.
In addition, the entry for `/' is nonzero to simplify checking. */
-static char portable_chars[] =
+static char const portable_chars[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0-15 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16-31 */
/* If PATH contains only portable characters, return 1, else 0. */
-int
+static int
portable_chars_only (path)
char *path;
{
char *p;
for (p = path; *p; ++p)
- if (portable_chars[*p] == 0)
+ if (portable_chars[(unsigned char)*p] == 0)
{
error (0, 0, "path `%s' contains nonportable character `%c'",
path, *p);
/* Return 1 if PATH is a usable leading directory, 0 if not,
2 if it doesn't exist. */
-int
+static int
dir_ok (path)
char *path;
{
Return 0 if all of these tests are successful, 1 if any fail. */
-int
+static int
validate_path (path, portability)
char *path;
int portability;
return 0;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#define octtobin(c) ((c) - '0')
char *xmalloc ();
-double xstrtod ();
-int print_esc ();
-int print_formatted ();
-long xstrtol ();
-unsigned long xstrtoul ();
void error ();
-void print_direc ();
-void print_esc_char ();
-void print_esc_string ();
-void verify ();
+
+static double xstrtod ();
+static int print_esc ();
+static int print_formatted ();
+static long xstrtol ();
+static unsigned long xstrtoul ();
+static void print_direc ();
+static void print_esc_char ();
+static void print_esc_string ();
+static void verify ();
/* The name this program was run with. */
char *program_name;
arguments to any `%' directives.
Return the number of elements of ARGV used. */
-int
+static int
print_formatted (format, argc, argv)
char *format;
int argc;
Return the number of characters in the escape sequence
besides the backslash. */
-int
+static int
print_esc (escstart)
char *escstart;
{
/* Output a single-character \ escape. */
-void
+static void
print_esc_char (c)
char c;
{
/* Print string STR, evaluating \ escapes. */
-void
+static void
print_esc_string (str)
char *str;
{
If FIELD_WIDTH or PRECISION is non-negative, they are args for
'*' values in those fields. */
-void
+static void
print_direc (start, length, field_width, precision, argument)
char *start;
int length;
free (p);
}
-unsigned long
+static unsigned long
xstrtoul (s)
char *s;
{
return val;
}
-long
+static long
xstrtol (s)
char *s;
{
return val;
}
-double
+static double
xstrtod (s)
char *s;
{
return val;
}
-void
+static void
verify (s, end)
char *s, *end;
{
#include <sys/types.h>
#include "system.h"
-long argdecode ();
void error ();
+static long argdecode ();
+
/* The name by which this program was run. */
char *program_name;
exit (0);
}
-long
+static long
argdecode (s)
char *s;
{
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
-void log_su ();
+static void log_su ();
#else
#ifdef SYSLOG_SUCCESS
#undef SYSLOG_SUCCESS
void setusershell ();
char *basename ();
-char *concat ();
char *xmalloc ();
char *xrealloc ();
-int correct_password ();
-int elements ();
-int restricted_shell ();
-void change_identity ();
void error ();
-void modify_environment ();
-void run_shell ();
-void usage ();
-void xputenv ();
+
+static char *concat ();
+static int correct_password ();
+static int elements ();
+static int restricted_shell ();
+static void change_identity ();
+static void modify_environment ();
+static void run_shell ();
+static void usage ();
+static void xputenv ();
extern char **environ;
/* If nonzero, change some environment vars to indicate the user su'd to. */
static int change_environment;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"command", 1, 0, 'c'},
{"fast", 0, &fast_startup, 1},
0 if not. Return 1 without asking for a password if run by UID 0
or if PW has an empty password. */
-int
+static int
correct_password (pw)
struct passwd *pw;
{
/* Update `environ' for the new shell based on PW, with SHELL being
the value for the SHELL environment variable. */
-void
+static void
modify_environment (pw, shell)
struct passwd *pw;
char *shell;
/* Become the user and group(s) specified by PW. */
-void
+static void
change_identity (pw)
struct passwd *pw;
{
If ADDITIONAL_ARGS is nonzero, pass it to the shell as more
arguments. */
-void
+static void
run_shell (shell, command, additional_args)
char *shell;
char *command;
/* Log the fact that someone has run su to the user given by PW;
if SUCCESSFUL is nonzero, they gave the correct password, etc. */
-void
+static void
log_su (pw, successful)
struct passwd *pw;
int successful;
/* Return 1 if SHELL is a restricted shell (one not returned by
getusershell), else 0, meaning it is a standard shell. */
-int
+static int
restricted_shell (shell)
char *shell;
{
char *line;
setusershell ();
- while (line = getusershell ())
+ while ((line = getusershell ()) != NULL)
{
if (*line != '#' && strcmp (line, shell) == 0)
{
/* Return the number of elements in ARR, a null-terminated array. */
-int
+static int
elements (arr)
char **arr;
{
/* Add VAL to the environment, checking for out of memory errors. */
-void
+static void
xputenv (val)
char *val;
{
/* Return a newly-allocated string whose contents concatenate
those of S1, S2, S3. */
-char *
+static char *
concat (s1, s2, s3)
char *s1, *s2, *s3;
{
return result;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#include "system.h"
char *xmalloc ();
-int tee ();
void error ();
void xwrite ();
+static int tee ();
+
/* If nonzero, append to output files rather than truncating them. */
static int append;
/* The name that this program was run with. */
char *program_name;
-static struct option long_options[] =
+static struct option const long_options[] =
{
{"append", 0, NULL, 'a'},
{"ignore-interrupts", 0, NULL, 'i'},
and into the standard output.
Return 0 if successful, 1 if any errors occur. */
-int
+static int
tee (nfiles, files)
int nfiles;
char **files;
static int and ();
static int or ();
+static int group_member ();
+
static void
test_syntax_error (format, arg)
char *format, *arg;
char *path;
int mode;
{
- extern int group_member ();
struct stat st;
static int euid = -1;
#endif /* HAVE_GETGROUPS */
/* Return non-zero if GID is one that we have in our groups list. */
-int
+static int
group_member (gid)
gid_t gid;
{
#include <sys/types.h>
#include "system.h"
-void usage ();
+static void usage ();
/* The name under which this program was run. */
char *program_name;
/* If nonzero, return an exit status but produce no output. */
static int silent;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"silent", 0, NULL, 's'},
{"quiet", 0, NULL, 's'},
exit (tty == NULL);
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#include "system.h"
void error ();
-void print_element ();
-void usage ();
+
+static void print_element ();
+static void usage ();
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
/* The name this program was run with, for error messages. */
char *program_name;
-static struct option long_options[] =
+static struct option const long_options[] =
{
{"sysname", 0, NULL, 's'},
{"nodename", 0, NULL, 'n'},
print ELEMENT; then print a space unless it is the last element to
be printed, in which case print a newline. */
-void
+static void
print_element (mask, element)
unsigned char mask;
char *element;
}
}
-void
+static void
usage ()
{
fprintf (stderr, "\
#define MESG_BIT 020 /* Group write bit. */
-char *ttyname ();
char *idle_string ();
char *xmalloc ();
-struct utmp *search_entries ();
void error ();
-void list_entries ();
-void print_entry ();
-void print_heading ();
-void scan_entries ();
-void usage ();
-void who ();
-void who_am_i ();
+
+
+static char *ttyname ();
+static struct utmp *search_entries ();
+static void list_entries ();
+static void print_entry ();
+static void print_heading ();
+static void scan_entries ();
+static void usage ();
+static void who ();
+static void who_am_i ();
/* The name this program was run with. */
char *program_name;
or a `?' if their tty cannot be statted. */
static int include_mesg;
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"count", 0, NULL, 'q'},
{"idle", 0, NULL, 'u'},
/* Display a list of who is on the system, according to utmp file FILENAME. */
-void
+static void
who (filename)
char *filename;
{
/* Read the utmp file FILENAME into UTMP_CONTENTS and return the
number of entries it contains. */
-int
+static int
read_utmp (filename)
char *filename;
{
/* Display a line of information about entry THIS. */
-void
+static void
print_entry (this)
struct utmp *this;
{
/* Print the username of each valid entry and the number of valid entries
in `utmp_contents', which should have N elements. */
-void
+static void
list_entries (n)
int n;
{
printf ("\n# users=%u\n", entries);
}
-void
+static void
print_heading ()
{
struct utmp *ut;
/* Display `utmp_contents', which should have N entries. */
-void
+static void
scan_entries (n)
int n;
{
Return the first matching entry found, or NULL if there
is no matching entry. */
-struct utmp *
+static struct utmp *
search_entries (n, line)
int n;
char *line;
/* Display the entry in utmp file FILENAME for this tty on standard input,
or nothing if there is no entry for it. */
-void
+static void
who_am_i (filename)
char *filename;
{
/* Return a string representing the time between WHEN and the time
that this function is first run. */
-char *
+static char *
idle_string (when)
time_t when;
{
return " old ";
}
-void
+static void
usage ()
{
fprintf (stderr, "\