|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/corelib/ncbienv.h |
source navigation diff markup identifier search freetext search file search |
1
2 /* $Id: ncbienv.h,v 6.4 2003/06/06 15:01:03 rsmith Exp $
3 * ===========================================================================
4 *
5 * PUBLIC DOMAIN NOTICE
6 * National Center for Biotechnology Information
7 *
8 * This software/database is a "United States Government Work" under the
9 * terms of the United States Copyright Act. It was written as part of
10 * the author's official duties as a United States Government employee and
11 * thus cannot be copyrighted. This software/database is freely available
12 * to the public for use. The National Library of Medicine and the U.S.
13 * Government have not placed any restriction on its use or reproduction.
14 *
15 * Although all reasonable efforts have been taken to ensure the accuracy
16 * and reliability of the software and data, the NLM and the U.S.
17 * Government do not and cannot warrant the performance or results that
18 * may be obtained by using this software or data. The NLM and the U.S.
19 * Government disclaim all warranties, express or implied, including
20 * warranties of performance, merchantability or fitness for any particular
21 * purpose.
22 *
23 * Please cite the author in any work or product based on this material.
24 *
25 * ===========================================================================
26 *
27 * File Name: ncbimain.h
28 *
29 * Author: Gish, Kans, Ostell, Schuler, Vakatov
30 *
31 * Version Creation Date: 7/7/91
32 *
33 * $Revision: 6.4 $
34 *
35 * File Description:
36 * protokeys for portable string routines
37 *
38 * Modifications:
39 * --------------------------------------------------------------------------
40 * $Log: ncbienv.h,v $
41 * Revision 6.4 2003/06/06 15:01:03 rsmith
42 * fixed ProgramPath for OS Darwin & Mac, Added IsApplicationPackage for Darwin. ProgramPath on Darwin now returns the seen application not the executable buried in the package.
43 *
44 * Revision 6.3 2003/01/29 19:37:14 kans
45 * added GetOpSysString to return allocated string describing operating system running the program
46 *
47 * Revision 6.2 1999/11/29 19:58:50 vakatov
48 * To parse command-line arguments:
49 * + ECmdLineQuote, Nlm_ParseCmdLineArguments(), Nlm_FreeCmdLineArguments()
50 *
51 * Revision 6.1 1999/02/12 16:01:41 vakatov
52 * Added a draft version of Nlm_GetEnvParamEx()
53 * Got rid of the old "PROTO" and "LIBCALL" prototype junk, etc.
54 *
55 * Revision 5.1 1996/12/03 21:48:33 vakatov
56 * Adopted for 32-bit MS-Windows DLLs
57 *
58 * Revision 4.1 1995/10/06 15:54:00 epstein
59 * add CacheAppParam() and FlushAppParam()
60 *
61 * 06-14-94 Schuler Created this file. These definitions previously
62 * resided in ncbimain.h
63 * 06-14-94 Schuler Added some new functions:
64 * GetAppParamBoolean() , SetAppParamBoolean(),
65 * GetAppParamInt2(), SetAppParamInt2(),
66 * GetAppParamInt4(), SetAppParamInt4()
67 * 06-14-94 Schuler Added LIBCALL to ProgramPath
68 * ==========================================================================
69 */
70
71 #ifndef __NCBIenv_h__
72 #define __NCBIenv_h__
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 NLM_EXTERN Nlm_Boolean Nlm_FindPath(const Nlm_Char* file, const Nlm_Char* section, const Nlm_Char* type, Nlm_Char* buf, Nlm_Int2 buflen);
87 NLM_EXTERN Nlm_Boolean Nlm_TransientSetAppParam(const Nlm_Char* file, const Nlm_Char* section, const Nlm_Char* type, const Nlm_Char* value);
88 NLM_EXTERN void Nlm_FreeConfigStruct(void);
89 NLM_EXTERN void Nlm_ProgramPath(Nlm_Char* buf, size_t maxsize);
90 #ifdef OS_UNIX_DARWIN
91 NLM_EXTERN Nlm_Boolean Nlm_IsApplicationPackage(char *filePath);
92 #endif
93
94 NLM_EXTERN void Nlm_FlushAppParam(void);
95 NLM_EXTERN Nlm_Boolean Nlm_CacheAppParam(Nlm_Boolean value);
96
97 NLM_EXTERN Nlm_Int2 Nlm_GetAppParam(const Nlm_Char* file, const Nlm_Char* section, const Nlm_Char* type, const Nlm_Char* dflt, Nlm_Char* buf, Nlm_Int2 buflen);
98 NLM_EXTERN Nlm_Boolean Nlm_SetAppParam(const Nlm_Char* file, const Nlm_Char* section, const Nlm_Char* type, const Nlm_Char* value);
99 NLM_EXTERN Nlm_Boolean GetAppParamBoolean(const Nlm_Char* filebase, const Nlm_Char* sect, const Nlm_Char* key, Nlm_Boolean dflt);
100 NLM_EXTERN Nlm_Boolean SetAppParamBoolean(const Nlm_Char* filebase, const Nlm_Char* sect, const Nlm_Char* key, Nlm_Boolean value);
101 NLM_EXTERN Nlm_Boolean SetAppParamLong(const Nlm_Char* filebase, const Nlm_Char* sect, const Nlm_Char* key, long value);
102 NLM_EXTERN long GetAppParamLong(const Nlm_Char* filebase, const Nlm_Char* sect, const Nlm_Char* key, long dflt);
103
104 /* 1) search for the specified key "conf_name" in the transient parameter list
105 * in pseudo-file "conf_file", pseudo-section "conf_section";
106 * 2) if not found then look for the environment variable named "env_name";
107 * 3) if not found then read configuration file "conf_file", section
108 * "conf_section" and search "conf_name" entry there.
109 * If the parameter is found in (1),(2),(3) then put its value to "buf".
110 * If nothing is found and "dflt" is not zero then put "dflt" to "buf".
111 * Return the length of "buf" string(can be zero).
112 * NOTE: the resultant "buf" string is guaranteed to be '\0'-terminated
113 * and no bigger than "bufsize-1" long.
114 */
115 NLM_EXTERN size_t Nlm_GetEnvParamEx
116 (const Char* conf_file, /* default: "ncbi" */
117 const Char* conf_section, /* default: "NCBI" */
118 const Char* env_name,
119 const Char* conf_name,
120 Char* buf,
121 size_t bufsize,
122 const Char* dflt
123 );
124
125 /* Call Nlm_GetEnvParamEx() with "env_name" == "conf_name" := "env_conf_name"
126 */
127 NLM_EXTERN size_t Nlm_GetEnvParam
128 (const Char* conf_file, const Char* conf_section,
129 const Char* env_conf_name, Char* buf, size_t bufsize, const Char* dflt);
130
131 /* Parse cmd.-line args and create (NULL-terminated) "argv" array of values.
132 * Use "prog_name" to compose "argv[0]"; if "prog_name" is NULL then
133 * use the value of app.property "ProgramName" instead.
134 * The resultant argv must be deallocated by the caller using
135 * Nlm_FreeCmdLineArguments().
136 * On error, do nothing and return FALSE.
137 */
138 typedef enum { /* specifies whether " and ' have special meaning */
139 eProcessQuotes, /* `aa "bb c"' --> argv[]: {`aa', `bb c'} */
140 eIgnoreQuotes /* `aa "bb c"' --> argv[]: {`aa', `"bb', `c"'} */
141 } ECmdLineQuote;
142
143 NLM_EXTERN Nlm_Boolean Nlm_ParseCmdLineArguments
144 (const char* prog_name, const char* cmd_line, int* argc_ptr, char*** argv_ptr,
145 ECmdLineQuote quote_handling);
146
147 /* Deallocate all dynamic memory occupied by "argv".
148 * NOTE: the "argv" must be created by Nlm_ParseCmdLineArguments()
149 */
150 NLM_EXTERN void Nlm_FreeCmdLineArguments(char** argv);
151
152 /* returns allocated string describing operating system running the program */
153
154 NLM_EXTERN Nlm_CharPtr Nlm_GetOpSysString (void);
155
156 #define GetAppParamInt(a,b,c,d) (int)GetAppParamLong(a,b,c,(long)(d))
157 #define SetAppParamInt(a,b,c,d) SetAppParamLong(a,b,c,(long)(d))
158 #define GetAppParamShort(a,b,c,d) (short)GetAppParamLong(a,b,c,(long)(d))
159 #define SetAppParamShort(a,b,c,d) SetAppParamLong(a,b,c,(long)(d))
160
161 #define FindPath Nlm_FindPath
162 #define FlushAppParam Nlm_FlushAppParam
163 #define CacheAppParam Nlm_CacheAppParam
164 #define GetAppParam Nlm_GetAppParam
165 #define SetAppParam Nlm_SetAppParam
166 #define TransientSetAppParam Nlm_TransientSetAppParam
167 #define FreeConfigStruct Nlm_FreeConfigStruct
168 #define ProgramPath Nlm_ProgramPath
169 #define GetAppParamInt2 GetAppParamShort
170 #define GetAppParamInt4 GetAppParamLong
171 #define GetEnvParamEx Nlm_GetEnvParamEx
172 #define GetEnvParam Nlm_GetEnvParam
173 #define ParseCmdLineArguments Nlm_ParseCmdLineArguments
174 #define FreeCmdLineArguments Nlm_FreeCmdLineArguments
175 #define GetOpSysString Nlm_GetOpSysString
176 #ifdef OS_UNIX_DARWIN
177 #define IsApplicationPackage Nlm_IsApplicationPackage
178 #endif
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184
185 #undef NLM_EXTERN
186 #ifdef NLM_EXPORT
187 #define NLM_EXTERN NLM_EXPORT
188 #else
189 #define NLM_EXTERN
190 #endif
191
192 #endif
193
194 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |