/* Returns false on an error */ static rbool decode_args(int ip,op_rec *oprec) { rbool grammer_arg; /* Have NOUN/OBJECT that is 0 and so failed argok tests */ if (oprec->errmsg!=NULL) { if (!PURE_ERROR) writeln(oprec->errmsg); return 0; } if (DEBUG_AGT_CMD && !supress_debug) { if (oprec->negate) { /* Output NOT */ debug_cmd_out(ip,108,0,0,0); ip++; } } if (DEBUG_AGT_CMD && !supress_debug) debug_cmd_out(ip,oprec->op,oprec->arg1,oprec->arg2,oprec->optype); /* This checks and translates the arguments */ if (!argok(oprec->opdata,&(oprec->arg1),&(oprec->arg2), oprec->optype,&grammer_arg)) { /* Don't report errors for null NOUN/OBJECT/ACTOR arguments used in conditional tokens */ if (grammer_arg && oprec->op<=MAX_COND) return 0; if (!PURE_ERROR) { if (DEBUG_AGT_CMD && !supress_debug) debugout("\n"); writeln("GAME ERROR: Invalid argument to metacommand token."); } return 0; } return 1; }
/* This function assumes that at least one between field1 and field2 is not empty. */ void print_fields (const char* field1, const char* field2, size_t l1, size_t l2, unsigned long lineno1, unsigned long lineno2, unsigned long fieldno1, unsigned long fieldno2) { fieldno1++; /* The field number must start from 1, not from 0 */ fieldno2++; /* The field number must start from 1, not from 0 */ if (*field1 == '\0') { printf ("##%-7lu <==\n##%-7lu #>%-3lu ==> ", lineno1, lineno2, fieldno2); /* length(" #> ") + 3 = 7 white spaces before the arrow */ writeln (field2, 0); } else if (*field2 == '\0') { printf ("##%-7lu #>%-3lu <== ", lineno1, fieldno1); writeln (field1, 0); /* length(" #> ") + 3 = 7 white spaces before the arrow */ printf ("##%-7lu ==>\n", lineno2); } else { printf ("##%-7lu #:%-3lu <== ", lineno1, fieldno1); print_head (field1, l1); putchar ('\n'); printf ("##%-7lu #:%-3lu ==> ", lineno2, fieldno2); print_head (field2, l2); putchar ('\n'); } }
void IGCWriter::header(const BrokenDateTime &DateTime, const TCHAR *pilot_name, const TCHAR *aircraft_model, const TCHAR *aircraft_registration, const TCHAR *strAssetNumber, const TCHAR *driver_name) { char datum[] = "HFDTM100Datum: WGS-84"; char temp[100]; // Flight recorder ID number MUST go first.. sprintf(temp, "AXCS%c%c%c", (char)strAssetNumber[0], (char)strAssetNumber[1], (char)strAssetNumber[2]); writeln(temp); sprintf(temp, "HFDTE%02u%02u%02u", DateTime.day, DateTime.month, DateTime.year % 100); writeln(temp); if (!Simulator) writeln(GetHFFXARecord()); write_tstring("HFPLTPILOT:", pilot_name); write_tstring("HFGTYGLIDERTYPE:", aircraft_model); write_tstring("HFGIDGLIDERID:", aircraft_registration); write_tstring("HFFTYFR TYPE:XCSOAR,XCSOAR ", XCSoar_VersionStringOld); write_tstring("HFGPS: ", driver_name); writeln(datum); if (!Simulator) writeln(GetIRecord()); }
void IGCWriter::StartDeclaration(const BrokenDateTime &FirstDateTime, const int ntp) { // TODO bug: this is causing problems with some analysis software // maybe it's because the date and location fields are bogus char start[] = "C0000000N00000000ETAKEOFF"; char temp[100]; // JMW added task start declaration line // LGCSTKF013945TAKEOFF DETECTED // IGC GNSS specification 3.6.1 sprintf(temp, "C%02u%02u%02u%02u%02u%02u0000000000%02d", // DD MM YY HH MM SS DD MM YY IIII TT FirstDateTime.day, FirstDateTime.month, FirstDateTime.year % 100, FirstDateTime.hour, FirstDateTime.minute, FirstDateTime.second, ntp - 2); writeln(temp); // takeoff line // IGC GNSS specification 3.6.3 writeln(start); }
/* This function assumes that at least one between line1 and line2 is not empty (!NULL). */ void print_lines (const char* line1, const char* line2, unsigned long lineno1, unsigned long lineno2, int delimiter_only) { puts (LINE_SEP); if (!delimiter_only) { if (!line1) { printf (" <==\n##%-7lu ==> ", lineno2); writeln (line2, 1); } else if (!line2) { printf ("##%-7lu <== ", lineno1); writeln (line1, 0); printf (" ==>\n\n"); } else { printf ("##%-7lu <== ", lineno1); writeln (line1, 0); printf ("##%-7lu ==> ", lineno2); writeln (line2, 1); } } }
/** * ステータスラインと、標準メッセージヘッダを出力します。 */ NyLPC_TBool NyLPC_cHttpHeaderWriter_writeResponseHeader(NyLPC_TcHttpHeaderWriter_t* i_inst,NyLPC_TUInt16 i_status) { NyLPC_TChar v[12]; const char* m=getStatusMessage(i_status); //エラー状態ならなにもしない。 if(i_inst->_is_error){ return NyLPC_TBool_FALSE; } //検索に失敗したら500番に変更 if(m==NULL){ i_status=500; m=getStatusMessage(500); } //ステータスラインの記述 if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,"HTTP/1.1 ",9)){ NyLPC_OnErrorGoto(Error); } NyLPC_itoa(i_status,v,10); if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,v,-1)){ NyLPC_OnErrorGoto(Error); } if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream," ",1)){ NyLPC_OnErrorGoto(Error); } if(!writeln(i_inst->_ref_stream,m,-1)){ NyLPC_OnErrorGoto(Error); } if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,"Server: " NyLPC_cHttpdConfig_SERVER "\r\n",-1)){ NyLPC_OnErrorGoto(Error); } if(i_inst->_is_close){ if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,"Connection: CLOSE\r\n",-1)){ NyLPC_OnErrorGoto(Error); } } //ヘッダの記述 if(i_inst->_is_chunked){ if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,"Transfer-Encoding: chunked\r\n",-1)){ NyLPC_OnErrorGoto(Error); } }else{ if(!NyLPC_iHttpPtrStream_write(i_inst->_ref_stream,"Content-Length: ",-1)){ NyLPC_OnErrorGoto(Error); } NyLPC_uitoa(i_inst->_content_length,v,10); if(!writeln(i_inst->_ref_stream,v,-1)){ NyLPC_OnErrorGoto(Error); } } //送信サイズをリセット i_inst->_size_of_sent=0; return NyLPC_TBool_TRUE; Error: i_inst->_is_error=NyLPC_TUInt8_FALSE; return NyLPC_TBool_FALSE; }
void CHECK_SETTINGS (const string projectname) { ASSERT_EXACTLY_ONE_TRUE (is_mode_STD(), is_mode_DEBUG()); const string SFN = capslock (projectname + ".set"); const string sfn = projectname + ".set"; writeln (""); writeln ("============================"); writeln ("1) CHECKING OF SETTINGS FILE"); writeln ("============================"); writeln (""); writeln (" - CHECKING " + SFN + " SETTINGS FILE"); const bool CORR_SET = is_SETTINGS_FILE_CORRECT (sfn); if (CORR_SET) { writeln (" - " + SFN + " SETTINGS FILE IS CORRECT."); vector <vector <string> > SET = READ_SETTINGS_FILE (sfn); SET = COMPLETE_SET_WITH_DEFAULT (SET); INIT_SETTINGS (SET); } else { writeln (""); writeln (" WARNING, SET_ERROR: the input " + SFN + " file structure is incorrect, the file will not be processed."); throw set_error(); } }
ASTDumper::ASTDumper (Node *root, std::string outpath) { file = fopen(outpath.c_str(), "w"); nodeCounter = 0; writeln("digraph {"); root->accept(*this); writeln("}"); fclose(file); }
void IGCWriter::LogPoint(const NMEA_INFO& gps_info) { char szBRecord[500]; int iSIU = GetSIU(gps_info); fixed dEPE = GetEPE(gps_info); LogPoint_GPSPosition p; char IsValidFix; // if at least one GPS fix comes from the simulator, disable signing if (gps_info.gps.Simulator) Simulator = true; if (!Simulator) { const char *p = frecord.update(gps_info.gps.SatelliteIDs, gps_info.DateTime, gps_info.Time, gps_info.gps.NAVWarning); if (p != NULL) writeln(p); } if (!LastValidPoint.Initialized && ((gps_info.GPSAltitude < fixed(-100)) || (gps_info.BaroAltitude < fixed(-100)) || gps_info.gps.NAVWarning)) return; if (gps_info.gps.NAVWarning) { IsValidFix = 'V'; // invalid p = LastValidPoint; } else { IsValidFix = 'A'; // Active // save last active fix location p = LastValidPoint = gps_info; } char *q = szBRecord; sprintf(q, "B%02d%02d%02d", gps_info.DateTime.hour, gps_info.DateTime.minute, gps_info.DateTime.second); q += strlen(q); q = igc_format_location(q, p.Location); sprintf(q, "%c%05d%05d%03d%02d", IsValidFix, (int)gps_info.BaroAltitude, p.GPSAltitude, (int)dEPE, iSIU); writeln(szBRecord); }
int main(){ list L = cons(1,cons(5,cons(3,cons(8,nil)))); write("Erlang: foldl (xmy, 0, L) = (8-(3-(5-(1-0)))) = "); writeln(foldl(xmy, 0, L)); write("Haskell: foldlH(xmy, 0, L) = ((((0-1)-5)-3)-8) = "); writeln(foldlH(xmy, 0, L)); write("Erlang: foldl (ymx, 0, L) = ((((0-1)-5)-3)-8) = "); writeln(foldl(ymx, 0, L)); write("Haskell: foldlH(ymx, 0, L) = (8-(3-(5-(1-0)))) = "); writeln(foldlH(ymx, 0, L)); write(" foldr (xmy, 0, L) = (1-(5-(3-(8-0)))) = "); writeln(foldr(xmy, 0, L)); }
void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const { writeln(file, indentLevel, "{"); writeHexVal(file, indentLevel + 1, "layer", (int)this); writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId); writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip); writeIntVal(file, indentLevel + 1, "isRootLayer", m_isRootLayer); writeIntVal(file, indentLevel + 1, "isFixed", m_isFixed); writeFloatVal(file, indentLevel + 1, "opacity", getOpacity()); writeSize(file, indentLevel + 1, "size", getSize()); writePoint(file, indentLevel + 1, "position", getPosition()); writePoint(file, indentLevel + 1, "translation", m_translation); writePoint(file, indentLevel + 1, "anchor", getAnchorPoint()); writePoint(file, indentLevel + 1, "scale", m_scale); if (m_doRotation) writeFloatVal(file, indentLevel + 1, "angle", m_angleTransform); if (m_isFixed) { writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft); writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop); writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight); writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom); writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft); writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop); writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight); writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom); writePoint(file, indentLevel + 1, "fixedOffset", m_fixedOffset); writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth); writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight); } if (m_recordingPicture) { writeIntVal(file, indentLevel + 1, "picture width", m_recordingPicture->width()); writeIntVal(file, indentLevel + 1, "picture height", m_recordingPicture->height()); } if (countChildren()) { writeln(file, indentLevel + 1, "children = ["); for (int i = 0; i < countChildren(); i++) { if (i > 0) writeln(file, indentLevel + 1, ", "); getChild(i)->dumpLayers(file, indentLevel + 1); } writeln(file, indentLevel + 1, "];"); } writeln(file, indentLevel, "}"); }
void show2e(ar2e* arr) { dom2d dom = arr->dom; for_dom_d1(i1, dom) { for_dom_d2(i2, dom) printf("%s", tost(0, get2e(arr, i1, i2))); writeln(); }
/* Basically, we need to find an object with a matching noun and adj to our choice. */ static int extract_obj(word name, word adj) { int i,obj; /* We just take the first one. We split this into separate noun and creature loops for performance reaons */ if (name==-1) /* <*NONE*> */ return 0; obj=expand_redirect(name); adj=it_name(expand_redirect(adj)); if (obj>0) { /* $noun$, $object$, or $name$ */ if (adj==0 || adj==it_adj(obj)) return obj; /* We're done */ name=it_name(obj); } else name=-obj; if (adj==0) return -name; /* Adjectives required for CLASS redirect */ nounloop(i) if (noun[i].name==name && noun[i].adj==adj) return i+first_noun; creatloop(i) if (creature[i].name==name && creature[i].adj==adj) return i+first_creat; /* Hmm... just hope it's an internal noun. */ writeln("GAME ERROR: Redirect statement with bad object name."); return -name; }
void ktov_hajlamot (CStr path_to_hajlamot) { ofstream out; StringTemp thefilename = concat_path_to_filename(path_to_hajlamot,"hajlamotb.ma"); DO(open(thefilename.str,out,0)); writeln (out, mone_hajlamot_pealim, Format("P ")); out.close(); }
static int obj_cond(int op, int obj, int arg) { switch(op) { case 0:cret(in_scope(obj)); /* Present-- Do we want to use visible here?? */ case 1:cret(is_within(obj,1000,1)); /* IsWearing */ case 2:cret(is_within(obj,1,1)); /* if (PURE_WEAR) return (it_loc(obj)==1); else */ case 3:cret(it_loc(obj)==0); /* Nowhere */ case 4:cret(it_loc(obj)!=0); case 5:cret(!player_has(obj) && in_scope(obj)); case 6:cret(it_loc(obj)==arg); case 7:cret(it_on(obj)); case 8:cret(!it_on(obj)); case 9:cret(it_open(obj)); case 10:cret(!it_open(obj)); case 11:cretn(obj,locked); case 12:cret(!tnoun(obj) || !noun[obj-first_noun].locked); case 13:cretn(obj,edible); case 14:cretn(obj,drinkable); case 15:cretn(obj,poisonous); case 16:cretn(obj,movable); default: writeln("INTERNAL ERROR: Bad obj_cond value."); return 2; } }
void IGCWriter::LoggerNote(const TCHAR *text) { char fulltext[500]; sprintf(fulltext, "LPLT%S", text); writeln(fulltext); }
int main(){ short i,a,b; int q; char opt; read(N); for(i=1;i<N;++i) read2(a,b),addEdge(V+a,V+b); for(i=1;i<=N;++i) read(V[i].w); V->top=V; V[1].BuildTree(V,1); MakeChain(); scanf("%d\n",&q); while(q--) switch(opt=(getchar(),getchar()),read2(a,b),opt){ case 'H':V[a].Modify(b);break; case 'M':writeln(Max(V+a,V+b));break; case 'S':writeln(Sum(V+a,V+b)); } }
void ktov_lexicon_bituyim(ostream& out, Format format="") { out << '{' << endl; for (Trie0<Bituy>::Cursor c(lexicon_bituyim); c.isvalid(); ++c) { writeln (out, c.item()); } out << '}' << endl; }
void ASTDumper::edge(int a, int b) { std::string buff = "node" + std::to_string(a) + " -> node" + std::to_string(b); if (!desc.empty()) { buff += " [label=\"" + desc + "\"]"; desc.clear(); } writeln(buff); }
void IGCWriter::EndDeclaration(void) { // TODO bug: this is causing problems with some analysis software // maybe it's because the date and location fields are bogus const char start[] = "C0000000N00000000ELANDING"; writeln(start); }
void B< T, A >::method_B() { writeln("method_B"); B_Float temp; temp.method_Strategy(); this->method_Strategy(); std::cout<<this->q<<std::endl; }
void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const { writeln(file, indentLevel, "{"); dumpLayer(file, indentLevel); if (countChildren()) { writeln(file, indentLevel + 1, "children = ["); for (int i = 0; i < countChildren(); i++) { if (i > 0) writeln(file, indentLevel + 1, ", "); getChild(i)->dumpLayers(file, indentLevel + 1); } writeln(file, indentLevel + 1, "];"); } writeln(file, indentLevel, "}"); }
int get_username(int conn_fd, struct conn_status *conn) { if (writeln(conn_fd, "your password:", 100) < 0) { return -1; } conn->status = STATUS_NAME; return 0; }
int get_passwd(int conn_fd, struct conn_status *conn) { if (writeln(conn_fd, "authorizing, please wait...", 100) < 0) { return -1; } conn->status = STATUS_PASS; return 0; }
int auth_failed(int conn_fd, struct conn_status *conn) { if (writeln(conn_fd, "authorizing failed, connection close.", 100) < 0) { return -1; } conn->status = STATUS_FAIL; return 0; }
void Console::writefln(const tchar* fmt, ...) { tchar buffer[1024]; va_list args; va_start(args, fmt); vsprintf(buffer, fmt, args); writeln(buffer); va_end(args); }
int auth_success(int conn_fd, struct conn_status *conn) { if (writeln(conn_fd, "authorizing success, ready to receive data.", 100) < 0) { return -1; } conn->status = STATUS_SUCC; return 0; }
TEST_F(ReaderTests, ReadStringWithSemicolon) { const char *s = "str;ng"; writeln("\"%s\"", s); OBJ o = ybRead(stdin); EXPECT_EQ(T_STRING, TYPE(o)); EXPECT_STREQ(s, o->u.string.string); }
TEST_F(ReaderTests, ReadUppercaseChars) { const char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; writeln("\"%s\"", s); OBJ o = ybRead(stdin); EXPECT_EQ(T_STRING, TYPE(o)); EXPECT_STREQ(s, o->u.string.string); }
TEST_F(ReaderTests, ReadLowercaseChars) { const char *s = "abcdefghijklmnopqrstuvwxyz"; writeln("\"%s\"", s); OBJ o = ybRead(stdin); EXPECT_EQ(T_STRING, TYPE(o)); EXPECT_STREQ(s, o->u.string.string); }