home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / bmd-1.0beta.tar.Z / bmd-1.0beta.tar / bmd-1.0beta / app / omtd / command.c < prev    next >
C/C++ Source or Header  |  1991-01-22  |  1KB  |  70 lines

  1. /*
  2.  * Copyright (c) 1990 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Lawrence Berkeley Laboratory,
  11.  * Berkeley, CA.  The name of the University may not be used to
  12.  * endorse or promote products derived from this software without
  13.  * specific prior written permission.
  14.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17.  */
  18.  
  19. #include "command.h"
  20.  
  21. struct command {
  22.     char *cmd_name;
  23.     void (*cmd_fn)();
  24. };
  25.  
  26. struct command cmdtbl[] = {
  27.     CMDS
  28. };
  29.  
  30. int
  31. do_command(cmd, args)
  32.     char *cmd;
  33.     struct token **args;
  34. {
  35.     struct command *p;
  36.  
  37.     for (p = cmdtbl; p->cmd_name != 0; ++p) {
  38.         if (strcmp(p->cmd_name, cmd) == 0) {
  39.             (*p->cmd_fn)(args);
  40.             return 0;
  41.         }
  42.     }
  43.     return -1;
  44. }
  45.  
  46. void
  47. quit_command(args)
  48.     struct token **args;
  49. {
  50.     /* XXX Save state in /tmp file. */
  51.     exit(0);
  52. }
  53.  
  54. void
  55. stop_command(args)
  56.     struct token **args;
  57. {
  58.     printf("STOP\n");
  59.     ptokens(args);
  60. }
  61.  
  62. void
  63. print_command(args)
  64.     struct token **args;
  65. {
  66.     printf("PRINT\n");
  67.     ptokens(args);
  68. }
  69.  
  70.