ReactOS  0.4.12-dev-18-gf469aca
calc.h
Go to the documentation of this file.
1 #ifndef _CALC_H
2 #define _CALC_H
3 
4 #include <stdarg.h>
5 #include <windef.h>
6 #include <winuser.h>
7 #include <tchar.h>
8 #include <math.h>
9 #include <float.h>
10 #include <malloc.h>
11 #ifndef DISABLE_HTMLHELP_SUPPORT
12 #include <htmlhelp.h>
13 #endif
14 
15 /* Messages reserved for the main dialog */
16 #define WM_CLOSE_STATS (WM_APP+1)
17 #define WM_HANDLE_CLIPBOARD (WM_APP+2)
18 #define WM_INSERT_STAT (WM_APP+3)
19 #define WM_LOAD_STAT (WM_APP+4)
20 #define WM_START_CONV (WM_APP+5)
21 #define WM_HANDLE_FROM (WM_APP+6)
22 #define WM_HANDLE_TO (WM_APP+7)
23 
24 #ifdef ENABLE_MULTI_PRECISION
25 #include <mpfr.h>
26 
27 #ifndef MPFR_DEFAULT_RND
28 #define MPFR_DEFAULT_RND mpfr_get_default_rounding_mode ()
29 #endif
30 
31 #define LOCAL_EXP_SIZE 100000000L
32 #else
33 
34 #define LOCAL_EXP_SIZE 10000L
35 
36 #endif
37 
38 #include "resource.h"
39 
40 #ifndef IDC_STATIC
41 #define IDC_STATIC ((DWORD)-1)
42 #endif
43 
44 #define MAX_CALC_SIZE 256
45 
46 /*#define USE_KEYBOARD_HOOK*/
47 
48 #define SIZEOF(_ar) (sizeof(_ar)/sizeof(_ar[1]))
49 
50 // RPN.C
51 
52 enum {
56 
69 
71 };
72 
73 typedef union {
74 #ifdef ENABLE_MULTI_PRECISION
75  mpfr_t mf;
76 #else
77  double f;
80 #endif
82 
83 typedef struct {
85  unsigned int operation;
87 } calc_node_t;
88 
90  calc_node_t *b, unsigned int operation);
91 int exec_infix2postfix(calc_number_t *, unsigned int);
93 int eval_parent_count(void);
94 void flush_postfix(void);
95 void exec_change_infix(void);
96 void start_rpn_engine(void);
97 void stop_rpn_engine(void);
98 
99 typedef struct {
100  char *data;
101  char *ptr;
103 } sequence_t;
104 
105 typedef struct {
108  void *next;
109 } statistic_t;
110 
111 enum {
115 };
116 
117 typedef struct {
119 #ifdef USE_KEYBOARD_HOOK
120  HHOOK hKeyboardHook;
121 #endif
137  signed int esp;
145  sequence_t Convert[2];
146  unsigned int last_operator;
147  unsigned int prev_operator;
148  TCHAR sDecimal[8];
149  TCHAR sThousand[8];
150  unsigned int sDecimal_len;
151  unsigned int sThousand_len;
152  signed int x_coord;
153  signed int y_coord;
154 } calc_t;
155 
156 extern calc_t calc;
157 
158 #define CALC_E 2.7182818284590452354
159 
160 #define CALC_PI_2 1.57079632679489661923
161 #define CALC_PI 3.14159265358979323846
162 #define CALC_3_PI_2 4.71238898038468985769
163 #define CALC_2_PI 6.283185307179586476925
164 
165 #define MODIFIER_INV 0x01
166 #define MODIFIER_HYP 0x02
167 #define NO_CHAIN 0x04
168 
170 #ifdef ENABLE_MULTI_PRECISION
173 #else
175 double logic_int2dbl(calc_number_t *a);
176 double validate_rad2angle(double a);
178 #endif
179 void rpn_sin(calc_number_t *c);
180 void rpn_cos(calc_number_t *c);
181 void rpn_tan(calc_number_t *c);
182 void rpn_asin(calc_number_t *c);
183 void rpn_acos(calc_number_t *c);
184 void rpn_atan(calc_number_t *c);
185 void rpn_sinh(calc_number_t *c);
186 void rpn_cosh(calc_number_t *c);
187 void rpn_tanh(calc_number_t *c);
188 void rpn_asinh(calc_number_t *c);
189 void rpn_acosh(calc_number_t *c);
190 void rpn_atanh(calc_number_t *c);
192 void rpn_int(calc_number_t *c);
193 void rpn_frac(calc_number_t *c);
194 void rpn_reci(calc_number_t *c);
195 void rpn_fact(calc_number_t *c);
196 void rpn_not(calc_number_t *c);
197 void rpn_pi(calc_number_t *c);
198 void rpn_2pi(calc_number_t *c);
199 void rpn_sign(calc_number_t *c);
200 void rpn_exp2(calc_number_t *c);
201 void rpn_exp3(calc_number_t *c);
202 void rpn_sqrt(calc_number_t *c);
203 void rpn_cbrt(calc_number_t *c);
204 void rpn_exp(calc_number_t *c);
205 void rpn_exp10(calc_number_t *c);
206 void rpn_ln(calc_number_t *c);
207 void rpn_log(calc_number_t *c);
208 void rpn_ave(calc_number_t *c);
209 void rpn_sum(calc_number_t *c);
210 void rpn_s(calc_number_t *c);
211 void rpn_s_m1(calc_number_t *c);
214 void rpn_zero(calc_number_t *c);
217 void rpn_alloc(calc_number_t *c);
218 void rpn_free(calc_number_t *c);
219 
220 void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base);
222 void convert_real_integer(unsigned int base);
223 
225 
226 void ConvExecute(HWND hWnd);
227 void ConvAdjust(HWND hWnd, int n_cat);
228 void ConvInit(HWND hWnd);
229 
230 #endif /* _CALC_H */
void rpn_s(calc_number_t *c)
Definition: fun_mpfr.c:403
statistic_t * stat
Definition: calc.h:130
DWORD base
Definition: calc.h:138
void rpn_pi(calc_number_t *c)
Definition: fun_mpfr.c:269
UINT64 u
Definition: calc.h:79
void rpn_acosh(calc_number_t *c)
Definition: fun_mpfr.c:213
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
UINT wm_msg
Definition: calc.h:102
BOOL sci_out
Definition: calc.h:133
calc_number_t code
Definition: calc.h:127
void rpn_cbrt(calc_number_t *c)
Definition: fun_mpfr.c:303
Definition: calc.h:117
BOOL is_menu_on
Definition: calc.h:136
DWORD layout
Definition: calc.h:123
void rpn_atanh(calc_number_t *c)
Definition: fun_mpfr.c:218
void rpn_sqrt(calc_number_t *c)
Definition: fun_mpfr.c:297
TCHAR * ptr
Definition: calc.h:126
double f
Definition: calc.h:77
unsigned int sThousand_len
Definition: calc.h:151
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
void rpn_free(calc_number_t *c)
Definition: fun_mpfr.c:487
#define CALLBACK
Definition: compat.h:27
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn.c:288
HWND hWnd
Definition: settings.c:17
void rpn_exp(calc_number_t *c)
Definition: fun_mpfr.c:309
void convert_real_integer(unsigned int base)
Definition: utl.c:92
GLuint buffer
Definition: glext.h:5915
DWORD degr
Definition: calc.h:140
void ConvInit(HWND hWnd)
Definition: convert.c:615
double logic_int2dbl(calc_number_t *a)
Definition: function.c:253
int32_t INT_PTR
Definition: typedefs.h:62
BOOL is_nan
Definition: calc.h:132
signed int esp
Definition: calc.h:137
void rpn_asin(calc_number_t *c)
Definition: fun_mpfr.c:176
void rpn_dms2dec(calc_number_t *c)
Definition: fun_mpfr.c:413
void rpn_frac(calc_number_t *c)
Definition: fun_mpfr.c:229
UINT_PTR WPARAM
Definition: windef.h:207
void rpn_exp2(calc_number_t *c)
Definition: fun_mpfr.c:285
void rpn_not(calc_number_t *c)
Definition: fun_mpfr.c:258
double validate_angle2rad(calc_number_t *c)
Definition: fun_mpfr.c:58
__int64 logic_dbl2int(calc_number_t *a)
Definition: function.c:240
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
DWORD action
Definition: calc.h:141
void convert_text2number_2(calc_number_t *a)
Definition: utl.c:66
void exec_change_infix(void)
Definition: rpn.c:397
LONG_PTR LPARAM
Definition: windef.h:208
void ConvExecute(HWND hWnd)
Definition: convert.c:533
DWORD size
Definition: calc.h:139
signed int y_coord
Definition: calc.h:153
void rpn_log(calc_number_t *c)
Definition: fun_mpfr.c:327
UINT msg
Definition: msvc.h:92
unsigned int prev_operator
Definition: calc.h:147
HINSTANCE hInstance
Definition: calc.h:118
signed int x_coord
Definition: calc.h:152
void rpn_acos(calc_number_t *c)
Definition: fun_mpfr.c:181
void rpn_ave(calc_number_t *c)
Definition: fun_mpfr.c:344
void start_rpn_engine(void)
Definition: rpn.c:454
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: sndrec32.cpp:83
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn.c:365
char TCHAR
Definition: xmlstorage.h:189
HWND hWnd
Definition: calc.h:122
void * next
Definition: calc.h:108
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
void rpn_cosh(calc_number_t *c)
Definition: fun_mpfr.c:197
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
int rpn_is_zero(calc_number_t *c)
Definition: fun_mpfr.c:477
unsigned int sDecimal_len
Definition: calc.h:150
void rpn_int(calc_number_t *c)
Definition: fun_mpfr.c:224
BOOL usesep
Definition: calc.h:135
char * ptr
Definition: calc.h:101
INT64 i
Definition: calc.h:78
void rpn_ln(calc_number_t *c)
Definition: fun_mpfr.c:321
void rpn_tan(calc_number_t *c)
Definition: fun_mpfr.c:154
void rpn_dec2dms(calc_number_t *c)
Definition: fun_mpfr.c:440
const GLubyte * c
Definition: glext.h:8905
unsigned int UINT
Definition: ndis.h:50
void rpn_s_m1(calc_number_t *c)
Definition: fun_mpfr.c:408
unsigned long DWORD
Definition: ntddk_ex.h:95
void rpn_sign(calc_number_t *c)
Definition: fun_mpfr.c:280
BOOL sci_in
Definition: calc.h:134
int eval_parent_count(void)
Definition: rpn.c:432
void rpn_2pi(calc_number_t *c)
Definition: fun_mpfr.c:274
unsigned int last_operator
Definition: calc.h:146
#define MAX_CALC_SIZE
Definition: calc.h:44
void rpn_sinh(calc_number_t *c)
Definition: fun_mpfr.c:192
DWORD base
Definition: calc.h:107
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl.c:3
calc_number_t number
Definition: calc.h:84
double validate_rad2angle(double a)
Definition: function.c:50
signed long long INT64
HWND hConvWnd
Definition: calc.h:143
void exec_closeparent(calc_number_t *)
Definition: rpn.c:411
void rpn_cos(calc_number_t *c)
Definition: fun_mpfr.c:130
void rpn_atan(calc_number_t *c)
Definition: fun_mpfr.c:186
char * data
Definition: calc.h:100
void rpn_exp10(calc_number_t *c)
Definition: fun_mpfr.c:315
void flush_postfix(void)
Definition: rpn.c:445
BOOL rpn_validate_result(calc_number_t *c)
calc_number_t num
Definition: calc.h:106
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:586
HWND hStatWnd
Definition: calc.h:142
DWORD base
Definition: calc.h:86
BOOL is_memory
Definition: calc.h:131
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
unsigned int operation
Definition: calc.h:85
void rpn_fact(calc_number_t *c)
Definition: fun_mpfr.c:242
void rpn_sin(calc_number_t *c)
Definition: fun_mpfr.c:106
void rpn_sum(calc_number_t *c)
Definition: fun_mpfr.c:358
calc_node_t memory
Definition: calc.h:129
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
unsigned long long UINT64
void stop_rpn_engine(void)
Definition: rpn.c:459
calc_t calc
Definition: winmain.c:226
GLuint64EXT * result
Definition: glext.h:11304
void rpn_exp3(calc_number_t *c)
Definition: fun_mpfr.c:291
void rpn_reci(calc_number_t *c)
Definition: fun_mpfr.c:234
#define __int64
Definition: basetyps.h:16
sequence_t Clipboard
Definition: calc.h:144
void rpn_asinh(calc_number_t *c)
Definition: fun_mpfr.c:208
calc_number_t prev
Definition: calc.h:128
void apply_int_mask(calc_number_t *a)
Definition: fun_mpfr.c:3
void rpn_tanh(calc_number_t *c)
Definition: fun_mpfr.c:202
void rpn_alloc(calc_number_t *c)
Definition: fun_mpfr.c:482