home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / game / think / chaos / src / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-27  |  4.1 KB  |  176 lines

  1. /*  Chaos:            The Chess HAppening Organisation System    V5.2
  2.     Copyright (C)   1993    Jochen Wiedmann
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.     $RCSfile: main.c,v $
  20.     $Revision: 2.3 $
  21.     $Date: 1993/12/12 13:22:15 $
  22.  
  23.     This file contains main() and some other global stuff.
  24.  
  25.     Computer:    Amiga 1200            Compiler:    Dice 2.07.54 (3.0)
  26.  
  27.     Author:    Jochen Wiedmann
  28.         Am Eisteich 9
  29.       72555 Metzingen
  30.         Tel. 07123 / 14881
  31.         Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  32. */
  33.  
  34.  
  35. char *AVERSION = "Chaos V5.2";
  36. char *PVERSION = "Chaos V5.2     (C) 1993        by  Jochen Wiedmann";
  37. char *VERVERSION = "$VER: Chaos 5.2 (13.12.93)";
  38.  
  39.  
  40. #ifndef CHAOS_H
  41. #include "chaos.h"
  42. #endif
  43.  
  44.  
  45. /*
  46.     Global variables
  47. */
  48. struct List PlayerList;
  49. int IsSaved                = TRUE;
  50. int OutputDevice            = FALSE;
  51. char TrnFileName [TRNFILENAME_LEN+1]    = "";
  52. int AllowErrorMessage            = TRUE;
  53.  
  54. /*
  55.     The following global variables get saved into the tournament file.
  56. */
  57. int NumRounds                = 0;
  58. struct Player *RankingFirst        = NULL;
  59. int NumPlayers                = 0;
  60. int NumGamesMissing;
  61. char TrnName [TRNNAME_LEN+1]        = "";
  62. int TrnMode                = TNMODEF_SWISS_PAIRING;
  63.  
  64.  
  65.  
  66. /*
  67.     The Cleanup() function gets called when the program terminates.
  68. */
  69. void Cleanup(int errcode, char *errmsg)
  70.  
  71.   {
  72.     if (AllowErrorMessage  &&  errmsg != NULL)
  73.       { printf("%s\n", errmsg);
  74.       }
  75.  
  76.     TerminateMainWnd();
  77.     PutMemAll();
  78.     CloseLibs();
  79.  
  80.     exit (errcode);
  81.   }
  82.  
  83.  
  84.  
  85. /*
  86.     Die übliche main()-Funktion
  87. */
  88. void main(int argc, char *argv[])
  89.  
  90. { /*  Initialize the libraries            */
  91.   OpenLibs();
  92.   /*  Initialize the random number generator    */
  93.   InitRandom();
  94.   /*  Initialize the tournament data        */
  95.   DeleteTournament(NULL);
  96.   /*  Process the arguments            */
  97.   DoStartup(argc, argv);
  98.   /*  Initialize the main window        */
  99.   InitMainWnd();
  100.  
  101.   ProcessMainWnd();
  102. }
  103.  
  104.  
  105.  
  106. /*
  107.     wbmain() gets called from DICE startup code when running from the
  108.     Workbench. We do nothing special except calling main() to be Aztec
  109.     compatible.
  110. */
  111. #ifdef _DCC
  112. void wbmain(void *wbmsg)
  113.  
  114. { main(0, (char **) wbmsg);
  115. }
  116. #endif    /*  _DCC    */
  117.  
  118.  
  119.  
  120. #ifdef DEBUG
  121. #undef strlen
  122. size_t dbg_strlen(const char *ptr)
  123. { if (ptr == NULL)
  124.   { printf("strlen: NULL pointer!\n");
  125.   }
  126.   return(strlen(ptr));
  127. }
  128.  
  129. #undef strcpy
  130. char *dbg_strcpy(char *dest, const char *src)
  131. { if (src == NULL  ||  dest == NULL)
  132.   { printf("strcpy: NULL pointer!\n");
  133.   }
  134.   return(strcpy (dest, src));
  135. }
  136.  
  137. #undef printf
  138. int dbg_printf(const char *fmt, ...)
  139. { char **args = &fmt;
  140.  
  141.   if (fmt == NULL)
  142.   { printf("printf: NULL pointer!\n");
  143.   }
  144.   return(printf(fmt, args[1], args[2], args[3], args[4], args[5], args [6],
  145.      args[7], args[8], args[9], args[10], args[11], args[12], args[13],
  146.      args[14], args[15], args[16], args[17], args[18], args[19],
  147.      args[20]));
  148. }
  149.  
  150. #undef sprintf
  151. int dbg_sprintf(char *dest, const char *fmt, ...)
  152. { char **args = &fmt;
  153.  
  154.   if (dest == NULL  ||  fmt == NULL)
  155.   { printf("sprintf: NULL pointer!\n");
  156.   }
  157.   return(sprintf(dest, fmt, args[1], args[2], args[3], args[4], args[5],
  158.      args [6], args[7], args[8], args[9], args[10], args[11], args[12],
  159.      args[13], args[14], args[15], args[16], args[17], args[18],
  160.      args[19], args[20]));
  161. }
  162.  
  163. #undef fprintf
  164. int dbg_fprintf(FILE *fh, const char *fmt, ...)
  165. { char **args = &fmt;
  166.  
  167.   if (fh == NULL  ||  fmt == NULL)
  168.   { printf("fprintf: NULL pointer!\n");
  169.   }
  170.   return(fprintf(fh, fmt, args[1], args[2], args[3], args[4], args[5],
  171.      args [6], args[7], args[8], args[9], args[10], args[11], args[12],
  172.      args[13], args[14], args[15], args[16], args[17], args[18],
  173.      args[19], args[20]));
  174. }
  175. #endif
  176.