2
* plu_args.c: common popt argument processing routines
4
* Copyright (C) 2004 by Adriaan de Groot <groot@kde.org>
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation; either version 2 of the License, or (at your
9
* option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14
* Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "pi-userland.h"
27
#include "pi-header.h"
29
char *plu_port = NULL;
32
static char *badoption_help = NULL;
35
#define ARGUMENT_BAD_OPTION 17227
37
static void callback(poptContext pc,
39
const struct poptOption *opt,
43
static int have_complained_already = 0;
46
print_splash(poptGetInvocationName(pc));
49
case ARGUMENT_BAD_OPTION:
50
if (!have_complained_already) {
51
fprintf(stderr," WARNING: You are using deprecated options. %s\n\n", badoption_help ? "Use these instead:" : "See --help for more.");
52
if (badoption_help) fprintf(stderr,"%s",badoption_help);
53
have_complained_already=1;
59
struct poptOption plu_common_options[] = {
60
{ NULL, 0, POPT_ARG_CALLBACK, callback, 0, NULL, NULL},
61
{ "port", 'p', POPT_ARG_STRING, &plu_port, 0 , "Use device <port> to communicate with Palm", "<port>"},
62
{ "timeout", 't', POPT_ARG_INT, &plu_timeout, 0 , "Use timeout <timeout> seconds", "<timeout>"},
63
{ "version", 0 , POPT_ARG_NONE, NULL, 'v', "Display version information", NULL},
64
{ "quiet", 'q', POPT_ARG_NONE, &plu_quiet, 0 , "Suppress 'Hit HotSync button' message", NULL},
65
{ "bad-option",0, POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, NULL, ARGUMENT_BAD_OPTION, NULL, NULL },
70
void plu_badoption(poptContext pc, int optc)
72
fprintf(stderr, "%s: %s\n",
73
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
76
poptPrintUsage(pc, stderr, 0);
81
void plu_popt_alias(poptContext pc,
82
const char *alias_long,
84
const char *expansion)
86
struct poptAlias alias = {
93
poptParseArgvString(expansion,&alias.argc,&alias.argv);
94
poptAddAlias(pc,alias,0);
98
void plu_set_badoption_help(const char *h)
100
if (badoption_help) free(badoption_help);
101
badoption_help = NULL;
102
if (h) badoption_help = strdup(h);
105
/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
106
/* Local Variables: */
107
/* indent-tabs-mode: t */
108
/* c-basic-offset: 8 */