?? misc.c
字號:
/* Autoconf patching by David Hedbor, neotron@lysator.liu.se *//*********************************************************************//* file: misc.c - misc commands *//* TINTIN III *//* (T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t *//* coded by peter unold 1992 *//*********************************************************************//* note: a bunch of changes were made for readline support -- daw */#ifdef HAVE_STRING_H#include <string.h>#else#ifdef HAVE_STRINGS_H#include <strings.h>#endif#endif#include <ctype.h>#include "tintin.h"#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif/* externs */extern struct session *newactive_session();extern struct listnode *common_aliases, *common_functions, *common_actions, *common_subs, *common_myvars;extern struct listnode *common_highs, *common_antisubs, *common_pathdirs;extern char *get_arg_in_braces();/* extern void term_echo(); */extern int redraw, is_split;extern struct session *sessionlist;extern struct completenode *complete_head;extern char tintin_char;extern int echo;extern int speedwalk;extern int presub;extern int togglesubs;extern char vars[10][BUFFER_SIZE]; /* the %0, %1, %2,....%9 variables */extern int mesvar[7];extern int verbatim;int nRnd(int nMin,int nMax){ int temp; if (nMin>nMax) {temp=nMax;nMax=nMin;nMin=temp; } return (rand() % (nMax - nMin + 1)) + nMin;}/***********************//* the #random command *//*****************************************//* Syntax: #random {<var>} ( {from,to} ) *//*****************************************/void random_command(arg, ses) char *arg; struct session *ses;{ char left[BUFFER_SIZE],right[BUFFER_SIZE], temp[BUFFER_SIZE]; int nr1,nr2,tmp,result; arg=get_arg_in_braces(arg,left,0); if (*left) { arg=get_arg_in_braces(arg,right,1); substitute_vars(left,temp); substitute_myvars(temp,left,ses); substitute_vars(right,temp); substitute_myvars(temp,right,ses); if (!*right) { /* No number arguments were given to #random */ result=nRnd(0,100); } else { /* Number arguments were given to #random */ if (sscanf(right,"%d,%d",&nr1,&nr2)!=2) { tintin_puts2("#Wrong number of arguments in #random",ses); result=0; } else { result=nRnd(nr1,nr2); } } sprintf(temp,"{%s} {%d}",left,result); var_command(temp,ses); } else { tintin_puts2("#Syntax: #random {<var>} ( {from,to} )",ses); }}/***********************//* the isdigit command *//**************************************************************//* Syntax: #ifdigit {digit?} {do this} else {do this instead} *//**************************************************************/void ifdigit_command(arg, ses) char *arg; struct session *ses;{ char left[BUFFER_SIZE], right[BUFFER_SIZE], elsebuf[BUFFER_SIZE], temp[BUFFER_SIZE]; arg=get_arg_in_braces(arg, left, 0); arg=get_arg_in_braces(arg, right, 1); if (!*left || !*right) { tintin_puts2("#Syntax: #ifdigit {digit?} {do this} else {do this instead}",ses); } else { substitute_vars(left,temp); substitute_myvars(temp,left,ses); if (isdigit(*left)) { /* Yup, it's a digit */ substitute_vars(right,temp); substitute_myvars(temp,right,ses); parse_input(right, ses); } else { /* Nope, that's no digit; check for else */ arg = (char *) get_arg_stop_spaces(arg, elsebuf); if (*elsebuf && strcmp(elsebuf, "else") == 0) { arg = get_arg_in_braces(arg, elsebuf, 1); substitute_vars(elsebuf, temp); substitute_myvars(temp, elsebuf, ses); parse_input(elsebuf, ses); } } }}/****************************//* the cr command *//****************************/void cr_command(ses) struct session *ses;{ if (ses != NULL) write_line_mud("\n", ses);}/****************************//* the version command *//****************************/void version_command(){ char temp[80]; sprintf(temp,"#You are using TINTIN++ %s\n\r", VERSION_NUM); tintin_puts2(temp, NULL); prompt(NULL);} /****************************//* the verbatim command, *//* used as a toggle *//****************************/void verbatim_command(){ verbatim=!verbatim; if (verbatim) tintin_puts2("#All text is now sent 'as is'.", (struct sesssion *)NULL); else tintin_puts2("#Text is no longer sent 'as is'.", (struct session *)NULL); prompt(NULL);}/*******************//* the #do command *//*******************/void do_command(arg, ses) char *arg; struct session *ses;{ get_arg_in_braces(arg,arg,1); parse_input(arg,ses);}/********************//* the #all command *//********************/struct session *all_command(arg, ses) char *arg; struct session *ses;{ struct session *sesptr; if(sessionlist) { get_arg_in_braces(arg, arg, 1); for(sesptr=sessionlist; sesptr; sesptr=sesptr->next) parse_input(arg, sesptr); } else tintin_puts("BUT THERE ISN'T ANY SESSION AT ALL!", ses); return ses;}void redraw_command(){ redraw=!redraw; if (redraw) tintin_puts2("#Ok. I now redraw input line when text arrives.", (struct session *)NULL); else tintin_puts2("#Ok. I no longer redraw the input line.", (struct session *)NULL); prompt(NULL);}/*********************//* the #bell command *//*********************/void bell_command(ses) struct session *ses;{ char temp[2]; temp[0]=7; temp[1]=0; write(1, temp, 2);}/*********************//* the #boss command *//*********************/void boss_command(ses) struct session *ses;{ char temp[80]; int i; for(i=0; i<50; i++) { sprintf(temp, "in-order traverse of tree starting from node %d resulted in %d red nodes\n", i, 50-i); tintin_puts2(temp, (struct session *)NULL); } getchar(); /* stop screen from scrolling stuff */}/*********************//* the #char command *//*********************/void char_command(arg, ses) char *arg; struct session *ses;{ char strng[80]; get_arg_in_braces(arg, arg,1); if(ispunct(*arg)) { tintin_char= *arg; sprintf(strng, "#OK. TINTIN-CHAR is now {%c}\n", tintin_char); tintin_puts2(strng, (struct session *)NULL); } else tintin_puts2("#SPECIFY A PROPER TINTIN-CHAR! SOMETHING LIKE # OR /!", (struct session *)NULL);}/*********************//* the #echo command *//*********************/void echo_command(ses) struct session *ses;{ echo=!echo; if(echo) tintin_puts("#ECHO IS NOW ON.", ses); else tintin_puts("#ECHO IS NOW OFF.", ses);}/*********************//* the #end command *//*********************/void end_command(command, ses) char *command; struct session *ses;{ if(strcmp(command, "end")) tintin_puts("#YOU HAVE TO WRITE #end - NO LESS, TO END!", ses); else { quitmsg(NULL); /* changed for readline struct session *sesptr; for(sesptr=sessionlist; sesptr; sesptr=sesptr->next) cleanup_session(sesptr); ses=NULL; if (is_split) write(1, "c", 3); tintin_puts2("TINTIN suffers from bloodlack, and the lack of a beating heart...", ses); tintin_puts2("TINTIN is dead! R.I.P.", ses); tintin_puts2("Your blood freezes as you hear TINTIN's death cry.", ses); term_echo(); exit(0); */ }}/***********************//* the #ignore command *//***********************/void ignore_command(ses) struct session *ses;{ if (ses) { if(ses->ignore=!ses->ignore) tintin_puts("#ACTIONS ARE IGNORED FROM NOW ON.", ses);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -