Table of Contents
These functions have been created to handle differences between different operating systems (Linux, QNX 4, and QNX 6) and/or different graphical user interfaces (GTK, Photon 1.14 and Photon 2). We refer to these functions as "abstracted" because they come in OS- or GUI-specific pairs or triplets, where each function has exactly the same name and arguments. Each function in the pair or triplet is included in a mutually exclusive OS-specific or GUI-specific library. When a program starts up, the common.g function lib_require ensures that the appropriate libraries are loaded. Thereafter, when the program or the common code calls one of these functions, the code that runs is specific to the OS and GUI in use.
For more information on abstracted and common functions, please refer to Section 3.1, “File Overview”.
Section 10.1.1, “System Calls - anyos_system” |
Section 10.1.2, “Showing Help - anyos_help” |
This function has been abstracted because the QNX operating system emits a signal when it makes a system call. In QNX we have to block signals while we make the system call.
/*-------------------------------------------------------------------- * Function: anyos_system * Returns: doesn't return * Description: A wrapper for the system() function to allow for alternate * code in QNX. *------------------------------------------------------------------*/ function anyos_system(call, sig) { system(call); }
The Gamma functions block_signal and unblock_signal signal are used for deactivating signals while the system call is made. The signal has to be re-defined using the Gamma signal function once block_signal has been used.
/*-------------------------------------------------------------------- * Function: anyos_system * Application: common * Returns: t or nil * Description: A wrapper for the Gamma system() function that blocks * signals while making a call, then reassigns a signal * and unblocks the signals. This is necessary for QNX4, * and perhaps QNX6, because in that OS a system() call * emits a signal. *------------------------------------------------------------------*/ function anyos_system(call, sig) { block_signal(sig); system(call); signal(sig, `anygui_sigchild()); unblock_signal(sig); }
Each of these functions calls the anygui_makemsg function to create the message/dialog window that displays the message.
For Linux we assume that help files are not installed on the system, but that a browser is installed. Thus, this function walks through a list of browsers and starts the first available one, pointing it to the on-line Cogent documentation for the Demo and Tutorials. We use the find_on_path fuction to locate a browser that is actually installed.
/*-------------------------------------------------------------------- * Function: anyos_help * Returns: function * Description: Starts up a browser and displays the Tutorial docs. *------------------------------------------------------------------*/ function anyos_help() { local url = "http://developers.cogentrts.com/cogent/cogentdocs/booktu.html"; local browser, browsers = list("galeon", "mozilla", "lynx", "opera", "dillo", "netscape", "w3m", "netrik", "skipstone", "amaya", "phoenix", "elinks"); local b_length = length(browsers); for (i = 0; i < b_length; i++) { browser = car(nth_cdr(browsers,i)); if (find_on_path(browser)) { system(string(browser, " ", url, " &")); i = b_length; } else if(i == (b_length - 1)) anygui_makemsg(string("\nSorry, your browser isn't supported. ", "Try installing one of these: \n", browsers, "\n\n", "Or modify the anyos_help() function, ", "line 60, in lib/linux.d\n", "and add your browser to the list.\n")); } }
For QNX running Photon, we assume that the Helpviewer is available to view the documentation. We use the Gamma is_file function to make sure the documentation has been installed in the Helpviewer. Then we use the Gamma/Photon functions PxHelpTopicRoot and PxHelpTopic to set the Helpviewer to the proper page. When QNX 6 is running GTK, the Px* functions are not readily available, so we use Voyager to view the documentation.
/*-------------------------------------------------------------------- * Function: anyos_help * Returns: t or nil * Description: Starts up the Helpviewer and displays the Tutorial docs. *------------------------------------------------------------------*/ function anyos_help() { local help_url = "/usr/cogent/help/cogent-set/booktu/booktu.html"; if (is_file(help_url)) { if (_gui_ == "Photon") { /* Use Helpviewer */ PxHelpTopicRoot("/Cogent Documentation/Cogent Tools Demo and Tutorial"); PxHelpTopic("booktu.html"); } else { /* Use Voyager */ help_url = "http://developers.cogentrts.com/cogent/cogentdocs/booktu.html"; system(string("voyager -u ", help_url, " &")); } } else anygui_makemsg(string("\nSorry, the Cogent Tools Demo and Tutorial", "\nmanual is not available on your system.\n", "\nPlease check your", "\nCogent Documentation installation.\n\n")); }
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.