home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / game / think / chaos / src / arexxami.c next >
Encoding:
C/C++ Source or Header  |  1993-12-27  |  19.3 KB  |  851 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: ARexxAmi.c,v $
  20.     $Revision: 2.5 $
  21.     $Date: 1993/12/12 13:22:15 $
  22.  
  23.     This file contains the functions of the ARexx port. I don't expect them
  24.     to be interesting besides the Amiga.
  25.  
  26.     Computer:    Amiga 1200            Compiler:    Dice 2.07.54 (3.0)
  27.  
  28.     Author:    Jochen Wiedmann
  29.         Am Eisteich 9
  30.       72555 Metzingen
  31.         Tel. 07123 / 14881
  32.         Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  33. */
  34.  
  35.  
  36. #ifndef CHAOS_H
  37. #include "chaos.h"
  38. #endif
  39.  
  40. #include <ctype.h>
  41.  
  42.  
  43.  
  44. #ifdef AMIGA
  45. #ifndef AZTEC_C
  46. SAVEDS ASM static ULONG ARexxCmdFunc(REG(a0) struct Hook *hook,
  47.                      REG(a1) char *args[])
  48.  
  49. { extern void MakeDisplay(void);
  50.   extern int EnableARexx;
  51.   extern int NoWindow;
  52.   int result;
  53.   LONG (*func)(char **) = hook->h_SubEntry;
  54.  
  55.   if (!EnableARexx)
  56.   { return(RETURN_ERROR);
  57.   }
  58.   result = (*func)(args);
  59.   if (!NoWindow)
  60.   { MakeDisplay();
  61.   }
  62.   return(result);
  63. }
  64. #else    /*  AZTEC_C */
  65. extern ULONG ARexxCmdFunc(struct Hook *, char **);
  66. #asm
  67.         xref    _geta4
  68.         xref    _EnableARexx
  69.         xref    _MakeDisplay
  70.         xref    _NoWindow
  71. _ARexxCmdFunc:    move.l    a4,-(sp)
  72.         jsr    _geta4
  73.         move.l    #10,d0
  74.         tst.l    _EnableARexx
  75.         bne    ARexxCmdFuncE
  76.         move.l    a1,-(sp)
  77.         move.l    12(a0),a0
  78.         jsr    (a0)
  79.         add.l    #4,sp
  80.         tst.l    _NoWindow
  81.         bne    ARexxCmdFuncE
  82.         move.l    d0,-(sp)
  83.         jsr    _MakeDisplay
  84.         move.l    (sp)+,d0
  85. ARexxCmdFuncE:    move.l    (sp)+,a4
  86.         rts
  87. #endasm
  88. #endif    /*  AZTEC_C */
  89.  
  90.  
  91.  
  92.  
  93. /*
  94.     NewTrnCmd creates a new tournament.
  95.  
  96.     Inputs: NAME  - the new tournament's name
  97.         FORCE - suppress asking the user for confirmation, if current
  98.             tournament isn't saved
  99. */
  100. ULONG NewTrnCmd(char *args[])
  101.  
  102. {
  103.   if (!(ULONG)args[1]  &&  !TestSaved)
  104.   { return(RETURN_WARN);
  105.   }
  106.  
  107.   DeleteTournament(args[0]);
  108.   return(RETURN_OK);
  109. }
  110. struct Hook NewTrnCmdHook = {{NULL, NULL}, ARexxCmdFunc, NewTrnCmd};
  111.  
  112.  
  113.  
  114.  
  115. /*
  116.     LoadTrn loads a tournament
  117.  
  118.     Inputs: FILE  - the name of the file to be loaded
  119.         FORCE - suppress asking the user for confirmation, if current
  120.             tournament isn't saved
  121. */
  122. ULONG LoadTrnCmd(char *args[])
  123.  
  124. {
  125.   if (!(ULONG)args[1]  &&  !TestSaved)
  126.   { return(RETURN_WARN);
  127.   }
  128.  
  129.   return(LoadTournament(args[0], NULL, NULL));
  130. }
  131. struct Hook LoadTrnCmdHook = {{NULL, NULL}, ARexxCmdFunc, LoadTrnCmd};
  132.  
  133.  
  134.  
  135.  
  136. /*
  137.     SaveTrn saves a tournament
  138.  
  139.     Inputs: FILE  - the name of the file to be written
  140.         ICON  - create an icon
  141. */
  142. ULONG SaveTrnCmd(char *args[])
  143.  
  144. { int makeicons = MakeIcons;
  145.   int result;
  146.  
  147.   MakeIcons = (ULONG)args[1];
  148.   result = SaveTournament(args[0]);
  149.   MakeIcons = makeicons;
  150.   return(result ? RETURN_OK : RETURN_ERROR);
  151. }
  152. struct Hook SaveTrnCmdHook = {{NULL, NULL}, ARexxCmdFunc, SaveTrnCmd};
  153.  
  154.  
  155.  
  156.  
  157. /*
  158.     AddPlrCmd adds a new player
  159.  
  160.     Inputs: NAME    - the players name
  161.         STREET, VILLAGE, CHESSCLUB, BIRTHDAY, PHONE, RATING, ELO
  162.             - the corresponding fields in the player structure
  163.         FLAGS   - a string, that may contain the characters
  164.               s,j,w,a,b,c,d,e corresponding to the flags
  165.               TNFLAGSF_SENIOR, TNFLAGSF_JUNIOR, TNFLAGSF_WOMAN
  166.               and TNFLAGSFJUNIORA, ..., TNFLAGSF_JUNIORE
  167.         NOUSER  - a flag which indicates, that the user should not be
  168.               asked
  169. */
  170. static void getstr(char *dest, char *src, int maxlen, ULONG *result)
  171. { int len;
  172.  
  173.   if (src != NULL)
  174.   { len = strlen(src);
  175.  
  176.     if (len > maxlen)
  177.     { *result = RETURN_WARN;
  178.       strncpy(dest, src, maxlen);
  179.       dest[maxlen] = '\0';
  180.     }
  181.     else
  182.     { strcpy(dest, src);
  183.     }
  184.   }
  185. }
  186. static int getflags(char *flagsstr, ULONG *result)
  187. { int flags = 0;
  188.  
  189.   while (flagsstr != NULL  &&  *flagsstr != '\0')
  190.   { switch(tolower((int) *flagsstr++))
  191.     { case 's':
  192.     flags |= TNFLAGSF_SENIOR;
  193.     break;
  194.       case 'j':
  195.     flags |= TNFLAGSF_JUNIOR;
  196.     break;
  197.       case 'w':
  198.     flags |= TNFLAGSF_WOMAN;
  199.     break;
  200.       case 'a':
  201.     flags |= TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORA;
  202.     break;
  203.       case 'b':
  204.     flags |= TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORB;
  205.     break;
  206.       case 'c':
  207.     flags |= TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORC;
  208.     break;
  209.       case 'd':
  210.     flags |= TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORD;
  211.     break;
  212.       case 'e':
  213.     flags |= TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORE;
  214.     break;
  215.       default:
  216.     *result = RETURN_WARN;
  217.     }
  218.     if ((flags & TNFLAGSF_SENIOR)  &&
  219.     (flags & TNFLAGSF_JUNIOR|TNFLAGSF_JUNIORA|TNFLAGSF_JUNIORB|
  220.          TNFLAGSF_JUNIORC|TNFLAGSF_JUNIORD|TNFLAGSF_JUNIORE))
  221.     { *result = RETURN_WARN;
  222.     }
  223.   }
  224.   return(flags);
  225. }
  226. ULONG AddPlrCmd(char *args[])
  227.  
  228. { struct Player plr;
  229.   ULONG result = 0;
  230.  
  231.   /*
  232.       Check, if we may enter new players.
  233.   */
  234.   if (NumRounds >= 1 &&  RoundRobinTournament)
  235.   { return(RETURN_ERROR);
  236.   }
  237.   if (NumRounds > 1  &&  SwissPairingTournament)
  238.   { return(RETURN_ERROR);
  239.   }
  240.   if (NumRounds > 0)
  241.   { if (!args[9]  &&
  242.     !AskContinue((char *) GetChaosString(MSG_NEW_PLAYER_REQUEST)))
  243.     { return(RETURN_ERROR);
  244.     }
  245.   }
  246.  
  247.  
  248.   memset(&plr, 0, sizeof(plr));
  249.   getstr(plr.Name, args[0], NAMELEN, &result);
  250.   if (result != 0)
  251.   { return(RETURN_ERROR);
  252.   }
  253.   getstr(plr.Street, args[1], NAMELEN, &result);
  254.   getstr(plr.Village, args[2], NAMELEN, &result);
  255.   getstr(plr.ChessClub, args[3], NAMELEN, &result);
  256.   getstr(plr.BirthDay, args[4], NAMELEN, &result);
  257.   getstr(plr.PhoneNr, args[5], PHONENRLEN, &result);
  258.   getstr(plr.DWZ, args[6], DWZLEN, &result);
  259.   if (args[7] != NULL)
  260.   { plr.ELO = *((ULONG *) args[7]);
  261.   }
  262.   plr.Flags = getflags(args[8], &result);
  263.  
  264.   if (!CheckPlayerValid(&plr, !args[9]))
  265.   { return(RETURN_ERROR);
  266.   }
  267.  
  268.   if (!AddPlayer(&plr))
  269.   { return(RETURN_ERROR);
  270.   }
  271.   return(result);
  272. }
  273. struct Hook AddPlrCmdHook = {{NULL, NULL}, ARexxCmdFunc, AddPlrCmd};
  274.  
  275.  
  276.  
  277.  
  278. /*
  279.     ModifyPlrCmd modifies a new player
  280.  
  281.     Inputs: PLAYER  - the players name
  282.         NAME, STREET, VILLAGE, CHESSCLUB, BIRTHDAY, PHONE, RATING, ELO
  283.             - the corresponding fields in the player structure
  284.         FLAGS   - a string, that may contain the characters
  285.               s,j,w,a,b,c,d,e corresponding to the flags
  286.               TNFLAGSF_SENIOR, TNFLAGSF_JUNIOR, TNFLAGSF_WOMAN
  287.               and TNFLAGSFJUNIORA, ..., TNFLAGSF_JUNIORE
  288.         NOUSER  - a flag which indicates, that the user should not be
  289.               asked
  290.  
  291.     Note, that only those fields are modified, for which an argument is
  292.     supplied
  293. */
  294. static struct Player *getplayer(char *arg)
  295. { struct Player *plr;
  296.  
  297.   if (arg)
  298.   { for (plr = (struct Player *) PlayerList.lh_Head;
  299.      plr->Tn_Node.ln_Succ != NULL;
  300.      plr = (struct Player *) plr->Tn_Node.ln_Succ)
  301.     { if (Stricmp((STRPTR) plr->Name, (STRPTR) arg)  ==  0)
  302.       { return(plr);
  303.       }
  304.     }
  305.   }
  306.   return(NULL);
  307. }
  308. ULONG ModifyPlrCmd(char *args[])
  309.  
  310. { struct Player plr, *plrptr;
  311.   ULONG result = 0;
  312.  
  313.   /*
  314.       Check, if we really may modify players
  315.   */
  316.   if (!args[10]  &&  NumRounds > 0  &&
  317.       !AskContinue((char *) GetChaosString(MSG_MODIFY_PLAYER_REQUEST)))
  318.   { return(RETURN_ERROR);
  319.   }
  320.  
  321.   if (plrptr = getplayer(args[0]))
  322.   { memcpy(&plr, plrptr, sizeof(plr));
  323.     getstr(plr.Name, args[1], NAMELEN, &result);
  324.     getstr(plr.Street, args[2], NAMELEN, &result);
  325.     getstr(plr.Village, args[3], NAMELEN, &result);
  326.     getstr(plr.ChessClub, args[4], NAMELEN, &result);
  327.     getstr(plr.BirthDay, args[5], NAMELEN, &result);
  328.     getstr(plr.PhoneNr, args[6], PHONENRLEN, &result);
  329.     getstr(plr.DWZ, args[7], DWZLEN, &result);
  330.     if (args[7] != NULL)
  331.     { plr.ELO = *((ULONG *) args[8]);
  332.     }
  333.     plr.Flags = getflags(args[9], &result);
  334.  
  335.     { int result;
  336.  
  337.       Remove((struct Node *) plrptr);
  338.       result = CheckPlayerValid(&plr, !args[10]);
  339.       Insert(&PlayerList, (struct Node *) plrptr,
  340.          (struct Node *) plrptr->Tn_Node.ln_Pred);
  341.       if (!result)
  342.       { return(RETURN_ERROR);
  343.       }
  344.     }
  345.  
  346.     ModifyPlayer(plrptr, &plr);
  347.     return(result);
  348.   }
  349.   return(RETURN_ERROR);
  350. }
  351. struct Hook ModifyPlrCmdHook = {{NULL, NULL}, ARexxCmdFunc, ModifyPlrCmd};
  352.  
  353.  
  354.  
  355.  
  356. /*
  357.     DelPlrCmd deletes a player
  358.  
  359.     Inputs: PLAYER - the players name
  360.         FORCE  - suppresses asking the user for confirmation
  361. */
  362. ULONG DelPlrCmd(char *args[])
  363.  
  364. { struct Player *plrptr;
  365.   ULONG result = 0;
  366.  
  367.   if ((NumRounds > 0  &&  RoundRobinTournament)  ||
  368.       (NumGamesMissing > 0  &&  SwissPairingTournament))
  369.   { return(RETURN_ERROR);
  370.   }
  371.  
  372.   if (plrptr = getplayer(args[0]))
  373.   { if ((plrptr->Flags & TNFLAGSF_WITHDRAWN)  ||
  374.     (!(ULONG)args[1]  &&
  375.      !AskContinue((char *) GetChaosString((NumRounds == 0)  ?
  376.                     MSG_DELETE_THIS_PLAYER_REQUEST    :
  377.                     MSG_THIS_PLAYER_GONE_REQUEST),
  378.               plrptr->Name)))
  379.     { return(RETURN_WARN);
  380.     }
  381.     DeletePlayer(plrptr);
  382.   }
  383.   return(RETURN_ERROR);
  384. }
  385. struct Hook DelPlrCmdHook = {{NULL, NULL}, ARexxCmdFunc, DelPlrCmd};
  386.  
  387.  
  388.  
  389.  
  390. /*
  391.     SetPlrCmd sets a player
  392.  
  393.     Inputs: PLAYER   - the player, that should be set
  394.         INIT     - discard set players
  395.         FORCE    - suppresses asking the user for confirmation, if
  396.                players should be paired, that had the same color
  397.                in the last two rounds
  398.         SETCOLOR - colors are determined by the order of entering the
  399.                players
  400. */
  401. static ULONG SetPlrCmd(char **args)
  402.  
  403. { struct Player *plr;
  404.  
  405.   if (args[1]  &&  !InitSetGames())
  406.     { return(RETURN_ERROR);
  407.     }
  408.   if (!args[0])
  409.   { return (args[1] ? RETURN_OK : RETURN_ERROR);
  410.   }
  411.   if (!(plr = getplayer(args[0])))
  412.   { return(RETURN_ERROR);
  413.   }
  414.   return(SetPlayer(plr, (int) args[2], (int) args[3])  ?
  415.         RETURN_OK  :  RETURN_ERROR);
  416. }
  417. struct Hook SetPlrCmdHook = {{NULL, NULL}, ARexxCmdFunc, SetPlrCmd};
  418.  
  419.  
  420.  
  421.  
  422. /*
  423.     DoPairingsCmd creates a new round
  424.  
  425.     Inputs: SWISSPAIRING    - create a swiss pairing tournament
  426.         ROUNDROBIN        - create a round robin tournament (FIDE system)
  427.         ROUNDROBINSHIFT - create a round robin tournament (shift system)
  428.         NOUSER        - suppresses setting games by the user
  429. */
  430. static ULONG DoPairingsCmd(char *args[])
  431.  
  432. { int mode = TrnMode;
  433.  
  434.   if (args[0])
  435.   { if (RoundRobinTournament  ||  args[1]  ||  args[2])
  436.     { return(RETURN_ERROR);
  437.     }
  438.     else
  439.     { mode = TNMODEF_SWISS_PAIRING;
  440.     }
  441.   }
  442.  
  443.   if (args[1])
  444.   { if ((TrnMode & (TNMODEF_SWISS_PAIRING|TNMODEF_SHIFT_SYSTEM))  ||
  445.     args[2])
  446.     { return(RETURN_ERROR);
  447.     }
  448.     else
  449.     { mode = TNMODEF_ROUND_ROBIN;
  450.     }
  451.   }
  452.  
  453.   if (args[2])
  454.   { if (SwissPairingTournament  ||
  455.     (TrnMode & (TNMODEF_ROUND_ROBIN|TNMODEF_SHIFT_SYSTEM)
  456.             == TNMODEF_ROUND_ROBIN))
  457.     { return(RETURN_ERROR);
  458.     }
  459.     else
  460.     { mode = TNMODEF_ROUND_ROBIN|TNMODEF_SHIFT_SYSTEM;
  461.     }
  462.   }
  463.  
  464.   if (mode == 0)
  465.   { return(RETURN_ERROR);
  466.   }
  467.  
  468.   return(DoPairings(mode, FALSE, !(int) args[3]) ? 0 : RETURN_ERROR);
  469. }
  470. struct Hook DoPairingsCmdHook = {{NULL, NULL}, ARexxCmdFunc, DoPairingsCmd};
  471.  
  472.  
  473.  
  474.  
  475. /*
  476.     RsltCmd allows to enter a result
  477.  
  478.     Inputs: WHITE     - the white players name
  479.         BLACK     - the black players name
  480.         RESULT    - the result (-1 = result missing, 0 = black wins,
  481.             1 = draw, 2 = white wins)
  482.         NOTPLAYED - indicates, that the game wasn't really played
  483. */
  484. ULONG RsltCmd(char *args[])
  485.  
  486. { struct Game *gm;
  487.   struct GameNode gn;
  488.   int round;
  489.  
  490.   if (NumRounds == 0  ||  (ULONG)args[2] < -1  ||  (ULONG)args[2] > 2)
  491.   { return(RETURN_ERROR);
  492.   }
  493.  
  494.   for(gn.White = (struct Player *) PlayerList.lh_Head;
  495.       gn.White->Tn_Node.ln_Succ != NULL;
  496.       gn.White = (struct Player *) gn.White->Tn_Node.ln_Succ)
  497.   { if (Stricmp((STRPTR) gn.White->Name, (STRPTR) args[0])  ==  0)
  498.     { for (gm = gn.White->First_Game, round = 1;  gm != NULL;
  499.        gm = gm->Next, round++)
  500.       { if (Stricmp((STRPTR) gm->Opponent->Name, (STRPTR) args[1])  ==  0)
  501.     { gn.Result = *(ULONG *)args[2];
  502.       gn.Flags = (ULONG)args[3] ? GMFLAGSF_NOFIGHT : 0;
  503.       gn.Black = gm->Opponent;
  504.       EnterResult(&gn, round);
  505.     }
  506.       }
  507.       break;
  508.     }
  509.   }
  510.   return(RETURN_ERROR);
  511. }
  512. struct Hook RsltCmdHook = {{NULL, NULL}, ARexxCmdFunc, RsltCmd};
  513.  
  514.  
  515.  
  516.  
  517. /*
  518.     PlrLstCmd prints the list of players
  519.  
  520.     Inputs: FILE  - the file, which should receive the output
  521.         SHORT - makes the output short
  522. */
  523. static int getdevice(char *devicestr)
  524. { int device = DEVICE_FileAscii;
  525.  
  526.   if (Stricmp((STRPTR) devicestr, (STRPTR) "prt:")  ==  0)
  527.   { device = DEVICE_PrinterDraft;
  528.   }
  529.   else if (Stricmp((STRPTR) devicestr, (STRPTR) "prt:LQ")  ==  0)
  530.   { device = DEVICE_PrinterLQ;
  531.   }
  532.   return(device);
  533. }
  534. ULONG PlrLstCmd(char *args[])
  535.  
  536. { extern int OutputReturnCode;
  537.  
  538.   if (NumPlayers == 0)
  539.   { return(RETURN_ERROR);
  540.   }
  541.  
  542.   OutPlayerList(args[0], getdevice(args[0]), !(ULONG)args[1]);
  543.   return(OutputReturnCode);
  544. }
  545. struct Hook PlrLstCmdHook = {{NULL, NULL}, ARexxCmdFunc, PlrLstCmd};
  546.  
  547.  
  548.  
  549.  
  550. /*
  551.     IntRatCmd prints the internal rankings.
  552.  
  553.     Inputs: FILE  - the file, which should receive the output
  554. */
  555. ULONG IntRatCmd(char *args[])
  556.  
  557. { extern int OutputReturnCode;
  558.  
  559.   if (NumPlayers == 0)
  560.   { return(RETURN_ERROR);
  561.   }
  562.  
  563.   OutInternalRankings(args[0], getdevice(args[0]));
  564.   return(OutputReturnCode);
  565. }
  566. struct Hook IntRatCmdHook = {{NULL, NULL}, ARexxCmdFunc, IntRatCmd};
  567.  
  568.  
  569.  
  570.  
  571. /*
  572.     TblCmd prints the table.
  573.  
  574.     Inputs: FILE    - the file, which should receive the output
  575.         TABMODE - the table's sorting mode (0 = simple, 1 = Buchholz,
  576.               2 = Extended Buchholz, 3 = Sonneborn-Berger)
  577.               default is simple
  578.         PLRMODE - the code, which players should be included into the
  579.               table (0 = all, 1 = seniors, 2 = juniors, 3 = women,
  580.               4 = juniors (A), 5 = juniors (B), 6 = juniors (C),
  581.               7 = juniors (D), 8 = juniors (E))
  582.               default is all players
  583. */
  584. int gettabmode(ULONG *mode)
  585. { int tabmode = 0;
  586.  
  587.   if (mode != NULL)
  588.   { switch(*mode)
  589.     { case 0:
  590.     break;
  591.       case 1:
  592.     if (RoundRobinTournament)
  593.     { return(-1);
  594.     }
  595.     tabmode = TNMODEF_BUCHHOLZ;
  596.     break;
  597.       case 2:
  598.     if (RoundRobinTournament)
  599.     { return(-1);
  600.     }
  601.     tabmode = TNMODEF_EXT_BUCHHOLZ;
  602.     break;
  603.       case 3:
  604.     if (!SwissPairingTournament)
  605.     { tabmode = TNMODEF_SONNEBORN_BERGER;
  606.       break;
  607.     }
  608.       default:
  609.     return(-1);
  610.     }
  611.   }
  612.   return(tabmode);
  613. }
  614. ULONG TblCmd(char *args[])
  615.  
  616. { extern int OutputReturnCode;
  617.   int plrmode = 0;
  618.   int tabmode;
  619.  
  620.   if (NumRounds == 0)
  621.   { return(RETURN_ERROR);
  622.   }
  623.  
  624.   if ((tabmode = gettabmode((ULONG *) args[1]))  == -1)
  625.   { return(RETURN_ERROR);
  626.   }
  627.  
  628.   if (args[2])
  629.   { switch(*(ULONG *)args[2])
  630.     { case 0:
  631.     break;
  632.       case 1:
  633.     plrmode = TNFLAGSF_SENIOR;
  634.     break;
  635.       case 2:
  636.     plrmode = TNFLAGSF_JUNIOR;
  637.     break;
  638.       case 3:
  639.     plrmode = TNFLAGSF_WOMAN;
  640.     break;
  641.       case 4:
  642.     plrmode = TNFLAGSF_JUNIORA;
  643.     break;
  644.       case 5:
  645.     plrmode = TNFLAGSF_JUNIORB;
  646.     break;
  647.       case 6:
  648.     plrmode = TNFLAGSF_JUNIORC;
  649.     break;
  650.       case 7:
  651.     plrmode = TNFLAGSF_JUNIORD;
  652.     break;
  653.       case 8:
  654.     plrmode = TNFLAGSF_JUNIORE;
  655.     break;
  656.       default:
  657.     return(RETURN_ERROR);
  658.     }
  659.   }
  660.  
  661.   OutTable(args[0], getdevice(args[0]), plrmode, tabmode);
  662.   return(OutputReturnCode);
  663. }
  664. struct Hook TblCmdHook = {{NULL, NULL}, ARexxCmdFunc, TblCmd};
  665.  
  666.  
  667.  
  668.  
  669. /*
  670.     RndCmd prints the results of one round
  671.  
  672.     Inputs: FILE  - the file, which should receive the output
  673.         ROUND - the number of the round (default is the last round)
  674. */
  675. ULONG RndCmd(char *args[])
  676.  
  677. { extern int OutputReturnCode;
  678.   int round;
  679.  
  680.  
  681.   if ((round = NumRounds) == 0)
  682.   { return(RETURN_ERROR);
  683.   }
  684.  
  685.   if (args[1]  &&
  686.       ((round = *(ULONG *)args[1]) <= 0  ||  round > NumRounds))
  687.   { return(RETURN_ERROR);
  688.   }
  689.  
  690.   OutRound(args[0], getdevice(args[0]), round);
  691.   return(OutputReturnCode);
  692. }
  693. struct Hook RndCmdHook = {{NULL, NULL}, ARexxCmdFunc, RndCmd};
  694.  
  695.  
  696.  
  697.  
  698. /*
  699.     TblPrgrssCmd prints the table of progress
  700.  
  701.     Inputs: FILE    - the file, which should receive the output
  702.         TABMODE - the table's sorting mode (see TblCmd)
  703. */
  704. ULONG TblPrgrssCmd(char *args[])
  705.  
  706. { extern int OutputReturnCode;
  707.   int tabmode = 0;
  708.  
  709.   if (NumRounds == 0)
  710.   { return(RETURN_ERROR);
  711.   }
  712.  
  713.   if ((tabmode = gettabmode((ULONG *) args[1]))  == -1)
  714.   { return(RETURN_ERROR);
  715.   }
  716.  
  717.   OutTableProgress(args[0], getdevice(args[0]), tabmode);
  718.   return(OutputReturnCode);
  719. }
  720. struct Hook TblPrgrssCmdHook = {{NULL, NULL}, ARexxCmdFunc, TblPrgrssCmd};
  721.  
  722.  
  723.  
  724.  
  725. /*
  726.     CrossTableCmd prints a crosstable
  727.  
  728.     Inputs: FILE - the file, which should receive the output
  729.         TEX  - creates tex source
  730. */
  731. ULONG CrssTblCmd(char *args[])
  732.  
  733. { int device = getdevice(args[0]);
  734.  
  735.   if (!RoundRobinTournament)
  736.   { return (RETURN_ERROR);
  737.   }
  738.   if (args[1])
  739.   { device = DEVICE_FileTeX;
  740.   }
  741.  
  742.   OutCrossTable(args[0], device);
  743.   return(OutputReturnCode);
  744. }
  745. struct Hook CrssTblCmdHook = {{NULL, NULL}, ARexxCmdFunc, CrssTblCmd};
  746.  
  747.  
  748.  
  749.  
  750. /*
  751.     PlrCrdsCmd prints player cards
  752.  
  753.     Inputs: FILE - the file, which should receive the output
  754.         TEX  - creates tex source
  755. */
  756. ULONG PlrCrdsCmd(char *args[])
  757.  
  758. { int device = getdevice(args[0]);
  759.  
  760.   if (!SwissPairingTournament)
  761.   { return(RETURN_ERROR);
  762.   }
  763.   if (args[1])
  764.   { device = DEVICE_FileTeX;
  765.   }
  766.  
  767.   OutPlayerCards(args[0], device);
  768.   return(OutputReturnCode);
  769. }
  770. struct Hook PlrCrdsCmdHook = {{NULL, NULL}, ARexxCmdFunc, PlrCrdsCmd};
  771.  
  772.  
  773.  
  774.  
  775. /*
  776.     DWZRprtCmd prints the DWZ report
  777.  
  778.     Inputs: FILE - the file, which should receive the output
  779. */
  780. ULONG DWZRprtCmd(char *args[])
  781.  
  782. {
  783.   if (NumRounds == 0)
  784.   { return(RETURN_ERROR);
  785.   }
  786.  
  787.   OutDWZReport(args[0], getdevice(args[0]));
  788.   return(OutputReturnCode);
  789. }
  790. struct Hook DWZRprtCmdHook = {{NULL, NULL}, ARexxCmdFunc, DWZRprtCmd};
  791.  
  792.  
  793.  
  794.  
  795. /*
  796.     WindowCmd switches the main window on or off
  797.  
  798.     Inputs: ON    - switch the window on
  799.         OFF - switch it off
  800. */
  801. ULONG WindowCmd(char *args[])
  802.  
  803. { extern int NoWindow;
  804.   int open;
  805.  
  806.   if (args[0] == args[1])
  807.   { return(RETURN_ERROR);
  808.   }
  809.   NoWindow = (int) args[1];
  810.   get(MainWnd, MUIA_Window_Open, &open);
  811.   if (!open != NoWindow)
  812.   { set(MainWnd, MUIA_Window_Open, !open);
  813.   }
  814.   return(RETURN_OK);
  815. }
  816. struct Hook WindowCmdHook = {{NULL, NULL}, ARexxCmdFunc, WindowCmd};
  817.  
  818.  
  819.  
  820. struct MUI_Command ARexxCommands[] =
  821.   { {"NewTournament",   "NAME/A,FORCE/S",   2,  &NewTrnCmdHook},
  822.     {"LoadTournament",  "FILE/A,FORCE/S",   2,  &LoadTrnCmdHook},
  823.     {"SaveTournament",  "FILE/A,ICON/S",    1,  &SaveTrnCmdHook},
  824.     {"AddPlayer",       "NAME/A,STREET/K,VILLAGE/K,CHESSCLUB/K,BIRTHDAY/K,"
  825.             "PHONE/K,RATING/K,ELO/K/N,FLAGS/K,NOUSER/S",
  826.                         9,    &AddPlrCmdHook},
  827.     {"ModifyPlayer",    "PLAYER/A,NAME/K,STREET/K,VILLAGE/K,CHESSCLUB/K,"
  828.             "BIRTHDAY/K,PHONE/K,RATING/K,ELO/K,FLAGS/K,NOUSER/S,",
  829.                         10, &ModifyPlrCmdHook},
  830.     {"DeletePlayer",    "PLAYER/A,FORCE/S", 2,  &DelPlrCmdHook},
  831.     {"SetPlayer",       "PLAYER,INIT/S,FORCE/S,SETCOLOR/S",
  832.                         3,    &SetPlrCmdHook},
  833.     {"DoPairings",      "SWISSPAIRING/S,ROUNDROBIN/S,ROUNDROBINSHIFT/S,"
  834.             "NOUSER/S",         4,  &DoPairingsCmdHook},
  835.     {"EnterResult",     "WHITE/A,BLACK/A,RESULT/A/N,NOTPLAYED/S",
  836.                         4,    &RsltCmdHook},
  837.     {"PlayerList",      "FILE/A,SHORT/S",   3,  &PlrLstCmdHook},
  838.     {"InternalRatings", "FILE/A",           1,  &IntRatCmdHook},
  839.     {"Table",           "FILE/A,TABMODE/K/N,PLRMODE/K/N",
  840.                         3,    &TblCmdHook},
  841.     {"Round",           "FILE/A,NUMBER/N",  2,  &RndCmdHook},
  842.     {"TableOfProgress", "FILE/A,TABMODE/K/N",
  843.                         2,    &TblPrgrssCmdHook},
  844.     {"CrossTable",      "FILE/A,TEX/S",     2,  &CrssTblCmdHook},
  845.     {"PlayerCards",     "FILE/A,TEX/S",     2,  &PlrCrdsCmdHook},
  846.     {"DWZReport",       "FILE/A",           1,  &DWZRprtCmdHook},
  847.     {"Window",          "ON/S,OFF/S",       2,  &WindowCmdHook},
  848.     {NULL,        NULL,            0,    NULL}
  849.   };
  850. #endif    /*  AMIGA   */
  851.