NEURON
nrnversion.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include <nrnversion.h>
6 #include <nrnconfigargs.h>
7 #include <assert.h>
8 #include "nrnassrt.h"
9 
10 
11 extern int nrn_global_argc;
12 extern char** nrn_global_argv;
13 
14 extern int nrn_main_launch; /* 1 if nrniv, 2 if python, 0 if unknownn */
15 
16 static char* ver[10];
17 static char* sarg = 0;
18 static char configargs[] = NRN_CONFIG_ARGS;
19 
20 #if !defined(GIT_BRANCH)
21 #define GIT_DATE "2018-08-24"
22 #define GIT_BRANCH "unknown"
23 #define GIT_CHANGESET "d3ead4a+"
24 #define GIT_DESCRIBE "7.6.2-2-gd3ead4a+"
25 #endif
26 
27 char *nrn_version(int i) {
28  char buf[1024];
29  char head[1024];
30  char *cp;
31  int b;
32  buf[0] = '\0';
33  if (strncmp(GIT_BRANCH, "Release", 7) == 0) {
34  sprintf(head, "%s (%s)", GIT_BRANCH, GIT_CHANGESET);
35  } else {
36  sprintf(head, "VERSION %s %s (%s)",
38  GIT_BRANCH,
40  }
41  if (i == 0) {
42  sprintf(buf, "%s", PACKAGE_VERSION);
43  } else if (i == 2) {
44  sprintf(buf, "%s", head);
45  } else if (i == 3) {
46  sprintf(buf, "%s", GIT_CHANGESET);
47  } else if (i == 4) {
48  sprintf(buf, "%s", GIT_DATE);
49  } else if (i == 5) {
50  sprintf(buf, "%s", GIT_DESCRIBE);
51  } else if (i == 6) {
52  return configargs;
53  } else if (i == 7) {
54  int j, size;
55  if (!sarg) {
56  char *c;
57  int size = 0;
58  for (j = 0; j < nrn_global_argc; ++j) {
59  size += strlen(nrn_global_argv[j]) + 1;
60  }
61  sarg = (char *) calloc(size + 1, sizeof(char));
62  c = sarg;
63  for (j = 0; j < nrn_global_argc; ++j) {
64  sprintf(c, "%s%s", j ? " " : "", nrn_global_argv[j]);
65  c = c + strlen(c);
66  }
67  }
68  return sarg;
69  } else if (i == 8) {
70  sprintf(buf, "%s", NRNHOST);
71  } else if (i == 9) {
72  sprintf(buf, "%d", nrn_main_launch);
73  } else {
74  nrn_assert(snprintf(buf, 1024, "NEURON -- %s %s", head, GIT_DATE) < 1024);
75  }
76 
77  if (i > 9) { i = 1; }
78  if (!ver[i]) {
79  ver[i] = strdup(buf);
80  }
81 
82  return ver[i];
83 }
84 
85 
static char configargs[]
Definition: nrnversion.cpp:18
#define nrn_assert(ex)
Definition: nrnassrt.h:35
#define GIT_BRANCH
Definition: nrnversion.cpp:22
static char * sarg
Definition: nrnversion.cpp:17
int nrn_global_argc
Definition: hoc.cpp:29
#define GIT_DESCRIBE
Definition: nrnversion.cpp:24
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
#define GIT_DATE
Definition: nrnversion.cpp:21
int nrn_main_launch
Definition: hoc_init.cpp:396
size_t j
#define i
Definition: md1redef.h:12
#define c
char ** nrn_global_argv
Definition: hoc.cpp:30
char buf[512]
Definition: init.cpp:13
char * nrn_version(int i)
Definition: nrnversion.cpp:27
static char * ver[10]
Definition: nrnversion.cpp:16
#define GIT_CHANGESET
Definition: nrnversion.cpp:23