|
Packit |
032894 |
/* Options common to ar and ranlib.
|
|
Packit |
032894 |
Copyright (C) 2012 Red Hat, Inc.
|
|
Packit |
032894 |
This file is part of elfutils.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
This file is free software; you can redistribute it and/or modify
|
|
Packit |
032894 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
032894 |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
032894 |
(at your option) any later version.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit |
032894 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
032894 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
032894 |
GNU General Public License for more details.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
You should have received a copy of the GNU General Public License
|
|
Packit |
032894 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
032894 |
# include <config.h>
|
|
Packit |
032894 |
#endif
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#include <argp.h>
|
|
Packit |
032894 |
#include <libintl.h>
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#include "arlib.h"
|
|
Packit |
032894 |
|
|
Packit |
032894 |
bool arlib_deterministic_output = DEFAULT_AR_DETERMINISTIC;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
static const struct argp_option options[] =
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
{ NULL, 'D', NULL, 0,
|
|
Packit |
032894 |
N_("Use zero for uid, gid, and date in archive members."), 0 },
|
|
Packit |
032894 |
{ NULL, 'U', NULL, 0,
|
|
Packit |
032894 |
N_("Use actual uid, gid, and date in archive members."), 0 },
|
|
Packit |
032894 |
|
|
Packit |
032894 |
{ NULL, 0, NULL, 0, NULL, 0 }
|
|
Packit |
032894 |
};
|
|
Packit |
032894 |
|
|
Packit |
032894 |
static error_t
|
|
Packit |
032894 |
parse_opt (int key, char *arg __attribute__ ((unused)),
|
|
Packit |
032894 |
struct argp_state *state __attribute__ ((unused)))
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
switch (key)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
case 'D':
|
|
Packit |
032894 |
arlib_deterministic_output = true;
|
|
Packit |
032894 |
break;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
case 'U':
|
|
Packit |
032894 |
arlib_deterministic_output = false;
|
|
Packit |
032894 |
break;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
default:
|
|
Packit |
032894 |
return ARGP_ERR_UNKNOWN;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
return 0;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
static char *
|
|
Packit |
032894 |
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
inline char *text_for_default (void)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
char *new_text;
|
|
Packit |
032894 |
if (unlikely (asprintf (&new_text, gettext ("%s (default)"), text) < 0))
|
|
Packit |
032894 |
return (char *) text;
|
|
Packit |
032894 |
return new_text;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
switch (key)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
case 'D':
|
|
Packit |
032894 |
if (DEFAULT_AR_DETERMINISTIC)
|
|
Packit |
032894 |
return text_for_default ();
|
|
Packit |
032894 |
break;
|
|
Packit |
032894 |
case 'U':
|
|
Packit |
032894 |
if (! DEFAULT_AR_DETERMINISTIC)
|
|
Packit |
032894 |
return text_for_default ();
|
|
Packit |
032894 |
break;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
return (char *) text;
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
static const struct argp argp =
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
options, parse_opt, NULL, NULL, NULL, help_filter, NULL
|
|
Packit |
032894 |
};
|
|
Packit |
032894 |
|
|
Packit |
032894 |
const struct argp_child arlib_argp_children[] =
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
{ &argp, 0, "", 2 },
|
|
Packit |
032894 |
{ NULL, 0, NULL, 0 }
|
|
Packit |
032894 |
};
|