1: /*	interact.c	1.8	83/07/27	*/
   2: #include <stdio.h>
   3: #include "command.h"
   4: #include <setjmp.h>
   5: #include <signal.h>
   6: 
   7: #define errinp { printf("??\n"); break; }
   8: 
   9: jmp_buf env;
  10: int firsttime = 0;
  11: 
  12: interact()
  13: 
  14: {
  15: 
  16:     int i, intrpt();
  17:     char    cmd[80], *rest, *index();
  18: 
  19:     for (;;) {
  20:         if (firsttime++ == 0) {
  21:             signal(SIGINT, intrpt, -1);
  22:             (void) setjmp(env);
  23:         }
  24:         if (cmdinp(cmd) < 0)
  25:             return (0);
  26:         rest = index(cmd, ' ');
  27:         if (rest)
  28:             *rest++ = '\0';
  29:         i = chkcmd(cmd);
  30: #ifdef DEBUG
  31:         printf("command: %s, ind: %d\n", cmd, i);
  32: #endif
  33: 
  34:         switch (i) {
  35:         default:
  36:             errinp;
  37:             break;
  38:         case CMD_DIR:
  39:         case CMD_LS:
  40:             dispdir();
  41:             break;
  42: 
  43:         case CMD_RENAME:
  44:             rename(rest);
  45:             break;
  46: 
  47:         case CMD_OCOPY:
  48:             copyc(rest, 0);
  49:             break;
  50: 
  51:         case CMD_ICOPY:
  52:             pip(rest, 0);
  53:             break;
  54: 
  55:         case CMD_DELETE:
  56:         case CMD_ERASE:
  57:             delete(rest);
  58:             break;
  59: 
  60:         case CMD_EXIT:
  61:         case CMD_LOGOUT:
  62:             return(0);
  63: 
  64:         case CMD_TYPE:
  65:             copy(rest, stdout, 0);
  66:             break;
  67: 
  68:         case CMD_HELP:
  69:             help();
  70:             break;
  71: 
  72:         case CMD_OCCOPY:
  73:             copyc(rest, 1);
  74:             break;
  75: 
  76:         case CMD_ICCOPY:
  77:             pip(rest,1);
  78:             break;
  79: 
  80:         case CMD_DUMP:
  81:             dump(rest);
  82:             break;
  83: 
  84:         }
  85:     }
  86: }
  87: 
  88: /*
  89:  * handle interrupts (in interactive mode only),
  90:  * just (long)jump back to command input mode
  91:  */
  92: 
  93: intrpt()
  94: {
  95:     firsttime = 0;
  96:     printf("\n");
  97:     longjmp(env, 0);
  98: }

Defined functions

interact defined in line 12; used 1 times
intrpt defined in line 93; used 2 times

Defined variables

env defined in line 9; used 2 times
firsttime defined in line 10; used 2 times

Defined macros

errinp defined in line 7; used 1 times
  • in line 36
Last modified: 1985-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 954
Valid CSS Valid XHTML 1.0 Strict