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