static void xmore(const char *s) /* allowed chars besides space/return */ { if(flags.toplin) { curs(tlx, tly); if(tlx + 8 > CO) putsym('\n'), tly++; } if(flags.standout) standoutbeg(); putstr("--More--"); if(flags.standout) standoutend(); xwaitforspace(s); if(flags.toplin && tly > 1) { home(); cl_end(); docorner(1, tly-1); } flags.toplin = 0; }
/* spaceflag: TRUE if space required */ void xmore(boolean spaceflag) { if(flags.topl != 0) { curs(tlx, tly); if((tlx + 8) > COLNO) { putsym('\n'); ++tly; } } putstr("--More--"); xwaitforspace(spaceflag); if((flags.topl != 0) && (tly > 1)) { home(); cl_end(); docorner(1, tly - 1); } flags.topl = 0; }
void outrip() { char buf[BUFSZ]; cls(); curs(1, 8); puts(riptop); (void) strlcpy(buf, plname, sizeof buf); buf[16] = 0; center(6, buf); (void) snprintf(buf, sizeof buf, "%ld AU", u.ugold); center(7, buf); (void) snprintf(buf, sizeof buf, "killed by%s", !strncmp(killer, "the ", 4) ? "" : !strcmp(killer, "starvation") ? "" : strchr(vowels, *killer) ? " an" : " a"); center(8, buf); (void) strlcpy(buf, killer, sizeof buf); { int i1; if((i1 = strlen(buf)) > 16) { int i,i0; i0 = i1 = 0; for(i = 0; i <= 16; i++) if(buf[i] == ' ') i0 = i, i1 = i+1; if(!i0) i0 = i1 = 16; buf[i1 + 16] = 0; buf[i0] = 0; } center(9, buf); center(10, buf+i1); } (void) snprintf(buf, sizeof buf, "%4d", getyear()); center(11, buf); puts(ripbot); getret(); }
bool page_line(const char *s) /* returns 1 if we should quit */ { if (cury == LI - 1) { if (!*s) return (0); /* suppress blank lines at top */ putchar('\n'); cury++; cmore("q\033"); if (morc) { morc = 0; return (1); } if (whole_screen) cls(); else { curs(1, ROWNO + 4); cl_eos(); } } puts(s); cury++; return (0); }
static int _tt_match_string_list(const _Tt_string& str, _Tt_string_list_ptr slist) { int matched = 0; if (slist->is_empty()) { matched = 0; } else { _Tt_string_list_cursor curs(slist); while (curs.next()) { if (str.sh_match(*curs)) { matched = 1; break; } } } if (!matched) return 0; return 1; }
RecordBuffer* DbCreatorsList::getList(thread_db* tdbb, jrd_rel* relation) { fb_assert(relation); fb_assert(relation->rel_id == rel_sec_db_creators); RecordBuffer* buffer = getData(relation); if (buffer) { return buffer; } RefPtr<IAttachment> att; RefPtr<ITransaction> tra; const char* dbName = tdbb->getDatabase()->dbb_config->getSecurityDatabase(); if (!openDb(dbName, att, tra)) { // In embedded mode we are not raising any errors - silent return if (MasterInterfacePtr()->serverMode(-1) < 0) return makeBuffer(tdbb); (Arg::Gds(isc_crdb_nodb) << dbName).raise(); } Message gr; Field<ISC_SHORT> uType(gr); Field<Varying> u(gr, MAX_SQL_IDENTIFIER_LEN); FbLocalStatus st; RefPtr<IResultSet> curs(att->openCursor(&st, tra, 0, "select RDB$USER_TYPE, RDB$USER from RDB$DB_CREATORS", SQL_DIALECT_V6, NULL, NULL, gr.getMetadata(), NULL, 0)); if (st->getState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err)) check("IAttachment::openCursor", &st); // isc_dsql_relation_err when opening cursor - i.e. table // is missing due to non-FB3 security DB // In embedded mode we are not raising any errors - silent return if (MasterInterfacePtr()->serverMode(-1) < 0) return makeBuffer(tdbb); (Arg::Gds(isc_crdb_notable) << dbName).raise(); } try { buffer = makeBuffer(tdbb); while (curs->fetchNext(&st, gr.getBuffer()) == IStatus::RESULT_OK) { Record* record = buffer->getTempRecord(); record->nullify(); putField(tdbb, record, DumpField(f_sec_crt_user, VALUE_STRING, u->len, u->data)); SINT64 v = uType; putField(tdbb, record, DumpField(f_sec_crt_u_type, VALUE_INTEGER, sizeof(v), &v)); buffer->store(record); } check("IResultSet::fetchNext", &st); } catch (const Exception&) { clearSnapshot(); throw; } return getData(relation); }
int dosave() { #ifdef KEEP_SAVE /*WAC for reloading*/ register int fd; #endif clear_nhwindow(WIN_MESSAGE); if(yn("Really save?") == 'n') { clear_nhwindow(WIN_MESSAGE); if(multi > 0) nomul(0); } else { clear_nhwindow(WIN_MESSAGE); pline("Saving..."); #if defined(UNIX) || defined(VMS) || defined(__EMX__) program_state.done_hup = 0; #endif #ifdef KEEP_SAVE saverestore = FALSE; if (flags.keep_savefile) if(yn("Really quit?") == 'n') saverestore = TRUE; if(dosave0() && !saverestore) { #else if(dosave0()) { #endif program_state.something_worth_saving = 0; u.uhp = -1; /* universal game's over indicator */ /* make sure they see the Saving message */ display_nhwindow(WIN_MESSAGE, TRUE); exit_nhwindows("Be seeing you..."); terminate(EXIT_SUCCESS); } /*WAC redraw later else (void)doredraw();*/ } #ifdef KEEP_SAVE if (saverestore) { /*WAC pulled this from pcmain.c - restore game from the file just saved*/ fd = create_levelfile(0); if (fd < 0) { raw_print("Cannot create lock file"); } else { hackpid = 1; write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); close(fd); } #ifdef MFLOPPY level_info[0].where = ACTIVE; #endif fd = restore_saved_game(); if (fd >= 0) dorecover(fd); check_special_room(FALSE); flags.move = 0; /*WAC correct these after restore*/ if(flags.moonphase == FULL_MOON) change_luck(1); if(flags.friday13) change_luck(-1); if(iflags.window_inited) clear_nhwindow(WIN_MESSAGE); } saverestore = FALSE; #endif (void)doredraw(); return 0; } #if defined(UNIX) || defined(VMS) || defined (__EMX__) || defined(WIN32) /*ARGSUSED*/ void hangup(sig_unused) /* called as signal() handler, so sent at least one arg */ int sig_unused; { # ifdef NOSAVEONHANGUP (void) signal(SIGINT, SIG_IGN); clearlocks(); # ifndef VMS terminate(EXIT_FAILURE); # endif # else /* SAVEONHANGUP */ if (!program_state.done_hup++) { if (program_state.something_worth_saving) (void) dosave0(); # ifdef VMS /* don't call exit when already within an exit handler; that would cancel any other pending user-mode handlers */ if (!program_state.exiting) # endif { clearlocks(); terminate(EXIT_FAILURE); } } # endif return; } #endif /* returns 1 if save successful */ int dosave0() { const char *fq_save; register int fd, ofd; xchar ltmp; d_level uz_save; char whynot[BUFSZ]; if (!SAVEF[0]) return 0; fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */ #if defined(UNIX) || defined(VMS) (void) signal(SIGHUP, SIG_IGN); #endif #ifndef NO_SIGNAL (void) signal(SIGINT, SIG_IGN); #endif #if defined(MICRO) && defined(MFLOPPY) if (!saveDiskPrompt(0)) return 0; #endif HUP if (iflags.window_inited) { uncompress_area(fq_save, SAVEF); fd = open_savefile(); if (fd > 0) { (void) close(fd); clear_nhwindow(WIN_MESSAGE); There("seems to be an old save file."); if (yn("Overwrite the old file?") == 'n') { compress_area(fq_save, SAVEF); #ifdef KEEP_SAVE /*WAC don't restore if you didn't save*/ saverestore = FALSE; #endif return 0; } } } HUP mark_synch(); /* flush any buffered screen output */ fd = create_savefile(); if(fd < 0) { HUP pline("Cannot open save file."); (void) delete_savefile(); /* ab@unido */ return(0); } vision_recalc(2); /* shut down vision to prevent problems in the event of an impossible() call */ /* undo date-dependent luck adjustments made at startup time */ if(flags.moonphase == FULL_MOON) /* ut-sally!fletcher */ change_luck(-1); /* and unido!ab */ if(flags.friday13) change_luck(1); if(iflags.window_inited) HUP clear_nhwindow(WIN_MESSAGE); #if defined(MICRO) && defined(TTY_GRAPHICS) if (!strncmpi("tty", windowprocs.name, 3)) { dotcnt = 0; dotrow = 2; curs(WIN_MAP, 1, 1); putstr(WIN_MAP, 0, "Saving:"); } #endif #ifdef MFLOPPY /* make sure there is enough disk space */ if (iflags.checkspace) { long fds, needed; savelev(fd, ledger_no(&u.uz), COUNT_SAVE); savegamestate(fd, COUNT_SAVE); needed = bytes_counted; for (ltmp = 1; ltmp <= maxledgerno(); ltmp++) if (ltmp != ledger_no(&u.uz) && level_info[ltmp].where) needed += level_info[ltmp].size + (sizeof ltmp); fds = freediskspace(fq_save); if (needed > fds) { HUP { There("is insufficient space on SAVE disk."); pline("Require %ld bytes but only have %ld.", needed, fds); } flushout(); (void) close(fd); (void) delete_savefile(); return 0; } co_false(); }
/* returns 1 if save successful */ int dosave0(void) { const char *fq_save; register int fd, ofd; xchar ltmp; d_level uz_save; char whynot[BUFSZ]; #ifdef WHEREIS_FILE delete_whereis(); #endif if (!SAVEF[0]) return 0; fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */ #if defined(UNIX) || defined(VMS) (void) signal(SIGHUP, SIG_IGN); #endif #ifndef NO_SIGNAL (void) signal(SIGINT, SIG_IGN); #endif #if defined(MICRO) && defined(MFLOPPY) if (!saveDiskPrompt(0)) return 0; #endif HUP if (iflags.window_inited) { uncompress_area(fq_save, SAVEF); fd = open_savefile(); if (fd > 0) { (void) close(fd); clear_nhwindow(WIN_MESSAGE); There("seems to be an old save file."); if (yn("Overwrite the old file?") == 'n') { compress_area(fq_save, SAVEF); return 0; } } } HUP mark_synch(); /* flush any buffered screen output */ fd = create_savefile(); if(fd < 0) { HUP pline("Cannot open save file."); (void) delete_savefile(); /* ab@unido */ return(0); } vision_recalc(2); /* shut down vision to prevent problems in the event of an impossible() call */ /* undo date-dependent luck adjustments made at startup time */ if(flags.moonphase == FULL_MOON) /* ut-sally!fletcher */ change_luck(-1); /* and unido!ab */ if(flags.friday13) change_luck(1); if(iflags.window_inited) HUP clear_nhwindow(WIN_MESSAGE); #ifdef MICRO dotcnt = 0; dotrow = 2; curs(WIN_MAP, 1, 1); if (strncmpi("X11", windowprocs.name, 3)) putstr(WIN_MAP, 0, "Saving:"); #endif #ifdef MFLOPPY /* make sure there is enough disk space */ if (iflags.checkspace) { long fds, needed; savelev(fd, ledger_no(&u.uz), COUNT_SAVE); savegamestate(fd, COUNT_SAVE); needed = bytes_counted; for (ltmp = 1; ltmp <= maxledgerno(); ltmp++) if (ltmp != ledger_no(&u.uz) && level_info[ltmp].where) needed += level_info[ltmp].size + (sizeof ltmp); fds = freediskspace(fq_save); if (needed > fds) { HUP { There("is insufficient space on SAVE disk."); pline("Require %ld bytes but only have %ld.", needed, fds); } flushout(); (void) close(fd); (void) delete_savefile(); return 0; }
/* * Flexible pager: feed it with a number of lines and it will decide * whether these should be fed to the pager above, or displayed in a * corner. * Call: * cornline(0, title or 0) : initialize * cornline(1, text) : add text to the chain of texts * cornline(2, morcs) : output everything and cleanup * cornline(3, 0) : cleanup */ void cornline(int mode, char *text) { static struct line { struct line *next_line; char *line_text; } *texthead, *texttail; static int maxlen; static int linect; struct line *tl; if(mode == 0) { texthead = 0; maxlen = 0; linect = 0; if(text) { cornline(1, text); /* title */ cornline(1, ""); /* blank line */ } return; } if(mode == 1) { int len; if(!text) return; /* superfluous, just to be sure */ linect++; len = strlen(text); if(len > maxlen) maxlen = len; tl = (struct line *) alloc((unsigned)(len + sizeof(struct line) + 1)); tl->next_line = 0; tl->line_text = (char *)(tl + 1); (void) strlcpy(tl->line_text, text, len + 1); if(!texthead) texthead = tl; else texttail->next_line = tl; texttail = tl; return; } /* --- now we really do it --- */ if(mode == 2 && linect == 1) /* topline only */ pline(texthead->line_text); else if(mode == 2) { int curline, lth; if(flags.toplin == 1) more(); /* ab@unido */ remember_topl(); lth = CO - maxlen - 2; /* Use full screen width */ if (linect < LI && lth >= 10) { /* in a corner */ home(); cl_end(); flags.toplin = 0; curline = 1; for (tl = texthead; tl; tl = tl->next_line) { curs(lth, curline); if(curline > 1) cl_end(); putsym(' '); putstr (tl->line_text); curline++; } curs(lth, curline); cl_end(); cmore(text); home(); cl_end(); docorner(lth, curline-1); } else { /* feed to pager */ set_pager(0); for (tl = texthead; tl; tl = tl->next_line) { if (page_line (tl->line_text)) { set_pager(2); goto cleanup; } } if(text) { cgetret(text); set_pager(2); } else set_pager(1); } } cleanup: while ((tl = texthead)) { texthead = tl->next_line; free((char *) tl); } }