2 #include <../../nrnconf.h> 16 #include "../mswin/extra/d2upath.cpp" 43 char buf[256];
char *
s;
54 GetModuleFileName(
NULL, buf, 256);
55 for (i=strlen(buf); i >= 0 && buf[
i] !=
'\\'; --
i) {;}
58 for (j=strlen(buf); j >= 0 && buf[
j] !=
'\\'; --
j) {;}
68 &&(buf[--i] ==
'n' || buf[i] ==
'N')
69 &&(buf[--i] ==
'i' || buf[i] ==
'I')
70 &&(buf[--i] ==
'b' || buf[i] ==
'B')
72 char buf1[256], *nh_old;
76 sprintf(buf1,
"%s/lib/nrn.def", buf);
77 if ((f =
fopen(buf1,
"r")) == (FILE*)0) {
78 sprintf(buf1,
"%s/lib/nrn.defaults", buf);
79 if ((f =
fopen(buf1,
"r")) == (FILE*)0) {
86 sprintf(buf1,
"NEURONHOME=%s", buf);
87 nh_old =
getenv(
"NEURONHOME");
90 if (!nh_old ||
stricmp(buf, nh_old) != 0) {
91 printf(
"Setting %s", buf1);
93 printf(
" from old value of %s\n", nh_old);
97 s =
static_cast<char *
>(
emalloc(strlen(buf1)+1));
106 if (!
neuron_home) MessageBox(
NULL, p,
"Can't compute NEURONHOME from", MB_OK);
118 hoc_execerror(
"\nUnhandled Exception. This usually means a bad memory \n\ 119 address.",
"It is not possible to make a judgment as to whether it is safe\n\ 120 to continue. If this happened while compiling a template, you will have to\n\ 124 MessageBox(
NULL,
"Second Unhandled Exception: Quitting NEURON. You will be asked to save \ 125 any unsaved em buffers before exiting.",
"NEURON Internal ERROR", MB_OK);
128 return EXCEPTION_EXECUTE_HANDLER;
132 SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)
exception_filter);
135 return CopyFile(src, dest,
FALSE);
138 static FILE*
dll_stdio_[] = {(FILE*)0x0, (FILE*)0x20, (FILE*)0x40};
142 printf(
"nrn_mswindll_stdio stdio in dll = %p but expected %p\n", o,
dll_stdio_[1]);
154 #define ncyg_fprintf fprintf 160 static char s[4096] = {0};
162 va_start(marker, strFmt);
165 printf(
"ncyg stdin=%lx\n", (
long)stdin);
166 printf(
"ncyg stdout=%lx\n", (
long)stdout);
167 printf(
"ncyg stderr=%lx\n", (
long)stderr);
169 printf(
"ncyg dll_stdio[1]=%lx\n", (
long)dll_stdio_[1]);
170 printf(
"ncyg dll_sdtio[2]=%lx\n", (
long)dll_stdio_[2]);
171 printf(
"ncyg stream=%lx\n", (
long)stream);
173 if (stream == dll_stdio_[1]) {
175 }
else if (stream == dll_stdio_[2]) {
178 len = vsprintf(s, strFmt, marker);
186 for (cp = s; *cp; ++cp) {
205 void ivoc_win32_cleanup();
212 ivoc_win32_cleanup();
247 while (PeekMessage(&msg,
hCurrWnd, 0, 0, PM_REMOVE))
249 TranslateMessage(&msg);
250 DispatchMessage(&msg);
255 #if defined(__MWERKS__) 256 void __assertfail() {
printf(
"assertfail\n");}
260 char* dos_neuronhome() {
261 static char* dnrnhome;
264 nrnhome =
getenv(
"NEURONHOME");
265 dnrnhome =
static_cast<char *
>(
emalloc(strlen(nrnhome) + 1));
266 strcpy(dnrnhome, nrnhome);
267 for (cp = dnrnhome; *cp; ++cp) {
277 #define HOCXDOS "lib/nrnsys.sh" 278 #define SEMA1 "tmpdos1.tmp" 279 #define SEMA2 "tmpdos2.tmp" 282 char buf[256], stin[128];
289 redirect = strchr(s,
'>');
291 strcpy(stin, redirect+1);
292 sprintf(buf,
"%s\\bin\\sh %s/%s %s %s %s",
294 redirect = strchr(buf,
'>');
297 sprintf(buf,
"%s\\bin\\sh %s/%s %s %s %s",
301 if (WinExec(buf, 0) < 32) {
304 while((fin =
fopen(
SEMA1,
"r")) == (FILE*)0) {
310 if (!redirect && (fin =
fopen(
SEMA2,
"r")) != (FILE*)0) {
311 while(fgets(buf, 256, fin)) {
329 static int ready = 0;
344 ShowWindow(
hCurrWnd, b ? SW_SHOW : SW_HIDE);
354 #if !defined(__MWERKS__)
void setneuronhome(const char *p)
double(* nrnpy_object_to_double_)(Object *)
void hoc_winio_show(int b)
static HCURSOR wait_cursor
char * hoc_dos2unixpath(const char *d)
void HandleOutput(char *s)
const char * expand_env_var(const char *s)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
int system(const char *s)
static long exception_filter(LPEXCEPTION_POINTERS p)
int const size_t const size_t n
#define TRY_GUI_REDIRECT_DOUBLE(name, obj)
void hoc_check_intupt(int intupt)
FILE * popen(char *s1, char *s2)
void hoc_execerror(const char *, const char *)
void Fig_file(const char *, int)
BOOL hoc_copyfile(const char *src, const char *dest)
char * getenv(const char *s)
char * hoc_back2forward(char *s)
static FILE * dll_stdio_[]
char * emalloc(unsigned n)
static HCURSOR old_cursor
void hoc_forward2back(char *s)
void hoc_set_unhandled_exception_filter()
void nrn_mswindll_stdio(FILE *i, FILE *o, FILE *e)
double chkarg(int, double low, double high)