m_info: remove repetition

This commit is contained in:
Ed Kellett 2020-11-08 21:15:20 +00:00
parent 0ee3f45c89
commit dce5f18f6f
1 changed files with 22 additions and 62 deletions

View File

@ -731,110 +731,70 @@ send_conf_options(struct Client *source_p)
*/ */
for (i = 0; info_table[i].name; i++) for (i = 0; info_table[i].name; i++)
{ {
static char opt_buf[BUFSIZE];
char *opt_value = opt_buf;
switch (info_table[i].output_type) switch (info_table[i].output_type)
{ {
case OUTPUT_STRING: case OUTPUT_STRING:
{ {
char *option = *info_table[i].option.string_p; char *option = *info_table[i].option.string_p;
opt_value = option != NULL ? option : "NONE";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option ? option : "NONE",
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_STRING_PTR: case OUTPUT_STRING_PTR:
{ {
char *option = info_table[i].option.string; char *option = info_table[i].option.string;
opt_value = option != NULL ? option : "NONE";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
EmptyString(option) ? "NONE" : option,
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_DECIMAL: case OUTPUT_DECIMAL:
{ {
int option = *info_table[i].option.int_; int option = *info_table[i].option.int_;
snprintf(opt_buf, sizeof opt_buf, "%d", option);
sendto_one(source_p, ":%s %d %s :%-30s %-16d [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option,
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_BOOLEAN: case OUTPUT_BOOLEAN:
{ {
bool option = *info_table[i].option.bool_; bool option = *info_table[i].option.bool_;
opt_value = option ? "ON" : "OFF";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option ? "ON" : "OFF",
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_BOOLEAN_YN: case OUTPUT_BOOLEAN_YN:
{ {
bool option = *info_table[i].option.bool_; bool option = *info_table[i].option.bool_;
opt_value = option ? "YES" : "NO";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option ? "YES" : "NO",
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_YESNOMASK: case OUTPUT_YESNOMASK:
{ {
int option = *info_table[i].option.int_; int option = *info_table[i].option.int_;
opt_value = option == 0 ? "NO" :
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]", option == 1 ? "MASK" :
me.name, RPL_INFO, source_p->name, "YES";
info_table[i].name, break;
option ? ((option == 1) ? "MASK" : "YES") : "NO",
info_table[i].desc ? info_table[i].desc : "<none>");
} }
case OUTPUT_INTBOOL: case OUTPUT_INTBOOL:
{ {
bool option = *info_table[i].option.int_; bool option = *info_table[i].option.int_;
opt_value = option ? "ON" : "OFF";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option ? "ON" : "OFF",
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
case OUTPUT_INTBOOL_YN: case OUTPUT_INTBOOL_YN:
{ {
bool option = *info_table[i].option.int_; bool option = *info_table[i].option.int_;
opt_value = option ? "YES" : "NO";
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
option ? "YES" : "NO",
info_table[i].desc ? info_table[i].desc : "<none>");
break; break;
} }
} }
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p),
info_table[i].name,
opt_value,
info_table[i].desc ? info_table[i].desc : "<none>");
} }