Browse Source

Add function ngSpice_nospiceinit(void) if you don't want to read .spiceinit

pre-master-46
Holger Vogt 1 year ago
parent
commit
2b89d2a1cd
  1. 15
      src/include/ngspice/sharedspice.h
  2. 18
      src/sharedspice.c

15
src/include/ngspice/sharedspice.h

@ -3,12 +3,21 @@
/* Modified BSD license */
/*
Interface between a calling program (caller) and ngspice.dll (ngspice.so)
Interface between a calling program (caller) and ngspice.dll (libngspice.so)
**
ngSpice_nospinit(void)
Set variable no_spinit, if reading the initialization file 'spinit' is not wanted.
To be called before ngSpice_Init()
**
ngSpice_nospiceinit(void)
Set variable no_spiceinit, if reading the user defined initialization file
'.spiceinit' is not wanted.
To be called before ngSpice_Init().
Use with care, as this removes the last chance to send preparative commands
before the netlist is loaded. Then use the the caller to send such commands.
**
ngSpice_Init(SendChar*, SendStat*, ControlledExit*,
SendData*, SendInitData*, BGThreadRunning*, void*)
@ -453,6 +462,10 @@ NG_BOOL ngSpice_SetBkpt(double time);
IMPEXP
int ngSpice_nospinit(void);
/* Set variable no_spiceinit, if reading '.spiceinit' is not wanted. */
IMPEXP
int ngSpice_nospiceinit(void);
#ifdef __cplusplus
}
#endif

18
src/sharedspice.c

@ -814,6 +814,16 @@ ngSpice_nospinit(void)
return 0;
}
/* Set variable no_spiceinit, if reading '.spiceinit' is not wanted. */
IMPEXP
int
ngSpice_nospiceinit(void)
{
bool t = TRUE;
cp_vset("no_spicenit", CP_BOOL, &t);
return 0;
}
/* Initialise external voltage source and synchronization */
IMPEXP
int
@ -972,7 +982,9 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi
try accessing the initialisation file .spiceinit in a user provided
path read from environmental variable SPICE_USERINIT_DIR,
if that fails try the alternate name spice.rc, then look into
the current directory, then the HOME directory, then into USERPROFILE */
the current directory, then the HOME directory, then into USERPROFILE.
Don't read .spiceinit, if ngSpice_nospiceinit() has been called. */
if (!cp_getvar("no_spiceinit", CP_BOOL, NULL, 0)) {
do {
{
const char* const userinit = getenv("SPICE_USERINIT_DIR");
@ -1017,6 +1029,10 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi
}
}
} while (0); /* end of case that init file is read */
}
else {
fprintf(stdout, "Note: .spiceinit is ignored, because ngSpice_nospiceinit() has been called.\n");
}
#endif /* ~ HAVE_PWD_H */

Loading…
Cancel
Save