int redrawhelp() { int nextc; int col; fseek(helpfd, helpfilepos, 0); col = Columns - 52; if (col < 0) col = 0; outstr(T_ED); while ((nextc = getc(helpfd)) != -1 && nextc != '\f') { if (nextc == Ctrl('B')) /* begin of invert */ outstr(T_TI); else if (nextc == Ctrl('E')) /* end of invert */ outstr(T_TP); else outchar((char)nextc); } windgoto(0, (int)(Columns - strlen(Version) - 1)); outstrn(Version); windgoto((int)Rows - 1, col); outstrn("<space = next; return = quit; a = index; b = back>"); return (nextc == -1); }
static int bbsnet_key(struct _select_def *conf, int command) { char* ptr; if ((ptr=strchr(str,command))!=NULL) { conf->new_pos = (ptr-str) + 1; return SHOW_SELCHANGE; } if ((ptr=strchr(section,command))!=NULL) { if (ptr-section<sectioncount) { sectionindex=ptr-section+1; return SHOW_DIRCHANGE; } } switch (command) { case ' ': sectionindex++; sectionindex=sectionindex%sectioncount; if (sectionindex==0) sectionindex=sectioncount; return SHOW_DIRCHANGE; case Ctrl('C'): case Ctrl('A'): return SHOW_QUIT; case '?': show_help("help/bbsnethelp"); bbsnet_redraw=true; return SHOW_REFRESH; case '$': conf->new_pos=conf->item_count; return SHOW_SELCHANGE; case '^': conf->new_pos=1; return SHOW_SELCHANGE; } return SHOW_CONTINUE; }
int do_dict() { newtComponent form, label, entry, text; struct newtExitStruct es; char *entryValue, *wordlist; newtCenteredWindow(70, 20, NULL); newtPushHelpLine("输入要查找的词,回车确定,上下键滚动,^C退出"); label = newtLabel(2, 1, "请输入要查找的词"); entry = newtEntry(2, 2, "", 40, &entryValue, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); text = newtTextbox(2, 3, 66, 17, NEWT_FLAG_WRAP | NEWT_FLAG_SCROLL); newtTextboxSetText(text, ""); form = newtForm(NULL, NULL, 0); newtFormAddHotKey(form, Ctrl('c')); newtFormAddHotKey(form, Ctrl('\r')); newtFormAddHotKey(form, Ctrl('\n')); newtFormAddComponents(form, label, entry, text, NULL); while (1) { newtFormRun(form, &es); if ((es.u.key == Ctrl('c') || es.u.key == NEWT_KEY_F12) && es.reason == NEWT_EXIT_HOTKEY) break; wordlist = search_dict(entryValue); newtTextboxSetText(text, wordlist); } newtFormDestroy(form); newtPopHelpLine(); newtPopWindow(); return 0; }
int FtpRead(FTP *con) { int c; if ( con -> mode == 'I' ) return FtpGetc(con,FTPDATA(con)); if ( con->ch != EOF ) { c=con->ch; con->ch=EOF; return c; } c=FtpGetc(con,FTPDATA(con)); if ( c == Ctrl('M') ) { c = FtpGetc(con,FTPDATA(con)); if ( c == Ctrl('J') ) return '\n'; con->ch = c; return Ctrl('M'); } return c; }
int FtpWrite(FTP *ftp,char c) { if ( ftp -> mode == 'I' || c != '\n' ) return FtpPutc(ftp,FTPDATA(ftp),c); FtpPutc(ftp,FTPDATA(ftp),Ctrl('M')); return FtpPutc(ftp,FTPDATA(ftp),Ctrl('J')); }
void bell() { #ifndef BBSD char sound[3], *ptr; ptr = sound; memset(ptr, Ctrl('G'), sizeof(sound)); write(1, ptr, sizeof(sound)); #else static char sound[1] = {Ctrl('G')}; send(0, sound, sizeof(sound), 0); #endif }
int main (int argc, char **argv){ int const accSigma = 1; int const t = (argc == 2)?(lexical_cast<int>(argv[1])):(4); double const deltaT = 1.0; dmat A(2,2), B(2,2), G(2,1), Q(2,2); dmat State(2,1), Cov(2,2), Ctrl(2,1); std::vector<dmat> Result; A(0,0) = 1;A(0,1) = deltaT; A(1,0) = 0;A(1,1) = 1; B(0,0) = 0;B(0,1) = 0; B(1,0) = 0;B(1,1) = 0; G(0,0) = deltaT * deltaT * 0.5; G(1,0) = deltaT; Q = accSigma * prod(G, trans(G)); State(0,0) = 0; State(1,0) = 0; Cov(0,0) = 1;Cov(0,1) = 0; Cov(1,0) = 0;Cov(1,1) = 1; Ctrl(0,0) = 0; Ctrl(1,0) = 0; KalmanFilter kf = KalmanFilter(&A, &B, &Q, accSigma); for(int i = 0; i < t; ++i){ string fileName = "KFCorrect(k=" + lexical_cast<string>(i + 1) + ").txt"; ofstream ofs(fileName.c_str()); Result = kf.Correct(&State, &Cov, &Ctrl, &G); State = Result.at(0); Cov = Result.at(1); for(double location = -20.0; location <= 20.0; location += 0.5){ for(double vel = -10.0; vel <= 10.0; vel += 0.5){ dmat Info(2,1); Info(0,0) = location; Info(1,0) = vel; double prob = kf.calcBelief(&Info, &State, &Cov); ofs << location << "\t" << vel << "\t" << prob << endl; } } } return 0; }
//-----------------------------------------------------------------------------------------// void Epoll::Update( int fd, int events, const epoll_data_t *data ) { if( Ctrl( EPOLL_CTL_MOD, fd, events, data ) == -1 ) { throw Exception( "Epoll::Update() failed", errno ); } }
void ParallelPort::Close(void) volatile throw(ParallelPort_errors) { //Don't close port if its not opened if (!mPortOpened) { throw ParallelPort_errors(Closed); }; //Restore R/W registers to what they were before we came along Data(const_cast<unsigned char&>(mPortSavedRegs[0])); Ctrl(const_cast<unsigned char&>(mPortSavedRegs[1])); //Release exlusive use of parallel port if (ioctl(mPortFD, PPRELEASE) < 0) { throw ParallelPort_errors(Perm); }; //Close parallel port device (file) if (close(mPortFD) < 0) { throw ParallelPort_errors(Closing); }; //Set member variables to failsafe values const_cast<std::string&>(mPortName) = ""; mPortFD = 0; mPortOpened = false; mDataOut = false; };
void ParallelPort::Open(const std::string& PortName) volatile throw(ParallelPort_errors) { int PortDataDir; //Don't open port if it is already opened if (mPortOpened) { throw ParallelPort_errors(Opened); }; //Open device (e.g. /dev/parport0) mPortFD = open(PortName.c_str(), O_RDWR); if (mPortFD < 0) { mPortFD = 0; throw ParallelPort_errors(Opening); }; //Claim control over parallel port to deny other processes form access if (ioctl(mPortFD, PPCLAIM) < 0) { close(mPortFD); mPortFD = 0; throw ParallelPort_errors(Perm); }; //Set member variables const_cast<std::string&>(mPortName) = PortName; mPortOpened = true; //Save existing R/W registers so that we can restore them later mPortSavedRegs[0] = Data(); mPortSavedRegs[1] = Ctrl(); //Set data register in known configuration PortDataDir = 0; ioctl(mPortFD, PPDATADIR, &PortDataDir); mDataOut = true; };
static void rel_move(int was_col, int was_ln, int new_col, int new_ln) { if (new_ln >= t_lines || new_col >= t_columns) return; tc_col = new_col; tc_line = new_ln; if (new_col == 0) { if (new_ln == was_ln) { if (was_col) ochar('\r'); return; } else if (new_ln == was_ln + 1) { ochar('\n'); if (was_col) ochar('\r'); return; } } if (new_ln == was_ln) { if (was_col == new_col) return; if (new_col == was_col - 1) { ochar(Ctrl('H')); return; } } do_move(new_col, new_ln); }
void tty_settings() { int is_tty = isatty(0); #if defined(MSDOS) || defined(MAC_OS) eofc = Ctrl('Z'); del_line = Ctrl('U'); del_char = Ctrl('H'); #else #ifdef TERM_USE_TIO #if 0 /* this now happens in savetty() */ eofc = Ztty.c_cc[VEOF]; #endif #else #ifdef TERM_USE_SGTTYB if (ioctl(0, TIOCGETC, &tchars) != -1) eofc = tchars.t_eofc; else #endif /* TERM_USE_SGTTYB */ eofc = Ctrl('D'); #endif /* TERM_USE_TIO */ if (!is_tty) { del_line = Ctrl('U'); del_char = Ctrl('H'); } else { del_line = Ztty.sg_kill; del_char = Ztty.sg_erase; } #if defined(TERMIO_USE_SGTTYB) && defined(HAVE_LTCHARS) if (ioctl(0, TIOCGLTC, <chars) != -1) { del_word = ltchars.t_werasc; reprint_line = ltchars.t_rprntc; lit_next = ltchars.t_lnextc; } else #endif /* TERMIO_USE_SGTTYB && HAVE_LTCHARS */ #endif /* MSDOS || MAC_OS */ { del_word = Ctrl('W'); reprint_line = Ctrl('R'); lit_next = Ctrl('V'); } }
BLAPI_PROTO bl_getstr(lua_State* L) { int y, x; // TODO not using fixed length here? char buf[PATHLEN] = ""; int len = 2, echo = 1; int n = lua_gettop(L); const char *pmsg = NULL; if (n > 0) len = lua_tointeger(L, 1); if (n > 1) echo = lua_tointeger(L, 2); if (n > 2) pmsg = lua_tostring(L, 3); if (len < 2) len = 2; if (len >= (int)sizeof(buf)) len = sizeof(buf) - 1; /* * this part now done in getdata_str if (pmsg && *pmsg) { strlcpy(buf, pmsg, sizeof(buf)); } */ // TODO process Ctrl-C here getyx(&y, &x); if (!pmsg) pmsg = ""; len = getdata_str(y, x, NULL, buf, len, echo, pmsg); if (len <= 0) { len = 0; // check if we got Ctrl-C? (workaround in getdata) // TODO someday write 'ungetch()' in io.c to prevent // such workaround. if (buf[1] == Ctrl('C')) { vkey_purge(); blrt.abort = 1; return lua_yield(L, 0); } lua_pushstring(L, ""); } else { lua_pushstring(L, buf); } // return len ? 1 : 0; return 1; }
void bell() { /* * change by KCN 1999.09.08 fprintf(stderr,"%c",Ctrl('G')) ; */ char sound; sound = Ctrl('G'); output(&sound, 1); }
static int do_terminal_getchar(void) { int ch = igetch(); // Handle messages. if (ch == Ctrl('Z')) { if (!msg_num) RMSG = true; } return ch; }
STATUS FtpWriteBlock(FTP *ftp, char *buffer, int size) { fd_set fds; register int wsize; int err = 0; char *buffer2; if ( ( buffer2 = (char *) malloc( size * 2 ) ) == NULL ) return EXIT( ftp, QUIT ); FD_ZERO( &fds ); FD_SET( fileno( FTPDATA(ftp) ), &fds ); ftp->timeout.tv_sec = kDefaultFTPTimeoutSeconds; if ( ( err = select( fileno( FTPDATA( ftp ) ) + 1, 0, &fds, 0, &ftp->timeout ) ) == -1 ) { fprintf( stderr, "select failed in FtpWriteBlock(): %s\n", strerror( errno ) ); } else if ( ! err ) { fprintf( stderr, "select timed out in FtpWriteBlock()\n" ); err = 1; } else err = 0; if ( ! err && ftp->mode == 'A' ) { register int i, ii; for( i=0, ii = 0; ! err && i < size; ++i, ++ii ) if ( buffer[ i ] == '\n' ) buffer2[ ii++ ] = Ctrl( 'M' ), buffer2[ ii ] = Ctrl( 'J' ); else buffer2[ ii ] = buffer[ i ]; buffer = buffer2; size = ii; } for ( wsize = 0; ! err && ( wsize += send( fileno( FTPDATA(ftp) ), buffer + wsize, size - wsize, 0 ) ) < size; ) { if ( wsize == -1 ) err = -1; } if ( ! err && ftp->hash && wsize ) (*ftp->hash)( ftp, wsize ); free( buffer2 ); return err ? EXIT( ftp, QUIT ) : wsize; }
int egetch(void) { int rval; while (1) { rval = terminal_getchar(); if (rval != Ctrl('L')) break; screen_redraw(); } return rval; }
STATUS FtpReadBlock(FTP *ftp, char *buffer, int size) { fd_set fds; register int rsize; FD_ZERO(&fds); FD_SET(fileno(FTPDATA(ftp)),&fds); if (select(getdtablesize(), &fds,0, 0, &(ftp->timeout))<1) return EXIT(ftp,QUIT); if ((rsize=recv(fileno(FTPDATA(ftp)),buffer,size,0))<0) return EXIT(ftp,QUIT); if (ftp->hash!=NULL && rsize!=0) (*ftp->hash)(ftp,rsize); if (ftp->mode == 'A') { char *buffer2; register int i,ii; if ( ( buffer2 = (char *) malloc( size ) ) == NULL ) return EXIT( ftp, LQUIT ); for (i=0,ii=0;i<rsize;i++,ii++) if (buffer[i]==Ctrl('M')&&buffer[i+1]==Ctrl('J')) buffer2[ii]='\n',i++; else buffer2[ii]=buffer[i]; rsize=ii; bcopy(buffer2,buffer,rsize); free( buffer2 ); } return rsize; }
int interrupt_chk() { int key; while (1) { key = egetch(); if (!inrp_by_user) { return; } if (key == Ctrl('C')) { kill(uinfo.pid, SIGINT); return; } } }
int reset_line () { #if defined(uniosu) putchar (Ctrl ('O')); /* おまじない。括弧の中はゼロでなくオー */ #endif /* defined(uniosu) */ if (empty_modep () == 0) { push_cursor (); set_scroll_region (0, crow - 1); kk_restore_cursor (); call_redraw_line (c_b->t_c_p, 1); pop_cursor (); } return (0); }
void CheckEscape() { struct display *odisplay; int i, nr; if (DefaultEsc >= 0) return; odisplay = display; for (display = displays; display; display = display->d_next) { for (i = 0; i < D_nseqs; i += D_kmaps[i + 2] * 2 + 4) { nr = (D_kmaps[i] << 8 | D_kmaps[i + 1]) & ~KMAP_NOTIMEOUT; if (nr < KMAP_KEYS+KMAP_AKEYS) { if (umtab[nr].nr == RC_COMMAND) break; if (umtab[nr].nr == RC_ILLEGAL && dmtab[nr].nr == RC_COMMAND) break; } else { struct kmap_ext *kme = kmap_exts + nr - (KMAP_KEYS+KMAP_AKEYS); if (kme->um.nr == RC_COMMAND) break; if (kme->um.nr == RC_ILLEGAL && kme->dm.nr == RC_COMMAND) break; } } } if (display == 0) { display = odisplay; return; } SetEscape((struct acluser *)0, Ctrl('a'), 'a'); if (odisplay->d_user->u_Esc == -1) odisplay->d_user->u_Esc = DefaultEsc; if (odisplay->d_user->u_MetaEsc == -1) odisplay->d_user->u_MetaEsc = DefaultMetaEsc; display = 0; Msg(0, "Warning: escape char set back to ^A"); display = odisplay; }
/** * 移动终端光标到指定位置 * @param col 要移动到的列 * @param line 要移动到的行 */ static void move_terminal_cursor(int col, int line) { if (line >= screen.lines || col >= screen.columns) return; if (!col && line == screen.tc_line + 1) { terminal_putchar('\n'); if (screen.tc_col) terminal_putchar('\r'); } else if (!col && line == screen.tc_line) { if (screen.tc_col) terminal_putchar('\r'); } else if (col == screen.tc_col - 1 && line == screen.tc_line) { terminal_putchar(Ctrl('H')); } else if (col != screen.tc_col || line != screen.tc_line) { move_terminal_cursor_to(col, line); } screen.tc_col = col; screen.tc_line = line; }
/** * Get next byte from stdin, with special byte interpreted. * @return next byte from stdin */ int igetch(void) { static bool cr = 0; int ch; while (1) { ch = get_raw_ch(); switch (ch) { case IAC: handle_iac(); continue; case KEY_ESC: ch = handle_esc(); break; case Ctrl('L'): screen_redraw(); continue; case '\r': ch = '\n'; cr = true; break; case '\n': if (cr) { cr = false; continue; } break; case '\0': cr = false; continue; default: cr = false; break; } break; } return ch; }
int pip_basic_feed() { /* Òûʳ */ time_t now; char buf[256]; int pipkey; d.nodone = 1; do { if (d.death == 1 || d.death == 2 || d.death == 3) return 0; if (pip_mainmenu(1)) return 0; move(b_lines - 2, 0); clrtoeol(); move(b_lines - 2, 1); sprintf(buf, "%s¸Ã×öʲ÷áÊÂÄØ?", d.name); prints(buf); now = time(0); move(b_lines, 0); clrtoeol(); move(b_lines, 0); prints ("\033[1;44;37m Òûʳѡµ¥ \033[46m[1]³Ô·¹ [2]Áãʳ [3]²¹Íè [4]ÁéÖ¥ [5]È˲Π[6]Ñ©Á« [Q]Ìø³ö£º \033[m"); pip_time_change(now); pipkey = igetkey(); pip_time_change(now); switch (pipkey) { case '1': if (d.food <= 0) { move(b_lines, 0); temppress("ûÓÐʳÎïÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4, 0); if ((d.bbtime / 60 / 30) < 3) show_feed_pic(0); else show_feed_pic(1); d.food--; d.hp += 50; if (d.hp >= d.maxhp) { d.hp = d.maxhp; d.weight += rand() % 2; } d.nodone = 0; temppress("ÿ³ÔÒ»´ÎʳÎï»á»Ö¸´ÌåÁ¦50à¸!"); break; case '2': if (d.cookie <= 0) { move(b_lines, 0); temppress("Áãʳ³Ô¹âÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4, 0); d.cookie--; d.hp += 100; if (d.hp >= d.maxhp) { d.hp = d.maxhp; d.weight += (rand() % 2 + 2); } else { d.weight += (rand() % 2 + 1); } if (rand() % 2 > 0) show_feed_pic(2); else show_feed_pic(3); d.happy += (rand() % 3 + 4); d.satisfy += rand() % 3 + 2; d.nodone = 0; temppress("³ÔÁãʳÈÝÒ×ÅÖà¸..."); break; case '3': if (d.bighp <= 0) { move(b_lines, 0); temppress("ûÓдó²¹ÍèÁËÒ®! ¿ìÂò°É.."); break; } d.bighp--; d.hp += 600; d.tired -= 20; d.weight += rand() % 2; move(4, 0); show_feed_pic(4); d.nodone = 0; temppress("²¹Íè..³¬¼«°ôµÄà¡..."); break; case '4': if (d.medicine <= 0) { move(b_lines, 0); temppress("ûÓÐÁéÖ¥ÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4, 0); show_feed_pic(1); d.medicine--; d.mp += 50; if (d.mp >= d.maxmp) { d.mp = d.maxmp; } d.nodone = 0; temppress("ÿ³ÔÒ»´ÎÁéÖ¥»á»Ö¸´·¨Á¦50à¸!"); break; case '5': if (d.ginseng <= 0) { move(b_lines, 0); temppress("ûÓÐǧÄêÈ˲ÎÒ®! ¿ìÂò°É.."); break; } d.ginseng--; d.mp += 500; d.tired -= 20; move(4, 0); show_feed_pic(1); d.nodone = 0; temppress("ǧÄêÈ˲Î..³¬¼«°ôµÄà¡..."); break; case '6': if (d.snowgrass <= 0) { move(b_lines, 0); temppress("ûÓÐÌìɽѩÁ«Ò®! ¿ìÂò°É.."); break; } d.snowgrass--; d.mp = d.maxmp; d.hp = d.maxhp; d.tired -= 0; d.sick = 0; move(4, 0); show_feed_pic(1); d.nodone = 0; temppress("ÌìɽѩÁ«..³¬¼«°ôµÄà¡..."); break; #ifdef MAPLE case Ctrl('R'): if (currutmp->msgs[0].last_pid) { show_last_call_in(); my_write(currutmp->msgs[0].last_pid, "Ë®Çò¶ª»ØÈ¥£º"); } d.nodone = 0; break; #endif // END MAPLE } } while ((pipkey != 'Q') && (pipkey != 'q') && (pipkey != KEY_LEFT)); return 0; }
static int morekey(void) { int ch; while (1) { switch (ch = egetch()) { case 'q': case KEY_LEFT: case EOF: return KEY_LEFT; case ' ': case KEY_RIGHT: case KEY_PGDN: case Ctrl('F'): return KEY_RIGHT; case KEY_PGUP: case Ctrl('B'): return KEY_PGUP; case '\r': case '\n': case KEY_DOWN: case 'j': return KEY_DOWN; case 'k': case KEY_UP: return KEY_UP; case 'h': case 'H': case '?': return 'H'; case 'b': case 'B': case KEY_HOME: return KEY_HOME; case 'e': case 'E': case KEY_END: return KEY_END; case 'l': case 'L': return 'L'; case 'g': case 'G': return 'G'; case 'y': case 'Y': case 'n': case 'N': case 'r': case 'R': case 'c': case 'C': case 'm': case 'M': return toupper(ch); case '*': return ch; default: ; } } }
int fmain_menu() { char c; int i, x, y; int now_main = site, old_main = 0; clear(); draw_banner(MAIN_MENU_TOP - 6); move(MAIN_MENU_TOP - 2, MAIN_MENU_LEFT); prints("¢~שששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששש¢¡"); for (i = 0;i < total_nall;i++) { x = i % MAX_MAIN_MENU ; y = i / MAX_MAIN_MENU ; if (y == 0) { move(MAIN_MENU_TOP + x, MAIN_MENU_LEFT); clrtohol(); } move(MAIN_MENU_TOP + x, MAIN_MENU_LEFT + y*37); prints("%s%12s %s", ORG_BAR, main_menu[i], ORG_BAR); } move(MAIN_MENU_TOP + MAX_MAIN_MENU + 1, MAIN_MENU_LEFT); prints("¢¢שששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששש¢£"); outz("\033[46;44m ¡i¾�§@»¡©ת¡j \033[47;31m (¡פ¡ץ¡צ¡ק) \033[30m¿ן¾� \033[31m(Enter) \033[30m½T©w\033[31m (q)\033[30m ֲק¶} \033[m"); draw_main_menu(site, site); do { old_main = now_main; c = vkey(); switch (c) { case KEY_DOWN: now_main ++; if (now_main == total_nall) now_main = 0; draw_main_menu(now_main, old_main); break; case KEY_UP: now_main --; if (now_main < 0) now_main = total_nall - 1; draw_main_menu(now_main, old_main); break; case KEY_HOME: case '0': now_main = 0; draw_main_menu(now_main, old_main); break; case KEY_END: case '$': now_main = total_nall - 1; draw_main_menu(now_main, old_main); break; case Ctrl('U'): every_U(); break; case KEY_RIGHT: now_main += MAX_MAIN_MENU ; if (now_main > total_nall - 1) now_main %= MAX_MAIN_MENU ; draw_main_menu(now_main, old_main); break ; case KEY_LEFT: if (now_main < MAX_MAIN_MENU) { if (now_main <= (total_nall - 1) % MAX_MAIN_MENU) { now_main += MAX_MAIN_MENU * ((total_nall - 1) / MAX_MAIN_MENU); } else { now_main = total_nall - 1; } } else now_main -= MAX_MAIN_MENU ; draw_main_menu(now_main, old_main); break; case '\n': case '\r': return now_main; } } while (c != 'q' && c != 'Q' && c != KEY_ESC); return -1; }
void bell(void) { terminal_putchar(Ctrl('G')); }
int more(char *fpath, int promptend) { extern char *strcasestr(); static char *head[4] = {"§@ªÌ", "¼ÐÃD", "®É¶¡", "Âà«H"}; char *ptr, *word, buf[1024], *ch1; struct stat st; FILE *fp; usint pagebreak[MAXPAGES], pageno, lino; int line, ch, viewed, pos, numbytes; int header = 0; int local = 0; char search_char0 = 0; static char search_str[81] = ""; typedef char *(*FPTR) (); static FPTR fptr; int searching = 0; int scrollup = 0; char *http[80] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; /* Ptt */ char pagemode = 0; char pagecount = 0; inmore = 1; memset(pagebreak, 0, sizeof(pagebreak)); if (*search_str) search_char0 = *search_str; *search_str = 0; if (!(fp = fopen(fpath, "r"))) { inmore = 0; return -1; } if (fstat(fileno(fp), &st)) { inmore = 0; fclose(fp); return -1; } pagebreak[0] = pageno = viewed = line = pos = 0; clear(); while ((numbytes = readln(fp, buf)) || (line == t_lines)) { if (scrollup) { rscroll(); move(0, 0); } if (numbytes) /* ¤@¯ë¸ê®Æ³B²z */ { if (!viewed) /* begin of file */ { if (showansi) /* header processing */ { if (!strncmp(buf, str_author1, LEN_AUTHOR1)) { line = 3; word = buf + LEN_AUTHOR1; local = 1; } else if (!strncmp(buf, str_author2, LEN_AUTHOR2)) { line = 4; word = buf + LEN_AUTHOR2; } while (pos < line) { if (!local) str_decode(word); if (!pos && ((ptr = strstr(word, str_post1)) || (ptr = strstr(word, str_post2)))) { ptr[-1] = '\0'; /* hialan §ïÃC¦â */ clrtoeol(); prints("[1;36m¢~\033[46;37m%s\033[m%-55.55s[1;33;46m%.4s[m\033[1;33m%-13s\033[36m¢¡[0m\n", head[0], word, ptr, ptr + 5); } else if (pos < (local ? 3 : 4)) { clrtoeol(); prints("[1;36m¢x\033[46;37m%s\033[m%-72.72s[1;36m¢x\033[m\n", head[pos], word); } viewed += numbytes; numbytes = readln(fp, buf); if (!pos && viewed >= 79) /* ²Ä¤@¦æ¤Óªø¤F */ { if (memcmp(buf, head[1], 2)) /* ²Ä¤G¦æ¤£¬O [¼Ð....] */ { viewed += numbytes; /* Ū¤U¤@¦æ¶i¨Ó³B²z */ numbytes = readln(fp, buf); } } pos++; } if (pos) { header = 1; outs("[1;36m¢¢¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w\033[0;30;47m y)¦^À³ /)·j´M¤å¦r =[]<>)¥DÃD¦¡¾\\Ū \033[0;1;36m¢£[m\n"); line = pos = (local ? 4 : 5); } } lino = pos; word = NULL; } /* ¡°³B²z¤Þ¥ÎªÌ & ¤Þ¨¥ */ if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>')) word = "[36m"; if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>') && (buf[2] == ':' || buf[2] == '>')) word = "[33m"; if ((buf[0] == '¡' && buf[1] == '°') || !strncmp(buf, "==>", 3)) word = "[1;36m"; ch1 = buf; while (1) /* Ptt */ { int i; char e, *ch2; if (ch2 = strstr(ch1, "gopher://")); else if (ch2 = strstr(ch1, "mailto:")); else if (ch2 = strstr(ch1, "board://")); /* ¤ä´©ª½±µ¶i¤J¬ÝªO */ else break; for (e = 0; ch2[e] != ' ' && ch2[e] != '\n' && ch2[e] != '\0' && ch2[e] != '"' && ch2[e] != ';' && ch2[e] != ']'; e++); for (i = 0; http[i] && i < 80; i++) if (!strncmp(http[i], ch2, e) && http[e] == 0) break; if (!http[i]) { http[i] = (char *)malloc(e + 1); strncpy(http[i], ch2, e); http[i][e] = 0; pagecount++; } ch1 = &ch2[7]; } if (word) outs(word); { char msg[500], *pos; if (*search_str && (pos = fptr(buf, search_str))) { char SearchStr[41]; char buf1[100], *pos1; strncpy(SearchStr, pos, strlen(search_str)); SearchStr[strlen(search_str)] = 0; searching = 0; sprintf(msg, "%.*s[7m%s[0m", pos - buf, buf, SearchStr); while (pos = fptr(pos1 = pos + strlen(search_str), search_str)) { sprintf(buf1, "%.*s[7m%s[0m", pos - pos1, pos1, SearchStr); strcat(msg, buf1); } strcat(msg, pos1); outs(Ptt_prints(msg, NO_RELOAD)); } else { outs(Ptt_prints(buf, NO_RELOAD)); } } if (word) { outs("[0m"); word = NULL; } outc('\n'); if (beep) { bell(); beep = 0; } if (line < b_lines) /* ¤@¯ë¸ê®ÆŪ¨ú */ line++; if (line == b_lines && searching == -1) { if (pageno > 0) fseek(fp, (off_t) (viewed = pagebreak[--pageno]), SEEK_SET); else searching = 0; lino = pos = line = 0; clear(); continue; } if (scrollup) { move(line = b_lines, 0); clrtoeol(); for (pos = 1; pos < b_lines; pos++) viewed += readln(fp, buf); } else if (pos == b_lines) /* ±²°Ê¿Ã¹õ */ scroll(); else pos++; if (!scrollup && ++lino >= b_lines && pageno < MAXPAGES - 1) { pagebreak[++pageno] = viewed; lino = 1; } if (scrollup) { lino = scrollup; scrollup = 0; } viewed += numbytes; /* ²ÖpŪ¹L¸ê®Æ */ } else line = b_lines; /* end of END */ if (promptend && (!searching && line == b_lines || viewed == st.st_size)) { move(b_lines, 0); if (viewed == st.st_size) { if (searching == 1) searching = 0; } else if (pageno == 1 && lino == 1) { if (searching == -1) searching = 0; } prints("%s ÂsÄý P.%d(%d%%) ", COLOR2, pageno, (viewed * 100) / st.st_size); prints("%s ¡ö¡ô¡õ¡÷|PgUp|PgDn|Home|End)¾ÉÄý h)»¡©ú \033[m", COLOR3); move(b_lines, 0); /* ¸Ñ¨Mª½±µ¸õ¨ì¬ÝªOªºBug */ while (line == b_lines || (line > 0 && viewed == st.st_size)) { switch (ch = igetkey()) { case 'h': case 'H': case '?': show_file("etc/help/MORE.help", 0, 24, ONLY_COLOR); pressanykey_old(NULL); if (pageno) pageno--; lino = line = 0; break; case ':': { char buf[10]; int i = 0; getdata(b_lines - 1, 0, "Goto Page: ", buf, 5, DOECHO, 0); sscanf(buf, "%d", &i); if (0 < i && i < MAXPAGES && (i == 1 || pagebreak[i - 1])) pageno = i - 1; else if (pageno) pageno--; lino = line = 0; break; } case '/': { char ans[4] = "n"; *search_str = search_char0; getdata(b_lines - 1, 0, "[·j´M]ÃöÁä¦r:", search_str, 40, DOECHO, 0); if (*search_str) { searching = 1; if (getdata(b_lines - 1, 0, "°Ï¤À¤j¤p¼g(Y/N/Q)? [N] ", ans, 4, LCECHO, 0) && *ans == 'y') fptr = strstr; else fptr = strcasestr; } if (*ans == 'q') searching = 0; if (pageno) pageno--; lino = line = 0; break; } case 'n': if (*search_str) { searching = 1; if (pageno) pageno--; lino = line = 0; } break; case 'N': if (*search_str) { searching = -1; if (pageno) pageno--; lino = line = 0; } break; case 'r': case 'R': case 'Y': case 'y': case 'A': case 'a': case 'F': case 'B': case KEY_LEFT: case 'q': case 'b': case 'f': case ']': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ case '[': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ case '=': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ fclose(fp); inmore = 0; return ch; case Ctrl('F'): case KEY_PGDN: line = 1; break; case 't': if (viewed == st.st_size) { /* ch ']' */ fclose(fp); inmore = 0; return ']'; } line = 1; break; case ' ': if (viewed == st.st_size) { /* ch 'f' */ fclose(fp); inmore = 0; return 'f'; } line = 1; break; case KEY_RIGHT: if (viewed == st.st_size) { /* ch 'q' */ fclose(fp); inmore = 0; return 'q'; } line = 1; pagemode = 0; break; case '\r': case '\n': if (pagemode) { more_web(http[pagemode - 1], YEA); /* pagebreak[0] = pageno = viewed = line = pos = 0; */ pagemode = 0; *search_str = 0; if (pageno) pageno--; lino = line = 0; break; } case KEY_DOWN: if (viewed == st.st_size || promptend == 2 && (ch == '\r' || ch == '\n')) { /* ch 'f' */ fclose(fp); inmore = 0; return 'f'; } line = t_lines - 2; break; case '$': case 'G': case KEY_END: line = t_lines; break; case '0': case 'g': case KEY_HOME: pageno = line = 0; break; case 'E': if (strcmp(fpath, "etc/ve.hlp")) { /* ch 'q' */ fclose(fp); inmore = 0; vedit(fpath, HAS_PERM(PERM_SYSOP) ? 0 : 2); return 'q'; } break; case KEY_ESC: if (KEY_ESC_arg == 'n') { edit_note(); if (pageno) pageno--; lino = line = 0; } else if (KEY_ESC_arg == 'c') capture_screen(); break; case Ctrl('I'): if (!pagecount) break; pagemode = (pagemode % pagecount) + 1; strcpy(search_str, http[pagemode - 1]); fptr = strstr; if (pageno) pageno--; lino = line = 0; break; case KEY_UP: line = -1; break; case Ctrl('B'): case KEY_PGUP: if (pageno > 1) { if (lino < 2) pageno -= 2; else pageno--; lino = line = 0; } else if (pageno && lino > 1) pageno = line = 0; break; case Ctrl('H'): if (pageno > 1) { if (lino < 2) pageno -= 2; else pageno--; lino = line = 0; } else if (pageno && lino > 1) pageno = line = 0; else { /* ch 'b' */ fclose(fp); inmore = 0; return 'b'; } } } if (line > 0) { move(b_lines, 0); clrtoeol(); refresh(); } else if (line < 0) { /* Line scroll up */ if (pageno <= 1) { if (lino == 1 || !pageno) { /* ch 'b' */ fclose(fp); inmore = 0; return 'b'; } /* ¶¤º¤W±² sheng 20020113 */ if (header && lino <= 6 - local) { fseek(fp, (off_t) (viewed = pagebreak[scrollup = lino = pageno = 0] = 0), SEEK_SET); clear(); } } if (pageno && lino > 1) { line = lino - 2; if (pageno == 1 && header) line = lino - 3; scrollup = lino - 1; fseek(fp, (off_t) (viewed = pagebreak[pageno - 1]), SEEK_SET); while (line--) viewed += readln(fp, buf); } else if (pageno > 1) { scrollup = b_lines - 1; line = b_lines - 2; if (pageno == 2 && header) line = b_lines - 3; fseek(fp, (off_t) (viewed = pagebreak[--pageno - 1]), SEEK_SET); while (line--) viewed += readln(fp, buf); } line = pos = 0; } else { pos = 0; fseek(fp, (off_t) (viewed = pagebreak[pageno]), SEEK_SET); clear(); } } } fclose(fp); if (promptend) { pressanykey(NULL); clear(); } else outs(reset_color); inmore = 0; return 'q'; /* ch 'q'*/ }
int winloop() { int x, y, c, marked, t0, inited; x= 10; y= 8; inited= 0; marked= 0; t0=time(0); steps=0; while(1) { c= igetkey(); //system("echo start_winloop_igetkey >> /home/bbs/stiger.test"); steps++; if(c=='q' || c==Ctrl('C')) return 0; if((c==KEY_UP||c=='k')&&y>1) y--; if((c==KEY_DOWN||c=='j')&&y<16) y++; if((c==KEY_LEFT||c=='h')&&x>1) x--; if((c==KEY_RIGHT||c=='l')&&x<30) x++; move(20,0); prints("й╠╪Д: %d ", time(0)-t0); move(21,0); prints("вЬ╠Й: %3d, %3d", x, y); move(y-1,x*2-2); //modified by stiger,2001,6,12,╦дуЩmarkedмЁ╪ф╣д╢МнС if(ganyingshi) { marknum=o[x-1][y-1]+o[x-1][y]+o[x-1][y+1]+o[x][y-1]+o[x][y+1]+o[x+1][y-1]+o[x+1][y]+o[x+1][y+1]; if((m[x][y]!=1)&&(num_mine_beside(x, y)==8-marknum)) { if(o[x-1][y-1]!=1) { if(!m[x-1][y-1]) {m[x-1][y-1]=1; marked++; } winsh(x-1,y-1);} if(o[x-1][y]!=1) { if(!m[x-1][y]) {m[x-1][y]=1; marked++; } winsh(x-1,y);} if(o[x-1][y+1]!=1) { if(!m[x-1][y+1]) {m[x-1][y+1]=1; marked++;} winsh(x-1,y+1);} if(o[x][y-1]!=1) { if(!m[x][y-1]) {m[x][y-1]=1; marked++; } winsh(x,y-1);} if(o[x][y+1]!=1) { if(!m[x][y+1]) {m[x][y+1]=1; marked++;} winsh(x,y+1);} if(o[x+1][y-1]!=1) { if(!m[x+1][y-1]) {m[x+1][y-1]=1; marked++;} winsh(x+1,y-1);} if(o[x+1][y]!=1) { if(!m[x+1][y]) {m[x+1][y]=1; marked++;} winsh(x+1,y);} if(o[x+1][y+1]!=1) { if(!m[x+1][y+1]) {m[x+1][y+1]=1; marked++;} winsh(x+1,y+1);} } if(num_mine_beside(x, y)==num_mark_beside(x, y)) dblclick(x,y); } //add by stiger,2001,6,12,╦дуЩmarkedотй╬╣днйлБ move(20,30); prints("╠Й╪г: %d ", marked); //add end if(c=='H') winhelp(); if(c=='d'|| c=='D') winrefresh(); if(c=='f'|| c=='F'){ if(!inited) { wininit(x, y); inited= 1; } dig(x, y); } if((c==83|| c==115)&&!o[x][y]) { if(m[x][y]){ m[x][y]=0; marked--; } else { m[x][y]=1; marked++; } winsh(x, y); //add by stiger,2001,6,12 move(20,30); prints("╠Й╪г: %d ", marked); //add end } if(checkwin()==1) { /*add by stiger*/ stiger=steps*1.0/(time(0)-t0); move(22,0); prints("вё╨ьдЦё║дЦЁи╧╕акё║ф╫╬Ыц©цК%lf╡╫",stiger); gameover= 0; win_checkrec(time(0)-t0);/* added by soff ╫Ьппеепп╪Л╡И */ return 1; } if(gameover) { move(22,0); prints("╨эре╨╤ё╛дЦй╖╟эак... тыю╢р╩╢н╟иё║ "); gameover= 0; return 1; } move(y-1,x*2-2); refresh(); } return 1; }
static char *ShellArgs[2]; static char inbuf[IOSIZE]; static inlen; static ESCseen; static GotSignal; static char DefaultShell[] = "/bin/sh"; static char DefaultPath[] = ":/usr/ucb:/bin:/usr/bin"; static char PtyProto[] = "/dev/ptyXY"; static char TtyProto[] = "/dev/ttyXY"; static int TtyMode = 0622; static char SockPath[512]; static char SockDir[] = ".rmgr"; static char *SockNamePtr, *SockName; static ServerSocket; static char *NewEnv[MAXARGS]; static char Esc = Ctrl('a'); static char *home; static HasWindow; static utmp, utmpf; static char UtmpName[] = "/etc/utmp"; static char *LoginName; static char HostName[MAXSTR]; static Detached; static AttacherPid; /* Non-Zero in child if we have an attacher */ static DevTty; static char EventStr[]="%c%cA"; static char CommNames[MAXLINE]; static int VoluntaryDetach = 0; static int MyFont; struct mode {