1 /*
2  *  calculator.h
3  *  Wcalc
4  *
5  *  Created by Kyle Wheeler on Thu Feb 07 2002.
6  *  Copyright (c) 2001 Kyle Wheeler. All rights reserved.
7  *
8  */
9 
10 #ifndef WCALC_CALCULATOR_H
11 #define WCALC_CALCULATOR_H
12 
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16 
17 #ifdef EBUG
18 # include <stdio.h>
19 # define Dprintf(fmt, ...)                                               \
20     fprintf(stderr, "[%s:%d] " fmt, __FILE__, __LINE__, ## __VA_ARGS__); \
21     fflush(stderr);
22 #else
23 # define Dprintf(...) ;
24 #endif
25 
26 #include "definitions.h"
27 #include "number.h"
28 
29 enum functions {
30     wnot,
31     wbnot,
32     wsin,
33     wcos,
34     wtan,
35     wcot,
36     wsec,
37     wcsc,
38     wasin,
39     wacos,
40     watan,
41     wacot,
42     wasec,
43     wacsc,
44     wsinh,
45     wcosh,
46     wtanh,
47     wcoth,
48     wsech,
49     wcsch,
50     wasinh,
51     wacosh,
52     watanh,
53     wacoth,
54     wasech,
55     wacsch,
56     wlog,
57     wlogtwo,
58     wln,
59     wround,
60     wneg,
61     wabs,
62     wsqrt,
63     wfloor,
64     wceil,
65     wrand,
66     wirand,
67     wexp,
68     wfact,
69     wcomp,
70     weint,
71     wgamma,
72     wlngamma,
73     wzeta,
74     wsinc,
75     wcbrt
76 };
77 enum operations {
78     wplus,
79     wminus,
80     wmult,
81     wdiv,
82     wmod,
83     wpow,
84     wor,
85     wbor,
86     wbxor,
87     wand,
88     wband,
89     wequal,
90     wnequal,
91     wgt,
92     wlt,
93     wrshft,
94     wlshft,
95     wgeq,
96     wleq,
97     wnone
98 };
99 
100 enum commands {redisplay, nothing};
101 
102 enum engineering_modes {always, never, automatic};
103 
104 void parseme(const char *);
105 void report_error(const char *fmt,
106                   ...);
107 void  set_prettyanswer(const Number num);
108 char *print_this_result(const Number result,
109                         int          output,
110                         char        *nad,
111                         char       **es);
112 void uber_function(Number               output,
113                    const enum functions func,
114                    Number               input);
115 void simple_exp(Number                output,
116                 const Number          first,
117                 const enum operations op,
118                 const Number          second);
119 int   seed_random(void);
120 char *output_string(const unsigned int);
121 
122 struct _conf {
123     unsigned long          history_limit_len;
124     int                    precision;
125     char                   thou_delimiter;
126     char                   dec_delimiter;
127     char                   in_thou_delimiter;
128     char                   in_dec_delimiter;
129     enum engineering_modes engineering         : 2;
130     unsigned int           picky_variables     : 1;
131     unsigned int           use_radians         : 1;
132     unsigned int           output_format       : 4;
133     unsigned int           print_prefixes      : 1;
134     unsigned int           rounding_indication : 4;
135     unsigned int           remember_errors     : 1;
136     unsigned int           precision_guard     : 1;
137     unsigned int           history_limit       : 1;
138     unsigned int           print_equal         : 1;
139     unsigned int           print_ints          : 1;
140     unsigned int           simple_calc         : 1;
141     unsigned int           verbose             : 1;
142     unsigned int           print_commas        : 1;
143     unsigned int           live_precision      : 1;
144     unsigned int           c_style_mod         : 1;
145     unsigned int           color_ui            : 1;
146 };
147 
148 /* configuration */
149 extern struct _conf conf;
150 
151 /* results */
152 extern Number last_answer;
153 extern char  *pretty_answer;
154 
155 /* communication with parser */
156 extern char         compute;
157 extern unsigned int sig_figs;
158 
159 /* communication with the frontend */
160 extern char standard_output;
161 extern char not_all_displayed;
162 
163 #define DECIMAL_FORMAT     0
164 #define OCTAL_FORMAT       1
165 #define HEXADECIMAL_FORMAT 2
166 #define BINARY_FORMAT      3
167 
168 #define NO_ROUNDING_INDICATION      0
169 #define SIMPLE_ROUNDING_INDICATION  1
170 #define SIG_FIG_ROUNDING_INDICATION 2
171 #endif // ifndef WCALC_CALCULATOR_H
172 /* vim:set expandtab: */
173