void writeZStream(TAThread thread, z_stream* strm) { if(strm==NULL) { writeString(thread, "NULL"); return; } writeString(thread, "NON_NULL"); writeULong(thread, strm->adler); writeUInt(thread, strm->avail_in); writeUInt(thread, strm->avail_out); writeInt(thread, strm->data_type); writeString(thread, strm->msg); writePointer(thread, strm->state); ta_debug_printf("strm->state==%d\n", strm->state); writePointer(thread, strm->zalloc); writePointer(thread, strm->zfree); writePointer(thread, strm->opaque); writePointer(thread, strm->next_in); writePointer(thread, strm->next_out); writeULong(thread, strm->reserved); writeULong(thread, strm->total_in); writeULong(thread, strm->total_out); }
boolean SFE_TSL2561::setInterruptThreshold(unsigned int low, unsigned int high) // Set interrupt thresholds (channel 0 only) // low, high: 16-bit threshold values // Returns true (1) if successful, false (0) if there was an I2C error // (Also see getError() below) { // Write low and high threshold values if (writeUInt(TSL2561_REG_THRESH_L,low) && writeUInt(TSL2561_REG_THRESH_H,high)) return(true); return(false); }
DataOutputStream::DataOutputStream(std::ostream * ostream) { _verboseOutput = false; _ostream = ostream; if(!_ostream) throw Exception("DataOutputStream::DataOutputStream(): null pointer exception in argument."); writeUInt(ENDIAN_TYPE) ; writeUInt(getVersion()); m_scenery = Scenery::getInstance(); }
bool L2Game_RequestUserCommand::create( unsigned int commandID ) { writeReset(); writeUChar( 0xB3 ); writeUInt( commandID ); return true; }
void DataConverter::write(const osg::FrameStamp& fs) { osg::notify(osg::NOTICE)<<"writeFramestamp = "<<fs.getFrameNumber()<<" "<<fs.getReferenceTime()<<std::endl; writeUInt(fs.getFrameNumber()); writeDouble(fs.getReferenceTime()); }
int main(int argc, char *argv[]) { int file, count; if ((file = open("/dev/tty4", O_RDWR | O_NOCTTY | O_NDELAY))<0){ perror("UART: Failed to open the file.\n"); return -1; } struct termios options; tcgetattr(file, &options); options.c_cflag = B9600 | CS8 | CLOCAL; options.c_iflag = IGNPAR | ICRNL; tcflush(file, TCIFLUSH); tcsetattr(file, TCSANOW, &options); for (unsigned int i = 1; i<=200; i++) { // send the string plus the null character writeUInt(file,i); usleep(10000); } close(file); return 0; }
void writeUintList( TAThread thread, int size, unsigned int * list ) { writeInt( thread, size ); if ( size >= 0 ) { int i; for ( i = 0; i < size; i++ ) { writeUInt( thread, list[ i ] ); } ta_dealloc_memory( list ); } }
void write(CameraPacket& cameraPacket) { writeUInt(cameraPacket._byte_order); writeUInt(cameraPacket._masterKilled); write(cameraPacket._matrix); write(cameraPacket._frameStamp); writeUInt(cameraPacket._events.size()); for(osgGA::EventQueue::Events::iterator itr = cameraPacket._events.begin(); itr != cameraPacket._events.end(); ++itr) { write(*(*itr)); } }
void writeMsgUInt(unsigned int val) /*@globals msg_fd@*/ { if (msg_fd==-1) return; writeUInt(msg_fd, val); }
void logFinalReport(int killCount) { assert(killCount >= 0); if (!writeClientMessageStatusCode(__serverSocket, INT_ACK, saveLogReport) || !writeUInt(__serverSocket, (uint32_t)killCount, saveLogReport)) { exit(-1); } }
void ASMStream::writeIString(const String &s) { writeUInt(static_cast<uint32_t>(s.length())); for(uint32_t i = 0; i < s.length(); i++) { stream.write(static_cast<uint8_t>(s[i])); } }
void DataConverter::write(CameraPacket& cameraPacket) { writeUInt(cameraPacket._byte_order); writeUInt(cameraPacket._masterKilled); write(cameraPacket._matrix); write(cameraPacket._frameStamp); writeUInt(cameraPacket._events.size()); for(osgGA::EventQueue::Events::iterator itr = cameraPacket._events.begin(); itr != cameraPacket._events.end(); ++itr) { osgGA::GUIEventAdapter* event = (*itr)->asGUIEventAdapter(); if (event) write(*(event)); } }
void MessageEncoder::writeHeader(const Header& msg) { size_t fields(optimise ? optimisable(msg) : 5); if (fields) { void* token = startList8(&qpid::amqp::message::HEADER); writeBoolean(msg.isDurable()); if (fields > 1) writeUByte(msg.getPriority()); if (msg.getTtl()) writeUInt(msg.getTtl()); else if (fields > 2) writeNull(); if (msg.isFirstAcquirer()) writeBoolean(true); else if (fields > 3) writeNull(); if (msg.getDeliveryCount()) writeUInt(msg.getDeliveryCount()); else if (fields > 4) writeNull(); endList8(fields, token); } }
void NitroFile::setUintAt(int offs, u32 val) { if(cached) { iprintf("== %s: %x = %x\n", name.c_str(), offs, val); *(u32*)(cachedContents+offs) = val; cacheModified = true; return; } fseek(parent->romFile, begOffs+offs, SEEK_SET); writeUInt(parent->romFile, val); }
int main() { unsigned int const NUMS[] = { 0, 2, 42, 529, 1073741824, 2147483648u, 3141592653u, 4294967295u }; size_t i; for (i=0; i<sizeof(NUMS)/sizeof(NUMS[0]); ++i) { writeUInt(1, NUMS[i]); write(1, "\n", 1); } return EXIT_SUCCESS; }
/*@-superuser@*/ int initializeSystem(int argc, char *argv[], struct InterfaceInfoList * ifs, struct ServerInfoList * servers, struct FdInfoList * fds) { struct ConfigInfo cfg; pid_t pid, pidfile_pid; int pidfile_fd; cfg.conffile_name = CFG_FILENAME; cfg.do_fork = true; parseCommandline(argc, argv, &cfg); /*@-boundswrite@*/ getConfig(cfg.conffile_name, &cfg); initFDs(fds, &cfg); /*@=boundswrite@*/ pidfile_fd = Eopen(cfg.pidfile_name, O_WRONLY|O_CREAT, 0444); openMsgfile(cfg.logfile_name); *ifs = cfg.interfaces; *servers = cfg.servers; Eclose(0); if (cfg.do_fork) pid = fork(); else pid = 0; pidfile_pid = 0; switch (pid) { case 0 : pidfile_pid = initializeDaemon(&cfg); break; case -1 : perror("fork()"); break; default : pidfile_pid = pid; break; } if (pidfile_pid!=0) { writeUInt(pidfile_fd, pidfile_pid); (void)write(pidfile_fd, "\n", 1); } freeLimitList(&cfg.ulimits); /* It is too late to handle an error here. So just ignore it... */ (void)close(pidfile_fd); return pid; }
void loop() { static int prev_button = BUTTON_NOT_PRESSED; // Previous button press value int cur_button; // Current button press value cur_button = digitalRead(BUTTON_PIN); if ((prev_button == BUTTON_NOT_PRESSED) && (cur_button == BUTTON_PRESSED)) { writeUInt(271); // Put any number you want to send here (71 is just a test) } delay(50); // Debounce button prev_button = cur_button; }
void MessageEncoder::writeProperties(const Properties& msg) { size_t fields(optimise ? optimisable(msg) : 13); if (fields) { void* token = startList32(&qpid::amqp::message::PROPERTIES); if (msg.hasMessageId()) writeString(msg.getMessageId()); else writeNull(); if (msg.hasUserId()) writeBinary(msg.getUserId()); else if (fields > 1) writeNull(); if (msg.hasTo()) writeString(msg.getTo()); else if (fields > 2) writeNull(); if (msg.hasSubject()) writeString(msg.getSubject()); else if (fields > 3) writeNull(); if (msg.hasReplyTo()) writeString(msg.getReplyTo()); else if (fields > 4) writeNull(); if (msg.hasCorrelationId()) writeString(msg.getCorrelationId()); else if (fields > 5) writeNull(); if (msg.hasContentType()) writeSymbol(msg.getContentType()); else if (fields > 6) writeNull(); if (msg.hasContentEncoding()) writeSymbol(msg.getContentEncoding()); else if (fields > 7) writeNull(); if (msg.hasAbsoluteExpiryTime()) writeLong(msg.getAbsoluteExpiryTime()); else if (fields > 8) writeNull(); if (msg.hasCreationTime()) writeLong(msg.getCreationTime()); else if (fields > 9) writeNull(); if (msg.hasGroupId()) writeString(msg.getGroupId()); else if (fields > 10) writeNull(); if (msg.hasGroupSequence()) writeUInt(msg.getGroupSequence()); else if (fields > 11) writeNull(); if (msg.hasReplyToGroupId()) writeString(msg.getReplyToGroupId()); else if (fields > 12) writeNull(); endList32(fields, token); } }
static TACommandVerdict if_nametoindex_cmd(TAThread thread,TAInputStream stream) { char * ifname; unsigned int res; ifname = readString(&stream); START_TARGET_OPERATION(thread); res = if_nametoindex(ifname); END_TARGET_OPERATION(thread); writeUInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict read_ifnameindex_cmd(TAThread thread,TAInputStream stream) { struct if_nameindex * ptr; unsigned int if_index; char *if_name; ptr = (struct if_nameindex *)readPointer(&stream); START_TARGET_OPERATION(thread); if_index = ptr->if_index; if_name = ptr->if_name; END_TARGET_OPERATION(thread); writeUInt(thread, if_index); writeString(thread, if_name); sendResponse(thread); return taDefaultVerdict; }
void PriorityQueue_print(struct PriorityQueue const *q, int fd, void (*func)(int fd, void const*)) { char *delim = ""; size_t i; assert(q!=0); assert(func!=0); WRITE_MSG(fd, "["); for (i=0; i<q->count; ++i) { WRITE_MSG(fd, delim); (*func)(fd, addr(q->data, i, q->elem_size)); delim = ", "; } WRITE_MSG(fd, "] ("); writeUInt(fd, q->count); WRITE_MSG(fd, ")\n"); }
void write(const osgGA::GUIEventAdapter& event) { writeUInt(event.getEventType()); writeUInt(event.getKey()); writeUInt(event.getButton()); writeInt(event.getWindowX()); writeInt(event.getWindowY()); writeUInt(event.getWindowWidth()); writeUInt(event.getWindowHeight()); writeFloat(event.getXmin()); writeFloat(event.getYmin()); writeFloat(event.getXmax()); writeFloat(event.getYmax()); writeFloat(event.getX()); writeFloat(event.getY()); writeUInt(event.getButtonMask()); writeUInt(event.getModKeyMask()); writeDouble(event.getTime()); }
void writeFileStatus(TAThread thread, struct stat* buffer) { writeULLong(thread, buffer->st_dev); writeULong(thread, buffer->st_ino); //Encoding st_mode if(S_ISBLK(buffer->st_mode)) writeInt(thread, 1); else if(S_ISCHR(buffer->st_mode)) writeInt(thread, 2); else if(S_ISFIFO(buffer->st_mode)) writeInt(thread, 3); else if(S_ISREG(buffer->st_mode)) writeInt(thread, 4); else if(S_ISDIR(buffer->st_mode)) writeInt(thread, 5); else if(S_ISLNK(buffer->st_mode)) writeInt(thread, 6); else if(S_ISSOCK(buffer->st_mode)) writeInt(thread, 7); else if(S_TYPEISMQ(buffer)) writeInt(thread, 8); else if(S_TYPEISSEM(buffer)) writeInt(thread, 9); else if(S_TYPEISSHM(buffer)) writeInt(thread, 10); #ifdef S_TYPEISTMO else if(S_TYPEISTMO(buffer)) writeInt(thread, 11); #endif else writeInt(thread, 0); //Encoding S_IRWXU if(buffer->st_mode & S_IRUSR) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWUSR) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXUSR) writeInt(thread, 1); else writeInt(thread, 0); //Encoding S_IRWXG if(buffer->st_mode & S_IRGRP) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWGRP) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXGRP) writeInt(thread, 1); else writeInt(thread, 0); //Encoding S_IRWXO if(buffer->st_mode & S_IROTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWOTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXOTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISUID) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISGID) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISVTX) writeInt(thread, 1); else writeInt(thread, 0); //End of encoding st_mode writeULong(thread, buffer->st_nlink); writeUInt(thread, buffer->st_uid); writeUInt(thread, buffer->st_gid); writeULLong(thread, buffer->st_rdev); writeLLong(thread, buffer->st_size); writeLong(thread, buffer->st_atime); writeLong(thread, buffer->st_mtime); writeLong(thread, buffer->st_ctime); writeLLong(thread, buffer->st_blksize); writeLLong(thread, buffer->st_blocks); }
void CCBuffer::writeLengthAndData(const char* p_data, unsigned int u_len) { writeUInt(u_len); writeData(p_data, u_len); }
void MessageEncoder::writeMap(const qpid::types::Variant::Map& properties, const Descriptor* d, bool large) { void* token = large ? startMap32(d) : startMap8(d); for (qpid::types::Variant::Map::const_iterator i = properties.begin(); i != properties.end(); ++i) { writeString(i->first); switch (i->second.getType()) { case qpid::types::VAR_MAP: case qpid::types::VAR_LIST: //not allowed (TODO: revise, only strictly true for application-properties) whereas this is now a more general method) QPID_LOG(warning, "Ignoring nested map/list; not allowed in application-properties for AMQP 1.0"); case qpid::types::VAR_VOID: writeNull(); break; case qpid::types::VAR_BOOL: writeBoolean(i->second); break; case qpid::types::VAR_UINT8: writeUByte(i->second); break; case qpid::types::VAR_UINT16: writeUShort(i->second); break; case qpid::types::VAR_UINT32: writeUInt(i->second); break; case qpid::types::VAR_UINT64: writeULong(i->second); break; case qpid::types::VAR_INT8: writeByte(i->second); break; case qpid::types::VAR_INT16: writeShort(i->second); break; case qpid::types::VAR_INT32: writeInt(i->second); break; case qpid::types::VAR_INT64: writeULong(i->second); break; case qpid::types::VAR_FLOAT: writeFloat(i->second); break; case qpid::types::VAR_DOUBLE: writeDouble(i->second); break; case qpid::types::VAR_STRING: if (i->second.getEncoding() == BINARY) { writeBinary(i->second); } else { writeString(i->second); } break; case qpid::types::VAR_UUID: writeUuid(i->second); break; } } if (large) endMap32(properties.size()*2, token); else endMap8(properties.size()*2, token); }
void IO::writeFloat( const unsigned int& index, const vmFloat& data ) { const vmUInt* c = reinterpret_cast<const vmUInt*>( &data ); writeUInt( index, *c ); }