void VerticalRowOutputStream::writeSpecialRow(const Block & block, size_t row_num, const char * title) { writeCString("\n", ostr); row_number = 0; field_number = 0; size_t columns = block.columns(); writeCString(title, ostr); writeCString(":\n", ostr); size_t width = strlen(title) + 1; for (size_t i = 0; i < width; ++i) writeCString("─", ostr); writeChar('\n', ostr); for (size_t i = 0; i < columns; ++i) { if (i != 0) writeFieldDelimiter(); auto & col = block.getByPosition(i); writeField(*col.column, *col.type, row_num); } }
/** * Writes a null terminated string from flash program memory to UART. * You can use the macro writeString_P(STRING); , this macro * ensures that the String is stored in program memory only! * Otherwise you need to use PSTR("your string") from AVRLibC for this. * * Example: * * writeNStringP(PSTR("Robotarm System\n")); * * // There is also a Macro that makes life easier and * // you can simply write: * writeString_P("Robot ARm System\n"); * */ void writeNStringP(const char *pstring) { uint8_t c; for (;(c = pgm_read_byte_near(pstring++));writeChar(c)); }
String FieldVisitorToString::operator() (const Array & x) const { String res; WriteBufferFromString wb(res); writeChar('[', wb); for (Array::const_iterator it = x.begin(); it != x.end(); ++it) { if (it != x.begin()) wb.write(", ", 2); writeString(applyVisitor(*this, *it), wb); } writeChar(']', wb); return res; }
void TabSeparatedRowOutputStream::writeExtremes() { if (extremes) { size_t rows = extremes.rows(); size_t columns = extremes.columns(); writeChar('\n', ostr); for (size_t i = 0; i < rows; ++i) { if (i != 0) writeRowBetweenDelimiter(); writeRowStartDelimiter(); for (size_t j = 0; j < columns; ++j) { if (j != 0) writeFieldDelimiter(); writeField(*extremes.unsafeGetByPosition(j).column.get(), *extremes.unsafeGetByPosition(j).type.get(), i); } writeRowEndDelimiter(); } } }
void FTPClient::storData(std::string param) { int32_t ch; std::ifstream in; std::string token, reply; std::stringstream ss(param); // arg may be a ',' seperated list of arguments. while ( getline(ss, token, ','/* DELIMITER */) ) { // Establish Data Connection dataConnect(); //########## Send file character by character ############ in.open(token.c_str(),std::ifstream::in); ch = in.get(); while ( in.good() ) { //#TODO if the file contains NULL character. writeChar(this->datafd, (char)ch); ch = in.get(); } //####################################################### in.close(); // Close Data Connection (Indicates EOF ) close(this->datafd); // Create a new data socket for FUTURE. createDataSock(); } }
// 4.3 - this function sends out the characters of the String cmd, one by one void SDI12::sendCommand(String cmd){ wakeSensors(); // wake up sensors for (int i = 0; i < cmd.length(); i++){ writeChar(cmd[i]); // write each characters } setState(LISTENING); // listen for reply }
/** * Serializes the supplied register data into the supplied buffer, ready for sending * @param buf the buffer into which the packet will be serialized * @param buflen the length in bytes of the supplied buffer * @param topicid if sent by a gateway, contains the id for the topicname, otherwise 0 * @param packetid integer - the MQTT packet identifier * @param topicname null-terminated topic name string * @return the length of the serialized data. <= 0 indicates error */ int MQTTSNSerialize_register(unsigned char* buf, int buflen, unsigned short topicid, unsigned short packetid, MQTTSNString* topicname) { unsigned char *ptr = buf; int len = 0; int rc = 0; int topicnamelen = 0; FUNC_ENTRY; topicnamelen = (topicname->cstring) ? strlen(topicname->cstring) : topicname->lenstring.len; if ((len = MQTTSNPacket_len(MQTTSNSerialize_registerLength(topicnamelen))) > buflen) { rc = MQTTSNPACKET_BUFFER_TOO_SHORT; goto exit; } ptr += MQTTSNPacket_encode(ptr, len); /* write length */ writeChar(&ptr, MQTTSN_REGISTER); /* write message type */ writeInt(&ptr, topicid); writeInt(&ptr, packetid); memcpy(ptr, (topicname->cstring) ? topicname->cstring : topicname->lenstring.data, topicnamelen); ptr += topicnamelen; rc = ptr - buf; exit: FUNC_EXIT_RC(rc); return rc; }
void writeString(char * string, int length) { int i; for (i = 0; i < length; i++) { writeChar(string[i]); } }
/** * Serializes the supplied unsuback data into the supplied buffer, ready for sending * @param buf the buffer into which the packet will be serialized * @param buflen the length in bytes of the supplied buffer * @param packetid integer - the MQTT packet identifier * @return the length of the serialized data. <= 0 indicates error */ int MQTTSerialize_unsuback(char* buf, int buflen, int packetid) { MQTTHeader header; int rc = 0; char *ptr = buf; FUNC_ENTRY; if (buflen < 2) { rc = MQTTPACKET_BUFFER_TOO_SHORT; goto exit; } header.byte = 0; header.bits.type = UNSUBACK; writeChar(&ptr, header.byte); /* write header */ ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */ writeInt(&ptr, packetid); rc = ptr - buf; exit: FUNC_EXIT_RC(rc); return rc; }
/* Blocking write to STDIN */ int write(char * buf, int len) { int i; for(i = 0; i < len; i++) writeChar(buf[i]); return len; }
void JSONRowOutputStream::writeRowEndDelimiter() { writeChar('\n', *ostr); writeCString("\t\t}", *ostr); field_number = 0; ++row_count; }
void createFontAtlas(u8 *buffer, u32 width, u32 height) { // write entire font set to buffer u32 x = 1; u32 y = 1; u32 char_width = s_glyph_width + 1; u32 char_height = s_glyph_height + 1; for (u32 c = 32; c < 127; ++c, x += char_width) { // if at end of buffer, go to next line if ((width - x) < char_width) { x = 1; y += char_height; } // stop at end of buffer if ((height - y) < char_height) { break; } // write char to buffer writeChar(c, &buffer[(y * width) + x], width, 255); } }
int MQTTSPacket_send_willTopic(Clients* client) { char *buf, *ptr; MQTTS_WillTopic packet; int rc, len; FUNC_ENTRY; len = 1 + strlen(client->will->topic); ptr = buf = malloc(len); packet.header.type = MQTTS_WILLTOPIC; packet.header.len = len+2; packet.flags.all = 0; packet.flags.QoS = client->will->qos; packet.flags.retain = client->will->retained; writeChar(&ptr, packet.flags.all); memcpy(ptr, client->will->topic, len-1); rc = MQTTSPacket_send(client, packet.header, buf, len); free(buf); Log(LOG_PROTOCOL, 44, NULL, client->socket, client->addr, client->clientID, client->will->qos, client->will->retained, client->will->topic, rc); FUNC_EXIT_RC(rc); return rc; }
int MQTTSPacket_send_subscribe(Clients* client, char* topicName, int qos, int msgId) { MQTTS_Subscribe packet; int rc = 0; char *buf, *ptr; int datalen = 3 + strlen(topicName); FUNC_ENTRY; packet.header.len = datalen+2; packet.header.type = MQTTS_SUBSCRIBE; /* TODO: support TOPIC_TYPE_PREDEFINED/TOPIC_TYPE_SHORT */ packet.flags.all = 0; packet.flags.topicIdType = MQTTS_TOPIC_TYPE_NORMAL; packet.flags.QoS = qos; ptr = buf = malloc(datalen); writeChar(&ptr, packet.flags.all); writeInt(&ptr, msgId); memcpy(ptr, topicName, strlen(topicName)); rc = MQTTSPacket_send(client, packet.header, buf, datalen); free(buf); FUNC_EXIT_RC(rc); return rc; }
/** * This function gets called automatically if there was an I2C Error like * the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30). */ void I2C_transmissionError(uint8_t errorState) { writeString_P("\n############ I2C ERROR!!!!! - TWI STATE: 0x"); writeInteger(errorState, HEX); writeChar('\n'); errors++; }
int MQTTSPacket_send_puback(Clients* client, /*char* shortTopic, */ int topicId, int msgId, char returnCode) { MQTTS_PubAck packet; char *buf, *ptr; int rc = 0; int datalen = 5; FUNC_ENTRY; packet.header.len = 7; packet.header.type = MQTTS_PUBACK; ptr = buf = malloc(datalen); /*if (shortTopic) { writeChar(&ptr, shortTopic[0]); writeChar(&ptr, shortTopic[1]); } else */ writeInt(&ptr, topicId); writeInt(&ptr, msgId); writeChar(&ptr, returnCode); rc = MQTTSPacket_send(client, packet.header, buf, datalen); free(buf); Log(LOG_PROTOCOL, 56, NULL, socket, client->addr, client->clientID, msgId, topicId, returnCode, rc); FUNC_EXIT_RC(rc); return rc; }
void writeString(char* strg2Write){ //goes to the null character at the end of the pointer while(*strg2Write != 0){ writeChar(*strg2Write); strg2Write++; } }
void writeUnsignedByte(int value){ if (value < 0 || value > 255) { LOG_E(OMG, " Storage::writeUnsignedByte(): Invalid value, not in [0, 255]\n"); } writeChar( ((unsigned char)value)); }
void Modem::abortXModem() { timer->stop(); writeChar(CCAN); xreset(); emit xmodemDone(false); }
void writeMpre() { if (fMpre != 0) { fMPreOutIndex = fOutIndex; writeChar(fMpre, fMpreIndex, fMatraFeatures); } }
void writeTypedListElement( TAThread thread, const TypedListElement * value ) { const int * start; switch ( value->type ) { case IntTObjCode : writeString( thread, "IntTObj" ); writeInt ( thread, value->data.IntTObj ); break; case CharTObjCode : writeString( thread, "CharTObj" ); writeChar ( thread, value->data.CharTObj ); break; case ShortTObjCode : writeString( thread, "ShortTObj" ); writeShort ( thread, value->data.ShortTObj ); break; case LongTObjCode : writeString( thread, "LongTObj" ); writeLong ( thread, value->data.LongTObj ); break; case LLongTObjCode : writeString( thread, "LLongTObj" ); writeLLong ( thread, value->data.LLongTObj ); break; case IntMaxTObjCode : writeString( thread, "IntMaxTObj" ); writeIntMax( thread, value->data.IntMaxTObj ); break; case SizeTObjCode : writeString( thread, "SizeTObj" ); writeSize ( thread, value->data.SizeTObj ); break; case PtrDiffTObjCode: writeString( thread, "PtrDiffTObj" ); writeLong ( thread, value->data.PtrDiffTObj ); break; case WIntTObjCode : writeString( thread, "WIntTObj" ); writeWChar ( thread, value->data.WIntTObj ); break; case FloatTObjCode: start = (int *)& value->data.FloatTObj; writeString( thread, "FloatTObj" ); writeIntArray( thread, start, sizeof( float ) / sizeof( int ) ); break; case DoubleTObjCode: start = (int *)& value->data.DoubleTObj; writeString( thread, "DoubleTObj" ); writeIntArray( thread, start, sizeof( double ) / sizeof( int ) ); break; case LongDoubleTObjCode: start = (int *)& value->data.LongDoubleTObj; writeString( thread, "LongDoubleTObj" ); writeIntArray( thread, start, sizeof( long double ) / sizeof( int ) ); break; case CStringCode : writeString( thread, "CString" ); writeString ( thread, value->data.CString ); break; case WStringCode : writeString( thread, "WString" ); writeWString( thread, value->data.WString ); break; case VoidTPtrObjCode: writeString( thread, "VoidTPtrObj" ); writePointer( thread, value->data.VoidTPtrObj ); break; default: assertion( 0, "writeTypedListElement : unsupported type" ); break; } } // writeTypedListElement
void Modem::writeLine(const char *line) { kdDebug() << "Modem::writeLine(): " << line << endl; write(fd, (const void *) line, strlen(line)); writeChar('\r'); }
void FileChecker::load(Map & map) const { map.clear(); if (!Poco::File(files_info_path).exists()) return; std::string content; { ReadBufferFromFile in(files_info_path); WriteBufferFromString out(content); /// Библиотека JSON не поддерживает пробельные символы. Удаляем их. Неэффективно. while (!in.eof()) { char c; readChar(c, in); if (!isspace(c)) writeChar(c, out); } } JSON json(content); JSON files = json["yandex"]; for (const auto & name_value : files) map[unescapeForFileName(name_value.getName())] = name_value.getValue()["size"].toUInt(); }
boolean write(uint8_t num) { if(num < 17) { writeChar(num); return true; } return false; }
void JSONEachRowRowOutputStream::writeField(const IColumn & column, const IDataType & type, size_t row_num) { writeString(fields[field_number], ostr); writeChar(':', ostr); type.serializeTextJSON(column, row_num, ostr); ++field_number; }
/** * Send an MQTT subscribe packet down a socket. * @param topics list of topics * @param qoss list of corresponding QoSs * @param msgid the MQTT message id to use * @param dup boolean - whether to set the MQTT DUP flag * @param socket the open socket to send the data to * @param clientID the string client identifier, only used for tracing * @return the completion code (e.g. TCPSOCKET_COMPLETE) */ int MQTTPacket_send_subscribe(List* topics, List* qoss, int msgid, int dup, int socket, char* clientID) { Header header; char *data, *ptr; int rc = -1; ListElement *elem = NULL, *qosElem = NULL; int datalen; FUNC_ENTRY; header.bits.type = SUBSCRIBE; header.bits.dup = dup; header.bits.qos = 1; header.bits.retain = 0; datalen = 2 + topics->count * 3; // utf length + char qos == 3 while (ListNextElement(topics, &elem)) datalen += strlen((char*)(elem->content)); ptr = data = malloc(datalen); writeInt(&ptr, msgid); elem = NULL; while (ListNextElement(topics, &elem)) { ListNextElement(qoss, &qosElem); writeUTF(&ptr, (char*)(elem->content)); writeChar(&ptr, *(int*)(qosElem->content)); } rc = MQTTPacket_send(socket, header, data, datalen); Log(LOG_PROTOCOL, 22, NULL, socket, clientID, msgid, rc); free(data); FUNC_EXIT_RC(rc); return rc; }
void writeByte(int value){ if (value < -128 || value > 127) { LOG_E(OMG, " Storage::writeByte(): Invalid value, not in [-128, 127]\n"); } writeChar( (unsigned char)( (value+256) % 256 ) ); }
extern void FilterRequestData(REQUEST_STRUCT* request, char request_buffer[], size_t separatorindex, size_t startindex, size_t endindex) { if((separatorindex - startindex) > 0 && (endindex - separatorindex) > 2 && request != NULL) { char cmdbuffer[(separatorindex - startindex)+1]; strncpy(cmdbuffer, request_buffer+startindex, ((separatorindex - startindex)+1)); static char* proper_keys[2] = {"cmd", "val"}; int index = -1; for(uint8_t i = 0; i < 2;i++) { if(strncmp(cmdbuffer, proper_keys[i], strlen(proper_keys[i])) == 0) { index = i; break; } } switch(index) { case 0://CMD { uint16_t length = (endindex-separatorindex+1); if(length > 0) { // char filtervalue [length]; strncpy(filtervalue, request_buffer+(separatorindex+1), length); uint16_t value = strtol(filtervalue, NULL, 0); writeString("{cmd=0x"); writeInteger(value, HEX); writeChar('}'); (*request).cmd = value; } // break; } case 1: //VAL { // char filtervalue [(endindex-separatorindex)+1]; strncpy(filtervalue, request_buffer+(separatorindex+1), (endindex-separatorindex+1)); if(strlen(filtervalue) > 0) { uint16_t value = strtol(filtervalue, NULL, 0); (*request).val = value; } // break; } } } }
//Function to Print String on LCD void LCD::print(char *str) { while(*str != '\0') { writeChar(*str); str++; } }
void AnalyzeLambdas::dump(WriteBuffer & out) const { for (const auto & ast : higher_order_functions) { writeString(ast->getColumnName(), out); writeChar('\n', out); } }