Esempio n. 1
0
static void redraw_line(char *prompt, char *buffer, int pos) 
{
int c;

writeC(CR);

c = *prompt++;
	
  while (c) 
  {
  writeC(c);
  c = *prompt++;
  }	

redraw_eol(buffer, 0);
backup(buffer, pos);
}
Esempio n. 2
0
void prettyC(int c) 
{
static int n;

  if (c == '\t') 
  {
    do 
    {
    writeC(' ');
    } while (++n & 7);
  return;
  }

  if (c == '\n') 
  {
  n = 0;
  writeC('\r');
  }

  if (c >= 0x20) n++; writeC(c);
}
Esempio n. 3
0
void write0(char *s) 
{
int c;

c = *s++;

  while (c) 
  {
  writeC(c);
  c = *s++;
  }
}
Esempio n. 4
0
static void redraw_eol (char *buffer, int pos) 
{
int c;

c = buffer[pos++];

  while (c) 
  {
  writeC(c);
  c = buffer[pos++];
  }
}
Esempio n. 5
0
void newLine(void) 
{
writeC('\r');
writeC('\n');
}
Esempio n. 6
0
	void iobFile::writeStr( const char *str )
	{
		unsigned int len = (unsigned int) strlen( str );
		writeUI( len );
		for (unsigned int i=0; i<len; i++) writeC( str[i] );
	}
Esempio n. 7
0
/* Get a command from the client.
 * If a command is received, returns 1,
 * otherwise return 0.
 */
int get_command(struct vtcmd *v)
{
  int i,loc;
  char ch,bootbuf[40];

  sum0 = 0;
  sum1 = 0;

  /* Get a valid command from the client */
  read0(portfd, &v->hdr1, 1);

  /* Send down the bootstrap code to ODT if we see an @ sign */
  if ((havesentbootcode==0) && (v->hdr1 == '@')) {
    writeC(ttyfd,&v->hdr1,1);
    for (i=0,loc=BOOTSTART;i<(sizeof(bootcode)/sizeof(int));i++,loc+=2) {
	sprintf(bootbuf, "%06o/", loc);
	writeP(portfd, bootbuf, strlen(bootbuf));

	/* wait for current value to print */
	while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch==' ') break; }
	sprintf(bootbuf, "%06o\r", bootcode[i]);
	writeP(portfd, bootbuf, strlen(bootbuf));

	/* and suck up any characters sent from ODT */
	while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch=='@') break; }
    }
    sprintf(bootbuf, "r6/", loc);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch==' ') break; }
    sprintf(bootbuf, "%06o\r", BOOTSTACK);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch=='@') break; }
    sprintf(bootbuf, "r7/", loc);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch==' ') break; }
    sprintf(bootbuf, "%06o\r", BOOTSTART);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch=='@') break; }
    sprintf(bootbuf, "rs/", loc);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch==' ') break; }
    sprintf(bootbuf, "%06o\r", 000340);
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch=='@') break; }
    sprintf(bootbuf, "p");
    writeP(portfd, bootbuf, strlen(bootbuf));
    while (1) { readP(portfd, &ch, 1); writeC(ttyfd,&ch,1); if (ch=='p') break; }
    havesentbootcode=1; return(0);
  }

  if (v->hdr1 != VT_HDR1) { v->hdr1&= 127; writeC(1,&v->hdr1, 1); return(0); }
  read1(portfd, &v->hdr2, 1);
  if (v->hdr2 != VT_HDR2) { v->hdr1&= 127; writeC(1,&v->hdr1, 1); v->hdr2&= 127; writeC(1,&v->hdr2, 1); return(0); }

  read0(portfd, &v->cmd, 1); read1(portfd, &v->record, 1);
  read0(portfd, &v->blklo, 1); read1(portfd, &v->blkhi, 1);
  block = v->blkhi<<8&0xff00 | v->blklo&0xff;
  if(block>=0xff00)
	{
	unsigned char tmp0,tmp1;

	read0(portfd, &tmp0, 1);
	read1(portfd, &tmp1, 1);
	block = tmp1<<16&0xff0000 | tmp0<<8&0xff00 | v->blklo&0xff;
	}


  /* All done if a quick read */
  if (v->cmd == VTC_QUICK) return(1);

  /* Retrieve the block if a WRITE cmd */
  if (v->cmd == VTC_WRITE) {
    for (i = 0; i < BLKSIZE; i++) {
      read0(portfd, &inbuf[i], 1); i++;
      read1(portfd, &inbuf[i], 1);
    }
  }

  /* Get the checksum */
  read0(portfd, &(v->sum0), 1);
  read1(portfd, &(v->sum1), 1);

  /* Try again on a bad checksum */
  if (sum0 | sum1)
    { fputc('e',stderr); return(0); }

  return(1);
}
Esempio n. 8
0
static void backspace (int n) 
{
  while (n--) writeC(BACKSPACE);
}