1 /* ncbimain.h 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * File Name: ncbimain.h 27 * 28 * Author: Gish, Kans, Ostell, Schuler, Vakatov 29 * 30 * Version Creation Date: 7/7/91 31 * 32 * $Revision: 6.3 $ 33 * 34 * File Description: 35 * NCBI Main() function and cmd.-line argument-handling routines 36 * 37 * Modifications: 38 * -------------------------------------------------------------------------- 39 * $Log: ncbimain.h,v $ 40 * Revision 6.3 2001/04/12 22:13:54 vakatov 41 * #define GetArgs only if it is not defined yet 42 * 43 * Revision 6.2 2000/06/15 20:51:41 vakatov 44 * Use "const" in Args code 45 * 46 * Revision 6.1 1997/10/27 21:58:13 vakatov 47 * Added Nlm_FreeArgs() to reset args earlier set by GetArgs[Silent]() 48 * 49 * Revision 5.5 1997/07/22 19:11:31 vakatov 50 * Separated Main() from GetArg[svc]() functions; [WIN_MSWIN] converged 51 * console and GUI libraries; [for WIN32-DLL] encapsulated global variables 52 * 53 * Revision 5.4 1996/12/30 15:11:36 vakatov 54 * [WIN_MOTIF][WIN_MSWIN][WIN_MAC] +GetArgsSilent() 55 * 56 * Revision 5.3 1996/12/13 15:04:25 vakatov 57 * Declared Nlm_GetArgv() and Nlm_GetArgc() be DLL-importable 58 * 59 * Revision 5.2 1996/12/12 17:05:12 shavirin 60 * Added definitions for functions Nlm_GetArgv() and Nlm_GetArgc() 61 * 62 * Revision 5.1 1996/12/03 21:48:33 vakatov 63 * Adopted for 32-bit MS-Windows DLLs 64 * 65 * 7/7/91 Kans Multiple configuration files, get and set functions 66 * 04-15-93 Schuler Changed _cdecl to LIBCALL 67 * 68 * ========================================================================== 69 */ 70 71 #ifndef _NCBIMAIN_ 72 #define _NCBIMAIN_ 73 74 #undef NLM_EXTERN 75 #ifdef NLM_IMPORT 76 #define NLM_EXTERN NLM_IMPORT 77 #else 78 #define NLM_EXTERN extern 79 #endif 80 81 82 #ifdef __cplusplus 83 extern "C" { 84 #endif 85 86 87 typedef struct mainargs { 88 const char *prompt; /* prompt for field */ 89 const char *defaultvalue; /* default */ 90 char *from; /* range or datalink type */ 91 char *to; 92 Nlm_Boolean optional; 93 Nlm_Char tag; /* argument on command line */ 94 Nlm_Int1 type; /* type of value */ 95 Nlm_FloatHi floatvalue; 96 Nlm_Int4 intvalue; 97 CharPtr strvalue; 98 } Nlm_Arg, * Nlm_ArgPtr; /* (*) not PNTR for MS Windows */ 99 100 #define Args Nlm_Arg 101 #define ArgPtr Nlm_ArgPtr 102 103 104 #define ARG_INVALID 0 105 #define ARG_BOOLEAN 1 106 #define ARG_INT 2 107 #define ARG_FLOAT 3 108 #define ARG_STRING 4 109 #define ARG_FILE_IN 5 110 #define ARG_FILE_OUT 6 111 #define ARG_DATA_IN 7 112 #define ARG_DATA_OUT 8 113 114 115 extern Nlm_Int2 Nlm_Main(void); 116 117 NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname, Nlm_Int2 numargs, Nlm_ArgPtr ap); 118 119 /* do not post the arg-query dialog if all non-optional arguments can be 120 * resolved by default or using command line(even if command line is empty) */ 121 NLM_EXTERN Nlm_Boolean Nlm_GetArgsSilent(const char* progname, Nlm_Int2 numargs, Nlm_ArgPtr ap); 122 123 /* Free all dynamically allocated data and reset all data in "ap" */ 124 NLM_EXTERN Nlm_Boolean Nlm_FreeArgs(Nlm_Int2 numargs, Nlm_ArgPtr ap); 125 126 127 /***************************************************************************** 128 * 129 * Nlm_GetArg[v,c] 130 * these functions will return standard argc, argv of command-line 131 * program 132 * 133 *****************************************************************************/ 134 135 NLM_EXTERN Nlm_CharPtr PNTR Nlm_GetArgv(void); 136 NLM_EXTERN Nlm_Int4 Nlm_GetArgc(void); 137 138 139 #define Main Nlm_Main 140 #if !defined(GetArgs) 141 # define GetArgs Nlm_GetArgs 142 #endif 143 #define FreeArgs Nlm_FreeArgs 144 #define GetArgsSilent Nlm_GetArgsSilent 145 #define GetArgv Nlm_GetArgv 146 #define GetArgc Nlm_GetArgc 147 148 #ifdef __cplusplus 149 } 150 #endif 151 152 153 #undef NLM_EXTERN 154 #ifdef NLM_EXPORT 155 #define NLM_EXTERN NLM_EXPORT 156 #else 157 #define NLM_EXTERN 158 #endif 159 160 #endif 161 162