本文整理汇总了C++中server_get_network函数的典型用法代码示例。如果您正苦于以下问题:C++ server_get_network函数的具体用法?C++ server_get_network怎么用?C++ server_get_network使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了server_get_network函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log_write
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);
}
示例2: chanopt_save
void
chanopt_save (session *sess)
{
int i;
guint8 vals;
guint8 valm;
chanopt_in_memory *co;
char *network;
if (sess->channel[0] == 0)
return;
network = server_get_network (sess->server, FALSE);
if (!network)
return;
/* 2. reconcile sess with what we loaded from disk */
co = chanopt_find (network, sess->channel, TRUE);
i = 0;
while (i < sizeof (chanopt) / sizeof (channel_options))
{
vals = G_STRUCT_MEMBER(guint8, sess, chanopt[i].offset);
valm = G_STRUCT_MEMBER(guint8, co, chanopt[i].offset);
if (vals != valm)
{
*(guint8 *)G_STRUCT_MEMBER_P(co, chanopt[i].offset) = vals;
chanopt_changed = TRUE;
}
i++;
}
}
示例3: chanopt_load
void
chanopt_load (session *sess)
{
int i;
guint8 val;
chanopt_in_memory *co;
char *network;
if (sess->channel[0] == 0)
return;
network = server_get_network (sess->server, FALSE);
if (!network)
return;
if (!chanopt_open)
{
chanopt_open = TRUE;
chanopt_load_all ();
}
co = chanopt_find (network, sess->channel, FALSE);
if (!co)
return;
/* fill in all the sess->xxxxx fields */
i = 0;
while (i < sizeof (chanopt) / sizeof (channel_options))
{
val = G_STRUCT_MEMBER(guint8, co, chanopt[i].offset);
*(guint8 *)G_STRUCT_MEMBER_P(sess, chanopt[i].offset) = val;
i++;
}
}
示例4: scrollback_get_filename
static char *
scrollback_get_filename (session *sess)
{
char *net, *chan, *buf, *ret = NULL;
net = server_get_network (sess->server, FALSE);
if (!net)
return NULL;
net = log_create_filename (net);
buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "scrollback" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.txt", get_xdir (), net, "");
mkdir_p (buf);
g_free (buf);
chan = log_create_filename (sess->channel);
if (chan[0])
buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "scrollback" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.txt", get_xdir (), net, chan);
else
buf = NULL;
g_free (chan);
g_free (net);
if (buf)
{
ret = g_filename_from_utf8 (buf, -1, NULL, NULL, NULL);
g_free (buf);
}
return ret;
}
示例5: notify_announce_online
static void
notify_announce_online (server * serv, struct notify_per_server *servnot,
char *nick)
{
session *sess;
sess = serv->front_session;
servnot->lastseen = time (0);
if (servnot->ison)
return;
servnot->ison = TRUE;
servnot->laston = time (0);
EMIT_SIGNAL (XP_TE_NOTIFYONLINE, sess, nick, serv->servername,
server_get_network (serv, TRUE), NULL, 0);
fe_notify_update (nick);
fe_notify_update (0);
if (prefs.whois_on_notifyonline)
{
/* Let's do whois with idle time (like in /quote WHOIS %s %s) */
char *wii_str = malloc (strlen (nick) * 2 + 2);
sprintf (wii_str, "%s %s", nick, nick);
serv->p_whois (serv, wii_str);
free (wii_str);
}
}
示例6: process_private
static void
process_private(gpointer *params)
{
session *sess = params[0];
gchar *from = params[1];
gchar *message = params[2];
const char *network = server_get_network(sess->server, FALSE);
if (!network)
network = sess->server->connected ? sess->server->servername : NULL;
if (FromNick(from, prefs.irc_no_hilight))
return;
if (prefs.input_tray_priv)
{
tray_set_flash(ICON_HILIGHT);
tray_priv_count++;
if (tray_priv_count == 1)
tray_set_tipf(_("GChat: Private message from: %s (%s)"),
from, network);
else
tray_set_tipf(_("GChat: %u private messages, latest from: %s (%s)"),
tray_priv_count, from, network);
}
if (prefs.input_balloon_priv)
tray_set_balloonf(message, _("GChat: Private message from: %s (%s)"),
from, network);
}
示例7: process_invited
static void
process_invited(gpointer *params)
{
gchar **word = params[1];
gchar *from = params[2];
server *serv = params[3];
gchar *channel = word[4][0] == ':' ? word[4] + 1 : word[4];
const char *network = server_get_network(serv, FALSE);
if (!network)
network = serv->connected ? serv->servername : NULL;
if (FromNick(from, prefs.irc_no_hilight))
return;
if (prefs.input_tray_priv)
{
tray_set_flash(ICON_HILIGHT);
tray_invite_count++;
if (tray_invite_count == 1)
tray_set_tipf(_("GChat: Invite from: %s (%s) to %s"),
from, network, channel);
else
tray_set_tipf(_("GChat: %u private messages, latest from: %s (%s) to %s"),
tray_priv_count, from, network, channel);
}
if (prefs.input_balloon_priv)
tray_set_balloonf("", _("GChat: Invite from: %s (%s) to %s"),
from, network, channel);
}
示例8: nick_command_parse
void
nick_command_parse (session *sess, char *cmd, char *nick, char *allnick)
{
char *buf;
char *host = _("Host unknown");
struct User *user;
int len;
/* if (sess->type == SESS_DIALOG)
{
buf = (char *)(GTK_ENTRY (sess->gui->topic_entry)->text);
buf = strrchr (buf, '@');
if (buf)
host = buf + 1;
} else*/
{
user = userlist_find (sess, nick);
if (user && user->hostname)
host = strchr (user->hostname, '@') + 1;
}
/* this can't overflow, since popup->cmd is only 256 */
len = strlen (cmd) + strlen (nick) + strlen (allnick) + 512;
buf = malloc (len);
auto_insert (buf, len, cmd, 0, 0, allnick, sess->channel, "",
server_get_network (sess->server, TRUE), host,
sess->server->nick, nick);
nick_command (sess, buf);
free (buf);
}
示例9: process_dcc
static void
process_dcc(gpointer *params)
{
session *sess = params[0];
gchar *nick = params[1];
const char *network = server_get_network(sess->server, FALSE);
if (!network)
network = sess->server->connected ? sess->server->servername : NULL;
if (prefs.input_tray_priv)
{
tray_set_flash(ICON_FILE);
tray_dcc_count++;
if (tray_dcc_count == 1)
tray_set_tipf(_("GChat: DCC offer from: %s (%s)"),
nick, network ? network : "unknown network");
else
tray_set_tipf(_("GChat: %u DCC offers, latest from: %s (%s)"),
tray_dcc_count, nick, network ? network : "unknown network");
}
if (prefs.input_balloon_priv)
tray_set_balloonf("", _("GChat: DCC offer from: %s (%s)"),
nick, network ? network : "unknown network");
}
示例10: xchat_find_context
xchat_context* xchat_find_context(xchat_plugin *ph, const char *servname, const char *channel)
{
GSList *slist, *clist, *sessions = nullptr;
server *serv;
session *sess;
char *netname;
if (servname == nullptr && channel == nullptr)
return current_sess;
slist = serv_list;
while (slist)
{
serv = (server*)slist->data;
netname = server_get_network(serv, TRUE);
if (servname == nullptr ||
rfc_casecmp(servname, serv->servername) == 0 ||
strcasecmp(servname, serv->hostname) == 0 ||
strcasecmp(servname, netname) == 0)
{
if (channel == nullptr)
return serv->front_session;
clist = sess_list;
while (clist)
{
sess = (session*)clist->data;
if (sess->server == serv)
{
if (rfc_casecmp(channel, sess->channel) == 0)
{
if (sess->server == ph->context->server)
{
g_slist_free(sessions);
return sess;
}
else
{
sessions = g_slist_prepend(sessions, sess);
}
}
}
clist = clist->next;
}
}
slist = slist->next;
}
if (sessions)
{
sessions = g_slist_reverse(sessions);
sess = (session*)sessions->data;
g_slist_free(sessions);
return sess;
}
return nullptr;
}
示例11: plugin_find_context
session *
plugin_find_context (const char *servname, const char *channel, server *current_server)
{
GSList *slist, *clist, *sessions = NULL;
server *serv;
session *sess;
char *netname;
if (servname == NULL && channel == NULL)
return current_sess;
slist = serv_list;
while (slist)
{
serv = slist->data;
netname = server_get_network (serv, TRUE);
if (servname == NULL ||
rfc_casecmp (servname, serv->servername) == 0 ||
g_ascii_strcasecmp (servname, serv->hostname) == 0 ||
g_ascii_strcasecmp (servname, netname) == 0)
{
if (channel == NULL)
return serv->front_session;
clist = sess_list;
while (clist)
{
sess = clist->data;
if (sess->server == serv)
{
if (rfc_casecmp (channel, sess->channel) == 0)
{
if (sess->server == current_server)
{
g_slist_free (sessions);
return sess;
} else
{
sessions = g_slist_prepend (sessions, sess);
}
}
}
clist = clist->next;
}
}
slist = slist->next;
}
if (sessions)
{
sessions = g_slist_reverse (sessions);
sess = sessions->data;
g_slist_free (sessions);
return sess;
}
return NULL;
}
示例12: log_open
static void
log_open (session *sess)
{
static gboolean log_error = FALSE;
log_close (sess);
sess->logfd = log_open_file (sess->server->servername, sess->channel,
server_get_network (sess->server, FALSE));
if (!log_error && sess->logfd == -1)
{
char message[512];
snprintf (message, sizeof (message), _("* Can't open log file(s) for writing. Check the\npermissions on %s"),
log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)));
fe_message (message, FE_MSG_WAIT | FE_MSG_ERROR);
log_error = TRUE;
}
}
示例13: log_open
static void
log_open (session *sess)
{
static gboolean log_error = FALSE;
log_close (sess);
sess->logfd = log_open_file (sess->server->servername, sess->channel,
server_get_network (sess->server, FALSE));
if (!log_error && sess->logfd == -1)
{
char *filename = log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE));
char *message = g_strdup_printf (_("* Can't open log file(s) for writing. Check the\npermissions on %s"), filename);
g_free (filename);
fe_message (message, FE_MSG_WAIT | FE_MSG_ERROR);
g_free (message);
log_error = TRUE;
}
}
示例14: ctcp_reply
static void
ctcp_reply (session *sess, char *nick, char *word[], char *word_eol[],
char *conf)
{
char tbuf[4096]; /* can receive 2048 from IRC, so this is enough */
conf = strdup (conf);
/* process %C %B etc */
check_special_chars (conf, TRUE);
auto_insert (tbuf, sizeof (tbuf), conf, word, word_eol, "", "", word_eol[5],
server_get_network (sess->server, TRUE), "", "", nick);
free (conf);
handle_command (sess, tbuf, FALSE);
}
示例15: notify_netcmp
static int
notify_netcmp (char *str, void *serv)
{
char *net = despacify_dup (server_get_network (serv, TRUE));
if (rfc_casecmp (str, net) == 0)
{
free (net);
return 0; /* finish & return FALSE from token_foreach() */
}
free (net);
return 1; /* keep going... */
}