struct session *parse_input(struct session *ses, char *input) { char *line; push_call("parse_input(%s,%s)",ses->name,input); if (*input == 0) { write_mud(ses, input, SUB_EOL); pop_call(); return ses; } if (VERBATIM(ses)) { line = (char *) malloc(BUFFER_SIZE); strcpy(line, input); if (check_all_aliases(ses, line)) { ses = script_driver(ses, LIST_ALIAS, line); } else { write_mud(ses, line, SUB_EOL); } free(line); pop_call(); return ses; } if (*input == gtd->verbatim_char) { write_mud(ses, input+1, SUB_EOL); pop_call(); return ses; } line = (char *) malloc(BUFFER_SIZE); while (*input) { input = space_out(input); input = get_arg_all(ses, input, line, FALSE); if (parse_command(ses, line)) { ses = script_driver(ses, -1, line); } else if (check_all_aliases(ses, line)) { ses = script_driver(ses, LIST_ALIAS, line); } else if (HAS_BIT(ses->flags, SES_FLAG_SPEEDWALK) && is_speedwalk(ses, line)) { process_speedwalk(ses, line); } else { write_mud(ses, line, SUB_VAR|SUB_FUN|SUB_ESC|SUB_EOL); } if (*input == COMMAND_SEPARATOR) { input++; } } free(line); pop_call(); return ses; }
void parse_input(char *input) { char command[BUFFER_SIZE], arg[BUFFER_SIZE], result[BUFFER_SIZE]; char *input2; bPasswordEcho = TRUE; if(*input=='\0') { write_line_mud(""); return ; } if ( verbatim && *input == cCommandChar && *(input+1) == 'v' ) {// check verbatim command char command[BUFFER_SIZE]; char* input2=get_arg_stop_spaces(input+1, command); if(command[0] == 'v' && is_abrev(command, "verbatim")){ char arg[BUFFER_SIZE]; get_arg_all(input2, arg); verbatim_command(arg); return; } } if (verbatim ) { write_line_mud(input); return ; } if (*input==verbatim_char) { input++; write_line_mud(input); return ; } substitute_myvars(input, result); input2=result; while(*input2) { //* en:colon // if(*input2==';') if(*input2==cCommandDelimiter||(bColon && *input2==';')&&*(input2-1)!='\\') input2++; //*/en input2=get_arg_stop_spaces(input2, command); input2=get_arg_all(input2, arg); //* en:prefix if(s_prefix[0] && command[0] != cCommandChar) { char p_command[BUFFER_SIZE]; strcpy(p_command,command); strcat(p_command," "); strcat(p_command,arg); strcpy(command,s_prefix); strcpy(arg,p_command); } //*/en if(*command==cCommandChar) { if (bDisplayCommands) { // output command in square brackets char strInputCommand[BUFFER_SIZE], strOutputBuffer[BUFFER_SIZE]; strcpy(strInputCommand, "\n["); strcat(strInputCommand, command); if (*arg != '\0') { strcat(strInputCommand, " "); strcat(strInputCommand, arg); } strcat(strInputCommand, "]"); add_codes(strInputCommand, strOutputBuffer, "brown", TRUE); tintin_puts2(strOutputBuffer); if (hLogFile.is_open()) { log(strInputCommand); } } parse_tintin_command(command+1, arg); } //* en:comments else if(*command==cCommentChar); //*/en else { //* en:waits if(iWaitState>0) { char *ptr1,*ptr2; for(ptr1=mQueue;*ptr1&&*ptr1!='\0';ptr1++); *ptr1++=cCommandDelimiter; for(ptr2=command;*ptr2&&*ptr2!='\0';ptr2++,ptr1++) *ptr1=*ptr2; if(*arg) *ptr1++=' '; for(ptr2=arg;*ptr2&&*ptr2!='\0';ptr2++,ptr1++) *ptr1=*ptr2; *ptr1++='\0'; continue; } //* en ALIAS_INDEX ind; if( (ind=AliasList.find(command)) != AliasList.end() && ind->second->m_pGroup->m_bEnabled ) { int i; char *cpsource, *cpsource2, newcommand[BUFFER_SIZE], end; strcpy(vars[0], arg); for(i=1, cpsource=arg; i<10; i++) { /* Next lines CHANGED to allow argument grouping with aliases */ while (*cpsource == ' ') cpsource++; end = (*cpsource == '{') ? '}' : ' '; cpsource = (*cpsource == '{') ? cpsource+1 : cpsource; for(cpsource2=cpsource; *cpsource2 && *cpsource2!=end; cpsource2++); strncpy(vars[i], cpsource, cpsource2-cpsource); *(vars[i]+(cpsource2-cpsource))='\0'; cpsource=(*cpsource2) ? cpsource2+1 : cpsource2; } ALIAS* pal = ind->second; prepare_actionalias((char*)pal->m_strRight.data(), newcommand); if(!strcmp(pal->m_strRight.data(), newcommand) && *arg) { strcat(newcommand, " "); strcat(newcommand, arg); } parse_input(newcommand); } else if(speedwalk && !*arg && is_speedwalk_dirs(command)) do_speedwalk(command); else { get_arg_with_spaces(arg,arg); write_com_arg_mud(command, arg); } } } return; }