sss_tools.h revision cf3ba77997dfbd076a1f30fdbb33c7973766ac03
98N/A/*
98N/A Authors:
98N/A Pavel Březina <pbrezina@redhat.com>
98N/A
1265N/A Copyright (C) 2015 Red Hat
98N/A
98N/A This program is free software; you can redistribute it and/or modify
919N/A it under the terms of the GNU General Public License as published by
919N/A the Free Software Foundation; either version 3 of the License, or
919N/A (at your option) any later version.
919N/A
919N/A This program is distributed in the hope that it will be useful,
919N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
919N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
919N/A GNU General Public License for more details.
919N/A
919N/A You should have received a copy of the GNU General Public License
919N/A along with this program. If not, see <http://www.gnu.org/licenses/>.
919N/A*/
919N/A
919N/A#ifndef _SSS_TOOLS_H_
919N/A#define _SSS_TOOLS_H_
919N/A
919N/A#include <talloc.h>
98N/A#include <popt.h>
98N/A
98N/A#include "confdb/confdb.h"
98N/A
98N/Astruct sss_tool_ctx {
98N/A struct confdb_ctx *confdb;
1265N/A
493N/A char *default_domain;
98N/A struct sss_domain_info *domains;
911N/A};
1276N/A
1276N/Astruct sss_tool_ctx *sss_tool_init(TALLOC_CTX *mem_ctx,
1276N/A int *argc, const char **argv);
911N/A
98N/Astruct sss_cmdline;
235N/A
493N/Atypedef int
98N/A(*sss_route_fn)(struct sss_cmdline *cmdline,
916N/A struct sss_tool_ctx *tool_ctx,
916N/A void *pvt);
916N/A
916N/A#define SSS_TOOL_COMMAND(cmd, msg, fn) {cmd, _(msg), fn}
970N/A
970N/Astruct sss_route_cmd {
970N/A const char *command;
970N/A const char *description;
970N/A sss_route_fn fn;
970N/A};
970N/A
970N/Aint sss_tool_usage(const char *tool_name,
970N/A struct sss_route_cmd *commands);
970N/A
970N/Aint sss_tool_route(int argc, const char **argv,
970N/A struct sss_tool_ctx *tool_ctx,
970N/A struct sss_route_cmd *commands,
970N/A void *pvt);
970N/A
970N/Atypedef int (*sss_popt_fn)(poptContext pc, char option, void *pvt);
970N/A
970N/Aenum sss_tool_opt {
970N/A SSS_TOOL_OPT_REQUIRED,
970N/A SSS_TOOL_OPT_OPTIONAL
970N/A};
970N/A
970N/Aint sss_tool_popt_ex(struct sss_cmdline *cmdline,
970N/A struct poptOption *options,
970N/A enum sss_tool_opt require_option,
1029N/A sss_popt_fn popt_fn,
1029N/A void *popt_fn_pvt,
1124N/A const char *free_opt_name,
1124N/A const char *free_opt_help,
1124N/A const char **_free_opt);
1124N/A
1124N/Aint sss_tool_popt(struct sss_cmdline *cmdline,
1124N/A struct poptOption *options,
970N/A enum sss_tool_opt require_option,
98N/A sss_popt_fn popt_fn,
98N/A void *popt_fn_pvt);
1265N/A
1124N/Aint sss_tool_main(int argc, const char **argv,
1124N/A struct sss_route_cmd *commands,
1124N/A void *pvt);
1265N/A
1265N/Aint sss_tool_parse_name(TALLOC_CTX *mem_ctx,
1265N/A struct sss_tool_ctx *tool_ctx,
1124N/A const char *input,
98N/A const char **_username,
493N/A struct sss_domain_info **_domain);
98N/A
970N/A#endif /* SRC_TOOLS_COMMON_SSS_TOOLS_H_ */
970N/A