void HttpMultipartClient::response() { condition.lock(); responding = true; string boundary = "--RhobanMultipartBoundary\r\n"; ostringstream oss; oss << "HTTP/1.0 200 OK\r\n"; oss << "Content-type: multipart/x-mixed-replace; boundary=" << boundary; oss << "\r\n"; transmitString(oss.str()); char dummy; setBlocking(false); while (!isDead()) { receive(&dummy, 1); condition.wait(); oss.str(""); oss << boundary; oss << "Content-type: " << type << "\r\n"; oss << "Content-length: " << frame->length() << "\r\n"; oss << "\r\n" << *frame; transmitString(oss.str()); } condition.unlock(); }
/** * Get register * \param reg Register name ('a' to 'h') * \returns token *DO NOT FREE* */ token_t* getReg(char reg) { int regNum = reg - 'a'; if ((regNum < 0) || (regNum >= NUM_REGS)) { transmitString("# Register '"); transmit(®, 1); transmitString("' out of range #" EOL); return &emptyReg; } if (regs[regNum] == NULL) { transmitString("# Register '"); transmit(®, 1); transmitString("' undefined #" EOL); return &emptyReg; } return regs[regNum]; }
//*************************************************** //Function to transmit hex format data //first argument indicates type: CHAR, INT or LONG //Second argument is the data to be displayed //*************************************************** void transmitHex( unsigned char dataType, unsigned long data ) { unsigned char count, i, temp; unsigned char dataString[] = "0x "; if (dataType == CHAR) count = 2; if (dataType == INT) count = 4; if (dataType == LONG) count = 8; for(i=count; i>0; i--) { temp = data % 16; if((temp>=0) && (temp<10)) dataString [i+1] = temp + 0x30; else dataString [i+1] = (temp - 10) + 0x41; data = data/16; } transmitString (dataString); }