⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outbound.c

📁 The major functionality added in this release includes: - Rootless mode in X11 - Widget Templt
💻 C
📖 第 1 页 / 共 5 页
字号:
					k = 0;				} else				{					if (isdigit (buf[i]) && k < (sizeof (numb) - 1))					{						numb[k] = buf[i];						k++;					}				}			} else			{norm:			nbuf[j] = buf[i];				j++;			}		}		i++;	}	nbuf[j] = 0;	memcpy (buf, nbuf, j + 1);	free (nbuf);}static gbooleanexec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s){	char *buf, *readpos, *rest;	int rd, len;	int sok = s->myfd;	len = s->buffill;	if (len) {		/* append new data to buffered incomplete line */		buf = malloc(len + 2050);		memcpy(buf, s->linebuf, len);		readpos = buf + len;		free(s->linebuf);		s->linebuf = NULL;	}	else		readpos = buf = malloc(2050);		rd = read (sok, readpos, 2048);	if (rd < 1)	{		/* The process has died */		kill(s->childpid, SIGKILL);		if (len) {			buf[len] = '\0';			exec_handle_colors(buf, len);			if (s->tochannel)				handle_multiline (s->sess, buf, FALSE, TRUE);			else				PrintText (s->sess, buf);		}		free(buf);		waitpid (s->childpid, NULL, 0);		s->sess->running_exec = NULL;		fe_input_remove (s->iotag);		close (sok);		free (s);		return TRUE;	}	len += rd;	buf[len] = '\0';		rest = strrchr(buf, '\n');	if (rest)		rest++;	else		rest = buf;	if (*rest) {		s->buffill = len - (rest - buf); /* = strlen(rest) */		s->linebuf = malloc(s->buffill);		memcpy(s->linebuf, rest, s->buffill);		*rest = '\0';		len -= s->buffill; /* possibly 0 */	}	else		s->buffill = 0;	if (len) {		exec_handle_colors (buf, len);		if (s->tochannel)			handle_multiline (s->sess, buf, FALSE, TRUE);		else			PrintText (s->sess, buf);	}		free(buf);	return TRUE;}intcmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	int tochannel = FALSE;	char *cmd = word_eol[2];	int fds[2], pid = 0;	struct nbexec *s;	if (*cmd)	{		if (access ("/bin/sh", X_OK) != 0)		{			fe_message (_("I need /bin/sh to run!\n"), FALSE);			return TRUE;		}		exec_check_process (sess);		if (sess->running_exec != NULL)		{			EMIT_SIGNAL (XP_TE_ALREADYPROCESS, sess, NULL, NULL, NULL, NULL, 0);			return TRUE;		}		if (!strcmp (word[2], "-o"))		{			if (!*word[3])				return FALSE;			else			{				cmd = word_eol[3];				tochannel = TRUE;			}		}#ifdef __EMX__						  /* if os/2 */		if (pipe (fds) < 0)		{			PrintText (sess, "Pipe create error\n");			return FALSE;		}		setmode (fds[0], O_BINARY);		setmode (fds[1], O_BINARY);#else		if (socketpair (PF_UNIX, SOCK_STREAM, 0, fds) == -1)		{			PrintText (sess, "socketpair(2) failed\n");			return FALSE;		}#endif		s = (struct nbexec *) malloc (sizeof (struct nbexec));		memset(s, 0, sizeof(*s));		s->myfd = fds[0];		s->tochannel = tochannel;		s->sess = sess;		pid = fork ();		if (pid == 0)		{			/* This is the child's context */			close (0);			close (1);			close (2);			/* Close parent's end of pipe */			close(s->myfd);			/* Copy the child end of the pipe to stdout and stderr */			dup2 (fds[1], 1);			dup2 (fds[1], 2);			/* Also copy it to stdin so we can write to it */			dup2 (fds[1], 0);			/* Now we call /bin/sh to run our cmd ; made it more friendly -DC1 */			execl ("/bin/sh", "sh", "-c", cmd, 0);			/* not reached unless error */			/*printf("exec error\n");*/			fflush (stdout);			fflush (stdin);			_exit (0);		}		if (pid == -1)		{			/* Parent context, fork() failed */			PrintText (sess, "Error in fork(2)\n");			close(fds[0]);			close(fds[1]);		} else		{			/* Parent path */			close(fds[1]);			s->childpid = pid;			s->iotag = fe_input_add (s->myfd, 1, 0, 1, exec_data, s);			sess->running_exec = s;			return TRUE;		}	}	return FALSE;}#endifintcmd_quit (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	if (*word_eol[2])		sess->quitreason = word_eol[2];	disconnect_server (sess, TRUE, -1);	sess->quitreason = NULL;	return 2;}intcmd_gate (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	char *server = word[2];	if (*server)	{		char *port = word[3];#ifdef USE_OPENSSL		sess->server->use_ssl = FALSE;#endif		if (*port)			connect_server (sess, server, atoi (port), TRUE);		else			connect_server (sess, server, 23, TRUE);		return TRUE;	}	return FALSE;}static intcmd_help (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	int i = 0, longfmt = 0;	char *helpcmd = "";	if (tbuf)		helpcmd = word[2];	if (*helpcmd && strcmp (helpcmd, "-l") == 0)		longfmt = 1;	if (*helpcmd && !longfmt)	{		help (sess, helpcmd, FALSE);	} else	{		struct popup *pop;		GSList *list = command_list;		char *buf = malloc (4096);		int t = 1, j;		strcpy (buf, _("\nCommands Available:\n\n  "));		if (longfmt)		{			while (1)			{				if (!xc_cmds[i].name)					break;				if (!xc_cmds[i].help || *xc_cmds[i].help == '\0')					snprintf (buf, 4096, "   \0034%s\003 :\n", xc_cmds[i].name);				else					snprintf (buf, 4096, "   \0034%s\003 : %s", xc_cmds[i].name,								 _(xc_cmds[i].help));				PrintText (sess, buf);				i++;			}			buf[0] = 0;		} else		{			while (1)			{				if (!xc_cmds[i].name)					break;				strcat (buf, xc_cmds[i].name);				t++;				if (t == 6)				{					t = 1;					strcat (buf, "\n  ");				} else					for (j = 0; j < (10 - strlen (xc_cmds[i].name)); j++)						strcat (buf, " ");				i++;			}		}		strcat (buf,				  _("\n\nType /HELP <command> for more information, or /HELP -l\n\n"));		strcat (buf, _("User defined commands:\n\n  "));		t = 1;		while (list)		{			pop = (struct popup *) list->data;			strcat (buf, pop->name);			t++;			if (t == 6)			{				t = 1;				strcat (buf, "\n");				PrintText (sess, buf);				strcpy (buf, "  ");			} else			{				if (strlen (pop->name) < 10)				{					for (j = 0; j < (10 - strlen (pop->name)); j++)						strcat (buf, " ");				}			}			list = list->next;		}		strcat (buf, "\n");		PrintText (sess, buf);		free (buf);	}	return TRUE;}intcmd_ignore (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	int i;	int priv = 0;	int noti = 0;	int chan = 0;	int ctcp = 0;	int invi = 0;	int unignore = 0;	int quiet = 0;	int no_save = 0;	if (!*word[2])	{		ignore_showlist (sess);		return TRUE;	}	if (!*word[3])		return FALSE;	i = 3;	while (1)	{		if (!*word[i])		{			if (!priv && !noti && !chan && !ctcp && !invi && !unignore)				return FALSE;			i =				ignore_add (word[2], priv, noti, chan, ctcp, invi, unignore,								no_save);			if (!quiet)			{				if (i == 1)					EMIT_SIGNAL (XP_TE_IGNOREADD, sess, word[2], NULL, NULL, NULL,									 0);				if (i == 2)			  /* old ignore changed */					EMIT_SIGNAL (XP_TE_IGNORECHANGE, sess, word[2], NULL, NULL,									 NULL, 0);			}			return TRUE;		}		if (!strcasecmp (word[i], "UNIGNORE"))			unignore = 1;		else if (!strcasecmp (word[i], "ALL"))			priv = noti = chan = ctcp = invi = 1;		else if (!strcasecmp (word[i], "PRIV"))			priv = 1;		else if (!strcasecmp (word[i], "NOTI"))			noti = 1;		else if (!strcasecmp (word[i], "CHAN"))			chan = 1;		else if (!strcasecmp (word[i], "CTCP"))			ctcp = 1;		else if (!strcasecmp (word[i], "INVI"))			invi = 1;		else if (!strcasecmp (word[i], "QUIET"))			quiet = 1;		else if (!strcasecmp (word[i], "NOSAVE"))			no_save = 1;		else		{			sprintf (tbuf, _("Unknown arg '%s' ignored."), word[i]);			PrintText (sess, tbuf);		}		i++;	}}intcmd_invite (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	if (!*word[2])		return FALSE;	if (*word[3])		sprintf (tbuf, "INVITE %s %s\r\n", word[2], word[3]);	else		sprintf (tbuf, "INVITE %s %s\r\n", word[2], sess->channel);	tcp_send (sess->server, tbuf);	return TRUE;}intcmd_join (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	char *chan = word[2];	if (*chan)	{		char *po, *pass = word[3];		if (*pass)			sprintf (tbuf, "JOIN %s %s\r\n", chan, pass);		else			sprintf (tbuf, "JOIN %s\r\n", chan);		tcp_send (sess->server, tbuf);		if (sess->channel[0] == 0 && !prefs.persist_chans)		{			po = strchr (chan, ',');			if (po)				*po = 0;			safe_strcpy (sess->waitchannel, chan, CHANLEN);		}		return TRUE;	}	return FALSE;}intcmd_kick (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	char *nick = word[2];	char *reason = word_eol[3];	if (*nick)	{		if (*reason)			sprintf (tbuf, "KICK %s %s :%s\r\n", sess->channel, nick, reason);		else			sprintf (tbuf, "KICK %s %s\r\n", sess->channel, nick);		tcp_send (sess->server, tbuf);		return TRUE;	}	return FALSE;}intcmd_kickban (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	char *nick = word[2];	char *reason = word_eol[3];	struct User *user;	if (*nick)	{		/* if the reason is a 1 digit number, treat it as a bantype */		user = find_name (sess, nick);		if (isdigit (reason[0]) && reason[1] == 0)		{			ban (sess, tbuf, nick, reason, (user && user->op));			reason[0] = 0;		} else			ban (sess, tbuf, nick, "", (user && user->op));		if (*reason)			sprintf (tbuf, "KICK %s %s :%s\r\n", sess->channel, nick, reason);		else			sprintf (tbuf, "KICK %s %s\r\n", sess->channel, nick);		tcp_send (sess->server, tbuf);		return TRUE;	}	return FALSE;}intcmd_lagcheck (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	lag_check ();	return TRUE;}static voidlastlog (session *sess, char *search){	session *lastlog_sess;	if (!is_session (sess))		return;	lastlog_sess = find_dialog (sess->server, "(lastlog)");	if (!lastlog_sess)	{		lastlog_sess = new_ircwindow (sess->server, "(lastlog)", SESS_DIALOG);		lastlog_sess->lastlog_sess = sess;	}	fe_text_clear (lastlog_sess);	fe_lastlog (sess, lastlog_sess, search);}intcmd_lastlog (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	if (*word_eol[2])	{		lastlog (sess, word_eol[2]);		return TRUE;	}	return FALSE;}intcmd_list (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	if (*word_eol[2])	{		sprintf (tbuf, "LIST %s\r\n", word_eol[2]);		tcp_send (sess->server, tbuf);	} else	{		if (sess->server->is_newtype)			tcp_send (sess->server, "LIST >0,<10000\r\n");		else			tcp_send (sess->server, "LIST\r\n");	}	return TRUE;}intcmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	FILE *fp;	char *nl;	char *file;#ifdef USE_PERL	int i;#endif	if (strcmp (word[2], "-e") == 0)	{		file = expand_homedir (word[3]);		fp = fopen (file, "r");		free (file);		if (fp)		{			tbuf[1024] = 0;			while (fgets (tbuf, 1024, fp))			{				nl = strchr (tbuf, '\n');				if (nl)					*nl = 0;				handle_command (tbuf, sess, FALSE, FALSE);			}			fclose (fp);		}		return TRUE;	}#ifdef USE_PERL	file = expand_homedir (word[2]);	i = perl_load_file (file);	free (file);	switch (i)	{	case 0:		return TRUE;	case 1:		PrintText (sess, _("Error compiling script\n"));		return FALSE;	case 2:		PrintText (sess, _("Error Loading file\n"));		return FALSE;	}	return FALSE;#else	PrintText (sess, _("Perl scripting not available in this compilation.\n"));	return TRUE;#endif}#ifdef USE_PLUGINintcmd_loaddll (struct session *sess, char *tbuf, char *word[], char *word_eol[]){	char *file;	int i;	file = expand_homedir (word[2]);	i = module_load (file, sess);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -