June 1994
Intermediate to advanced
821 pages
24h 40m
English
The main is a very short and straightforward outline for the major routines to follow.
Example 14-2. basecalc — the main
char myDisplayName[256];
/* X11 Integer Programmer's Calculator with base conversions */
main (argc, argv)
int argc;
register char *argv[];
{
/* So we can use the resource manager data merging functions */
XrmInitialize();
/* Parse command line first so we can open display, store any
* options in a database */
parseOpenDisp (&argc, argv);
/* Get server defaults, program defaults, .Xdefaults;
* merge them and finally the command line */
mergeDatabases();
/* Extract values from database and convert to form usable
* by this program */
extractOpts ();
/* Load font, make pixmaps, set up arrays of windows */
initCalc ();
/* Get keyboard settings for interrupt, delete, etc. */
initTty ();
/* Make a standard cursor */
makeCursor ();
/* Set standard properties, create and map windows */
makeWindows (argc, argv);
/* Get events */
takeEvents ();
/* Bow out gracefully */
XCloseDisplay(display);
exit (1);
}initTty is not shown in this chapter, but it is
included in Appendix D. It simply
performs a few system calls to determine which keys are being used for
erase, delete, and interrupt.
The following sections describe each routine called in the main. Each section will begin with a brief description of the routine, followed by the declarations from basecalc.h that are needed with that routine and then the code.
Read now
Unlock full access