本文整理汇总了C++中printformat函数的典型用法代码示例。如果您正苦于以下问题:C++ printformat函数的具体用法?C++ printformat怎么用?C++ printformat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printformat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: event_topic_info
static void event_topic_info(IRC_SERVER_REC *server, const char *data)
{
const char *channel;
char *params, *timestr, *bynick, *byhost, *topictime;
g_return_if_fail(data != NULL);
params = event_get_params(data, 4, NULL, &channel,
&bynick, &topictime);
timestr = my_asctime((time_t) atol(topictime));
byhost = strchr(bynick, '!');
if (byhost != NULL)
*byhost++ = '\0';
channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_TOPIC_INFO,
bynick, timestr, byhost == NULL ? "" : byhost);
g_free(timestr);
g_free(params);
}
示例2: dcc_connected
static void dcc_connected(CHAT_DCC_REC *dcc)
{
char *sender;
if (!IS_DCC_CHAT(dcc)) return;
sender = g_strconcat("=", dcc->id, NULL);
printformat(dcc->server, NULL, MSGLEVEL_DCC,
IRCTXT_DCC_CHAT_CONNECTED,
dcc->id, dcc->addrstr, dcc->port);
if (query_find(NULL, sender) == NULL) {
int level = settings_get_level("autocreate_query_level");
int autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0;
if (!autocreate_dccquery)
completion_last_message_add(sender);
else
irc_query_create(dcc->servertag, sender, TRUE);
}
g_free(sender);
}
示例3: chat_protocol_find_net
static SERVER_SETUP_REC *create_server_setup(GHashTable *optlist)
{
CHAT_PROTOCOL_REC *rec;
SERVER_SETUP_REC *server;
char *chatnet;
rec = chat_protocol_find_net(optlist);
if (rec == NULL)
rec = chat_protocol_get_default();
else {
chatnet = g_hash_table_lookup(optlist, rec->chatnet);
if (chatnet_find(chatnet) == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_UNKNOWN_CHATNET, chatnet);
return NULL;
}
}
server = rec->create_server_setup();
server->chat_type = rec->id;
return server;
}
示例4: set_print_pattern
static void set_print_pattern(const char *pattern)
{
GSList *sets, *tmp;
const char *last_section;
last_section = "";
sets = settings_get_sorted();
for (tmp = sets; tmp != NULL; tmp = tmp->next) {
SETTINGS_REC *rec = tmp->data;
if (stristr(rec->key, pattern) == NULL)
continue;
if (g_strcmp0(last_section, rec->section) != 0) {
/* print section */
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
TXT_SET_TITLE, rec->section);
last_section = rec->section;
}
set_print(rec);
}
g_slist_free(sets);
}
示例5: set_print
static void set_print(SETTINGS_REC *rec)
{
const char *value;
char value_int[MAX_INT_STRLEN];
switch (rec->type) {
case SETTING_TYPE_BOOLEAN:
value = settings_get_bool(rec->key) ? "ON" : "OFF";
break;
case SETTING_TYPE_INT:
ltoa(value_int, settings_get_int(rec->key));
value = value_int;
break;
case SETTING_TYPE_STRING:
value = settings_get_str(rec->key);
break;
default:
value = "";
}
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_ITEM,
rec->key, value);
}
示例6: theme_save
static void theme_save(THEME_REC *theme, int save_all)
{
CONFIG_REC *config;
THEME_SAVE_REC data;
char *path;
int ok;
config = config_open(theme->path, -1);
if (config != NULL)
config_parse(config);
else {
if (g_strcasecmp(theme->name, "default") == 0) {
config = config_open(NULL, -1);
config_parse_data(config, default_theme, "internal");
config_change_file_name(config, theme->path, 0660);
} else {
config = config_open(theme->path, 0660);
if (config == NULL)
return;
config_parse(config);
}
}
data.config = config;
data.save_all = save_all;
g_hash_table_foreach(theme->modules, (GHFunc) module_save, &data);
/* always save the theme to ~/.irssi/ */
path = g_strdup_printf("%s/%s", get_irssi_dir(),
g_basename(theme->path));
ok = config_write(config, path, 0660) == 0;
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
ok ? TXT_THEME_SAVED : TXT_THEME_SAVE_FAILED,
path, config_last_error(config));
g_free(path);
config_close(config);
}
示例7: cmd_unignore
/* SYNTAX: UNIGNORE <id>|<mask> */
static void cmd_unignore(const char *data)
{
IGNORE_REC *rec;
GSList *tmp;
char *mask;
void *free_arg;
if (!cmd_get_params(data, &free_arg, 1, &mask))
return;
if (*mask == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (is_numeric(mask, ' ')) {
/* with index number */
tmp = g_slist_nth(ignores, atoi(mask)-1);
rec = tmp == NULL ? NULL : tmp->data;
} else {
/* with mask */
const char *chans[2] = { "*", NULL };
if (active_win->active_server != NULL &&
server_ischannel(active_win->active_server, mask)) {
chans[0] = mask;
mask = NULL;
}
rec = ignore_find("*", mask, (char **) chans);
}
if (rec != NULL) {
rec->level = 0;
ignore_update_rec(rec);
} else {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_IGNORE_NOT_FOUND, mask);
}
cmd_params_free(free_arg);
}
示例8: event_whois_channels
static void event_whois_channels(IRC_SERVER_REC *server, const char *data)
{
char *params, *nick, *chans, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &chans);
/* sure - we COULD print the channel names as-is, but since the
colors, bolds, etc. are mostly just to fool people, I think we
should show the channel names as they REALLY are so they could
even be joined without any extra tricks. */
chans = show_lowascii(chans);
if (settings_get_bool("whois_hide_safe_channel_id"))
hide_safe_channel_id(server, chans);
recoded = recode_in(SERVER(server), chans, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS_CHANNELS, nick, recoded);
g_free(chans);
g_free(params);
g_free(recoded);
}
示例9: ctcp_default_reply
static void ctcp_default_reply(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr,
const char *target)
{
const char *ctcpdata;
char *ctcp, *ptr;
g_return_if_fail(data != NULL);
ctcp = g_strdup(data);
ptr = strchr(ctcp, ' ');
if (ptr == NULL)
ctcpdata = "";
else {
*ptr = '\0';
ctcpdata = ptr+1;
}
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL :
IRCTXT_CTCP_REPLY, ctcp, nick, ctcpdata, target);
g_free(ctcp);
}
示例10: event_who
static void event_who(IRC_SERVER_REC *server, const char *data)
{
char *params, *nick, *channel, *user, *host, *stat, *realname, *hops;
char *serv, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 8, NULL, &channel, &user,
&host, &serv, &nick, &stat, &realname);
/* split hops/realname */
hops = realname;
while (*realname != '\0' && *realname != ' ') realname++;
if (*realname == ' ')
*realname++ = '\0';
recoded = recode_in(SERVER(server), realname, nick);
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_WHO,
channel, nick, stat, hops, user, host, recoded, serv);
g_free(params);
g_free(recoded);
}
示例11: event_away
static void event_away(IRC_SERVER_REC *server, const char *data)
{
char *params, *nick, *awaymsg, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
recoded = recode_in(SERVER(server), awaymsg, nick);
if (!settings_get_bool("show_away_once") ||
last_away_nick == NULL || g_strcasecmp(last_away_nick, nick) != 0 ||
last_away_msg == NULL || g_strcasecmp(last_away_msg, awaymsg) != 0) {
/* don't show the same away message
from the same nick all the time */
g_free_not_null(last_away_nick);
g_free_not_null(last_away_msg);
last_away_nick = g_strdup(nick);
last_away_msg = g_strdup(awaymsg);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_NICK_AWAY, nick, recoded);
}
g_free(params);
g_free(recoded);
}
示例12: sig_message_own_action
static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
const char *target)
{
void *item;
const char *oldtarget;
char *freemsg = NULL;
oldtarget = target;
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
if (server_ischannel(SERVER(server), target))
item = irc_channel_find(server, target);
else
item = irc_query_find(server, target);
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis(item, msg);
printformat(server, target,
MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
server->nick, msg, oldtarget);
g_free_not_null(freemsg);
}
示例13: glog_func
void glog_func(const char *log_domain, GLogLevelFlags log_level,
const char *message)
{
const char *reason;
switch (log_level) {
case G_LOG_LEVEL_WARNING:
reason = "warning";
break;
case G_LOG_LEVEL_CRITICAL:
reason = "critical";
break;
default:
reason = "error";
break;
}
if (windows == NULL)
fprintf(stderr, "GLib %s: %s\n", reason, message);
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
TXT_GLIB_ERROR, reason, message);
}
}
示例14: cmd_channel_add
/* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
<channel> <chatnet> [<password>] */
static void cmd_channel_add(const char *data)
{
GHashTable *optlist;
CHANNEL_SETUP_REC *rec;
char *botarg, *botcmdarg, *chatnet, *channel, *password;
void *free_arg;
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS,
"channel add", &optlist, &channel, &chatnet, &password))
return;
botarg = g_hash_table_lookup(optlist, "bots");
botcmdarg = g_hash_table_lookup(optlist, "botcmd");
if (*chatnet == '\0' || *channel == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
rec = channels_setup_find(channel, chatnet);
if (rec == NULL) {
rec = g_new0(CHANNEL_SETUP_REC, 1);
rec->name = g_strdup(channel);
rec->chatnet = g_strdup(chatnet);
} else {
if (g_hash_table_lookup(optlist, "bots")) g_free_and_null(rec->botmasks);
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
if (*password != '\0') g_free_and_null(rec->password);
}
if (g_hash_table_lookup(optlist, "auto")) rec->autojoin = TRUE;
if (g_hash_table_lookup(optlist, "noauto")) rec->autojoin = FALSE;
if (botarg != NULL && *botarg != '\0') rec->botmasks = g_strdup(botarg);
if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg);
if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password);
channels_setup_create(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_ADDED, channel, chatnet);
cmd_params_free(free_arg);
}
示例15: sig_module_loaded
static void sig_module_loaded(MODULE_REC *module, MODULE_FILE_REC *file)
{
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_MODULE_LOADED, module->name, file->name);
}