Beispiel #1
0
void write_mud(struct session *ses, char *command, int flags)
{
	char output[BUFFER_SIZE];
	int size;

	size = substitute(ses, command, output, flags);

	if (HAS_BIT(ses->flags, SES_FLAG_MAPPING))
	{
		if (ses->map == NULL || ses->map->nofollow == 0)
		{
			check_insert_path(command, ses);
		}
	}

	if (ses->map && ses->map->in_room && ses->map->nofollow == 0)
	{
		if (!HAS_BIT(ses->map->flags, MAP_FLAG_NOFOLLOW))
		{
			if (follow_map(ses, command))
			{
				return;
			}
		}
	}

	write_line_mud(ses, output, size);
}
Beispiel #2
0
void read_file(char *arg)
{
  FILE *myfile;
  char buffer[BUFFER_SIZE], *cptr;
  get_arg_in_braces(arg, arg, WITH_SPACES);

  if ( !arg || !*arg ) {
	  tintin_puts2(rs::rs(1173));
	  return;
  }


  if((myfile=fopen(arg, "r"))==NULL) {
    char buff[MAX_PATH];
    sprintf (buff, rs::rs(1174), arg);
    tintin_puts2(buff);
    return;
  }
  while(fgets(buffer, sizeof(buffer), myfile)) {
    for(cptr=buffer; *cptr && *cptr!='\n'; cptr++);
    *cptr='\0';
    write_line_mud(buffer);
  }
  fclose(myfile);
  tintin_puts2(rs::rs(1175));
}
Beispiel #3
0
void write_line_mud(struct session *ses, char *line, int size)
{
	static int retry;

	push_call("write_line_mud(%p,%p)",line,ses);

	if (ses == gts)
	{
		tintin_printf2(ses, "#NO SESSION ACTIVE. USE: %csession {name} {host} {port} TO START ONE.", gtd->tintin_char);

		pop_call();
		return;
	}

	if (!HAS_BIT(ses->flags, SES_FLAG_CONNECTED))
	{
		tintin_printf2(ses, "#THIS SESSION IS NOT CONNECTED.");

		pop_call();
		return;
	}

	if (write(ses->socket, line, size) == -1)
	{
		if (retry++ < 10)
		{
			usleep(100000);

			write_line_mud(ses, line, size);

			pop_call();
			return;
		}
		perror("write in write_line_mud");

		cleanup_session(ses);

		pop_call();
		return;
	}

	retry = 0;

	check_all_events(ses, SUB_ARG|SUB_SEC, 0, 1, "SEND OUTPUT", line);

	pop_call();
	return;
}
Beispiel #4
0
void write_com_arg_mud(char* command, char* argument)
{
    char outtext[BUFFER_SIZE];
    int i;

    check_insert_path(command);
    strncpy(outtext, command, BUFFER_SIZE);
    if(*argument) {
      strncat(outtext, " ", BUFFER_SIZE-strlen(command)-1); 
      strncat(outtext, argument, BUFFER_SIZE-strlen(command)-2);
    }
    write_line_mud(outtext);
    i=strlen(outtext);
    outtext[i++]='\r';
    outtext[i++]='\n';
}
Beispiel #5
0
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;
}