2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: calctool.h /main/7 1996/10/29 14:10:36 mustafa $ */
26 * Contains the none user interface includes for the Desktop *
29 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
30 * (c) Copyright 1993, 1994 International Business Machines Corp. *
31 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
32 * (c) Copyright 1993, 1994 Novell, Inc. *
38 #include <X11/Intrinsic.h>
39 #include <Dt/UserMsg.h>
40 #include <Dt/DtNlUtils.h>
43 #define MSGFILE_LABEL "dtcalc.label"
44 #define MSGFILE_MESSAGE "dtcalc.message"
46 extern char *MSGFILE_LABEL ;
47 extern char *MSGFILE_MESSAGE ;
51 #define LGET(s) (char *) dgettext(MSGFILE_LABEL, s)
52 #define MGET(s) (char *) dgettext(MSGFILE_MESSAGE, s)
54 #define dgettext(f, s) (s)
55 #define bindtextdomain(f, s)
57 #ifndef NO_MESSAGE_CATALOG
59 # define _CLIENT_CAT_NAME "dtcalc.cat"
61 # define _CLIENT_CAT_NAME "dtcalc"
62 # endif /* __ultrix */
63 extern char *_DtGetMessage(char *filename, int set, int n, char *s);
64 # define GETMESSAGE(set, number, string)\
65 (_DtGetMessage(_CLIENT_CAT_NAME, set, number, string))
67 # define GETMESSAGE(set, number, string)\
71 #if !(defined(sun) && (_XOPEN_VERSION==3))
95 /* For all function declarations, if ANSI then use a prototype. */
99 #else /* ! __STDC__ */
104 #define HIL_PC101_KBD 1
105 #define HIL_ITF_KBD 2
106 #define SERIAL_PC101_KBD 3
107 #define FIRST_HIL_KBD 0xC0
108 #define LAST_HIL_KBD 0xDF
109 #define LED_BITS 0x30
110 #define PS2_DIN_NAME "PS2_DIN_KEYBOARD"
113 extern char *getenv P((const char *)) ;
114 extern char *mktemp P((char *)) ;
116 extern double drand48 P(()) ;
121 #define FIN_EPSILON 1.0e-10
122 #define MAX_FIN_ITER 1000
124 #define MP_SIZE 150 /* Size of the multiple precision values. */
126 #define FCLOSE (void) fclose /* To make lint happy. */
127 #define FPRINTF (void) fprintf
128 #define FPUTS (void) fputs
129 #define FREE (void) free
130 #define MEMCPY (void) memcpy
131 #define MKTEMP (void) mktemp
132 #define REWIND (void) rewind
133 #define SPRINTF (void) sprintf
134 #define SSCANF (void) sscanf
135 #define STRCPY (void) strcpy
136 #define STRNCAT (void) strncat
137 #define UNLINK (void) unlink
139 /* Various pseudo events used by the dtcalc program. */
140 #define KEYBOARD_DOWN 100 /* Keyboard character was pressed. */
141 #define KEYBOARD_UP 101 /* Keyboard character was released. */
142 #define LASTEVENTPLUSONE 102 /* Not one of the above. */
154 enum base_type { BIN, OCT, DEC, HEX } ; /* Base definitions. */
156 /* Command line options (for saving). */
157 enum cmd_type { CMD_ACC, CMD_MODE, CMD_BASE, CMD_DISP, CMD_MENU_BAR,
158 CMD_SESSION, CMD_TRIG, CMD_DUMMY } ;
160 /* Frame/Canvas/Pixwin types. */
161 enum fcp_type { FCP_KEY, FCP_REG, FCP_MODE, FCP_FIN_REG } ;
163 /* Help string types. */
164 enum help_type { H_ACC, H_BASE, H_CON, H_EXCH,
165 H_FUN, H_MODE, H_NUM,
166 H_RCL, H_STO, H_TRIG,
167 H_ABUT, H_AFRAME, H_APANEL,
168 H_APPEARANCE, H_APPLY, H_ATEXT, H_CFCBUT,
169 H_CFDESC, H_CFFRAME, H_CFNO, H_CFPANEL,
170 H_CFVAL, H_DEF, H_DISPLAY, H_PFRAME,
171 H_PPANEL, H_RESET, H_STYLE, H_DUMMY } ;
173 /* Pseudo panel items. */
174 enum item_type { BASEITEM, TTYPEITEM, NUMITEM, HYPITEM,
175 INVITEM, OPITEM, MODEITEM, DISPLAYITEM } ;
177 /* Motif labels for various items. */
178 enum label_type { L_LCALC, L_UCALC, L_CONNO, L_NEWCON, L_FUNNO,
179 L_NEWFUN, L_MEMT, L_PROPT, L_DESC, L_VALUE,
180 L_CONB, L_FUNB, L_FINMEMT, L_DUMMY } ;
182 /* Popup menu types. */
183 enum menu_type { M_ACC, M_BASE, M_CON, M_EXCH, M_FUN, M_MODE,
184 M_NUM, M_RCL, M_STO, M_TRIG, M_NONE
187 /* Message string types. */
188 enum mess_type { MESS_PARAM, MESS_CON, MESS_DUMMY } ;
190 /* Calculator modes. */
191 enum mode_type { FINANCIAL, LOGICAL, SCIENTIFIC } ;
193 enum mp_type { MP_ADD2A, MP_ADD2B, MP_PART1, MP_ASIN, /* MP error types. */
195 MP_CHKD, MP_CHKE, MP_CHKF, MP_CHKG,
196 MP_CHKH, MP_CHKI, MP_CHKJ, MP_CHKL,
197 MP_CHKM, MP_CHKN, MP_CMD, MP_CMR,
198 MP_CQM, MP_DIVA, MP_DIVB, MP_DIVIA,
199 MP_DIVIB, MP_EXPA, MP_EXPB, MP_EXP1,
200 MP_LNA, MP_LNB, MP_LNSA,
201 MP_LNSB, MP_LNSC, MP_MULA, MP_MULB,
202 MP_MULC, MP_MUL2A, MP_MUL2B, MP_MULQ,
203 MP_NZRA, MP_NZRB, MP_NZRC,
204 MP_OVFL, MP_PI, MP_PWRA,
205 MP_PWRB, MP_PWR2A, MP_PWR2B, MP_RECA,
206 MP_RECB, MP_RECC, MP_RECD, MP_ROOTA,
207 MP_ROOTB, MP_ROOTC, MP_ROOTD,
208 MP_ROOTE, MP_ROOTF, MP_SETB,
209 MP_SETC, MP_SETD, MP_SETE, MP_SIN,
210 MP_SIN1, MP_SQRT, MP_TAN, MP_DUMMY } ;
212 enum num_type { ENG, FIX, SCI } ; /* Number display mode. */
214 enum op_type { OP_SET, OP_CLEAR, OP_NOP } ; /* Operation item settings. */
216 enum opt_type { O_ACCVAL, O_ACCRANGE, O_BASE, O_DISPLAY,
217 O_MODE, O_TRIG, O_SESSION, O_DUMMY } ;
219 enum prop_type { P_CHAR, P_ASCIIT, P_DUMMY } ;
222 enum res_type { R_ACCURACY, R_BASE, R_DISPLAY, R_MODE, R_FREGS,
223 R_REGS, R_TRIG, R_BEEP, R_ICON, R_WORKSPACE,
224 R_HEIGHT, R_WIDTH, R_X, R_Y, R_DISPLAYED,
225 R_REG0, R_REG1, R_REG2, R_REG3, R_REG4,
226 R_REG5, R_REG6, R_REG7, R_REG8, R_REG9,
227 R_FREG0, R_FREG1, R_FREG2, R_FREG3, R_FREG4,
228 R_FREG5, R_MENUBAR, R_KEYS, R_DUMMY } ;
230 enum trig_type { DEG, GRAD, RAD } ; /* Trigonometric types. */
232 /* Usage message types. */
233 enum usage_type { USAGE1, USAGE2, USAGE3, U_DUMMY } ;
235 enum var_type { V_CANCEL,
236 V_CLR, V_CONFIRM, V_CONTINUE,
238 V_FUNWNAME, V_HYP, V_INV,
239 V_INVCON, V_LCON, V_LFUN,
240 V_NOCHANGE, V_NUMSTACK, V_OPSTACK, V_OWRITE,
241 V_RANGE, V_TRUE, V_UCON, V_UFUN,
242 V_NORSAVE, V_DUMMY } ;
244 /* Abbreviations for the dtcalc keyboard and menu equivalents. */
246 #define KEY_BLNKD buttons[0].value /* q */
247 #define KEY_FUN buttons[1].value /* F */
248 #define KEY_CON buttons[2].value /* # */
249 #define KEY_KEYS buttons[3].value /* k */
251 #define KEY_INT buttons[4].value /* CTL('i') */
252 #define KEY_FRAC buttons[5].value /* CTL('f') */
253 #define KEY_ABS buttons[6].value /* CTL('u') */
254 #define KEY_EXP buttons[7].value /* E */
256 #define KEY_ACC buttons[8].value /* A */
257 #define KEY_STO buttons[9].value /* S */
258 #define KEY_RCL buttons[10].value /* R */
259 #define KEY_EXCH buttons[11].value /* X */
261 #define KEY_BLNK1 buttons[12].value /* q */
262 #define KEY_BLNK2 buttons[13].value /* q */
263 #define KEY_BLNK3 buttons[14].value /* q */
264 #define KEY_BLNK4 buttons[15].value /* q */
266 #define KEY_BLNK5 buttons[16].value /* q */
267 #define KEY_BLNK6 buttons[17].value /* q */
268 #define KEY_BLNK7 buttons[18].value /* q */
269 #define KEY_BLNK8 buttons[19].value /* q */
271 #define KEY_BLNK9 buttons[20].value /* q */
272 #define KEY_BLNKA buttons[21].value /* q */
273 #define KEY_BLNKB buttons[22].value /* q */
274 #define KEY_BLNKC buttons[23].value /* q */
276 #define KEY_REC buttons[24].value /* r */
277 #define KEY_SQR buttons[25].value /* @ */
278 #define KEY_SQRT buttons[26].value /* s */
279 #define KEY_PER buttons[27].value /* % */
281 #define KEY_LPAR buttons[28].value /* ( */
282 #define KEY_RPAR buttons[29].value /* ) */
283 #define KEY_BSP buttons[30].value /* CTL('h') */
284 #define KEY_CLR buttons[31].value /* del */
286 #define KEY_D buttons[32].value /* d */
287 #define KEY_E buttons[33].value /* e */
288 #define KEY_F buttons[34].value /* f */
289 #define KEY_CHS buttons[35].value /* C */
291 #define KEY_A buttons[36].value /* a */
292 #define KEY_B buttons[37].value /* b */
293 #define KEY_C buttons[38].value /* c */
294 #define KEY_MUL buttons[39].value /* x */
296 #define KEY_7 buttons[40].value /* 7 */
297 #define KEY_8 buttons[41].value /* 8 */
298 #define KEY_9 buttons[42].value /* 9 */
299 #define KEY_DIV buttons[43].value /* / */
301 #define KEY_4 buttons[44].value /* 4 */
302 #define KEY_5 buttons[45].value /* 5 */
303 #define KEY_6 buttons[46].value /* 6 */
304 #define KEY_SUB buttons[47].value /* - */
306 #define KEY_1 buttons[48].value /* 1 */
307 #define KEY_2 buttons[49].value /* 2 */
308 #define KEY_3 buttons[50].value /* 3 */
309 #define KEY_ADD buttons[51].value /* + */
311 #define KEY_0 buttons[52].value /* 0 */
312 #define KEY_PNT buttons[53].value /* . */
313 #define KEY_EQ buttons[54].value /* = */
314 #define KEY_QUIT buttons[55].value /* q */
316 /* these are the extra definitions for MODE, BASE, and DISP */
317 #define KEY_BASE buttons[56].value /* B */
318 #define KEY_DISP buttons[57].value /* D */
319 #define KEY_MODE buttons[58].value /* M */
320 #define KEY_TRIG buttons[59].value /* T */
322 #define ACC_START 0 /* 0 */
323 #define ACC_END 9 /* 9 */
325 #define MEM_START 10 /* 0 */
326 #define MEM_END 19 /* 9 */
328 #define BASE_BIN menu_entries[20].val /* b */
329 #define BASE_OCT menu_entries[21].val /* o */
330 #define BASE_DEC menu_entries[22].val /* d */
331 #define BASE_HEX menu_entries[23].val /* h */
333 #define DISP_ENG menu_entries[24].val /* e */
334 #define DISP_FIX menu_entries[25].val /* f */
335 #define DISP_SCI menu_entries[26].val /* s */
337 #define TRIG_DEG menu_entries[27].val /* d */
338 #define TRIG_GRA menu_entries[28].val /* g */
339 #define TRIG_RAD menu_entries[29].val /* r */
341 #define MODE_BAS menu_entries[30].val /* b */
342 #define MODE_FIN menu_entries[31].val /* f */
343 #define MODE_LOG menu_entries[32].val /* l */
344 #define MODE_SCI menu_entries[33].val /* s */
346 #define KEY_TERM mode_buttons[0].value /* T */
347 #define KEY_RATE mode_buttons[1].value /* CTL('r') */
348 #define KEY_PV mode_buttons[2].value /* p */
349 #define KEY_PMT mode_buttons[3].value /* P */
350 #define KEY_FV mode_buttons[4].value /* v */
351 #define KEY_PYR mode_buttons[5].value /* y */
352 #define KEY_FCLR mode_buttons[6].value /* L */
353 #define KEY_CTRM mode_buttons[7].value /* CTL('t') */
354 #define KEY_DDB mode_buttons[8].value /* CTL('d') */
355 #define KEY_SLN mode_buttons[9].value /* CTL('s') */
356 #define KEY_SYD mode_buttons[10].value /* CTL('y') */
358 #define KEY_LSFT mode_buttons[16].value /* < */
359 #define KEY_RSFT mode_buttons[17].value /* > */
360 #define KEY_16 mode_buttons[18].value /* [ */
361 #define KEY_32 mode_buttons[19].value /* ] */
362 #define KEY_OR mode_buttons[20].value /* | */
363 #define KEY_AND mode_buttons[21].value /* & */
364 #define KEY_NOT mode_buttons[22].value /* ~ */
365 #define KEY_XOR mode_buttons[23].value /* ^ */
366 #define KEY_XNOR mode_buttons[24].value /* n */
368 #define KEY_INV mode_buttons[32].value /* i */
369 #define KEY_HYP mode_buttons[33].value /* h */
370 #define KEY_ETOX mode_buttons[34].value /* { */
371 #define KEY_TTOX mode_buttons[35].value /* } */
372 #define KEY_YTOX mode_buttons[36].value /* y */
373 #define KEY_FACT mode_buttons[37].value /* ! */
374 #define KEY_COS mode_buttons[38].value /* CTL('c') */
375 #define KEY_SIN mode_buttons[39].value /* CTL('s') */
376 #define KEY_TAN mode_buttons[40].value /* CTL('t') */
377 #define KEY_LN mode_buttons[41].value /* N */
378 #define KEY_LOG mode_buttons[42].value /* G */
379 #define KEY_RAND mode_buttons[43].value /* ? */
381 #define BCOLS 4 /* No of columns of buttons. */
382 #define BROWS 14 /* No of rows of buttons. */
383 #define CALC_CANCEL 1 /* Cancel button pressed on notice. */
384 #define CALC_CONFIRM 2 /* Confirm button pressed on notice. */
385 #define CTL(n) n - 96 /* Generate control character value. */
386 #define EQUAL(a, b) !strncmp(a, b, strlen(b))
387 #define EXTRA 4 /* Extra useful character definitions. */
389 #define INC { argc-- ; argv++ ; }
390 #define IS_KEY(v, n) (v == n)
394 #define LINT_CAST(arg) (arg ? 0 : 0)
396 #define LINT_CAST(arg) (arg)
400 #define MAXCMDS (int) CMD_DUMMY /* Max. no. of command line opts. */
401 #define MAX_DIGITS 41 /* Maximum displayable number of digits. */
403 /* Maximum number of various graphics pieces. */
404 #define MAXFCP 3 /* Max no of frames/canvases/pixwins. */
405 #define MAXHELP (int) H_DUMMY /* Max. no. help strings. */
406 #define MAXIMAGES 3 /* Maximum number of button images. */
407 #define MAXITEMS 8 /* Maximum number of panel items. */
408 #define MAXLABELS (int) L_DUMMY /* Max no. Motif label strings. */
409 #define MAXMENUS 13 /* Maximum number of popup menus. */
410 #define MAXMESS (int) MESS_DUMMY /* Max. no. message strings. */
411 #define MAXMPERRS (int) MP_DUMMY /* Max. no. MP error types. */
414 #define MAXLINE 256 /* Length of character strings. */
417 #define MAXBASES 4 /* Max. no. of numeric bases. */
418 #define MAXDISPMODES 3 /* Max. no. of display modes. */
419 #define MAXENTRIES 55 /* Max. no. of menu entries. */
420 #define MAXMODES 3 /* Max. no. of calculator modes. */
421 #define MAXOPTS (int) O_DUMMY /* Max. no. option types. */
422 #define MAXPSTRS (int) P_DUMMY /* Max. no. property strings. */
423 #define MAXREGS 10 /* Max. no. of memory registers. */
424 #define FINREGS 6 /* Max. no. of Fin. memory regs. */
425 #define MAXRESOURCES (int) R_DUMMY /* Max. number. of X resources. */
426 #define MAXSTACK 256 /* Parenthese stack size. */
427 #define MAXTRIGMODES 3 /* Max. no. of trig. modes. */
428 #define MAXUSAGE (int) U_DUMMY /* Max. no. usage strings. */
429 #define MAXVKEYS 6 /* No. of valid keys after error. */
430 #define MAXVMESS (int) V_DUMMY /* Max. no. various messages. */
432 #define MCOLS 8 /* No. of columns of "special" keys. */
433 #define MROWS 2 /* No. of rows of "special" keys. */
434 #define MODEKEYS MCOLS * MROWS
436 #define MAXCOLS BCOLS
437 #define MAXROWS BROWS
440 #define MIN(x,y) ((x) < (y) ? (x) : (y))
443 #define NOBUTTONS BROWS * BCOLS
446 #define RCNAME ".dtcalcrc"
449 #define TITEMS NOBUTTONS + EXTRA /* Total definitions. */
451 #ifndef TRUE /* Boolean definitions. */
459 typedef unsigned long BOOLEAN ;
462 char *str ; /* Button display string. */
463 char *str2 ; /* Button display string, with key. */
464 char value ; /* Unique button keyboard equivalent. */
465 enum op_type opdisp ; /* Is button selected during operation? */
466 enum menu_type mtype ; /* Type of popup menu (if any). */
467 char *resname ; /* Button resource name. */
468 void (*func)() ; /* Function to obey on button press. */
472 char *str ; /* Menu entry string to be displayed. */
473 char val ; /* Value when selected. */
477 char *title ; /* Menu title. */
478 int total ; /* Number of menu entries. */
479 int mindex ; /* Index into menu string array. */
480 int defval ; /* Default menu item position (from 1). */
483 struct calcVars { /* Calctool variables and options. */
484 char *appname ; /* Application name for resources. */
485 char con_names[MAXREGS][MAXLINE] ; /* Selectable constant names. */
486 char cur_op ; /* Current arithmetic operation. */
487 char current ; /* Current button/character pressed. */
488 char display[MAXLINE] ; /* Current calculator display. */
489 char *exp_posn ; /* Position of the exponent sign. */
490 char fnum[MAX_DIGITS+1] ; /* Scratchpad for fixed numbers. */
491 char fun_names[MAXREGS][MAXLINE] ; /* Function names from .dtcalcrc. */
492 char fun_vals[MAXREGS][MAXLINE] ; /* Function defs from .dtcalcrc. */
493 char *iconlabel ; /* The dtcalc icon label. */
494 char old_cal_value ; /* Previous calculation operator. */
495 char *progname ; /* Name of this program. */
496 char pstr[5] ; /* Current button text string. */
497 char *selection ; /* Current [Get] selection. */
498 char *shelf ; /* PUT selection shelf contents. */
499 char snum[MAX_DIGITS+1] ; /* Scratchpad for scientific numbers. */
500 char *titleline ; /* Value of titleline (if present). */
501 char *workspaces ; /* workspace names calc is in */
508 int MPcon_vals[MAXREGS][MP_SIZE] ; /* Selectable constants. */
509 int MPdebug ; /* If set, debug info. to stderr. */
510 int MPerrors ; /* If set, output errors to stderr. */
511 int MPdisp_val[MP_SIZE] ; /* Value of the current display. */
512 int MPlast_input[MP_SIZE] ; /* Previous number input by user. */
513 int MPmvals[MAXREGS][MP_SIZE] ; /* Memory register values. */
514 double MPfvals[FINREGS] ; /* Financial Memory register values. */
515 int *MPnumstack[MAXSTACK] ; /* Numeric stack for parens. */
516 int MPresult[MP_SIZE] ; /* Current calculator total value. */
517 int MPtresults[3][MP_SIZE] ; /* Current trigonometric results. */
519 enum base_type base ; /* Current base: BIN, OCT, DEC or HEX. */
520 enum fcp_type curwin ; /* Window current event occurred in. */
521 enum fcp_type pending_win ; /* Window that pending op came from. */
522 enum mode_type modetype ; /* Current calculator mode. */
523 enum mode_type pending_mode ; /* Mode for pending op. */
524 enum num_type dtype ; /* Number display mode. */
525 enum trig_type ttype ; /* Trig. type (deg, grad or rad). */
526 BOOLEAN num_lock; /* Indicator of the state of NUM_LOCK */
527 int accuracy ; /* Number of digits precision (Max 9). */
528 int beep ; /* Indicates whether there is a beep sound on error. */
529 int column ; /* Column number of current key/mouse press. */
530 int cur_ch ; /* Current character if keyboard event. */
531 int error ; /* Indicates some kind of display error. */
532 int event_type ; /* Type of event being currently processed. */
533 int hasicon ; /* Set if user gave icon name on command line. */
534 int hyperbolic ; /* If set, trig functions will be hyperbolic. */
535 int iconic ; /* Set if window is currently iconic. */
536 int inverse ; /* If set, trig and log functions will be inversed. */
537 int ismenu ; /* Set when do_pending called via a popup menu. */
538 int key_exp ; /* Set if entering exponent number. */
539 int new_input ; /* New number input since last op. */
540 int noparens ; /* Count of left brackets still to be matched. */
541 int numsptr ; /* Pointer into the parenthese numeric stack. */
542 int opsptr ; /* Pointer into the parentheses operand stack. */
543 int opstack[MAXSTACK] ; /* Stack containing parentheses input. */
544 int pending ; /* Set for command depending on multiple presses. */
545 int pending_n ; /* Offset into function table for pending op. */
546 int pending_op ; /* Arithmetic operation for pending command. */
547 int pointed ; /* Whether a decimal point has been given. */
548 int row ; /* Row number of current key/mouse press. */
549 int rstate ; /* Indicates if memory register frame is displayed. */
550 int frstate ; /* Indicates if financial memory register
551 frame is displayed. */
552 int show_paren ; /* Set if we wish to show DISPLAYITEM during parens. */
553 int started ; /* Set just before window is displayed. */
554 int toclear ; /* Indicates if display should be cleared. */
555 int tstate ; /* Indicates current button set being displayed. */
556 int funstate ; /* whether the last key pressed was a fin. func. key*/
557 int defState ; /* Set when calculator has just been cleared */
564 typedef struct calcVars *Vars ;
566 /* Structure, resource definitions, for View's optional parameters. */
576 } ApplicationArgs, *ApplicationArgsPtr;
578 ApplicationArgs application_args;
580 /* MP definitions. */
582 #define C_abs(x) ((x) >= 0 ? (x) : -(x))
583 #define dabs(x) (double) C_abs(x)
584 #define min(a, b) ((a) <= (b) ? (a) : (b))
585 #define max(a, b) ((a) >= (b) ? (a) : (b))
586 #define dmax(a, b) (double) max(a, b)
587 #define dmin(a, b) (double) min(a, b)
589 BOOLEAN ibool P((double)) ;
590 BOOLEAN ibool2 P((double)) ;
592 char *convert P((char *)) ;
593 char *get_resource P((enum res_type)) ;
594 char *make_eng_sci P((int *)) ;
595 char *make_fixed P((int *, int)) ;
596 char *make_number P((int *, BOOLEAN)) ;
598 double mppow_di P((double *, int *)) ;
599 double mppow_ri P((float *, int *)) ;
600 double setbool P((BOOLEAN)) ;
602 int char_val P((char)) ;
603 int get_bool_resource P((enum res_type, int *)) ;
604 int get_index P((char)) ;
605 int get_int_resource P((enum res_type, int *)) ;
606 int get_str_resource P((enum res_type, char *)) ;
607 int main P((int, char **)) ;
610 void check_ow_beep P(()) ;
611 void clear_display P(()) ;
612 void doerr P((char *)) ;
613 void do_accuracy P(()) ;
614 void do_ascii P(()) ;
616 void set_base P(()) ;
617 void do_business P(()) ;
619 void do_dtcalc P((int, char **)) ;
620 void do_clear P(()) ;
621 void do_constant P(()) ;
622 void do_delete P(()) ;
623 void do_exchange P(()) ;
624 void do_expno P(()) ;
625 void do_factorial P((int *, int *)) ;
626 void do_frame P(()) ;
627 void do_function P(()) ;
628 void do_immed P(()) ;
632 void do_number P(()) ;
633 void do_numtype P(()) ;
634 void do_paren P(()) ;
635 void set_numtype P((enum num_type dtype));
636 void do_nothing P(()) ;
637 void do_pending P(()) ;
638 void do_point P(()) ;
639 void do_portion P(()) ;
640 double do_round P((double, int)) ;
641 void do_shift P(()) ;
642 void do_sto_rcl P(()) ;
644 void do_trigtype P(()) ;
645 void draw_button P((int, enum fcp_type, int, int, int)) ;
646 void get_display P(()) ;
647 void get_key_val P((char *, char *)) ;
648 void get_label P((int)) ;
649 void get_options P((int, char **)) ;
650 void getparam P((char *, char **, char *)) ;
651 void get_rcfile P((char *)) ;
652 void grey_button P((int, int, int)) ;
653 void grey_buttons P((enum base_type)) ;
654 void handle_menu_selection P((int, int)) ;
655 void handle_selection P(()) ;
656 void initialize P(()) ;
657 void init_cmdline_opts P(()) ;
658 void init_graphics P(()) ;
659 void init_options P(()) ;
660 void init_text P(()) ;
661 void init_vars P(()) ;
662 void key_init P(()) ;
663 void load_resources P(()) ;
664 void make_frames P(()) ;
665 void make_items P(()) ;
666 void make_modewin P(()) ;
667 void make_fin_registers P(()) ;
668 void make_registers P((int)) ;
669 void MPstr_to_num P((char *, enum base_type, int *)) ;
670 void paren_disp P((char)) ;
671 void process_event P((int)) ;
672 void process_item P((int)) ;
673 void process_parens P((char)) ;
674 void process_stack P((int, int, int)) ;
675 void process_str P((char *, enum menu_type)) ;
676 void push_num P((int *)) ;
677 void push_op P((int)) ;
678 void put_resource P((enum res_type, char *)) ;
679 void read_rcfiles P(()) ;
680 void read_resources P(()) ;
681 void redraw_buttons P(()) ;
682 void save_cmdline P((int, char **)) ;
683 void save_pending_values P((int)) ;
684 void save_resources P((char *)) ;
685 void blank_display P(()) ;
686 void ErrorDialog P((char *string));
687 void set_item P((enum item_type, char *)) ;
688 void set_title P((enum fcp_type, char *)) ;
689 void show_ascii_frame P(()) ;
690 void show_display P((int *)) ;
692 void start_tool P(()) ;
693 void switch_hands P((int)) ;
694 void usage P((char *)) ;
695 void win_display P((enum fcp_type, int)) ;
696 void write_cmdline P(()) ;
697 void write_rcfile P((enum menu_type, int, int, char *, char *)) ;
698 void write_resources P((char *)) ;
699 void RestoreSession P(()) ;
700 void TimerEvent P(( XtPointer, XtIntervalId *)) ;
701 void ErrDialog P(( char *, Widget ));
703 /* MP routines not found in the Brent FORTRAN package. */
704 void mpacos P((int *, int *)) ;
705 void mpacosh P((int *, int *)) ;
706 void mpasinh P((int *, int *)) ;
707 void mpatanh P((int *, int *)) ;
708 void mplog10 P((int *, int *)) ;
710 /* Brent MP routines in mp.c. */
711 int mpcmpi P((int *, int *)) ;
712 int mpcmpr P((int *, float *)) ;
713 int mpcomp P((int *, int *)) ;
714 int pow_ii P((int *, int *)) ;
716 int mpeq P((int *, int *)) ;
717 int mpge P((int *, int *)) ;
718 int mpgt P((int *, int *)) ;
719 int mple P((int *, int *)) ;
720 int mplt P((int *, int *)) ;
722 void mpabs P((int *, int *)) ;
723 void mpadd P((int *, int *, int *)) ;
724 void mpadd2 P((int *, int *, int *, int *, int *)) ;
725 void mpadd3 P((int *, int *, int *, int *, int *)) ;
726 void mpaddi P((int *, int *, int *)) ;
727 void mpaddq P((int *, int *, int *, int *)) ;
728 void mpart1 P((int *, int *)) ;
729 void mpasin P((int *, int *)) ;
730 void mpatan P((int *, int *)) ;
731 void mpcdm P((double *, int *)) ;
732 void mpchk P((int *, int *)) ;
733 void mpcim P((int *, int *)) ;
734 void mpcmd P((int *, double *)) ;
735 void mpcmf P((int *, int *)) ;
736 void mpcmi P((int *, int *)) ;
737 void mpcmim P((int *, int *)) ;
738 void mpcmr P((int *, float *)) ;
739 void mpcos P((int *, int *)) ;
740 void mpcosh P((int *, int *)) ;
741 void mpcqm P((int *, int *, int *)) ;
742 void mpcrm P((float *, int *)) ;
743 void mpdiv P((int *, int *, int *)) ;
744 void mpdivi P((int *, int *, int *)) ;
746 void mpexp P((int *, int *)) ;
747 void mpexp1 P((int *, int *)) ;
748 void mpext P((int *, int *, int *)) ;
749 void mpgcd P((int *, int *)) ;
750 void mpln P((int *, int *)) ;
751 void mplns P((int *, int *)) ;
752 void mpmaxr P((int *)) ;
753 void mpmlp P((int *, int *, int *, int *)) ;
754 void mpmul P((int *, int *, int *)) ;
755 void mpmul2 P((int *, int *, int *, int *)) ;
756 void mpmuli P((int *, int *, int *)) ;
757 void mpmulq P((int *, int *, int *, int *)) ;
758 void mpneg P((int *, int *)) ;
759 void mpnzr P((int *, int *, int *, int *)) ;
760 void mpovfl P((int *)) ;
761 void mppi P((int *)) ;
762 void mppwr P((int *, int *, int *)) ;
763 void mppwr2 P((int *, int *, int *)) ;
764 void mprec P((int *, int *)) ;
765 void mproot P((int *, int *, int *)) ;
766 void mpset P((int *, int *, int *)) ;
767 void mpsin P((int *, int *)) ;
768 void mpsin1 P((int *, int *, int *)) ;
769 void mpsinh P((int *, int *)) ;
770 void mpsqrt P((int *, int *)) ;
771 void mpstr P((int *, int *)) ;
772 void mpsub P((int *, int *, int *)) ;
773 void mptanh P((int *, int *)) ;
774 void mpunfl P((int *)) ;
777 void Help P((char *, char *)) ;
778 void HelpRequestCB P(()) ;
779 void HelpModeCB P(()) ;
780 void HelpCloseCB P(()) ;
781 void HelpHyperlinkCB P(()) ;
782 void DisplayHelp P((char *, char *)) ;
783 void CenterMsgCB P(()) ;
784 void HelpHelp P(()) ;
785 void SetWmHnts P(()) ;
787 void _DtmapCB P((Widget, XtPointer, XtPointer)) ;
789 void set_option_menu P((int, int)) ;