1
0
forked from bip/bip

Big grammar round-up :)

This commit is contained in:
Arnaud Cornet 2007-11-25 18:37:13 +01:00
parent 7020e7fa4c
commit 8c649b4357

156
src/bip.c
View File

@ -1214,7 +1214,7 @@ void adm_print_connection(struct link_client *ic, struct link *lnk,
{ {
hash_iterator_t lit; hash_iterator_t lit;
char buf[RET_STR_LEN + 1]; char buf[RET_STR_LEN + 1];
int t_wrote = 0; int t_written = 0;
if (!bu) if (!bu)
bu = lnk->user; bu = lnk->user;
@ -1225,47 +1225,47 @@ void adm_print_connection(struct link_client *ic, struct link *lnk,
(lnk->connect_nick ? lnk->connect_nick : bu->default_nick), (lnk->connect_nick ? lnk->connect_nick : bu->default_nick),
(lnk->username ? lnk->username : bu->default_username)); (lnk->username ? lnk->username : bu->default_username));
t_wrote = snprintf(buf, RET_STR_LEN, " Options:"); t_written = snprintf(buf, RET_STR_LEN, " Options:");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
if (lnk->follow_nick) { if (lnk->follow_nick) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " follow_nick"); RET_STR_LEN - t_written, " follow_nick");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
if (lnk->ignore_first_nick) { if (lnk->ignore_first_nick) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " ignore_first_nick"); RET_STR_LEN - t_written, " ignore_first_nick");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
if (lnk->away_nick) { if (lnk->away_nick) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " away_nick=%s", RET_STR_LEN - t_written, " away_nick=%s",
lnk->away_nick); lnk->away_nick);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
if (lnk->no_client_away_msg) { if (lnk->no_client_away_msg) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " no_client_away_msg=%s", RET_STR_LEN - t_written, " no_client_away_msg=%s",
lnk->no_client_away_msg); lnk->no_client_away_msg);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
if (lnk->vhost) { if (lnk->vhost) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " vhost=%s", RET_STR_LEN - t_written, " vhost=%s",
lnk->vhost); lnk->vhost);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
if (lnk->bind_port) { if (lnk->bind_port) {
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, " bind_port=%u", RET_STR_LEN - t_written, " bind_port=%u",
lnk->bind_port); lnk->bind_port);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to
@ -1276,78 +1276,78 @@ noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to
// TODO: on_connect_send // TODO: on_connect_send
// TODO : check channels struct // TODO : check channels struct
t_wrote = snprintf(buf, RET_STR_LEN, " Channels (* with key, ` no backlog)"); t_written = snprintf(buf, RET_STR_LEN, " Channels (* with key, ` no backlog)");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomchan; goto noroomchan;
for (hash_it_init(&lnk->chan_infos, &lit); hash_it_item(&lit); for (hash_it_init(&lnk->chan_infos, &lit); hash_it_item(&lit);
hash_it_next(&lit)) { hash_it_next(&lit)) {
struct chan_info *ch = hash_it_item(&lit); struct chan_info *ch = hash_it_item(&lit);
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, " %s%s%s", t_written += snprintf(buf + t_written, RET_STR_LEN - t_written, " %s%s%s",
ch->name, (ch->key ? "*" : ""), ch->name, (ch->key ? "*" : ""),
(ch->backlog ? "" : "`")); (ch->backlog ? "" : "`"));
if (t_wrote > LINE_SIZE_LIM) { if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
bip_notify(ic, buf); bip_notify(ic, buf);
t_wrote = 0; t_written = 0;
} }
} }
noroomchan: noroomchan:
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
bip_notify(ic, buf); bip_notify(ic, buf);
t_wrote = snprintf(buf, RET_STR_LEN, " Status: "); t_written = snprintf(buf, RET_STR_LEN, " Status: ");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
switch (lnk->s_state) { switch (lnk->s_state) {
case IRCS_NONE: case IRCS_NONE:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"not started"); "not started");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
case IRCS_CONNECTING: case IRCS_CONNECTING:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"connecting... attempts: %d, last: %s", "connecting... attempts: %d, last: %s",
lnk->s_conn_attempt, lnk->s_conn_attempt,
hrtime(lnk->last_connection_attempt)); hrtime(lnk->last_connection_attempt));
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
case IRCS_CONNECTED: case IRCS_CONNECTED:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"connected !"); "connected !");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
case IRCS_WAS_CONNECTED: case IRCS_WAS_CONNECTED:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"disconnected, attempts: %d, last: %s", "disconnected, attempts: %d, last: %s",
lnk->s_conn_attempt, lnk->s_conn_attempt,
hrtime(lnk->last_connection_attempt)); hrtime(lnk->last_connection_attempt));
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
case IRCS_RECONNECTING: case IRCS_RECONNECTING:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"reconnecting... attempts: %d, last: %s", "reconnecting... attempts: %d, last: %s",
lnk->s_conn_attempt, lnk->s_conn_attempt,
hrtime(lnk->last_connection_attempt)); hrtime(lnk->last_connection_attempt));
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
case IRCS_TIMER_WAIT: case IRCS_TIMER_WAIT:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"waiting to reconnect, attempts: %d, last: %s", "waiting to reconnect, attempts: %d, last: %s",
lnk->s_conn_attempt, lnk->s_conn_attempt,
hrtime(lnk->last_connection_attempt)); hrtime(lnk->last_connection_attempt));
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
default: default:
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
"unknown"); "unknown");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroomstatus; goto noroomstatus;
break; break;
// s_conn_attempt recon_timer last_connection_attempt // s_conn_attempt recon_timer last_connection_attempt
@ -1389,7 +1389,7 @@ void adm_info_user(struct link_client *ic, char *name)
{ {
struct user *u; struct user *u;
char buf[RET_STR_LEN + 1]; char buf[RET_STR_LEN + 1];
int t_wrote = 0; int t_written = 0;
bip_notify(ic, "-- User '%s' info", name); bip_notify(ic, "-- User '%s' info", name);
u = hash_get(&_bip->users, name); u = hash_get(&_bip->users, name);
@ -1398,26 +1398,26 @@ void adm_info_user(struct link_client *ic, char *name)
return; return;
} }
//t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, ""); //t_written += snprintf(buf + t_written, RET_STR_LEN - t_written, "");
//buf[RET_STR_LEN] = 0; //buf[RET_STR_LEN] = 0;
//bip_notify(ic, buf); //bip_notify(ic, buf);
//t_wrote = 0; //t_written = 0;
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, "user: %s", t_written += snprintf(buf + t_written, RET_STR_LEN - t_written, "user: %s",
u->name); u->name);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
if (u->admin) { if (u->admin) {
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN - t_wrote, t_written += snprintf(buf + t_written, RET_STR_LEN - t_written,
", is bip admin"); ", is bip admin");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
noroom: noroom:
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
bip_notify(ic, buf); bip_notify(ic, buf);
t_wrote = 0; t_written = 0;
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
bip_notify(ic, "SSL check mode '%s', stored into '%s'", bip_notify(ic, "SSL check mode '%s', stored into '%s'",
@ -1454,12 +1454,12 @@ void adm_list_users(struct link_client *ic)
hash_it_next(&it)) { hash_it_next(&it)) {
struct user *u = hash_it_item(&it); struct user *u = hash_it_item(&it);
int first = 1; int first = 1;
int t_wrote = 0; int t_written = 0;
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
t_wrote += snprintf(buf, RET_STR_LEN, "* %s%s:", u->name, t_written += snprintf(buf, RET_STR_LEN, "* %s%s:", u->name,
(u->admin ? "": "(admin)")); (u->admin ? "": "(admin)"));
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
for (hash_it_init(&u->connections, &lit); hash_it_item(&lit); for (hash_it_init(&u->connections, &lit); hash_it_item(&lit);
hash_it_next(&lit)) { hash_it_next(&lit)) {
@ -1467,21 +1467,21 @@ void adm_list_users(struct link_client *ic)
if (first) { if (first) {
first = 0; first = 0;
} else { } else {
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN t_written += snprintf(buf + t_written, RET_STR_LEN
- t_wrote, ","); - t_written, ",");
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} }
t_wrote += snprintf(buf + t_wrote, t_written += snprintf(buf + t_written,
RET_STR_LEN - t_wrote, RET_STR_LEN - t_written,
" %s", lnk->name); " %s", lnk->name);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
if (t_wrote > LINE_SIZE_LIM) { if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
bip_notify(ic, buf); bip_notify(ic, buf);
t_wrote = 0; t_written = 0;
} }
} }
noroom: noroom:
@ -1503,35 +1503,35 @@ void adm_list_networks(struct link_client *ic)
for (hash_it_init(&_bip->networks, &it); hash_it_item(&it); for (hash_it_init(&_bip->networks, &it); hash_it_item(&it);
hash_it_next(&it)) { hash_it_next(&it)) {
struct network *n = hash_it_item(&it); struct network *n = hash_it_item(&it);
int t_wrote = 0; int t_written = 0;
int i; int i;
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
if (n->ssl) { if (n->ssl) {
t_wrote += snprintf(buf, RET_STR_LEN, "- %s*:", t_written += snprintf(buf, RET_STR_LEN, "- %s*:",
n->name); n->name);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
} else { } else {
#endif #endif
t_wrote += snprintf(buf, RET_STR_LEN, "- %s:", n->name); t_written += snprintf(buf, RET_STR_LEN, "- %s:", n->name);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
} }
#endif #endif
for (i = 0; i < n->serverc; i++) { for (i = 0; i < n->serverc; i++) {
struct server *serv = i+n->serverv; struct server *serv = i+n->serverv;
t_wrote += snprintf(buf + t_wrote, RET_STR_LEN t_written += snprintf(buf + t_written, RET_STR_LEN
- t_wrote, " %s:%d", serv->host, - t_written, " %s:%d", serv->host,
serv->port); serv->port);
if (t_wrote >= RET_STR_LEN) if (t_written >= RET_STR_LEN)
goto noroom; goto noroom;
if (t_wrote > LINE_SIZE_LIM) { if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0; buf[RET_STR_LEN] = 0;
bip_notify(ic, buf); bip_notify(ic, buf);
t_wrote = 0; t_written = 0;
} }
} }
noroom: noroom:
@ -1783,7 +1783,7 @@ void adm_on_connect_send(struct link_client *ic, struct line *line,
unsigned int privmsg) unsigned int privmsg)
{ {
char buf[ON_CONNECT_MAX_STRSIZE]; char buf[ON_CONNECT_MAX_STRSIZE];
int t_wrote = 0; int t_written = 0;
unsigned int i; unsigned int i;
if (!line) { if (!line) {
@ -1795,16 +1795,16 @@ void adm_on_connect_send(struct link_client *ic, struct line *line,
return; return;
for (i = privmsg + 2; i < line->elemc; i++) { for (i = privmsg + 2; i < line->elemc; i++) {
if (t_wrote) { if (t_written) {
t_wrote += snprintf(buf, t_written += snprintf(buf,
ON_CONNECT_MAX_STRSIZE - 1 - t_wrote, ON_CONNECT_MAX_STRSIZE - 1 - t_written,
" %s", line->elemv[i]); " %s", line->elemv[i]);
if (t_wrote >= ON_CONNECT_MAX_STRSIZE) if (t_written >= ON_CONNECT_MAX_STRSIZE)
goto noroom; goto noroom;
} else { } else {
t_wrote = snprintf(buf, ON_CONNECT_MAX_STRSIZE - 1, t_written = snprintf(buf, ON_CONNECT_MAX_STRSIZE - 1,
"%s", line->elemv[i]); "%s", line->elemv[i]);
if (t_wrote >= ON_CONNECT_MAX_STRSIZE) if (t_written >= ON_CONNECT_MAX_STRSIZE)
goto noroom; goto noroom;
} }
} }