void run_chain(int nChainNumber) { int inst = inst_ok(INST_LOC_CHAINS, nChainNumber + 1); if (inst != 0) { char szMessage[255]; sprintf(szMessage, "|#2Chain %s is in use on instance %d", chains[nChainNumber].description, inst); if (!(chains[nChainNumber].ansir & ansir_multi_user)) { strcat(szMessage, "Try again later.\r\n"); GetSession()->bout << szMessage; return; } else { strcat(szMessage, "Care to join in? "); GetSession()->bout << szMessage; if (!yesno()) { return; } } } write_inst(INST_LOC_CHAINS, static_cast< unsigned short >(nChainNumber + 1), INST_FLAGS_NONE); if (GetApplication()->HasConfigFlag(OP_FLAGS_CHAIN_REG) && chains_reg) { chains_reg[nChainNumber].usage++; WFile regFile(syscfg.datadir, CHAINS_REG); if (regFile.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeCreateFile | WFile::modeTruncate, WFile::shareUnknown, WFile::permReadWrite)) { regFile.Write(chains_reg, GetSession()->GetNumberOfChains() * sizeof(chainregrec)); } } char szComSpeed[ 11 ]; sprintf(szComSpeed, "%d", (com_speed == 1) ? 115200 : com_speed); char szComPortNum[ 11 ]; sprintf(szComPortNum, "%d", syscfgovr.primaryport); char szModemSpeed[ 11 ]; sprintf(szModemSpeed, "%d", modem_speed); const std::string chainCmdLine = stuff_in(chains[nChainNumber].filename, create_chain_file(), szComSpeed, szComPortNum, szModemSpeed, ""); sysoplogf("!Ran \"%s\"", chains[nChainNumber].description); GetSession()->GetCurrentUser()->SetNumChainsRun(GetSession()->GetCurrentUser()->GetNumChainsRun() + 1); unsigned short flags = 0; if (!(chains[nChainNumber].ansir & ansir_no_DOS)) { flags |= EFLAG_COMIO; } if (chains[nChainNumber].ansir & ansir_no_pause) { flags |= EFLAG_NOPAUSE; } if (chains[nChainNumber].ansir & ansir_emulate_fossil) { flags |= EFLAG_FOSSIL; } ExecuteExternalProgram(chainCmdLine, flags); write_inst(INST_LOC_CHAINS, 0, INST_FLAGS_NONE); GetApplication()->UpdateTopScreen(); }
static void wfc_command(int instance_location_id, std::function<void()> f, std::function<void()> f2 = noop, std::function<void()> f3 = noop, std::function<void()> f4 = noop) { session()->reset_local_io(new CursesLocalIO(out->window()->GetMaxY())); wfc_cls(); write_inst(instance_location_id, 0, INST_FLAGS_NONE); f(); f2(); f3(); f4(); write_inst(INST_LOC_WFC, 0, INST_FLAGS_NONE); }
const string GetCommand(const MenuInstanceData* menu_data) { if (pSecondUserRec->cHotKeys == HOTKEYS_ON) { if (menu_data->header.nNumbers == MENU_NUMFLAG_DIRNUMBER) { write_inst(INST_LOC_XFER, udir[session()->GetCurrentFileArea()].subnum, INST_FLAGS_NONE); return string(mmkey(1, WSession::mmkeyFileAreas)); } else if (menu_data->header.nNumbers == MENU_NUMFLAG_SUBNUMBER) { write_inst(INST_LOC_MAIN, usub[session()->GetCurrentMessageArea()].subnum, INST_FLAGS_NONE); return string(mmkey(0, WSession::mmkeyMessageAreas)); } else { odc[0] = '/'; odc[1] = '\0'; return string(mmkey(2)); } } else { string text; input(&text, 50); return string(text); } }
static void gen_inst(CTX *ctx, struct ir_inst *in) { struct ir_type res_t = in->result_type; bool is_void = type_is_void(res_t); // Don't write anything not needed. Note that void values are never actually // "used" by the generated C code, and instead are replaced with VOID_VAL. if (!ir_op_writes_side_effects(in->op) && !ir_op_is_branch(in->op)) { if (is_void) return; if (in->users_count == 0) return; // If it has 1 use, it can be generated inline. if (write_inline && in->users_count == 1) { // But if it crosses side effects, it must be generated earlier. // NOTE: if there are any not yet generated instructions with read // side-effects, we must generate the code before crossing // write side-effects as well. // Consider: t1=read; t2=neg(t1); call a(); call b(t2); // Mustn't turn into: call a(); call b(neg(read)); bool crosses_sideffects = false; if (has_outstanding_sideffect_reads(in)) { struct ir_inst *user= in->users[0]; for (struct ir_inst *cur = in; cur; cur = cur->next) { if (cur == user) break; if (ir_op_writes_side_effects(cur->op)) { crosses_sideffects = true; break; } } } if (!crosses_sideffects) return; } } set_loc(ctx, in->loc); indent(ctx); if (!TEST_UNION0(IR_TYPE, any, &res_t) && !is_void && in->users_count > 0) { if (in->scratch1_i == -1) in->scratch1_i = ctx->reg++; P(ctx, "%s %s = ", type(ctx, res_t), get_temp(ctx, in->scratch1_i)); } write_inst(ctx, in, false); fprintf(ctx->f, ";\n"); talloc_free_children(ctx->tmp); }
int print_inst(struct self_s *self, struct instruction_s *instruction, int instruction_number, struct label_s *labels) { int ret; int tmp; struct string_s string1; string1.len = 0; string1.max = 1023; string1.string[0] = 0; ret = write_inst(self, &string1, instruction, instruction_number, labels); tmp = fprintf(stderr, "%s", string1.string); tmp = fprintf(stderr, "\n"); return ret; }
void send_inet_email() { if (GetSession()->GetCurrentUser()->GetNumEmailSentToday() > getslrec(GetSession()->GetEffectiveSl()).emails) { GetSession()->bout.NewLine(); GetSession()->bout << "|#6Too much mail sent today.\r\n"; return; } write_inst(INST_LOC_EMAIL, 0, INST_FLAGS_NONE); int nNetworkNumber = getnetnum("FILEnet"); GetSession()->SetNetworkNumber(nNetworkNumber); if (nNetworkNumber == -1) { return; } set_net_num(GetSession()->GetNetworkNumber()); GetSession()->bout.NewLine(); GetSession()->bout << "|#9Your Internet Address:|#1 " << (GetSession()->IsInternetUseRealNames() ? GetSession()->GetCurrentUser()->GetRealName() : GetSession()->GetCurrentUser()->GetName()) << " <" << GetSession()->internetFullEmailAddress << ">"; GetSession()->bout.NewLine(2); GetSession()->bout << "|#9Enter the Internet mail destination address.\r\n|#7:"; inputl(net_email_name, 75, true); if (check_inet_addr(net_email_name)) { unsigned short nUserNumber = 0; unsigned short nSystemNumber = 32767; irt[0] = 0; irt_name[0] = 0; grab_quotes(NULL, NULL); if (nUserNumber || nSystemNumber) { email(nUserNumber, nSystemNumber, false, 0); } } else { GetSession()->bout.NewLine(); if (net_email_name[0]) { GetSession()->bout << "|#6Invalid address format!\r\n"; } else { GetSession()->bout << "|#6Aborted.\r\n"; } } }
static char *gen_inst_inline(CTX *ctx, struct ir_inst *in) { assert(!ir_op_writes_side_effects(in->op) && !ir_op_is_branch(in->op) && !type_is_void(in->result_type) && in->users_count == 1); size_t sz = 0; char *data = NULL; FILE *oldf = ctx->f; ctx->f = open_memstream(&data, &sz); P(ctx, "("); write_inst(ctx, in, true); P(ctx, ")"); int res = fclose(ctx->f); assert(res == 0); ctx->f = oldf; char *r = talloc_strdup(ctx->tmp, data); free(data); return r; }