diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-20 05:03:54 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-20 05:03:54 -0400 |
commit | 52fc9f2e4499e75d17e7f12d32a8391054d8634a (patch) | |
tree | 164b6b4cdb6717f2df7d154793499e90bdd3ae3e /option.h | |
parent | 59f6ffb863b7121b8a49c13dd64f9943ddaf7ed0 (diff) | |
download | fork-ledger-52fc9f2e4499e75d17e7f12d32a8391054d8634a.tar.gz fork-ledger-52fc9f2e4499e75d17e7f12d32a8391054d8634a.tar.bz2 fork-ledger-52fc9f2e4499e75d17e7f12d32a8391054d8634a.zip |
Brought in the final round of 3.0 code, although it does not compile yet:
report, session, parts of xpath, main, journal, option.
Diffstat (limited to 'option.h')
-rw-r--r-- | option.h | 70 |
1 files changed, 39 insertions, 31 deletions
@@ -1,44 +1,52 @@ +/* + * Copyright (c) 2003-2007, John Wiegley. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of New Artisans LLC nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef _OPTION_H #define _OPTION_H -#include "utils.h" +#include "valexpr.h" namespace ledger { -typedef void (*handler_t)(const char * arg); - -struct option_t { - const char * long_opt; - char short_opt; - bool wants_arg; - handler_t handler; - bool handled; -}; - -DECLARE_EXCEPTION(error, option_error); - -bool process_option(option_t * options, const string& opt, +void process_option(const string& name, expr::scope_t& scope, const char * arg = NULL); -void process_arguments(option_t * options, int argc, char ** argv, - const bool anywhere, std::list<string>& args); -void process_environment(option_t * options, const char ** envp, - const string& tag); -class config_t; -class report_t; +void process_environment(const char ** envp, const string& tag, + expr::scope_t& scope); -extern config_t * config; -extern report_t * report; +void process_arguments(int argc, char ** argv, const bool anywhere, + expr::scope_t& scope, + std::list<string>& args); -#define CONFIG_OPTIONS_SIZE 97 -extern option_t config_options[CONFIG_OPTIONS_SIZE]; - -void option_help(std::ostream& out); - -#define OPT_BEGIN(tag, chars) \ - void opt_ ## tag(const char * optarg) - -#define OPT_END(tag) +DECLARE_EXCEPTION(error, option_error); } // namespace ledger |