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)", GIT_DESCRIBE, GIT_BRANCH, GIT_CHANGESET);
37  }
38  if (i == 0) {
39  sprintf(buf, "%s", PACKAGE_VERSION);
40  } else if (i == 2) {
41  sprintf(buf, "%s", head);
42  } else if (i == 3) {
43  sprintf(buf, "%s", GIT_CHANGESET);
44  } else if (i == 4) {
45  sprintf(buf, "%s", GIT_DATE);
46  } else if (i == 5) {
47  sprintf(buf, "%s", GIT_DESCRIBE);
48  } else if (i == 6) {
49  return configargs;
50  } else if (i == 7) {
51  int j, size;
52  if (!sarg) {
53  char* c;
54  int size = 0;
55  for (j = 0; j < nrn_global_argc; ++j) {
56  size += strlen(nrn_global_argv[j]) + 1;
57  }
58  sarg = (char*) calloc(size + 1, sizeof(char));
59  c = sarg;
60  for (j = 0; j < nrn_global_argc; ++j) {
61  sprintf(c, "%s%s", j ? " " : "", nrn_global_argv[j]);
62  c = c + strlen(c);
63  }
64  }
65  return sarg;
66  } else if (i == 8) {
67  sprintf(buf, "%s", NRNHOST);
68  } else if (i == 9) {
69  sprintf(buf, "%d", nrn_main_launch);
70  } else {
71  nrn_assert(snprintf(buf, 1024, "NEURON -- %s %s", head, GIT_DATE) < 1024);
72  }
73 
74  if (i > 9) {
75  i = 1;
76  }
77  if (!ver[i]) {
78  ver[i] = strdup(buf);
79  }
80 
81  return ver[i];
82 }
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
#define c
char buf[512]
Definition: init.cpp:13
#define i
Definition: md1redef.h:12
#define nrn_assert(ex)
Definition: nrnassrt.h:53
size_t j
char * nrn_version(int i)
Definition: nrnversion.cpp:27
int nrn_global_argc
Definition: hoc.cpp:29
#define GIT_DESCRIBE
Definition: nrnversion.cpp:24
#define GIT_CHANGESET
Definition: nrnversion.cpp:23
#define GIT_BRANCH
Definition: nrnversion.cpp:22
static char * sarg
Definition: nrnversion.cpp:17
#define GIT_DATE
Definition: nrnversion.cpp:21
int nrn_main_launch
Definition: hoc_init.cpp:528
char ** nrn_global_argv
Definition: hoc.cpp:30
static char * ver[10]
Definition: nrnversion.cpp:16
static char configargs[]
Definition: nrnversion.cpp:18