diff --git a/cde/programs/dtcalc/Makefile.am b/cde/programs/dtcalc/Makefile.am index 7dfd6f507..f86bf3a7b 100644 --- a/cde/programs/dtcalc/Makefile.am +++ b/cde/programs/dtcalc/Makefile.am @@ -12,6 +12,6 @@ endif dtcalc_SOURCES = calctool.c ds_common.c ds_popup.c ds_widget.c \ - ds_xlib.c functions.c help.c motif.c mp.c text.c \ + ds_xlib.c functions.c help.c motif.c mp.c text.c text.h \ calctool.h ds_popup.h ds_xlib.h patchlevel.h \ ds_common.h ds_widget.h motif.h diff --git a/cde/programs/dtcalc/calctool.c b/cde/programs/dtcalc/calctool.c index 69ea728ea..5f91e8884 100644 --- a/cde/programs/dtcalc/calctool.c +++ b/cde/programs/dtcalc/calctool.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -45,74 +46,60 @@ #include "patchlevel.h" #include "calctool.h" #include "ds_common.h" +#include "calctool.h" +#include "text.h" -time_t time() ; - -double max_fix[4] = { +static double max_fix[4] = { 6.871947674e+10, 3.245185537e+32, 1.000000000e+36, 2.230074520e+43 } ; -double min_fix0[4] = { +static double min_fix0[4] = { 2.500000000e-1, 3.750000000e-1, 1.000000000e-1, 4.375000000e-1 } ; -double min_fix1[4] = { +static double min_fix1[4] = { 1.250000000e-1, 4.687500000e-2, 1.000000000e-2, 2.734375000e-2 } ; -double min_fix2[4] = { +static double min_fix2[4] = { 6.250000000e-2, 5.859375000e-3, 1.000000000e-3, 1.708984375e-3 } ; -double min_fix3[4] = { +static double min_fix3[4] = { 3.125000000e-2, 7.324218750e-4, 1.000000000e-4, 1.068115234e-4 } ; -double min_fix4[4] = { +static double min_fix4[4] = { 1.562500000e-2, 9.155273437e-5, 1.000000000e-5, 6.675720215e-6 } ; -double min_fix5[4] = { +static double min_fix5[4] = { 7.812500000e-3, 1.144409180e-5, 1.000000000e-6, 4.172325134e-7 } ; -double min_fix6[4] = { +static double min_fix6[4] = { 6.906250000e-3, 1.430511475e-6, 1.000000000e-7, 2.607703209e-8 } ; -double min_fix7[4] = { +static double min_fix7[4] = { 1.953125000e-3, 1.788139343e-7, 1.000000000e-8, 1.629814506e-9 } ; -double min_fix8[4] = { +static double min_fix8[4] = { 9.765625000e-4, 2.235174179e-8, 1.000000000e-9, 1.018634066e-10 } ; -double min_fix9[4] = { +static double min_fix9[4] = { 4.882812500e-4, 2.793967724e-9, 1.000000000e-10, 6.366462912e-12 } ; -extern char *base_str[] ; /* Strings for each base value. */ -extern char *cmdstr[] ; /* Strings for each command line option. */ -extern char *dtype_str[] ; /* Strings for each display mode value. */ -extern char *lstrs[] ; /* Labels for various Motif items. */ -extern char *mess[] ; /* Message strings. */ -extern char *mode_str[] ; /* Strings for each mode value. */ -extern char *opts[] ; /* Command line option strings. */ -extern char *ttype_str[] ; /* Strings for each trig type value. */ -extern char *ustrs[] ; /* Usage message strings. */ -extern char *vstrs[] ; /* Various strings. */ - -char digits[] = "0123456789ABCDEF" ; -int basevals[4] = { 2, 8, 10, 16 } ; - -int left_pos[BCOLS] = { 3, 2, 1, 0 } ; /* Left positions. */ -int right_pos[BCOLS] = { 0, 1, 2, 3 } ; /* "Right" positions. */ +static char digits[] = "0123456789ABCDEF" ; +static int basevals[4] = { 2, 8, 10, 16 } ; /* Valid keys when an error condition has occurred. */ /* MEM KEYS clr clr QUIT REDRAW */ -char validkeys[MAXVKEYS] = { 'm', 'k', '\177', '\013', 'q', '\f' } ; +static char validkeys[MAXVKEYS] = { 'm', 'k', '\177', '\013', 'q', '\f' } ; Vars v ; /* Calctool variables and options. */ diff --git a/cde/programs/dtcalc/calctool.h b/cde/programs/dtcalc/calctool.h index 806d0f7e5..42cdcf6a8 100644 --- a/cde/programs/dtcalc/calctool.h +++ b/cde/programs/dtcalc/calctool.h @@ -442,11 +442,14 @@ struct button { char *resname ; /* Button resource name. */ void (*func)() ; /* Function to obey on button press. */ } ; +extern struct button buttons[] ; /* Calculator button values. */ +extern struct button mode_buttons[] ; /* Special "mode" buttons. */ struct menu_entry { char *str ; /* Menu entry string to be displayed. */ char val ; /* Value when selected. */ } ; +extern struct menu_entry menu_entries[] ; /* All the menu strings. */ struct menu { char *title ; /* Menu title. */ @@ -454,6 +457,7 @@ struct menu { int mindex ; /* Index into menu string array. */ int defval ; /* Default menu item position (from 1). */ } ; +extern struct menu cmenus[] ; /* Calculator menus. */ struct calcVars { /* Calctool variables and options. */ char *appname ; /* Application name for resources. */ @@ -539,6 +543,11 @@ struct calcVars { /* Calctool variables and options. */ extern struct calcVars CalcVars; typedef struct calcVars *Vars ; +extern Vars v ; /* Calctool variables and options. */ + +extern void matherr(void); // calctool.c + + /* Structure, resource definitions, for View's optional parameters. */ typedef struct @@ -754,10 +763,7 @@ void mpunfl(int *); void Help(char *, char *); void HelpRequestCB(Widget, caddr_t, caddr_t); void HelpModeCB(Widget, caddr_t, caddr_t); -void HelpCloseCB(Widget, caddr_t, caddr_t); -void HelpHyperlinkCB(Widget, caddr_t, caddr_t); void DisplayHelp(char *, char *); -void CenterMsgCB(Widget, XtPointer, XtPointer); void HelpHelp(void); void SetWmHnts(void); diff --git a/cde/programs/dtcalc/functions.c b/cde/programs/dtcalc/functions.c index 7e7041d71..8658c83fe 100644 --- a/cde/programs/dtcalc/functions.c +++ b/cde/programs/dtcalc/functions.c @@ -41,21 +41,7 @@ #include #endif #include "calctool.h" - -void matherr(void); // calctool.c - - -extern char *base_str[] ; /* Strings for each base value. */ -extern char *dtype_str[] ; /* Strings for each display mode value. */ -extern char *mode_str[] ; /* Strings for each mode value. */ -extern char *ttype_str[] ; /* Strings for each trig type value. */ -extern char *vstrs[] ; /* Various strings. */ - -extern struct button buttons[] ; /* Calculator button values. */ -extern struct button mode_buttons[] ; /* Special "mode" buttons. */ -extern struct menu_entry menu_entries[] ; /* All the menu strings. */ - -extern Vars v ; /* Calctool variables and options. */ +#include "text.h" double mods[] = { 1.0, 1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4, 1.0e-5, 1.0e-6, 1.0e-7, 1.0e-8, 1.0e-9, diff --git a/cde/programs/dtcalc/help.c b/cde/programs/dtcalc/help.c index 5eea3ad9a..50f19cca1 100644 --- a/cde/programs/dtcalc/help.c +++ b/cde/programs/dtcalc/help.c @@ -43,19 +43,10 @@ #include #include "calctool.h" #include "motif.h" +#include "text.h" #define DIALOG_MWM_FUNC MWM_FUNC_MOVE | MWM_FUNC_CLOSE -extern char *base_str[] ; /* Strings for each base value. */ -extern char *dtype_str[] ; /* Strings for each display mode value. */ -extern char *mode_str[] ; /* Strings for each mode value. */ -extern char *ttype_str[] ; /* Strings for each trig type value. */ -extern Vars v ; /* Calctool variables and options. */ -extern struct button buttons[] ; /* Calculator button values. */ - - -extern Boolean ignore_event; -extern XtIntervalId timerId; extern void _DtChildPosition(Widget, Widget, Position *, Position *); typedef struct _helpStruct { @@ -67,6 +58,10 @@ typedef struct _helpStruct { static Widget GetHelpDialog(void); static void UnmanageCB(Widget, XtPointer, XtPointer) ; +static void CenterMsgCB(Widget, XtPointer, XtPointer); +static void HelpHyperlinkCB(Widget, caddr_t, caddr_t); +static void HelpCloseCB(Widget, caddr_t, caddr_t); + void Help(char *helpVolume, char *locationId) @@ -118,7 +113,7 @@ Help(char *helpVolume, char *locationId) } -void +static void HelpCloseCB(Widget widget, caddr_t client_data, caddr_t call_data) { @@ -135,7 +130,7 @@ HelpCloseCB(Widget widget, caddr_t client_data, caddr_t call_data) X->helpMapped = False; } -void +static void HelpHyperlinkCB(Widget widget, caddr_t client_data, caddr_t call_data) { DtHelpDialogCallbackStruct *pHyper = (DtHelpDialogCallbackStruct *) call_data; @@ -534,7 +529,7 @@ UnmanageCB(Widget widget, XtPointer client_data, XtPointer call_data) XtUnmanageChild(widget); } -void +static void CenterMsgCB (Widget widget, XtPointer client_data, XtPointer call_data) { int n; diff --git a/cde/programs/dtcalc/motif.c b/cde/programs/dtcalc/motif.c index 6045341e1..00e3bb440 100644 --- a/cde/programs/dtcalc/motif.c +++ b/cde/programs/dtcalc/motif.c @@ -111,12 +111,14 @@ extern XmWidgetExtData _XmGetWidgetExtData( #include "ds_common.h" #include "ds_popup.h" #include "ds_xlib.h" +#include "text.h" Pixmap _DtGetMask(Screen *screen, char *image_name); // DtSvc/DtUtil2/XmWrap.c ApplicationArgs application_args; XVars X; -Boolean colorSrv; +Boolean ignore_event = False; +XtIntervalId timerId = 0; static XtResource resources[] = { @@ -152,17 +154,15 @@ static XtResource resources[] = }, }; -char DTCALC_CLASS_NAME[] = "Dtcalc"; +static char DTCALC_CLASS_NAME[] = "Dtcalc"; -extern char *opts[] ; /* Command line option strings. */ +static Widget modeArry[3]; +static XmPixelSet pixels[XmCO_MAX_NUM_COLORS]; +static Pixel white_pixel; +static Pixel black_pixel; +static Boolean BlackWhite = False; -Widget modeArry[3]; -XmPixelSet pixels[XmCO_MAX_NUM_COLORS]; -Pixel white_pixel; -Pixel black_pixel; -Boolean BlackWhite = False; - -char * dt_path = NULL; +static char * dt_path = NULL; static Widget funBtn = NULL; static Widget constBtn = NULL; @@ -175,12 +175,11 @@ static Atom saveatom ; static Atom command_atom ; static Atom wm_state_atom; -Boolean ignore_event = False; -XtIntervalId timerId = 0; - static int lastArmed[10]; static int countArmed = 0; +static Boolean colorSrv; + /* Structure used on a save session to see if a dt is iconic */ typedef struct { @@ -235,27 +234,7 @@ static void create_menu_bar(Widget parent); static void init_colors(void); static void create_popup(Widget parent); - -extern char **environ ; - -extern char *base_str[] ; /* Strings for each base value. */ -extern char *calc_res[] ; /* Calctool X resources. */ -extern char *dtype_str[] ; /* Strings for each display mode value. */ -extern char *lstrs[] ; /* Labels for various Motif items. */ -extern char *mess[] ; /* Message strings. */ -extern char *mode_str[] ; /* Strings for each mode value. */ -extern char *pstrs[] ; /* Property sheet strings. */ -extern char *ttype_str[] ; /* Strings for each trig type value. */ -extern char *vstrs[] ; /* Various strings. */ - -extern struct button buttons[] ; /* Calculator button values. */ -extern struct button mode_buttons[] ; /* Calculator mode button values. */ -extern struct menu cmenus[] ; /* Calculator menus. */ -extern struct menu_entry menu_entries[] ; /* All the menu strings. */ - -extern Vars v ; /* Calctool variables and options. */ - -char translations_return[] = "Return:ManagerGadgetSelect()"; +static char translations_return[] = "Return:ManagerGadgetSelect()"; static Boolean NoDisplay=False; extern XtPointer _XmStringUngenerate ( diff --git a/cde/programs/dtcalc/motif.h b/cde/programs/dtcalc/motif.h index 4ded8c26d..d8cb40af3 100644 --- a/cde/programs/dtcalc/motif.h +++ b/cde/programs/dtcalc/motif.h @@ -88,6 +88,8 @@ typedef struct Xobject { /* Motif/Xlib graphics object. */ typedef struct Xobject *XVars ; extern XVars X ; +extern XtIntervalId timerId; +extern Boolean ignore_event; #ifndef CDE_INSTALLATION_TOP #define CDE_INSTALLATION_TOP "/usr/dt" diff --git a/cde/programs/dtcalc/mp.c b/cde/programs/dtcalc/mp.c index 8e7b9e292..2a47a62d5 100644 --- a/cde/programs/dtcalc/mp.c +++ b/cde/programs/dtcalc/mp.c @@ -53,6 +53,7 @@ #include #include "calctool.h" #include
+#include "text.h" struct { int b, t, m, mxr, r[MP_SIZE] ; @@ -78,12 +79,6 @@ static int c__239 = 239 ; static int c__7 = 7 ; static int c__16 = 16 ; -extern char *mpstrs[] ; /* MP errors (visible with -D option). */ -extern char *vstrs[] ; /* Various strings. */ - -extern Vars v ; /* Calctool variables and options. */ - - void mpabs(int *x, int *y) { diff --git a/cde/programs/dtcalc/text.c b/cde/programs/dtcalc/text.c index ce3e70d3b..fb88666c2 100644 --- a/cde/programs/dtcalc/text.c +++ b/cde/programs/dtcalc/text.c @@ -36,14 +36,7 @@ #include "calctool.h" #include "ds_common.h" -extern struct button buttons[] ; /* Calculator button values. */ -extern struct button mode_buttons[] ; /* Special "mode" buttons. */ -extern struct menu cmenus[] ; /* Calculator menus. */ -extern struct menu_entry menu_entries[] ; /* All the menu strings. */ - -extern Vars v ; /* Calctool variables and options. */ - -void init_mess(void); +static void init_mess(void); /* The following are all the strings used by the dtcalc program. * They are initialized in init_text() to the local language equivalents. @@ -630,7 +623,7 @@ init_text(void) /* Setup text strings depending upon language. */ } -void +static void init_mess(void) /* Setup text strings depending upon language. */ { int i ; diff --git a/cde/programs/dtcalc/text.h b/cde/programs/dtcalc/text.h new file mode 100644 index 000000000..c9c58184f --- /dev/null +++ b/cde/programs/dtcalc/text.h @@ -0,0 +1,40 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 2021 Peter Howkins. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +#ifndef __TEXT_H +#define __TEXT_H + +extern char *base_str[] ; /* Strings for each base value. */ +extern char *dtype_str[] ; /* Strings for each display mode value. */ +extern char *cmdstr[] ; /* Strings for each command line option. */ +extern char *calc_res[] ; /* Calctool X resources. */ +extern char *lstrs[] ; /* Labels for various Motif items. */ +extern char *mess[] ; /* Message strings. */ +extern char *mode_str[] ; /* Strings for each mode value. */ +extern char *ttype_str[] ; /* Strings for each trig type value. */ +extern char *vstrs[] ; /* Various strings. */ +extern char *mpstrs[] ; /* MP errors (visible with -D option). */ +extern char *pstrs[] ; /* Property sheet strings. */ +extern char *opts[] ; /* Command line option strings. */ +extern char *ustrs[] ; /* Usage message strings. */ + +#endif /* __TEXT_H */