Пример #1
0
void tickoff_command(const char *arg, struct session *ses)
{
    if (ses)
    {
        ses->tickstatus = false;
        tintin_puts("#TICKER IS NOW OFF.", ses);
    }
    else
        tintin_puts("#NO SESSION ACTIVE => NO TICKER!", ses);
}
Пример #2
0
void tick_command(char*arg)
{
    if(bTickStatus) {
      char buf[100];
      sprintf(buf, rs::rs(1176), iSecToTick);
      tintin_puts(buf);
    }
    else
      tintin_puts(rs::rs(1177));
}
Пример #3
0
void tickon_command(const char *arg, struct session *ses)
{
    if (ses)
    {
        ses->tickstatus = true;
        if (ses->time0 == 0)
            ses->time0 = time(NULL);
        tintin_puts("#TICKER IS NOW ON.", ses);
    }
    else
        tintin_puts("#NO SESSION ACTIVE => NO TICKER!", ses);
}
Пример #4
0
void tick_command(const char *arg, struct session *ses)
{
    if (ses)
    {
        char buf[100];
        int to_tick;

        to_tick = ses->tick_size - (time(NULL) - ses->time0) % ses->tick_size;
        sprintf(buf, "THERE'S NOW %d SECONDS TO NEXT TICK.", to_tick);
        tintin_puts(buf, ses);
    }
    else
        tintin_puts("#NO SESSION ACTIVE => NO TICKER!", ses);
}
Пример #5
0
int connect_mud(struct session *ses, char *host, char *port)
{
	int sock, d;
	struct sockaddr_in sockaddr;

	if (sscanf(host, "%d.%d.%d.%d", &d, &d, &d, &d) == 4)
	{
		sockaddr.sin_addr.s_addr = inet_addr(host);
	}
	else
	{
		struct hostent *hp;

		if (!(hp = gethostbyname(host)))
		{
			tintin_puts2(ses, "#ERROR - UNKNOWN HOST.");
			return -1;
		}
		memcpy((char *)&sockaddr.sin_addr, hp->h_addr, sizeof(sockaddr.sin_addr));
	}

	if (is_number(port))
	{
		sockaddr.sin_port = htons(atoi(port));
	}
	else
	{
		tintin_puts(ses, "#THE PORT SHOULD BE A NUMBER.");
		return -1;
	}

	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	{
		syserr("socket");
	}

	sockaddr.sin_family = AF_INET;

	ses->connect_error = connect(sock, (struct sockaddr *)&sockaddr, sizeof(sockaddr));

	if (ses->connect_error)
	{
		close(sock);

		return 0;
	}

	if (fcntl(sock, F_SETFL, O_NDELAY|O_NONBLOCK) == -1)
	{
		perror("connect_mud: fcntl O_NDELAY|O_NONBLOCK");
	}

	RESTRING(ses->ip, inet_ntoa(sockaddr.sin_addr));

	return sock;
}
Пример #6
0
void tick_command(wchar_t*arg)
{
    if(bTickStatus) {
      wchar_t buf[100];
      swprintf(buf, rs::rs(1176), iSecToTick);
      tintin_puts(buf);
    }
    else
      tintin_puts2(rs::rs(1177));
}
Пример #7
0
int connect_mud(struct session *ses, char *host, char *port)
{
	int sock, error;
	struct addrinfo *address;
	static struct addrinfo hints;
	char ip[100];

	if (!is_number(port))
	{
		tintin_puts(ses, "#THE PORT SHOULD BE A NUMBER.");
		return -1;
	}

	hints.ai_family   = AF_UNSPEC;
	hints.ai_protocol = IPPROTO_TCP;
	hints.ai_socktype = SOCK_STREAM;

	error = getaddrinfo(host, port, &hints, &address);

	if (error)
	{
		tintin_printf(ses, "#SESSION '%s' COULD NOT CONNECT - UNKNOWN HOST.", ses->name);
		return -1;
	}

	sock = socket(address->ai_family, address->ai_socktype, address->ai_protocol);

	if (sock < 0)
	{
		syserr("socket");
	}

	ses->connect_error = connect(sock, address->ai_addr, address->ai_addrlen);

	if (ses->connect_error)
	{
		close(sock);
		freeaddrinfo(address);

		return 0;
	}

	if (fcntl(sock, F_SETFL, O_NDELAY|O_NONBLOCK) == -1)
	{
		perror("connect_mud: fcntl O_NDELAY|O_NONBLOCK");
	}

	getnameinfo(address->ai_addr, address->ai_addrlen, ip, 100, NULL, 0, NI_NUMERICHOST);

	RESTRING(ses->ip, ip);

	freeaddrinfo(address);

	return sock;
}
Пример #8
0
void suspend_handler(int signal)
{
	printf("\033[r\033[%d;%dH", gtd->ses->rows, 1);

	fflush(stdout);

	restore_terminal();

	kill(0, SIGSTOP);

	dirty_screen(gtd->ses);

	init_terminal();

	tintin_puts(NULL, "#RETURNING BACK TO TINTIN++.");
}
Пример #9
0
void antisubstitute_command(const char *arg, struct session *ses)
{
    char left[BUFFER_SIZE];
    struct listnode *myantisubs, *ln;

    myantisubs = ses->antisubs;
    arg = get_arg_in_braces(arg, left, 1);

    if (!*left)
    {
        tintin_puts("#THESE ANTISUBSTITUTES HAS BEEN DEFINED:", ses);
        show_list(myantisubs);
    }
    else
    {
        if ((ln = searchnode_list(myantisubs, left)) != NULL)
            deletenode_list(myantisubs, ln);
        insertnode_list(myantisubs, left, left, 0, ALPHA);
        antisubnum++;
        if (ses->mesvar[MSG_SUBSTITUTE])
            tintin_printf(ses, "Ok. Any line with {%s} will not be subbed.", left);
    }
}
Пример #10
0
struct session *new_session(struct session *ses, char *name, char *arg, int desc)
{
	int cnt = 0;
	char host[BUFFER_SIZE], port[BUFFER_SIZE], file[BUFFER_SIZE];
	struct session *newsession;

	push_call("new_session(%p,%p,%p,%d)",ses,name,arg,desc);

	if (HAS_BIT(gtd->flags, TINTIN_FLAG_TERMINATE))
	{
		pop_call();
		return ses;
	}

	arg = sub_arg_in_braces(ses, arg, host, GET_ONE, SUB_VAR|SUB_FUN);
	arg = sub_arg_in_braces(ses, arg, port, GET_ONE, SUB_VAR|SUB_FUN);
	arg = sub_arg_in_braces(ses, arg, file, GET_ONE, SUB_VAR|SUB_FUN);

	if (desc == 0)
	{
		if (*host == 0)
		{
			tintin_puts(ses, "#HEY! SPECIFY AN ADDRESS WILL YOU?");

			pop_call();
			return ses;
		}

		if (*port == 0)
		{
			tintin_puts(ses, "#HEY! SPECIFY A PORT NUMBER WILL YOU?");

			pop_call();
			return ses;
		}
	}

	for (newsession = gts ; newsession ; newsession = newsession->next)
	{
		if (!strcmp(newsession->name, name))
		{
			tintin_puts(ses, "THERE'S A SESSION WITH THAT NAME ALREADY.");

			pop_call();
			return ses;
		}
	}

	newsession                = (struct session *) calloc(1, sizeof(struct session));

	newsession->name          = strdup(name);
	newsession->host          = strdup(host);
	newsession->ip            = strdup("");
	newsession->port          = strdup(port);

	newsession->group         = strdup(gts->group);
	newsession->flags         = gts->flags;
	newsession->telopts       = gts->telopts;
	newsession->auto_tab      = gts->auto_tab;

	newsession->cmd_color     = strdup(gts->cmd_color);

	newsession->read_max      = gts->read_max;
	newsession->read_buf      = (unsigned char *) calloc(1, gts->read_max);

	LINK(newsession, gts->next, gts->prev);

	for (cnt = 0 ; cnt < LIST_MAX ; cnt++)
	{
		newsession->list[cnt] = copy_list(newsession, gts->list[cnt], cnt);
	}

	newsession->rows          = gts->rows;
	newsession->cols          = gts->cols;
	newsession->top_row       = gts->top_row;
	newsession->bot_row       = gts->bot_row;

	init_buffer(newsession, gts->scroll_max);

	if (desc)
	{
		tintin_printf(ses, "#TRYING TO LAUNCH '%s' RUNNING '%s'.", newsession->name, newsession->host);
	}
	else
	{
		tintin_printf(ses, "#TRYING TO CONNECT '%s' TO '%s' PORT '%s'.", newsession->name, newsession->host, newsession->port);
	}

	gtd->ses = newsession;

	dirty_screen(newsession);

	if (desc == 0)
	{
		newsession = connect_session(newsession);
	}
	else
	{
		SET_BIT(newsession->flags, SES_FLAG_CONNECTED|SES_FLAG_RUN);

		SET_BIT(newsession->telopts, TELOPT_FLAG_SGA);
		DEL_BIT(newsession->telopts, TELOPT_FLAG_ECHO);

		gtd->ses = newsession;

		gtd->ses->socket = desc;
	}

	if (newsession)
	{
		if (*file)
		{
			do_read(newsession, file);
		}
	}

	pop_call();
	return gtd->ses;
}
Пример #11
0
void write_line_mud(const wchar_t *line)
{
    int len, OriginalLen;
    char buff[BUFFER_SIZE*8], coded[BUFFER_SIZE*4];
    int ret = 0;

    if ( !MUDSocket ) {
        tintin_puts(rs::rs(1182) );
    } else {
        OriginalLen = len = wcslen(line);

		wcscpy(strLastCommand, line);

		int count;
		if (MudCodePageUsed == 1200) {
			count = len * 2;
			memcpy(coded, line, count);
		} else if (MudCodePageUsed == 1201) {
			count = len * 2;
			utf16le_to_utf16be((wchar_t*)coded, line, len);
		} else {
			count = WideCharToMultiByte(MudCodePageUsed, 0, &line[ret], len, coded, sizeof(coded) - 1, NULL, NULL);
		}
        
		if ( bIACSendSingle ) 
			memcpy (buff, coded, count);
		else {
			char* ptr = buff;
			int nIACs = 0;
			for ( int i = 0; i < count; i ++ ) {
				if ( coded[i] == (char)0xff ) {
					*ptr++ = (char)0xff;
					nIACs ++;
				}
				*ptr++ = coded[i];
			}
			count += nIACs;

		}
		if ( buff[count-1] != 0xA ) {
			buff[count] = 0xA;
			buff[count+1] = 0;
			count ++;
		}

		int sent = tls_send(MUDSocket, buff, count);

		if (sent < 0)
			ret = sent;
		else
			ret = len;
    }

//* en
	wchar_t daaString[BUFFER_SIZE+2];
	int daalen = 0;
	if (bDaaMessage) {
		daaString[daalen++] = L'<';
		for(int i = 0; i < wcslen(line) && i < BUFFER_SIZE; i++)
			daaString[daalen++]=L'*';
		daaString[daalen++] = L'>';
	}
	daaString[daalen] = 0;

    if (bDisplayInput && !(SocketFlags & SOCKECHO) && wcslen(line) > 0) 
	{
        std::wstring str;
		str = USER_INPUT_MARK;
        str += L"\x1B[0;33m";
		str += bDaaMessage ? daaString : line;
        str += L"\x1B[0m";
        tintin_puts2(str.c_str());

		if (hLogFile) {
			log(processLine(bDaaMessage ? daaString : line));
			log(L"\n");
		}
		add_line_to_scrollbuffer(bDaaMessage ? daaString : line);
    }    

//* en
	bDaaMessage = FALSE;
//* /en


#ifdef _DEBUG_LOG
    // --------   Write external log
    if (hExLog ) {
        char exLogText[128];
        DWORD Written;
        swprintf(exLogText , L"\r\n#SEND got %d bytes sent %d bytes#\r\n" , len, ret );
        WriteFile(hExLog , exLogText , wcslen(exLogText) , &Written, NULL);
        WriteFile(hExLog , buff , len , &Written, NULL);
    }
#endif
    if (  ret < 0 ) {
        tintin_puts2(rs::rs(1183) );
    }
}