2011-06-14 08:19:01 +00:00
|
|
|
|
/************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* Star Traders: A Game of Interstellar Trading *
|
2024-01-02 01:33:37 +00:00
|
|
|
|
* Copyright (C) 1990-2024, John Zaitseff *
|
2011-06-14 08:19:01 +00:00
|
|
|
|
* *
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*
|
2011-06-14 13:01:15 +00:00
|
|
|
|
Author: John Zaitseff <J.Zaitseff@zap.org.au>
|
2024-05-25 20:05:27 +00:00
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
2011-06-14 08:19:01 +00:00
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
|
|
Star Traders is a simple game of interstellar trading, where the object
|
|
|
|
|
of the game is to create companies, buy and sell shares, borrow and
|
|
|
|
|
repay money, in order to become the wealthiest player (the winner).
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
This file, trader.c, contains the main program and command-line
|
|
|
|
|
interface for Star Traders.
|
2011-06-14 08:19:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2018-03-30 01:46:37 +00:00
|
|
|
|
along with this program. If not, see https://www.gnu.org/licenses/.
|
2011-06-14 08:19:01 +00:00
|
|
|
|
*/
|
2011-06-14 13:02:16 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-14 13:19:58 +00:00
|
|
|
|
#include "trader.h"
|
|
|
|
|
|
|
|
|
|
|
2011-06-29 03:15:26 +00:00
|
|
|
|
/************************************************************************
|
2011-07-19 12:07:15 +00:00
|
|
|
|
* Module-specific constant definitions *
|
2011-06-29 03:15:26 +00:00
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
// Constants for command line options
|
|
|
|
|
|
|
|
|
|
enum options_char {
|
|
|
|
|
OPTION_NO_COLOR = 1,
|
2011-07-22 02:20:58 +00:00
|
|
|
|
OPTION_DONT_ENCRYPT,
|
2011-07-19 12:29:36 +00:00
|
|
|
|
OPTION_MAX_TURN
|
2011-07-19 12:07:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char options_short[] = "hV";
|
|
|
|
|
// -h, --help
|
|
|
|
|
// -V, --version
|
|
|
|
|
|
|
|
|
|
static struct option const options_long[] = {
|
2011-07-22 02:20:58 +00:00
|
|
|
|
{ "help", no_argument, NULL, 'h' },
|
|
|
|
|
{ "version", no_argument, NULL, 'V' },
|
|
|
|
|
{ "no-color", no_argument, NULL, OPTION_NO_COLOR },
|
|
|
|
|
{ "no-colour", no_argument, NULL, OPTION_NO_COLOR },
|
|
|
|
|
{ "dont-encrypt", no_argument, NULL, OPTION_DONT_ENCRYPT },
|
|
|
|
|
{ "max-turn", required_argument, NULL, OPTION_MAX_TURN },
|
|
|
|
|
{ NULL, 0, NULL, 0 }
|
2011-07-19 12:07:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* Module-specific function prototypes *
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: main - Main program implementing Star Traders
|
|
|
|
|
Parameters: argc - Command-line argument count
|
|
|
|
|
argv - Command-line argument vector
|
|
|
|
|
Returns: int - Operating system return code: 0 if all well, 1 if not.
|
|
|
|
|
|
|
|
|
|
The main() function is, of course, where all the action starts in a C
|
|
|
|
|
program. This function contains the main game loop, a series of game
|
|
|
|
|
functions that are called in sequence.
|
|
|
|
|
*/
|
2011-06-29 03:15:26 +00:00
|
|
|
|
int main (int argc, char *argv[]);
|
2011-07-04 05:45:03 +00:00
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: process_cmdline - Process command line arguments
|
|
|
|
|
Parameters: argc - Same as passed to main()
|
|
|
|
|
argv - Same as passed to main()
|
|
|
|
|
Returns: (nothing)
|
|
|
|
|
|
|
|
|
|
This function processes the command line arguments passed through argc
|
|
|
|
|
and argv. If required, it shows the program version number and/or
|
|
|
|
|
command-line help. It also sets global variables starting with option_
|
|
|
|
|
to appropriate values.
|
|
|
|
|
*/
|
2011-07-22 02:31:54 +00:00
|
|
|
|
static void process_cmdline (int argc, char *argv[]);
|
2011-07-19 12:07:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: show_version - Show program version information
|
|
|
|
|
Parameters: (none)
|
|
|
|
|
Returns: (does not return)
|
|
|
|
|
|
|
|
|
|
This function displays version information about this program, then
|
|
|
|
|
terminates with exit code EXIT_SUCCESS.
|
|
|
|
|
*/
|
2011-07-22 02:31:54 +00:00
|
|
|
|
static void show_version (void) __attribute__((noreturn));
|
2011-07-19 12:07:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: show_usage - Show command line usage information
|
|
|
|
|
Parameters: status - Exit status
|
|
|
|
|
Returns: (does not return)
|
|
|
|
|
|
|
|
|
|
This function displays usage information for this program. If status
|
|
|
|
|
is zero, a detailed explanation is sent to stdout; otherwise, a brief
|
|
|
|
|
message is sent to stderr. It exits to the operating system with
|
|
|
|
|
status as the exit code.
|
|
|
|
|
*/
|
2011-07-22 02:31:54 +00:00
|
|
|
|
static void show_usage (int status) __attribute__((noreturn));
|
2011-07-04 05:45:03 +00:00
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
|
2021-01-14 01:04:03 +00:00
|
|
|
|
/*
|
|
|
|
|
Function: init_program_prelim - Initialise program preliminaries
|
|
|
|
|
Parameters: argc - Same as passed to main()
|
|
|
|
|
argv - Same as passed to main()
|
|
|
|
|
Returns: (nothing)
|
|
|
|
|
|
|
|
|
|
This function initialises the program name, locale and message
|
|
|
|
|
catalogs. It must be called before command line arguments are
|
|
|
|
|
processed.
|
|
|
|
|
*/
|
|
|
|
|
static void init_program_prelim (int argc, char *argv[]);
|
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/*
|
|
|
|
|
Function: init_program - Initialise program-wide functions
|
|
|
|
|
Parameters: (none)
|
|
|
|
|
Returns: (nothing)
|
|
|
|
|
|
|
|
|
|
This function initialises the terminal display, internal low-level
|
|
|
|
|
routines, etc. It should be called before the game starts.
|
|
|
|
|
*/
|
2011-07-22 02:31:54 +00:00
|
|
|
|
static void init_program (void);
|
2011-07-19 12:07:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: end_program - Deinitialise program-wide functions
|
|
|
|
|
Parameters: (none)
|
|
|
|
|
Returns: (nothing)
|
|
|
|
|
|
|
|
|
|
This function finalises the terminal display, internal low-level
|
|
|
|
|
routines, etc. It should be the last function called in the ordinary
|
|
|
|
|
course of program execution.
|
|
|
|
|
*/
|
2011-07-22 02:31:54 +00:00
|
|
|
|
static void end_program (void);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
2011-06-14 13:02:16 +00:00
|
|
|
|
/************************************************************************
|
|
|
|
|
* Main program *
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
|
{
|
2021-01-14 01:04:03 +00:00
|
|
|
|
// Initialise program name, locale and message catalogs
|
|
|
|
|
init_program_prelim(argc, argv);
|
2011-08-01 08:17:02 +00:00
|
|
|
|
|
2011-06-29 03:15:26 +00:00
|
|
|
|
// Process command line arguments
|
|
|
|
|
process_cmdline(argc, argv);
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
// Set up the display, internal low-level routines, etc.
|
|
|
|
|
init_program();
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
// Play the actual game
|
|
|
|
|
init_game();
|
2011-07-14 05:11:53 +00:00
|
|
|
|
while (! quit_selected && ! abort_game && turn_number <= max_turn) {
|
2011-07-18 10:16:24 +00:00
|
|
|
|
selection_t selection;
|
2011-07-18 06:22:24 +00:00
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
select_moves();
|
2011-07-18 06:22:24 +00:00
|
|
|
|
selection = get_move();
|
|
|
|
|
process_move(selection);
|
2011-07-04 05:45:03 +00:00
|
|
|
|
exchange_stock();
|
|
|
|
|
next_player();
|
2011-06-30 10:31:19 +00:00
|
|
|
|
}
|
2011-07-04 05:45:03 +00:00
|
|
|
|
end_game();
|
2011-06-30 10:31:19 +00:00
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
// Finish up...
|
|
|
|
|
end_program();
|
2011-08-09 13:20:56 +00:00
|
|
|
|
return EXIT_SUCCESS;
|
2011-06-14 13:02:16 +00:00
|
|
|
|
}
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* Command line processing *
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
// These functions are documented at the start of this file
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/***********************************************************************/
|
2011-07-20 00:50:18 +00:00
|
|
|
|
// process_cmdline: Process command line arguments
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
void process_cmdline (int argc, char *argv[])
|
2011-06-29 03:15:26 +00:00
|
|
|
|
{
|
|
|
|
|
// Process arguments starting with "-" or "--"
|
2011-06-30 11:11:36 +00:00
|
|
|
|
opterr = true;
|
|
|
|
|
while (true) {
|
2011-07-20 11:18:28 +00:00
|
|
|
|
int c = getopt_long(argc, argv, options_short, options_long, NULL);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
if (c == EOF)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
|
case 'h':
|
2011-07-14 10:19:04 +00:00
|
|
|
|
// -h, --help: show help
|
2011-06-29 03:15:26 +00:00
|
|
|
|
show_usage(EXIT_SUCCESS);
|
2011-07-14 10:19:04 +00:00
|
|
|
|
break;
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
case 'V':
|
2011-07-14 10:19:04 +00:00
|
|
|
|
// -V, --version: show version information
|
2011-06-29 03:15:26 +00:00
|
|
|
|
show_version();
|
2011-07-14 10:19:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPTION_NO_COLOR:
|
|
|
|
|
// --no-color, --no-colour: don't use colour
|
|
|
|
|
option_no_color = true;
|
|
|
|
|
break;
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
2011-07-22 02:20:58 +00:00
|
|
|
|
case OPTION_DONT_ENCRYPT:
|
|
|
|
|
// --dont-encrypt: don't encrypt game files
|
|
|
|
|
option_dont_encrypt = true;
|
2011-07-19 13:24:17 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2011-07-19 12:29:36 +00:00
|
|
|
|
case OPTION_MAX_TURN:
|
|
|
|
|
// --max-turn: specify the maximum turn number
|
2011-07-20 11:18:28 +00:00
|
|
|
|
{
|
|
|
|
|
char *p;
|
2011-07-19 12:29:36 +00:00
|
|
|
|
|
2011-07-20 11:18:28 +00:00
|
|
|
|
option_max_turn = strtol(optarg, &p, 10);
|
|
|
|
|
|
|
|
|
|
if (option_max_turn < MIN_MAX_TURN || p == NULL || *p != '\0') {
|
2017-05-19 23:55:20 +00:00
|
|
|
|
fprintf(stderr, _("%s: invalid value for --max-turn: '%s'\n"),
|
2011-08-25 04:26:25 +00:00
|
|
|
|
program_name, optarg);
|
2011-07-20 11:18:28 +00:00
|
|
|
|
show_usage(EXIT_FAILURE);
|
|
|
|
|
}
|
2011-07-19 12:29:36 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2011-06-29 03:15:26 +00:00
|
|
|
|
default:
|
|
|
|
|
show_usage(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process remaining arguments
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
if (optind < argc && argv[optind] != NULL) {
|
|
|
|
|
if (*argv[optind] == '-') {
|
2017-05-19 23:55:20 +00:00
|
|
|
|
fprintf(stderr, _("%s: invalid operand '%s'\n"),
|
2011-08-25 11:34:41 +00:00
|
|
|
|
program_name, argv[optind]);
|
2011-06-30 05:25:30 +00:00
|
|
|
|
show_usage(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
if (strlen(argv[optind]) == 1
|
|
|
|
|
&& *argv[optind] >= '1' && *argv[optind] <= '9') {
|
2011-07-04 00:28:50 +00:00
|
|
|
|
game_num = *argv[optind] - '0';
|
|
|
|
|
} else {
|
2017-05-19 23:55:20 +00:00
|
|
|
|
fprintf(stderr, _("%s: invalid game number '%s'\n"),
|
2011-08-25 04:26:25 +00:00
|
|
|
|
program_name, argv[optind]);
|
2011-07-01 23:39:23 +00:00
|
|
|
|
show_usage(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-30 05:25:30 +00:00
|
|
|
|
optind++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
if (optind < argc && argv[optind] != NULL) {
|
2017-05-19 23:55:20 +00:00
|
|
|
|
fprintf(stderr, _("%s: extra operand '%s'\n"),
|
2011-08-25 04:26:25 +00:00
|
|
|
|
program_name, argv[optind]);
|
2011-06-30 05:25:30 +00:00
|
|
|
|
show_usage(EXIT_FAILURE);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/***********************************************************************/
|
2011-07-20 00:50:18 +00:00
|
|
|
|
// show_version: Show program version information
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
void show_version (void)
|
2011-06-29 03:15:26 +00:00
|
|
|
|
{
|
2011-08-17 02:21:18 +00:00
|
|
|
|
/* TRANSLATORS: "John Zaitseff" [IPA d͡ʒɒn ˈzaɪ̯t͡səf] is the proper
|
|
|
|
|
name of the author. The IPA pronunciation in this comment is in
|
|
|
|
|
UTF-8 encoding. */
|
2011-08-01 09:30:19 +00:00
|
|
|
|
printf(_("\
|
2011-08-01 09:43:55 +00:00
|
|
|
|
Star Traders (%s) %s\n\
|
2011-06-29 03:15:26 +00:00
|
|
|
|
Copyright (C) %s, John Zaitseff.\n\
|
|
|
|
|
\n\
|
|
|
|
|
Star Traders is a simple game of interstellar trading, where the object\n\
|
|
|
|
|
of the game is to create companies, buy and sell shares, borrow and repay\n\
|
|
|
|
|
money, in order to become the wealthiest player (the winner).\n\
|
|
|
|
|
\n\
|
|
|
|
|
This program is free software that is distributed under the terms of the\n\
|
|
|
|
|
GNU General Public License, version 3 or later. You are welcome to\n\
|
|
|
|
|
modify and/or distribute it under certain conditions. This program has\n\
|
|
|
|
|
NO WARRANTY, to the extent permitted by law; see the License for details.\n\
|
2024-01-02 01:33:37 +00:00
|
|
|
|
"), program_name, PACKAGE_VERSION, "1990-2024");
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/***********************************************************************/
|
2011-07-20 00:50:18 +00:00
|
|
|
|
// show_usage: Show command line usage information
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
void show_usage (int status)
|
2011-06-29 03:15:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (status != EXIT_SUCCESS) {
|
2017-05-19 23:55:20 +00:00
|
|
|
|
fprintf(stderr, _("%s: Try '%s --help' for more information.\n"),
|
2011-08-25 04:26:25 +00:00
|
|
|
|
program_name, program_name);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
} else {
|
2011-08-25 04:26:25 +00:00
|
|
|
|
printf(_("Usage: %s [OPTION ...] [GAME]\n"), program_name);
|
2011-08-01 09:30:19 +00:00
|
|
|
|
printf(_("\
|
2011-06-29 03:15:26 +00:00
|
|
|
|
Play Star Traders, a simple game of interstellar trading.\n\n\
|
2011-08-01 09:30:19 +00:00
|
|
|
|
"));
|
|
|
|
|
printf(_("\
|
2011-06-29 03:15:26 +00:00
|
|
|
|
Options:\n\
|
2011-07-22 02:16:09 +00:00
|
|
|
|
-V, --version output version information and exit\n\
|
|
|
|
|
-h, --help display this help and exit\n\
|
2011-08-01 10:52:40 +00:00
|
|
|
|
--no-color don't use color for displaying text\n\
|
2011-07-22 02:16:09 +00:00
|
|
|
|
--max-turn=NUM set the number of turns to NUM\n\n\
|
2011-08-01 09:30:19 +00:00
|
|
|
|
"));
|
|
|
|
|
printf(_("\
|
2011-06-29 03:15:26 +00:00
|
|
|
|
If GAME is specified as a number between 1 and 9, load and continue\n\
|
|
|
|
|
playing that game. If GAME is not specified, start a new game.\n\n\
|
2011-08-01 09:30:19 +00:00
|
|
|
|
"));
|
2011-06-29 03:15:26 +00:00
|
|
|
|
|
|
|
|
|
#ifdef PACKAGE_AUTHOR
|
2011-08-17 02:21:18 +00:00
|
|
|
|
/* TRANSLATORS: The first %s is the proper name of the package
|
|
|
|
|
author, John Zaitseff [IPA d͡ʒɒn ˈzaɪ̯t͡səf]; the second %s is
|
2019-04-11 19:13:41 +00:00
|
|
|
|
the email address for reporting bugs. Please add ANOTHER line
|
|
|
|
|
with the (translated) text "Report translation bugs to
|
|
|
|
|
<ADDRESS>\n", with ADDRESS replaced with either an email
|
2011-08-17 02:21:18 +00:00
|
|
|
|
address or web URL for reporting bugs in your translation. */
|
2011-08-01 09:30:19 +00:00
|
|
|
|
printf(_("Report bugs to %s <%s>.\n"), PACKAGE_AUTHOR, PACKAGE_BUGREPORT);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
#else
|
2019-04-11 19:13:41 +00:00
|
|
|
|
/* TRANSLATORS: %s is the email address for reporting bugs. As
|
2011-08-17 09:13:05 +00:00
|
|
|
|
with the previous string, please add ANOTHER line with the
|
2011-08-17 02:21:18 +00:00
|
|
|
|
(translated) text "Report translation bugs to <ADDRESS>\n",
|
2019-04-11 19:13:41 +00:00
|
|
|
|
with ADDRESS replaced with either an email address or web URL
|
2011-08-17 02:21:18 +00:00
|
|
|
|
for reporting bugs in your translation. */
|
2011-08-01 09:30:19 +00:00
|
|
|
|
printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef PACKAGE_PACKAGER_BUG_REPORTS
|
2011-08-17 09:13:05 +00:00
|
|
|
|
/* TRANSLATORS: The first %s is for packagers and may be
|
|
|
|
|
something like "Debian". */
|
2011-08-01 09:30:19 +00:00
|
|
|
|
printf(_("Report %s bugs to <%s>.\n"), PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef PACKAGE_URL
|
2011-08-01 09:49:16 +00:00
|
|
|
|
printf(_("Star Traders home page: <%s>.\n"), PACKAGE_URL);
|
2011-06-29 03:15:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit(status);
|
|
|
|
|
}
|
2011-07-04 05:45:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* Initialisation and deinitialisation function definitions *
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
// These functions are documented at the start of this file
|
2011-07-04 05:45:03 +00:00
|
|
|
|
|
|
|
|
|
|
2021-01-14 01:04:03 +00:00
|
|
|
|
/***********************************************************************/
|
|
|
|
|
// init_program_prelim: Initialise program preliminaries
|
|
|
|
|
|
|
|
|
|
void init_program_prelim (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
// Strip off leading pathname components from program name
|
|
|
|
|
init_program_name(argv[0]);
|
|
|
|
|
|
|
|
|
|
// Initialise the locale and message catalogs
|
2021-01-14 01:28:02 +00:00
|
|
|
|
init_locale();
|
2021-01-14 01:04:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/***********************************************************************/
|
2011-07-20 00:50:18 +00:00
|
|
|
|
// init_program: Initialise program-wide functions
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
void init_program (void)
|
|
|
|
|
{
|
|
|
|
|
// Initialise the random number generator
|
2011-07-04 07:13:29 +00:00
|
|
|
|
init_rand();
|
2011-07-04 05:45:03 +00:00
|
|
|
|
|
2011-07-20 00:44:44 +00:00
|
|
|
|
// Initialise locale-specific variables
|
2021-01-14 01:04:48 +00:00
|
|
|
|
init_locale_vars();
|
2011-07-20 00:44:44 +00:00
|
|
|
|
|
2011-07-19 09:09:59 +00:00
|
|
|
|
// Initialise the terminal display
|
|
|
|
|
init_screen();
|
2011-07-04 05:45:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-19 12:07:15 +00:00
|
|
|
|
/***********************************************************************/
|
2011-07-20 00:50:18 +00:00
|
|
|
|
// end_program: Deinitialise program-wide functions
|
|
|
|
|
|
2011-07-04 05:45:03 +00:00
|
|
|
|
void end_program (void)
|
|
|
|
|
{
|
|
|
|
|
end_screen();
|
|
|
|
|
}
|
2011-07-19 12:30:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
|
// End of file
|