Skip to content

Commit 9e48d5a

Browse files
committed
add password argument
1 parent 060acb9 commit 9e48d5a

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

README

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ result is a portable <250 sloc application that has no dependencies other
1111
than a C99 compiler.
1212

1313

14+
TODO
15+
----
16+
17+
- [ ] capture CTRL-C for safer child process shutdown
18+
- [ ] better color default color scheme
19+
- [ ] dynamic word wrap based on column width
20+
- [ ] additional shortcut keys
21+
- [ ] fix default arrow key and backspace behavior
22+
23+
1424
FEATURES
1525
--------
1626

@@ -35,10 +45,11 @@ Building and installing from source:
3545
USAGE
3646
-----
3747

38-
usage: kirc [-s hostname] [-p port] [-c channel] [-n nick] [-v|V]
48+
usage: kirc [-s hostname] [-p port] [-c channel] [-n nick] [-k password] [-v|V]
3949
-s server address (default: 'irc.freenode.org')
4050
-p server port (default: '6667')
4151
-c channel name (default: '#kisslinux')
4252
-n user nickname
53+
-n user password
4354
-v version information
4455
-V verbose output (e.g. raw stream)

kirc.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ static char *host = "irc.freenode.org"; /* irc host address */
2222
static char *chan = "kisslinux"; /* channel */
2323
static char *port = "6667"; /* port */
2424
static char *nick = NULL; /* nickname */
25+
static char *pass = NULL; /* password */
2526

2627
static int
2728
kbhit(void) {
29+
2830
int byteswaiting;
2931
struct termios term;
3032
fd_set fds;
@@ -45,6 +47,7 @@ kbhit(void) {
4547

4648
static void
4749
raw(char *fmt, ...) {
50+
4851
va_list ap;
4952

5053
va_start(ap, fmt);
@@ -58,6 +61,7 @@ raw(char *fmt, ...) {
5861

5962
static void
6063
con(void) {
64+
6165
struct addrinfo *res, hints = {
6266
.ai_family = AF_INET,
6367
.ai_socktype = SOCK_STREAM
@@ -69,6 +73,7 @@ con(void) {
6973

7074
if (nick) raw("NICK %s\r\n", nick);
7175
if (nick) raw("USER %s - - :%s\r\n", nick, nick);
76+
if (pass) raw("PASS %s\r\n", pass);
7277

7378
fcntl(conn, F_SETFL, O_NONBLOCK);
7479
}
@@ -83,13 +88,17 @@ printw(const char *format, ...) {
8388
va_start(argptr, format);
8489
vsnprintf(line, BUFF + 1, format, argptr);
8590
va_end(argptr);
91+
8692
if (strlen(line) <= CMAX) printf("%s", line);
8793
else if (strlen(line) > CMAX) {
94+
8895
for (i = 0; i < CMAX; i++) {
8996
if (line[i] == ' ') s1 = i;
9097
if (i == CMAX - 1) printf("%-*.*s\n", s1, s1, line);
9198
}
99+
92100
s2 = o = s1;
101+
93102
for (i = s1; line[i] != '\0'; i++) {
94103
if (line[i] == ' ') s2 = i;
95104
if ((i - o) == (CMAX - GUTL)) {
@@ -141,8 +150,7 @@ pars(int sl, char *buf) {
141150
GUTL, GUTL, "-->", nic, cha);
142151
}
143152
else {
144-
printw("\x1b[1m%*.*s\x1b[0m %s\n", \
145-
GUTL, GUTL, nic, msg);
153+
printw("\x1b[1m%*.*s\x1b[0m %s\n", GUTL, GUTL, nic, msg);
146154
}
147155
}
148156
}
@@ -157,11 +165,12 @@ main(int argc, char **argv) {
157165
while ((cval = getopt(argc, argv, "s:p:n:k:c:vV")) != -1) {
158166
switch (cval) {
159167
case 'v' : printf("kirc 0.0.1\n"); break;
160-
case 'V' : verb = 1; break;
161-
case 's' : host = optarg; break;
162-
case 'p' : port = optarg; break;
163-
case 'n' : nick = optarg; break;
164-
case 'c' : chan = optarg; break;
168+
case 'V' : verb = 1; break;
169+
case 's' : host = optarg; break;
170+
case 'p' : port = optarg; break;
171+
case 'n' : nick = optarg; break;
172+
case 'k' : pass = optarg; break;
173+
case 'c' : chan = optarg; break;
165174
case '?' : return 1;
166175
}
167176
}

0 commit comments

Comments
 (0)