예제 #1
0
int
main(int argc, const char * argv[]) {

    FILE * ifP;
    gray * grayrow;
    int rows;
    int cols;
    unsigned int depth;
    int format;
    unsigned int padright;
    unsigned int row;
    gray maxval;
    const char * inputFile;

    pm_proginit(&argc, argv);

    if (argc-1 < 1)
        inputFile = "-";
    else {
        inputFile = argv[1];

        if (argc-1 > 2)
            pm_error("Too many arguments.  The only argument is the optional "
                     "input file name");
    }

    ifP = pm_openr(inputFile);

    pgm_readpgminit(ifP, &cols, &rows, &maxval, &format);

    grayrow = pgm_allocrow(cols);
    depth = pm_maxvaltobits(maxval);

    /* Compute padding to round cols up to the nearest multiple of 32. */
    padright = ((cols + 31) / 32) * 32 - cols;

    putinit(cols, rows, depth);

    for (row = 0; row < rows; ++row) {
        unsigned int col;

        pgm_readpgmrow(ifP, grayrow, cols, maxval, format);

        for (col = 0; col < cols; ++col)
            putval(grayrow[col]);

        for (col = 0; col < padright; ++col)
            putval(0);
    }

    pm_close(ifP);

    putrest();

    return 0;
}
예제 #2
0
파일: cabi.c 프로젝트: TEAMarg/Cabi
// write a span length
// a string of bits encoding the number of bits needed to encode the length,
// and then the length.
static int putsplen(int len)
{
	int blen = 1; // how bits needed to encode length
	while ((1 << blen) <= len)
		blen += 2;
	// write number of bits (1-terminated string of zeroes)
	putval(0,(blen-1)/2);
	putval(1,1);          // terminator
	// write length
	putval(len, blen);
}
예제 #3
0
int main (int argc, char **argv) {
  char address[1024] = "unix:"DEFAULT_SOCK;

  lcc_connection_t *c;

  int status;

  while (42) {
    int c;

    c = getopt (argc, argv, "s:h");

    if (c == -1)
      break;

    switch (c) {
      case 's':
        snprintf (address, sizeof (address), "unix:%s", optarg);
        address[sizeof (address) - 1] = '\0';
        break;
      case 'h':
        exit_usage (argv[0], 0);
        break;
      default:
        exit_usage (argv[0], 1);
    }
  }

  if (optind >= argc) {
    fprintf (stderr, "%s: missing command\n", argv[0]);
    exit_usage (argv[0], 1);
  }

  c = NULL;
  status = lcc_connect (address, &c);
  if (status != 0) {
    fprintf (stderr, "ERROR: Failed to connect to daemon at %s: %s.\n",
        address, strerror (errno));
    return (1);
  }

  if (strcasecmp (argv[optind], "getval") == 0)
    status = getval (c, argc - optind, argv + optind);
  else if (strcasecmp (argv[optind], "flush") == 0)
    status = flush (c, argc - optind, argv + optind);
  else if (strcasecmp (argv[optind], "listval") == 0)
    status = listval (c, argc - optind, argv + optind);
  else if (strcasecmp (argv[optind], "putval") == 0)
    status = putval (c, argc - optind, argv + optind);
  else {
    fprintf (stderr, "%s: invalid command: %s\n", argv[0], argv[optind]);
    return (1);
  }

  LCC_DESTROY (c);

  if (status != 0)
    return (status);
  return (0);
} /* main */
예제 #4
0
파일: comm5.c 프로젝트: h31nr1ch/SOP
yylex()
{
	register c;
	int i;

	if (pass == PASS_1) {
		/* scan the input file */
		do
			c = nextchar();
		while (isspace(c) && c != '\n');
		if (ISALPHA(c))
			c = inident(c);
		else if (isdigit(c))
			c = innumber(c);
		else switch (c) {
		case '=':
		case '<':
		case '>':
		case '|':
		case '&':
			c = induo(c); break;
		case ASC_SQUO:
		case ASC_DQUO:
			c = instring(c); break;
		case ASC_COMM:
			do
				c = nextchar();
			while (c != '\n' && c != '\0');
			break;
		case CTRL('A'):
			c = CODE1; readcode(1); break;
		case CTRL('B'):
			c = CODE2; readcode(2); break;
		case CTRL('C'):
			c = CODE4; readcode(4); break;
		}

		/* produce the intermediate token file */
		if (c <= 0)
			return(0);
		if (c <= 127)
			putc(c, tempfile);
		else
			putval(c);
	} else {
		/* read from intermediate token file */
		c = getc(tempfile);
		if (c == EOF)
			return(0);
		if (c > 127) {
			c += 128;
			c = getval(c);
		}
	}
	return(c);
}
예제 #5
0
/**
 * Main
 *
 * @param const unsigned int argc
 *     Number of parameters.
 * @param const char **argv
 *     Parameter strings.
 */
int main(const unsigned int argc, const char **argv) {

	char *e_interval, *e_host;

	unsigned int interval = 0;
	char *hostname = NULL;
	char *id = NULL;
	memutil val;

	val.time = 123;

	/* Disable output buffering. */
	if (setvbuf(stdout, NULL, _IONBF, 0)) {
		perror("# Couldn't disable buffering");
		exit(EXIT_FAILURE);
	}

	/* Find hostname from the environment. */
	if (e_host = getenv("COLLECTD_HOSTNAME")) {
		hostname = e_host;
	}
	else {
		perror("# Couldn't find COLLECTD_HOSTNAME in environment");
		exit(EXIT_FAILURE);
	}

	/* Find the interval from the environment. */
	if (e_interval = getenv("COLLECTD_INTERVAL")) {
		if (! sscanf(e_interval, "%u", &interval)) {
			fprintf(stderr, "# LOLWUT: '%s' not an interval\n", e_interval);
			exit(0);
		}
		printf("# Using %d interval\n", interval);
	}
	else {
		perror("# Couldn't find COLLECTD_INTERVAL in environment");
		exit(EXIT_FAILURE);
	}

	/* Build the value identifier. */
	id = malloc(1024);
	snprintf(id, 1024, "\"%s/memutil/memutil\"", hostname);

	/* Report statistics every /interval/. */
	while (1) {
		getval(&val);
		putval(stdout, id, interval, &val);
		sleep(interval);
	}

	return 0;
}
예제 #6
0
파일: cabi.c 프로젝트: TEAMarg/Cabi
/*
	comp
	
	compress plen 1-bit pixels from src to dest
	
*/
int compress_rle(const uint8_t *src, int w, int h, char *prefix, char *suffix)
{
	int pos;
	int rlen;
	int len;
	
	printf("const uint8_t PROGMEM %s%s[] = {", prefix, suffix);
	fflush(stdout);
	
	memset(&cs, 0, sizeof(cs));
	cs.src = src;
	cs.bit = 1;
	cs.w = w;
	cs.h = h;
	
	// header
	putval(w-1, 8);
	putval(h-1, 8);
	putval(getcol(0), 1); // first colour
	
	pos = 0;
	
	// span data
	
	while (pos < w*h)
	{
		rlen = find_rlen(pos, w*h);
		pos += rlen;
		putsplen(rlen-1);
	}
	
	// pad with zeros and flush
	while (cs.bit != 0x1)
		putbit(0);
		
	printf("\n};\n");
	
	return cs.out_pos; // bytes
}
예제 #7
0
파일: ktrace.c 프로젝트: 99years/plan9
static void
readstack(void)
{
	Biobuf b;
	char *p;
	char *f[64];
	int nf, i;

	Binit(&b, 0, OREAD);
	while(p=Brdline(&b, '\n')){
		p[Blinelen(&b)-1] = 0;
		nf = tokenize(p, f, nelem(f));
		for(i=0; i<nf; i++){
			if(p=strchr(f[i], '=')){
				*p++ = 0;
				putval(strtoull(f[i], 0, 16), strtoull(p, 0, 16));
			}
		}
	}
}
예제 #8
0
파일: dict.c 프로젝트: vivekn/blitz8086
void init2() {
	/*0 operand opcodes */
		putval("ES:",0x26);
		putval("DAA",0x27);
		putval("CS:",0x2e);
		putval("DAS",0x2f);
		putval("SS:",0x36);
		putval("AAA",0x37);
		putval("DS:",0x3e);
		putval("AAS",0x3f);
		putval("NOP",0x90);
		putval("CBW",0x98);
		putval("CWD",0x99);
		putval("WAIT",0x9b);
		putval("PUSHF",0x9c);
		putval("POPF",0x9d);
		putval("SAHF",0x9e);
		putval("LAHF",0x9f);
		putval("MOVSB",0xa4);
		putval("MOVSW",0xa5);
		putval("CMPSB",0xa6);
		putval("CMPSW",0xa7);
		putval("STOSB",0xaa);
		putval("STOSW",0xab);
		putval("LODSB",0xac);
		putval("LODSW",0xad);
		putval("SCASB",0xae);
		putval("SCASW",0xaf);
		putval("RET",0xc3);
		putval("RETF",0xcb);
		putval("INTO",0xce);
		putval("IRET",0xcf);
		putval("XLAT",0xd7);
		putval("LOCK",0xf0);
		putval("REPNZ",0xf2);
		putval("REPZ",0xf3);
		putval("HLT",0xf4);
		putval("CMC",0xf5);
		putval("CLC",0xf8);
		putval("STC",0xf9);
		putval("CLI",0xfa);
		putval("STI",0xfb);
		putval("CLD",0xfc);
		putval("STD",0xfd);
		putval("es:",0x26);
		putval("daa",0x27);
		putval("cs:",0x2e);
		putval("das",0x2f);
		putval("ss:",0x36);
		putval("aaa",0x37);
		putval("ds:",0x3e);
		putval("aas",0x3f);
		putval("nop",0x90);
		putval("cbw",0x98);
		putval("cwd",0x99);
		putval("wait",0x9b);
		putval("pushf",0x9c);
		putval("popf",0x9d);
		putval("sahf",0x9e);
		putval("lahf",0x9f);
		putval("movsb",0xa4);
		putval("movsw",0xa5);
		putval("cmpsb",0xa6);
		putval("cmpsw",0xa7);
		putval("stosb",0xaa);
		putval("stosw",0xab);
		putval("lodsb",0xac);
		putval("lodsw",0xad);
		putval("scasb",0xae);
		putval("scasw",0xaf);
		putval("ret",0xc3);
		putval("retf",0xcb);
		putval("into",0xce);
		putval("iret",0xcf);
		putval("xlat",0xd7);
		putval("lock",0xf0);
		putval("repnz",0xf2);
		putval("repz",0xf3);
		putval("hlt",0xf4);
		putval("cmc",0xf5);
		putval("clc",0xf8);
		putval("stc",0xf9);
		putval("cli",0xfa);
		putval("sti",0xfb);
		putval("cld",0xfc);
		putval("std",0xfd);
	//1 operand opcodes (REGISTER)
		putval("push,es",0x06);
		putval("pop,es",0x07);
		putval("push,cs",0x0e);
		putval("push,ss",0x16);
		putval("push,ds",0x1e);
		putval("pop,ds",0x1f);
		putval("inc,ax",0x40);
		putval("inc,cx",0x41);
		putval("inc,dx",0x42);
		putval("inc,bx",0x43);
		putval("inc,sp",0x44);
		putval("inc,bp",0x45);
		putval("inc,si",0x46);
		putval("inc,di",0x47);
		putval("dec,ax",0x48);
		putval("dec,cx",0x49);
		putval("dec,dx",0x4a);
		putval("dec,bx",0x4b);
		putval("dec,sp",0x4c);
		putval("dec,bp",0x4d);
		putval("dec,si",0x4e);
		putval("dec,di",0x4f);
		putval("push,ax",0x50);
		putval("push,cx",0x51);
		putval("push,dx",0x52);
		putval("push,bx",0x53);
		putval("push,sp",0x54);
		putval("push,bp",0x55);
		putval("push,si",0x56);
		putval("push,di",0x57);
		putval("pop,ax",0x58);
		putval("pop,cx",0x59);
		putval("pop,dx",0x5a);
		putval("pop,bx",0x5b);
		putval("pop,sp",0x5c);
		putval("pop,bp",0x5d);
		putval("pop,si",0x5e);
		putval("pop,di",0x5f);
		
		putval("PUSH,ES",0x06);
		putval("POP,ES",0x07);
		putval("PUSH,CS",0x0e);
		putval("PUSH,SS",0x16);
		putval("PUSH,DS",0x1e);
		putval("POP,DS",0x1f);
		putval("INC,AX",0x40);
		putval("INC,CX",0x41);
		putval("INC,DX",0x42);
		putval("INC,BX",0x43);
		putval("INC,SP",0x44);
		putval("INC,BP",0x45);
		putval("INC,SI",0x46);
		putval("INC,DI",0x47);
		putval("DEC,AX",0x48);
		putval("DEC,CX",0x49);
		putval("DEC,DX",0x4a);
		putval("DEC,BX",0x4b);
		putval("DEC,SP",0x4c);
		putval("DEC,BP",0x4d);
		putval("DEC,SI",0x4e);
		putval("DEC,DI",0x4f);
		putval("PUSH,AX",0x50);
		putval("PUSH,CX",0x51);
		putval("PUSH,DX",0x52);
		putval("PUSH,BX",0x53);
		putval("PUSH,SP",0x54);
		putval("PUSH,BP",0x55);
		putval("PUSH,SI",0x56);
		putval("PUSH,DI",0x57);
		putval("POP,AX",0x58);
		putval("POP,CX",0x59);
		putval("POP,DX",0x5a);
		putval("POP,BX",0x5b);
		putval("POP,SP",0x5c);
		putval("POP,BP",0x5d);
		putval("POP,SI",0x5e);
		putval("POP,DI",0x5f);
	// 1op immediate		
		putval("INT,3",0xcc);
		putval("int,3",0xcc);
		putval("INT,ib",0xcd);
		putval("int,ib",0xcd);
		putval("RET,iw",0xc2);
		putval("RETF,iw",0xca);
		putval("ret,iw",0xc2);
		putval("retf,iw",0xca);
	// registers
		putval("AL",0x00);
		putval("CL",0x01);
		putval("DL",0x02);
		putval("BL",0x03);
		putval("AH",0x04);
		putval("CH",0x05);
		putval("DH",0x06);
		putval("BH",0x07);
		putval("AX",0x08);
		putval("CX",0x09);
		putval("DX",0x0A);
		putval("BX",0x0B);
		putval("SP",0x0C);
		putval("BP",0x0D);
		putval("SI",0x0E);
		putval("DI",0x0F);
		putval("al",0x0);
		putval("cl",0x1);
		putval("dl",0x2);
		putval("bl",0x3);
		putval("ah",0x4);
		putval("ch",0x5);
		putval("dh",0x6);
		putval("bh",0x7);
		putval("ax",0x8);
		putval("cx",0x9);
		putval("dx",0xa);
		putval("bx",0xb);
		putval("sp",0xc);
		putval("bp",0xd);
		putval("si",0xe);
		putval("di",0xf);
	/*Jump codes*/
		putval("JO",0x70);
		putval("jo",0x70);
		putval("JNO",0x71);
		putval("jno",0x71);
		putval("JB",0x72);
		putval("jb",0x72);
		putval("JNB",0x73);
		putval("jnb",0x73);
		putval("JZ",0x74);
		putval("jz",0x74);
		putval("JNZ",0x75);
		putval("jnz",0x75);
		putval("JBE",0x76);
		putval("jbe",0x76);
		putval("JA",0x77);
		putval("ja",0x77);
		putval("JS",0x78);
		putval("js",0x78);
		putval("JNS",0x79);
		putval("jns",0x79);
		putval("JPE",0x7A);
		putval("jpe",0x7A);
		putval("JPO",0x7B);
		putval("jpo",0x7B);
		putval("JL",0x7C);
		putval("jl",0x7C);
		putval("JGE",0x7D);
		putval("jge",0x7D);
		putval("JLE",0x7E);
		putval("jle",0x7E);
		putval("JG",0x7F);
		putval("jg",0x7F);
		putval("JMP",0xE9);
		putval("jmp",0xE9);
		putval("JMP",0xEA);
		putval("jmp",0xEA);
		putval("JMP",0xEB);
		putval("jmp",0xEB);	
		

}
예제 #9
0
void caml_debugger(enum event_kind event)
{
  int frame_number;
  value * frame;
  intnat i, pos;
  value val;

  if (dbg_socket == -1) return;  /* Not connected to a debugger. */

  /* Reset current frame */
  frame_number = 0;
  frame = caml_extern_sp + 1;

  /* Report the event to the debugger */
  switch(event) {
  case PROGRAM_START:           /* Nothing to report */
    goto command_loop;
  case EVENT_COUNT:
    putch(dbg_out, REP_EVENT);
    break;
  case BREAKPOINT:
    putch(dbg_out, REP_BREAKPOINT);
    break;
  case PROGRAM_EXIT:
    putch(dbg_out, REP_EXITED);
    break;
  case TRAP_BARRIER:
    putch(dbg_out, REP_TRAP);
    break;
  case UNCAUGHT_EXC:
    putch(dbg_out, REP_UNCAUGHT_EXC);
    break;
  }
  caml_putword(dbg_out, caml_event_count);
  if (event == EVENT_COUNT || event == BREAKPOINT) {
    caml_putword(dbg_out, caml_stack_high - frame);
    caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
  } else {
    /* No PC and no stack frame associated with other events */
    caml_putword(dbg_out, 0);
    caml_putword(dbg_out, 0);
  }
  caml_flush(dbg_out);

 command_loop:

  /* Read and execute the commands sent by the debugger */
  while(1) {
    switch(getch(dbg_in)) {
    case REQ_SET_EVENT:
      pos = caml_getword(dbg_in);
      Assert (pos >= 0);
      Assert (pos < caml_code_size);
      caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), EVENT);
      break;
    case REQ_SET_BREAKPOINT:
      pos = caml_getword(dbg_in);
      Assert (pos >= 0);
      Assert (pos < caml_code_size);
      caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), BREAK);
      break;
    case REQ_RESET_INSTR:
      pos = caml_getword(dbg_in);
      Assert (pos >= 0);
      Assert (pos < caml_code_size);
      pos = pos / sizeof(opcode_t);
      caml_set_instruction(caml_start_code + pos, caml_saved_code[pos]);
      break;
    case REQ_CHECKPOINT:
#ifndef _WIN32
      i = fork();
      if (i == 0) {
        close_connection();     /* Close parent connection. */
        open_connection();      /* Open new connection with debugger */
      } else {
        caml_putword(dbg_out, i);
        caml_flush(dbg_out);
      }
#else
      caml_fatal_error("error: REQ_CHECKPOINT command");
      exit(-1);
#endif
      break;
    case REQ_GO:
      caml_event_count = caml_getword(dbg_in);
      return;
    case REQ_STOP:
      exit(0);
      break;
    case REQ_WAIT:
#ifndef _WIN32
      wait(NULL);
#else
      caml_fatal_error("Fatal error: REQ_WAIT command");
      exit(-1);
#endif
      break;
    case REQ_INITIAL_FRAME:
      frame = caml_extern_sp + 1;
      /* Fall through */
    case REQ_GET_FRAME:
      caml_putword(dbg_out, caml_stack_high - frame);
      if (frame < caml_stack_high){
        caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
      }else{
        caml_putword (dbg_out, 0);
      }
      caml_flush(dbg_out);
      break;
    case REQ_SET_FRAME:
      i = caml_getword(dbg_in);
      frame = caml_stack_high - i;
      break;
    case REQ_UP_FRAME:
      i = caml_getword(dbg_in);
      if (frame + Extra_args(frame) + i + 3 >= caml_stack_high) {
        caml_putword(dbg_out, -1);
      } else {
        frame += Extra_args(frame) + i + 3;
        caml_putword(dbg_out, caml_stack_high - frame);
        caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
      }
      caml_flush(dbg_out);
      break;
    case REQ_SET_TRAP_BARRIER:
      i = caml_getword(dbg_in);
      caml_trap_barrier = caml_stack_high - i;
      break;
    case REQ_GET_LOCAL:
      i = caml_getword(dbg_in);
      putval(dbg_out, Locals(frame)[i]);
      caml_flush(dbg_out);
      break;
    case REQ_GET_ENVIRONMENT:
      i = caml_getword(dbg_in);
      putval(dbg_out, Field(Env(frame), i));
      caml_flush(dbg_out);
      break;
    case REQ_GET_GLOBAL:
      i = caml_getword(dbg_in);
      putval(dbg_out, Field(caml_global_data, i));
      caml_flush(dbg_out);
      break;
    case REQ_GET_ACCU:
      putval(dbg_out, *caml_extern_sp);
      caml_flush(dbg_out);
      break;
    case REQ_GET_HEADER:
      val = getval(dbg_in);
      caml_putword(dbg_out, Hd_val(val));
      caml_flush(dbg_out);
      break;
    case REQ_GET_FIELD:
      val = getval(dbg_in);
      i = caml_getword(dbg_in);
      if (Tag_val(val) != Double_array_tag) {
        putch(dbg_out, 0);
        putval(dbg_out, Field(val, i));
      } else {
        double d = Double_field(val, i);
        putch(dbg_out, 1);
        caml_really_putblock(dbg_out, (char *) &d, 8);
      }
      caml_flush(dbg_out);
      break;
    case REQ_MARSHAL_OBJ:
      val = getval(dbg_in);
      safe_output_value(dbg_out, val);
      caml_flush(dbg_out);
      break;
    case REQ_GET_CLOSURE_CODE:
      val = getval(dbg_in);
      caml_putword(dbg_out, (Code_val(val)-caml_start_code) * sizeof(opcode_t));
      caml_flush(dbg_out);
      break;
    case REQ_SET_FORK_MODE:
      caml_debugger_fork_mode = caml_getword(dbg_in);
      break;
    }
  }
}
예제 #10
0
파일: docomm.c 프로젝트: dank101/4.2BSD
docommand() {
	register char	*p;
	register int	i;
	register ADDR	addr, bkaddr;
	struct proct 	*procp;
	char s[4];
	
	cntval = 1;
	adrflg = 0;
	errflg = 0;

	if (scallf) {
		doscall();
		setcur(1);
		lastcom = NOCOM;
		return;
	}
	
	if (reflag) {  /* search for regular expression */
		dore();
		lastcom = PRCOM;
		return;
	}
	
	if (cmd == '\0') {
		if (integ != 0 && var[0] != '\0') {
			error("Invalid command (1)");
			return;
		}
		if (integ != 0) { /* print line number */
			ffind(integ);
			fprint();
			lastcom = PRCOM;
			return;
		}
		if (var[0] != 0) {
			printf("Unexpected null command\n");
			return;
		}
	}
		
	switch (cmd) {
	
	case 'Y':
		debug = !debug;
		break;

	case 'V':
		version();
		break;

	case 'M':
		if (args[0]) {
			setmap(args);
		} else {
			printmap("? map", &txtmap);
			printmap("/ map", &datmap);
		}
		break;

	case 'x':
		printregs();
		break;

	case 'X':
		printpc();
		break;

	case 'a':
		if (integ) {
			cpstr(args, "l\n");
		} else if (proc[0]) {
			cpall(args, "T\n");
		} else {
			error("Bad arguments");
			break;
		}
		goto setbrk;
		break;	

	case 'l':
		setcur(1);
		lastcom = NOCOM;
		break;
		
	case 'T':
		prfrx(1);
		lastcom = NOCOM;
		break;
		
	case 't':
		prframe();
		lastcom = NOCOM;
		break;
		
	case 'e':
		p = args;
		if (*p == '\0') {
#ifndef FLEXNAMES
			printf("%.16s() in \"%s\"\n",
				curproc()->pname, curfile);
#else
			printf("%s() in \"%s\"\n",
				curproc()->pname, curfile);
#endif
			break;
		}

		while (*p != '\0')
			if (*p++ == '.') goto l1;
		/* argument is procedure name */
		procp = findproc(args);
		if ((procp->pname[0] != '\0') && (procp->sfptr != badfile)) {
			finit(adrtofilep(procp->paddr)->sfilename);
			ffind(procp->lineno);
		}
		else printf("Can't find %s\n", args);
#ifndef FLEXNAMES
		printf("%.16s() in \"%s\"\n", curproc()->pname, curfile);
#else
		printf("%s() in \"%s\"\n", curproc()->pname, curfile);
#endif
		lastcom = PRCOM;
		break;
		
	l1:	/* argument is filename */
		finit(args);
		printf("\"%s\"\n", curfile);
		lastcom = PRCOM;
		break;
		
	case 'p':
		if (integ) ffind(integ);
		fprint();
		lastcom = PRCOM;
		break;
		
	case 'q':
		exit(0);
		
	case 'w':
		if (integ) ffind(integ);
		i = fline;
		fback(WINDOW/2);
		fprintn(WINDOW);
		ffind(i);
		lastcom = PRCOM;
		break;
		
	case 'Q':
		prdebug();
		break;

	case 'z':
		if (integ) ffind(integ);
		fprintn(WINDOW);
		lastcom = PRCOM;
		break;

	case '-':
		fback(integ ? integ : 1);
		fpargs();
		lastcom = PRCOM;
		break;

	case '+':
		fforward(integ ? integ : 1);
		fpargs();
		lastcom = PRCOM;
		break;

	case '\n':
		switch (lastcom) {
		case PRCOM:
			fforward(1);
			fprint();
			break;
		case DSCOM:
			oaddr += oincr ? oincr : typetosize(otype, WORDSIZE);
			printf("0x%x/ ", oaddr);
			dispf((ADDR) oaddr, odesc,
			    oclass == N_RSYM ? oclass : N_GSYM, otype, 0, 0, DSP);
			break;
		case DSICOM:
			dot += oincr;
			prisploc();
			dispi(dot, odesc, N_GSYM, 0, 0);
			break;
		}
		break;

	case '\004':
		if (!isatty(0))
			exit(0);
		switch (lastcom) {
		case PRCOM:
			fforward(1);
			printf("\b");
			fprintn(WINDOW);
			lastcom = PRCOM;
			break;
		case DSICOM:
			printf("\b");
			for (i=0; i<WINDOW; i++) {
				dot += oincr;
				prisploc();
				if (dispi(dot, odesc, N_GSYM, 0, 0) == -1)
					break;
			}
			break;
		case DSCOM:
			printf("\b");
			for (i=0; i<WINDOW; i++) {
				oaddr += oincr ?
					oincr : typetosize(otype, WORDSIZE);
				printf("0x%x/ ", oaddr);
				if (dispf((ADDR) oaddr, odesc,
					oclass == N_RSYM ? oclass :
					N_GSYM, otype, 0, 0, DSP) == -1)
					break;
			}
			break;
		default:
			printf("\n");
		}
		break;

	case 'r':
		if (args[0] == '\0') getargs();
	case 'R':
		signo = 0;
		cpstr(oldargs, args);
		if (debug) error("calling dopcs");
		if (integ) cntval = integ;
		if (!executing) {
			executing = TRUE;
			if (integ) cntval = integ;
			dopcs('r');
			executing = FALSE;
		}
		if (debug) error("exiting dopcs");
		bkaddr = -1;
		goto f1;

	case 'c':
		signo = 0;
	case 'C':
		if (proc[0] != '\0' || integ != 0) {
			setdot();
			if (dot == -1) {
				error("Cannot set temporary breakpoint");
				break;
			}
			dopcs('b');
			bkaddr = dot;
		} else
			bkaddr = -1;
		integ = atoi(args);

f1:		if (debug) error("calling dopcs");
		if (integ) cntval = integ;
		dopcs('c');
		if (debug) error("exiting dopcs");
		if (bkaddr != -1) {
			ADDR dotsave;
			dotsave = dot;
			dot = bkaddr;
			dopcs('d');
			dot = dotsave;
		}
		if (!signo) printf("Breakpoint");
		printf(" at\n");
		setcur(1);
		lastcom = NOCOM;
		break;
		
	case 'S':
	case 's':
		signo = 0;
		integ = atoi(args);
		singstep(integ ? integ : 1, cmd);
		if (signo) printf("\n");
		setcur(1);
		lastcom = NOCOM;
		break;
		
	case 'g':
		if (pid == 0  ||  signo) {
			error("Not stopped at breakpoint");
			break;
		}
		setdot();
		if (dot == -1) {
			error("Bad address");
			break;
		}
		adrflg = 1;
		integ = atoi(args);
		if (integ) cntval = integ;
		dopcs('c');
		if (!signo) printf("Breakpoint");
		printf(" at\n");
		setcur(1);
		lastcom = NOCOM;
		break;

	case 'k':
		if (scallx) {
	 		userpc = dot = *(ADDR *)(((ADDR)&u)+PC) = pcs;
	 		*(ADDR *)(((ADDR)&u)+FP) = fps;
	 		*(ADDR *)(((ADDR)&u)+AP) = aps;
			if (bkpts)
				bkpts->flag = flagss;
			scallx = 0;
			error("Procedure killed");
			longjmp(env, 0);
		} else {
			dopcs('k');
			printf("\n");
			lastcom = NOCOM;
			break;
		}

	case 'B':
		prbkpt();
		break;

	case 'b':
	setbrk:
		if (proc[0] == '\0' && integ == 0) {
			integ = fline;
		}
		setdot();
		if (dot == -1 || dot == 0) {
			error("Cannot set breakpoint");
			break;
		}
		dopcs('b');
		s[0] = ' ';
		s[1] = cmd;
		s[2] = '\n';
		s[3] = 0;
		s[1] = cmd;
		printbkpt(s, adrtoprocp(dot), dot);
		break;
		
	case 'd':
		if (proc[0] == '\0' && integ == 0) {
			idbkpt();
			break;
		}
		setdot();
		if (dot == -1) {
			error("Non existent breakpoint");
			break;
		}
		dopcs('d');
		break;
		
	case 'D':
		dabkpt();
		error("All breakpoints deleted");
		break;

	case 'm':
		addr = varaddr(proc[0] ? proc : curproc()->pname, var);
		printf("stopped with value %d\n", monex(addr, 'd'));
		setcur(1);
		lastcom = NOCOM;
		break;
		
	case '?':
		if (!(var[0] == '.' && var[1] == '\0'))
			setdot();
		if (errflg) {
			error(errflg);
			break;
		}
		prisploc();
		dispi(dot, args[0] ? args : "i", N_GSYM, 0, 0);
		lastcom = DSICOM;
		break;

	case '/':
		if (var[0] == '.' && var[1] == '\0') {
			if (integ == 0) integ = oaddr;
			dispf((ADDR) integ, args[0] ? args : odesc,
			    oclass == N_RSYM ? oclass : N_GSYM, otype, 0, 0, DSP);
			oaddr = integ;
		} else
		if (integ && (var[0] == '\0')) {
			dispf((ADDR) integ, args, N_GSYM, 0, 0, 0, DSP);
			oaddr = integ;
			cpstr(odesc, args);
			oclass = N_GSYM;
			otype = 0;
		} else
			dispvar(proc, var, args);
		lastcom = DSCOM;
		break;
		
	case '=':
		if (var[0] == '\0') {
			if (proc[0]) {
				addr = getaddr(proc, integ);
				if (addr == -1) {
					error("Unknown address");
					break;
				}
			}
			else
				addr = integ;
			dispf(addr, args[0] ? args : "x", 0, -1, 0, 0, DSP);
		} else 
			findvar(proc, var, args[0] ? args : "x", 2);
		break;

	case '!':
		if (var[0] == '\0')
			addr = getaddr(proc, integ);
		else
			addr = varaddr(proc, var);
		if (addr == -1) 
			error("Unknown variable");
		else {
			if (number(args[0]) || eqany(args[0], ".-")) {
				char *p;
				double atof();
				union {
					struct{
						int w1, w2;
					} ww;
					double d;
				} dbl;

				p = (args[0] == '-') ? args+1 : args;
				for (; *p != '.' && *p != 'e'; p++) {
					if (!number(*p)) goto l2;
				}
				dbl.d = atof(args);
				putval(addr, 'd', dbl.ww.w1);
				if (typetodesc(sl_type,0)[0] == 'g')
					putval(addr+WORDSIZE, 'd', dbl.ww.w2);
				break;
			}
l2:			if (percentflag)
				*(ADDR *)(((ADDR)&u)+addr) = argvalue(args);
			else if (sl_class == N_RSYM && addr < 16)
				putreg(addr,typetodesc(sl_type,subflag)[0],
						argvalue(args));
			else
				putval(addr,typetodesc(sl_type,subflag)[0],
						argvalue(args));
		}
		lastcom = NOCOM;
		break;

	case '"':
		printf(args);
		break;
	}
}