home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / comprgs / term232.lha / Source_Code / termSource / termRexx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-18  |  59.1 KB  |  3,703 lines

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