Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PASS (--pass) and related stuff, also call termsize() at startup

  • Loading branch information...
commit b5829d68d3ab5dfc8566505c5ce00c4770f37ee0 1 parent 44b847a
ec429 authored
View
34 config.c
@@ -108,6 +108,12 @@ int def_config(void)
{
#include "config_def.c"
autojoin=true;
+ int l, c;
+ if(!termsize(STDIN_FILENO, &c, &l))
+ {
+ height=max(l, 5);
+ width=max(c, 30);
+ }
char *cols=getenv("COLUMNS"), *rows=getenv("LINES");
if(cols) sscanf(cols, "%u", &width);
if(rows) sscanf(rows, "%u", &height);
@@ -119,6 +125,7 @@ int def_config(void)
fname=malloc(64+strlen(VERSION_TXT));
nick=strdup(eu?eu:"ac");
defnick=true;
+ pass=NULL;
snprintf(fname, 64+strlen(VERSION_TXT), "quIRC %hhu.%hhu.%hhu%s%s : http://github.com/ec429/quIRC", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
version=malloc(16+strlen(VERSION_TXT));
snprintf(version, 16+strlen(VERSION_TXT), "%hhu.%hhu.%hhu%s%s", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
@@ -233,6 +240,7 @@ int rcread(FILE *rcfp)
new->name=strdup(rest);
new->nick=strdup(nick);
new->portno=strdup(portno);
+ new->pass=pass?strdup(pass):NULL;
new->join=false;
new->chans=NULL;
new->igns=NULL;
@@ -240,11 +248,24 @@ int rcread(FILE *rcfp)
}
else if(servs && (strcmp(cmd, "*port")==0))
{
- if(servs->portno) free(servs->portno);
+ free(servs->portno);
servs->portno=strdup(rest);
}
else if(strcmp(cmd, "port")==0)
+ {
+ free(portno);
portno=strdup(rest);
+ }
+ else if(strcmp(cmd, "pass")==0)
+ {
+ free(pass);
+ pass=strdup(rest);
+ }
+ else if(servs && (strcmp(cmd, "*pass")==0))
+ {
+ free(servs->pass);
+ servs->pass=strdup(rest);
+ }
else if(strcmp(cmd, "uname")==0)
{
username=strdup(rest);
@@ -255,14 +276,18 @@ int rcread(FILE *rcfp)
}
}
else if(strcmp(cmd, "fname")==0)
+ {
+ free(fname);
fname=strdup(rest);
+ }
else if(servs && (strcmp(cmd, "*nick")==0))
{
- if(servs->nick) free(servs->nick);
+ free(servs->nick);
servs->nick=strdup(rest);
}
else if(strcmp(cmd, "nick")==0)
{
+ free(nick);
nick=strdup(rest);
defnick=false;
}
@@ -442,6 +467,11 @@ signed int pargs(int argc, char *argv[])
free(portno);
portno=strdup(argv[arg]+7);
}
+ else if(strncmp(argv[arg], "--pass=", 7)==0)
+ {
+ free(pass);
+ pass=strdup(argv[arg]+7);
+ }
else if(strncmp(argv[arg], "--uname=", 8)==0)
{
free(username);
View
3  config.h
@@ -26,6 +26,7 @@ typedef struct _servlist
char *name;
char *portno;
char *nick;
+ char *pass;
bool join;
chanlist *chans;
struct _servlist *next;
@@ -44,7 +45,7 @@ servlist;
// global settings & state
#include "config_globals.h"
bool autojoin;
-char *username, *fname, *nick, *portno;
+char *username, *fname, *nick, *pass, *portno;
bool defnick;
servlist *servs;
name *igns;
View
11 irc.c
@@ -76,7 +76,7 @@ int irc_connect(char *server, char *portno, fd_set *master, int *fdmax)
return(serverhandle);
}
-int irc_conn_rest(int b, char *nick, char *username, char *fullname)
+int irc_conn_rest(int b, char *nick, char *username, char *passwd, char *fullname)
{
if(debug)
{
@@ -88,7 +88,14 @@ int irc_conn_rest(int b, char *nick, char *username, char *fullname)
bufs[b].last=time(NULL);
if(bufs[b].autoent && bufs[b].autoent->nick)
nick=bufs[b].autoent->nick;
- // TODO: Optionally send a PASS message before the NICK/USER
+ if(bufs[b].autoent && bufs[b].autoent->pass)
+ passwd=bufs[b].autoent->pass;
+ if(passwd) // Optionally send a PASS message before the NICK/USER
+ {
+ char passmsg[6+strlen(passwd)];
+ sprintf(passmsg, "PASS %s", passwd); // PASS <password>
+ irc_tx(bufs[b].handle, passmsg);
+ }
char nickmsg[6+strlen(nick)];
sprintf(nickmsg, "NICK %s", nick); // NICK <nickname>
irc_tx(bufs[b].handle, nickmsg);
View
2  irc.h
@@ -54,7 +54,7 @@ volatile sig_atomic_t sigpipe, sigwinch;
void handle_sigpipe(int); // handles both sigpipe and sigwinch
int irc_connect(char *server, char *portno, fd_set *master, int *fdmax); // non-blocking
-int irc_conn_rest(int b, char *nick, char *username, char *fullname); // call this when the non-blocking connect() has finished
+int irc_conn_rest(int b, char *nick, char *username, char *passwd, char *fullname); // call this when the non-blocking connect() has finished
int autoconnect(fd_set *master, int *fdmax, servlist *serv);
int irc_tx(int fd, char * packet);
int irc_rx(int fd, char ** data);
View
4 plans
@@ -4,7 +4,7 @@ Scripting language. Under development in branch 'script'.
curses. The current hardwired ANSI-escapes code for painting the screen is clumsy. However, it's tailored to my needs, and now that it's neatly packaged away, it should be easier to cope with. So, I may just stick with it.
-PASS (auto-send during connect time). Also need to fix the problem of the conn_rest not getting called for eg worldofspectrum (why is this happening?)
+Need to fix the problem of the conn_rest not getting called for eg worldofspectrum (why is this happening?)
Fix possible issue with CTCP. Funny stuff (including random characters) happened when eg spike1 sent a CTCP PONG to the channel.
@@ -12,8 +12,6 @@ Fix issue with an infinite loop in irc_rx of bytes==0 from recv(). Don't fully
/set uname (and fname) at runtime.
---uname should set the default nick.
-
Make hidden lines (quiet mode, conference mode, etc.) be stored in scrollback. Filter on render; that way changes are retroactive.
Find a way to make getaddrinfo() calls asynch. They currently block everything on connect, which means that /server can cause existing connections to ping off.
View
2  quirc.c
@@ -403,7 +403,7 @@ int main(int argc, char *argv[])
}
else if(bufs[b].conninpr)
{
- irc_conn_rest(b, nick, username, fname);
+ irc_conn_rest(b, nick, username, pass, fname);
}
else
{
View
2  text.h
@@ -17,4 +17,4 @@
There is NO WARRANTY, to the extent permitted by law.\n\
Compiler was %s\n", "quirc", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT, CC_VERSION
-#define USAGE_MSG "quirc [--no-server] [--no-chan] [--check] [--server=<server>] [--uname=<uname>]\n [--fname=<fname>] [--nick=<nick>] [--chan=<chan>] [--port=<port>] [options]\nquirc {-h|--help|-V|--version}\n"
+#define USAGE_MSG "quirc [--no-server] [--no-chan] [--check] [--server=<server>] [--uname=<uname>]\n [--fname=<fname>] [--nick=<nick>] [--chan=<chan>] [--port=<port>]\n [--pass=<pass>] [options]\nquirc {-h|--help|-V|--version}\n"
Please sign in to comment.
Something went wrong with that request. Please try again.