2009-07-08 13:19:16 -07:00
|
|
|
/*
|
2012-05-02 15:21:36 -07:00
|
|
|
* Copyright (c) 2008, 2009, 2010 Nicira, Inc.
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-07-08 13:19:16 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMAND_LINE_H
|
|
|
|
#define COMMAND_LINE_H 1
|
|
|
|
|
|
|
|
/* Utilities for command-line parsing. */
|
|
|
|
|
2009-10-23 11:49:39 -07:00
|
|
|
#include "compiler.h"
|
|
|
|
|
2009-07-08 13:19:16 -07:00
|
|
|
struct option;
|
2009-10-23 11:49:39 -07:00
|
|
|
|
2015-03-17 10:35:26 -04:00
|
|
|
/* Command handler context */
|
|
|
|
struct ovs_cmdl_context {
|
|
|
|
/* number of command line arguments */
|
|
|
|
int argc;
|
|
|
|
/* array of command line arguments */
|
|
|
|
char **argv;
|
|
|
|
/* private context data defined by the API user */
|
|
|
|
void *pvt;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*ovs_cmdl_handler)(struct ovs_cmdl_context *);
|
|
|
|
|
2015-03-16 12:01:55 -04:00
|
|
|
struct ovs_cmdl_command {
|
2009-10-23 11:49:39 -07:00
|
|
|
const char *name;
|
2014-10-16 13:27:32 -07:00
|
|
|
const char *usage;
|
2009-10-23 11:49:39 -07:00
|
|
|
int min_args;
|
|
|
|
int max_args;
|
2015-03-17 10:35:26 -04:00
|
|
|
ovs_cmdl_handler handler;
|
2009-10-23 11:49:39 -07:00
|
|
|
};
|
|
|
|
|
2015-03-16 12:01:55 -04:00
|
|
|
char *ovs_cmdl_long_options_to_short_options(const struct option *options);
|
|
|
|
void ovs_cmdl_print_options(const struct option *options);
|
|
|
|
void ovs_cmdl_print_commands(const struct ovs_cmdl_command *commands);
|
2015-03-17 10:35:26 -04:00
|
|
|
void ovs_cmdl_run_command(struct ovs_cmdl_context *, const struct ovs_cmdl_command[]);
|
2009-07-08 13:19:16 -07:00
|
|
|
|
2015-03-16 12:01:55 -04:00
|
|
|
void ovs_cmdl_proctitle_init(int argc, char **argv);
|
2013-05-21 17:49:54 +09:00
|
|
|
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
2015-03-16 12:01:55 -04:00
|
|
|
#define ovs_cmdl_proctitle_set setproctitle
|
2012-10-11 20:58:17 +00:00
|
|
|
#else
|
2015-03-16 12:01:55 -04:00
|
|
|
void ovs_cmdl_proctitle_set(const char *, ...)
|
2014-12-15 14:10:38 +01:00
|
|
|
OVS_PRINTF_FORMAT(1, 2);
|
2012-10-11 20:58:17 +00:00
|
|
|
#endif
|
2015-03-16 12:01:55 -04:00
|
|
|
void ovs_cmdl_proctitle_restore(void);
|
2010-01-19 15:00:56 -08:00
|
|
|
|
2009-07-08 13:19:16 -07:00
|
|
|
#endif /* command-line.h */
|