2008-04-17 14:09:13 +00:00
|
|
|
/* apk_applet.h - Alpine Package Keeper (APK)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2008 Natanael Copa <n@tanael.org>
|
2011-09-13 08:53:01 +00:00
|
|
|
* Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
|
2008-04-17 14:09:13 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2009-06-25 12:14:07 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
2008-04-17 14:09:13 +00:00
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef APK_APPLET_H
|
|
|
|
#define APK_APPLET_H
|
|
|
|
|
2014-10-08 12:29:27 +00:00
|
|
|
#include <errno.h>
|
2009-01-13 12:09:45 +00:00
|
|
|
#include <getopt.h>
|
2009-02-17 12:23:01 +00:00
|
|
|
#include "apk_defines.h"
|
2009-08-06 11:25:03 +00:00
|
|
|
#include "apk_database.h"
|
2008-04-21 16:30:10 +00:00
|
|
|
|
2018-01-09 01:47:21 +00:00
|
|
|
#define APK_COMMAND_GROUP_INSTALL 0x0001
|
|
|
|
#define APK_COMMAND_GROUP_SYSTEM 0x0002
|
|
|
|
#define APK_COMMAND_GROUP_QUERY 0x0004
|
|
|
|
#define APK_COMMAND_GROUP_REPO 0x0008
|
|
|
|
|
2009-06-25 12:14:07 +00:00
|
|
|
struct apk_option {
|
|
|
|
int val;
|
|
|
|
const char *name;
|
|
|
|
int has_arg;
|
|
|
|
const char *arg_name;
|
|
|
|
};
|
|
|
|
|
2014-10-08 12:29:27 +00:00
|
|
|
struct apk_option_group {
|
|
|
|
const char *name;
|
|
|
|
int num_options;
|
|
|
|
const struct apk_option *options;
|
|
|
|
|
|
|
|
int (*parse)(void *ctx, struct apk_db_options *dbopts,
|
|
|
|
int optch, const char *optarg);
|
|
|
|
};
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_applet {
|
2014-05-12 16:42:32 +00:00
|
|
|
struct list_head node;
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
const char *name;
|
2009-06-25 12:14:07 +00:00
|
|
|
const char *arguments;
|
2014-10-08 12:29:27 +00:00
|
|
|
const struct apk_option_group *optgroups[4];
|
2009-01-13 12:09:45 +00:00
|
|
|
|
2018-01-09 01:47:21 +00:00
|
|
|
unsigned int open_flags, forced_flags, forced_force, command_groups;
|
2009-01-13 12:09:45 +00:00
|
|
|
int context_size;
|
|
|
|
|
2013-06-18 10:01:51 +00:00
|
|
|
int (*main)(void *ctx, struct apk_database *db, struct apk_string_array *args);
|
2008-04-17 14:09:13 +00:00
|
|
|
};
|
|
|
|
|
2014-10-08 12:29:27 +00:00
|
|
|
extern const struct apk_option_group optgroup_global, optgroup_commit;
|
|
|
|
|
2014-05-12 16:42:32 +00:00
|
|
|
void apk_applet_register(struct apk_applet *);
|
|
|
|
typedef void (*apk_init_func_t)(void);
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
#define APK_DEFINE_APPLET(x) \
|
2014-05-12 16:42:32 +00:00
|
|
|
static void __register_##x(void) { apk_applet_register(&x); } \
|
|
|
|
static apk_init_func_t __regfunc_##x __attribute__((__section__("initapplets"))) __attribute((used)) = __register_##x;
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
#endif
|