home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / util / moni / snoopdos / source / settings.c < prev    next >
C/C++ Source or Header  |  1994-09-17  |  52KB  |  1,907 lines

  1. /*
  2.  *        SETTINGS.C                                            vi:ts=4
  3.  *
  4.  *      Copyright (c) Eddy Carroll, September 1994.
  5.  *
  6.  *        This module handles all the command parsing for tooltypes, command
  7.  *        line options, config files, AREXX, etc.
  8.  */        
  9.  
  10. #include "system.h"
  11. #include "snoopdos.h"
  12.  
  13. extern char Version[];            /* From Snoopdos.c */
  14. extern char CommodityTitle[];    /* From Snoopdos.c */
  15.  
  16. char ConfigID[] = "<SnoopDos Settings>";
  17.  
  18. ULONG            UpdateFlags;        /* Shows what settings were changed        */
  19. struct MsgPort *RemoteReplyPort;    /* Used when talking to b/g SnoopDos    */
  20.  
  21. /*
  22.  *        Now the result codes returned by our simple command interpreter
  23.  */
  24. typedef enum {
  25.     EXEC_FAIL,            /* The command failed for some reason    */
  26.     EXEC_OKAY,            /* The command succeeded                */
  27.     EXEC_UNKNOWN,        /* The command wasn't recognised        */
  28.     EXEC_NOPARAM        /* The command was missing a parameter    */
  29. } ExecEnum;
  30.  
  31. /*
  32.  *        Now let's define the commands we understand.
  33.  */
  34. #define CMD_UNKNOWN        -1
  35. #define CMD_NOPARAM        -2
  36.  
  37. typedef enum {
  38.     CMD_END,
  39.  
  40.     /*
  41.      *        Options within function requester. Note that these MUST correspond
  42.      *        exactly with the first set of enums in SNOOPDOS.H for GID_???!
  43.      */
  44.     CMD_FINDPORT,
  45.     CMD_FINDRESIDENT,
  46.     CMD_FINDSEMAPHORE,
  47.     CMD_FINDTASK,
  48.     CMD_LOCKSCREEN,
  49.     CMD_OPENDEVICE,
  50.     CMD_OPENFONT,
  51.     CMD_OPENLIBRARY,
  52.     CMD_OPENRESOURCE,
  53.     CMD_READTOOLTYPES,
  54.     CMD_SENDREXX,
  55.  
  56.     CMD_CHANGEDIR,
  57.     CMD_DELETE,
  58.     CMD_EXECUTE,
  59.     CMD_GETVAR,
  60.     CMD_LOADSEG,
  61.     CMD_LOCK,
  62.     CMD_MAKEDIR,
  63.     CMD_MAKELINK,
  64.     CMD_OPEN,
  65.       CMD_RENAME,
  66.       CMD_RUNCOMMAND,
  67.       CMD_SETVAR,
  68.     CMD_DOSSYSTEM,        /* CMD_SYSTEM is defined in dos/dosextens.h    */
  69.  
  70.     CMD_DUMMY1,
  71.     CMD_DUMMY2,
  72.     CMD_DUMMY3,
  73.     CMD_DUMMY4,
  74.     CMD_DUMMY5,
  75.  
  76.     CMD_ONLYSHOWFAILS,
  77.     CMD_SHOWCLI,
  78.     CMD_SHOWFULLPATH,
  79.     CMD_USEDEVICENAME,
  80.     CMD_MONITORPACKETS,
  81.     CMD_MONALLPACKETS,
  82.     CMD_MONROMCALLS,
  83.     CMD_IGNORESHELL,
  84.  
  85. #define MAX_BOOL_CMD            CMD_IGNORESHELL
  86.  
  87.     CMD_MATCHNAME,
  88.  
  89.     /*
  90.      *        General commands
  91.      */
  92.     CMD_LOADSETTINGS,
  93.     CMD_SAVESETTINGS,
  94.     CMD_LOADDEFSETTINGS,
  95.     CMD_SAVEDEFSETTINGS,
  96.     CMD_SETTINGS,
  97.     CMD_FUNCTIONS,
  98.     CMD_LANGUAGE,
  99.     CMD_CLEARBUFFER,
  100.     CMD_WINDOWWIDTH,
  101.     CMD_HELP,
  102.     CMD_COPYWINDOW,
  103.     CMD_COPYBUFFER,
  104.     CMD_SAVEWINDOW,
  105.     CMD_SAVEBUFFER,
  106.     CMD_SHOW,
  107.     CMD_HIDE,
  108.     CMD_OPENFORMAT,
  109.     CMD_OPENFUNCTION,
  110.     CMD_OPENSETUP,
  111.     CMD_CLOSEFORMAT,
  112.     CMD_CLOSEFUNCTION,
  113.     CMD_CLOSESETUP,
  114.     CMD_QUIT,
  115.     CMD_PAUSE,
  116.     CMD_UNPAUSE,
  117.     CMD_DISABLE,
  118.     CMD_ENABLE,
  119.     CMD_SINGLESTEP,
  120.     CMD_OPENLOG,
  121.     CMD_APPENDLOG,
  122.     CMD_OPENSERIALLOG,
  123.     CMD_CLOSELOG,
  124.     CMD_ADDLOG,
  125.     CMD_FLUSHLOG,
  126.     CMD_SCROLLUP,
  127.     CMD_SCROLLDOWN,
  128.     CMD_GOTO,
  129.  
  130.     /*
  131.      *        General settings
  132.      */
  133.     CMD_PATCHRAMLIB,
  134.     CMD_STACKLIMIT,
  135.     CMD_ICONPOS,
  136.     CMD_SHOWGADGETS,
  137.     CMD_HIDEGADGETS,
  138.     CMD_AUTOOPEN,
  139.     CMD_DISABLEWHENHIDDEN,
  140.     CMD_SHOWSTATUS,
  141.     CMD_HIDESTATUS,
  142.     CMD_CREATEICONS,
  143.     CMD_TEXTSPACING,
  144.     CMD_SIMPLEREFRESH,
  145.     CMD_SMARTREFRESH,
  146.     CMD_LEFTALIGNED,
  147.     CMD_RIGHTALIGNED,
  148.     CMD_ROWQUALIFIER,
  149.     CMD_MAINPOS,
  150.     CMD_MAINSIZE,
  151.     CMD_FUNCPOS,
  152.     CMD_FORMPOS,
  153.     CMD_SETPOS,
  154.     CMD_TASKPRI,
  155.     CMD_CXPRI,
  156.  
  157.     /*
  158.      *        Options within setup requester
  159.      */
  160.     CMD_HIDEMETHOD,
  161.     CMD_SCREENTYPE,
  162.     CMD_BUFFERSIZE,
  163.     CMD_LOGMODE,
  164.     CMD_FILEIOTYPE,
  165.     CMD_FORMAT,
  166.     CMD_LOGFORMAT,
  167.     CMD_HOTKEY,
  168.     CMD_SCREENNAME,
  169.     CMD_LOGNAME,
  170.     CMD_WINDOWFONT,
  171.     CMD_BUFFERFONT,
  172.  
  173.     NUMCOMMANDS
  174.  
  175. } COMMAND_ID;
  176.  
  177.  
  178. /*
  179.  *        Now associate a command string with each of these identifiers
  180.  */
  181. struct Command {
  182.     short    cmdid;            /* Command ID                            */
  183.     short    changemask;        /* Which group of settings will change    */
  184.     short    numparms;        /* Min number of parameters (0 or more)    */
  185.     char    *name;            /* Command name                            */
  186. } CommandTable[] = {
  187.     /*
  188.      *        In alphabetical order, for quick reference
  189.      */
  190.     CMD_ADDLOG,                SET_NONE,    1, "AddLog",
  191.     CMD_APPENDLOG,            SET_NONE,    1, "AppendLog",
  192.     CMD_AUTOOPEN,            SET_MAIN,    0, "AutoOpen",
  193.     CMD_BUFFERFONT,         SET_SETUP,     1, "BufferFont",
  194.     CMD_BUFFERSIZE,         SET_SETUP,     1, "BufferSize",
  195.     CMD_CHANGEDIR,            SET_FUNC,    0, "ChangeDir",
  196.     CMD_CLEARBUFFER,        SET_FUNC,    0, "ClearBuffer",
  197.     CMD_CLOSEFORMAT,        SET_NONE,    0, "CloseFormat",
  198.     CMD_CLOSEFUNCTION,        SET_NONE,    0, "CloseFunction",
  199.     CMD_CLOSELOG,            SET_NONE,    0, "CloseLog",
  200.     CMD_CLOSESETUP,         SET_NONE,    0, "CloseSetup",
  201.     CMD_COPYBUFFER,         SET_NONE,    0, "CopyBuffer",
  202.     CMD_COPYWINDOW,         SET_NONE,    0, "CopyWindow",
  203.     CMD_CREATEICONS,        SET_MAIN,    0, "CreateIcons",
  204.     CMD_HOTKEY,                SET_SETUP,    1, "CX_PopKey",
  205.     CMD_SHOW,                SET_NONE,    0, "CX_Popup",
  206.     CMD_CXPRI,                SET_NONE,    1, "CX_Priority",
  207.     CMD_DELETE,             SET_FUNC,    0, "Delete",
  208.     CMD_DISABLE,            SET_NONE,    0, "Disable",
  209.     CMD_DISABLEWHENHIDDEN,    SET_MAIN,    0, "DisableWhenHidden",
  210.     CMD_ENABLE,             SET_NONE,    0, "Enable",
  211.     CMD_EXECUTE,            SET_FUNC,    0, "Execute",
  212.     CMD_FILEIOTYPE,         SET_SETUP,    1, "FileIOType",
  213.     CMD_FINDPORT,            SET_FUNC,    0, "FindPort",
  214.     CMD_FINDRESIDENT,        SET_FUNC,    0, "FindResident",
  215.     CMD_FINDSEMAPHORE,        SET_FUNC,    0, "FindSemaphore",
  216.     CMD_FINDTASK,            SET_FUNC,    0, "FindTask",
  217.     CMD_FLUSHLOG,            SET_NONE,    0, "FlushLog",
  218.     CMD_FORMAT,             SET_SETUP,    1, "Format",
  219.     CMD_FORMPOS,            SET_MAIN,    1, "FormatWindowPos",
  220.     CMD_FUNCTIONS,            SET_FUNC,    1, "Functions",
  221.     CMD_FUNCPOS,            SET_MAIN,    1, "FunctionWindowPos",
  222.     CMD_GETVAR,             SET_FUNC,    0, "GetVar",
  223.     CMD_GOTO,                SET_NONE,    1, "GotoLine",
  224.     CMD_HELP,                SET_NONE,    0, "Help",
  225.     CMD_HIDE,                SET_NONE,    0, "Hide",
  226.     CMD_HIDEGADGETS,        SET_MAIN,    0, "HideGadgets",
  227.     CMD_HIDEMETHOD,         SET_SETUP,    1, "HideMethod",
  228.     CMD_HIDESTATUS,         SET_MAIN,    0, "HideStatus",
  229.     CMD_HOTKEY,             SET_SETUP,    1, "HotKey",
  230.     CMD_ICONPOS,            SET_MAIN,    1, "IconPos",
  231.     CMD_IGNORESHELL,        SET_FUNC,    0, "IgnoreShell",
  232.     CMD_LANGUAGE,            SET_NONE,    1, "Language",
  233.     CMD_LEFTALIGNED,        SET_MAIN,    0, "LeftAligned",
  234.     CMD_LOADDEFSETTINGS,    SET_NONE,    0, "LoadDefSettings",
  235.     CMD_LOADSEG,            SET_FUNC,    0, "LoadSeg",
  236.     CMD_LOADSETTINGS,         SET_NONE,    1, "LoadSettings",
  237.     CMD_LOCK,                SET_FUNC,    0, "Lock",
  238.     CMD_LOCKSCREEN,         SET_FUNC,    0, "LockScreen",
  239.     CMD_LOGFORMAT,            SET_SETUP,    1, "LogFormat",
  240.     CMD_LOGMODE,            SET_SETUP,    1, "LogMode",
  241.     CMD_LOGNAME,            SET_SETUP,    1, "LogName",
  242.     CMD_MAINPOS,            SET_MAIN,    1, "MainWindowPos",
  243.     CMD_MAINSIZE,            SET_MAIN,    1, "MainWindowSize",
  244.     CMD_MAKEDIR,            SET_FUNC,    0, "MakeDir",
  245.     CMD_MAKELINK,            SET_FUNC,    0, "MakeLink",
  246.     CMD_MATCHNAME,            SET_FUNC,    1, "MatchName",
  247.     CMD_MONITORPACKETS,     SET_FUNC,    0, "MonitorPackets",
  248.     CMD_MONROMCALLS,        SET_FUNC,    0, "MonitorROMCalls",
  249.     CMD_ONLYSHOWFAILS,        SET_FUNC,    0, "OnlyShowFails",
  250.     CMD_OPEN,                SET_FUNC,    0, "Open",
  251.     CMD_OPENDEVICE,         SET_FUNC,    0, "OpenDevice",
  252.     CMD_OPENFONT,            SET_FUNC,    0, "OpenFont",
  253.     CMD_OPENFORMAT,         SET_NONE,    0, "OpenFormat",
  254.     CMD_OPENFUNCTION,        SET_NONE,    0, "OpenFunction",
  255.     CMD_OPENLIBRARY,        SET_FUNC,    0, "OpenLibrary",
  256.     CMD_OPENLOG,            SET_NONE,    1, "OpenLog",
  257.     CMD_OPENRESOURCE,        SET_FUNC,    0, "OpenResource",
  258.     CMD_OPENSERIALLOG,        SET_NONE,    0, "OpenSerialLog",
  259.     CMD_OPENSETUP,            SET_NONE,    0, "OpenSetup",
  260.     CMD_MONALLPACKETS,        SET_FUNC,    0, "PacketDebugger",
  261.     CMD_PATCHRAMLIB,        SET_NONE,    0, "PatchRamLib",
  262.     CMD_PAUSE,                SET_NONE,    0, "Pause",
  263.     CMD_QUIT,                SET_NONE,    0, "Quit",
  264.     CMD_READTOOLTYPES,        SET_FUNC,    0, "ReadToolTypes",
  265.     CMD_RENAME,             SET_FUNC,    0, "Rename",
  266.     CMD_RIGHTALIGNED,        SET_MAIN,    0, "RightAligned",
  267.     CMD_ROWQUALIFIER,        SET_MAIN,    1, "RowQualifier",
  268.     CMD_RUNCOMMAND,         SET_FUNC,    0, "RunCommand",
  269.     CMD_SAVEBUFFER,         SET_NONE,    1, "SaveBuffer",
  270.     CMD_SAVEDEFSETTINGS,      SET_NONE,    0, "SaveDefSettings",
  271.     CMD_SAVESETTINGS,         SET_NONE,    1, "SaveSettings",
  272.     CMD_SAVEWINDOW,         SET_NONE,    1, "SaveWindow",
  273.     CMD_SCREENNAME,         SET_SETUP,    1, "ScreenName",
  274.     CMD_SCREENTYPE,         SET_SETUP,    1, "ScreenType",
  275.     CMD_SCROLLDOWN,            SET_NONE,    1, "ScrollDown",
  276.     CMD_SCROLLUP,            SET_NONE,    1, "ScrollUp",
  277.     CMD_SENDREXX,            SET_FUNC,    0, "SendRexx",
  278.     CMD_SETTINGS,            SET_NONE,    1, "Settings",
  279.     CMD_SETPOS,             SET_MAIN,    1, "SetupWindowPos",
  280.     CMD_SETVAR,             SET_FUNC,    0, "SetVar",
  281.     CMD_SHOW,                SET_NONE,    0, "Show",
  282.     CMD_SHOWCLI,            SET_FUNC,    0, "ShowCLI",
  283.     CMD_SHOWFULLPATH,        SET_FUNC,    0, "ShowFullPath",
  284.     CMD_SHOWGADGETS,        SET_MAIN,    0, "ShowGadgets",
  285.     CMD_SHOWSTATUS,         SET_MAIN,    0, "ShowStatus",
  286.     CMD_SIMPLEREFRESH,        SET_MAIN,    0, "SimpleRefresh",
  287.     CMD_SINGLESTEP,            SET_NONE,    0, "SingleStep",
  288.     CMD_SMARTREFRESH,        SET_MAIN,    0, "SmartRefresh",
  289.     CMD_STACKLIMIT,            SET_MAIN,    1, "StackLimit",
  290.     CMD_DOSSYSTEM,            SET_FUNC,    0, "System",
  291.     CMD_TASKPRI,            SET_NONE,    1, "TaskPri",
  292.     CMD_TEXTSPACING,        SET_MAIN,    1, "TextSpacing",
  293.     CMD_UNPAUSE,            SET_NONE,    0, "Unpause",
  294.     CMD_USEDEVICENAME,        SET_FUNC,    0, "UseDevice