-static struct option options[] = {
- { "key", required_argument, NULL, 'k' },
+static struct option options_l[] = {
+ { "author", no_argument, NULL, 'a' },
{ "certificate", required_argument, NULL, 'c' },
{ "distributor", required_argument, NULL, 'd' },
{ "certificate", required_argument, NULL, 'c' },
{ "distributor", required_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
/* install the widgets of the list */
int main(int ac, char **av)
{
int i, force, ncert, author;
unsigned int number;
/* install the widgets of the list */
int main(int ac, char **av)
{
int i, force, ncert, author;
unsigned int number;
- char *keyfile, *certfiles[MAXCERT+1], *directory, **x;
+ char *keyfile, *certfiles[MAXCERT+1], *directory;
- i = getopt_long(ac, av, "hfqvVak:c:d:", options, NULL);
+ i = getopt_long(ac, av, options_s, options_l, NULL);
- continue;
- case 'k': x = &keyfile; break;
- case 'd': number = get_number(optarg); continue;
- case 'f': force = 1; continue;
- case 'a': author = 1; continue;
- case 'h': usage(); return 0;
- case 'V': version(); return 0;
+ break;
+ case 'k':
+ if (keyfile) {
+ ERROR("key already set");
+ return 1;
+ }
+ keyfile = optarg;
+ break;
+ case 'd':
+ if (number != UINT_MAX) {
+ ERROR("number already set");
+ return 1;
+ }
+ number = get_number(optarg);
+ break;
+ case 'f':
+ force = 1;
+ break;
+ case 'a':
+ author = 1;
+ break;
+ case 'h':
+ usage();
+ return 0;
+ case 'V':
+ version();
+ return 0;
if (access(certfiles[i], R_OK) != 0) {
ERROR("can't access certificate %s", certfiles[i]);
return 1;
if (access(certfiles[i], R_OK) != 0) {
ERROR("can't access certificate %s", certfiles[i]);
return 1;
-#define rp(x) do { char *p = realpath(x, NULL); if (p != NULL) x = p; else { ERROR("realpath failed for %s",x); return 1; } } while(0)
- rp(keyfile);
- for(i = 0 ; i < ncert ; i++)
- rp(certfiles[i]);
-#undef rp
+ make_realpath(&keyfile);
+ for(i = 0 ; i < ncert ; i++)
+ make_realpath(&certfiles[i]);
/* set and enter the workdir */
if (set_workdir(directory, 0))
/* set and enter the workdir */
if (set_workdir(directory, 0))