dpkg 1.21.11
options.h
Go to the documentation of this file.
1/*
2 * libdpkg - Debian packaging suite library routines
3 * options.h - option parsing functions
4 *
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
7 *
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.
12 *
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.
17 *
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/>.
20 */
21
22#ifndef LIBDPKG_OPTIONS_H
23#define LIBDPKG_OPTIONS_H
24
25#include <dpkg/macros.h>
26#include <dpkg/dpkg-db.h>
27
29
36typedef int action_func(const char *const *argv);
37
38struct cmdinfo {
39 const char *olong;
40 char oshort;
41
42 /*
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)
47 */
50 const char **sassignto;
51 void (*call)(const struct cmdinfo*, const char *value);
52
54 void *arg_ptr;
55
57};
58
59void badusage(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
60
61#define MAX_CONFIG_LINE 1024
62
63void dpkg_options_load(const char *prog, const struct cmdinfo *cmdinfos);
64void dpkg_options_parse(const char *const **argvp,
65 const struct cmdinfo *cmdinfos, const char *help_str);
66
67long dpkg_options_parse_arg_int(const struct cmdinfo *cmd, const char *str);
68
69struct pkginfo *
70dpkg_options_parse_pkgname(const struct cmdinfo *cmd, const char *name);
71
75extern const struct cmdinfo *cipaction;
76
77void setaction(const struct cmdinfo *cip, const char *value);
78void setobsolete(const struct cmdinfo *cip, const char *value);
79
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 }
86
87void
88set_instdir(const struct cmdinfo *cip, const char *value);
89void
90set_admindir(const struct cmdinfo *cip, const char *value);
91void
92set_root(const struct cmdinfo *cip, const char *value);
93
97
98#endif /* LIBDPKG_OPTIONS_H */
#define DPKG_BEGIN_DECLS
Definition: macros.h:86
#define DPKG_ATTR_PRINTF(n)
Definition: macros.h:56
#define DPKG_END_DECLS
Definition: macros.h:87
#define DPKG_ATTR_NORET
Definition: macros.h:55
void setobsolete(const struct cmdinfo *cip, const char *value)
Definition: options.c:302
void dpkg_options_load(const char *prog, const struct cmdinfo *cmdinfos)
Definition: options.c:195
const struct cmdinfo * cipaction
Current cmdinfo action.
Definition: options.c:307
void set_admindir(const struct cmdinfo *cip, const char *value)
Definition: options-dirs.c:44
void set_root(const struct cmdinfo *cip, const char *value)
Definition: options-dirs.c:50
void badusage(const char *fmt,...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1)
Definition: options.c:42
long dpkg_options_parse_arg_int(const struct cmdinfo *cmd, const char *str)
Definition: options.c:284
void setaction(const struct cmdinfo *cip, const char *value)
Definition: options.c:317
void set_instdir(const struct cmdinfo *cip, const char *value)
Definition: options-dirs.c:33
int action_func(const char *const *argv)
Definition: options.h:36
struct pkginfo * dpkg_options_parse_pkgname(const struct cmdinfo *cmd, const char *name)
Parse an argument as a package name.
Definition: options-parsers.c:42
void dpkg_options_parse(const char *const **argvp, const struct cmdinfo *cmdinfos, const char *help_str)
Definition: options.c:214
Definition: options.h:38
void(* call)(const struct cmdinfo *, const char *value)
Definition: options.h:51
int takesvalue
Definition: options.h:48
char oshort
Definition: options.h:40
int arg_int
Definition: options.h:53
action_func * action
Definition: options.h:56
const char ** sassignto
Definition: options.h:50
void * arg_ptr
Definition: options.h:54
int * iassignto
Definition: options.h:49
const char * olong
Definition: options.h:39
Node describing an architecture package instance.
Definition: dpkg-db.h:198