getopt: add static qualifiers

Signed-off-by: Olivier Mengué <dolmen@cpan.org>
This commit is contained in:
Olivier Mengué 2011-03-27 18:29:56 +02:00 committed by Karel Zak
parent 488c033f2a
commit 0a626987e2
1 changed files with 26 additions and 26 deletions

View File

@ -59,27 +59,27 @@ typedef enum {BASH,TCSH} shell_t;
/* 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);
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);
void *our_malloc(size_t size)
static void *our_malloc(size_t size)
{
void *ret=malloc(size);
if (! ret) {
@ -89,7 +89,7 @@ void *our_malloc(size_t size)
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) {
@ -108,7 +108,7 @@ void *our_realloc(void *ptr, size_t 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;
@ -172,8 +172,8 @@ const char *normalize(const char *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;
@ -222,7 +222,7 @@ int generate_output(char * argv[],int argc,const char *optstr,
* 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);
@ -237,7 +237,7 @@ static int long_options_nr=0; /* Nr of used elements in array */
#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 */
@ -276,7 +276,7 @@ void add_longopt(const char *name,int has_arg)
* 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");
@ -301,7 +301,7 @@ void add_long_options(char *options)
}
}
void set_shell(const char *new_shell)
static void set_shell(const char *new_shell)
{
if (!strcmp(new_shell,"bash"))
shell=BASH;
@ -315,7 +315,7 @@ void set_shell(const char *new_shell)
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);