コード例 #1
0
ファイル: net.c プロジェクト: acceso/gbot
/* measure the length till SEPARATOR, and PEEK that length */
int
botrecv (struct servermsg *msg)
{
	int bytes, offset;
	char data[MSGBUF];
	static unsigned int modes_left = 1;

	/* Receive MSGBUF bytes but PEEKing */
	bytes = recv (msg->server->sock, data, MSGBUF, MSG_PEEK);

	/* The offset till SEPARATOR */
	if (strstr (data, SEPARATOR) != NULL)
		offset = strstr (data, SEPARATOR) - data + SEPARATOR_LEN;
	else
		offset = strchr (data, '\0') - data;

	data[offset] = '\0';

	/* If finished with previous mode changes, check modes for this line */
	if (modes_left <= 1)
		count_multi (data, &modes_left);
	else /* If not, check next */
		modes_left--;

	/* Really receive, but just one line till SEPARATOR */
	if (modes_left <= 1) {
		if ((bytes = recv (msg->server->sock, data, offset, 0)) < 1)
			return bytes;

		/* The separator is kept to mark the end of string */
		data[bytes] = '\0';

		/* Just in case we got an empty line or NULL */
		if (data[0] == '\0')
			return bytes;
	}

	/* If the data received starts with ':' ... */
	if (data[0] == ':') /* Most commands: */
		parse_server (&data[1], msg, modes_left);
	else /* PING, NOTICE, etc. */
		parse_server2 (data, msg);

#ifdef DEBUG_VERBOSE
	DUMP_MSG (msg);
#endif /* DEBUG */


	return bytes;

}
コード例 #2
0
ファイル: mbbsd.c プロジェクト: YanlongLai/Program
static void multi_user_check() {
    register userinfo_t *ui;
    register pid_t pid;
    char genbuf[3];

    if(HAS_PERM(PERM_SYSOP))
	return;		/* don't check sysops */
    
    if(cuser.userlevel) {
	if(!(ui = (userinfo_t *)search_ulist(cmpuids, usernum)))
	    return;	/* user isn't logged in */
	
	pid = ui->pid;
	if(!pid /*|| (kill(pid, 0) == -1)*/)
	    return;	/* stale entry in utmp file */
	
	getdata(b_lines - 1, 0, "您想刪除其他重複的 login (Y/N)嗎?[Y] ",
		genbuf, 3, LCECHO);

	if(genbuf[0] != 'n') {
	    if(pid > 0) kill(pid, SIGHUP);
	    log_usies("KICK ", cuser.username);
	} else {
	    if(count_multi() >= 3)
		system_abort();		/* Goodbye(); */
	}
    } else {
	/* allow multiple guest user */
	if(count_multi() > 32) {
	    outs("\n抱歉,目前已有太多 guest, 請稍後再試。\n");
	    pressanykey();
	    oflush();
	    exit(1);
	}
    }
}
コード例 #3
0
ファイル: mbbsd.c プロジェクト: yrchen/Athena
static void 
multi_user_check()
{
	register user_info *ui;
	register pid_t	pid;
	int		cmpuids    ();

	if (HAS_PERM(PERM_SYSOP))
		return;		/* wildcat:站長不限制 */

	if (cuser.userlevel) {
		if (!(ui = (user_info *) search_ulist(cmpuids, usernum)))
			return;	/* user isn't logged in */

		pid = ui->pid;
		if (!pid || (kill(pid, 0) == -1))
			return;	/* stale entry in utmp file */

		if (getans2(b_lines, 0, "您想刪除其他重複的 login 嗎?", 0, 2, 'y') != 'n') {
			kill(pid, SIGHUP);
			log_usies("KICK ", cuser.username);
		} else {
			int		nums = MULTI_NUMS;
			if (HAS_PERM(PERM_BM))
				nums += 2;
			if (count_multi() >= nums)
				system_abort();
		}
	} else {		/* guest的話 */
		if (count_multi() > 512) {
			pressanykey("抱歉,目前已有太多 guest, 請稍後再試。");
			oflush();
			exit(1);
		}
	}
}