MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
env.c File Reference
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for env.c:

Go to the source code of this file.

Functions

int main (void)
 

Variables

char ** environ
 

Function Documentation

int main ( void  )

Definition at line 40 of file env.c.

References c, and environ.

41 {
42  char** s = environ;
43  int c = 0;
44 
45  if (s == NULL || *s == NULL) {
46  printf("environment is empty!\n");
47  return EXIT_SUCCESS;
48  }
49 
50  do {
51  long int i = 0;
52  double d = 0.;
53  char* p = NULL;
54  char* v = NULL;
55  char* n = NULL;
56 
57  if (strncmp(*s, "MBDYN", 5) != 0) {
58  continue;
59  }
60 
61  c++;
62 
63  printf("%s\n", *s);
64 
65  p = strdup(*s);
66  if (p == NULL) {
67  fprintf(stderr, "error 1\n");
68  exit(EXIT_FAILURE);
69  }
70  v = strchr(p, '=');
71  if (v == NULL) {
72  fprintf(stderr, "error 2\n");
73  exit(EXIT_FAILURE);
74  }
75 
76  *v = '\0';
77  v++;
78 
79  if (strncmp(p+5, "_real_", 6) == 0) {
80  n = p+11;
81  d = atof(v);
82  printf("env=%s, var=%s, val=%s(%e, real)\n",
83  *s, n, v, d);
84  } else if (strncmp(p+5, "_integer_", 9) == 0) {
85  n = p+14;
86  i = atoi(v);
87  printf("env=%s, var=%s, val=%s(%ld, integer)\n",
88  *s, n, v, i);
89  } else {
90  fprintf(stderr, "error 3\n");
91  exit(EXIT_FAILURE);
92  }
93  } while (*++s);
94 
95  printf("%d entries\n", c);
96 
97  return EXIT_SUCCESS;
98 }
char ** environ
static std::stack< cleanup * > c
Definition: cleanup.cc:59

Variable Documentation

char** environ

Referenced by main().