2 * libdpkg - Debian packaging suite library routines
3 * options.h - option parsing functions
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
8 * This is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 #ifndef LIBDPKG_OPTIONS_H
23 #define LIBDPKG_OPTIONS_H
25 #include <dpkg/macros.h>
26 #include <dpkg/dpkg-db.h>
31 * @defgroup options Option parsing
32 * @ingroup dpkg-internal
36 typedef int action_func(const char *const *argv
);
43 * 0 = Normal (-o, --option)
44 * 1 = Standard value (-o=value, --option=value or
45 * -o value, --option value)
46 * 2 = Option string continued (--option-value)
50 const char **sassignto
;
51 void (*call
)(const struct cmdinfo
*, const char *value
);
59 void badusage(const char *fmt
, ...) DPKG_ATTR_NORET
DPKG_ATTR_PRINTF(1);
61 #define MAX_CONFIG_LINE 1024
63 void dpkg_options_load(const char *prog
, const struct cmdinfo
*cmdinfos
);
64 void dpkg_options_parse(const char *const **argvp
,
65 const struct cmdinfo
*cmdinfos
, const char *help_str
);
67 long dpkg_options_parse_arg_int(const struct cmdinfo
*cmd
, const char *str
);
70 dpkg_options_parse_pkgname(const struct cmdinfo
*cmd
, const char *name
);
73 * Current cmdinfo action.
75 extern const struct cmdinfo
*cipaction
;
77 void setaction(const struct cmdinfo
*cip
, const char *value
);
78 void setobsolete(const struct cmdinfo
*cip
, const char *value
);
80 #define ACTION(longopt, shortopt, code, func) \
81 { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, func }
82 #define ACTION_MUX(longopt, shortopt, code, func, strvar) \
83 { longopt, shortopt, 2, NULL, strvar, setaction, code, NULL, func }
84 #define OBSOLETE(longopt, shortopt) \
85 { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
88 set_instdir(const struct cmdinfo
*cip
, const char *value
);
90 set_admindir(const struct cmdinfo
*cip
, const char *value
);
92 set_root(const struct cmdinfo
*cip
, const char *value
);
98 #endif /* LIBDPKG_OPTIONS_H */