commit 1eb7b699d4b999e8f3a3b5334e57d8c4ff6c9cdb
parent f231e9cbd21a43dd2337e400eadb2f40928ffb93
Author: hhvn <dev@hhvn.uk>
Date: Mon, 2 May 2022 21:38:46 +0100
Consistant naming of queries
Diffstat:
7 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/src/chan.c b/src/chan.c
@@ -52,7 +52,7 @@ chan_free_list(struct Channel **head) {
}
struct Channel *
-chan_create(struct Server *server, char *name, int priv) {
+chan_create(struct Server *server, char *name, int query) {
struct Channel *channel;
channel = emalloc(sizeof(struct Channel));
@@ -61,7 +61,7 @@ chan_create(struct Server *server, char *name, int priv) {
channel->nicks = NULL;
channel->old = 0;
channel->mode = channel->topic = NULL;
- channel->priv = priv;
+ channel->query = query;
channel->server = server;
channel->history = emalloc(sizeof(struct HistInfo));
channel->history->activity = Activity_none;
@@ -85,13 +85,13 @@ chan_selected(struct Channel *channel) {
}
struct Channel *
-chan_add(struct Server *server, struct Channel **head, char *name, int priv) {
+chan_add(struct Server *server, struct Channel **head, char *name, int query) {
struct Channel *channel, *p;
if (!name)
return NULL;
- if ((channel = chan_create(server, name, priv)) == NULL)
+ if ((channel = chan_create(server, name, query)) == NULL)
return NULL;
if (!*head) {
diff --git a/src/commands.c b/src/commands.c
@@ -110,7 +110,7 @@ command_msg) {
if (serv_ischannel(server, target))
chan = chan_get(&server->channels, target, -1);
else
- chan = chan_get(&server->privs, target, -1);
+ chan = chan_get(&server->queries, target, -1);
serv_write(server, "PRIVMSG %s :%s\r\n", target, message);
if (chan) {
@@ -134,7 +134,7 @@ command_notice) {
if (serv_ischannel(server, target))
chan = chan_get(&server->channels, target, -1);
else
- chan = chan_get(&server->privs, target, -1);
+ chan = chan_get(&server->queries, target, -1);
serv_write(server, "NOTICE %s :%s\r\n", target, message);
if (chan) {
@@ -171,7 +171,7 @@ command_ctcp) {
}
if ((chan = chan_get(&server->channels, target, -1)) == NULL)
- chan = chan_get(&server->privs, target, -1);
+ chan = chan_get(&server->queries, target, -1);
/* XXX: if we CTCP a channel, responses should go to that channel.
* This requires more than just expect_set, so might never be
@@ -186,7 +186,7 @@ command_ctcp) {
COMMAND(
command_query) {
- struct Channel *priv;
+ struct Channel *query;
if (!str) {
command_toofew("query");
@@ -203,11 +203,11 @@ command_query) {
return;
}
- if ((priv = chan_get(&server->privs, str, -1)) == NULL)
- priv = chan_add(server, &server->privs, str, 1);
+ if ((query = chan_get(&server->queries, str, -1)) == NULL)
+ query = chan_add(server, &server->queries, str, 1);
if (!nouich)
- ui_select(server, priv);
+ ui_select(server, query);
}
COMMAND(
@@ -1496,7 +1496,7 @@ command_dump) {
fprintf(file, "/server %s /join %s\n", sp->name, chp->name);
}
if (selected & opt_queries) {
- for (chp = sp->privs; chp; chp = chp->next)
+ for (chp = sp->queries; chp; chp = chp->next)
fprintf(file, "/server %s /query %s\n", sp->name, chp->name);
}
fprintf(file, "\n");
@@ -1581,7 +1581,7 @@ command_close) {
serv_write(sp, "PART %s\r\n", chp->name);
chan_remove(&sp->channels, chp->name);
} else {
- chan_remove(&sp->privs, chp->name);
+ chan_remove(&sp->queries, chp->name);
}
ui_select(sp, NULL);
} else {
diff --git a/src/handle.c b/src/handle.c
@@ -218,7 +218,6 @@ HANDLER(
handle_PRIVMSG) {
int act_direct = Activity_hilight, act_regular = Activity_message, act;
struct Channel *chan;
- struct Channel *priv;
struct Nick *nick;
char *target;
@@ -235,18 +234,18 @@ handle_PRIVMSG) {
hist_addp(server->history, msg, Activity_status, HIST_DFL);
} else if (strcmp_n(target, server->self->nick) == 0) {
/* it's messaging me */
- if ((priv = chan_get(&server->privs, nick->nick, -1)) == NULL)
- priv = chan_add(server, &server->privs, nick->nick, 1);
- chan_setold(priv, 0);
+ if ((chan = chan_get(&server->queries, nick->nick, -1)) == NULL)
+ chan = chan_add(server, &server->queries, nick->nick, 1);
+ chan_setold(chan, 0);
- hist_addp(priv->history, msg, act_direct, HIST_DFL);
+ hist_addp(chan->history, msg, act_direct, HIST_DFL);
} else if (nick_isself(nick) && !strchr("#&!+", *target)) {
/* i'm messaging someone */
- if ((priv = chan_get(&server->privs, target, -1)) == NULL)
- priv = chan_add(server, &server->privs, target, 1);
- chan_setold(priv, 0);
+ if ((chan = chan_get(&server->queries, target, -1)) == NULL)
+ chan = chan_add(server, &server->queries, target, 1);
+ chan_setold(chan, 0);
- hist_addp(priv->history, msg, act_regular, HIST_DFL);
+ hist_addp(chan->history, msg, act_regular, HIST_DFL);
} else {
/* message to a channel */
if ((chan = chan_get(&server->channels, target, -1)) == NULL)
@@ -262,13 +261,13 @@ handle_PRIVMSG) {
HANDLER(
handle_INVITE) {
- struct Channel *priv;
+ struct Channel *query;
if (!msg->from || param_len(msg->params) < 3)
return;
- if ((priv = chan_get(&server->privs, msg->from->nick, -1)) != NULL)
- hist_addp(priv->history, msg, Activity_status, HIST_DFL);
+ if ((query = chan_get(&server->queries, msg->from->nick, -1)) != NULL)
+ hist_addp(query->history, msg, Activity_status, HIST_DFL);
else
hist_addp(server->history, msg, Activity_status, HIST_DFL);
}
@@ -302,10 +301,10 @@ handle_RPL_ISUPPORT) {
HANDLER(
handle_RPL_AWAY) {
- struct Channel *priv;
+ struct Channel *query;
- if ((priv = chan_get(&server->privs, *(msg->params+2), -1)) != NULL) {
- hist_addp(priv->history, msg, Activity_status, HIST_DFL);
+ if ((query = chan_get(&server->queries, *(msg->params+2), -1)) != NULL) {
+ hist_addp(query->history, msg, Activity_status, HIST_DFL);
hist_addp(server->history, msg, Activity_status, HIST_LOG);
} else {
hist_addp(server->history, msg, Activity_status, HIST_DFL);
diff --git a/src/hirc.h b/src/hirc.h
@@ -71,9 +71,9 @@ char * wctos(wchar_t *str);
/* chan.c */
void chan_free(struct Channel *channel);
void chan_free_list(struct Channel **head);
-struct Channel *chan_create(struct Server *server, char *name, int priv);
+struct Channel *chan_create(struct Server *server, char *name, int query);
struct Channel *chan_get(struct Channel **head, char *name, int old);
-struct Channel *chan_add(struct Server *server, struct Channel **head, char *name, int priv);
+struct Channel *chan_add(struct Server *server, struct Channel **head, char *name, int query);
int chan_isold(struct Channel *channel);
void chan_setold(struct Channel *channel, int old);
/* struct Channel *chan_dup(struct Channel *channel); */
@@ -155,7 +155,7 @@ void ui_draw_input(void);
void ui_draw_nicklist(void);
void ui_draw_buflist(void);
void ui_draw_main(void);
-int ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_privs);
+int ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_queries);
int ui_buflist_get(int num, struct Server **server, struct Channel **chan);
int ui_get_pair(short fg, short bg);
int ui_wprintc(struct Window *window, int lines, char *format, ...);
diff --git a/src/serv.c b/src/serv.c
@@ -48,7 +48,7 @@ serv_free(struct Server *server) {
nick_free(server->self);
hist_free_list(server->history);
chan_free_list(&server->channels);
- chan_free_list(&server->privs);
+ chan_free_list(&server->queries);
prev = server->supports;
p = prev->next;
while (prev) {
@@ -101,7 +101,7 @@ serv_create(char *name, char *host, char *port, char *nick, char *username,
server->history->channel = NULL;
server->history->history = NULL;
server->channels = NULL;
- server->privs = NULL;
+ server->queries = NULL;
server->schedule = NULL;
server->reconnect = 0;
for (i=0; i < Expect_last; i++)
diff --git a/src/struct.h b/src/struct.h
@@ -98,7 +98,7 @@ struct Channel {
char *name;
char *mode;
char *topic;
- int priv;
+ int query;
struct Nick *nicks;
struct HistInfo *history;
struct Server *server;
@@ -180,7 +180,7 @@ struct Server {
struct Nick *self;
struct HistInfo *history;
struct Channel *channels;
- struct Channel *privs;
+ struct Channel *queries;
struct Schedule *schedule;
int reconnect;
char *expect[Expect_last];
diff --git a/src/ui.c b/src/ui.c
@@ -446,7 +446,7 @@ ui_draw_nicklist(void) {
}
int
-ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_privs) {
+ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_queries) {
struct Server *sp;
struct Channel *chp;
int sc, cc, pc;
@@ -454,7 +454,7 @@ ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_privs) {
for (sc = cc = pc = 0, sp = servers; sp; sp = sp->next, sc++) {
for (chp = sp->channels; chp; chp = chp->next, cc++)
;
- for (chp = sp->privs; chp; chp = chp->next, pc++)
+ for (chp = sp->queries; chp; chp = chp->next, pc++)
;
}
@@ -462,7 +462,7 @@ ui_buflist_count(int *ret_servers, int *ret_channels, int *ret_privs) {
*ret_servers = sc;
if (ret_channels)
*ret_channels = cc;
- if (ret_privs)
+ if (ret_queries)
*ret_channels = pc;
return sc + cc + pc + 1;
@@ -502,7 +502,7 @@ ui_buflist_get(int num, struct Server **server, struct Channel **chan) {
return 0;
}
}
- for (chp = sp->privs; chp; chp = chp->next, i++) {
+ for (chp = sp->queries; chp; chp = chp->next, i++) {
if (i == num) {
*server = sp;
*chan = chp;
@@ -568,13 +568,13 @@ ui_draw_buflist(void) {
indicator = format_get_bufact(chp->history->activity);
ui_wprintc(&windows[Win_buflist], 1, "%02d: %s %s─ %s%s\n", i,
- sp->next ? "│" : " ", chp->next || sp->privs ? "├" : "└", indicator, chp->name);
+ sp->next ? "│" : " ", chp->next || sp->queries ? "├" : "└", indicator, chp->name);
wattrset(windows[Win_buflist].window, A_NORMAL);
}
i++;
}
- for (prp = sp->privs; prp && (i - scroll - 1) < windows[Win_buflist].h; prp = prp->next) {
+ for (prp = sp->queries; prp && (i - scroll - 1) < windows[Win_buflist].h; prp = prp->next) {
if (scroll < i - 1) {
if (selected.channel == prp)
wattron(windows[Win_buflist].window, A_BOLD);
@@ -843,7 +843,7 @@ ui_select(struct Server *server, struct Channel *channel) {
selected.server = server;
selected.history = channel ? channel->history : server ? server->history : main_buf;
selected.name = channel ? channel->name : server ? server->name : "hirc";
- selected.hasnicks = channel ? !channel->priv && !channel->old : 0;
+ selected.hasnicks = channel ? !channel->query && !channel->old : 0;
selected.showign = 0;
if (selected.history->unread || selected.history->ignored) {