コード例 #1
0
ファイル: plugin-tray.c プロジェクト: amalmurali47/hexchat
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
#if 0
	const char *argv[8];
	const char *path;
	char time[16];
#endif
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if ((prefs.hex_away_omit_alerts && hexchat_get_info(ph, "away")) ||
		(prefs.hex_gui_focus_omitalerts && ws == WS_FOCUSED))
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet)
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef USE_LIBNOTIFY
	NotifyNotification *notification;
	char *notify_text, *notify_title;

	if (!notify_is_initted())
		notify_init(PACKAGE_NAME);

	notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	notify_title = strip_color (title, -1, STRIP_ALL);

	notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/icons/hicolor/scalable/apps/hexchat.svg", NULL);

#if NOTIFY_CHECK_VERSION(0,7,0)
	notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat"));
#endif

	g_free ((char *)notify_title);
	g_free ((char *)notify_text);

	notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000);
	notify_notification_show (notification, NULL);

	g_object_unref (notification);
#endif
#endif
}
コード例 #2
0
ファイル: plugin-tray.c プロジェクト: Babl0lka/XChat
static gboolean
libnotify_notify_new (const char *title, const char *text, GtkStatusIcon *icon)
{
	void *noti;

	if (!nn_mod)
	{
		nn_mod = g_module_open ("libnotify", G_MODULE_BIND_LAZY);
		if (!nn_mod)
		{
			nn_mod = g_module_open ("libnotify.so.1", G_MODULE_BIND_LAZY);
			if (!nn_mod)
				return FALSE;
		}

		if (!g_module_symbol (nn_mod, "notify_init", (gpointer)&nn_init))
			goto bad;
		if (!g_module_symbol (nn_mod, "notify_uninit", (gpointer)&nn_uninit))
			goto bad;
		if (!g_module_symbol (nn_mod, "notify_notification_new_with_status_icon", (gpointer)&nn_new_with_status_icon))
			goto bad;
		if (!g_module_symbol (nn_mod, "notify_notification_new", (gpointer)&nn_new))
			goto bad;
		if (!g_module_symbol (nn_mod, "notify_notification_show", (gpointer)&nn_show))
			goto bad;
		if (!g_module_symbol (nn_mod, "notify_notification_set_timeout", (gpointer)&nn_set_timeout))
			goto bad;
		if (!nn_init (PACKAGE_NAME))
			goto bad;
	}

	text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	title = strip_color (title, -1, STRIP_ALL);
	noti = nn_new (title, text, XCHATSHAREDIR"/pixmaps/xchat.png", NULL);
	g_free ((char *)title);
	g_free ((char *)text);

	nn_set_timeout (noti, prefs.input_balloon_time*1000);
	nn_show (noti, NULL);
	g_object_unref (G_OBJECT (noti));

	return TRUE;

bad:
	g_module_close (nn_mod);
	nn_mod = NULL;
	return FALSE;
}
コード例 #3
0
int cmd_whack(string str) {
  object tp = this_player();
  object env = environment(tp);
  object tgt, wep;
  object *weps;
  string wepname;

  if (!abil()) return 0;

  if (str)
    tgt = present(str, env);
  else
    tgt = tp->query_current_attacker();

  weps = filter(tp->query_wielded(), (: $1->query_type() == "blunt" :) );

  if (!can_cast(tp, tgt, weps)) return 0;

  wep = weps[random(sizeof(weps))];
  wepname = remove_article(strip_color(wep->query_short()));
  wepname = replace_string(wepname, " (wielded)", "");

  message("combat", "You spin your "+wepname+" around.", tp);
  message("combat", tp->query_cap_name()+" spins "+tp->query_possessive()+
    " "+wepname+" around.", env, tp);

  tp->set_disable(2);

  call_out("do_whack_hit", 2, ({ tp, env, tgt, wep, wepname }) );
コード例 #4
0
ファイル: tray.c プロジェクト: arinity/gchat2
void
fe_tray_set_balloon(const char *title, const char *text)
{
#ifndef _WIN32
	char *stext;
	WinStatus ws;
	NotifyNotification *n;

	/* no balloons if the window is focused */
	ws = tray_get_window_status();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2))
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

	stext = strip_color(text, -1, STRIP_ALL);
	n = notify_notification_new(title, stext, NULL);
    notify_notification_set_icon_from_pixbuf(n, ICON_NORMAL);
	notify_notification_set_timeout(n, 20000);
	notify_notification_show(n, NULL);

	free(stext);
	g_object_unref(G_OBJECT(n));
#endif
}
コード例 #5
0
ファイル: inbound.c プロジェクト: TheWug/hexchat
static int
is_hilight (char *from, char *text, session *sess, server *serv)
{
	if (alert_match_word (from, prefs.hex_irc_no_hilight))
		return 0;

	text = strip_color (text, -1, STRIP_ALL);

	if (alert_match_text (text, serv->nick) ||
		 alert_match_text (text, prefs.hex_irc_extra_hilight) ||
		 alert_match_word (from, prefs.hex_irc_nick_hilight))
	{
		g_free (text);
		if (sess != current_tab)
		{
			sess->nick_said = TRUE;
			lastact_update (sess);
		}
		fe_set_hilight (sess);
		return 1;
	}

	g_free (text);
	return 0;
}
コード例 #6
0
ファイル: text.cpp プロジェクト: wowzaman12/libPChat
void scrollback_load(session *sess)
{
	int fh;
	char buf[512 * 4];
	char *text;
	time_t stamp;
	int lines;

	if (sess->text_scrollback == SET_DEFAULT)
	{
		if (!prefs.text_replay)
			return;
	}
	else
	{
		if (sess->text_scrollback != SET_ON)
			return;
	}

	if (scrollback_get_filename(sess, buf, sizeof(buf)) == nullptr)
		return;

	fh = open(buf, O_RDONLY | OFLAGS);
	if (fh == -1)
		return;

	
	lines = 0;
	while (waitline(fh, buf, sizeof buf, FALSE) != -1)
	{
		if (buf[0] == 'T')
		{
			if (sizeof(time_t) == 4)
				stamp = strtoul(buf + 2, nullptr, 10);
			else
				stamp = strtoull(buf + 2, nullptr, 10); // just incase time_t is 64 bits
			text = strchr(buf + 3, ' ');
			if (text)
			{
				text = strip_color(text + 1, -1, STRIP_COLOR);
				fe_print_text(sess, text, stamp);
				g_free(text);
			}
			lines++;
		}
	}

	sess->scrollwritten = lines;

	if (lines)
	{
		text = ctime(&stamp);
		text[24] = 0;	// get rid of the \n
		snprintf(buf, sizeof(buf), "\n*\t%s %s\n\n", _("Loaded log from"), text);
		fe_print_text(sess, buf, 0);
		//EMIT_SIGNAL(XP_TE_GENMSG, sess, "*", buf, nullptr, nullptr, nullptr, 0);
	}

	close(fh);
}
コード例 #7
0
ファイル: plugin-tray.c プロジェクト: Babl0lka/XChat
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
	const char *argv[8];
	const char *path;
	char time[16];
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2))
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef LIBNOTIFY
	/* try it via libnotify.so */
	if (libnotify_notify_new (title, text, sticon))
		return;	/* success */
#endif

	/* try it the crude way */
	path = g_find_program_in_path ("notify-send");
	if (path)
	{
		sprintf(time, "%d000",prefs.input_balloon_time);
		argv[0] = path;
		argv[1] = "-i";
		argv[2] = "gtk-dialog-info";
		if (access (XCHATSHAREDIR"/pixmaps/xchat.png", R_OK) == 0)
			argv[2] = XCHATSHAREDIR"/pixmaps/xchat.png";
		argv[3] = "-t";
		argv[4] = time;
		argv[5] = title;
		text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
		argv[6] = text;
		argv[7] = NULL;
		xchat_execv (argv);
		g_free ((char *)path);
		g_free ((char *)text);
	}
	else
	{
		/* show this error only once */
		static unsigned char said_it = FALSE;
		if (!said_it)
		{
			said_it = TRUE;
			fe_message (_("Cannot find 'notify-send' to open balloon alerts.\nPlease install libnotify."), FE_MSG_ERROR);
		}
	}
#endif
}
コード例 #8
0
ファイル: m_part.c プロジェクト: KSoute/oftc-hybrid
/* part_one_client()
 *
 * inputs	- pointer to server
 * 		- pointer to source client to remove
 *		- char pointer of name of channel to remove from
 * output	- none
 * side effects	- remove ONE client given the channel name 
 */
static void
part_one_client(struct Client *client_p, struct Client *source_p,
                const char *name, char *reason)
{
  struct Channel *chptr = NULL;
  struct Membership *ms = NULL;

  if ((chptr = hash_find_channel(name)) == NULL)
  {
    sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
               me.name, source_p->name, name);
    return;
  }

  if ((ms = find_channel_link(source_p, chptr)) == NULL)
  {
    sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
               me.name, source_p->name, name);
    return;
  }

  if (MyConnect(source_p) && !IsOper(source_p))
    check_spambot_warning(source_p, NULL);

  /*
   *  Remove user from the old channel (if any)
   *  only allow /part reasons in -m chans
   */
  if(msg_has_colors(reason) && (chptr->mode.mode & MODE_NOCOLOR)) 
    reason = strip_color(reason); 
  
  if (reason[0] && (!MyConnect(source_p) ||
      ((can_send(chptr, source_p, ms) &&
       (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
        < CurrentTime))))
  {
    sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                  ":%s PART %s :%s", ID(source_p), chptr->chname,
                  reason);
    sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
                  ":%s PART %s :%s", source_p->name, chptr->chname,
                  reason);
    sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s :%s",
                         source_p->name, source_p->username,
                         source_p->host, chptr->chname, reason);
  }
  else
  {
    sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                  ":%s PART %s", ID(source_p), chptr->chname);
    sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
                  ":%s PART %s", source_p->name, chptr->chname);
    sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s",
                         source_p->name, source_p->username,
                         source_p->host, chptr->chname);
  }

  remove_user_from_channel(ms);
}
コード例 #9
0
ファイル: plugin-tray.c プロジェクト: aperson/hexchat
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
#if 0
	const char *argv[8];
	const char *path;
	char time[16];
#endif
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet)
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef USE_LIBNOTIFY
	NotifyNotification *notification;
	char *notify_text, *notify_title;

	if (!notify_is_initted())
		notify_init(PACKAGE_NAME);

	notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	notify_title = strip_color (title, -1, STRIP_ALL);

	notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/pixmaps/hexchat.png", NULL);

	g_free ((char *)notify_title);
	g_free ((char *)notify_text);

	notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000);
	notify_notification_show (notification, NULL);

	g_object_unref (notification);
#endif
#endif
}
コード例 #10
0
ファイル: fe-gnome.c プロジェクト: GNOME/xchat-gnome
void
fe_add_chan_list (struct server *serv, char *chan, char *users, char *topic)
{
    char *clean_topic;

    clean_topic = strip_color (topic, -1, STRIP_ALL);
    channel_list_append (serv, chan, users, clean_topic);
    free (clean_topic);
}
コード例 #11
0
ファイル: text.c プロジェクト: TheWug/hexchat
static void
log_write (session *sess, char *text, time_t ts)
{
	char *temp;
	char *stamp;
	char *file;
	int len;

	if (sess->text_logging == SET_DEFAULT)
	{
		if (!prefs.hex_irc_logging)
			return;
	}
	else
	{
		if (sess->text_logging != SET_ON)
			return;
	}

	if (sess->logfd == -1)
		log_open (sess);

	/* change to a different log file? */
	file = log_create_pathname (sess->server->servername, sess->channel,
										 server_get_network (sess->server, FALSE));
	if (file)
	{
		if (g_access (file, F_OK) != 0)
		{
			close (sess->logfd);
			sess->logfd = log_open_file (sess->server->servername, sess->channel,
												  server_get_network (sess->server, FALSE));
		}
		g_free (file);
	}

	if (prefs.hex_stamp_log)
	{
		if (!ts) ts = time(0);
		len = get_stamp_str (prefs.hex_stamp_log_format, ts, &stamp);
		if (len)
		{
			write (sess->logfd, stamp, len);
			g_free (stamp);
		}
	}
	temp = strip_color (text, -1, STRIP_ALL);
	len = strlen (temp);
	write (sess->logfd, temp, len);
	/* lots of scripts/plugins print without a \n at the end */
	if (temp[len - 1] != '\n')
		write (sess->logfd, "\n", 1);	/* emulate what xtext would display */
	g_free (temp);
}
コード例 #12
0
ファイル: inbound.c プロジェクト: BackupTheBerlios/vertigo
void
inbound_topicnew (server *serv, char *nick, char *chan, char *topic)
{
	session *sess;
	char *new_topic;

	sess = find_channel (serv, chan);
	if (sess)
	{
		new_topic = strip_color (topic);
		set_topic (sess, new_topic);
		free (new_topic);
		EMIT_SIGNAL (XP_TE_NEWTOPIC, sess, nick, topic, chan, NULL, 0);
	}
}
コード例 #13
0
ファイル: inbound.c プロジェクト: ArchUser/hexchat
void
inbound_topicnew (server *serv, char *nick, char *chan, char *topic)
{
	session *sess;
	char *stripped_topic;

	sess = find_channel (serv, chan);
	if (sess)
	{
		EMIT_SIGNAL (XP_TE_NEWTOPIC, sess, nick, topic, chan, NULL, 0);
		stripped_topic = strip_color (topic, -1, STRIP_ALL);
		set_topic (sess, topic, stripped_topic);
		g_free (stripped_topic);
	}
}
コード例 #14
0
ファイル: inbound.c プロジェクト: TheWug/hexchat
void
inbound_topicnew (server *serv, char *nick, char *chan, char *topic,
						const message_tags_data *tags_data)
{
	session *sess;
	char *stripped_topic;

	sess = find_channel (serv, chan);
	if (sess)
	{
		EMIT_SIGNAL_TIMESTAMP (XP_TE_NEWTOPIC, sess, tags_data->timestamp, nick, topic, chan);
		stripped_topic = strip_color (topic, -1, STRIP_ALL);
		set_topic (sess, topic, stripped_topic);
		g_free (stripped_topic);
	}
}
コード例 #15
0
ファイル: inbound.c プロジェクト: ArchUser/hexchat
void
inbound_topic (server *serv, char *chan, char *topic_text)
{
	session *sess = find_channel (serv, chan);
	char *stripped_topic;

	if (sess)
	{
		stripped_topic = strip_color (topic_text, -1, STRIP_ALL);
		set_topic (sess, topic_text, stripped_topic);
		g_free (stripped_topic);
	} else
		sess = serv->server_session;

	EMIT_SIGNAL (XP_TE_TOPIC, sess, chan, topic_text, NULL, NULL, 0);
}
コード例 #16
0
ファイル: inbound.c プロジェクト: BackupTheBerlios/vertigo
void
inbound_topic (server *serv, char *chan, char *topic_text)
{
	session *sess = find_channel (serv, chan);
	char *new_topic;

	if (sess)
	{
		new_topic = strip_color (topic_text);
		set_topic (sess, new_topic);
		free (new_topic);
	} else
		sess = serv->server_session;

	EMIT_SIGNAL (XP_TE_TOPIC, sess, chan, topic_text, NULL, NULL, 0);
}
コード例 #17
0
ファイル: arrange_string.c プロジェクト: ehershey/pd
string arrange_string(string str, int x) {
  int actuallen, vislen, codelen;
  string code = "%^";

  if(!str || str == "" || !intp(x) || x < 1)
    return "";

  if(intp(str)) 
    str = str+"";
  
  actuallen = strlen(str);
  vislen = strlen(strip_color(str));
  codelen = actuallen - vislen;
  if (codelen < 0) codelen=0; // should be impossible, but just in case

  // shrinking a string...
  if (vislen > x) {
    // shrinking a string with no color
    if (!codelen)
      str = str[0..x-1];
    // shrinking a string that has color, might be slow due to explode/implode
    else {
      string *tmp;
      int i, count, flag;

      tmp = explode(str, code);

      if (str[0..sizeof(code)-1] == code) flag=0;
      else flag=1;

      for (i = 0, count=0; i < sizeof(tmp) && count < x; i++) {
        if (i%2 != flag)
          count += sizeof(tmp[i]);
      }

      i--;

      if (i%2 != flag)
        tmp[i] = tmp[i][0..<(count-x+1)];
      else
        tmp[i] = tmp[i] + code;

      str = implode(tmp[0..i], code);
      if (flag == 0)
        str = code + str;
      
    }
コード例 #18
0
ファイル: inbound.c プロジェクト: TheWug/hexchat
void
inbound_topic (server *serv, char *chan, char *topic_text,
					const message_tags_data *tags_data)
{
	session *sess = find_channel (serv, chan);
	char *stripped_topic;

	if (sess)
	{
		stripped_topic = strip_color (topic_text, -1, STRIP_ALL);
		set_topic (sess, topic_text, stripped_topic);
		g_free (stripped_topic);
	} else
		sess = serv->server_session;

	EMIT_SIGNAL_TIMESTAMP (XP_TE_TOPIC, sess, tags_data->timestamp, chan, topic_text);
}
コード例 #19
0
ファイル: inbound.c プロジェクト: arinity/gchat
void
inbound_topic (server * serv, char *chan, char *topic_text)
{
    session *sess = find_channel (serv, chan);

    if (sess)
    {
        if (!prefs.topic_color)
            set_topic(sess, topic_text, strip_color(topic_text, -1, STRIP_ALL));
        else
            set_topic(sess, topic_text, topic_text);
    }
    else
        sess = serv->server_session;

    EMIT_SIGNAL (XP_TE_TOPIC, sess, chan, topic_text, NULL, NULL, 0);
}
コード例 #20
0
ファイル: email.c プロジェクト: hadigsf/Assault-3.0
bool save_mail_file( const char * mfilename, char * mtext )
{
    FILE * mailfp;
    char mailfpfilename[MSL];
    fclose( fpReserve );
    sprintf( mailfpfilename, "%s%s", MAIL_DIR, mfilename );
    if ( ( mailfp = fopen( mailfpfilename, "w" ) ) == NULL )
    {
        fpReserve = fopen( NULL_FILE, "r" );
        return FALSE;
    }
    fprintf( mailfp, "%s\n", strip_color( mtext, "@@" ) );
    fflush( mailfp );
    fclose( mailfp );
    fpReserve = fopen( NULL_FILE, "r" );
    return TRUE;
}
コード例 #21
0
ファイル: chanlist.cpp プロジェクト: leeter/hexchat
/**
 * Accepts incoming channel data from inbound.c, allocates new space for a
 * chanlistrow, adds it to our linked list and calls chanlist_place_row_in_gui.
 */
void
fe_add_chan_list (server *serv, char *chan, char *users, char *topic)
{
	auto len = strlen (chan) + 1;

	chanlistrow * next_row = new chanlistrow;
	next_row->topic = strip_color(topic, STRIP_ALL);
	glib_string collation_key(g_utf8_collate_key(chan, len - 1));
	next_row->collation_key = collation_key ? collation_key.get() : chan;
	next_row->users = atoi (users);

	/* add this row to the data */
	serv->gui->chanlist_data_stored_rows =
		g_slist_prepend (serv->gui->chanlist_data_stored_rows, next_row);

	/* _possibly_ add the row to the gui */
	chanlist_place_row_in_gui (*serv->gui, next_row, FALSE);
}
コード例 #22
0
string arrange_string(string str, int x) {
  int actuallen, vislen, codelen;
  string code = "%^";

  if(!str || str == "" || !intp(x) || x < 1)
    return "";

  if(intp(str)) 
    str = str+"";
  
  str = wrap(str, x);
  str = str[0..strsrch(str, "\n")-1];

  for (int i = strlen(strip_color(str)); i < x; i++)
    str += " ";

  return str;
}
コード例 #23
0
string align(string strtmp, int i) {
	int x, r, tmp;
	string out, str;
	str=strip_color(strtmp);
	x = sizeof(str);
	out = "";
	if(i==x) return str;

	if(x > i) return strtmp[0..i-1];

	r = i-x;
	out = strtmp;
	if(!out) out="";
	while(r--) {
		if(!out) out = " ";
		else out += " ";
	}
	return out;
}
コード例 #24
0
ファイル: m_quit.c プロジェクト: Cloudxtreme/ircd-3
/*
** m_quit
**      parv[0] = sender prefix
**      parv[1] = comment
*/
static void m_quit(struct Client *client_p,
                  struct Client *source_p,
                  int parc,
                  char *parv[])
{
  static char *dummy = "<no reason>";
  char *comment = (parc > 1 && parv[1]) ? parv[1] : client_p->name;
  char reason [TOPICLEN + 1];
  if (!comment[0]) comment = dummy;

  source_p->flags |= FLAGS_NORMALEX;
  if (strlen(comment) > (size_t) TOPICLEN)
    comment[TOPICLEN] = '\0';

  if (match("*http://*", comment) || match("*www*", comment))
	  comment = "<spam removed>";

  if (ConfigFileEntry.client_exit && comment[0])
    {
#ifndef VMS
      snprintf(reason, TOPICLEN, "Quit: %s", comment);
#else
      sprintf(reason, "Quit: %s", comment);
#endif
      comment = reason;
    }
  
  if(!IsOper(source_p) && 
     (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
     > CurrentTime)
    {
      comment = "Client Quit";
    }

  if (parc > 1)
    /*strip_color(comment);*/
    comment = strip_color(comment, 1);

  exit_client(client_p, source_p, source_p, comment);
}
コード例 #25
0
ファイル: m_quit.c プロジェクト: Cloudxtreme/ircd-3
/*
** ms_quit
**      parv[0] = sender prefix
**      parv[1] = comment
*/
static void ms_quit(struct Client *client_p,
                   struct Client *source_p,
                   int parc,
                   char *parv[])
{
  static char *dummy = "<no reason>";
  char *comment;
  
  cluster_prefix(client_p, parc, parv, 0, 0, 0);
  comment = (parc > 1 && parv[1]) ? parv[1] : client_p->name;
  if (!comment[0]) comment = dummy;

  source_p->flags |= FLAGS_NORMALEX;
  if (strlen(comment) > (size_t) TOPICLEN)
    comment[TOPICLEN] = '\0';

  if (parc > 1)
    /*strip_color(comment);*/
    comment = strip_color(comment, 1);

  exit_client(client_p, source_p, source_p, comment);
}
コード例 #26
0
ファイル: chanlist.c プロジェクト: Babl0lka/XChat
/**
 * Accepts incoming channel data from inbound.c, allocates new space for a
 * chanlistrow, adds it to our linked list and calls chanlist_place_row_in_gui.
 */
void
fe_add_chan_list (server *serv, char *chan, char *users, char *topic)
{
	chanlistrow *next_row;
	int len = strlen (chan) + 1;

	/* we allocate the struct and channel string in one go */
	next_row = malloc (sizeof (chanlistrow) + len);
	memcpy (((char *)next_row) + sizeof (chanlistrow), chan, len);
	next_row->topic = strip_color (topic, -1, STRIP_ALL);
	next_row->collation_key = g_utf8_collate_key (chan, len-1);
	if (!(next_row->collation_key))
		next_row->collation_key = g_strdup (chan);
	next_row->users = atoi (users);

	/* add this row to the data */
	serv->gui->chanlist_data_stored_rows =
		g_slist_prepend (serv->gui->chanlist_data_stored_rows, next_row);

	/* _possibly_ add the row to the gui */
	chanlist_place_row_in_gui (serv, next_row, FALSE);
}
コード例 #27
0
ファイル: inbound.c プロジェクト: BackupTheBerlios/vertigo
static int
SearchNick (char *text, char *nicks)
{
	char S[300];	/* size of bluestring in xchatprefs */
	char *n;
	char *p;
	char *t;
	int ns;

	if (nicks == NULL)
		return 0;

	text = strip_color (text);

	safe_strcpy (S, nicks, sizeof (S));
	n = strtok (S, ",");
	while (n != NULL)
	{
		t = text;
		ns = strlen (n);
		while ((p = nocasestrstr (t, n)))
		{
			if ((p == text || !isalnum (*(p - 1))) && !isalnum (*(p + ns)))
			{
				free (text);
				return 1;
			}

			t = p + 1;
		}

		n = strtok (NULL, ",");
	}
	free (text);
	return 0;
}
コード例 #28
0
ファイル: devik.c プロジェクト: raziel23x/Anotherland_Mud
char *randcolor( char *string )
{
    char buf[MAX_STRING_LENGTH];
    char *c;
    int i;

    if ( !string ) return 0;

    strip_color(string);
    for ( c = string, i = 0; *c; c++ )
    {
        if ( *c == ' ' || *c == '\n' || *c == '\r' )
        {
            buf[i++] = *c;
            continue;
        }
        if ( number_range(1,4) == 1 || c == string )
        {
            buf[i++] = '#';
            buf[i++] = 's';
        }
        if ( *c == '#' )
        {
            if ( *(c+1) == '#' )
            {
                buf[i++] = *c;
                c++;
            }
            else buf[i++] = '#';
        }
        buf[i++] = *c;
    }
    buf[i] = '\0';
    strcpy(string,buf);
    return string;
}
コード例 #29
0
ファイル: plugin.c プロジェクト: IotaSpencer/hexchat
char *
hexchat_strip (hexchat_plugin *ph, const char *str, int len, int flags)
{
	return strip_color ((char *)str, len, flags);
}
コード例 #30
0
ファイル: text.c プロジェクト: TheWug/hexchat
void
scrollback_load (session *sess)
{
	char *buf;
	char *text;
	time_t stamp;
	int lines;
	GIOChannel *io;
	GError *file_error = NULL;
	GError *io_err = NULL;

	if (sess->text_scrollback == SET_DEFAULT)
	{
		if (!prefs.hex_text_replay)
			return;
	}
	else
	{
		if (sess->text_scrollback != SET_ON)
			return;
	}

	if ((buf = scrollback_get_filename (sess)) == NULL)
		return;

	io = g_io_channel_new_file (buf, "r", &file_error);
	g_free (buf);
	if (!io)
		return;

	lines = 0;

	while (1)
	{
		gsize n_bytes;
		GIOStatus io_status;

		io_status = g_io_channel_read_line (io, &buf, &n_bytes, NULL, &io_err);
		
		if (io_status == G_IO_STATUS_NORMAL)
		{
			char *buf_tmp;

			/* If nothing but funny trailing matter e.g. 0x0d or 0x0d0a, toss it */
			if (n_bytes >= 1 && buf[0] == 0x0d)
			{
				g_free (buf);
				continue;
			}

			n_bytes--;
			buf_tmp = buf;
			buf = g_strndup (buf_tmp, n_bytes);
			g_free (buf_tmp);

			/*
			 * Some scrollback lines have three blanks after the timestamp and a newline
			 * Some have only one blank and a newline
			 * Some don't even have a timestamp
			 * Some don't have any text at all
			 */
			if (buf[0] == 'T')
			{
				if (sizeof (time_t) == 4)
					stamp = strtoul (buf + 2, NULL, 10);
				else
					stamp = strtoull (buf + 2, NULL, 10); /* in case time_t is 64 bits */
				text = strchr (buf + 3, ' ');
				if (text && text[1])
				{
					if (prefs.hex_text_stripcolor_replay)
					{
						text = strip_color (text + 1, -1, STRIP_COLOR);
					}

					fe_print_text (sess, text, stamp, TRUE);

					if (prefs.hex_text_stripcolor_replay)
					{
						g_free (text);
					}
				}
				else
				{
					fe_print_text (sess, "  ", stamp, TRUE);
				}
			}
			else
			{
				if (strlen (buf))
					fe_print_text (sess, buf, 0, TRUE);
				else
					fe_print_text (sess, "  ", 0, TRUE);
			}
			lines++;

			g_free (buf);
		}

		else
			break;
	}

	g_io_channel_unref (io);

	sess->scrollwritten = lines;

	if (lines)
	{
		text = ctime (&stamp);
		text[24] = 0;	/* get rid of the \n */
		buf = g_strdup_printf ("\n*\t%s %s\n\n", _("Loaded log from"), text);
		fe_print_text (sess, buf, 0, TRUE);
		g_free (buf);
		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf);*/
	}
}