home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / xdme1820.lha / XDME / command.c < prev    next >
C/C++ Source or Header  |  1993-03-09  |  35KB  |  1,179 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     command.c
  5.  
  6.     DESCRIPTION
  7.     )c          single character (typing)
  8.     'c                single character (typing)
  9.     `string'          string of characters w/ embedded `' allowed!
  10.     (string)             same thing w/ embedded () allowed!
  11.     \c          override
  12.  
  13.     name arg arg      command name. The arguments are interpreted as
  14.               strings for the command.
  15.  
  16.     $scanf          macro insert scanf'd variable
  17.     $filename      macro insert current file name with the complete path
  18.     $file          macro insert current name filename
  19.     $path          macro insert complete path of current file
  20.     $currentdir      macro insert the base dir of XDME
  21.     $currentline      macro insert entire contents of current line
  22.     $colno          macro insert column number of cursor
  23.     $lineno       macro insert line number of cursor
  24.     $margin       macro insert current margin setting
  25.     $modified      macro insert 0/1 modified flag
  26.     $rexxport      macro insert rexx port name
  27.  
  28.     Any string arguments not part of a command are considered to be typed
  29.     text.
  30.  
  31.     NOTES
  32.  
  33.     BUGS
  34.  
  35.     TODO
  36.  
  37.     EXAMPLES
  38.  
  39.     SEE ALSO
  40.  
  41.     INDEX
  42.  
  43.     HISTORY
  44.     06. Dec 1992    ada created
  45.  
  46. ******************************************************************************/
  47.  
  48. /**************************************
  49.         Includes
  50. **************************************/
  51. #include "defs.h"
  52.  
  53.  
  54. /**************************************
  55.         Globale Variable
  56. **************************************/
  57. Prototype int     do_command   (char *);
  58. Prototype void     do_null      (void);
  59. Prototype void     do_source    (long);
  60. Prototype void     do_quit      (void);
  61. Prototype void     do_quitall   (void);
  62. Prototype void     do_execute   (void);
  63. Prototype char * breakout     (char **, char *, char **);
  64.  
  65. extern int foundcmd;       /* control for implicit ARexx macro invocation   */
  66. extern int cmderr;       /* global command error flag for do_rexx()'s use */
  67.  
  68.  
  69. /**************************************
  70.       Interne Defines & Strukturen
  71. **************************************/
  72. #define CF_COK    1   /*    Can be executed while in command line mode    */
  73. #define CF_PAR    2   /*    ESCIMM special flag.. save rest of command line */
  74.             /*    so it can be executed after user entry        */
  75. #define CF_ICO    4   /*    OK to execute if iconified, else uniconify first*/
  76. #define CF_VWM    8   /*    OK to execute if in viewmode, else abort    */
  77.  
  78. #define BTOCP(val, type)    ((type)((long)val << 2))
  79.  
  80. typedef void (*FPTR)(long);
  81.  
  82. typedef struct
  83. {
  84.     const char * name;    /* command name     */
  85.     ubyte args;     /* number of arguments    */
  86.     ubyte flags;    /* flags        */
  87.     FPTR func;        /* c-function        */
  88. } COMM;
  89.  
  90. #define MAXIA        5
  91.  
  92.  
  93. /**************************************
  94.         Interne Variable
  95. **************************************/
  96.         /*      args         flags      */
  97.  
  98. static CONST COMM Comm[] =
  99. {
  100.     "abort",         0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_abort,
  101.     "activatefront", 1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_activefront,
  102.     "add",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  103.     "addpath",       1,        CF_VWM|CF_ICO, (FPTR)do_addpath,
  104.     "appendsave",    1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_appendsave,
  105.     "arpfont",       0,               CF_VWM, (FPTR)do_aslfont,
  106.     "arpinsfile",    0,                    0, (FPTR)do_aslinsfile,
  107.     "arpload",       0,               CF_VWM, (FPTR)do_aslload,
  108.     "arpsave",       0,        CF_VWM|CF_ICO, (FPTR)do_aslsave,
  109.     "autoindent",    1,        CF_VWM|CF_ICO, (FPTR)do_autoindent,
  110.     "autosplit",     1,        CF_VWM|CF_ICO, (FPTR)do_autosplit,
  111.     "autounblock",   1,        CF_VWM|CF_ICO, (FPTR)do_autounblock,
  112.     "back",          0,               CF_COK, (FPTR)do_bs,
  113.     "backtab",       0,        CF_VWM|CF_COK, (FPTR)do_backtab,
  114.     "bappendsave",   0, CF_VWM|CF_COK|CF_ICO, (FPTR)do_bappendsave,
  115.     "barpsave",      0,        CF_VWM|CF_ICO, (FPTR)do_barpsave,
  116.     "bbpen",         1,               CF_VWM, (FPTR)do_bbpen,
  117.     "bcopy",         0,                    0, (FPTR)do_bcopy,
  118.     "bdelete",       0,                    0, (FPTR)do_bdelete,
  119.     "bend",          0,               CF_VWM, (FPTR)do_block,    /* checks com name for mode */
  120.     "bgpen",         1,               CF_VWM, (FPTR)do_bgpen,
  121.     "block",         0,               CF_VWM, (FPTR)do_block,    /* checks com name for mode */
  122.     "blocktype",     1,               CF_VWM, (FPTR)do_blocktype,
  123.     "bmove",         0,                    0, (FPTR)do_bmove,
  124.     "bottom",        0,               CF_VWM, (FPTR)do_bottom,
  125.     "break",         0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_break,
  126.     "bs",            0,               CF_COK, (FPTR)do_bs,
  127.     "bsave",         1,        CF_VWM|CF_ICO, (FPTR)do_bsave,
  128.     "bsource",       0,        CF_VWM|CF_ICO, (FPTR)do_bsource,
  129.     "bstart",        0,               CF_VWM, (FPTR)do_block,    /* checks com name for mode */
  130.     "cd",            1,        CF_VWM|CF_ICO, (FPTR)do_cd,
  131.     "chfilename",    1,        CF_VWM|CF_ICO, (FPTR)do_chfilename,
  132.     "clipins",       0,               CF_COK, (FPTR)do_clipins,
  133.     "col",           1,        CF_VWM|CF_COK, (FPTR)do_col,
  134.     "continue",      0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_continue,
  135.     "copy",          0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_copy,
  136.     "ctags",         0,               CF_VWM, (FPTR)do_ctags,
  137.     "debug",         1,        CF_VWM|CF_ICO, (FPTR)do_debug,
  138.     "dec",           1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  139.     "del",           0,               CF_COK, (FPTR)do_bs,
  140.     "delete",        0,               CF_COK, (FPTR)do_delete,
  141.     "deline",        0,                    0, (FPTR)do_deline,
  142.     "delines",       1,                    0, (FPTR)do_delines,
  143.     "div",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  144.     "down",          0,        CF_VWM|CF_COK, (FPTR)do_down,
  145.     "downadd",       0,                    0, (FPTR)do_downadd,
  146.     "esc",           0,        CF_VWM|CF_COK, (FPTR)do_esc,
  147.     "escimm",        1,        CF_VWM|CF_PAR, (FPTR)do_esc,
  148.     "eval",          1,        CF_VWM|CF_COK, (FPTR)do_eval,
  149.     "execute",       1,        CF_VWM|CF_ICO, (FPTR)do_execute,
  150.     "fgpen",         1,               CF_VWM, (FPTR)do_fgpen,
  151. #ifdef PATCH_FILTER
  152.     "filter",        4, CF_VWM|CF_COK|CF_PAR, (FPTR)do_filter,
  153. #endif
  154.     "find",          1,               CF_VWM, (FPTR)do_find,     /* checks com name for mode */
  155.     "findr",         2,                    0, (FPTR)do_findr,    /* checks com name for mode */
  156.     "findstr",       1,               CF_VWM, (FPTR)do_findstr,  /* checks com name for mode */
  157.     "first",         0,        CF_VWM|CF_COK, (FPTR)do_firstcolumn,
  158.     "firstnb",       0,        CF_VWM|CF_COK, (FPTR)do_firstnb,
  159.     "followcursor",  1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_followcursor,
  160.     "force",         2,        CF_VWM|CF_COK, (FPTR)do_force,
  161.     "global",        1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_global,
  162.     "goto",          1,               CF_VWM, (FPTR)do_goto,
  163.     "hgpen",         1,               CF_VWM, (FPTR)do_hgpen,
  164.     "iconify",       0,        CF_VWM|CF_ICO, (FPTR)do_iconify,
  165.     "if",            2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_if,
  166.     "ifelse",        3, CF_VWM|CF_COK|CF_ICO, (FPTR)do_if,
  167.     "ignorecase",    1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_ignorecase,
  168.     "inc",           1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  169.     "indent",        2,                    0, (FPTR)do_indent,
  170.     "infixmode",     1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_infixmode,
  171.     "insert",        1,               CF_COK, (FPTR)do_insertwrite,
  172.     "insertmode",    1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_insertmode,
  173.     "insfile",       1,                    0, (FPTR)do_edit,
  174.     "insline",       0,                    0, (FPTR)do_insline,
  175.     "inslines",      1,                    0, (FPTR)do_inslines,
  176.     "join",          0,                    0, (FPTR)do_join,
  177.     "justify",       1,                    0, (FPTR)do_justify,
  178.     "keyload",       1,        CF_VWM|CF_ICO, (FPTR)do_keyload, /* tester */
  179.     "keysave",       1,        CF_VWM|CF_ICO, (FPTR)do_keysave, /* tester */
  180.     "last",          0,        CF_VWM|CF_COK, (FPTR)do_lastcolumn,
  181.     "left",          0,        CF_VWM|CF_COK, (FPTR)do_left,
  182.     "lineblock",     0,        CF_VWM|CF_ICO, (FPTR)do_block,
  183.     "macroload",     1,        CF_VWM|CF_ICO, (FPTR)do_macroload, /* tester */
  184.     "macrosave",     1,        CF_VWM|CF_ICO, (FPTR)do_macrosave, /* tester */
  185.     "makecursorvisible", 0,    CF_VWM|CF_COK, (FPTR)do_makecursorvisible,
  186.     "map",           2,        CF_VWM|CF_ICO, (FPTR)do_map,
  187.     "margin",        1,        CF_VWM|CF_ICO, (FPTR)do_margin,
  188.     "match",         0,        CF_VWM|CF_COK, (FPTR)do_match,
  189.     "math1",         2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unnamedmathfunc,
  190.     "math2",         3, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unnamedmathfunc,
  191.     "menuadd",       3,        CF_VWM|CF_ICO, (FPTR)do_itemadd,
  192.     "menubar",       1,        CF_VWM|CF_ICO, (FPTR)do_itembar,
  193.     "menucheck",     3,        CF_VWM|CF_ICO, (FPTR)do_itemcheck,
  194.     "menuclear",     0,        CF_VWM|CF_ICO, (FPTR)do_menuclear,
  195.     "menudel",       2,        CF_VWM|CF_ICO, (FPTR)do_delitem,
  196.     "menudelbar",    1,        CF_VWM|CF_ICO, (FPTR)do_delitembar,
  197.     "menudelhdr",    1,        CF_VWM|CF_ICO, (FPTR)do_delmenu,
  198.     "menudelsub",    3,        CF_VWM|CF_ICO, (FPTR)do_delsub,
  199.     "menudelsubar",  2,        CF_VWM|CF_ICO, (FPTR)do_delsubbar,
  200.     "menugetcheck",  3,        CF_VWM|CF_ICO, (FPTR)do_getcheckitem,
  201.     "menugetscheck", 4,        CF_VWM|CF_ICO, (FPTR)do_getchecksub,
  202.     "menuload",      1,        CF_VWM|CF_ICO, (FPTR)do_menuload, /* tester */
  203.     "menuoff",       0,        CF_VWM|CF_ICO, (FPTR)do_menuoff,
  204.     "menuon",        0,        CF_VWM|CF_ICO, (FPTR)do_menuon,
  205.     "menusave",      1,        CF_VWM|CF_ICO, (FPTR)do_menusave, /* tester */
  206.     "menusetcheck",  3,        CF_VWM|CF_ICO, (FPTR)do_setcheckitem,
  207.     "menusetscheck", 4,        CF_VWM|CF_ICO, (FPTR)do_setchecksub,
  208.     "menusubadd",    4,        CF_VWM|CF_ICO, (FPTR)do_subadd,
  209.     "menusubbar",    2,        CF_VWM|CF_ICO, (FPTR)do_subbar,
  210.     "menusubcheck",  4,        CF_VWM|CF_ICO, (FPTR)do_subcheck,
  211.     "mod",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  212.     "modified",      1,               CF_ICO, (FPTR)do_modified,
  213.     "mul",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  214.     "neg",           1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  215.     "newfile",       1,               CF_VWM, (FPTR)do_edit,   /* checks com name for mode */
  216.     "newkeytable",   1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_new_keytable,
  217.     "newmenustrip",  1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_new_menustrip,
  218.     "newwindow",     0,        CF_VWM|CF_ICO, (FPTR)do_newwindow,
  219.     "next",          0,               CF_VWM, (FPTR)do_find,
  220.     "nextr",         0,                    0, (FPTR)do_findr,
  221.     "not",           1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  222.     "null",          0,        CF_VWM|CF_COK, (FPTR)do_null,
  223.     "openwindow",    1,        CF_VWM|CF_ICO, (FPTR)do_openwindow,
  224.     "overwrite",     1,               CF_COK, (FPTR)do_insertwrite,
  225.     "pagedown",      0,               CF_VWM, (FPTR)do_page,
  226.     "pageleft",      0,               CF_VWM, (FPTR)do_page,
  227.     "pageright",     0,               CF_VWM, (FPTR)do_page,
  228.     "pageset",       1,        CF_VWM|CF_ICO, (FPTR)do_page,
  229.     "pageup",        0,               CF_VWM, (FPTR)do_page,
  230.     "pattern",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_pattern,
  231.     "pick",          1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_pop,
  232.     "pickvar",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_pickVAR,
  233.     "ping",          1,        CF_VWM|CF_ICO, (FPTR)do_ping,
  234.     "pong",          1,               CF_VWM, (FPTR)do_pong,
  235.     "pop",           1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_pop,
  236.     "popvar",        1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_popVAR,
  237.     "port",          2,        CF_VWM|CF_ICO, (FPTR)to_port,          /* HD Rexx */
  238.     "prev",          0,               CF_VWM, (FPTR)do_find,
  239.     "prevr",         0,                    0, (FPTR)do_findr,
  240.     "projectinfo",   0,        CF_VWM|CF_ICO, (FPTR)project_info,     /* HD */
  241.     "projectload",   0,        CF_VWM|CF_ICO, (FPTR)load_project,     /* HD */
  242.     "projectsave",   0,        CF_VWM|CF_ICO, (FPTR)save_project,     /* HD */
  243.     "pubscreen",     1,        CF_VWM|CF_ICO, (FPTR)set_pubscreen,
  244.     "purgevar",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_purgeVAR,
  245.     "push",          1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_push,
  246.     "pushvar",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_pushVAR,
  247.     "qualifier",     1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_qualifier,
  248.     "quiet",         1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_quiet,
  249.     "quit",          0,        CF_VWM|CF_ICO, (FPTR)do_quit,
  250.     "quitall",       0,        CF_VWM|CF_ICO, (FPTR)do_quitall,
  251.     "recall",        0,               CF_VWM, (FPTR)do_recall,
  252.     "recend",        0, CF_VWM|CF_ICO|CF_COK, (FPTR)end_recording, /* it is recommended to end a record by pressing Ctl-C */
  253.     "recplay",       0, CF_VWM|CF_ICO|CF_COK, (FPTR)replay_record,
  254.     "recsave",       1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_saverecord,
  255.     "recstart",      0, CF_VWM|CF_ICO|CF_COK, (FPTR)start_recording,
  256.     "redisplay",     0,               CF_VWM, (FPTR)text_redisplay,
  257.     "ref",           0,        CF_VWM|CF_ICO, (FPTR)do_refs,
  258.     "refctags",      0,        CF_VWM|CF_ICO, (FPTR)do_refctags,
  259.     "reformat",      0,                    0, (FPTR)do_reformat,
  260.     "rem"            1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_null,    /* comments in lines */
  261.     "remeol",        0,        CF_VWM|CF_COK, (FPTR)do_remeol,
  262.     "remkeytable",   1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_del_keytable,
  263.  /* "remmenustrip",  1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_del_menustrip, */ /* that function is not stable yet */
  264.     "rempath",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_rempath,
  265.     "repeat",        2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_repeat,
  266.     "replace",       0,                    0, (FPTR)do_replace,
  267.     "repstr",        1,        CF_VWM|CF_ICO, (FPTR)do_findstr,
  268.     "reqfont",       0,               CF_VWM, (FPTR)do_reqfont,
  269.     "reqinsfile",    0,                    0, (FPTR)do_reqinsfile,
  270.     "reqload",       0,               CF_VWM, (FPTR)do_reqload,
  271.     "reqsave",       0,        CF_VWM|CF_ICO, (FPTR)do_reqsave,
  272.     "resettoggle",   1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_toggle,
  273.     "resize",        2,               CF_VWM, (FPTR)do_resize,
  274.     "ret",           0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_retmacro,
  275.     "return",        0,               CF_COK, (FPTR)do_return,   /* special meaning in command line mode */
  276.     "right",         0,        CF_VWM|CF_COK, (FPTR)do_right,
  277.     "rx",            1,        CF_VWM|CF_ICO, (FPTR)do_rx,       /* explicit ARexx macro invocation      */
  278.     "rx1",           2,        CF_VWM|CF_ICO, (FPTR)do_rx1,      /* explicit, with 1 arg  to ARexx macro */
  279.     "rx2",           3,        CF_VWM|CF_ICO, (FPTR)do_rx2,      /* explicit, with 2 args to ARexx macro */
  280.     "rxresult",      1,        CF_VWM|CF_ICO, (FPTR)put_rexx_result,
  281. #ifdef PATCH_RXVARS
  282.     "rxset",         2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_setrexx,      /* explicit, with 1 arg  to ARexx macro */
  283. #endif /* PATCH_RXVARS */
  284.     "saveas",        1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_saveas,
  285.     "saveconfig",    0, CF_VWM|CF_COK|CF_ICO, (FPTR)do_saveconfig,
  286. //  "savemap",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_savemap,         /* checks com name for mode */
  287.     "saveold",       0, CF_VWM|CF_COK|CF_ICO, (FPTR)do_save,
  288. //  "savesmap",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_savemap,
  289.     "savetabs",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_savetabs,
  290.     "scanf",         1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_scanf,
  291.     "screenbottom",  0,               CF_VWM, (FPTR)do_screenbottom,
  292.     "screentop",     0,               CF_VWM, (FPTR)do_screentop,
  293.     "scrolldown",    0,               CF_VWM, (FPTR)do_scrolldown,
  294.     "scrollleft",    0,               CF_VWM, (FPTR)do_scroll,
  295.     "scrollright",   0,               CF_VWM, (FPTR)do_scroll,
  296.     "scrollup",      0,               CF_VWM, (FPTR)do_scrollup,
  297.     "select",        1,        CF_VWM|CF_ICO, (FPTR)select_window,      /* HD Rexx */
  298.     "set",           2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_set,
  299.     "setenv",        2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_setenv,
  300.     "setfont",       2,               CF_VWM, (FPTR)do_setfont,
  301.     "setgeometry",   4,               CF_VWM, (FPTR)do_setgeometry,
  302.     "setmacro",      3, CF_VWM|CF_ICO|CF_COK, (FPTR)do_setmacro,
  303.     "setmacrovar",   2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_setmacrovar,
  304.     "setparcol",     1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_setparcol,
  305.     "settoggle",     1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_toggle,
  306.     "settvar",       2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_settvar,
  307.     "sizewindow",    1,        CF_VWM|CF_COK, (FPTR)do_sizewindow,
  308.     "smv",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_setmacrovar,
  309.     "source",        1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_source,
  310.     "sourcebreaks",  1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_sourcebreak,
  311.     "spacing",       1,               CF_VWM, (FPTR)do_setlinedistance,
  312.     "split",         0,                    0, (FPTR)do_split,
  313.     "sub",           2, CF_VWM|CF_ICO|CF_COK, (FPTR)do_namedmathfunc,
  314.     "swap",          1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_swap,
  315.     "swapvar",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_swapVAR,
  316.     "tab",           0,        CF_VWM|CF_COK, (FPTR)do_tab,
  317.     "tabstop",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_tabstop,
  318.     "taskpri",       1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_taskpri,
  319.     "title",         1,        CF_VWM|CF_ICO, (FPTR)do_title,
  320.     "tlate",         1,               CF_COK, (FPTR)do_tlate,
  321.     "toggle",        1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_toggle,
  322.     "tomouse",       0,               CF_VWM, (FPTR)do_tomouse,
  323.     "top",           0,               CF_VWM, (FPTR)do_top,
  324.     "tpen",          1,               CF_VWM, (FPTR)do_tpen,
  325.     "unabort",       0, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unabort,
  326.     "unblock",       0,        CF_VWM|CF_ICO, (FPTR)do_block,
  327.     "undeline",      0,                    0, (FPTR)do_undeline,
  328.     "undo",          0,                    0, (FPTR)do_undo,
  329.     "uniconify",     0,        CF_VWM|CF_ICO, (FPTR) uniconify,     /* PATCH_NULL [14 Feb 1993] : added */
  330.     "unjustify",     0,                    0, (FPTR)do_unjustify,
  331.     "unmap",         1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_unmap,
  332.     "unset",         1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_unset,
  333.     "unsetenv",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_unsetenv,
  334.     "unsetmacro",    1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unsetmacro,
  335.     "unsetmacrovar", 1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unsetmacrovar,
  336.     "unsettvar",     1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_unsettvar,
  337.     "up",            0,        CF_VWM|CF_COK, (FPTR)do_up,
  338.     "usekeytable",   1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_use_keytable,
  339.     "usemenustrip",  1, CF_VWM|CF_ICO|CF_COK, (FPTR)do_use_menustrip,
  340.     "vctags",        1,        CF_VWM|CF_ICO, (FPTR)do_ctags,
  341.     "viewmode",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_viewmode,
  342.     "vref",          1,        CF_VWM|CF_ICO, (FPTR)do_refs,
  343.     "vrefctags",     1,        CF_VWM|CF_ICO, (FPTR)do_refctags,
  344.     "while",         2, CF_VWM|CF_COK|CF_ICO, (FPTR)do_if,
  345.     "windowcycling", 1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_windowcyc,
  346.     "wleft",         0,        CF_VWM|CF_COK, (FPTR)do_wleft,
  347.     "wordwrap",      1, CF_VWM|CF_COK|CF_ICO, (FPTR)do_wordwrap,
  348.     "wright",        0,        CF_VWM|CF_COK, (FPTR)do_wright
  349. };
  350.  
  351. static CONST COMM repcmd =
  352. {
  353.     "repeat",        2, CF_COK|CF_ICO, (FPTR)do_repeat,
  354. };
  355.  
  356.  
  357. /**************************************
  358.        Interne Prototypes
  359. **************************************/
  360.  
  361.  
  362. int do_command (char * str)
  363. {
  364.     char     * arg;
  365.     char     * aux1,
  366.          * aux2,
  367.          * repstr[MAXIA];
  368.     char       quoted;
  369.     short      repi = 0;
  370.     long       j;
  371.     short      low;
  372.     short      high;
  373.     short      diff;
  374.     static int level = 0;
  375.     COMM     * comm;
  376. #define DEBUG_FILE  /* Logging on ? */
  377. #ifdef DEBUG_FILE
  378.     static FILE * debug_file = NULL;
  379.  
  380.     if (!debug_file && globalflags.debug)
  381.     debug_file = fopen ("t:XDME.debug", "w");
  382. #endif
  383.  
  384.     if (!str || !*str)
  385.     return (1);
  386.  
  387. #ifdef DEBUG_FILE
  388.     if (debug_file && globalflags.debug)
  389.     fprintf (debug_file, "%s\n", str);
  390. #endif
  391.  
  392. /* if (debug) printf("dcom[%2d|%d]: %s\n", level+1, globalflags.Abortcommand, str); */
  393.  
  394.     if (MacroRecord != 0 && level == 0) {       /* PATCH_NULL [14 Feb 1993] : added */
  395.     add_record (str);                       /* PATCH_NULL [14 Feb 1993] : added */
  396.     } /* if */                    /* PATCH_NULL [14 Feb 1993] : added */
  397.  
  398.     if (++level > 20)
  399.     {
  400.     error ("command:\nRecursion too deep");
  401.     --level;
  402.  
  403.     foundcmd = 1;    /* to prevent us from trying an ARexx macro */
  404.  
  405.     return (0);
  406.     }
  407.  
  408.     while ((arg = breakout (&str, "ed, &aux1)) &&
  409.         !(LoopBreak || LoopCont) )                      /* PATCH_BREAK - should be put together */
  410.     {
  411. /* if (globalflags.debug) printf("loop[%2d|%d] CHECK %s\n",level, globalflags.Abortcommand, arg); */
  412.     if (quoted)
  413.     {
  414. /* if (debug) printf("loop[%2d|%d] write %s\n",level, globalflags.Abortcommand, arg); */
  415.         if (Ep->viewmode && !globalflags.Comlinemode)               /* PATCH_NULL */
  416.         {
  417. /* if (debug) printf("-- viewmode"); */
  418.         goto fail;                    /* PATCH_NULL */
  419.         } /* if */                        /* PATCH_NULL */
  420.  
  421.         if (Ep->iconmode)
  422.         uniconify ();
  423.  
  424.         text_write (arg);
  425.         goto loop;
  426.     } /* if (quoted) */
  427.  
  428.     if (isalpha (*arg))
  429.     {
  430.         low  = 0;
  431.         high = sizeof(Comm)/sizeof(Comm[0]) - 1;
  432.  
  433.         do
  434.         {
  435.         j = (low + high)/2;
  436.  
  437.         diff = stricmp (arg, Comm[j].name);
  438.  
  439.         if (!diff)
  440.             break;
  441.  
  442.         if (diff < 0)
  443.             high = j-1;
  444.         else
  445.             low = j+1;
  446.         } while (low <= high);
  447.  
  448.         if (!diff)
  449.         {
  450. /* if (debug) printf("loop[%2d|%d] comm %s\n",level, globalflags.Abortcommand, arg); */
  451.  
  452.         comm = &Comm[j];
  453.  
  454.         foundcmd = 1;
  455.  
  456.         av[0] = (ubyte *)comm->name;
  457.  
  458.         for (j=1; j<=comm->args; j++)
  459.         {
  460.             av[j] = (ubyte *)breakout (&str, "ed, &aux2);
  461.  
  462.             if (aux2)
  463.             {
  464.             if (repi == MAXIA)
  465.             {
  466.                 free (aux2);
  467.  
  468.                 error ("command:\nToo many args for\n%s", av[0]);
  469.  
  470. /* if (debug) printf("-- varargs Oflow"); */
  471.  
  472.                 goto fail;
  473.             } else
  474.             {
  475.                 repstr[repi ++] = aux2;
  476.             }
  477.             }
  478.  
  479.             if (!av[j])
  480.             {
  481.             if (j < 2)
  482.                 error ("command:\nBad argument %ld of\n%s", j, av[0]);
  483.             else
  484.                 error ("command:\nBad argument %ld of\n%s %s", j, av[0], av[1]);
  485.  
  486. /* if (debug) printf("-- less args"); */
  487.             goto fail;
  488.             }
  489.         } /* for all args */
  490.  
  491.         av[j] = NULL;    /* end of arglist */
  492.  
  493. process:
  494.         if ((comm->flags & CF_COK) || !globalflags.Comlinemode)
  495.         {
  496.             if (Ep->viewmode && !globalflags.Comlinemode && !(comm->flags & CF_VWM))   /* PATCH_NULL */
  497.             {
  498. /* if (debug) printf("-- viewmode"); */
  499.             goto fail;                    /* PATCH_NULL */
  500.             } /* if */                        /* PATCH_NULL */
  501.  
  502.             if (comm->flags & CF_PAR)
  503.             {
  504.             if (Partial)
  505.                 free (Partial);
  506.  
  507.             Partial = (char *)malloc (strlen (str) + 1);
  508.             strcpy (Partial, str);
  509.             str += strlen(str);     /*  skip string */
  510.             } /* if CF_PAR */
  511.  
  512.             if (Ep->iconmode && !(comm->flags & CF_ICO))
  513.             uniconify ();
  514.  
  515. /* if (debug) printf ("comm[%2d|%d] %s/%s\n", level, globalflags.Abortcommand, av[0], av[1]); */
  516.  
  517.             (*comm->func)(-1);
  518.         } /* if CF_COK or Not Comlinemode */
  519.  
  520.         if (globalflags.Abortcommand)
  521.         {
  522. /* if (debug) printf("-- aborted"); */
  523.             goto fail;
  524.         }
  525.  
  526.         goto loop;
  527.         } /* if arg == command */
  528.     } else if (isdigit(*arg))
  529.     {
  530.         av[0] = "repeat";
  531.         av[1] = arg;
  532.         av[2] = (ubyte *)breakout(&str, "ed, &aux2);
  533.  
  534.         if (aux2)
  535.         {
  536.         repstr[repi ++] = aux2;
  537.         }
  538.  
  539.         if (!av[2])
  540.         {
  541.         error ("command:\nBad second argument\nfor short-repeat");
  542. /* if (debug) printf("-- repeat"); */
  543.         goto fail;
  544.         }
  545.  
  546.         av[3] = 0;
  547.         comm = &repcmd;
  548.  
  549.         goto process;
  550.     } /* Repeat */
  551.  
  552.     {
  553.         /*
  554.         **    Search for a macro - we had to put that scan
  555.         **    before the checks for menus and keys, as
  556.         **    keys are only checked up to 3 chars
  557.         */
  558.  
  559.         void * macro;
  560.         int    ret;
  561.  
  562.         if (macro = (void*)getmacro(arg))
  563.         {
  564.         int narg = nummacroargs (macro);
  565.  
  566.         /* av[0] = (CHAR *)((NODE*)macro)->ln_Name; */
  567. /* if (debug) printf("loop[%2d|%d] macro %s\n",level, Abortcommand, arg); */
  568.  
  569.         av[0] = NULL;
  570.  
  571.         foundcmd = 1;
  572.  
  573.         for (j = 1; j <= narg; ++j)
  574.         {
  575.             av[j] = (ubyte *)breakout (&str, "ed, &aux2);
  576.  
  577.             if (aux2)
  578.             {
  579.             if (repi == MAXIA)
  580.             {
  581.                 free(aux2);
  582.                 error ("macro:\nToo many args for\n%s", av[0]);
  583. /* if (debug) printf("-- M:varargs Oflow"); */
  584.                 goto fail;
  585.             } else
  586.             {
  587.                 repstr[repi++] = aux2;
  588.             }
  589.             }
  590.  
  591.             if (!av[j])
  592.             {
  593.             error ("macro:\nBad argument %ld of\n%s", j, av[0]);
  594. /* if (debug) printf("-- M:less args"); */
  595.             goto fail;
  596.             }
  597.         }
  598.  
  599.         av[j] = NULL;    /* end of arglist */
  600.  
  601. /* if (debug) printf ("mac [%2d|%d] %s/%s\n", level, Abortcommand, arg, av[1]); */
  602.         ret = callmacro(macro);
  603.  
  604.         if (!ret)
  605.         {
  606. /* if (debug) printf("-- M:abort"); */
  607.             goto fail;
  608.         } /* if no succ */
  609.  
  610.         goto loop;
  611.         } /* if */
  612.     } /* block */
  613.  
  614.     /* Command not found, check for macro    */
  615.     {
  616.         char * cmdstr;
  617.         int    ret;
  618.  
  619.         if ((cmdstr = keyspectomacro(arg)) || (cmdstr = menutomacro(arg)))
  620.         {
  621.         cmdstr = strdup (cmdstr);
  622.  
  623. /* if (debug) printf ("loop[%2d|%d] key %s\n", level, Abortcommand, cmdstr); */
  624.  
  625.         ret = do_command (cmdstr);
  626.  
  627.         free (cmdstr);
  628.  
  629.         if (ret)
  630.         {
  631.             foundcmd = 1;
  632.             goto loop;
  633.         }
  634.  
  635. /* if (debug) printf("-- K:abort"); */
  636.  
  637.         goto fail;
  638.         } /* if arg is macro or menu */
  639.     }
  640.  
  641.  
  642. /*
  643. *!  PATCH_JUX (reine gaudi)
  644. *!
  645. *!    Direct assignments of existing vars
  646. *! With that patch something is possible like:
  647. *!    set abc 1 ... abc = 3 (instead of set abc 3)
  648. *!
  649. *! if arg1 is a "=" we search for a variable of the name in arg0
  650. *! if there is such a variable, we assign its value to the value
  651. *! in arg2  (the correct types are used)
  652. *!
  653. *!  But what shall we do, if there was not such a variable???
  654. */
  655.     {
  656.         char * dummy = NULL;
  657.         int    type  = VAR_NEX;
  658.  
  659.         dummy = str;
  660.  
  661.         while (*dummy && *dummy <33)
  662.         {
  663.         dummy ++;
  664.         } /* while */
  665.  
  666.         if (*dummy == '=')
  667.         {
  668.         dummy ++;
  669.  
  670.         str = dummy;
  671.  
  672.         dummy = GetTypedVar (arg, &type);
  673.  
  674.         if (dummy)
  675.         {
  676.             free (dummy);
  677.  
  678.             dummy = breakout (&str, "ed, &aux2);
  679.  
  680.             if (!dummy)
  681.             {
  682.             error ("Assignment without value");
  683.             goto fail;
  684.             } /* if */
  685.  
  686.             SetTypedVar (arg, dummy, type);
  687.  
  688.             if (aux2)
  689.             {
  690.             free (aux2);
  691.             } /* if */
  692.  
  693.             goto loop;
  694.         } else
  695.         { /* there is no variable of the given name  - WAS sollen wir jetzt machen ? einen Default verwenden ??? */
  696.  
  697.         } /* if */
  698.         } /* if */
  699.     } /* block direct assignment */
  700.  
  701.     /* Command still not found, check for public macro  */
  702.     /* code to be added */
  703.  
  704.     if (do_rxImplied (arg, str))
  705.         error ("command:\nUnknown command\n`%s'", arg);
  706.  
  707. /* if (debug) printf("running into fail"); */
  708.  
  709. fail:
  710. /* if (debug) printf ("fail[%2d|%d]\n", level, Abortcommand); */
  711.     --level;
  712.  
  713.     while (--repi >= 0)
  714.         free (repstr[repi]);
  715.  
  716.     if (aux1) free (aux1);
  717.  
  718.     return(0);
  719.  
  720. loop:
  721.     if (aux1) free (aux1);
  722.  
  723.     // aux1 = NULL;      /* PATCH_BREAK - is not necessary */
  724.     } /* while (arg) */
  725.  
  726. /* ret_ok: - point is not necessary */
  727. /* if (debug) printf ("ret1[%2d|%d]\n", level, Abortcommand); */
  728.  
  729.     --level;
  730.  
  731.     while (--repi >= 0)
  732.     free (repstr[repi]);
  733.  
  734.     // if (aux1) free (aux1); /* PATCH_BREAK - is not necessary */
  735.  
  736.     return(1);
  737. } /* do_command */
  738.  
  739.  
  740. void do_null (void)
  741. {
  742. } /* do_null */
  743.  
  744.  
  745. void do_source (long do_err)
  746. {
  747.     char   buf[MAXLINELEN];
  748.     FILE * fi;
  749.     char * str;
  750.     BPTR   oldlock = CurrentDir(DupLock(Ep->dirlock));
  751.  
  752.     if (fi = fopen(av[1], "r"))
  753.     {
  754.     while (fgets(buf, MAXLINELEN, fi))
  755.     {
  756.         if (buf[0] == '#')
  757.         continue;
  758.         for (str = buf; *str; ++str)
  759.         {
  760.         if (*str == 9)
  761.             *str = ' ';
  762.         }
  763.  
  764.         if (str > buf && str[-1] == '\n')
  765.         str[-1] = 0;
  766.  
  767.         do_command(buf);
  768.  
  769.         if (globalflags.SourceBreaks)                                   /* PATCH_NULL */
  770.         {
  771.         if (globalflags.Abortcommand || LoopBreak || LoopCont)      /* PATCH_NULL */
  772.         {
  773.             break;                    /* PATCH_NULL */
  774.         } /* if */                    /* PATCH_NULL */
  775.         } else                        /* PATCH_NULL */
  776.         {
  777.         globalflags.Abortcommand = 0;        /* PATCH_NULL */
  778.         LoopBreak    = 0;            /* PATCH_NULL */
  779.         LoopCont     = 0;            /* PATCH_NULL */
  780.         } /* if */                        /* PATCH_NULL */
  781.     }
  782.     fclose(fi);
  783.     } else
  784.     {
  785.     if (do_err)
  786.     {
  787.         error ("source:\nFile `%s'\nnot found", av[1]);
  788.     }
  789.     }
  790.  
  791.     UnLock(CurrentDir(oldlock));
  792. } /* do_source */
  793.  
  794.  
  795. void do_quit (void)
  796. {
  797.     globalflags.Quitflag = 1;
  798.  
  799.     ActivateWindow (Ep->win);                    /* HD damit aus AREXX */
  800. } /* do_quit */
  801.  
  802.  
  803. void do_quitall (void)
  804. {
  805.     globalflags.Quitflag = 1;
  806.     globalflags.QuitAll = 1;
  807.  
  808.     ActivateWindow (Ep->win);                    /* HD damit aus AREXX */
  809. } /* do_quitall */
  810.  
  811.  
  812. void do_execute (void)
  813. {
  814.     BPTR   oldlock = CurrentDir (Ep->dirlock);
  815.     BPTR   NilFH;
  816.     PROC * proc    = (PROC *)FindTask (NULL);
  817.  
  818.     NilFH = Open ("NIL:", 1006);
  819.  
  820.     if (NilFH)
  821.     {
  822.     void *oldConsoleTask = proc->pr_ConsoleTask;
  823.  
  824.     proc->pr_ConsoleTask = (APTR)BTOCP(NilFH, struct FileHandle *)->fh_Port;
  825.  
  826.     Execute (av[1], NilFH, NilFH);
  827.  
  828.     proc->pr_ConsoleTask = oldConsoleTask;
  829.  
  830.     Close(NilFH);
  831.     } else
  832.     {
  833.     error ("execute:\nNIL:-device required");
  834.     }
  835.  
  836.     CurrentDir(oldlock);
  837. } /* do_execute */
  838.  
  839.  
  840. /*
  841.  *  BREAKOUT()
  842.  *
  843.  *  Break out the next argument.  The argument is space delimited and
  844.  *  might be quoted with `' or (), or single quoted as 'c or )c
  845.  *
  846.  *  Also:    $var        -variable insertion
  847.  *        ^c        -control character
  848.  */
  849.  
  850. char * breakout (char ** ptr, char * quoted, char ** paux)
  851. {
  852.     char * str = *ptr;
  853.     char * base;
  854.     short  count;        /* Level of brace */
  855.     char   opc;         /* Open-Char */
  856.     char   clc;         /* Close-Char */
  857.     char   immode;
  858.     char   isaux;
  859.     char   buf[MAXLINELEN];
  860.     short  di, i;
  861.  
  862. /* if (debug) printf("bout[  |%d] ? %s\n", globalflags.Abortcommand, str); */
  863.  
  864.     count =
  865.     opc   =
  866.     clc   =
  867.     immode=
  868.     isaux =
  869.     di    = 0;
  870.  
  871.     *quoted = 0;
  872.     if (paux)
  873.     *paux = NULL;
  874.  
  875.     while (*str == ' ')
  876.     ++str;
  877.  
  878.     if (!*str)
  879.     return (NULL);
  880.  
  881.     *ptr = str;
  882.     base = str;
  883.  
  884.     while (*str)
  885.     {
  886.     if (immode)
  887.     {
  888.         if (di != sizeof(buf)-1)
  889.         buf[di++] = *str;
  890.  
  891.         str ++;
  892.         continue;
  893.     }
  894.  
  895.     if (count == 0)
  896.     {
  897.         if (*str == ' ')
  898.         break;
  899.  
  900.         if (*str == '\'' || *str == ')')
  901.         clc = *str;
  902.         else if (*str == '`')
  903.         {
  904.         opc = '`';
  905.         clc = '\'';
  906.         } else if (*str == '(')
  907.         {
  908.         opc = '(';
  909.         clc = ')';
  910.         }
  911.     }
  912.  
  913.     if (*str == opc)
  914.     {
  915.         count ++;
  916.  
  917.         if (str == *ptr)
  918.         {
  919.         *quoted = 1;
  920.         base = ++ str;
  921.         continue;
  922.         }
  923.     }
  924.  
  925.     if (*str == clc)
  926.     {
  927.         count --;
  928.  
  929.         if (count == 0 && *quoted)     /*  end of argument     */
  930.         break;
  931.  
  932.         if (str == *ptr && count < 0)
  933.         {
  934.         immode = 1;
  935.         *quoted = 1;
  936.         base = ++str;
  937.  
  938.         continue;
  939.         }
  940.     }
  941.  
  942.     /*
  943.      *  $varname $(varname) $`varname'.  I.E. three forms are allowed,
  944.      *  which allows one to insert the string almost anywhere.  The
  945.      *  first form names are limited to alpha-numerics, '-', and '_'.
  946.      */
  947.  
  948.     if (*str == '$')
  949.     {
  950.         char * ptr2;
  951.         char * tmpptr;
  952.         char   c,
  953.            ce;
  954.         short  len;
  955.  
  956. /* if (debug) printf("bout[  |%d] $ %s\n", globalflags.Abortcommand, str); */
  957.  
  958.         ce = 0;                /*    first form  */
  959.         str ++;                /*    skip $        */
  960.  
  961.         if (*str == '(')                /*  second form */
  962.         {
  963.         ce = ')';
  964.         ++str;
  965.         } else if (*str == '`')         /*  third form  */
  966.         {
  967.         ce = '\'';
  968.         ++str;
  969.         }
  970.  
  971.         ptr2 = str;             /*    start of varname    */
  972.  
  973.         if (ce)                         /*  until end char OR   */
  974.         {
  975.         while (*ptr2 && *ptr2 != ce)
  976.             ptr2 ++;
  977.         } else                /*    smart end-varname   */
  978.         {
  979.         while (isalnum(*ptr2) || *ptr2 == '-' || *ptr2 == '_' )
  980.         {
  981.             ptr2 ++;
  982.         }
  983.         }
  984.  
  985.         len = ptr2 - str;            /*    length of variable  */
  986.         c = *ptr2; *ptr2 = 0;        /*    temp. terminate \0  */
  987.  
  988. /* if (debug) printf("bout[  |%d] var '%s'\n", globalflags.Abortcommand, str); */
  989.  
  990.         if (stricmp(str, "currentdir") == 0)
  991.         {
  992.         *ptr2  = c;
  993.         isaux = 1;
  994.  
  995.         if (NameFromLock(Ep->dirlock, tmp_buffer, sizeof(tmp_buffer)))
  996.         {
  997.             i = strlen(tmp_buffer);
  998.  
  999.             if (di + i < sizeof(buf)-1)
  1000.             {
  1001.             strcpy (buf + di, tmp_buffer);
  1002.             di += i;
  1003.             }
  1004.         }
  1005.  
  1006.         str += len;
  1007.  
  1008.         if (ce)
  1009.             ++str;
  1010.  
  1011.         continue;
  1012.         } else if (stricmp(str, "path") == 0)
  1013.         {
  1014.         *ptr2 = c;
  1015.         isaux = 1;
  1016.  
  1017.         if (NameFromLock(Ep->dirlock, tmp_buffer, sizeof(tmp_buffer)))
  1018.         {
  1019.             i = strlen (tmp_buffer);
  1020.  
  1021.             if (di + i < sizeof(buf)-1)
  1022.             {
  1023.             strcpy (buf+di, tmp_buffer);
  1024.             di += i;
  1025.             }
  1026.         }
  1027.  
  1028.         str += len;
  1029.         if (ce)
  1030.             ++str;
  1031.  
  1032.         continue;
  1033.         } else if (stricmp(str, "file") == 0)
  1034.         {
  1035.         i = strlen(Ep->name);
  1036.         *ptr2 = c;
  1037.         isaux = 1;
  1038.         if (di + i < sizeof(buf)-1)
  1039.         {
  1040.             movmem(Ep->name, buf + di, i);
  1041.             di += i;
  1042.             buf[di] = 0;
  1043.         }
  1044.         str += len;
  1045.         if (ce)
  1046.             ++str;
  1047.         continue;
  1048.         } else if (stricmp(str, "filename") == 0)
  1049.         {
  1050.         *ptr2 = c;
  1051.         isaux = 1;
  1052.  
  1053.         if (NameFromLock(Ep->dirlock, tmp_buffer, sizeof(tmp_buffer)))
  1054.         {
  1055.             if (AddPart (tmp_buffer, Ep->name, sizeof(tmp_buffer)))
  1056.             {
  1057.             i = strlen (tmp_buffer);
  1058.  
  1059.             if (di + i < sizeof(buf)-1)
  1060.             {
  1061.                 strcpy(buf + di, tmp_buffer);
  1062.                 di += i;
  1063.             }
  1064.             }
  1065.         }
  1066.  
  1067.         str += len;
  1068.         if (ce)
  1069.             ++str;
  1070.         continue;
  1071.         } else if (!stricmp(str, "rexxport"))           /* TJM */
  1072.         {
  1073.         *ptr2 = c;
  1074.         isaux = 1;
  1075.  
  1076.         if (di + strlen(RexxPortName) < sizeof(buf)-1)
  1077.         {
  1078.             strcpy(buf + di, RexxPortName);
  1079.             di += strlen(buf + di);
  1080.         }
  1081.  
  1082.         str += len;
  1083.  
  1084.         if (ce)
  1085.             ++str;
  1086.         continue;
  1087.         } else if (!stricmp(str, "rxresult"))
  1088.         {
  1089.         *ptr2 = c;
  1090.         isaux = 1;
  1091.  
  1092.         if (di + strlen(get_rexx_result()) < sizeof(buf)-1)
  1093.         {
  1094.             strcpy(buf + di, get_rexx_result());
  1095.             di += strlen(buf + di);
  1096.         }
  1097.  
  1098.         str += len;
  1099.  
  1100.         if (ce)
  1101.             ++str;
  1102.         continue;
  1103.         } else if (tmpptr = getvar(str))
  1104.         {
  1105.         ptr2 = tmpptr;
  1106.         str[len] = c;
  1107.         isaux = 1;
  1108.  
  1109.         if (di + strlen(ptr2) < sizeof(buf)-1)
  1110.         {
  1111.             strcpy(buf + di, ptr2);
  1112.             di += strlen(buf + di);
  1113.         }
  1114.  
  1115.         str += len;
  1116.  
  1117.         if (ce)
  1118.             ++str;
  1119.  
  1120.         free(ptr2);
  1121.         continue;
  1122.         }
  1123.  
  1124.         *ptr2 = c;
  1125.         str --;
  1126.  
  1127.         if (ce)
  1128.         str --;
  1129.     } else if (*str == '^' && (str[1] & 0x1F))   /* CTRL-sequence */
  1130.     {
  1131.         str ++;
  1132.         *str &= 0x1F;
  1133.         isaux = 1;
  1134.     } else if (*str == '\\' && str[1])
  1135.     {
  1136.         if (!count) /* ignore \ */
  1137.         {
  1138.         str ++;
  1139.         } else if (*quoted && count == 1) /* remove it, but check next char */
  1140.         {
  1141.         str ++;
  1142.         isaux = 1;
  1143.         continue;
  1144.         } else /* don't remove it, but also ignore next char */
  1145.         {
  1146.         buf[di ++] = *str ++;
  1147.         }
  1148.         isaux = 1;
  1149.     }
  1150.  
  1151.     buf[di ++] = *str ++;
  1152.     } /* while (*str) */
  1153.  
  1154.     buf[di ++] = 0;
  1155.  
  1156.     if (isaux)
  1157.     {
  1158.     *paux = malloc (di);
  1159.     strcpy (*paux, buf);
  1160.     base = *paux;
  1161.     }
  1162.  
  1163.     if (*str)               /*  space ended */
  1164.     {
  1165.     *str = '\0';
  1166.     *ptr = str + 1;     /*    next arg    */
  1167.     } else
  1168.     {
  1169.     *ptr = str;        /*    last arg    */
  1170.     }
  1171.  
  1172.     return (base);
  1173. } /* breakout */
  1174.  
  1175.  
  1176. /******************************************************************************
  1177. *****  ENDE command.c
  1178. ******************************************************************************/
  1179.