home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / text / jed / src / jed.lha / initsymbols.c < prev    next >
C/C++ Source or Header  |  1993-01-09  |  4KB  |  175 lines

  1.  
  2. /*
  3.  * INITSYMBOLS.C
  4.  * (c) 1992-3 J.Harper
  5.  *
  6.  * defines and creates the default commands
  7.  */
  8.  
  9. #include "jed.h"
  10. #include "jed_protos.h"
  11.  
  12. Prototype   BOOL    initcommands    (VOID);
  13. Prototype   VOID    killsymbols        (VOID);
  14.  
  15. typedef struct INIT {
  16.     STRPTR        i_Name;
  17.     CMPTR        i_Func;
  18. } INIT;
  19.  
  20. Local const INIT CmdList[] =
  21. {
  22.     "+", cmd_plus,
  23.     "-", cmd_minus,
  24.     "*", cmd_product,
  25.     "/", cmd_divide,
  26.     "%", cmd_mod,
  27.     "<<", cmd_lshift,
  28.     ">>", cmd_rshift,
  29.     "~", cmd_b_not,
  30.     "!", cmd_l_not,
  31.     "|", cmd_b_or,
  32.     "||", cmd_l_or,
  33.     "&", cmd_b_and,
  34.     "&&", cmd_l_and,
  35.     "^", cmd_b_eor,
  36.     "^^", cmd_l_eor,
  37.  
  38.     "=", cmd_equals,
  39.  
  40.     "==", cmd_equality,
  41.     "!=", cmd_inequality,
  42.     ">", cmd_gtthan,
  43.     "<", cmd_ltthan,
  44.     ">=", cmd_gethan,
  45.     "<=", cmd_lethan,
  46.  
  47.     "activatefile", cmd_activatefile,
  48.     "addsym", cmd_addsym,
  49.     "addpath", cmd_addpath,
  50.     "arg", cmd_arg,
  51.     "atol", cmd_atol,
  52.     "bind", cmd_bind,
  53.     "block", cmd_block,
  54.     "break", cmd_break,
  55.     "car", cmd_car,
  56.     "cd", cmd_cd,   
  57.     "cdr", cmd_cdr,
  58.     "changes", cmd_changes,
  59.     "cli", cmd_cli,
  60.     "close", cmd_close,
  61.     "copy", cmd_copy,
  62.     "cut", cmd_cut,
  63.     "clear", cmd_clear,
  64.     "changecase", cmd_changecase,
  65.     "delete", cmd_delete,
  66.     "dowhile", cmd_dowhile,
  67.     "dlock", cmd_dlock,
  68.     "export", cmd_export,
  69.     "extract", cmd_extract,
  70.     "find", cmd_find,
  71.     "freq", cmd_freq,
  72.     "format", cmd_format,
  73.     "getref", cmd_getref,
  74.     "getstr", cmd_getstr,
  75.     "getnum", cmd_getnum,
  76.     "getpref", cmd_getpref,
  77.     "if", cmd_if,
  78.     "ilock", cmd_ilock,
  79.     "insert", cmd_insert,
  80.     "info", cmd_info,
  81.     "isalpha", cmd_isalpha,
  82.     "isdigit", cmd_isdigit,
  83.     "isalnum", cmd_isalnum,
  84.     "isspace", cmd_isspace,
  85.     "join", cmd_join,
  86.     "move", cmd_move,
  87.     "match", cmd_match,
  88.     "menu", cmd_menu,
  89.     "nargs", cmd_nargs,
  90.     "newfile", cmd_newfile,
  91.     "newview", cmd_newview,
  92.     "nextwind", cmd_nextwind,
  93.     "nop", cmd_nop,
  94.     "openfile", cmd_openfile,
  95.     "prevwind", cmd_prevwind,
  96.     "poke", cmd_poke,
  97.     "position", cmd_position,
  98.     "replace", cmd_replace,
  99.     "remsym", cmd_remsym,
  100.     "rempath", cmd_rempath,
  101.     "rename", cmd_rename,
  102.     "renamesym", cmd_renamesym,
  103.     "req", cmd_req,
  104.     "rexx", cmd_rexx,
  105.     "return", cmd_return,
  106.     "savefile", cmd_savefile,
  107.     "savefileas", cmd_savefileas,
  108.     "savesection", cmd_savesection,
  109.     "saveprefs", cmd_saveprefs,
  110.     "select", cmd_select,
  111.     "setmenu", cmd_setmenu,
  112.     "setpref", cmd_setpref,
  113.     "settitle", cmd_settitle,
  114.     "script", cmd_script,
  115.     "sleep", cmd_sleep,
  116.     "split", cmd_split,
  117.     "substr", cmd_substr,
  118.     "symboldump", cmd_symboldump,
  119.     "system", cmd_system,
  120.     "toupper", cmd_toupper,
  121.     "tolower", cmd_tolower,
  122.     "type", cmd_type,
  123.     "unbind", cmd_unbind,
  124.     "undo", cmd_undo,
  125.     "unsleep", cmd_unsleep,
  126.     "while", cmd_while,
  127.     NULL, NULL
  128. };
  129.  
  130. /*
  131.  * initializes command list
  132.  */
  133. BOOL
  134. initcommands(VOID)
  135. {
  136.     INIT *init = CmdList;
  137.     VALUE tmp;
  138.     tmp.val_Type = VTF_FUNC;
  139.     while(init->i_Name)
  140.     {
  141.     tmp.val_Value.Func = init->i_Func;
  142.     if(!(addgsym(init->i_Name, STF_COMMAND, &tmp)))
  143.     {
  144.         killsymbols();
  145.         return(FALSE);
  146.     }
  147.     init++;
  148.     }
  149.     return(TRUE);
  150. }
  151.  
  152. /*
  153.  * kills symbol table
  154.  */
  155. VOID
  156. killsymbols(VOID)
  157. {
  158.     HASHNODE **hash = SymbolTab;
  159.     WORD i;
  160.  
  161.     for(i = 0; i < GSYMTABSIZE; i++)
  162.     {
  163.     GSYM *sym = hash[i], *next;
  164.     while(sym)
  165.     {
  166.         next = sym->gs_Node.h_Next;
  167.         freestring(sym->gs_Node.h_Name);
  168.         releasevalue(&sym->gs_Sym.sym_Value);
  169.         FreeVec(sym);
  170.         sym = next;
  171.     }
  172.     }
  173. }
  174.  
  175.