00001 /** @file 00002 00003 A brief file description 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 */ 00023 00024 /**************************************************************************** 00025 Process arguments 00026 00027 ****************************************************************************/ 00028 00029 #ifndef _INK_ARGS_H 00030 #define _INK_ARGS_H 00031 #include "ink_defs.h" 00032 #include "ink_apidefs.h" 00033 00034 #define MAX_FILE_ARGUMENTS 100 00035 00036 struct ArgumentDescription; 00037 00038 typedef void ArgumentFunction(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, const char *arg); 00039 00040 struct ArgumentDescription 00041 { 00042 const char *name; 00043 char key; // set to '-' if no single character key. 00044 /* 00045 "I" = integer 00046 "L" = int64_t 00047 "D" = double (floating point) 00048 "T" = toggle 00049 "F" = set flag to TRUE (default is FALSE) 00050 "f" = set flag to FALSE (default is TRUE) 00051 "T" = toggle 00052 "S80" = read string, 80 chars max 00053 "S*" = read unbounded string, allocating 00054 */ 00055 const char *description; 00056 const char *type; 00057 void *location; 00058 const char *env; 00059 ArgumentFunction *pfn; 00060 }; 00061 00062 /* Global Data 00063 */ 00064 extern const char *file_arguments[]; // exported by process_args() 00065 extern unsigned n_file_arguments; // exported by process_args() 00066 extern const char *program_name; // exported by process_args() 00067 00068 /* Print out arguments and values 00069 */ 00070 void show_argument_configuration(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions); 00071 00072 void usage(const ArgumentDescription * argument_descriptions, unsigned n_argument_descriptions, const char *arg_unused) TS_NORETURN; 00073 00074 /* Process all arguments 00075 */ 00076 void process_args(const ArgumentDescription * argument_descriptions, 00077 unsigned n_argument_descriptions, char **argv, const char *usage_string = 0); 00078 00079 #endif /*_INK_ARGS_H*/