/* Reply has been mostly initialised by do_command */ void send_reply() { int i; if ((vtcmd.cmd)==VTC_QUICK) { /* Only send buffer on a quick read */ writeP(portfd, &vtreply.cmd, 1); if (vtreply.cmd!=VTC_QUICK) return; /* Must have been an error */ for (i=0; i< BLKSIZE; i++) writeP(portfd, &inbuf[i], 1); return; } sum0 = 0; sum1 = 0; /* Transmit the reply */ write0(portfd, &vtreply.hdr1, 1); write1(portfd, &vtreply.hdr2, 1); write0(portfd, &vtreply.cmd, 1); write1(portfd, &vtreply.record, 1); if(block<0xff00) { unsigned char tmp; tmp = block; write0(portfd, &tmp, 1); tmp = block>>8; write1(portfd, &tmp, 1); }
void WebServer::favicon(ConnectionType type) { httpSuccess("image/x-icon", "Cache-Control: max-age=31536000\r\n"); if (type != HEAD) { P (faviconIco) = WEBDUINO_FAVICON_DATA; writeP(faviconIco, sizeof(faviconIco)); } }
/* 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); }