Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git] / Taumath.cpp.bak
blobc58e1618749740714a1f9ab5eaa90a8df57738f1
1 #include <stdio.h>
2 #include <setjmp.h>
4 #include "defs.h"
5 extern "C"{
6 #include "console.h"
7 #include "fxlib.h"
8 #define EXPR_BUF_SIZE 256
10 extern U ** mem;
11 extern unsigned int **free_stack;
13 int
14 initialize_tuamath()
16         // modified by anderain 
17         free_stack      = (unsigned int**)      calloc(500,sizeof(unsigned int*));
18         mem                     = (U**)                         calloc(100,sizeof(U*));
19         stack           = (U**)                         calloc(TOS,sizeof(U*));
20         symtab          = (U*)                          calloc(NSYM,sizeof(U));
21         binding         = (U**)                         calloc(NSYM,sizeof(U*));
22         arglist         = (U**)                         calloc(NSYM,sizeof(U*));
23         logbuf          = (char*)                       calloc(256,1);
26 const unsigned char *Setup[]={
27         "logab(a,b)=log(b)/log(a)",
28         "log10(x)=log(x)/log(10)",
29         "ln(x)=log(x)",
30         "cis(x)=cos(x)+i*sin(x)",
31         "cot(x)=1/tan(x)",
32         "coth(x)=cosh(x)/sinh(x)",
33         "arccot(x)=arctan(1/x)",
34         "arccoth(x)=arctanh(1/x)",
35         "sec(x)=1/cos(x)",
36         "sech(x)=1/cosh(x)",
37         "arcsec(x)=arccos(1/x)",
38         "arcsech(x)=arccosh(1/x)",
39         "csc(x)=1/sin(x)",
40         "csch(x)=1/sinh(x)",
41         "arccsc(x)=arcsin(1/x)",
42         "arccsch(x)=arcsinh(1/x)",
43         "npr(n,r)=(n!)/(n-r)!",
44         "ncr(n,r)=n!/(r!(n-r)!)",
45         "xor(x,y)=or(and(x,not(y)),and(not(x),y))",
46         NULL,
49 int AddIn_main(int isAppli, unsigned short OptionNum)
51         unsigned int    key;
52         unsigned char *expr;
54         initialize_tuamath();
55         // initialize failed ?
56         if (!(free_stack && mem && stack && symtab && binding && arglist && logbuf))
57                 return 0;
59         int i = 0;
60         while(Setup[i] != NULL)
61         {
62                 run((char *)Setup[i++]);
63         }
65     Console_Init();
66         Console_Disp();
67         while(1)
68         {
69                 if((expr=Console_GetLine())==NULL) stop("memory error");
70                 run((char *)expr);
71                 Console_NewLine(LINE_TYPE_OUTPUT,1);
72                 Console_Disp();
73         }
76         for(;;)GetKey(&key);
77     return 1;
80 #pragma section _BR_Size
81 unsigned long BR_Size;
82 #pragma section
84 #pragma section _TOP
85 int InitializeSystem(int isAppli, unsigned short OptionNum)
87     return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
89 #pragma section