/[ascend]/trunk/base/generic/general/env.h
ViewVC logotype

Contents of /trunk/base/generic/general/env.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1598 - (show annotations) (download) (as text)
Fri Aug 17 06:44:45 2007 UTC (17 years, 2 months ago) by jpye
File MIME type: text/x-chdr
File size: 2360 byte(s)
All platforms will now use the lib<name>_ascend.so convention for ASCEND external libraries.
(it makes it simpler for people writing such things).
1 /* ASCEND modelling environment
2 Copyright (C) 2006 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//**
19 @file
20 Environment variable helper routines
21 *//*
22 by John Pye, May 2006.
23 */
24
25 #ifndef ASC_ENV_H
26 #define ASC_ENV_H
27
28 #ifdef TEST
29 # define ASC_DLLSPEC T T
30 #else
31 # include <utilities/config.h>
32 # include <utilities/ascConfig.h>
33 # include <utilities/ascMalloc.h>
34 # define FREE ascfree
35 # define MALLOC ascmalloc
36 #endif
37
38 /**
39 This is the type of env var function that you must send to 'env_subst'.
40 It doesn't have to actually consult the environment; it could do all
41 sorts of other stuff if you wanted.
42 */
43 typedef char *(GetEnvFn)(const char *name);
44
45 /**
46 This the type of a putenv function that can be used to set and environment
47 variable.
48 */
49 typedef int (PutEnvFn)(const char *inputstring);
50
51 /**
52 Attempts to read from a getenv function, and if the value is found, write it
53 using a putenv function. You would use this to copy values from one
54 environment to another.
55
56 @return nonzero on error, -1 means that the value didn't exist in getenv,
57 otherwise the errors are those returned by putenv.
58 */
59 ASC_DLLSPEC int env_import(const char *varname,GetEnvFn *getenvptr,PutEnvFn *putenvptr);
60
61 /**
62 Perform variable substitution on a string in shell-like way.
63 This should replace any $VARNAME with the result of
64 (*getenvptr)(VARNAME).
65
66 At present there will be no allowance for lowercase env var names
67 only uppercase and underscores. No escaping of dollar signs is
68 allowed for yet, and not ${BRACKETING}TO_STOP adjacent characters
69 from being swallowed up is allowed for, either. These can be added
70 later, 'as an exercise'.
71 */
72 ASC_DLLSPEC char *env_subst(const char *path,GetEnvFn *getenvptr);
73
74 #endif

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22