NEURON
ocmain.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 /* /local/src/master/nrn/src/oc/ocmain.cpp,v 1.7 1997/07/29 20:23:33 hines Exp */
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <hocdec.h>
7 
9 extern const char* neuron_home;
10 
11 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj) = NULL;
12 extern double (*nrnpy_object_to_double_)(Object*) = NULL;
13 
14 #if MAC
15 char hoc_console_buffer[256];
16 #endif
17 
18 #if defined(WIN32)
19 void* cvode_pmem;
20 extern void setneuronhome(const char*);
21 #endif
22 
23 static void setnrnhome(const char* arg) {
24 
25 #if !defined(WIN32)&&!defined(MAC)
26 /*
27  Gary Holt's first pass at this was:
28 
29  Set the NEURONHOME environment variable. This should override any setting
30  in the environment, so someone doesn't accidently use data files from an
31  old version of neuron.
32 
33  But I have decided to use the environment variable if it exists
34 */
35  neuron_home = getenv("NEURONHOME");
36  if (!neuron_home) {
37 #if defined(HAVE_PUTENV)
38  static char* buffer;
39  buffer = static_cast<char *>(malloc(strlen(NEURON_DATA_DIR) + 12));
40  sprintf(buffer, "NEURONHOME=%s", NEURON_DATA_DIR);
41  putenv(buffer);
42  neuron_home = NEURON_DATA_DIR;
43 #elif defined(HAVE_SETENV)
44  setenv("NEURONHOME", NEURON_DATA_DIR, 1);
45  neuron_home = NEURON_DATA_DIR;
46 #else
47 #error "I don't know how to set environment variables."
48 // Maybe in this case the user will have to set it by hand.
49 #endif
50  }
51 
52 #else // Not unix:
53  setneuronhome(arg);
54 #endif
55 }
56 
57 #if LINDA /* LINDA (SAF) */
58 real_main(int argc, const char** argv, const char**envp) {
59 #else
60 int main(int argc, const char** argv, const char** envp) {
61 #endif
62  int err;
63  nrn_isdouble(nullptr, 0., 0.);
64 #if MAC
65 int our_argc = 1;
66 char *our_argv[1];
67 our_argv[0] = "Neuron";
68  err = hoc_main1(our_argc, our_argv, envp);
69 #else
70  setnrnhome(argv[0]);
71  err = hoc_main1(argc, argv, envp);
72 #endif
73  if (!err) {
75  }
76 #if EXPRESS
77  exit(0);
78 #else
79 #if LINDA
80  lexit(0);
81 #else
82  return err;
83 #endif
84 #endif
85 }
86 
87 
88 void hoc_single_event_run() { /* for interviews, ivoc make use of own main */
89 #if LINDA
90  extern int hoc_retreat_flag;
91  if (hoc_retreat_flag) {
92  hoc_retreat();
93  }
94 #endif
95 #if INTERVIEWS && 0
97 #endif
98  hoc_ret();
99  hoc_pushx(0.);
100 }
101 
102 int run_til_stdin() {return 1;}
104 
105 #ifdef WIN32
106 void ivcleanup() {}
107 void ivoc_win32_cleanup() {}
108 int bad_install_ok;
109 #endif
void hoc_final_exit()
Definition: hoc.cpp:1130
int hoc_nframe
Definition: ocmain.cpp:8
const char * neuron_home
Definition: hoc_init.cpp:268
int bad_install_ok
Definition: mswinprt.cpp:36
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
void hoc_ret()
#define putenv
Definition: mwprefix.h:37
void single_event_run()
int nrn_isdouble(double *, double, double)
Definition: isoc99.cpp:12
void hoc_single_event_run()
Definition: ocmain.cpp:88
char * getenv(const char *s)
Definition: macprt.cpp:67
char * name
Definition: init.cpp:16
static void setnrnhome(const char *arg)
Definition: ocmain.cpp:23
void hoc_pushx(double)
int hoc_nstack
Definition: ocmain.cpp:8
void hoc_notify_value()
Definition: ocmain.cpp:103
Definition: hocdec.h:226
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
int main(int argc, const char **argv, const char **envp)
Definition: ocmain.cpp:60
#define arg
Definition: redef.h:28
int run_til_stdin()
Definition: ocmain.cpp:102
int hoc_main1(int, const char **, const char **)
Definition: hoc.cpp:972
void setneuronhome(const char *)
Definition: ivocmain.cpp:196
static int argc
Definition: inithoc.cpp:53
return NULL
Definition: cabcode.cpp:461
static char ** argv
Definition: inithoc.cpp:54