static int open_interactive (void) { if (Use_Readline && (-1 == open_readline ("slsh"))) return -1; if (NULL == (Readline_Load_Object = SLallocate_load_type ("<stdin>"))) { if (Use_Readline) close_readline (); return -1; } Readline_Load_Object->read = read_using_readline; Readline_Load_Object->auto_declare_globals = 1; #if !SYSTEM_SUPPORTS_SIGNALS /* If the system does not support asynchronouse signals, then it may install * a SLang_Interrupt hook that checks for ^C, etc. For that reason, the * tty must be initialized the whole time. */ init_tty (); #endif enable_keyboard_interrupt (); return 0; }
main(int argc, char **argv) { /* * Optionally let them specify device. */ if (argc > 1) { tty_dev = argv[1]; open_tty_dev(tty_dev); } /* * Randomize a bit */ srandom(time((long *)0)); /* * Display welcoming banner */ cat(_PATH_BANNER); /* * Set up the TTY mode for cbreak noecho type of interaction */ init_tty(); /* * Login or bust */ for (;;) { do_login(); } }
static void sig_sigtstp (int sig) /*{{{*/ { (void) sig; SLsig_block_signals (); reset_tty (); kill(getpid(),SIGSTOP); init_tty (); if (Use_SLang_Readline == 0) { #ifdef HAVE_GNU_READLINE rl_refresh_line (0,0); #endif } else { if (Active_Rline_Info != NULL) { SLrline_set_display_width (Active_Rline_Info, SLtt_Screen_Cols); SLrline_redraw (Active_Rline_Info); } } SLsig_unblock_signals (); }
void task_tty(void) { Tty *tty; init_console(); for (tty = tty_table ; tty < tty_table + TTY_NUM ; ++tty) { init_tty(tty); } select_tty(0); static int i=0; while(1) { //assert(0); //panic("in tty"); s32_print_int(i, (u8*)(0xb8000+160*23), 10); ++i; for (tty = tty_table ; tty < tty_table + TTY_NUM ; ++tty) { if (tty->ready == 1) { tty_do_read(tty); tty_do_write(tty); } } } }
/*======================================================================* task_tty *----------------------------------------------------------------------* * 作用:键盘中断处理函数 *======================================================================*/ PUBLIC void task_tty() { TTY *p_tty; // 初始化键盘中断放到这里,进程开始执行的时候执行一次 init_keyboard(); // 遍历初始化所有TTY for (p_tty = TTY_FIRST; p_tty < TTY_END; p_tty++) { init_tty(p_tty); } nr_current_console = 0; // 最开始生效的是第一个TTY while (1) { // 轮询所有TTY,如果当前TTY在前台,读取键盘缓冲区,显示到显存中 for (p_tty = TTY_FIRST; p_tty < TTY_END; p_tty++) { tty_do_read(p_tty); tty_do_write(p_tty); } } }
void init_driver() { init_hal(); init_timer(); init_tty(); init_ide(); init_ramdisk(); hal_list(); }
int main(int n, char* cmd[]) { tcgetattr(0, &oldtty); //cfmakeraw(&newtty); init_tty(); tcsetattr(0, TCSANOW, &newtty); if(n>=2) strcpy(userid, cmd[1]); if(n>=3) strcpy(fromhost, cmd[2]); syslog("ENTER"); winmine(); tcsetattr(0, TCSANOW, &oldtty); }
void suspend_myself(void) { /* restore tty and SIGTSTP settings before suspending myself */ cleanup_tty(); cleanup_ctrl_z_handler(); kill(getpid(), SIGTSTP); /* received SIGCONT: perform again initial setup */ init_ctrl_z_handler(); init_tty(); }
int main(int argc, char **argv) { check_privileges(); clear(); init_tty(); setup_signals(); struct pollfd ufds[2] = { { .fd = STDIN_FILENO, .events = POLLIN, .revents = 0 }, { .fd = -1, .events = POLLIN, .revents = 0 }
int main(int argc, char *argv[]) { char *host=NULL; /* "hostname" or "user@hostname" */ char *path; /* path to socket */ char *p; char *text=NULL; char *timeout_str=NULL; int timeout = 1; if (argc<2 || argc>4) { fprintf(stderr, "%s: unrecognized arguments\n" "usage: %s /path/to/socket [text] [timeout]\n" " %s remote_user@remote_host:/path/to/socket [text] [timeout]\n", argv[0], argv[0], argv[0]); exit(1); } p=strdup(argv[1]); log_fp=stderr; if((path=strchr(p,':')) != NULL) { host=p; *path='\0'; path++; } else { path=p; } if (argc >= 3) text = argv[2]; if (argc == 4) { timeout_str = argv[3]; int read_timeout = atoi(timeout_str); if (read_timeout > 0) timeout = read_timeout; } init_signal_handlers(); setlinebuf(stdout); setlinebuf(stderr); if (host) { logprintf(MY_NAME,"connecting through ssh to %s on %s",path,host); connect_ssh(host,path,text,timeout_str); } else { logprintf(MY_NAME,"connecting directly to %s",path); init_tty(); connect_direct(path,text,timeout); cleanup_tty(); } if (time_to_die != 0) { logprintf(MY_NAME,"got signal %d, exiting",time_to_die); } return 0; }
/** * <Ring 1> Main loop of task TTY. *****************************************************************************/ PUBLIC void task_tty() { TTY * tty; MESSAGE msg; init_keyboard(); for (tty = TTY_FIRST; tty < TTY_END; tty++) init_tty(tty); select_console(0); while (1) { for (tty = TTY_FIRST; tty < TTY_END; tty++) { do { tty_dev_read(tty); tty_dev_write(tty); } while (tty->ibuf_cnt); } send_recv(RECEIVE, ANY, &msg); int src = msg.source; assert(src != TASK_TTY); TTY* ptty = &tty_table[msg.DEVICE]; switch (msg.type) { case DEV_OPEN: reset_msg(&msg); msg.type = SYSCALL_RET; send_recv(SEND, src, &msg); break; case DEV_READ: tty_do_read(ptty, &msg); break; case DEV_WRITE: tty_do_write(ptty, &msg); break; case HARD_INT: /** * waked up by clock_handler -- a key was just pressed * @see clock_handler() inform_int() */ key_pressed = 0; continue; default: dump_msg("TTY::unknown msg", &msg); break; } } }
/*======================================================================* task_tty *======================================================================*/ PUBLIC void task_tty() { TTY* p_tty; MSG msg; init_keyboard(); for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { init_tty(p_tty); } select_console(0); //清屏 clear(TTY_FIRST); //欢迎信息 printf("X-Tinix.\n"); printf("X-Tinix: TTY(TASK) loaded.\n"); //就绪消息 _send(PID_SERVICE_PROC ,MSG_TYPE_TTY_READY); _recv(MSG_TYPE_PROC_READY); _send(PID_SERVICE_SHELL,MSG_TYPE_TTY_READY); //监听消息 while (1) { if(recv(ANY_MSG_SRC,&msg)!=-1){ SHELL_MSG shell_msg; memcpy(&shell_msg,msg.msg,sizeof(SHELL_MSG)); switch(msg.type){ case MSG_TYPE_SHELL: tty_write(TTY_FIRST+shell_msg.tty,shell_msg.command,strlen(shell_msg.command)); break; case MSG_TYPE_TTY_CLEAR: p_tty = TTY_FIRST + shell_msg.tty; clear(p_tty); break; default: break; } } for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { tty_do_read(p_tty); //tty_do_write(p_tty); } //clean work memset(&msg,0x0,sizeof(MSG)); } }
void task_tty() { struct Tty *p_tty; init_keyboard(); for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++) init_tty(p_tty); select_console(0); while(1) { for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++) { tty_do_read(p_tty); tty_do_write(p_tty); } } }
static void sig_sigtstp (int sig) { (void) sig; SLsig_block_signals (); reset_tty (); kill(getpid(),SIGSTOP); init_tty (); if (Active_Rline_Info != NULL) { SLrline_set_display_width (Active_Rline_Info, SLtt_Screen_Cols); SLrline_redraw (Active_Rline_Info); } SLsig_unblock_signals (); }
static void suspend_slsh (void) { reset_tty (); (void) SLang_run_hooks ("slsh_readline_suspend_before_hook", 0); kill (0, SIGSTOP); (void) SLang_run_hooks ("slsh_readline_suspend_after_hook", 0); init_tty (); if (Active_Rline_Info != NULL) { SLsig_block_signals (); SLrline_set_display_width (Active_Rline_Info->rli, SLtt_Screen_Cols); SLrline_redraw (Active_Rline_Info->rli); SLsig_unblock_signals (); } }
int jed_spawn_fg_process (int (*f)(VOID_STAR), VOID_STAR cd) { int status; int inited; if ((Jed_Secure_Mode) || (Jed_Suspension_Not_Allowed)) { msg_error ("Access to shell denied."); return -1; } /* FIXME: X_Suspend_Hook should not be here. Currently, this hook is * used only by GUI jed, where suspension makes no sense. Of course in * this case, spawning a foreground process also does not make sense. */ if (Batch || (X_Suspend_Hook != NULL)) return (*f) (cd); SLsig_block_signals (); inited = Jed_Display_Initialized; SLsig_unblock_signals (); jed_reset_display(); #if !defined(IBMPC_SYSTEM) && !defined(VMS) jed_reset_signals (); #endif reset_tty(); status = (*f) (cd); if (inited) { #if !defined(IBMPC_SYSTEM) && !defined(VMS) init_signals(); #endif if (-1 == init_tty()) { exit_error ("Unable to initialize terminal.", 0); } flush_input (); jed_init_display (); } check_buffers(); return status; }
void kernel_main(char boot_disk_id, void *memory_map, BootModuleInfo *boot_module_list) { init_memory_manager(memory_map); init_tty(); clear(); init_interrupts(); init_pci(); int arr[10000]; textcolor(2); printf("Structure size: %d\n",sizeof(arr)); printf("kernel_page_dir = 0x%x\n", kernel_page_dir); printf("memory_size = %d MB\n", memory_size / 1024 / 1024); printf("get_page_info(kernel_page_dir, 0xB8000) = 0x%x\n", get_page_info(kernel_page_dir, (void*)0xB8000)); }
/*======================================================================* task_tty *======================================================================*/ PUBLIC void task_tty() { TTY* p_tty; init_keyboard(); for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { init_tty(p_tty); } select_console(0); while (1) { for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { tty_do_read(p_tty); tty_do_write(p_tty); } } }
int main(int n, char *cmd[]) { save_tty(); init_tty(); if (n >= 2) strcpy(datafile, cmd[1]); if (n >= 3) strcpy(telnet, cmd[2]); if (n >= 4) strcpy(userid, cmd[3]); init_data(); main_loop(); printf("\033[m"); reset_tty(); return 0; }
static void sigtstp_handler (int sig) { sig = errno; SLsmg_suspend_smg (); if (TTY_State) SLang_reset_tty (); kill(getpid(),SIGSTOP); SLsmg_resume_smg (); if (TTY_State) init_tty (TTY_State - 1); signal (SIGTSTP, sigtstp_handler); errno = sig; }
void osmain( void ) { int i; int j=0; char nb[10]; char tmbuf[30]; /* ini screen first,so that we can output info as early as possible */ init_tty(); /* initialize the screen*/ kprintf( "TTY initialized\n" ); /* init both physical and virtual memory */ init_mm(); kprintf( "Memory manager initialized\n" ); init_irq(); /*initialize irq,with all interrupte disabled.*/ kprintf( "IRQ initialized\n" ); kprintf("\nHello\n"); install_syscall(); init_all_tasks(); init_kb(); /* set keyboard IRQ,and enable it */ kprintf( "\nKeyboard initialized\n" ); init_timer(); /* initialize time, enable timer irq */ /* init_system_clock(&real_tm); */ kprintf( "\nTimer initialized\n"); init_system_clock(&start_tm); kprintf("\nSystem start time is \n"); kprintf(timetostr(&start_tm, tmbuf)); kprintf("\nStarting first process....\n"); start_first_process(); kprintf( "\nNow I am doing a loop ,waiting for interrupt :)\n" ); while(1); halt(); }
PUBLIC void task_tty() { TTY* tty; init_keyboard(); for (tty=TTY_FIRST;tty<TTY_END;tty++) { init_tty(tty); } printinfo("\ninit clock\n"); printinfo("init keyboard\n"); select_SCREEN(0); while (1) { for (tty=TTY_FIRST;tty<TTY_END;tty++) { tty_do_read(tty); tty_do_write(tty); } } }
int SLcurses_wnoutrefresh (SLcurses_Window_Type *w) { unsigned int len; unsigned int r, c; unsigned int i, imax; if (SLcurses_Is_Endwin) { if (TTY_State) init_tty (TTY_State - 1); SLsmg_resume_smg (); SLcurses_Is_Endwin = 0; } if (w == NULL) { SLsmg_refresh (); return -1; } if (w->modified == 0) return 0; r = w->_begy; c = w->_begx; len = w->ncols; imax = w->nrows; for (i = 0; i < imax; i++) { SLsmg_gotorc (r, c); write_color_chars (w->lines[i], len); r++; } if (w->has_box) SLsmg_draw_box(w->_begy, w->_begx, w->nrows, w->ncols); SLsmg_gotorc (w->_begy + w->_cury, w->_begx + w->_curx); w->modified = 0; return 0; }
int main(int argc, char** argv) { int ret; t_arg arg; if (isatty(STDIN_FILENO) == 0) return fatal(2, strerror(errno), 1); ret = 0; if (get_arg(argc, argv, &arg)) return 1; if (arg.name_process != 0) { if (init_tty()) return 1; ret = inspect_proccess(&arg); restore_tty(); } return ret; }
void initwin() { char *s; init_tty(); LINES = DEFAULT_LINES; COLS = DEFAULT_COLS; if ((s = getenv("LINES")) != NULL) { LINES = atoi(s); LINES = (LINES > MAX_LINES)? MAX_LINES:LINES; } if ((s = getenv("COLUMNS")) != NULL) { COLS = atoi(s); COLS = (COLS > MAX_COLS)? MAX_COLS:COLS; } ctrlflag &= ~F_TABEXPAND; tabsz = 8; /* default tabsize */ clear(); refresh(); }
static char *read_input_line (Slsh_Readline_Type *sri, char *prompt, int noecho) { char *line; if (Use_Readline == 0) return read_with_no_readline (prompt, noecho); #if SYSTEM_SUPPORTS_SIGNALS init_tty (); #endif #if USE_GNU_READLINE (void) sri; if (noecho == 0) rl_redisplay_function = rl_redisplay; else { /* FIXME: What is the proper way to implement this in GNU readline? */ (void) fputs (prompt, stdout); (void) fflush (stdout); rl_redisplay_function = redisplay_dummy; } line = readline (prompt); rl_redisplay_function = rl_redisplay; #else SLtt_get_screen_size (); SLrline_set_display_width (sri->rli, SLtt_Screen_Cols); (void) add_sigwinch_handlers (); Active_Rline_Info = sri; (void) SLrline_set_echo (sri->rli, (noecho == 0)); line = SLrline_read_line (sri->rli, prompt, NULL); Active_Rline_Info = NULL; #endif #if SYSTEM_SUPPORTS_SIGNALS reset_tty (); #endif if (sri->output_newline) fputs ("\r\n", stdout); fflush (stdout); return line; }
int _clip_init_tty(ClipMachine * ret) { int r; char errbuf[128]; if (ret->screen) { restart_tty(ret->screen->base); return 0; } r = init_tty(ret->screen_base, 0, _clip_envp, 0, (ScreenPgChars *) _clip_pgtbl, errbuf, sizeof(errbuf)); if (r >= 0) { ret->screen = new_Screen(ret->screen_base); if (r > 0) _clip_logg(0, "init screen: %s", errbuf); r = 0; } else { free(ret->screen_base); snprintf(ret->syserr, sizeof(ret->syserr), "%s", errbuf); ret->screen_base = 0; ret->screen = 0; } if (ret->screen) { ret->wboard.bottom_of_ClipRect = ret->windows->ClipRect_format_of_ClipWindow.bottom_of_ClipRect = ret->screen->base->Lines - 1; ret->wboard.right_of_ClipRect = ret->windows->ClipRect_format_of_ClipWindow.right_of_ClipRect = ret->screen->base->Columns - 1; ret->windows->ClipRect_format_of_ClipWindow = ret->windows->ClipRect_format_of_ClipWindow; } return r; }
static void shell_login(int argc, char *argv[], char *envp[]) { /* Give up root privileges: no way back from here */ setgid(BBSGID); setuid(BBSUID); chdir(BBSHOME); /* mmap passwd file */ if(passwd_mmap()) exit(1); use_shell_login_mode=1; initsetproctitle(argc, argv, envp); /* copy from the original "bbs" */ if(argc > 1) { strcpy(fromhost, argv[1]); #if 0 if(argc > 2) strcpy(tty_name, argv[2]); #endif if(argc > 3) strcpy(remoteusername, argv[3]); } { char cmd[80] = "??@"; if(!getenv("RFC931")) setenv("RFC931", strcat(cmd, fromhost), 1); } close(2); /* don't close fd 1, at least init_tty need it */ init_tty(); if(check_ban_and_load(0)) exit(0); }
/* * definition */ void task_tty(){ int i; MSG *p_msg; /* * Can not change */ init_console(); init_tty(); // tty_write_str("LeiMing" , (TTY *)&tty_table[TTY_ENABLE]); // tty_write_ctrl((TTY *)&tty_table[TTY_ENABLE]); // tty_write_str("is Best!" , (TTY *)&tty_table[TTY_ENABLE]); /* * Test msg = get_msg(); msg -> type = 8; tty_write_int((u32)msg -> type , (TTY *)&tty_table[TTY_ENABLE]); del_msg(msg); msg = get_msg(); tty_write_int((u32)msg -> type , (TTY *)&tty_table[TTY_ENABLE]); */ // int i; // char *src = {"Lei Ming is best hahaha"}; // char dest[20]; // for(i = 0; i < 20; i++){ // dest[i] = '0'; // } // strcpy(dest , src , sizeof(dest) - 1); // tty_write_str(dest , (TTY *)&tty_table[TTY_ENABLE]); // disp_int(i); // set_start_vmem((u32)(80 * 1)); while(1){ p_msg = recv_msg(); if(p_msg == (MSG *)NULL){ }else{ switch(p_msg -> type){ //根据消息的不同类型来不同地处理 // case MSG_WRITE_ENTER: case MSG_WRITE_CHAR: tty_write_char(p_msg -> int_info[0] , (TTY *)&tty_table[p_msg -> int_proc_info[1]]); del_msg(p_msg); break; case MSG_WRITE_INT: tty_write_int(p_msg -> int_info[0] , (TTY *)&tty_table[p_msg -> int_proc_info[1]]); del_msg(p_msg); break; case MSG_WRITE_STR: tty_write_str(p_msg -> str_info , (TTY *)&tty_table[p_msg -> int_proc_info[1]]); //第二个参数是进程所在的p_tty del_msg(p_msg); break; case MSG_PRINT_CTRL: tty_print_ctrl((TTY *)&tty_table[p_msg -> int_proc_info[1]]); del_msg(p_msg); break; default: break; } } key_control((TTY *)&tty_table[TTY_ENABLE]); } }
int sysbef (char *befbuf) //************************************************************************* // //************************************************************************* { static char shutdown_reason[23]; char xbuf[20]; static char *beftab[] = { "CONNECT", "LOGIN", "CALL", "OSHELL", #ifdef __DOS16__ #ifdef _TNC "TNC", #endif "W2", "UWIN", "TWIN", #ifdef _AUTOTRCWIN "TRWIN", #endif #endif "RTEXT", "CAT", "RPRG", "WTEXT", "WPRG", "RBIN", "WBIN", "SLR", "CLOG", "REORG", "LIFETIME", "MKBOARD", "RMBOARD", "MVBOARD", "SHUTDOWN", "NEW", "KILL", "TEST", "IMPORT", "DISABLE", "ENABLE", #ifdef DIEBOX_UIMPORT "UIMPORT", #endif #ifdef OLDMAILIMPORT "OLDMAILIMPORT", #endif "SETUSER", "BEACON", "GREP", "TGREP", "TAIL", "BEGIN", "BATCH", "EXPORT", "PWGEN", "POSTFWD", "MONITOR", "NOTE", "MACRO", "CFGFLEX", "ORM", "OMV", "OCP", "OMD", "APPEND", #ifdef DF3VI_EXTRACT "EXTRACT", #endif "HOLD", "SETPW", #ifdef FEATURE_YAPP "WYAPP", "RYAPP", #endif #ifdef FEATURE_DIDADIT "WDIDADIT", "RDIDADIT", #endif #if defined FEATURE_SERIAL || defined _TELEPHONE "TTYINIT", #endif #ifdef _TELEPHONE // JJ "TTYCMD", "TTYDIAL", "TTYHANGUP", "TTYSTATUS", "TTYWIN", "TTYCOUNTERRESET", #endif #ifdef _AUTOFWD "AFWDLIST", #endif #ifdef FEATURE_MDPW "MD2SUM", "MD5SUM", #endif #ifdef FEATURE_EDITOR "EDIT", "FEDIT", "REDIT", #else #ifdef DF3VI_FWD_EDIT "FEDIT", "FWDEDIT", #endif #ifdef DF3VI_REJ_EDIT "REDIT", "REJECTEDIT", #endif #ifdef DF3VI_CONV_EDIT "CEDIT", "CONVEDIT", #endif #endif #ifdef _FILEFWD "FWDIMPORT", "FWDEXPORT", #endif "YMBTEST", "SCMDLIST", // Dies ist immer das letzte Kommando! NULL }; enum befnum { unsinn, connect_, login, call_, oshell_, #ifdef __DOS16__ #ifdef _TNC tnc, #endif w2, uwin, twin, #ifdef _AUTOTRCWIN trwin, #endif #endif rtext, rtext_, rprg, wtext, wprg, rbin, wbin, slr, clog, reorg, life_, mkb, rmb, mvb, shutdown_, new_, kill_, test, import, disable_, enable_, #ifdef DIEBOX_UIMPORT uimport_, #endif #ifdef OLDMAILIMPORT oldmailimport_, #endif setuser, beacon, grep_, tgrep, tail, begin, batch, export_, pwgen, postfwd_, monitor_, note, macro, cfgflex_, orm, omv, ocp, omd, _append, #ifdef DF3VI_EXTRACT extract_, #endif hold, setpw, #ifdef FEATURE_YAPP wyapp, ryapp, #endif #ifdef FEATURE_DIDADIT wdidadit, rdidadit, #endif #if defined FEATURE_SERIAL || defined _TELEPHONE ttyinit, #endif #ifdef _TELEPHONE // JJ ttycmd, ttydial, ttyhangup, ttystatus, ttywin_, ttycounterreset, #endif #ifdef _AUTOFWD afwdlist_, #endif #ifdef FEATURE_MDPW md2sum, md5sum, #endif #ifdef FEATURE_EDITOR edit, fedit, redit, #else #ifdef DF3VI_FWD_EDIT fedit, fwdedit, #endif #ifdef DF3VI_REJ_EDIT redit, rejectedit, #endif #ifdef DF3VI_CONV_EDIT cedit, convedit_, #endif #endif #ifdef _FILEFWD fwdimport, fwdexport, #endif ymbtest, scmdlist // Dies ist immer das letzte Kommando! } cmd = unsinn; befbuf += blkill(befbuf); cmd = (befnum) readcmd(beftab, &befbuf, 0); switch (cmd) { #ifdef FEATURE_YAPP case ryapp: #endif #ifdef FEATURE_DIDADIT case rdidadit: #endif #if defined(FEATURE_YAPP) || defined(FEATURE_DIDADIT) break; #endif default: if (u->lf != 6) putv(LF); leerzeile(); // Sends the number of CRs stored in "ALTER LF" } switch (cmd) { case unsinn: if ( mbinitbef(befbuf, 0) #ifdef _TELEPHONE // JJ || ttyinitbef(befbuf, 0) #endif ) { strcpy(xbuf, "^"); mbparsave(); #ifdef _TELEPHONE // JJ ttyparsave(); #endif strncpy(xbuf + 1, befbuf, 18); xbuf[19] = 0; subst1(xbuf, ' ', 0); subst1(xbuf, '=', 0); grep(MBINITNAME, xbuf, o_i); #ifdef _TELEPHONE // JJ grep(INITTTYNAME, xbuf, o_i); #endif return OK; } else return NO; case note: trace(replog, "note", "%s", befbuf); break; #ifdef DF3VI_EXTRACT case extract_: mbchange(befbuf, w_extract, 1); break; #endif case hold: mbchange(befbuf, w_hold, 1); break; case omv: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || xrename(f1, f2)) putf(ms(m_error)); else { putf(ms(m_moving)); putf(ms(m_nach), f1, f2); } break; } case ocp: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || filecopy(f1, f2)) putf(ms(m_error)); else { putf(ms(m_copying)); putf(ms(m_nach), f1, f2); } break; } case orm: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); if (! *f1 || xunlink(f1)) putf(ms(m_filecantdeleted), f1); else putf(ms(m_filedeleted), f1); break; } case omd: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); killbackslash(f1); if (! *f1 || xmkdir(f1)) putf(ms(m_directorycantcreated), f1); else putf(ms(m_directorycreated), f1); break; } case _append: { char textline[LINELEN+1]; befbuf = nexttoken(befbuf, textline, LINELEN); if (! *befbuf) { putf("Syntax: APPEND <textline> <filename>\n"); break; } FILE *f = s_fopen(befbuf, "sat"); if (f) { fprintf(f, "%s\n", textline); s_fclose(f); } else putf(ms(m_filenotfound), befbuf); } break; case macro: { mk_start(befbuf); } break; case setuser: { char call[CALLEN+1]; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); if (mbcallok(call) && *befbuf) { trace(report, "setuser", "%s", befbuf); { if (! mbalter(NULL, befbuf, call)) putf(ms(m_isunknown), call); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } } else putf("Syntax: SETUSER <call> <option> <value>\n"); } break; case setpw: //automatisierte Passwort-Vergabe { char call[CALLEN+1]; char passwd[40]; int i, pwline = 0; FILE *upwf; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); pwline = atoi(befbuf); if (! mbcallok(call) || ! pwline) { putf("Syntax: SETPW <call> <number>\n"); break; } if (! loaduser(call, u, 0)) { putf(ms(m_isunknown), call); break; } upwf = s_fopen("userpw.bcm", "sr"); if (! upwf) { putf(ms(m_filenotfound), "userpw.bcm"); break; } for (i = 0; i < pwline && ! feof(upwf); i++) fgets(passwd, sizeof(passwd) - 1, upwf); s_fclose(upwf); if (i < pwline) { putf(ms(m_userpwlines), i - 1); break; } strcpy(u->password, passwd); saveuser(u); pwline = strlen(u->password); putf(ms(m_loginpw), pwtypestr(u->loginpwtype), pwtypestr(u->sfpwtype)); putf(" "); putf(ms(m_pwdlength), pwline); sprintf(passwd, "pw set to %i char", pwline); pwlog(call, b->logincall, passwd); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } break; #ifdef DIEBOX_UIMPORT case uimport_: { putf(ms(m_dieboximport)); uimport(); } break; #endif #ifdef OLDMAILIMPORT case oldmailimport_: { scanoptions(befbuf); formoptions(); befbuf += blkill(befbuf); if (isdir(befbuf)) { putf(ms(m_omi_started), befbuf); putflush(); oldmailimport(befbuf); } else putf(ms(m_dirunknown), befbuf); } break; #endif case disable_: { putf(ms(m_boxdisabled)); m.disable = 1; mbparsave(); } break; case enable_: { putf(ms(m_boxenabled)); m.disable = 0; mbparsave(); } break; case test: { if (*befbuf == 'W') { while (1); } // for testing watchdog else if (*befbuf == 'S') { trace(fatal, "test", "abort"); } else if (*befbuf == 'V') { *(char *)0 = 1; } else mk_start(befbuf); } break; case batch: { runbatch(befbuf); } break; case rtext: case rtext_: { fileio_text fio; fio.usefile(befbuf); fio.tx(); putf("\032\n"); // CTRL-Z } break; case wtext: { fileio_text fio; fio.usefile(befbuf); fio.rx(); } break; case rbin: case rprg: { fileio_abin fio; fio.usefile(befbuf); fio.tx(); } break; case wbin: case wprg: { fileio_abin fio; fio.usefile(befbuf); fio.rx(); } break; #ifdef FEATURE_YAPP case ryapp: { fileio_yapp fio; fio.usefile(befbuf); fio.tx(); } break; case wyapp: { fileio_yapp fio; fio.usefile(befbuf); fio.rx(); } break; #endif // FEATURE_YAPP #ifdef FEATURE_DIDADIT case rdidadit: { fileio_dida fio; fio.usefile(befbuf); fio.tx(); } break; case wdidadit: { fileio_dida fio; if (! *befbuf) fio.usefile("dummy"); else { if (befbuf[strlen(befbuf) - 1] != '/') strcat(befbuf, "/"); strcat(befbuf, "dummy"); fio.usefile(befbuf); } fio.rx(); } break; #endif // FEATURE_DIDADIT case slr: { scanoptions(befbuf); putlog(TRACEPATH "/" SYSLOGRNAME, befbuf); } break; case clog: { scanoptions(befbuf); putlog(TRACEPATH "/" CMDLOGNAME, befbuf); } break; case tail: { scanoptions(befbuf); befbuf += blkill(befbuf); if (b->optplus&o_f && *befbuf) { int a; FILE *f = s_fopen(befbuf, "lrt"); if (f) { fseek(f, 0, SEEK_END); do { while ((a = fgetc(f)) != EOF) putv(a); wdelay(349); } while (! testabbruch()); s_fclose(f); } } else { fileio_text fio; fio.usefile(befbuf); fio.settail(-2000); fio.tx(); } } break; case begin: { fileio_text fio; fio.usefile(befbuf); fio.settail(2000); fio.tx(); } break; case monitor_: { if (*befbuf) { scanoptions(befbuf); b->continous = 1; monitor(atoi(befbuf), b->optplus); } else putf("Syntax: MONITOR [-iords] <task-id>\n"); } break; case tgrep: { char string[61]; char name[40]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; if (! *befbuf) { putf("Syntax: TGREP [pattern] <fwd-bbs>\n"); break; } befbuf = nexttoken(befbuf, string, 60); if (*befbuf) { sprintf(name, TRACEPATH "/t_%s.bcm", befbuf); grep(name, string, b->optplus); } else { sprintf(name, TRACEPATH "/t_%s.bcm", string); putlog(name, ""); } } break; case grep_: { char string[61]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; befbuf = nexttoken(befbuf, string, 60); grep(befbuf, string, b->optplus); } break; #ifdef _AUTOFWD case afwdlist_: { afwdlist(befbuf); } break; #endif case life_: { if (*befbuf) { strupr(befbuf); char *life = skip(befbuf); int board = finddir(befbuf, b->sysop); if (board > 0) { board -= 1; if (life && *life) { tree[board].lifetime_max = atoi(life); tree[board].lifetime_min = 1; if (tree[board].lifetime_max > 999) tree[board].lifetime_max = 999; if (tree[board].lifetime_max < 1) tree[board].lifetime_max = 1; char *life_min = skip(life); if (life_min && *life_min) { tree[board].lifetime_min = atoi(life_min); if (tree[board].lifetime_min > 999) tree[board].lifetime_min = 999; if (tree[board].lifetime_min < 1) tree[board].lifetime_min = 1; } mbtreesave(); } putf(ms(m_lifetimestat), b->boardfullname, tree[board].lifetime_max, tree[board].lifetime_min); } else putf(ms(m_notfound), befbuf); } else putf("Syntax: LIFETIME <board> <days_maximum> [<days_minimum>]\n" " (with 1 <= days_maximum/days_minimum <= 999)\n\n"); } break; #ifdef _TNC case tnc: { control_tnc(befbuf); } break; #endif case connect_: { termqso(befbuf); } break; case login: { if (mbcallok(befbuf)) { mblogin(befbuf, login_standard, b->uplink); cmdlog("login changed"); putf(ms(m_loginchanged)); } else putf("Syntax: LOGIN <new logincall>\n"); } break; case call_: { if (mbcallok(befbuf)) { mblogin(befbuf, login_silent, b->uplink); b->msg_loadnum--; //Sonst wird falsche Sprache benutzt cmdlog("call changed"); } else putf("Syntax: CALL <new logincall>\n"); } break; case oshell_: { if (t->input == io_file || t->output == io_file) oshell(befbuf, sh_noinput); else oshell(befbuf, m.dosinput ? sh_forceinput : sh_ifmultitask); } break; case reorg: { if (sema_test("purgereorg") == 1) putf(ms(m_purgeallstarted)); else { putf(ms(m_reorginvoked)); fork(P_BACK | P_MAIL, 0, mbreorg, befbuf); } } break; case postfwd_: { putf(ms(m_postfwdinvoked)); fork(P_BACK | P_MAIL, 0, postfwd, "Postfwd"); } break; #ifdef FEATURE_EDITOR case edit: { fork(P_WIND | P_KEYB, 0, editfile, befbuf); } break; case fedit: { fork(P_WIND | P_KEYB, 0, editfile, FWDLISTNAME); } break; case redit: { fork(P_WIND | P_KEYB, 0, editfile, REJECTNAME); } break; #else #ifdef DF3VI_FWD_EDIT case fedit: //wenn kein editor vorhanden remote-editor aufrufen case fwdedit: { fwdlistedit(befbuf); } break; #endif #ifdef DF3VI_REJ_EDIT case redit: case rejectedit: { rejectlistedit(befbuf); } break; #endif #ifdef DF3VI_CONV_EDIT case cedit: case convedit_: { convedit(befbuf); } break; #endif #endif case new_: { scanoptions(befbuf); mbinit(); initfwdlist(); #ifdef _AUTOFWD initafwdlist(); #endif if (! (b->optplus & o_q)) // skip statistics on "new -q" { b->optplus = o_s | o_f | o_c; putf(ms(m_hadrstat)); browse_hadr(""); } mbcvtload(); #ifdef RUNUTILS read_runfile(); #endif msg_dealloc(1); mk_read_jobs(); } break; case kill_: { if (atoi(befbuf)) { while (atoi(befbuf)) { if (! killtask(nextdez(&befbuf), 1)) putf(ms(m_cantkilltask)); } } else putf("Syntax: KILL <task-id>\n"); } break; #ifdef __DOS16__ case w2: { fork(P_WIND | P_KEYB|P_MAIL, 0, mbwin2, m.sysopcall); } break; case uwin: { fork(P_WIND | P_KEYB|P_MAIL, 0, userwin, "Users"); } break; case twin: { fork(P_WIND | P_MAIL, 0, taskwin, befbuf); } break; #ifdef _AUTOTRCWIN case trwin: { if (*befbuf) fork(P_WIND | P_MAIL, 0, trcwin, befbuf); else putf("Syntax: TRWIN [-iords] <task-id>\n"); } break; #endif #endif //__DOS16__ case mkb: { char mainboard[30]; char newboard[20]; char *slash; befbuf = nexttoken(befbuf, mainboard, 29); befbuf = nexttoken(befbuf, newboard, 19); slash = strchr(mainboard + 1, '/'); if (slash && (! *newboard)) { *slash = 0; strcpy(newboard, slash + 1); } if (! *newboard && *mainboard == '/') { strcpy(newboard, mainboard + 1); mainboard[1] = 0; } if (*mainboard && *newboard) { switch (mkboard(mainboard, newboard, 0)) { case 0: putf(ms(m_boardcreated)); break; case 1: putf(ms(m_mainboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 3: putf(ms(m_boardnameexist)); break; case 4: putf(ms(m_invalidboardname)); break; } } else putf("Syntax: MKBOARD <mainboard> <subboard>\n"); } break; case rmb: { if (*befbuf) { subst1(befbuf, ' ', '/'); if (*befbuf == '/' && befbuf[1] == '/') befbuf++; switch (rmboard(befbuf)) { case 0: putf(ms(m_boardremoved)); break; case 1: putf(ms(m_boardnotfound)); break; case 2: putf(ms(m_boardnotempty)); break; } } else putf("Syntax: RMBOARD <mainboard> <subboard>\n"); } break; case mvb: { char oldboard[20]; char subboard[20]; char neuboard[20]; befbuf = nexttoken(befbuf, oldboard, 19); befbuf = nexttoken(befbuf, subboard, 19); befbuf = nexttoken(befbuf, neuboard, 19); if (*oldboard && *subboard && *neuboard) { switch (mvboard(oldboard, subboard, neuboard)) { case 0: putf(ms(m_boardmoved)); break; case 1: putf(ms(m_newboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 4: putf(ms(m_oldboardnotfound)); break; } } else putf("Syntax: MVBOARD <oldboard> <subboard> <newboard>\n"); } break; case shutdown_: { scanoptions(befbuf); #ifdef __DOS16__ if (b->optplus & o_r) atexit((void(*)()) MK_FP(0xffff, 0x0000)); #endif runterfahren = 1; sprintf(shutdown_reason, "shutdown by %s", b->logincall); stopreason = shutdown_reason; } break; case cfgflex_: { if (*befbuf && file_isreg("cfgflex.bcm")) { putf(ms(m_flexstarted)); fork(P_BACK | P_MAIL, 0, cfgflex, befbuf); } else putf("Syntax: CFGFLEX <flexcall> (cfgflex.bcm must exist)\n"); } break; case import: { sysimport(befbuf); } break; case export_: { if (*befbuf) { if ((t->input != io_file || t->output == io_dummy) && t->output != io_file) { char fname[51]; scanoptions(befbuf); befbuf = nexttoken(befbuf, fname, 50); if (b->optplus & o_a) // neue Option -b fuer binaer { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "sab"); else b->outputfile = s_fopen(fname, "sat"); } else { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "swb"); else b->outputfile = s_fopen(fname, "swt"); } if (b->outputfile) { s_fsetopt(b->outputfile, 1); b->oldinput = t->input; b->oldoutput = t->output; t->input = io_dummy; t->output = io_file; b->continous = 1; if (b->optplus & o_u) b->sysop = 0; if (*befbuf) mailbef(befbuf, 0); b->sysop = 1; } else putf(ms(m_filenotopen), fname); } } else putf("Syntax: EXPORT <filename> <box-command>\n"); } break; case beacon: { if (*befbuf) { FILE *f = s_fopen(BEACONNAME, "srt"); unsigned int i = 0; char s[LINELEN+1]; if (f) { while (fgets(s, LINELEN, f)) { if (*s) { s[strlen(s) - 1] = 0; putbeacon_tnc(s, befbuf); i++; } } s_fclose(f); } putf(ms(m_beaconframes), i); } else { fork(P_BACK | P_MAIL, 0, sendmailbake, "Beacon"); putf(ms(m_beaconstarted)); } } break; case pwgen: { FILE *f; if (*befbuf && (f = s_fopen(befbuf, "swt")) != 0) { unsigned int i; int upw; upw = ! stricmp(befbuf, "userpw.bcm"); // file fuer setpw for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if (upw && (i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "%s created", befbuf); s_fclose(f); } else //ohne Parameter immer userpw.bcm erzeugen if (! *befbuf && (f = s_fopen("userpw.bcm", "swt")) != 0) { unsigned int i; for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if ((i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "userpw.bcm created"); s_fclose(f); } } break; case scmdlist: // DH3MB { unsigned int i = 0; while (beftab[i]) putf("(%02d) %s\n", ++i, beftab[i]); } break; #ifdef FEATURE_MDPW case md2sum: { if (! *befbuf) { putf("Syntax: MD2SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD2 md2; md2.readfile(befbuf, 0L); md2.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; case md5sum: { if (! *befbuf) { putf("Syntax: MD5SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD5 md5; md5.readfile(befbuf, 0L); md5.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; #endif #if defined FEATURE_SERIAL || defined _TELEPHONE case ttyinit: { if (eingelogt("getty", 0, 0)) putf(ms(m_ttyactive)); else init_tty(); } break; #endif #ifdef _TELEPHONE // JJ case ttycmd: { if (*befbuf) { if (m.ttydevice > 1) putf_tty("%s\r", befbuf); else putf(ms(m_nomodem)); } else putf("Syntax: TTYCMD <command>\n"); } break; case ttydial: { strupr(befbuf); char *nummer; char call[8]; nummer = nexttoken(befbuf, call, 8); if (*befbuf && mbcallok(call)) { if (m.ttydevice && (get_ufwd(call)[0] || isforwardpartner(call) >= 0)) { putf(ms(m_startphonefwd), call, nummer); sprintf(befbuf, "%s TTY %s", call, nummer); fork(P_BACK | P_MAIL, 0, fwdsend, befbuf); } else putf(ms(m_nottyactive)); } else putf("Syntax: TTYDIAL <call> <number>\n"); } break; case ttyhangup: { tty_hangup(); putf(ms(m_hangupmodem)); } break; case ttystatus: { tty_statustext(); putv(LF); } break; case ttywin_: { fork(P_WIND | P_MAIL, 0, tty_win, befbuf); } break; case ttycounterreset: { tty_counterreset(); putv(LF); } break; #endif #ifdef _FILEFWD case fwdimport: { if (*befbuf) fwd_import(befbuf); } break; case fwdexport: { if (*befbuf) fwd_export(befbuf); } break; #endif case ymbtest: { #ifdef _USERCOMP if (u->comp == 1) { /* char output[256] = { 0 }; char output2[256] = { 0 }; int i, il = 0; */ putf("//COMP 1\n\n"); putflush(); /* il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); // printf("il: %d strlen: %d\n",il,strlen(befbuf)); // printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); //putflush(); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist noch ein laengerer text 2"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist ein noch laengerer text 3"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); putf("\n"); il = decomp_sp_stat_huff(output, strlen(output), output2); printf("il: %d strlen: %d\n",il,strlen(output)); printf("Out2:\n-%s-\n",output2); */ /* #include "ahuf.h" // TOP-Huffman class AHUF; AHUF *ahuf; ahuf = new AHUF(); il = ahuf->Komprimieren(true, befbuf, output, strlen(befbuf) ); printf("il: %d strlen: %d\n",il,strlen(befbuf)); printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); putflush(); putf("%s",output); putflush(); putf("\n"); */ } #endif } break; } return OK;