Rename chan to join

In preparation for multi-channel?
weechat-hashes
Curtis McEnroe 2018-08-10 00:01:35 -04:00
parent 4e1501df41
commit 1a9ae050d6
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 18 additions and 18 deletions

4
chat.c
View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
switch (opt) { switch (opt) {
break; case 'W': webirc = optarg; break; case 'W': webirc = optarg;
break; case 'h': host = strdup(optarg); break; case 'h': host = strdup(optarg);
break; case 'j': chat.chan = strdup(optarg); break; case 'j': chat.join = strdup(optarg);
break; case 'n': chat.nick = strdup(optarg); break; case 'n': chat.nick = strdup(optarg);
break; case 'p': port = optarg; break; case 'p': port = optarg;
break; case 'u': chat.user = strdup(optarg); break; case 'u': chat.user = strdup(optarg);
@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
} }
if (!host) host = prompt("Host: "); if (!host) host = prompt("Host: ");
if (!chat.chan) chat.chan = prompt("Join: "); if (!chat.join) chat.join = prompt("Join: ");
if (!chat.nick) chat.nick = prompt("Name: "); if (!chat.nick) chat.nick = prompt("Name: ");
if (!chat.user) chat.user = strdup(chat.nick); if (!chat.user) chat.user = strdup(chat.nick);

20
chat.h
View File

@ -29,18 +29,9 @@ struct {
bool verbose; bool verbose;
char *nick; char *nick;
char *user; char *user;
char *chan; char *join;
} chat; } chat;
enum {
IRC_BOLD = 002,
IRC_COLOR = 003,
IRC_REVERSE = 026,
IRC_RESET = 017,
IRC_ITALIC = 035,
IRC_UNDERLINE = 037,
};
int ircConnect( int ircConnect(
const char *host, const char *port, const char *pass, const char *webPass const char *host, const char *port, const char *pass, const char *webPass
); );
@ -50,6 +41,15 @@ void ircWrite(const char *ptr, size_t len);
__attribute__((format(printf, 1, 2))) __attribute__((format(printf, 1, 2)))
void ircFmt(const char *format, ...); void ircFmt(const char *format, ...);
enum {
IRC_BOLD = 002,
IRC_COLOR = 003,
IRC_REVERSE = 026,
IRC_RESET = 017,
IRC_ITALIC = 035,
IRC_UNDERLINE = 037,
};
void uiInit(void); void uiInit(void);
void uiHide(void); void uiHide(void);
void uiExit(void); void uiExit(void);

View File

@ -99,7 +99,7 @@ static void handle001(char *prefix, char *params) {
free(chat.nick); free(chat.nick);
chat.nick = strdup(nick); chat.nick = strdup(nick);
} }
ircFmt("JOIN %s\r\n", chat.chan); ircFmt("JOIN %s\r\n", chat.join);
} }
static void handleJoin(char *prefix, char *params) { static void handleJoin(char *prefix, char *params) {
@ -272,7 +272,7 @@ static void handlePrivmsg(char *prefix, char *params) {
static void handleNotice(char *prefix, char *params) { static void handleNotice(char *prefix, char *params) {
char *nick, *user, *chan, *mesg; char *nick, *user, *chan, *mesg;
shift(prefix, &nick, &user, NULL, params, 2, 0, &chan, &mesg); shift(prefix, &nick, &user, NULL, params, 2, 0, &chan, &mesg);
if (strcmp(chan, chat.chan)) return; if (strcmp(chan, chat.join)) return;
uiFmt( uiFmt(
"\3%d-%s-\3 %s", "\3%d-%s-\3 %s",
color(user), nick, mesg color(user), nick, mesg

View File

@ -28,7 +28,7 @@ static void privmsg(bool action, const char *mesg) {
int send; int send;
asprintf( asprintf(
&line, ":%s!%s %nPRIVMSG %s :%s%s%s", &line, ":%s!%s %nPRIVMSG %s :%s%s%s",
chat.nick, chat.user, &send, chat.chan, chat.nick, chat.user, &send, chat.join,
(action ? "\1ACTION " : ""), mesg, (action ? "\1" : "") (action ? "\1ACTION " : ""), mesg, (action ? "\1" : "")
); );
if (!line) err(EX_OSERR, "asprintf"); if (!line) err(EX_OSERR, "asprintf");
@ -54,14 +54,14 @@ static void inputNick(char *params) {
static void inputWho(char *params) { static void inputWho(char *params) {
(void)params; (void)params;
ircFmt("WHO %s\r\n", chat.chan); ircFmt("WHO %s\r\n", chat.join);
} }
static void inputTopic(char *params) { static void inputTopic(char *params) {
if (params) { if (params) {
ircFmt("TOPIC %s :%s\r\n", chat.chan, params); ircFmt("TOPIC %s :%s\r\n", chat.join, params);
} else { } else {
ircFmt("TOPIC %s\r\n", chat.chan); ircFmt("TOPIC %s\r\n", chat.join);
} }
} }