56 std::string MBDYNVARS = std::string(
MBDYNPREFIX) +
"VARS";
57 char* e = getenv(MBDYNVARS.c_str());
59 DEBUGCOUT(
"GetEnv: reading variable <" << e <<
">" << std::endl);
60 std::istringstream in(e);
63 DEBUGCOUT(
"GetEnv: variable <" << e <<
"> read" << std::endl);
71 DEBUGCOUT(
"reading var <" << *env <<
">" << std::endl);
77 v = std::strchr(p,
'=');
79 silent_cerr(
"parse error in envvar <"
80 << p <<
">" << std::endl);
88 if (strcmp(p,
"MBDYNVARS") == 0) {
91 }
else if (strncmp(p,
"MBDYN_real_",
STRLENOF(
"MBDYN_real_")) == 0) {
96 int save_errno = errno;
97 if (endptr != NULL && endptr[0] !=
'\0') {
98 silent_cerr(
"SetEnv: unable to parse "
100 "for var <" << p <<
">"
105 }
else if (save_errno == ERANGE) {
106 silent_cerr(
"SetEnv: real <" << v <<
"> "
107 "for var <" << p <<
"> overflows"
113 << n <<
"=" << d <<
">" << std::endl);
115 if ((T.
Get(n)) == NULL) {
116 if (T.
Put(n,
Real(d)) == NULL) {
117 silent_cerr(
"SetEnv:"
118 " error in insertion"
120 << n <<
">" << std::endl);
126 }
else if (strncmp(p,
"MBDYN_integer_",
STRLENOF(
"MBDYN_integer_")) == 0) {
131 long i = strtol(v, &endptr, 10);
132 int save_errno = errno;
133 if (endptr != NULL && endptr[0] !=
'\0') {
134 silent_cerr(
"SetEnv: unable to parse "
135 "integer <" << v <<
"> "
136 "for var <" << p <<
">"
141 }
else if (save_errno == ERANGE) {
142 silent_cerr(
"SetEnv: integer <" << v <<
"> "
143 "for var <" << p <<
"> overflows"
152 << n <<
"=" << i <<
">" << std::endl);
154 if ((T.
Get(n)) == NULL) {
155 if (T.
Put(n,
Int(i)) == NULL) {
156 silent_cerr(
"SetEnv:"
157 " error in insertion"
158 " of integer symbol <"
159 << n <<
">" << std::endl);
165 }
else if (strncmp(p,
"MBDYN_string_",
STRLENOF(
"MBDYN_string_")) == 0) {
167 if ((T.
Get(n)) == NULL) {
169 silent_cerr(
"SetEnv:"
170 " error in insertion"
171 " of string symbol <"
172 << n <<
">" << std::endl);
179 silent_cerr(
"unknown var type <"
180 << p <<
">; skipping ..." << std::endl);
#define MBDYN_EXCEPT_ARGS
Var * Put(const std::string &name, const TypedValue &v)
#define SAFEDELETEARR(pnt)
void GetEnviron(MathParser &MP)
static const char MBDYNPREFIX[]
NamedValue * Get(const std::string &name) const
Real GetLastStmt(Real d=0., Token t=ARGSEP)
#define SAFESTRDUP(pnt, src)
Table & GetSymbolTable(void) const