libdballe 5.10
|
00001 /* 00002 * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00016 * 00017 * Author: Enrico Zini <enrico@enricozini.com> 00018 */ 00019 00020 #ifndef DBA_CMDLINE_H 00021 #define DBA_CMDLINE_H 00022 00028 #include <dballe/core/rawmsg.h> 00029 #include <popt.h> 00030 00031 namespace dballe { 00032 struct Record; 00033 00034 namespace cmdline { 00035 00036 struct op_dispatch_table 00037 { 00038 int (*func)(poptContext); 00039 const char* aliases[3]; 00040 const char* usage; 00041 const char* desc; 00042 const char* longdesc; 00043 struct poptOption* optable; 00044 }; 00045 00046 #define ODT_END { NULL, NULL, NULL, NULL, NULL, NULL } 00047 00048 struct tool_desc 00049 { 00050 const char* desc; 00051 const char* longdesc; 00052 struct op_dispatch_table* ops; 00053 }; 00054 00055 struct program_info 00056 { 00057 const char* name; 00058 const char* manpage_examples_section; 00059 const char* manpage_files_section; 00060 const char* manpage_seealso_section; 00061 }; 00062 00066 void dba_cmdline_print_dba_error(); 00067 00072 void dba_cmdline_error(poptContext optCon, const char* fmt, ...) __attribute__ ((noreturn)); 00073 00077 Encoding dba_cmdline_stringToMsgType(const char* type, poptContext optCon); 00078 00082 int dba_cmdline_dispatch_main(const struct program_info* pinfo, const struct tool_desc* desc, int argc, const char* argv[]); 00083 00089 unsigned dba_cmdline_get_query(poptContext optCon, Record& query); 00090 00094 void list_templates(); 00095 00096 } // namespace cmdline 00097 } // namespace dballe 00098 00099 /* vim:set ts=4 sw=4: */ 00100 #endif