Initial commit of newLISP.
[newlisp.git] / unix-lib.c
blob9f7722aa153cbc41a3b0a213a854d36148cd2ec6
1 /* unix-lib.c - make the newlisp shared newlisp library
3 Copyright (C) 2008 Lutz Mueller
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "newlisp.h"
21 #include "protos.h"
23 extern void setupAllSignals(void);
24 extern int evalSilent;
25 extern int opsys;
26 extern SYMBOL * mainArgsSymbol;
28 int libInitialized = 0;
30 void initializeMain(void)
32 opsys += 64;
34 #ifdef SUPPORT_UTF8
35 opsys += 128;
36 #endif
38 initLocale();
39 initialize();
41 mainArgsSymbol->contents = (UINT)getCell(CELL_EXPRESSION);
42 setupAllSignals();
44 initStacks();
46 libInitialized = 1;
47 reset();
51 extern STREAM errorStream;
52 STREAM libStrStream;
55 /* ---- imported and called from a client using newlisp.so ---- */
57 char * newlispEvalStr(char * cmd)
59 if(!libInitialized) initializeMain();
61 if(setjmp(errorJump))
63 setupAllSignals();
65 reset();
66 initStacks();
68 if(errorReg)
70 executeSymbol(errorEvent, NULL);
71 return(libStrStream.buffer);
73 else
74 return(errorStream.buffer);
77 openStrStream(&libStrStream, MAX_STRING, 1);
78 executeCommandLine(cmd, OUT_CONSOLE, NULL);
80 if(evalSilent) evalSilent = 0;
82 return(libStrStream.buffer);
85 /* eof */