static void writeGlyphLine(ufwCtx h, float x0, float y0) { writeStr(h, "\t\t\t<point x=\""); writeReal(h, x0); writeStr(h, "\" y=\""); writeReal(h, y0); writeLine(h, "\" type=\"line\"/>"); }
static void writeGlyphInitialCurve(ufwCtx h, float *coords) { writeStr(h, "\t\t\t<point x=\""); writeReal(h, coords[0]); writeStr(h, "\" y=\""); writeReal(h, coords[1]); writeLine(h, "\" type=\"curve\"/>"); }
/* * packetConnect:组EDP连接包 * 首先创建EDP缓存空间,按照EDP协议组EDP连接包 * 分配的内存需要在发送之后free掉 * devid: 设备id * key:APIKey */ edp_pkt *packetConnect(const int8* devid, const int8* key) { int32 remainlen; edp_pkt* pkt; if((pkt = packetCreate()) == NULL) return NULL; /* msg type */ writeByte(pkt, CONNREQ); /* remain len */ remainlen = (2 + 3) + 1 + 1 + 2 + (2 + strlen(devid)) + (2 + strlen(key)); writeRemainlen(pkt, remainlen); /* protocol desc */ writeStr(pkt, PROTOCOL_NAME); /* protocol version */ writeByte(pkt, PROTOCOL_VERSION); /* connect flag */ writeByte(pkt, 0x40); /* keep time */ writeByte(pkt, 0); writeByte(pkt, 0x80); /* DEVID */ writeStr(pkt, devid); /* auth key */ writeStr(pkt, key); return pkt; }
void CssPrettyWriter::writeRulesetEnd() { writeStr(";", 1); newline(); indent_size--; indent(); writeStr("}", 1); newline(); }
static void writeGlyphFinalCurve(ufwCtx h, float *coords) { writeStr(h, "\t\t\t<point x=\""); writeReal(h, coords[0]); writeStr(h, "\" y=\""); writeReal(h, coords[1]); writeLine(h, "\" />"); writeStr(h, "\t\t\t<point x=\""); writeReal(h, coords[2]); writeStr(h, "\" y=\""); writeReal(h, coords[3]); writeLine(h, "\" />"); }
void CGenerator::EndStruct() { // verbose output writeStr("};\n\n", stdout); // do the work writeStructEnd(); }
void accelDisable() { uint8_t value; int n; // Try 10 times to shutdown to make sure battery doesn't get drained for(n=0;n<10;n++) { accelAssertNSS(); // Send address accelSpiCycle(LIS331DLH_REG_CTRL_REG1); // Send config value accelSpiCycle(LIS331DLH_CR1_PM_POWERDOWN); accelDeassertNSS(); // Now try to read back the bits accelAssertNSS(); accelSpiCycle(LIS331DLH_REG_CTRL_REG1 | LIS331DLH_SPI_READ); value=accelSpiCycle(0); accelDeassertNSS(); if((value&0xe0)==0) break; } #if 0 if (value&0xe0) { writeStr("!aD"); } #endif }
NS_IMETHODIMP nsMsgFilterList::WriteStrAttr(nsMsgFilterFileAttribValue attrib, const char *aStr, nsIOutputStream *aStream) { nsresult rv = NS_OK; if (aStr && *aStr && aStream) // only proceed if we actually have a string to write out. { char *escapedStr = nullptr; if (PL_strchr(aStr, '"')) escapedStr = nsMsgSearchTerm::EscapeQuotesInStr(aStr); const char *attribStr = GetStringForAttrib(attrib); if (attribStr) { uint32_t bytesWritten; nsAutoCString writeStr(attribStr); writeStr.AppendLiteral("=\""); writeStr.Append((escapedStr) ? escapedStr : aStr); writeStr.AppendLiteral("\"" MSG_LINEBREAK); rv = aStream->Write(writeStr.get(), writeStr.Length(), &bytesWritten); } PR_Free(escapedStr); } return rv; }
void CssPrettyWriter::indent() { int i; if (indent_size == 0) return; for (i = 0; i < indent_size; i++) writeStr(" ", 2); }
void CGenerator::BeginStruct() { // verbose output writeRep("struct $(name)\n", stdout); writeStr("{\n", stdout); // do the work writeStructBegin(); }
/* Write formatted data to dst stream. This function must only be called when the maximum size of the resulting formatted string is known in advance. It must never be called with a string that has been passed into this library since it might cause a buffer overrun. Those strings may be handled safely by calling writeStr() directly. */ static void CTL_CDECL writeFmt(ufwCtx h, char *fmt, ...) { char buf[200]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); writeStr(h, buf); va_end(ap); }
void CssPrettyWriter::writeRulesetStart(const TokenList &selector) { indent(); writeSelector(selector); writeStr(" {", 2); newline(); indent_size++; }
/* * packetDataSaveTrans:组EDP数据存储转发包 * 首先创建EDP缓存空间,按照EDP协议组EDP数据存储转发包 * 分配的内存需要在发送之后free掉 * devid: 设备id * streamId:数据流ID,即数据流名 * val: 字符串形式的数据值 */ edp_pkt *packetDataSaveTrans(const int8* destId, const int8* streamId, const int8 *val) { int32 remainlen; int8 tmp[200]; int16 str_len; edp_pkt *pkt; if((pkt = packetCreate()) == NULL) return pkt; /* 生成数据类型格式5的数据类型 */ sprintf(tmp, ",;%s,%s", streamId, val); str_len = strlen(tmp); /* msg type */ writeByte(pkt, SAVEDATA); if (destId != NULL) { /* remain len */ remainlen = 1 + (2 + strlen(destId)) + 1 + (2 + str_len); writeRemainlen(pkt, remainlen); /* translate address flag */ writeByte(pkt, 0x80); /* dst devid */ writeStr(pkt, destId); } else { /* remain len */ remainlen = 1 + 1 + (2 + str_len); writeRemainlen(pkt, remainlen); /* translate address flag */ writeByte(pkt, 0x00); } /* json flag */ writeByte(pkt, 5); /* json */ writeStr(pkt, tmp); return pkt; }
// Set the size of the kernel's trace buffer in kilobytes. static bool setTraceBufferSizeKB(int size) { char str[32] = "1"; int len; if (size < 1) { size = 1; } snprintf(str, 32, "%d", size); return writeStr(k_traceBufferSizePath, str); }
int dprinti(text_t *device, const char *fmt, ...) { char buf[256]; va_list args; int r; va_start(args, fmt); r = _intsprnt(fmt, args, buf); va_end(args); writeStr(device, buf); return r; }
void TTerminal::draw() { short i; ushort begLine, endLine; char s[256]; ushort bottomLine; bottomLine = size.y + delta.y; if( limit.y > bottomLine ) { endLine = prevLines( queFront, limit.y - bottomLine ); bufDec( endLine ); } else endLine = queFront; if( limit.y > size.y ) i = size.y - 1; else { for( i = limit.y; i <= size.y - 1; i++ ) writeChar(0, i, ' ', 1, size.x); i = limit.y - 1; } for( ; i >= 0; i-- ) { begLine = prevLines(endLine, 1); if (endLine >= begLine) { int T = int( endLine - begLine ); memcpy( s, &buffer[begLine], T ); s[T] = EOS; } else { int T = int( bufSize - begLine); memcpy( s, &buffer[begLine], T ); memcpy( s+T, buffer, endLine ); s[T+endLine] = EOS; } if( delta.x >= strlen(s) ) *s = EOS; else strcpy( s, &s[delta.x] ); writeStr( 0, i, s, 1 ); writeChar( strlen(s), i, ' ', 1, size.x ); endLine = begLine; bufDec( endLine ); } }
void CssPrettyWriter::writeDeclaration(const Token &property, const TokenList &value) { indent(); if (sourcemap != NULL) sourcemap->writeMapping(column, property); writeToken(property); writeStr(": ", 2); writeValue(value); }
void wasm::writeImport(raw_ostream &OS, const WasmImport &Import) { writeStr(OS, Import.Module, "import module name"); writeStr(OS, Import.Field, "import field name"); writeU8(OS, Import.Kind, "import kind"); switch (Import.Kind) { case WASM_EXTERNAL_FUNCTION: writeUleb128(OS, Import.SigIndex, "import sig index"); break; case WASM_EXTERNAL_GLOBAL: writeGlobalType(OS, Import.Global); break; case WASM_EXTERNAL_EVENT: writeEventType(OS, Import.Event); break; case WASM_EXTERNAL_MEMORY: writeLimits(OS, Import.Memory); break; case WASM_EXTERNAL_TABLE: writeTableType(OS, Import.Table); break; default: fatal("unsupported import type: " + Twine(Import.Kind)); } }
nsresult nsMsgFilterList::WriteIntAttr(nsMsgFilterFileAttribValue attrib, int value, nsIOutputStream *aStream) { nsresult rv = NS_OK; const char *attribStr = GetStringForAttrib(attrib); if (attribStr) { uint32_t bytesWritten; nsAutoCString writeStr(attribStr); writeStr.AppendLiteral("=\""); writeStr.AppendInt(value); writeStr.AppendLiteral("\"" MSG_LINEBREAK); rv = aStream->Write(writeStr.get(), writeStr.Length(), &bytesWritten); } return rv; }
void displayTicks(void) { writeStr(xbee, "i = "); writeDec(xbee, i); writeStr(xbee, " eL = "); writeDec(xbee, ticksLeftCalc - ticksLeft); writeStr(xbee, " eR = "); writeDec(xbee, ticksRightCalc - ticksRight); writeStr(xbee, " LSC = "); writeDec(xbee, speedRight); writeStr(xbee, " LTC = "); writeDec(xbee, ticksLeftCalc); writeStr(xbee, " LT = "); writeDec(xbee, ticksLeft); writeStr(xbee, " RSC = "); writeDec(xbee, speedRight); writeStr(xbee, " RTC = "); writeDec(xbee, ticksRightCalc); writeStr(xbee, " RT = "); writeDec(xbee, ticksRight); writeChar(xbee, '\r'); }
/* Add horizontal advance width. */ static void glyphWidth(abfGlyphCallbacks *cb, float hAdv) { ufwCtx h = cb->direct_ctx; if (h->err.code != 0) return; /* Pending error */ else if (h->path.state != 1) { /* Call sequence error */ h->err.code = ufwErrBadCall; return; } writeStr(h, "\t<advance width=\""); writeInt(h, (long)roundf(hAdv)); writeLine(h, "\"/>"); h->path.state = 2; }
/* Write null-terminated string to dst steam and escape XML reserved characters. */ static void writeXMLStr(ufwCtx h, const char *s) { /* 64-bit warning fixed by cast here */ long len = (long)strlen(s); int i; char buf[9]; unsigned char code; for (i = 0; i < len; i++) { code = s[i]; if (code & 0x80) { writeStr(h, "&#x"); sprintf(buf, "%X", code); writeStr(h, buf); writeStr(h, ";"); } else { switch (code) { case '<': writeStr(h, "<"); break; case '>': writeStr(h, ">"); break; case '&': writeStr(h, "&"); break; case '"': writeStr(h, """); break; default: if (code < 0x20 && !(code == 0x9 || code == 0xa || code == 0xd)) continue; /* xml 1.0 limits control points to x9,xa,xd */ buf[0] = code; buf[1] = '\0'; writeStr(h, buf); } } } }
void wasm::writeExport(raw_ostream &OS, const WasmExport &Export) { writeStr(OS, Export.Name, "export name"); writeU8(OS, Export.Kind, "export kind"); switch (Export.Kind) { case WASM_EXTERNAL_FUNCTION: writeUleb128(OS, Export.Index, "function index"); break; case WASM_EXTERNAL_GLOBAL: writeUleb128(OS, Export.Index, "global index"); break; case WASM_EXTERNAL_MEMORY: writeUleb128(OS, Export.Index, "memory index"); break; case WASM_EXTERNAL_TABLE: writeUleb128(OS, Export.Index, "table index"); break; default: fatal("unsupported export type: " + Twine(Export.Kind)); } }
// Enable or disable a kernel option by writing a "1" or a "0" into a /sys file. static bool setKernelOptionEnable(const char* filename, bool enable) { return writeStr(filename, enable ? "1" : "0"); }
void ONScripter::saveSaveFile2( bool output_flag ) { int i, j; writeInt( 1, output_flag ); writeInt( (sentence_font.is_bold?1:0), output_flag ); writeInt( (sentence_font.is_shadow?1:0), output_flag ); writeInt( 0, output_flag ); writeInt( (rmode_flag)?1:0, output_flag ); writeInt( sentence_font.color[0], output_flag ); writeInt( sentence_font.color[1], output_flag ); writeInt( sentence_font.color[2], output_flag ); writeStr( cursor_info[0].image_name, output_flag ); writeStr( cursor_info[1].image_name, output_flag ); writeInt( window_effect.effect, output_flag ); writeInt( window_effect.duration, output_flag ); writeStr( window_effect.anim.image_name, output_flag ); // probably writeInt( sentence_font.top_xy[0], output_flag ); writeInt( sentence_font.top_xy[1], output_flag ); writeInt( sentence_font.num_xy[0], output_flag ); writeInt( sentence_font.num_xy[1], output_flag ); writeInt( sentence_font.font_size_xy[0], output_flag ); writeInt( sentence_font.font_size_xy[1], output_flag ); writeInt( sentence_font.pitch_xy[0], output_flag ); writeInt( sentence_font.pitch_xy[1], output_flag ); for ( i=0 ; i<3 ; i++ ) writeChar( sentence_font.window_color[2-i], output_flag ); writeChar( ( sentence_font.is_transparent )?0x00:0xff, output_flag ); writeInt( sentence_font.wait_time, output_flag ); writeInt( sentence_font_info.orig_pos.x, output_flag ); writeInt( sentence_font_info.orig_pos.y, output_flag ); writeInt( sentence_font_info.orig_pos.w + sentence_font_info.orig_pos.x - 1, output_flag ); writeInt( sentence_font_info.orig_pos.h + sentence_font_info.orig_pos.y - 1, output_flag ); writeStr( sentence_font_info.image_name, output_flag ); writeInt( (cursor_info[0].abs_flag)?0:1, output_flag ); writeInt( (cursor_info[1].abs_flag)?0:1, output_flag ); writeInt( cursor_info[0].orig_pos.x, output_flag ); writeInt( cursor_info[1].orig_pos.x, output_flag ); writeInt( cursor_info[0].orig_pos.y, output_flag ); writeInt( cursor_info[1].orig_pos.y, output_flag ); writeStr( bg_info.file_name, output_flag ); for ( i=0 ; i<3 ; i++ ) writeStr( tachi_info[i].image_name, output_flag ); for ( i=0 ; i<3 ; i++ ) writeInt( tachi_info[i].orig_pos.x, output_flag ); for ( i=0 ; i<3 ; i++ ) writeInt( tachi_info[i].orig_pos.y, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( -1, output_flag ); writeInt( -1, output_flag ); writeInt( -1, output_flag ); for ( i=0 ; i<MAX_SPRITE_NUM ; i++ ){ AnimationInfo *ai = &sprite_info[i]; writeStr( ai->image_name, output_flag ); writeInt( ai->orig_pos.x, output_flag ); writeInt( ai->orig_pos.y, output_flag ); writeInt( ai->visible?1:0, output_flag ); writeInt( ai->current_cell, output_flag ); if (ai->trans == 256) writeInt( -1, output_flag ); else writeInt( ai->trans, output_flag ); } writeVariables( 0, script_h.global_variable_border, output_flag ); // nested info int num_nest = 0; NestInfo *info = root_nest_info.next; while( info ){ if (info->nest_mode == NestInfo::LABEL) num_nest++; else if (info->nest_mode == NestInfo::FOR) num_nest+=4; info = info->next; } writeInt( num_nest, output_flag ); info = root_nest_info.next; while( info ){ if (info->nest_mode == NestInfo::LABEL){ writeInt( script_h.getOffset( info->next_script ), output_flag ); } else if (info->nest_mode == NestInfo::FOR){ writeInt( info->var_no, output_flag ); writeInt( info->to, output_flag ); writeInt( info->step, output_flag ); writeInt( -script_h.getOffset( info->next_script ), output_flag ); } info = info->next; } writeInt( (monocro_flag)?1:0, output_flag ); for ( i=0 ; i<3 ; i++ ) writeInt( monocro_color[2-i], output_flag ); writeInt( nega_mode, output_flag ); // sound writeStr( midi_file_name, output_flag ); // MIDI file writeStr( wave_file_name, output_flag ); // wave, waveloop if ( current_cd_track >= 0 ) // play CD writeInt( current_cd_track, output_flag ); else writeInt( -1, output_flag ); writeInt( (midi_play_loop_flag)?1:0, output_flag ); // play, playonce MIDI writeInt( (wave_play_loop_flag)?1:0, output_flag ); // wave, waveloop writeInt( (cd_play_loop_flag)?1:0, output_flag ); // play, playonce writeInt( (music_play_loop_flag)?1:0, output_flag ); // bgm, mp3, mp3loop writeInt( (mp3save_flag)?1:0, output_flag ); if (mp3save_flag) writeStr( music_file_name, output_flag ); else writeStr( NULL, output_flag ); writeInt( (erase_text_window_mode>0)?1:0, output_flag ); writeInt( 1, output_flag ); for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){ if ( bar_info[i] ){ writeInt( bar_info[i]->param, output_flag ); writeInt( bar_info[i]->orig_pos.x, output_flag ); writeInt( bar_info[i]->orig_pos.y, output_flag ); writeInt( bar_info[i]->max_width, output_flag ); writeInt( bar_info[i]->orig_pos.h, output_flag ); writeInt( bar_info[i]->max_param, output_flag ); for ( j=0 ; j<3 ; j++ ) writeChar( bar_info[i]->color[2-j], output_flag ); writeChar( 0x00, output_flag ); } else{ writeInt( 0, output_flag ); writeInt( -1, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); } } for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){ if ( prnum_info[i] ){ writeInt( prnum_info[i]->param, output_flag ); writeInt( prnum_info[i]->orig_pos.x, output_flag ); writeInt( prnum_info[i]->orig_pos.y, output_flag ); writeInt( prnum_info[i]->font_size_xy[0], output_flag ); writeInt( prnum_info[i]->font_size_xy[1], output_flag ); for ( j=0 ; j<3 ; j++ ) writeChar( prnum_info[i]->color_list[0][2-j], output_flag ); writeChar( 0x00, output_flag ); } else{ writeInt( 0, output_flag ); writeInt( -1, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); } } writeInt( 1, output_flag ); // unidentified (not 1) data in version 205 writeInt( 0, output_flag ); writeInt( 1, output_flag ); writeStr( btndef_info.image_name, output_flag ); writeArrayVariable(output_flag); writeInt( 0, output_flag ); writeChar( (erase_text_window_mode==2)?1:0, output_flag ); writeChar( 0, output_flag ); writeChar( 0, output_flag ); writeChar( 0, output_flag ); writeStr( loop_bgm_name[0], output_flag ); writeStr( loop_bgm_name[1], output_flag ); writeInt( (rubyon_flag)?1:0, output_flag ); writeInt( ruby_struct.font_size_xy[0], output_flag ); writeInt( ruby_struct.font_size_xy[1], output_flag ); writeStr( ruby_struct.font_name, output_flag ); writeInt( 0, output_flag ); for ( i=0 ; i<MAX_SPRITE2_NUM ; i++ ){ AnimationInfo *ai = &sprite2_info[i]; writeStr( ai->image_name, output_flag ); writeInt( ai->orig_pos.x, output_flag ); writeInt( ai->orig_pos.y, output_flag ); writeInt( ai->scale_x, output_flag ); writeInt( ai->scale_y, output_flag ); writeInt( ai->rot, output_flag ); writeInt( ai->visible?1:0, output_flag ); if (ai->trans == 256) writeInt( -1, output_flag ); else writeInt( ai->trans, output_flag ); writeInt( ai->blending_mode, output_flag ); } writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 1, output_flag ); // added in version 205 writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeInt( 0, output_flag ); writeChar( 0, output_flag ); // added in version 205 writeInt( 0, output_flag ); // added in version 206 writeInt( game_height/3, output_flag ); // added in version 206 writeInt( game_height*2/3, output_flag ); // added in version 206 writeInt( game_height, output_flag ); // added in version 206 writeInt( underline_value, output_flag ); // changed in version 207 Page *page = current_page; int num_page = 0; while( page != start_page ){ page = page->previous; num_page++; } writeInt( num_page, output_flag ); for ( i=0 ; i<num_page ; i++ ){ for ( j=0 ; j<page->text_count ; j++ ) writeChar( page->text[j], output_flag ); writeChar( 0, output_flag ); page = page->next; } page = start_page; writeInt(num_page, output_flag); for (i=0 ; i<num_page ; i++){ if (page->tag) for ( j=0 ; j<(int)strlen(page->tag) ; j++ ) writeChar( page->tag[j], output_flag ); writeChar( 0, output_flag ); page = page->next; } writeInt( current_label_info.start_line + current_line, output_flag ); char *buf = script_h.getAddressByLine( current_label_info.start_line + current_line ); //printf("save %d:%d\n", current_label_info.start_line, current_line); i = 0; if (!script_h.isText()){ while( buf != script_h.getCurrent() ){ if ( *buf == ':' ) i++; buf++; } } writeInt( i, output_flag ); }
void MirandaSettings::writeTree(const char* szSetting, const SettingsTree& value) const { writeStr(szSetting, value.toString().c_str()); }
virtual int writeFloat(float n) { char buf[64]; sprintf(buf, "%f", n); return writeStr(buf); }
// Enable or disable the kernel's use of the global clock. Disabling the global // clock will result in the kernel using a per-CPU local clock. static bool setGlobalClockEnable(bool enable) { return writeStr(k_traceClockPath, enable ? "global" : "local"); }
void writeFloatPrecision(text_t *p, float number, int width, int precision) { char str[20]; char *fs = float2string(number, str, width, precision); writeStr(p, fs); }
virtual int writeUInt(int n) { char buf[64]; sprintf(buf, "%u", n); return writeStr(buf); }