home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 500-599 / ff589.lza / Term / TermSrc.lha / termRexx.c < prev    next >
C/C++ Source or Header  |  1991-12-01  |  58KB  |  3,565 lines

  1. /* $Revision Header * Header built automatically - do not edit! *************
  2.  *
  3.  *    (C) Copyright 1991 by Olaf 'Olsen' Barthel & MXM
  4.  *
  5.  *    Name .....: TermRexx.c
  6.  *    Created ..: Monday 21-Jan-91 20:12
  7.  *    Revision .: 2
  8.  *
  9.  *    Date            Author          Comment
  10.  *    =========       ========        ====================
  11.  *    24-Mar-91       Olsen           Added some more commands.
  12.  *    26-Jan-91       Olsen           Added asynchronous RexxMsg parsing.
  13.  *    21-Jan-91       Olsen           Created this file!
  14.  *
  15.  * $Revision Header ********************************************************/
  16.  
  17. #include "TermGlobal.h"
  18.  
  19.     /* This module contains the ARexx support code I had adapted some
  20.      * time ago for rexxhost.library.
  21.      */
  22.  
  23. struct RexxMsg    *CreateRexxMsg(struct MsgPort *,STRPTR,STRPTR);
  24. VOID         DeleteRexxMsg(struct RexxMsg *);
  25. STRPTR         CreateArgstring(STRPTR,LONG);
  26. VOID         DeleteArgstring(STRPTR);
  27.  
  28. #pragma libcall RexxSysBase CreateArgstring 7e 802
  29. #pragma libcall RexxSysBase DeleteArgstring 84 801
  30. #pragma libcall RexxSysBase CreateRexxMsg 90 9803
  31. #pragma libcall RexxSysBase DeleteRexxMsg 96 801
  32.  
  33.     /* The rexx server commands are contained in lists in which
  34.      * each command name and the approriate routine is
  35.      * stored. The following three structure definitions
  36.      * are required to set up the list properly.
  37.      */
  38.  
  39. struct QueryStruct
  40. {
  41.     UBYTE    *String;
  42.     UBYTE *    (*Routine)(VOID);
  43. };
  44.  
  45. struct ASyncCommandStruct
  46. {
  47.     UBYTE    *String;
  48.     VOID    (*Routine)(VOID);
  49. };
  50.  
  51. struct CommandStruct
  52. {
  53.     UBYTE    *String;
  54.     UBYTE *    (*Routine)(UBYTE *);
  55. };
  56.  
  57.     /* Global rexx output buffer. */
  58.  
  59. STATIC UBYTE RexxTextBuffer[256];
  60.  
  61.     /* This structure defines a relation between a time unit
  62.      * (microseconds, seconds, minutes) and a string key.
  63.      */
  64.  
  65. struct TimeRel
  66. {
  67.     UBYTE    *Key;
  68.     LONG     Multi;
  69. };
  70.  
  71.     /* Relations between qualifying keywords and time multipliers. */
  72.  
  73. #define NUMTIMEREL 9
  74.  
  75. STATIC struct TimeRel TimeRelations[NUMTIMEREL] =
  76. {
  77.     "MIC",        1,
  78.     "SEC",        MILLION,
  79.     "MIN",        MILLION * 60,
  80.  
  81.     "MICROSECONDS",    1,
  82.     "SECONDS",    MILLION,
  83.     "MINUTES",    MILLION * 60,
  84.  
  85.     "MICROS",    1,
  86.     "SECS",        MILLION,
  87.     "MINS",        MILLION * 60
  88. };
  89.  
  90.     /* Asynchronous commands which can be executed by the
  91.      * rexx server process itself and do not require the
  92.      * term main process to take any action.
  93.      */
  94.  
  95. #define NUMASYNCS 9
  96.  
  97. STATIC struct ASyncCommandStruct ASyncCommands[NUMASYNCS] =
  98. {
  99.     "TERM2FRONT",        (APTR)Term2Front,
  100.     "DEFAULT2FRONT",    (APTR)BumpDefault,
  101.     "WB2FRONT",        (APTR)WBenchToFront,
  102.     "REXX2FRONT",        (APTR)Rexx2Front,
  103.     "DISPLAY2FRONT",    (APTR)Display2Front,
  104.     "CLOSEDISPLAY",        (APTR)CloseDisplay,
  105.     "CLEARDISPLAY",        (APTR)ClearBuffer,
  106.     "CLEARDOWNLOADLIST",    (APTR)ClearDownloadObjects,
  107.     "QUIETEXIT",        (APTR)QuietExit
  108. };
  109.  
  110.     /* Query commands which return miscellaneous system
  111.      * information (these routines are handled asynchronously
  112.      * as well).
  113.      */
  114.  
  115. #define NUMQUERIES 81
  116.  
  117. STATIC struct QueryStruct QueryCommands[NUMQUERIES] =
  118. {
  119.     "BAUDRATE",        (APTR)QueryBaud,
  120.     "BITSPERCHAR",        (APTR)QueryDataBits,
  121.     "PARITY",        (APTR)QueryParity,
  122.     "STOPBITS",        (APTR)QueryStopBits,
  123.     "HANDSHAKING",        (APTR)QueryHandshaking,
  124.     "DUPLEX",        (APTR)QueryDuplex,
  125.     "HIGHSPEED",        (APTR)QueryHighspeed,
  126.     "BREAKLENGTH",        (APTR)QueryBreakLength,
  127.     "SERIALDEVICE",        (APTR)QuerySerialDevice,
  128.     "UNITNUMBER",        (APTR)QueryUnitNumber,
  129.     "MODEMINIT",        (APTR)QueryModemInit,
  130.     "MODEMEXIT",        (APTR)QueryModemExit,
  131.     "DIALPREFIX",        (APTR)QueryDialPrefix,
  132.     "REDIALDELAY",        (APTR)QueryRedialDelay,
  133.     "DIALRETRIES",        (APTR)QueryDialRetries,
  134.     "DIALTIMEOUT",        (APTR)QueryDialTimeout,
  135.     "CONNECTAUTOBAUD",    (APTR)QueryConnectAutoBaud,
  136.     "NOCARRIER",        (APTR)QueryNoCarrier,
  137.     "CONNECT",        (APTR)QueryConnect,
  138.     "VOICE",        (APTR)QueryVoice,
  139.     "RING",            (APTR)QueryRing,
  140.     "BUSY",            (APTR)QueryBusy,
  141.     "PROTOCOL",        (APTR)QueryProtocol,
  142.     "PROTOCOLOPTIONS",    (APTR)QueryProtocolOptions,
  143.     "MACROFILE",        (APTR)QueryMacroFile,
  144.     "DISPLAYMODE",        (APTR)QueryDisplay,
  145.     "PUBLICSCREEN",        (APTR)QueryPublicScreen,
  146.     "SHANGHAI",        (APTR)QueryShanghai,
  147.     "CAPTUREFILTER",    (APTR)QueryCaptureFilter,
  148.     "DSBACKSPACE",        (APTR)QueryDSBackSpace,
  149.     "AUDBELL",        (APTR)QueryAudBell,
  150.     "VISBELL",        (APTR)QueryVisBell,
  151.     "EIGHTYCOLUMNS",    (APTR)QueryEightyColumns,
  152.     "SENDCR",        (APTR)QuerySendCR,
  153.     "SENDLF",        (APTR)QuerySendLF,
  154.     "COLOURMODE",        (APTR)QueryColourMode,
  155.     "COLORMODE",        (APTR)QueryColourMode,
  156.     "EMULATION",        (APTR)QueryEmulation,
  157.     "FONT",            (APTR)QueryFont,
  158.     "STATUS",        (APTR)QueryStatus,
  159.     "SERIAL",        (APTR)QuerySerial,
  160.     "STARTUP",        (APTR)QueryStartup,
  161.     "REQUESTERS",        (APTR)QueryRequesters,
  162.     "TIMEOUT",        (APTR)QueryTimeout,
  163.     "LINE",            (APTR)QueryLine,
  164.     "COLUMNS",        (APTR)QueryColumns,
  165.     "LINES",        (APTR)QueryLines,
  166.     "CURSOR",        (APTR)QueryCursor,
  167.  
  168.     /* Added in revision 1.6 */
  169.  
  170.     "MODEMHANGUP",        (APTR)QueryModemHangup,
  171.     "AUTOCAPTURE",        (APTR)QueryAutoCapture,
  172.     "LOGACTIONS",        (APTR)QueryLogActions,
  173.     "BLINKING",        (APTR)QueryBlinking,
  174.     "CURSORMODE",        (APTR)QueryCursorMode,
  175.     "FONTSCALE",        (APTR)QueryFontScale,
  176.     "SMOOTHSCROLL",        (APTR)QueryJumpScroll,
  177.     "CHARACTERWRAP",    (APTR)QueryCharacterWrap,
  178.     "CURSORWRAP",        (APTR)QueryCursorWrap,
  179.     "NEWLINEMODE",        (APTR)QueryNewLine,
  180.     "INSERTMODE",        (APTR)QueryInsert,
  181.     "NUMERICMODE",        (APTR)QueryNumeric,
  182.     "DEFAULTSTORE",        (APTR)QueryDefaultStore,
  183.     "TUPLOADPATH",        (APTR)QueryTUploadPath,
  184.     "TDOWNLOADPATH",    (APTR)QueryTDownloadPath,
  185.     "AUPLOADPATH",        (APTR)QueryAUploadPath,
  186.     "ADOWNLOADPATH",    (APTR)QueryADownloadPath,
  187.     "BUPLOADPATH",        (APTR)QueryBUploadPath,
  188.     "BDOWNLOADPATH",    (APTR)QueryBDownloadPath,
  189.     "CAPTUREPATH",        (APTR)QueryCapturePath,
  190.     "LOGFILE",        (APTR)QueryLogFile,
  191.     "EDITOR",        (APTR)QueryEditor,
  192.     "BEEPSOUND",        (APTR)QueryBeepSound,
  193.     "CAPTURESTATE",        (APTR)QueryCaptureState,
  194.     "DOWNLOADS",        (APTR)QueryDownloads,
  195.  
  196.     /* Added in revision 1.8b */
  197.  
  198.     "SPEECHFILE",        (APTR)QuerySpeechFile,
  199.     "SCREENADDRESS",    (APTR)QueryScreenAddress,
  200.     "SPEECHRATE",        (APTR)QuerySpeechRate,
  201.     "SPEECHPITCH",        (APTR)QuerySpeechPitch,
  202.     "SPEECHFREQUENCY",    (APTR)QuerySpeechFrequency,
  203.     "SPEECHVOLUME",        (APTR)QuerySpeechVolume,
  204.     "SPEECHSEX",        (APTR)QuerySpeechSex,
  205.     "SPEECH",        (APTR)QuerySpeech
  206. };
  207.  
  208.     /* Any options which are to be set using the `SET' command
  209.      * are stored in the following list (these commands are
  210.      * handled synchronously).
  211.      */
  212.  
  213. #define NUMSETS        71
  214.  
  215.     /* How many set commands require more parameters? */
  216.  
  217. #define SETMOREPARAMS    6
  218.  
  219. STATIC struct CommandStruct SetCommands[NUMSETS] =
  220. {
  221.     /* The first five commands require more than
  222.      * one calling parameter and are handled
  223.      * differently (as compared to the other
  224.      * set commands).
  225.      */
  226.  
  227.     "MACRO",        (APTR)RexxSetMacro,
  228.     "COLOUR",        (APTR)RexxSetColour,
  229.     "COLOR",        (APTR)RexxSetColour,
  230.     "SCREEN",        (APTR)RexxSetScreen,
  231.     "BELL",            (APTR)RexxSetBell,
  232.     "TIMEOUT",        (APTR)RexxSetTimeout,
  233.  
  234.     "BAUDRATE",        (APTR)RexxSetBaud,
  235.     "BITSPERCHAR",        (APTR)RexxSetDataBits,
  236.     "PARITY",        (APTR)RexxSetParity,
  237.     "STOPBITS",        (APTR)RexxSetStopBits,
  238.     "HANDSHAKING",        (APTR)RexxSetHandshaking,
  239.     "DUPLEX",        (APTR)RexxSetDuplex,
  240.     "HIGHSPEED",        (APTR)RexxSetHighSpeed,
  241.     "BREAKLENGTH",        (APTR)RexxSetBreakLength,
  242.     "SERIALDEVICE",        (APTR)RexxSetSerialDevice,
  243.     "UNITNUMBER",        (APTR)RexxSetUnitNumber,
  244.     "MODEMINIT",        (APTR)RexxSetModemInit,
  245.     "MODEMEXIT",        (APTR)RexxSetModemExit,
  246.     "DIALPREFIX",        (APTR)RexxSetDialPrefix,
  247.     "REDIALDELAY",        (APTR)RexxSetRedialDelay,
  248.     "DIALRETRIES",        (APTR)RexxSetDialRetries,
  249.     "DIALTIMEOUT",        (APTR)RexxSetDialTimeout,
  250.     "CONNECTAUTOBAUD",    (APTR)RexxSetConnectAutoBaud,
  251.     "NOCARRIER",        (APTR)RexxSetNoCarrier,
  252.     "CONNECT",        (APTR)RexxSetConnect,
  253.     "VOICE",        (APTR)RexxSetVoice,
  254.     "RING",            (APTR)RexxSetRing,
  255.     "BUSY",            (APTR)RexxSetBusy,
  256.     "SCREENMODE",        (APTR)RexxSetScreenMode,
  257.     "FILTER",        (APTR)RexxSetFilter,
  258.     "BACKSPACE",        (APTR)RexxSetBackspace,
  259.     "CR",            (APTR)RexxSetCR,
  260.     "LF",            (APTR)RexxSetLF,
  261.     "EIGHTYCOLUMNS",    (APTR)RexxSet80Columns,
  262.     "COLOURMODE",        (APTR)RexxSetColourMode,
  263.     "COLORMODE",        (APTR)RexxSetColourMode,
  264.     "EMULATION",        (APTR)RexxSetEmulation,
  265.     "FONT",            (APTR)RexxSetFont,
  266.     "STARTUP",        (APTR)RexxSetStartup,
  267.     "PROTOCOL",        (APTR)RexxSetProtocol,
  268.     "PROTOCOLOPTIONS",    (APTR)RexxSetProtocolOptions,
  269.     "REQUESTERS",        (APTR)RexxSetRequesters,
  270.     "SERIAL",        (APTR)RexxSetSerial,
  271.  
  272.     /* Added in revision 1.6 */
  273.  
  274.     "MODEMHANGUP",        (APTR)RexxSetModemHangup,
  275.     "AUTOCAPTURE",        (APTR)RexxSetAutoCapture,
  276.     "LOGACTIONS",        (APTR)RexxSetLogActions,
  277.     "BLINKING",        (APTR)RexxSetBlinking,
  278.     "CURSORMODE",        (APTR)RexxSetCursorMode,
  279.     "FONTSCALE",        (APTR)RexxSetFontScale,
  280.     "SMOOTHSCROLL",        (APTR)RexxSetJumpScroll,
  281.     "CHARACTERWRAP",    (APTR)RexxSetCharacterWrap,
  282.     "CURSORWRAP",        (APTR)RexxSetCursorWrap,
  283.     "NEWLINEMODE",        (APTR)RexxSetNewLine,
  284.     "INSERTMODE",        (APTR)RexxSetInsert,
  285.     "NUMERICMODE",        (APTR)RexxSetNumeric,
  286.     "DEFAULTSTORE",        (APTR)RexxSetDefaultStore,
  287.     "TUPLOADPATH",        (APTR)RexxSetTUploadPath,
  288.     "TDOWNLOADPATH",    (APTR)RexxSetTDownloadPath,
  289.     "AUPLOADPATH",        (APTR)RexxSetAUploadPath,
  290.     "ADOWNLOADPATH",    (APTR)RexxSetADownloadPath,
  291.     "BUPLOADPATH",        (APTR)RexxSetBUploadPath,
  292.     "BDOWNLOADPATH",    (APTR)RexxSetBDownloadPath,
  293.     "CAPTUREPATH",        (APTR)RexxSetCapturePath,
  294.     "LOGFILE",        (APTR)RexxSetLogFile,
  295.     "EDITOR",        (APTR)RexxSetEditor,
  296.  
  297.     /* Added in revision 1.8b */
  298.  
  299.     "SPEECHRATE",        (APTR)RexxSetSpeechRate,
  300.     "SPEECHPITCH",        (APTR)RexxSetSpeechPitch,
  301.     "SPEECHFREQUENCY",    (APTR)RexxSetSpeechFrequency,
  302.     "SPEECHVOLUME",        (APTR)RexxSetSpeechVolume,
  303.     "SPEECHSEX",        (APTR)RexxSetSpeechSex,
  304.     "SPEECH",        (APTR)RexxSetSpeech
  305. };
  306.  
  307.     /* The following list contains only synchronous commands
  308.      * the rexx server passes to the term main process.
  309.      */
  310.  
  311. #define NUMREXX        35
  312.  
  313.     /* How many commands require more parameters. */
  314.  
  315. #define REXXMOREPARAMS    8
  316.  
  317. struct CommandStruct RexxCommands[NUMREXX] =
  318. {
  319.     /* The first five commands require more than
  320.      * one calling parameter.
  321.      */
  322.  
  323.     "BUFFER",        (APTR)RexxBuffer,
  324.     "CAPTURE",        (APTR)RexxCapture,
  325.     "CONFIG",        (APTR)RexxConfig,
  326.     "MACROS",        (APTR)RexxMacros,
  327.     "SPEECH",        (APTR)RexxSpeech,
  328.     "PHONE",        (APTR)RexxPhone,
  329.     "DELAY",        (APTR)RexxDelay,
  330.     "WAITSTRING",        (APTR)RexxWaitString,
  331.  
  332.     "PRINTER",        (APTR)RexxPrinter,
  333.     "BEEP",            (APTR)DoSomeBeep,
  334.     "BREAK",        (APTR)RexxBreak,
  335.     "BUPLOAD",        (APTR)RexxBUpload,
  336.     "BDOWNLOAD",        (APTR)RexxBDownload,
  337.     "CLEARSCREEN",        (APTR)RexxClearScreen,
  338.     "COMMAND",        (APTR)RexxCommand,
  339.     "DIAL",            (APTR)RexxDial,
  340.     "GETSTRING",        (APTR)RexxGetString,
  341.     "HANGUP",        (APTR)RexxHangUp,
  342.     "INPUT",        (APTR)RexxInput,
  343.     "MESSAGE",        (APTR)RexxMessage,
  344.     "RESETSTYLES",        (APTR)RexxResetStyles,
  345.     "SAVEILBM",        (APTR)RexxSaveILBM,
  346.     "TUPLOAD",        (APTR)RexxTUpload,
  347.     "TDOWNLOAD",        (APTR)RexxTDownload,
  348.     "WRITE",        (APTR)RexxWrite,
  349.     "PUTCLIP",        (APTR)RexxPutClip,
  350.     "GETCLIP",        (APTR)RexxGetClip,
  351.  
  352.     /* Added in revision 1.6 */
  353.  
  354.     "FIRSTDOWNLOAD",    (APTR)RexxFirstDownload,
  355.     "NEXTDOWNLOAD",        (APTR)RexxNextDownload,
  356.     "LASTDOWNLOAD",        (APTR)RexxLastDownload,
  357.  
  358.     /* Added in revision 1.8a */
  359.  
  360.     "TONEDIAL",        (APTR)RexxToneDial,
  361.  
  362.     /* Added in revision 1.8b */
  363.  
  364.     "SIMPLEREQUEST",    (APTR)RexxSimpleRequest,
  365.     "TWOGADREQUEST",    (APTR)RexxTwoGadRequest,
  366.     "FILEREQUEST",        (APTR)RexxFileRequest,
  367.  
  368.     "SPEAK",        (APTR)RexxSpeak
  369. };
  370.  
  371.     /* A global error code and a global input timeout. */
  372.  
  373. STATIC LONG RexxRes1,RexxGlobalTimeout;
  374.  
  375.     /* The names of the 16 display mode IDs in abbreviated
  376.      * form.
  377.      */
  378.  
  379. STATIC UBYTE *ConfigDisplayNames[16] =
  380. {
  381.     "HIRES",
  382.     "HIRESLACE",
  383.     "SUPERHIRES",
  384.     "SUPERHIRESLACE",
  385.     "PRODUCT",
  386.     "PRODUCTLACE",
  387.  
  388.     "PALHIRES",
  389.     "PALHIRESLACE",
  390.     "PALSUPERHIRES",
  391.     "PALSUPERHIRESLACE",
  392.  
  393.     "NTSCHIRES",
  394.     "NTSCHIRESLACE",
  395.     "NTSCSUPERHIRES",
  396.     "NTSCSUPERHIRESLACE",
  397.  
  398.     "A2024TENHZ",
  399.     "A2024FIFTEENHZ"
  400. };
  401.  
  402.     /* The global duplex modes in abbreviated form. */
  403.  
  404. STATIC UBYTE *ConfigDuplex[2] =
  405. {
  406.     "FULL",
  407.     "HALF"
  408. };
  409.  
  410.     /* The global handshake modes in abbreviated form. */
  411.  
  412. STATIC UBYTE *ConfigHandshaking[3] =
  413. {
  414.     "XONOFF",
  415.     "RTSCTS",
  416.     "NONE"
  417. };
  418.  
  419.     /* The global fonts in abbreviated form. */
  420.  
  421. STATIC UBYTE *ConfigFont[2] =
  422. {
  423.     "TOPAZ",
  424.     "IBM"
  425. };
  426.  
  427.     /* The global colour modes in abbreviated form. */
  428.  
  429. STATIC UBYTE *ConfigColour[4] =
  430. {
  431.     "AMIGA",
  432.     "EIGHT",
  433.     "SIXTEEN",
  434.     "MONO"
  435. };
  436.  
  437.     /* The emulation types in abbreviated form. */
  438.  
  439. STATIC UBYTE *ConfigEmulation[3] =
  440. {
  441.     "ANSIVT",
  442.     "ATOMIC",
  443.     "TTY"
  444. };
  445.  
  446.     /* The global parity settings in abbreviated form. */
  447.  
  448. STATIC UBYTE *ConfigParity[5] =
  449. {
  450.     "NONE",
  451.     "EVEN",
  452.     "ODD",
  453.     "MARK",
  454.     "SPACE"
  455. };
  456.  
  457.     /* The global term status modes in abbreviated form. */
  458.  
  459. STATIC UBYTE *ConfigStatus[7] =
  460. {
  461.     "READY",
  462.     "HOLDING",
  463.     "DIALING",
  464.     "UPLOAD",
  465.     "DOWNLOAD",
  466.     "BREAKING",
  467.     "HANGUP"
  468. };
  469.  
  470.     /* Two boolean identifiers. */
  471.  
  472. STATIC UBYTE *Booleans[2] =
  473. {
  474.     "OFF",
  475.     "ON"
  476. };
  477.  
  478. STATIC UBYTE *KeyModes[2] =
  479. {
  480.     "STANDARD",
  481.     "APPLICATION"
  482. };
  483.  
  484. STATIC UBYTE *FontSizes[5] =
  485. {
  486.     "NORMAL",
  487.     "HIGHTOP",
  488.     "HIGHBOTTOM",
  489.     "WIDE",
  490.     "HALF"
  491. };
  492.  
  493. STATIC UBYTE *Qualifiers[4] =
  494. {
  495.     "NONE",
  496.     "SHIFT",
  497.     "ALTERNATE",
  498.     "CONTROL"
  499. };
  500.  
  501.     /* SendRexxCommand():
  502.      *
  503.      *    Post a command to an ARexx port.
  504.      */
  505.  
  506. BYTE
  507. SendRexxCommand(struct MsgPort *HostPort,STRPTR CommandString,STRPTR FileExtension,STRPTR HostName)
  508. {
  509.     struct MsgPort    *RexxPort = (struct MsgPort *)FindPort(RXSDIR);
  510.     struct RexxMsg    *HostMessage;
  511.  
  512.     if(RexxPort)
  513.     {
  514.         if(!HostName)
  515.             HostName = (STRPTR)"";
  516.  
  517.         if(!FileExtension)
  518.             FileExtension = (STRPTR)"";
  519.  
  520.         if(HostMessage = CreateRexxMsg((struct MsgPort *)HostPort,FileExtension,HostName))
  521.         {
  522.             if(HostMessage -> rm_Args[0] = CreateArgstring(CommandString,strlen(CommandString)))
  523.             {
  524.                 HostMessage -> rm_Action = RXCOMM;
  525.  
  526.                 PutMsg(RexxPort,HostMessage);
  527.  
  528.                 return(TRUE);
  529.             }
  530.  
  531.             DeleteRexxMsg(HostMessage);
  532.         }
  533.  
  534.         MyEasyRequest(Window,"`term' has a problem:\nCouldn't send rexx message!","Continue");
  535.  
  536.         return(FALSE);
  537.     }
  538.     else
  539.         MyEasyRequest(Window,"`term' has a problem:\nThe ARexx server isn't running!","Continue");
  540. }
  541.  
  542.     /* FreeRexxCommand(struct RexxMsg *RexxMessage):
  543.      *
  544.      *    Free the contents of a RexxMsg.
  545.      */
  546.  
  547. VOID
  548. FreeRexxCommand(struct RexxMsg *RexxMessage)
  549. {
  550.     if(RexxMessage -> rm_Args[0])
  551.         DeleteArgstring(RexxMessage -> rm_Args[0]);
  552.  
  553.     DeleteRexxMsg(RexxMessage);
  554. }
  555.  
  556.     /* ReplyRexxCommand():
  557.      *
  558.      *    Reply a command request the rexx server - or someone else -
  559.      *    has passed to us.
  560.      */
  561.  
  562. VOID
  563. ReplyRexxCommand(struct RexxMsg *RexxMessage,LONG Primary,LONG Secondary,STRPTR Result)
  564. {
  565.     if(Secondary == NULL && (RexxMessage -> rm_Action & RXFF_RESULT))
  566.     {
  567.         if(Result)
  568.         {
  569.             if(Result[0])
  570.                 Secondary = (LONG)CreateArgstring(Result,strlen(Result));
  571.         }
  572.     }
  573.  
  574.     RexxMessage -> rm_Result1 = Primary;
  575.     RexxMessage -> rm_Result2 = Secondary;
  576.  
  577.     ReplyMsg(RexxMessage);
  578. }
  579.  
  580.     /* IsSpace(UBYTE c):
  581.      *
  582.      *    Return if the character passed to this routine is some
  583.      *    kind of blank space.
  584.      */
  585.  
  586. STATIC BYTE
  587. IsSpace(UBYTE c)
  588. {
  589.     if((c >= 13 && c <= 17) || c == 32)
  590.         return(TRUE);
  591.     else
  592.         return(FALSE);
  593. }
  594.  
  595.     /* GetToken():
  596.      *
  597.      *    Parse a string for a token (typically used for
  598.      *    rexx message parsing).
  599.      */
  600.  
  601. STRPTR
  602. GetToken(STRPTR String,LONG *StartChar,STRPTR AuxBuff,LONG MaxLength)
  603. {
  604.     WORD    i,StrEnd = 0,MaxPos = strlen(String);
  605.     BYTE    Filter = FALSE;
  606.     UBYTE    Brace = 0;
  607.  
  608.     if(MaxPos >= MaxLength + *StartChar)
  609.         MaxPos = MaxLength + *StartChar - 1;
  610.  
  611.     if(*StartChar <= strlen(String) - 1 && String && String[0] && AuxBuff && MaxLength)
  612.     {
  613.         for(i = *StartChar ; i <= MaxPos ; i++)
  614.         {
  615.             if(!Filter)
  616.             {
  617.                 if(!StrEnd && IsSpace(String[i]))
  618.                 {
  619.                     while(IsSpace(String[i]) && i < MaxPos)
  620.                     {
  621.                         i++;
  622.  
  623.                         (*StartChar)++;
  624.                     }
  625.                 }
  626.             }
  627.  
  628.             if((!Filter && IsSpace(String[i])) || String[i] == 0)
  629.             {
  630.                 strncpy(AuxBuff,(String + *StartChar),StrEnd);
  631.                 AuxBuff[StrEnd] = 0;
  632.  
  633.                 (*StartChar) += StrEnd;
  634.  
  635.                 return(AuxBuff);
  636.             }
  637.  
  638.             if(String[i] == '\'' || String[i] == '\"')
  639.             {
  640.                 if(!Filter)
  641.                 {
  642.                     Brace = String[i];
  643.  
  644.                     Filter = TRUE;
  645.                 }
  646.                 else
  647.                 {
  648.                     if(String[i] == Brace)
  649.                         Filter = FALSE;
  650.                 }
  651.             }
  652.  
  653.             StrEnd++;
  654.         }
  655.     }
  656.  
  657.     return(NULL);
  658. }
  659.  
  660.     /* A bunch of single rexx server routines is to follow.
  661.      * Since there are pretty much of subroutines, I didn't
  662.      * necessarily make a comment on any (figure out yourself
  663.      * how they work :-)
  664.      */
  665.  
  666. UBYTE *
  667. QueryBaud()
  668. {
  669.     SPrintf(RexxTextBuffer,"%ld",Config . BaudRate);
  670.  
  671.     return(RexxTextBuffer);
  672. }
  673.  
  674. UBYTE *
  675. QueryDataBits()
  676. {
  677.     SPrintf(RexxTextBuffer,"%ld",Config . BitsPerChar);
  678.  
  679.     return(RexxTextBuffer);
  680. }
  681.  
  682. UBYTE *
  683. QueryParity()
  684. {
  685.     return(ConfigParity[Config . Parity]);
  686. }
  687.  
  688. UBYTE *
  689. QueryStopBits()
  690. {
  691.     SPrintf(RexxTextBuffer,"%ld",Config . StopBits);
  692.  
  693.     return(RexxTextBuffer);
  694. }
  695.  
  696. UBYTE *
  697. QueryHandshaking()
  698. {
  699.     return(ConfigHandshaking[Config . Handshaking]);
  700. }
  701.  
  702. UBYTE *
  703. QueryDuplex()
  704. {
  705.     return(ConfigDuplex[Config . Duplex]);
  706. }
  707.  
  708. UBYTE *
  709. QueryHighspeed()
  710. {
  711.     return(Booleans[Config . HighSpeed]);
  712. }
  713.  
  714. UBYTE *
  715. QueryBreakLength()
  716. {
  717.     SPrintf(RexxTextBuffer,"%ld",Config . BreakLength);
  718.  
  719.     return(RexxTextBuffer);
  720. }
  721.  
  722. UBYTE *
  723. QuerySerialDevice()
  724. {
  725.     return(Config . SerialDevice);
  726. }
  727.  
  728. UBYTE *
  729. QueryUnitNumber()
  730. {
  731.     SPrintf(RexxTextBuffer,"%ld",Config . UnitNumber);
  732.  
  733.     return(RexxTextBuffer);
  734. }
  735.  
  736. UBYTE *
  737. QueryModemInit()
  738. {
  739.     return(Config . ModemInit);
  740. }
  741.  
  742. UBYTE *
  743. QueryModemExit()
  744. {
  745.     return(Config . ModemExit);
  746. }
  747.  
  748. UBYTE *
  749. QueryDialPrefix()
  750. {
  751.     return(Config . DialPrefix);
  752. }
  753.  
  754. UBYTE *
  755. QueryRedialDelay()
  756. {
  757.     SPrintf(RexxTextBuffer,"%ld",Config . RedialDelay);
  758.  
  759.     return(RexxTextBuffer);
  760. }
  761.  
  762. UBYTE *
  763. QueryDialRetries()
  764. {
  765.     SPrintf(RexxTextBuffer,"%ld",Config . DialRetries);
  766.  
  767.     return(RexxTextBuffer);
  768. }
  769.  
  770. UBYTE *
  771. QueryDialTimeout()
  772. {
  773.     SPrintf(RexxTextBuffer,"%ld",Config . DialTimeout);
  774.  
  775.     return(RexxTextBuffer);
  776. }
  777.  
  778. UBYTE *
  779. QueryConnectAutoBaud()
  780. {
  781.     return(Booleans[Config . ConnectAutoBaud]);
  782. }
  783.  
  784. UBYTE *
  785. QueryNoCarrier()
  786. {
  787.     return(Config . NoCarrier);
  788. }
  789.  
  790. UBYTE *
  791. QueryConnect()
  792. {
  793.     return(Config . Connect);
  794. }
  795.  
  796. UBYTE *
  797. QueryVoice()
  798. {
  799.     return(Config . Voice);
  800. }
  801.  
  802. UBYTE *
  803. QueryRing()
  804. {
  805.     return(Config . Ring);
  806. }
  807.  
  808. UBYTE *
  809. QueryBusy()
  810. {
  811.     return(Config . Busy);
  812. }
  813.  
  814. UBYTE *
  815. QueryProtocol()
  816. {
  817.     return(Config . Protocol);
  818. }
  819.  
  820. UBYTE *
  821. QueryProtocolOptions()
  822. {
  823.     return(ProtocolOptsBuffer);
  824. }
  825.  
  826. UBYTE *
  827. QueryMacroFile()
  828. {
  829.     return(Config . MacroFile);
  830. }
  831.  
  832. UBYTE *
  833. QueryDisplay()
  834. {
  835.     WORD i;
  836.  
  837.     for(i = 0 ; i < 16 ; i++)
  838.         if(Config . DisplayMode == ModeID[i])
  839.             return(ConfigDisplayNames[i]);
  840. }
  841.  
  842. UBYTE *
  843. QueryPublicScreen()
  844. {
  845.     return(Booleans[Config . MakeScreenPublic]);
  846. }
  847.  
  848. UBYTE *
  849. QueryShanghai()
  850. {
  851.     return(Booleans[Config . ShanghaiWindows]);
  852. }
  853.  
  854. UBYTE *
  855. QueryCaptureFilter()
  856. {
  857.     return(Booleans[Config . HighSpeed]);
  858. }
  859.  
  860. UBYTE *
  861. QueryDSBackSpace()
  862. {
  863.     return(Booleans[Config . DestructiveBackspace]);
  864. }
  865.  
  866. UBYTE *
  867. QueryAudBell()
  868. {
  869.     return(Booleans[Config . AudibleBell]);
  870. }
  871.  
  872. UBYTE *
  873. QueryVisBell()
  874. {
  875.     return(Booleans[Config . VisibleBell]);
  876. }
  877.  
  878. UBYTE *
  879. QueryEightyColumns()
  880. {
  881.     return(Booleans[Config . EightyColumns != 0]);
  882. }
  883.  
  884. UBYTE *
  885. QuerySendCR()
  886. {
  887.     switch(Config . SendCR)
  888.     {
  889.         case CR_IGNORE:        return("IGNORE");
  890.         case CR_ASCR:        return("CR");
  891.         case CR_ASCRLF:        return("CRLF");
  892.     }
  893. }
  894.  
  895. UBYTE *
  896. QuerySendLF()
  897. {
  898.     switch(Config . SendLF)
  899.     {
  900.         case LF_IGNORE:        return("IGNORE");
  901.         case LF_ASLF:        return("LF");
  902.         case LF_ASLFCR:        return("LFCR");
  903.     }
  904. }
  905.  
  906. UBYTE *
  907. QueryColourMode()
  908. {
  909.     return(ConfigColour[Config . ColourMode]);
  910. }
  911.  
  912. UBYTE *
  913. QueryEmulation()
  914. {
  915.     return(ConfigEmulation[Config . Emulation]);
  916. }
  917.  
  918. UBYTE *
  919. QueryFont()
  920. {
  921.     return(ConfigFont[Config . Font]);
  922. }
  923.  
  924. UBYTE *
  925. QueryStatus()
  926. {
  927.     return(ConfigStatus[Status]);
  928. }
  929.  
  930. UBYTE *
  931. QuerySerial()
  932. {
  933.     return(Booleans[ReadPort ? 1 : 0]);
  934. }
  935.  
  936. UBYTE *
  937. QueryStartup()
  938. {
  939.     return(Config . StartupMacro);
  940. }
  941.  
  942. UBYTE *
  943. QueryRequesters()
  944. {
  945.     return((LONG)ThisProcess -> pr_WindowPtr == -1 ? Booleans[0] : Booleans[1]);
  946. }
  947.  
  948. UBYTE *
  949. QueryTimeout()
  950. {
  951.     SPrintf(RexxTextBuffer,"%ld",RexxGlobalTimeout);
  952.  
  953.     return(RexxTextBuffer);
  954. }
  955.  
  956. UBYTE *
  957. QueryLine()
  958. {
  959.     return(Booleans[Online]);
  960. }
  961.  
  962. UBYTE *
  963. QueryLines()
  964. {
  965.         /* Note: LastLine is the last accessible line (i.e. for a
  966.          *       24 line display, LastLine will be 23).
  967.          */
  968.  
  969.     SPrintf(RexxTextBuffer,"%ld",LastLine + 1);
  970.  
  971.     return(RexxTextBuffer);
  972. }
  973.  
  974. UBYTE *
  975. QueryColumns()
  976. {
  977.     SPrintf(RexxTextBuffer,"%ld",LastColumn);
  978.  
  979.     return(RexxTextBuffer);
  980. }
  981.  
  982. UBYTE *
  983. QueryCursor()
  984. {
  985.     SPrintf(RexxTextBuffer,"%ld %ld",CursorX,CursorY);
  986.  
  987.     return(RexxTextBuffer);
  988. }
  989.  
  990. UBYTE *
  991. QueryModemHangup()
  992. {
  993.     return(Config . ModemHangup);
  994. }
  995.  
  996. UBYTE *
  997. QueryAutoCapture()
  998. {
  999.     return(Booleans[Config . ConnectAutoCapture]);
  1000. }
  1001.  
  1002. UBYTE *
  1003. QueryLogActions()
  1004. {
  1005.     return(Booleans[Config . LogActions]);
  1006. }
  1007.  
  1008. UBYTE *
  1009. QueryBlinking()
  1010. {
  1011.     return(Booleans[Config . DisableBlinking ^ TRUE]);
  1012. }
  1013.  
  1014. UBYTE *
  1015. QueryCursorMode()
  1016. {
  1017.     return(KeyModes[Config . CursorApp]);
  1018. }
  1019.  
  1020. UBYTE *
  1021. QueryFontScale()
  1022. {
  1023.     return(FontSizes[Config . FontScale]);
  1024. }
  1025.  
  1026. UBYTE *
  1027. QueryJumpScroll()
  1028. {
  1029.     return(Booleans[Config . JumpScroll ^ TRUE]);
  1030. }
  1031.  
  1032. UBYTE *
  1033. QueryCharacterWrap()
  1034. {
  1035.     return(Booleans[Config . AutoWrap]);
  1036. }
  1037.  
  1038. UBYTE *
  1039. QueryCursorWrap()
  1040. {
  1041.     return(Booleans[Config . CursorWrap]);
  1042. }
  1043.  
  1044. UBYTE *
  1045. QueryNewLine()
  1046. {
  1047.     return(Booleans[Config . NewLine]);
  1048. }
  1049.  
  1050. UBYTE *
  1051. QueryInsert()
  1052. {
  1053.     return(Booleans[Config . InsertChar]);
  1054. }
  1055.  
  1056. UBYTE *
  1057. QueryNumeric()
  1058. {
  1059.     return(KeyModes[Config . NumApp]);
  1060. }
  1061.  
  1062. UBYTE *
  1063. QueryDefaultStore()
  1064. {
  1065.     return(Config . DefaultStorage);
  1066. }
  1067.  
  1068. UBYTE *
  1069. QueryTUploadPath()
  1070. {
  1071.     return(Config . TextUploadPath);
  1072. }
  1073.  
  1074. UBYTE *
  1075. QueryTDownloadPath()
  1076. {
  1077.     return(Config . TextDownloadPath);
  1078. }
  1079.  
  1080. UBYTE *
  1081. QueryAUploadPath()
  1082. {
  1083.     return(Config . ASCIIUploadPath);
  1084. }
  1085.  
  1086. UBYTE *
  1087. QueryADownloadPath()
  1088. {
  1089.     return(Config . ASCIIDownloadPath);
  1090. }
  1091.  
  1092. UBYTE *
  1093. QueryBUploadPath()
  1094. {
  1095.     return(Config . BinaryUploadPath);
  1096. }
  1097.  
  1098. UBYTE *
  1099. QueryBDownloadPath()
  1100. {
  1101.     return(Config . BinaryDownloadPath);
  1102. }
  1103.  
  1104. UBYTE *
  1105. QueryCapturePath()
  1106. {
  1107.     return(Config . CapturePath);
  1108. }
  1109.  
  1110. UBYTE *
  1111. QueryLogFile()
  1112. {
  1113.     return(Config . LogFile);
  1114. }
  1115.  
  1116. UBYTE *
  1117. QueryEditor()
  1118. {
  1119.     return(Config . Editor);
  1120. }
  1121.  
  1122. UBYTE *
  1123. QueryBeepSound()
  1124. {
  1125.     return(Config . BeepSound);
  1126. }
  1127.  
  1128. UBYTE *
  1129. QueryCaptureState()
  1130. {
  1131.     RexxTextBuffer[0] = 0;
  1132.  
  1133.     if(PrinterCapture)
  1134.     {
  1135.         strcat(RexxTextBuffer,"PRINTER");
  1136.  
  1137.         if(FileCapture)
  1138.             strcat(RexxTextBuffer," FILE");
  1139.     }
  1140.     else
  1141.     {
  1142.         if(FileCapture)
  1143.             strcat(RexxTextBuffer,"FILE");
  1144.         else
  1145.             strcat(RexxTextBuffer,Booleans[0]);
  1146.     }        
  1147.  
  1148.     return(RexxTextBuffer);
  1149. }
  1150.  
  1151. UBYTE *
  1152. QueryDownloads()
  1153. {
  1154.     SPrintf(RexxTextBuffer,"%ld",DownloadLineCount);
  1155.  
  1156.     return(RexxTextBuffer);
  1157. }
  1158.  
  1159. UBYTE *
  1160. QueryScreenAddress()
  1161. {
  1162.     SPrintf(RexxTextBuffer,"%ld",Screen);
  1163.  
  1164.     return(RexxTextBuffer);
  1165. }
  1166.  
  1167. UBYTE *
  1168. QuerySpeechFile()
  1169. {
  1170.     return(LastSpeech);
  1171. }
  1172.  
  1173. UBYTE *
  1174. QuerySpeechRate()
  1175. {
  1176.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Rate);
  1177.  
  1178.     return(RexxTextBuffer);
  1179. }
  1180.  
  1181. UBYTE *
  1182. QuerySpeechPitch()
  1183. {
  1184.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Pitch);
  1185.  
  1186.     return(RexxTextBuffer);
  1187. }
  1188.  
  1189. UBYTE *
  1190. QuerySpeechFrequency()
  1191. {
  1192.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Frequency);
  1193.  
  1194.     return(RexxTextBuffer);
  1195. }
  1196.  
  1197. UBYTE *
  1198. QuerySpeechVolume()
  1199. {
  1200.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Volume);
  1201.  
  1202.     return(RexxTextBuffer);
  1203. }
  1204.  
  1205. UBYTE *
  1206. QuerySpeechSex()
  1207. {
  1208.     return(SpeechConfig . Sex ? "FEMALE" : "MALE");
  1209. }
  1210.  
  1211. UBYTE *
  1212. QuerySpeech()
  1213. {
  1214.     return(Booleans[SpeechConfig . Enabled]);
  1215. }
  1216.  
  1217. VOID
  1218. RexxSetBaud(UBYTE *String)
  1219. {
  1220.     LONG Value = atol(String);
  1221.  
  1222.     if(Config . BaudRate != Value)
  1223.     {
  1224.         Config . BaudRate = Value;
  1225.  
  1226.         ResetSerial = TRUE;
  1227.     }
  1228. }
  1229.  
  1230. VOID
  1231. RexxSetDataBits(UBYTE *String)
  1232. {
  1233.     LONG Bits = atol(String);
  1234.  
  1235.     if(Bits == 7 || Bits == 8)
  1236.     {
  1237.         if(Config . BitsPerChar != Bits)
  1238.         {
  1239.             Config . BitsPerChar = Bits;
  1240.  
  1241.             ResetSerial = TRUE;
  1242.         }
  1243.     }
  1244.     else
  1245.         RexxRes1 = RC_ERROR;
  1246. }
  1247.  
  1248. VOID
  1249. RexxSetParity(UBYTE *String)
  1250. {
  1251.     WORD i;
  1252.  
  1253.     for(i = 0 ; i < 5 ; i++)
  1254.     {
  1255.         if(!Stricmp(String,ConfigParity[i]))
  1256.         {
  1257.             if(Config . Parity != i)
  1258.             {
  1259.                 Config . Parity = i;
  1260.  
  1261.                 ResetSerial = TRUE;
  1262.             }
  1263.  
  1264.             break;
  1265.         }
  1266.     }
  1267. }
  1268.  
  1269. VOID
  1270. RexxSetStopBits(UBYTE *String)
  1271. {
  1272.     LONG Bits = atol(String);
  1273.  
  1274.     if(Bits == 1 || Bits == 2)
  1275.     {
  1276.         if(Config . StopBits != Bits)
  1277.         {
  1278.             Config . StopBits = Bits;
  1279.  
  1280.             ResetSerial = TRUE;
  1281.         }
  1282.     }
  1283.     else
  1284.         RexxRes1 = RC_ERROR;
  1285. }
  1286.  
  1287. VOID
  1288. RexxSetHandshaking(UBYTE *String)
  1289. {
  1290.     WORD i;
  1291.  
  1292.     for(i = 0 ; i < 3 ; i++)
  1293.     {
  1294.         if(!Stricmp(String,ConfigHandshaking[i]))
  1295.         {
  1296.             if(Config . Handshaking != i)
  1297.             {
  1298.                 Config . Handshaking = i;
  1299.  
  1300.                 ResetSerial = TRUE;
  1301.             }
  1302.  
  1303.             break;
  1304.         }
  1305.     }
  1306. }
  1307.  
  1308. VOID
  1309. RexxSetDuplex(UBYTE *String)
  1310. {
  1311.     WORD i;
  1312.  
  1313.     for(i = 0 ; i < 2 ; i++)
  1314.     {
  1315.         if(!Stricmp(String,ConfigDuplex[i]))
  1316.         {
  1317.             Config . Duplex = i;
  1318.  
  1319.             break;
  1320.         }
  1321.     }
  1322. }
  1323.  
  1324. VOID
  1325. RexxSetHighSpeed(UBYTE *String)
  1326. {
  1327.     WORD i;
  1328.  
  1329.     for(i = 0 ; i < 2 ; i++)
  1330.     {
  1331.         if(!Stricmp(String,Booleans[i]))
  1332.         {
  1333.             if(Config . HighSpeed != i)
  1334.             {
  1335.                 Config . HighSpeed = i;
  1336.  
  1337.                 ResetSerial = TRUE;
  1338.             }
  1339.  
  1340.             break;
  1341.         }
  1342.     }
  1343. }
  1344.  
  1345. VOID
  1346. RexxSetBreakLength(UBYTE *String)
  1347. {
  1348.     LONG Value = atol(String);
  1349.  
  1350.     if(Config . BreakLength != Value)
  1351.     {
  1352.         Config . BreakLength = Value;
  1353.  
  1354.         ResetSerial = TRUE;
  1355.     }
  1356. }
  1357.  
  1358. VOID
  1359. RexxSetSerialDevice(UBYTE *String)
  1360. {
  1361.     if(strcmp(Config . SerialDevice,String))
  1362.     {
  1363.         strcpy(Config . SerialDevice,String);
  1364.  
  1365.         ResetSerial = TRUE;
  1366.     }
  1367. }
  1368.  
  1369. VOID
  1370. RexxSetUnitNumber(UBYTE *String)
  1371. {
  1372.     LONG Value = atol(String);
  1373.  
  1374.     if(Config . UnitNumber != Value)
  1375.     {
  1376.         Config . UnitNumber = Value;
  1377.  
  1378.         ResetSerial = TRUE;
  1379.     }
  1380. }
  1381.  
  1382. VOID
  1383. RexxSetModemInit(UBYTE *String)
  1384. {
  1385.     strcpy(Config . ModemInit,String);
  1386. }
  1387.  
  1388. VOID
  1389. RexxSetModemExit(UBYTE *String)
  1390. {
  1391.     strcpy(Config . ModemExit,String);
  1392. }
  1393.  
  1394. VOID
  1395. RexxSetDialPrefix(UBYTE *String)
  1396. {
  1397.     strcpy(Config . DialPrefix,String);
  1398. }
  1399.  
  1400. VOID
  1401. RexxSetRedialDelay(UBYTE *String)
  1402. {
  1403.     Config . RedialDelay = atol(String);
  1404. }
  1405.  
  1406. VOID
  1407. RexxSetDialRetries(UBYTE *String)
  1408. {
  1409.     Config . DialRetries = atol(String);
  1410. }
  1411.  
  1412. VOID
  1413. RexxSetDialTimeout(UBYTE *String)
  1414. {
  1415.     Config . DialTimeout = atol(String);
  1416. }
  1417.  
  1418. VOID
  1419. RexxSetConnectAutoBaud(UBYTE *String)
  1420. {
  1421.     WORD i;
  1422.  
  1423.     for(i = 0 ; i < 2 ; i++)
  1424.     {
  1425.         if(!Stricmp(String,Booleans[i]))
  1426.         {
  1427.             Config . ConnectAutoBaud = i;
  1428.  
  1429.             break;
  1430.         }
  1431.     }
  1432. }
  1433.  
  1434. VOID
  1435. RexxSetNoCarrier(UBYTE *String)
  1436. {
  1437.     strcpy(Config . NoCarrier,String);
  1438. }
  1439.  
  1440. VOID
  1441. RexxSetConnect(UBYTE *String)
  1442. {
  1443.     strcpy(Config . Connect,String);
  1444. }
  1445.  
  1446. VOID
  1447. RexxSetVoice(UBYTE *String)
  1448. {
  1449.     strcpy(Config . Voice,String);
  1450. }
  1451.  
  1452. VOID
  1453. RexxSetRing(UBYTE *String)
  1454. {
  1455.     strcpy(Config . Ring,String);
  1456. }
  1457.  
  1458. VOID
  1459. RexxSetBusy(UBYTE *String)
  1460. {
  1461.     strcpy(Config . Busy,String);
  1462. }
  1463.  
  1464. VOID
  1465. RexxSetScreenMode(UBYTE *String)
  1466. {
  1467.     WORD i;
  1468.  
  1469.     for(i = 0 ; i < 16 ; i++)
  1470.     {
  1471.         if(!Stricmp(ConfigDisplayNames[i],String))
  1472.         {
  1473.             if(!ModeNotAvailable(ModeID[i]))
  1474.             {
  1475.                 if(Config . DisplayMode != ModeID[i])
  1476.                 {
  1477.                     BYTE Limited;
  1478.  
  1479.                     if(Config . ColourMode == COLOUR_EIGHT || Config . ColourMode == COLOUR_SIXTEEN)
  1480.                         Limited = TRUE;
  1481.                     else
  1482.                         Limited = FALSE;
  1483.  
  1484.                     if(!Limited && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRES_KEY) && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRESLACE_KEY))
  1485.                     {
  1486.                         Config . DisplayMode = ModeID[i];
  1487.  
  1488.                         ResetDisplay = TRUE;
  1489.                     }
  1490.                 }
  1491.             }
  1492.  
  1493.             break;
  1494.         }
  1495.     }
  1496. }
  1497.  
  1498. VOID
  1499. RexxSetFilter(UBYTE *String)
  1500. {
  1501.     WORD i;
  1502.  
  1503.     for(i = 0 ; i < 2 ; i++)
  1504.     {
  1505.         if(!Stricmp(String,Booleans[i]))
  1506.         {
  1507.             Config . CaptureFilter = i;
  1508.  
  1509.             break;
  1510.         }
  1511.     }
  1512. }
  1513.  
  1514. VOID
  1515. RexxSetBackspace(UBYTE *String)
  1516. {
  1517.     WORD i;
  1518.  
  1519.     for(i = 0 ; i < 2 ; i++)
  1520.     {
  1521.         if(!Stricmp(String,Booleans[i]))
  1522.         {
  1523.             Config . DestructiveBackspace = i;
  1524.  
  1525.             break;
  1526.         }
  1527.     }
  1528. }
  1529.  
  1530. VOID
  1531. RexxSetCR(UBYTE *String)
  1532. {
  1533.     if(!Stricmp(String,"IGNORE"))
  1534.         Config . SendCR = CR_IGNORE;
  1535.  
  1536.     if(!Stricmp(String,"CR"))
  1537.         Config . SendCR = CR_ASCR;
  1538.  
  1539.     if(!Stricmp(String,"CRLF"))
  1540.         Config . SendCR = CR_ASCRLF;
  1541. }
  1542.  
  1543. VOID
  1544. RexxSetLF(UBYTE *String)
  1545. {
  1546.     if(!Stricmp(String,"IGNORE"))
  1547.         Config . SendLF = LF_IGNORE;
  1548.  
  1549.     if(!Stricmp(String,"LF"))
  1550.         Config . SendLF = LF_ASLF;
  1551.  
  1552.     if(!Stricmp(String,"LFCR"))
  1553.         Config . SendLF = LF_ASLFCR;
  1554. }
  1555.  
  1556. VOID
  1557. RexxSet80Columns(UBYTE *String)
  1558. {
  1559.     WORD i;
  1560.  
  1561.     for(i = 0 ; i < 2 ; i++)
  1562.     {
  1563.         if(!Stricmp(String,Booleans[i]))
  1564.         {
  1565.             Config . EightyColumns = i;
  1566.  
  1567.             ConfigSetup();
  1568.  
  1569.             break;
  1570.         }
  1571.     }
  1572. }
  1573.  
  1574. VOID
  1575. RexxSetColourMode(UBYTE *String)
  1576. {
  1577.     WORD i;
  1578.  
  1579.     for(i = 0 ; i < 4 ; i++)
  1580.     {
  1581.         if(!Stricmp(ConfigColour[i],String))
  1582.         {
  1583.             if(i != Config . ColourMode)
  1584.             {
  1585.                 BYTE Limited;
  1586.  
  1587.                 switch(Config . DisplayMode & ~MONITOR_ID_MASK)
  1588.                 {
  1589.                     case HIRES_KEY:
  1590.                     case HIRESLACE_KEY:    Limited = FALSE;
  1591.                                 break;
  1592.  
  1593.                     default:        Limited = TRUE;
  1594.                                 break;
  1595.                 }
  1596.  
  1597.                 if(Config . Emulation == EMULATION_ATOMIC && i > COLOUR_AMIGA && i < COLOUR_MONO)
  1598.                     Config . Emulation = EMULATION_ANSIVT100;
  1599.  
  1600.                 if(Limited && i != COLOUR_AMIGA && i != COLOUR_MONO)
  1601.                 {
  1602.                     if(Config . DisplayMode & LACE)
  1603.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRESLACE_KEY;
  1604.                     else
  1605.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRES_KEY;
  1606.                 }
  1607.  
  1608.                 Config . ColourMode = i;
  1609.  
  1610.                 ResetDisplay = TRUE;
  1611.             }
  1612.  
  1613.             break;
  1614.         }
  1615.     }
  1616. }
  1617.  
  1618. VOID
  1619. RexxSetEmulation(UBYTE *String)
  1620. {
  1621.     WORD i;
  1622.  
  1623.     for(i = 0 ; i < 3 ; i++)
  1624.     {
  1625.         if(!Stricmp(String,ConfigEmulation[i]))
  1626.         {
  1627.             if(Config . Emulation != i)
  1628.             {
  1629.                 Config . Emulation = i;
  1630.  
  1631.                 ResetDisplay = TRUE;
  1632.             }
  1633.  
  1634.             break;
  1635.         }
  1636.     }
  1637. }
  1638.  
  1639. VOID
  1640. RexxSetStartup(UBYTE *String)
  1641. {
  1642.     strcpy(Config . StartupMacro,String);
  1643. }
  1644.  
  1645. VOID
  1646. RexxSetFont(UBYTE *String)
  1647. {
  1648.     WORD i;
  1649.  
  1650.     for(i = 0 ; i < 2 ; i++)
  1651.     {
  1652.         if(!Stricmp(String,ConfigFont[i]))
  1653.         {
  1654.             if(Config . Font != i)
  1655.             {
  1656.                 Config . Font = i;
  1657.  
  1658.                 if(Config . Font == FONT_TOPAZ)
  1659.                     SetFont(RPort,Topaz);
  1660.                 else
  1661.                 {
  1662.                     if(IBM)
  1663.                         SetFont(RPort,IBM);
  1664.                 }
  1665.             }
  1666.  
  1667.             break;
  1668.         }
  1669.     }
  1670. }
  1671.  
  1672. VOID
  1673. RexxSetProtocol(UBYTE *String)
  1674. {
  1675.     if(Stricmp(LastXprLibrary,String))
  1676.     {
  1677.         UBYTE Name[80];
  1678.  
  1679.         WORD i;
  1680.  
  1681.         for(i = 0 ; i < strlen(String) ; i++)
  1682.             Name[i] = ToLower(String[i]);
  1683.  
  1684.         strcpy(LastXprLibrary,Name);
  1685.  
  1686.         strcpy(Config . Protocol,LastXprLibrary);
  1687.  
  1688.         ProtocolSetup();
  1689.     }
  1690. }
  1691.  
  1692. VOID
  1693. RexxSetProtocolOptions(UBYTE *String)
  1694. {
  1695.     if(XProtocolBase)
  1696.     {
  1697.         if(Stricmp(ProtocolOptsBuffer,String))
  1698.         {
  1699.             strcpy(ProtocolOptsBuffer,String);
  1700.  
  1701.             XprIO -> xpr_filename = ProtocolOptsBuffer;
  1702.  
  1703.             TransferBits = XProtocolSetup(XprIO);
  1704.  
  1705.             if(!(TransferBits & XPRS_SUCCESS))
  1706.             {
  1707.                 CloseLibrary(XProtocolBase);
  1708.  
  1709.                 XProtocolBase = NULL;
  1710.  
  1711.                 LastXprLibrary[0] = 0;
  1712.  
  1713.                 TransferBits = 0;
  1714.  
  1715.                 RexxRes1 = RC_ERROR;
  1716.             }
  1717.         }
  1718.     }
  1719. }
  1720.  
  1721. VOID
  1722. RexxSetMacro(UBYTE *String)
  1723. {
  1724.     UBYTE Arg1[40],Arg2[40],Arg3[256];
  1725.     LONG ArgCount,i,Qualifier = -1;
  1726.  
  1727.     Arg1[0] = Arg2[0] = Arg3[0] = 0;
  1728.     ArgCount = 0;
  1729.  
  1730.     GetToken(String,&ArgCount,Arg1,40);
  1731.     GetToken(String,&ArgCount,Arg2,40);
  1732.     GetToken(String,&ArgCount,Arg3,256);
  1733.  
  1734.     for(i = 0 ; i < 4 ; i++)
  1735.     {
  1736.         if(!Stricmp(Qualifiers[i],Arg1))
  1737.         {
  1738.             Qualifier = i;
  1739.             break;
  1740.         }
  1741.     }
  1742.  
  1743.     if(Qualifier != -1)
  1744.     {
  1745.         if(Arg2[0] >= '0' && Arg2[0] <= '9')
  1746.             strcpy(MacroKeys -> Keys[Qualifier][Arg2[0] - '0'],Arg3);
  1747.         else
  1748.             RexxRes1 = RC_ERROR;
  1749.     }
  1750.     else
  1751.         RexxRes1 = RC_ERROR;
  1752. }
  1753.  
  1754. VOID
  1755. RexxSetColour(UBYTE *String)
  1756. {
  1757.     UBYTE Arg1[20],Arg2[20];
  1758.     LONG ArgCount;
  1759.  
  1760.     Arg1[0] = Arg2[0] = 0;
  1761.     ArgCount = 0;
  1762.  
  1763.     GetToken(String,&ArgCount,Arg1,20);
  1764.     GetToken(String,&ArgCount,Arg2,20);
  1765.  
  1766.     if(Arg1[0] && Arg2[0])
  1767.     {
  1768.         LONG Colour,Value;
  1769.  
  1770.         Colour    = atol(Arg1);
  1771.         Value    = ahtoi(Arg2);
  1772.  
  1773.         if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  1774.         {
  1775.             Config . Colours[Colour] = Value;
  1776.  
  1777.             if(Config . ColourMode == COLOUR_AMIGA && Config . Emulation == EMULATION_ANSIVT100)
  1778.             {
  1779.                 if(Colour == 0)
  1780.                     BlinkColours[3] = Value;
  1781.  
  1782.                 if(Colour != 3)
  1783.                     BlinkColours[Colour] = Value;
  1784.             }
  1785.             else
  1786.             {
  1787.                 if(Colour == 0 && Config . ColourMode == COLOUR_EIGHT && Config . Emulation == EMULATION_ANSIVT100)
  1788.                 {
  1789.                     WORD i;
  1790.  
  1791.                     for(i = 8 ; i < 16 ; i++)
  1792.                         BlinkColours[i] = Value;
  1793.                 }
  1794.                 else
  1795.                     BlinkColours[Colour] = Value;
  1796.             }
  1797.  
  1798.             LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
  1799.         }
  1800.         else
  1801.             RexxRes1 = RC_ERROR;
  1802.     }
  1803.     else
  1804.         RexxRes1 = RC_ERROR;
  1805. }
  1806.  
  1807. VOID
  1808. RexxSetScreen(UBYTE *String)
  1809. {
  1810.     UBYTE Arg1[20],Arg2[20];
  1811.     LONG ArgCount;
  1812.  
  1813.     Arg1[0] = Arg2[0] = 0;
  1814.     ArgCount = 0;
  1815.  
  1816.     GetToken(String,&ArgCount,Arg1,20);
  1817.     GetToken(String,&ArgCount,Arg2,20);
  1818.  
  1819.     Config . MakeScreenPublic    = FALSE;
  1820.     Config . ShanghaiWindows    = FALSE;
  1821.  
  1822.     if(!Stricmp(Arg1,"PUBLIC") || !Stricmp(Arg2,"PUBLIC"))
  1823.         Config . MakeScreenPublic = TRUE;
  1824.  
  1825.     if(!Stricmp(Arg1,"SHANGHAI") || !Stricmp(Arg2,"SHANGHAI"))
  1826.         Config . ShanghaiWindows = TRUE;
  1827.  
  1828.     PubScreenStuff();
  1829. }
  1830.  
  1831. VOID
  1832. RexxSetBell(UBYTE *String)
  1833. {
  1834.     UBYTE Arg1[20],Arg2[20];
  1835.     LONG ArgCount;
  1836.  
  1837.     Arg1[0] = Arg2[0] = 0;
  1838.     ArgCount = 0;
  1839.  
  1840.     GetToken(String,&ArgCount,Arg1,20);
  1841.     GetToken(String,&ArgCount,Arg2,20);
  1842.  
  1843.     Config . AudibleBell    = FALSE;
  1844.     Config . VisibleBell    = FALSE;
  1845.  
  1846.     if(!Stricmp(Arg1,"VISIBLE") || !Stricmp(Arg2,"VISIBLE"))
  1847.         Config . VisibleBell = TRUE;
  1848.  
  1849.     if(!Stricmp(Arg1,"AUDIBLE") || !Stricmp(Arg2,"AUDIBLE"))
  1850.         Config . AudibleBell = TRUE;
  1851. }
  1852.  
  1853. VOID
  1854. RexxSetRequesters(UBYTE *String)
  1855. {
  1856.     WORD i;
  1857.  
  1858.     for(i = 0 ; i < 2 ; i++)
  1859.     {
  1860.         if(!Stricmp(String,Booleans[i]))
  1861.         {
  1862.             ThisProcess -> pr_WindowPtr = (APTR)(i ? Window : -1);
  1863.  
  1864.             break;
  1865.         }
  1866.     }
  1867. }
  1868.  
  1869. VOID
  1870. RexxSetSerial(UBYTE *String)
  1871. {
  1872.     if(!Stricmp(String,Booleans[0]) && ReadPort)
  1873.         DeleteSerial();
  1874.  
  1875.     if(!Stricmp(String,Booleans[1]) && !ReadPort)
  1876.     {
  1877.         if(!CreateSerial())
  1878.             RexxRes1 = RC_ERROR;
  1879.     }
  1880. }
  1881.  
  1882. VOID
  1883. RexxSetTimeout(UBYTE *String)
  1884. {
  1885.     UBYTE    Arg1[40],Arg2[40];
  1886.     LONG    ArgCount;
  1887.  
  1888.     ULONG    Time = 0;
  1889.     WORD    i;
  1890.  
  1891.     Arg1[0] = Arg2[0] = 0;
  1892.     ArgCount = 0;
  1893.  
  1894.     GetToken(String,&ArgCount,Arg1,40);
  1895.     GetToken(String,&ArgCount,Arg2,40);
  1896.  
  1897.     for(i = 0 ; i < NUMTIMEREL ; i++)
  1898.     {
  1899.         if(!Stricmp(Arg2,TimeRelations[i] . Key))
  1900.         {
  1901.             Time = atol(String) * TimeRelations[i] . Multi;
  1902.             break;
  1903.         }
  1904.     }
  1905.  
  1906.     if(Time > 0)
  1907.         RexxGlobalTimeout = Time;
  1908.     else
  1909.         RexxRes1 = RC_ERROR;
  1910. }
  1911.  
  1912. VOID
  1913. RexxSetModemHangup(UBYTE *String)
  1914. {
  1915.     strcpy(Config . ModemHangup,String);
  1916. }
  1917.  
  1918. VOID
  1919. RexxSetAutoCapture(UBYTE *String)
  1920. {
  1921.     WORD i;
  1922.  
  1923.     for(i = 0 ; i < 2 ; i++)
  1924.     {
  1925.         if(!Stricmp(String,Booleans[i]))
  1926.         {
  1927.             Config . ConnectAutoCapture = i;
  1928.             break;
  1929.         }
  1930.     }
  1931. }
  1932.  
  1933. VOID
  1934. RexxSetLogActions(UBYTE *String)
  1935. {
  1936.     WORD i;
  1937.  
  1938.     for(i = 0 ; i < 2 ; i++)
  1939.     {
  1940.         if(!Stricmp(String,Booleans[i]))
  1941.         {
  1942.             Config . LogActions = i;
  1943.             break;
  1944.         }
  1945.     }
  1946. }
  1947.  
  1948. VOID
  1949. RexxSetBlinking(UBYTE *String)
  1950. {
  1951.     WORD i;
  1952.  
  1953.     for(i = 0 ; i < 2 ; i++)
  1954.     {
  1955.         if(!Stricmp(String,Booleans[i]))
  1956.         {
  1957.             Config . DisableBlinking = TRUE ^ i;
  1958.             break;
  1959.         }
  1960.     }
  1961. }
  1962.  
  1963. VOID
  1964. RexxSetCursorMode(UBYTE *String)
  1965. {
  1966.     WORD i;
  1967.  
  1968.     for(i = 0 ; i < 2 ; i++)
  1969.     {
  1970.         if(!Stricmp(String,KeyModes[i]))
  1971.         {
  1972.             Config . CursorApp = i;
  1973.             break;
  1974.         }
  1975.     }
  1976. }
  1977.  
  1978. VOID
  1979. RexxSetFontScale(UBYTE *String)
  1980. {
  1981.     WORD i;
  1982.  
  1983.     for(i = 0 ; i < 5 ; i++)
  1984.     {
  1985.         if(!Stricmp(String,FontSizes[i]))
  1986.         {
  1987.             if(i != SCALE_HALF && Config . FontScale == SCALE_HALF)
  1988.             {
  1989.                 CursorX >>= 1;
  1990.                 SetCursor();
  1991.  
  1992.                 if(Config . EightyColumns)
  1993.                     LastColumn = 79;
  1994.                 else
  1995.                     LastColumn = (Window -> Width >> 3) - 1;
  1996.             }
  1997.  
  1998.             if(i == SCALE_HALF && Config . FontScale != SCALE_HALF)
  1999.             {
  2000.                 if(Config . EightyColumns)
  2001.                     LastColumn = 131;
  2002.                 else
  2003.                     LastColumn = (Window -> Width >> 2) - 1;
  2004.             }
  2005.  
  2006.             Config . FontScale = i;
  2007.             break;
  2008.         }
  2009.     }
  2010. }
  2011.  
  2012. VOID
  2013. RexxSetJumpScroll(UBYTE *String)
  2014. {
  2015.     WORD i;
  2016.  
  2017.     for(i = 0 ; i < 2 ; i++)
  2018.     {
  2019.         if(!Stricmp(String,Booleans[i]))
  2020.         {
  2021.             Config . JumpScroll = TRUE ^ i;
  2022.             break;
  2023.         }
  2024.     }
  2025. }
  2026.  
  2027. VOID
  2028. RexxSetCharacterWrap(UBYTE *String)
  2029. {
  2030.     WORD i;
  2031.  
  2032.     for(i = 0 ; i < 2 ; i++)
  2033.     {
  2034.         if(!Stricmp(String,Booleans[i]))
  2035.         {
  2036.             Config . AutoWrap = i;
  2037.             break;
  2038.         }
  2039.     }
  2040. }
  2041.  
  2042. VOID
  2043. RexxSetCursorWrap(UBYTE *String)
  2044. {
  2045.     WORD i;
  2046.  
  2047.     for(i = 0 ; i < 2 ; i++)
  2048.     {
  2049.         if(!Stricmp(String,Booleans[i]))
  2050.         {
  2051.             Config . CursorWrap = i;
  2052.             break;
  2053.         }
  2054.     }
  2055. }
  2056.  
  2057. VOID
  2058. RexxSetNewLine(UBYTE *String)
  2059. {
  2060.     WORD i;
  2061.  
  2062.     for(i = 0 ; i < 2 ; i++)
  2063.     {
  2064.         if(!Stricmp(String,Booleans[i]))
  2065.         {
  2066.             Config . NewLine = i;
  2067.             break;
  2068.         }
  2069.     }
  2070. }
  2071.  
  2072. VOID
  2073. RexxSetInsert(UBYTE *String)
  2074. {
  2075.     WORD i;
  2076.  
  2077.     for(i = 0 ; i < 2 ; i++)
  2078.     {
  2079.         if(!Stricmp(String,Booleans[i]))
  2080.         {
  2081.             Config . InsertChar = i;
  2082.             break;
  2083.         }
  2084.     }
  2085. }
  2086.  
  2087. VOID
  2088. RexxSetNumeric(UBYTE *String)
  2089. {
  2090.     WORD i;
  2091.  
  2092.     for(i = 0 ; i < 2 ; i++)
  2093.     {
  2094.         if(!Stricmp(String,KeyModes[i]))
  2095.         {
  2096.             Config . NumApp = i;
  2097.             break;
  2098.         }
  2099.     }
  2100. }
  2101.  
  2102. VOID
  2103. RexxSetDefaultStore(UBYTE *String)
  2104. {
  2105.     strcpy(Config . DefaultStorage,String);
  2106. }
  2107.  
  2108. VOID
  2109. RexxSetTUploadPath(UBYTE *String)
  2110. {
  2111.     strcpy(Config . TextUploadPath,String);
  2112. }
  2113.  
  2114. VOID
  2115. RexxSetTDownloadPath(UBYTE *String)
  2116. {
  2117.     strcpy(Config . TextDownloadPath,String);
  2118. }
  2119.  
  2120. VOID
  2121. RexxSetAUploadPath(UBYTE *String)
  2122. {
  2123.     strcpy(Config . ASCIIUploadPath,String);
  2124. }
  2125.  
  2126. VOID
  2127. RexxSetADownloadPath(UBYTE *String)
  2128. {
  2129.     strcpy(Config . ASCIIDownloadPath,String);
  2130. }
  2131.  
  2132. VOID
  2133. RexxSetBUploadPath(UBYTE *String)
  2134. {
  2135.     strcpy(Config . BinaryUploadPath,String);
  2136. }
  2137.  
  2138. VOID
  2139. RexxSetBDownloadPath(UBYTE *String)
  2140. {
  2141.     strcpy(Config . BinaryDownloadPath,String);
  2142. }
  2143.  
  2144. VOID
  2145. RexxSetCapturePath(UBYTE *String)
  2146. {
  2147.     strcpy(Config . CapturePath,String);
  2148. }
  2149.  
  2150. VOID
  2151. RexxSetLogFile(UBYTE *String)
  2152. {
  2153.     strcpy(Config . LogFile,String);
  2154. }
  2155.  
  2156. VOID
  2157. RexxSetEditor(UBYTE *String)
  2158. {
  2159.     strcpy(Config . Editor,String);
  2160. }
  2161.  
  2162. VOID
  2163. RexxSetSpeechRate(UBYTE *String)
  2164. {
  2165.     SpeechConfig . Rate = atol(String);
  2166.  
  2167.     SpeechSetup();
  2168. }
  2169.  
  2170. VOID
  2171. RexxSetSpeechPitch(UBYTE *String)
  2172. {
  2173.     SpeechConfig . Pitch = atol(String);
  2174.  
  2175.     SpeechSetup();
  2176. }
  2177.  
  2178. VOID
  2179. RexxSetSpeechFrequency(UBYTE *String)
  2180. {
  2181.     SpeechConfig . Frequency = atol(String);
  2182.  
  2183.     SpeechSetup();
  2184. }
  2185.  
  2186. VOID
  2187. RexxSetSpeechVolume(UBYTE *String)
  2188. {
  2189.     SpeechConfig . Volume = atol(String);
  2190.  
  2191.     SpeechSetup();
  2192. }
  2193.  
  2194. VOID
  2195. RexxSetSpeechSex(UBYTE *String)
  2196. {
  2197.     if(!Stricmp(String,"MALE"))
  2198.     {
  2199.         SpeechConfig . Sex = 0;
  2200.  
  2201.         SpeechSetup();
  2202.     }
  2203.     else
  2204.     {
  2205.         if(!Stricmp(String,"FEMALE"))
  2206.         {
  2207.             SpeechConfig . Sex = 1;
  2208.  
  2209.             SpeechSetup();
  2210.         }
  2211.         else
  2212.             RexxRes1 = RC_ERROR;
  2213.     }
  2214. }
  2215.  
  2216. VOID
  2217. RexxSetSpeech(UBYTE *String)
  2218. {
  2219.     WORD i;
  2220.  
  2221.     for(i = 0 ; i < 2 ; i++)
  2222.     {
  2223.         if(!Stricmp(String,Booleans[i]))
  2224.         {
  2225.             SpeechConfig . Enabled = i;
  2226.  
  2227.             SpeechSetup();
  2228.  
  2229.             break;
  2230.         }
  2231.     }
  2232. }
  2233.  
  2234. UBYTE *
  2235. RexxBreak()
  2236. {
  2237.     BYTE OldStatus = Status;
  2238.  
  2239.     if(WriteRequest)
  2240.     {
  2241.         Status = STATUS_BREAKING;
  2242.  
  2243.         WriteRequest -> IOSer . io_Command = SDCMD_BREAK;
  2244.         DoIO(WriteRequest);
  2245.  
  2246.         Status = OldStatus;
  2247.     }
  2248.  
  2249.     return(NULL);
  2250. }
  2251.  
  2252. UBYTE *
  2253. RexxTUpload(UBYTE *String)
  2254. {
  2255.     BinaryTransfer = FALSE;
  2256.  
  2257.     RexxBUpload(String);
  2258.  
  2259.     return(NULL);
  2260. }
  2261.  
  2262. UBYTE *
  2263. RexxTDownload(UBYTE *String)
  2264. {
  2265.     BinaryTransfer = FALSE;
  2266.  
  2267.     RexxBDownload(String);
  2268.  
  2269.     return(NULL);
  2270. }
  2271.  
  2272. UBYTE *
  2273. RexxBDownload(UBYTE *String)
  2274. {
  2275.     BYTE OldStatus = Status;
  2276.  
  2277.     if(XProtocolBase)
  2278.     {
  2279.         if(!(TransferBits & XPRS_NORECREQ))
  2280.             XprIO -> xpr_filename = String;
  2281.  
  2282.         if(TransferPanel(BinaryTransfer ? "Download File(s)" : "Download Text"))
  2283.         {
  2284.             Status = STATUS_DOWNLOAD;
  2285.  
  2286.             ClearSerial();
  2287.  
  2288.             XProtocolReceive(XprIO);
  2289.  
  2290.             Status = OldStatus;
  2291.  
  2292.             if(ReadRequest)
  2293.             {
  2294.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2295.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2296.                 ReadRequest -> IOSer . io_Length    = 1;
  2297.  
  2298.                 SendIO(ReadRequest);
  2299.             }
  2300.  
  2301.             DeleteTransferPanel();
  2302.         }
  2303.     }
  2304.  
  2305.     BinaryTransfer = TRUE;
  2306.  
  2307.     return(NULL);
  2308. }
  2309.  
  2310. UBYTE *
  2311. RexxBUpload(UBYTE *String)
  2312. {
  2313.     BYTE OldStatus = Status;
  2314.  
  2315.     if(XProtocolBase)
  2316.     {
  2317.         if(!(TransferBits & XPRS_NOSNDREQ))
  2318.             XprIO -> xpr_filename = String;
  2319.  
  2320.         if(TransferPanel(BinaryTransfer ? "Upload File(s)" : "Upload Text"))
  2321.         {
  2322.             Status = STATUS_UPLOAD;
  2323.  
  2324.             ClearSerial();
  2325.  
  2326.             XProtocolSend(XprIO);
  2327.  
  2328.             Status = OldStatus;
  2329.  
  2330.             DeleteTransferPanel();
  2331.  
  2332.             if(ReadRequest)
  2333.             {
  2334.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2335.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2336.                 ReadRequest -> IOSer . io_Length    = 1;
  2337.  
  2338.                 SendIO(ReadRequest);
  2339.             }
  2340.         }
  2341.     }
  2342.  
  2343.     BinaryTransfer = TRUE;
  2344.  
  2345.     return(NULL);
  2346. }
  2347.  
  2348. UBYTE *
  2349. RexxWrite(UBYTE *String)
  2350. {
  2351.     if(String[0])
  2352.         SerWrite(String,strlen(String));
  2353.     else
  2354.         RexxRes1 = RC_ERROR;
  2355.  
  2356.     return(NULL);
  2357. }
  2358.  
  2359. UBYTE *
  2360. RexxResetStyles()
  2361. {
  2362.     Escape = TRUE;
  2363.  
  2364.     ConProcess("\033[m",3);
  2365.  
  2366.     switch(Config . ColourMode)
  2367.     {
  2368.         case COLOUR_EIGHT:    FgPen = 7;
  2369.                     break;
  2370.  
  2371.         case COLOUR_SIXTEEN:    FgPen = 15;
  2372.                     break;
  2373.  
  2374.         case COLOUR_AMIGA:
  2375.         default:        FgPen = 1;
  2376.                     break;
  2377.     }
  2378.  
  2379.     BgPen = 0;
  2380.  
  2381.     if(RPort -> FgPen != FgPen)
  2382.         SetAPen(RPort,FgPen);
  2383.  
  2384.     if(RPort -> BgPen != BgPen)
  2385.         SetBPen(RPort,BgPen);
  2386.  
  2387.     Config . FontScale = SCALE_NORMAL;
  2388.  
  2389.     Escape = FALSE;
  2390.  
  2391.     return(NULL);
  2392. }
  2393.  
  2394. UBYTE *
  2395. RexxClearScreen()
  2396. {
  2397.     Escape = TRUE;
  2398.  
  2399.     ConProcess("\033[2J\033[H",7);
  2400.  
  2401.     Escape = FALSE;
  2402.  
  2403.     return(NULL);
  2404. }
  2405.  
  2406. UBYTE *
  2407. RexxSaveILBM(UBYTE *String)
  2408. {
  2409.     if(!SaveRPort(&Screen -> RastPort,VPort,0,Window -> TopEdge,Window -> Width,Window -> Height,Screen -> Width,Screen -> Height,FALSE,String))
  2410.         RexxRes1 = RC_ERROR;
  2411.  
  2412.     return(NULL);
  2413. }
  2414.  
  2415. UBYTE *
  2416. RexxHangUp()
  2417. {
  2418.     BYTE OldStatus = Status;
  2419.  
  2420.     Status = STATUS_HANGUP;
  2421.  
  2422.     SerialCommand(Config . ModemHangup);
  2423.  
  2424.     Status = OldStatus;
  2425.  
  2426.     Online = FALSE;
  2427.  
  2428.     Password[0] = 0;
  2429.  
  2430.     return(NULL);
  2431. }
  2432.  
  2433. UBYTE *
  2434. RexxGetString(UBYTE *String)
  2435. {
  2436.     RexxTextBuffer[0] = 0;
  2437.  
  2438.     if(xpr_gets(String[0] ? String : "Get String For Rexx",RexxTextBuffer))
  2439.         return(RexxTextBuffer);
  2440.     else
  2441.         return(NULL);
  2442. }
  2443.  
  2444. UBYTE *
  2445. RexxCommand(UBYTE *String)
  2446. {
  2447.     if(String[0])
  2448.         SerialCommand(String);
  2449.     else
  2450.         RexxRes1 = RC_ERROR;
  2451.  
  2452.     return(NULL);
  2453. }
  2454.  
  2455. UBYTE *
  2456. RexxMessage(UBYTE *String)
  2457. {
  2458.     if(String[0])
  2459.         ConProcess(String,strlen(String));
  2460.     else
  2461.         RexxRes1 = RC_ERROR;
  2462.  
  2463.     return(NULL);
  2464. }
  2465.  
  2466. UBYTE *
  2467. RexxPutClip(UBYTE *String)
  2468. {
  2469.     if(String[0])
  2470.         SaveClip(String,strlen(String));
  2471.     else
  2472.         RexxRes1 = RC_ERROR;
  2473.  
  2474.     return(NULL);
  2475. }
  2476.  
  2477. UBYTE *
  2478. RexxGetClip()
  2479. {
  2480.     LONG Size;
  2481.  
  2482.     if(Size = LoadClip(RexxTextBuffer,255))
  2483.     {
  2484.         RexxTextBuffer[Size] = 0;
  2485.  
  2486.         return(RexxTextBuffer);
  2487.     }
  2488.     else
  2489.         return(NULL);
  2490. }
  2491.  
  2492. UBYTE *
  2493. RexxDelay(UBYTE *String)
  2494. {
  2495.     UBYTE    Arg1[40],Arg2[40];
  2496.     LONG    ArgCount;
  2497.  
  2498.     ULONG    Time = 0;
  2499.     WORD    i;
  2500.  
  2501.     Arg1[0] = Arg2[0] = 0;
  2502.     ArgCount = 0;
  2503.  
  2504.     GetToken(String,&ArgCount,Arg1,40);
  2505.     GetToken(String,&ArgCount,Arg2,40);
  2506.  
  2507.     for(i = 0 ; i < NUMTIMEREL ; i++)
  2508.     {
  2509.         if(!Stricmp(Arg2,TimeRelations[i] . Key))
  2510.         {
  2511.             Time = atol(String) * TimeRelations[i] . Multi;
  2512.             break;
  2513.         }
  2514.     }
  2515.  
  2516.     if(Time)
  2517.     {
  2518.         ULONG SignalSet;
  2519.  
  2520.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  2521.         TimeRequest -> tr_time . tv_secs    = Time / MILLION;
  2522.         TimeRequest -> tr_time . tv_micro    = Time % MILLION;
  2523.  
  2524.         SendIO(TimeRequest);
  2525.  
  2526.         SignalSet = Wait(SIGBREAKF_CTRL_D | (1 << TimeRequest -> tr_node . io_Message . mn_ReplyPort -> mp_SigBit));
  2527.  
  2528.         if(SignalSet & SIGBREAKF_CTRL_D)
  2529.         {
  2530.             if(!CheckIO(TimeRequest))
  2531.                 AbortIO(TimeRequest);
  2532.  
  2533.             WaitIO(TimeRequest);
  2534.  
  2535.             return(NULL);
  2536.         }
  2537.  
  2538.         WaitIO(TimeRequest);
  2539.     }
  2540.     else
  2541.         RexxRes1 = RC_ERROR;
  2542.  
  2543.     return(NULL);
  2544. }
  2545.  
  2546. UBYTE *
  2547. RexxDial(UBYTE *String)
  2548. {
  2549.     LONG i;
  2550.  
  2551.     strcpy(RexxTextBuffer,Config . DialPrefix);
  2552.  
  2553.     for(i = 0 ; i < NumPhoneEntries ; i++)
  2554.     {
  2555.         if(!Stricmp(Phonebook[i] -> Name,String))
  2556.         {
  2557.             strcat(RexxTextBuffer,Phonebook[i] -> Number);
  2558.  
  2559.             goto DialIt;
  2560.         }
  2561.     }
  2562.  
  2563.     strcat(RexxTextBuffer,String);
  2564.  
  2565. DialIt:    strcat(RexxTextBuffer,"\\r");
  2566.  
  2567.     SerialCommand(RexxTextBuffer);
  2568.  
  2569.     return(NULL);
  2570. }
  2571.  
  2572. UBYTE *
  2573. RexxInput(UBYTE *String)
  2574. {
  2575.     LONG Length = atol(String);
  2576.  
  2577.     if(Length > 255)
  2578.         Length = 255;
  2579.  
  2580.     ClearSerial();
  2581.  
  2582.     if(Length = xpr_sread(RexxTextBuffer,Length,RexxGlobalTimeout))
  2583.     {
  2584.         RexxTextBuffer[Length] = 0;
  2585.  
  2586.         if(ReadRequest)
  2587.         {
  2588.             ReadRequest -> IOSer . io_Command    = CMD_READ;
  2589.             ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2590.             ReadRequest -> IOSer . io_Length    = 1;
  2591.  
  2592.             SendIO(ReadRequest);
  2593.         }
  2594.  
  2595.         return(RexxTextBuffer);
  2596.     }
  2597.  
  2598.     if(ReadRequest)
  2599.     {
  2600.         ReadRequest -> IOSer . io_Command    = CMD_READ;
  2601.         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2602.         ReadRequest -> IOSer . io_Length    = 1;
  2603.  
  2604.         SendIO(ReadRequest);
  2605.     }
  2606.  
  2607.     return(NULL);
  2608. }
  2609.  
  2610. UBYTE *
  2611. RexxPrinter(UBYTE *String)
  2612. {
  2613.     struct MenuItem *SomeItem;
  2614.  
  2615.     SomeItem = FindThisItem(MEN_CAPTUREPRINTER);
  2616.  
  2617.     if(!Stricmp(String,Booleans[0]) && PrinterCapture)
  2618.     {
  2619.         Close(PrinterCapture);
  2620.  
  2621.         SomeItem -> Flags &= ~CHECKED;
  2622.  
  2623.         PrinterCapture = NULL;
  2624.     }
  2625.  
  2626.     if(!Stricmp(String,Booleans[1]) && !PrinterCapture)
  2627.     {
  2628.         if(PrinterCapture = Open("PRT:",MODE_NEWFILE))
  2629.             SomeItem -> Flags |= CHECKED;
  2630.         else
  2631.         {
  2632.             SomeItem -> Flags &= ~CHECKED;
  2633.             RexxRes1 = RC_ERROR;
  2634.         }
  2635.     }
  2636.  
  2637.     return(NULL);
  2638. }
  2639.  
  2640. UBYTE *
  2641. RexxMacros(UBYTE *String)
  2642. {
  2643.     UBYTE Arg1[40],Arg2[256];
  2644.     LONG ArgCount;
  2645.  
  2646.     Arg1[0] = Arg2[0] = 0;
  2647.     ArgCount = 0;
  2648.  
  2649.     GetToken(String,&ArgCount,Arg1,40);
  2650.     GetToken(String,&ArgCount,Arg2,256);
  2651.  
  2652.     if(!Stricmp(Arg1,"SAVE"))
  2653.     {
  2654.         if(Arg2[0])
  2655.         {
  2656.             if(WriteIFFData(Arg2,MacroKeys,sizeof(struct MacroKeys),'KEYS'))
  2657.                 strcpy(LastMacros,Arg2);
  2658.             else
  2659.                 RexxRes1 = RC_ERROR;
  2660.         }
  2661.     }
  2662.  
  2663.     if(!Stricmp(Arg1,"LOAD"))
  2664.     {
  2665.         if(Arg2[0])
  2666.         {
  2667.             if(LoadMacros(Arg2,MacroKeys))
  2668.                 strcpy(LastMacros,Arg2);
  2669.             else
  2670.                 RexxRes1 = RC_ERROR;
  2671.         }
  2672.     }
  2673.  
  2674.     return(NULL);
  2675. }
  2676.  
  2677. UBYTE *
  2678. RexxSpeech(UBYTE *String)
  2679. {
  2680.     UBYTE Arg1[40],Arg2[256];
  2681.     LONG ArgCount;
  2682.  
  2683.     Arg1[0] = Arg2[0] = 0;
  2684.     ArgCount = 0;
  2685.  
  2686.     GetToken(String,&ArgCount,Arg1,40);
  2687.     GetToken(String,&ArgCount,Arg2,256);
  2688.  
  2689.     if(!Stricmp(Arg1,"SAVE"))
  2690.     {
  2691.         if(Arg2[0])
  2692.         {
  2693.             if(!WriteIFFData(Arg2,&SpeechConfig,sizeof(struct SpeechConfig),'SPEK'))
  2694.                 RexxRes1 = RC_ERROR;
  2695.             else
  2696.                 strcpy(LastSpeech,Arg2);
  2697.         }
  2698.     }
  2699.  
  2700.     if(!Stricmp(Arg1,"LOAD"))
  2701.     {
  2702.         if(Arg2[0])
  2703.         {
  2704.             if(!ReadIFFData(Arg2,&SpeechConfig,sizeof(struct SpeechConfig),'SPEK'))
  2705.                 RexxRes1 = RC_ERROR;
  2706.             else
  2707.             {
  2708.                 strcpy(LastSpeech,Arg2);
  2709.  
  2710.                 SpeechSetup();
  2711.             }
  2712.         }
  2713.     }
  2714.  
  2715.     return(NULL);
  2716. }
  2717.  
  2718. UBYTE *
  2719. RexxConfig(UBYTE *String)
  2720. {
  2721.     UBYTE Arg1[40],Arg2[256];
  2722.     LONG ArgCount;
  2723.  
  2724.     Arg1[0] = Arg2[0] = 0;
  2725.     ArgCount = 0;
  2726.  
  2727.     GetToken(String,&ArgCount,Arg1,40);
  2728.     GetToken(String,&ArgCount,Arg2,256);
  2729.  
  2730.     if(!Stricmp(Arg1,"SAVE"))
  2731.     {
  2732.         if(Arg2[0])
  2733.         {
  2734.             if(WriteIFFData(Arg2,&Config,sizeof(struct Configuration),'PREF'))
  2735.                 strcpy(LastConfig,Arg2);
  2736.             else
  2737.                 RexxRes1 = RC_ERROR;
  2738.         }
  2739.     }
  2740.  
  2741.     if(!Stricmp(Arg1,"LOAD"))
  2742.     {
  2743.         if(Arg2[0])
  2744.         {
  2745.             struct Configuration PrivateConfig;
  2746.  
  2747.             if(ReadIFFData(Arg2,&PrivateConfig,sizeof(struct Configuration),'PREF'))
  2748.             {
  2749.                 Config = PrivateConfig;
  2750.  
  2751.                 ConfigSetup();
  2752.  
  2753.                 strcpy(LastConfig,Arg2);
  2754.             }
  2755.             else
  2756.                 RexxRes1 = RC_ERROR;
  2757.         }
  2758.     }
  2759.  
  2760.     return(NULL);
  2761. }
  2762.  
  2763. UBYTE *
  2764. RexxPhone(UBYTE *String)
  2765. {
  2766.     UBYTE Arg1[40],Arg2[256];
  2767.     LONG ArgCount;
  2768.  
  2769.     Arg1[0] = Arg2[0] = 0;
  2770.     ArgCount = 0;
  2771.  
  2772.     GetToken(String,&ArgCount,Arg1,40);
  2773.     GetToken(String,&ArgCount,Arg2,256);
  2774.  
  2775.     if(!Stricmp(Arg1,"SAVE"))
  2776.     {
  2777.         if(Arg2[0])
  2778.         {
  2779.             if(SavePhonebook(Arg2))
  2780.                 strcpy(LastPhone,Arg2);
  2781.             else
  2782.                 RexxRes1 = RC_ERROR;
  2783.         }
  2784.     }
  2785.  
  2786.     if(!Stricmp(Arg1,"LOAD"))
  2787.     {
  2788.         if(Arg2[0])
  2789.         {
  2790.             if(LoadPhonebook(Arg2))
  2791.                 strcpy(LastPhone,Arg2);
  2792.             else
  2793.                 RexxRes1 = RC_ERROR;
  2794.         }
  2795.     }
  2796.  
  2797.     return(NULL);
  2798. }
  2799.  
  2800. UBYTE *
  2801. RexxCapture(UBYTE *String)
  2802. {
  2803.     UBYTE Arg1[40],Arg2[256];
  2804.     LONG ArgCount;
  2805.  
  2806.     Arg1[0] = Arg2[0] = 0;
  2807.     ArgCount = 0;
  2808.  
  2809.     GetToken(String,&ArgCount,Arg1,40);
  2810.     GetToken(String,&ArgCount,Arg2,256);
  2811.  
  2812.     if(!Stricmp(Arg1,"CLOSE") && FileCapture)
  2813.     {
  2814.         struct MenuItem *SomeItem;
  2815.  
  2816.         SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2817.  
  2818.         BufferClose(FileCapture);
  2819.  
  2820.         SomeItem -> Flags &= ~CHECKED;
  2821.  
  2822.         FileCapture = NULL;
  2823.  
  2824.         if(!GetFileSize(CaptureName))
  2825.             DeleteFile(CaptureName);
  2826.         else
  2827.             SetProtection(CaptureName,FIBF_EXECUTE);
  2828.     }
  2829.     else
  2830.     {
  2831.         if(!Stricmp(Arg1,"NEW") && Arg2[0])
  2832.             FileCapture = BufferOpen(Arg2,"w");
  2833.         else
  2834.         {
  2835.             if(!Stricmp(Arg1,"APPEND") && Arg2[0])
  2836.                 FileCapture = BufferOpen(Arg2,"a");
  2837.         }
  2838.  
  2839.         if(FileCapture)
  2840.         {
  2841.             struct MenuItem *SomeItem;
  2842.  
  2843.             strcpy(CaptureName,Arg2);
  2844.  
  2845.             SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2846.  
  2847.             SomeItem -> Flags |= CHECKED;
  2848.         }
  2849.         else
  2850.             RexxRes1 = RC_ERROR;
  2851.     }
  2852.  
  2853.     return(NULL);
  2854. }
  2855.  
  2856. UBYTE *
  2857. RexxBuffer(UBYTE *String)
  2858. {
  2859.     UBYTE Arg1[40],Arg2[256];
  2860.     LONG ArgCount;
  2861.  
  2862.     Arg1[0] = Arg2[0] = 0;
  2863.     ArgCount = 0;
  2864.  
  2865.     GetToken(String,&ArgCount,Arg1,40);
  2866.     GetToken(String,&ArgCount,Arg2,256);
  2867.  
  2868.     if(!Stricmp(Arg1,"NEW") || !Stricmp(Arg1,"APPEND"))
  2869.     {
  2870.         if(GetFileSize(Arg2))
  2871.         {
  2872.             BPTR SomeFile;
  2873.  
  2874.             if(SomeFile = Open(Arg2,MODE_OLDFILE))
  2875.             {
  2876.                 if(Lines)
  2877.                 {
  2878.                     if(!Stricmp(Arg1,"NEW"))
  2879.                         ClearBuffer();
  2880.                 }
  2881.  
  2882.                 LineRead(NULL,NULL,NULL);
  2883.  
  2884.                 while(LineRead(SomeFile,Arg2,80))
  2885.                     StoreBuffer(Arg2,strlen(Arg2));
  2886.  
  2887.                 Close(SomeFile);
  2888.             }
  2889.             else
  2890.                 RexxRes1 = RC_ERROR;
  2891.         }
  2892.         else
  2893.             RexxRes1 = RC_ERROR;
  2894.     }
  2895.     else
  2896.     {
  2897.         if(!Stricmp(Arg1,"DISPLAY"))
  2898.         {
  2899.             if(BufferProcess)
  2900.                 Signal(BufferProcess,SIGBREAKF_CTRL_D);
  2901.             else
  2902.             {
  2903.                 if(BufferProcess = (struct Process *)CreateNewProcTags(
  2904.                     NP_Entry,    BufferServer,
  2905.                     NP_Name,    "term Buffer Process",
  2906.                     NP_Priority,    0,
  2907.                     NP_StackSize,    8192,
  2908.                     NP_WindowPtr,    -1,
  2909.                 TAG_END))
  2910.                     Wait(SIGBREAKF_CTRL_C);
  2911.             }
  2912.         }
  2913.     }
  2914.  
  2915.     return(NULL);
  2916. }
  2917.  
  2918. UBYTE *
  2919. RexxFirstDownload()
  2920. {
  2921.     ObtainSemaphore(DownloadSemaphore);
  2922.  
  2923.     if(DownloadLineCount)
  2924.     {
  2925.         DownloadNode = DownloadList . lh_Head;
  2926.  
  2927.         if(DownloadNode -> ln_Succ)
  2928.         {
  2929.             strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2930.  
  2931.             ReleaseSemaphore(DownloadSemaphore);
  2932.  
  2933.             return(RexxTextBuffer);
  2934.         }
  2935.     }
  2936.  
  2937.     ReleaseSemaphore(DownloadSemaphore);
  2938.  
  2939.     return("");
  2940. }
  2941.  
  2942. UBYTE *
  2943. RexxNextDownload()
  2944. {
  2945.     ObtainSemaphore(DownloadSemaphore);
  2946.  
  2947.     if(!DownloadNode)
  2948.         DownloadNode = DownloadList . lh_Head;
  2949.     else
  2950.         DownloadNode = DownloadNode -> ln_Succ;
  2951.  
  2952.     if(DownloadNode -> ln_Succ)
  2953.     {
  2954.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2955.  
  2956.         ReleaseSemaphore(DownloadSemaphore);
  2957.  
  2958.         return(RexxTextBuffer);
  2959.     }
  2960.     else
  2961.         DownloadNode = NULL;
  2962.  
  2963.     ReleaseSemaphore(DownloadSemaphore);
  2964.  
  2965.     return("");
  2966. }
  2967.  
  2968. UBYTE *
  2969. RexxLastDownload()
  2970. {
  2971.     ObtainSemaphore(DownloadSemaphore);
  2972.  
  2973.     if(DownloadLineCount)
  2974.     {
  2975.         DownloadNode = DownloadList . lh_TailPred;
  2976.  
  2977.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2978.  
  2979.         ReleaseSemaphore(DownloadSemaphore);
  2980.  
  2981.         return(RexxTextBuffer);
  2982.     }
  2983.  
  2984.     ReleaseSemaphore(DownloadSemaphore);
  2985.  
  2986.     return("");
  2987. }
  2988.  
  2989. UBYTE *
  2990. RexxWaitString(UBYTE *String)
  2991. {
  2992.     UBYTE         Arg1[40];
  2993.     LONG         ArgCount;
  2994.  
  2995.     struct ScanNode    *Matching = NULL;
  2996.  
  2997.     ULONG         SignalSet;
  2998.     WORD         i;
  2999.  
  3000.     ULONG         Timeout = RexxGlobalTimeout;
  3001.  
  3002.     if(ReadPort)
  3003.     {
  3004.         Arg1[0] = 0;
  3005.  
  3006.         ArgCount = 0;
  3007.  
  3008.             /* Parse the argument looking for sequences
  3009.              * to wait for.
  3010.              */
  3011.  
  3012.         while(GetToken(String,&ArgCount,Arg1,40))
  3013.             AddSequenceObject(Arg1);
  3014.  
  3015.             /* If no timeout is set this routine becomes
  3016.              * a real trap: suppose the string to wait for
  3017.              * never happens to arrive -> we'll wait
  3018.              * forever. For this reason the default timeout
  3019.              * is set to five seconds.
  3020.              */
  3021.  
  3022.         if(Timeout < 1)
  3023.             Timeout = 5 * MILLION;
  3024.  
  3025.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  3026.         TimeRequest -> tr_time . tv_secs    = Timeout >= MILLION ? Timeout / MILLION : 0;
  3027.         TimeRequest -> tr_time . tv_micro    = Timeout % MILLION;
  3028.  
  3029.         SetSignal(0,SIG_TIMER);
  3030.  
  3031.         SendIO(TimeRequest);
  3032.  
  3033.         FOREVER
  3034.         {
  3035.             SignalSet = Wait(SIG_TIMER | SIG_SERIAL | SIGBREAKF_CTRL_D);
  3036.  
  3037.                 /* We are to abort the job. */
  3038.  
  3039.             if(SignalSet & SIGBREAKF_CTRL_D)
  3040.             {
  3041.                 Matching = NULL;
  3042.                 break;
  3043.             }
  3044.  
  3045.                 /* Serial data came in... */
  3046.  
  3047.             if(SignalSet & SIG_SERIAL)
  3048.             {
  3049.                 if(Status == STATUS_HOLDING)
  3050.                     Status = STATUS_READY;
  3051.  
  3052.                 /* Any news? */
  3053.  
  3054.                 if(CheckIO(ReadRequest))
  3055.                 {
  3056.                     LONG Length;
  3057.  
  3058.                     if(!WaitIO(ReadRequest))
  3059.                     {
  3060.                         /* Send the byte to the console. */
  3061.  
  3062.                         ConProcess(ReadBuffer,1);
  3063.  
  3064.                         if(Matching == NULL)
  3065.                             Matching = SequenceFilter(((UBYTE *)ReadBuffer)[0]);
  3066.  
  3067.                         /* Loop until all data has been processed. */
  3068.  
  3069. Loop:                        do
  3070.                         {
  3071.                             /* Check how many bytes are still in
  3072.                              * the serial buffer.
  3073.                              */
  3074.  
  3075.                             WriteRequest -> IOSer . io_Command = SDCMD_QUERY;
  3076.                             DoIO(WriteRequest);
  3077.  
  3078.                             if(Length = WriteRequest -> IOSer . io_Actual)
  3079.                             {
  3080.                                 if(Length > SERBUFF_SIZE)
  3081.                                     Length = SERBUFF_SIZE;
  3082.  
  3083.                                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  3084.                                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  3085.                                 ReadRequest -> IOSer . io_Length    = Length;
  3086.  
  3087.                                 DoIO(ReadRequest);
  3088.  
  3089.                                 /* Send the data to the console. */
  3090.  
  3091.                                 ConProcess(ReadBuffer,Length);
  3092.  
  3093.                                 if(Matching == NULL)
  3094.                                 {
  3095.                                     for(i = 0 ; i < Length ; i++)
  3096.                                     {
  3097.                                         if(Matching = SequenceFilter(((UBYTE *)ReadBuffer)[i]))
  3098.                                             break;
  3099.                                     }
  3100.                                 }
  3101.                             }
  3102.                         }
  3103.                         while(Length);
  3104.  
  3105.                         /* Ask for another byte. */
  3106.  
  3107.                         ReadRequest -> IOSer . io_Command    = CMD_READ;
  3108.                         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  3109.                         ReadRequest -> IOSer . io_Length     = 1;
  3110.  
  3111.                         SendIO(ReadRequest);
  3112.                     }
  3113.                 }
  3114.             }
  3115.  
  3116.                 /* Timeout has occured. */
  3117.  
  3118.             if(SignalSet & SIG_TIMER)
  3119.                 break;
  3120.  
  3121.                 /* We've made a match! */
  3122.  
  3123.             if(Matching)
  3124.                 break;
  3125.         }
  3126.  
  3127.             /* Is the timer still active? If so, cancel it. */
  3128.  
  3129.         if(!CheckIO(TimeRequest))
  3130.             AbortIO(TimeRequest);
  3131.  
  3132.             /* Wait for timer to return. */
  3133.  
  3134.         WaitIO(TimeRequest);
  3135.  
  3136.             /* Determine the result code if a match has been
  3137.              * made.
  3138.              */
  3139.  
  3140.         if(Matching)
  3141.             strcpy(RexxTextBuffer,Matching -> Sequence);
  3142.         else
  3143.             RexxTextBuffer[0] = 0;
  3144.     }
  3145.  
  3146.         /* Clear the list of sequences to check. */
  3147.  
  3148.     ClearSequenceObjects();
  3149.  
  3150.     return(RexxTextBuffer);
  3151. }
  3152.  
  3153. UBYTE *
  3154. RexxToneDial(UBYTE *String)
  3155. {
  3156.     if(ToneDial(String))
  3157.         DeleteTone();
  3158.     else
  3159.         RexxRes1 = RC_ERROR;
  3160.  
  3161.     return(NULL);
  3162. }
  3163.  
  3164. UBYTE *
  3165. RexxSimpleRequest(UBYTE *String)
  3166. {
  3167.     BlockWindows();
  3168.  
  3169.     MyEasyRequest(Window,String,"Continue");
  3170.  
  3171.     ReleaseWindows();
  3172.  
  3173.     return(NULL);
  3174. }
  3175.  
  3176. UBYTE *
  3177. RexxTwoGadRequest(UBYTE *String)
  3178. {
  3179.     BYTE Result;
  3180.  
  3181.     BlockWindows();
  3182.  
  3183.     Result = MyEasyRequest(Window,String,"Yes|No");
  3184.  
  3185.     ReleaseWindows();
  3186.  
  3187.     if(Result)
  3188.         return("YES");
  3189.     else
  3190.         return("NO");
  3191. }
  3192.  
  3193. UBYTE *
  3194. RexxFileRequest(UBYTE *String)
  3195. {
  3196.     struct AslFileRequest *FileRequest;
  3197.  
  3198.     BlockWindows();
  3199.  
  3200.     MoveScreen(Screen,0,-Screen -> TopEdge);
  3201.  
  3202.     ScreenToFront(Screen);
  3203.  
  3204.     if(FileRequest = GetFile(String,"","",RexxTextBuffer,NULL,FALSE,FALSE,FALSE,NULL))
  3205.     {
  3206.         if(RexxTextBuffer[0])
  3207.         {
  3208.             FreeAslRequest(FileRequest);
  3209.  
  3210.             ReleaseWindows();
  3211.  
  3212.             return(RexxTextBuffer);
  3213.         }
  3214.         else
  3215.         {
  3216.             FreeAslRequest(FileRequest);
  3217.  
  3218.             ReleaseWindows();
  3219.  
  3220.             return(NULL);
  3221.         }
  3222.     }
  3223.     else
  3224.     {
  3225.         ReleaseWindows();
  3226.  
  3227.         return(NULL);
  3228.     }
  3229. }
  3230.  
  3231. UBYTE *
  3232. RexxSpeak(UBYTE *String)
  3233. {
  3234.     Say(String);
  3235.  
  3236.     return(NULL);
  3237. }
  3238.  
  3239. VOID
  3240. Rexx2Front()
  3241. {
  3242.     if(RexxWindow)
  3243.         BumpWindow(RexxWindow);
  3244. }
  3245.  
  3246. VOID
  3247. Term2Front()
  3248. {
  3249.     BumpWindow(Window);
  3250. }
  3251.  
  3252. VOID
  3253. Display2Front()
  3254. {
  3255.     if(BufferProcess)
  3256.         Signal(BufferProcess,SIGBREAKF_CTRL_D);
  3257. }
  3258.  
  3259. VOID
  3260. CloseDisplay()
  3261. {
  3262.     if(BufferProcess)
  3263.         Signal(BufferProcess,SIGBREAKF_CTRL_C);
  3264. }
  3265.  
  3266. VOID
  3267. QuietExit()
  3268. {
  3269.     ExitQuietly = TRUE;
  3270. }
  3271.  
  3272.     /* RexxASyncCommand(struct RexxMsg *RexxMsg):
  3273.      *
  3274.      *    This routine handles the asynchronous Rexx
  3275.      *    commands and complains if the command passed
  3276.      *    to it cannot be executed asynchronously.
  3277.      */
  3278.  
  3279. BYTE
  3280. RexxASyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3281. {
  3282.     LONG    ArgCount = 0;
  3283.     STRPTR    StringResult = NULL;
  3284.     WORD    i;
  3285.     LONG    RexxRes1 = RC_OK;
  3286.  
  3287.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3288.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3289.  
  3290.     if(!Stricmp(Arg1,"QUERY"))
  3291.     {
  3292.         if(!Stricmp(Arg2,"COLOUR"))
  3293.         {
  3294.             LONG Colour;
  3295.  
  3296.             GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3297.  
  3298.             Colour = atol(Arg1);
  3299.  
  3300.             if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  3301.             {
  3302.                 SPrintf(RexxTextBuffer,"%03lx",Config . Colours[Colour]);
  3303.  
  3304.                 StringResult = RexxTextBuffer;
  3305.             }
  3306.             else
  3307.                 RexxRes1 = RC_ERROR;
  3308.         }
  3309.         else
  3310.         {
  3311.             if(!Stricmp(Arg2,"MACRO"))
  3312.             {
  3313.                 LONG Value,Qualifier = -1;
  3314.  
  3315.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3316.  
  3317.                 for(i = 0 ; i < 4 ; i++)
  3318.                 {
  3319.                     if(!Stricmp(Qualifiers[i],Arg2))
  3320.                     {
  3321.                         Qualifier = i;
  3322.                         break;
  3323.                     }
  3324.                 }
  3325.  
  3326.                 if(Qualifier != -1)
  3327.                 {
  3328.                     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3329.  
  3330.                     Value = atol(Arg2);
  3331.  
  3332.                     if(Value >= 0 && Value <= 9)
  3333.                         StringResult = MacroKeys -> Keys[Qualifier][Value];
  3334.                     else
  3335.                         RexxRes1 = RC_ERROR;
  3336.                 }
  3337.                 else
  3338.                     RexxRes1 = RC_ERROR;
  3339.             }
  3340.             else
  3341.             {
  3342.                 for(i = 0 ; i < NUMQUERIES ; i++)
  3343.                 {
  3344.                     if(!Stricmp(Arg2,QueryCommands[i] . String))
  3345.                         StringResult = QueryCommands[i] . Routine();
  3346.                 }
  3347.             }
  3348.         }
  3349.     }
  3350.     else
  3351.     {
  3352.         for(i = 0 ; i < NUMASYNCS ; i++)
  3353.         {
  3354.             if(!Stricmp(Arg1,ASyncCommands[i] . String))
  3355.             {
  3356.                 ASyncCommands[i] . Routine();
  3357.  
  3358.                 i = -1;
  3359.  
  3360.                 break;
  3361.             }
  3362.         }
  3363.  
  3364.         if(i != -1)
  3365.             return(FALSE);
  3366.     }
  3367.  
  3368.     ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3369.  
  3370.     return(TRUE);
  3371. }
  3372.  
  3373.     /* RexxSyncCommand(struct RexxMsg *RexxMsg):
  3374.      *
  3375.      *    Handles the synchronous Rexx commands and returns the
  3376.      *    message if no matching command is found.
  3377.      */
  3378.  
  3379. VOID
  3380. RexxSyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3381. {
  3382.     LONG    ArgCount = 0,Count2;
  3383.     STRPTR    StringResult = NULL;
  3384.     WORD    i;
  3385.  
  3386.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3387.  
  3388.         /* Save position of second argument for the
  3389.          * Rexx commands.
  3390.          */
  3391.  
  3392.     Count2 = ArgCount;
  3393.  
  3394.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3395.  
  3396.     RexxRes1 = RC_OK;
  3397.  
  3398.         /* Look if it's a `set' command. */
  3399.  
  3400.     if(!Stricmp(Arg1,"SET"))
  3401.     {
  3402.         for(i = 0 ; i < SETMOREPARAMS ; i++)
  3403.         {
  3404.             if(!Stricmp(Arg2,SetCommands[i] . String))
  3405.             {
  3406.                 SetCommands[i] . Routine(&RexxMsg -> rm_Args[0][ArgCount]);
  3407.  
  3408.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3409.  
  3410.                 return;
  3411.             }
  3412.         }
  3413.  
  3414.         for(i = SETMOREPARAMS ; i < NUMSETS ; i++)
  3415.         {
  3416.             if(!Stricmp(Arg2,SetCommands[i] . String))
  3417.             {
  3418.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3419.  
  3420.                 SetCommands[i] . Routine(Arg2);
  3421.  
  3422.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3423.  
  3424.                 return;
  3425.             }
  3426.         }
  3427.     }
  3428.  
  3429.     for(i = 0 ; i < REXXMOREPARAMS ; i++)
  3430.     {
  3431.         if(!Stricmp(Arg1,RexxCommands[i] . String))
  3432.         {
  3433.             StringResult = RexxCommands[i] . Routine(&RexxMsg -> rm_Args[0][Count2]);
  3434.  
  3435.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3436.  
  3437.             return;
  3438.         }
  3439.     }
  3440.  
  3441.     for(i = REXXMOREPARAMS ; i < NUMREXX ; i++)
  3442.     {
  3443.         if(!Stricmp(Arg1,RexxCommands[i] . String))
  3444.         {
  3445.             StringResult = RexxCommands[i] . Routine(Arg2);
  3446.  
  3447.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3448.  
  3449.             return;
  3450.         }
  3451.     }
  3452.  
  3453.     ReplyRexxCommand(RexxMsg,RC_ERROR,0,NULL);
  3454. }
  3455.  
  3456.     /* RexxServer(VOID):
  3457.      *
  3458.      *    Asynchronous ARexx host server.
  3459.      */
  3460.  
  3461. VOID __saveds
  3462. RexxServer(VOID)
  3463. {
  3464.     UBYTE         Arg1[80],Arg2[80];
  3465.  
  3466.     struct MsgPort    *RexxPort;
  3467.     struct RexxMsg    *RexxMsg;
  3468.  
  3469.     ULONG         SignalSet;
  3470.  
  3471.     BYTE         Terminated = FALSE;
  3472.  
  3473.         /* Create the public host port. */
  3474.  
  3475.     if(RexxPort = (struct MsgPort *)CreateMsgPort())
  3476.     {
  3477.         RexxPort -> mp_Node . ln_Name    = TermIDString;
  3478.         RexxPort -> mp_Node . ln_Pri    = 1;
  3479.  
  3480.             /* Make it a public port. */
  3481.  
  3482.         AddPort(RexxPort);
  3483.  
  3484.             /* Signal our father that we're running. */
  3485.  
  3486.         Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3487.  
  3488.             /* Go into loop and wait for input. */
  3489.  
  3490.         while(!Terminated)
  3491.         {
  3492.             SignalSet = Wait(SIGBREAKF_CTRL_C | (1 << RexxPort -> mp_SigBit));
  3493.  
  3494.                 /* This is probably a Rexx command. */
  3495.  
  3496.             if(SignalSet & (1 << RexxPort -> mp_SigBit))
  3497.             {
  3498.                     /* Pick up all the messages. */
  3499.  
  3500.                 while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3501.                 {
  3502.                     Arg1[0] = Arg2[0] = 0;
  3503.  
  3504.                         /* At first try to run the
  3505.                          * command asynchronously.
  3506.                          * If this turns out to be
  3507.                          * somewhat `impossible' pass
  3508.                          * it to the `term' main process
  3509.                          * or - if in batch mode - try
  3510.                          * to deal with the message
  3511.                          * on our own.
  3512.                          */
  3513.  
  3514.                     if(!RexxASyncCommand(RexxMsg,Arg1,Arg2))
  3515.                     {
  3516.                         if(!BatchMode)
  3517.                             PutMsg(TermRexxPort,RexxMsg);
  3518.                         else
  3519.                             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3520.                     }
  3521.                 }
  3522.             }
  3523.  
  3524.             if(SignalSet & SIGBREAKF_CTRL_C)
  3525.                 Terminated = TRUE;
  3526.         }
  3527.  
  3528.         Forbid();
  3529.  
  3530.         while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3531.             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3532.  
  3533.         RemPort(RexxPort);
  3534.  
  3535.         DeleteMsgPort(RexxPort);
  3536.     }
  3537.  
  3538.     Forbid();
  3539.  
  3540.     RexxProcess = NULL;
  3541.  
  3542.     Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3543. }
  3544.  
  3545.     /* HandleRexx():
  3546.      *
  3547.      *    Tiny & simple subroutine to read and examine all
  3548.      *    messages coming in to be processed synchronously
  3549.      *    by the `term' main process.
  3550.      */
  3551.  
  3552. VOID
  3553. HandleRexx()
  3554. {
  3555.     struct RexxMsg    *RexxMsg;
  3556.     UBYTE         Arg1[80],Arg2[256];
  3557.  
  3558.     while(RexxMsg = (struct RexxMsg *)GetMsg(TermRexxPort))
  3559.     {
  3560.         Arg1[0] = Arg2[0] = 0;
  3561.  
  3562.         RexxSyncCommand(RexxMsg,Arg1,Arg2);
  3563.     }
  3564. }
  3565.