/* Some global variables that tells us how to parse. */
-shell_t shell=BASH; /* The shell we generate output for. */
-int quiet_errors=0; /* 0 is not quiet. */
-int quiet_output=0; /* 0 is not quiet. */
-int quote=1; /* 1 is do quote. */
-int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
+static shell_t shell=BASH; /* The shell we generate output for. */
+static int quiet_errors=0; /* 0 is not quiet. */
+static int quiet_output=0; /* 0 is not quiet. */
+static int quote=1; /* 1 is do quote. */
+static int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
/* Function prototypes */
-void *our_malloc(size_t size);
-void *our_realloc(void *ptr, size_t size);
-const char *normalize(const char *arg);
-int generate_output(char * argv[],int argc,const char *optstr,
- const struct option *longopts);
+static void *our_malloc(size_t size);
+static void *our_realloc(void *ptr, size_t size);
+static const char *normalize(const char *arg);
+static int generate_output(char * argv[],int argc,const char *optstr,
+ const struct option *longopts);
int main(int argc, char *argv[]);
-void parse_error(const char *message);
-void add_long_options(char *options);
-void add_longopt(const char *name,int has_arg);
-void print_help(void);
-void set_shell(const char *new_shell);
-void set_initial_shell(void);
-
-void *our_malloc(size_t size)
+static void parse_error(const char *message);
+static void add_long_options(char *options);
+static void add_longopt(const char *name,int has_arg);
+static void print_help(void);
+static void set_shell(const char *new_shell);
+static void set_initial_shell(void);
+
+static void *our_malloc(size_t size)
{
void *ret=malloc(size);
if (! ret) {
return(ret);
}
-void *our_realloc(void *ptr, size_t size)
+static void *our_realloc(void *ptr, size_t size)
{
void *ret=realloc(ptr,size);
if (! ret && size) {
* This function returns a pointer to a buffer that is overwritten by
* each call.
*/
-const char *normalize(const char *arg)
+static const char *normalize(const char *arg)
{
static char *BUFFER=NULL;
const char *argptr=arg;
* optstr must contain the short options, and longopts the long options.
* Other settings are found in global variables.
*/
-int generate_output(char * argv[],int argc,const char *optstr,
- const struct option *longopts)
+static int generate_output(char * argv[],int argc,const char *optstr,
+ const struct option *longopts)
{
int exit_code = 0; /* We assume everything will be OK */
int opt;
* If message is NULL, we already sent a message, we just exit with a helpful
* hint.
*/
-void parse_error(const char *message)
+static void parse_error(const char *message)
{
if (message)
fprintf(stderr,"getopt: %s\n",message);
#define init_longopt() add_longopt(NULL,0)
/* Register a long option. The contents of name is copied. */
-void add_longopt(const char *name,int has_arg)
+static void add_longopt(const char *name,int has_arg)
{
char *tmp;
if (!name) { /* init */
* separated by commas or whitespace.
* This nukes options!
*/
-void add_long_options(char *options)
+static void add_long_options(char *options)
{
int arg_opt;
char *tokptr=strtok(options,", \t\n");
}
}
-void set_shell(const char *new_shell)
+static void set_shell(const char *new_shell)
{
if (!strcmp(new_shell,"bash"))
shell=BASH;
parse_error(_("unknown shell after -s or --shell argument"));
}
-void print_help(void)
+static void print_help(void)
{
fputs(_("Usage: getopt optstring parameters\n"),stderr);
fputs(_(" getopt [options] [--] optstring parameters\n"),stderr);