indents
This commit is contained in:
122
ii.c
122
ii.c
@@ -118,7 +118,7 @@ static void add_channel(char *name)
|
|||||||
if(!strcmp(name, c->name))
|
if(!strcmp(name, c->name))
|
||||||
return; /* already handled */
|
return; /* already handled */
|
||||||
|
|
||||||
fd = open_channel(name);
|
fd = open_channel(name);
|
||||||
if(fd == -1) {
|
if(fd == -1) {
|
||||||
perror("ii: cannot create in channel");
|
perror("ii: cannot create in channel");
|
||||||
return;
|
return;
|
||||||
@@ -156,11 +156,11 @@ static void login(char *key, char *fullname)
|
|||||||
{
|
{
|
||||||
if(key)
|
if(key)
|
||||||
snprintf(message, PIPE_BUF,
|
snprintf(message, PIPE_BUF,
|
||||||
"PASS %s\r\nNICK %s\r\nUSER %s localhost %s :%s\r\n", key,
|
"PASS %s\r\nNICK %s\r\nUSER %s localhost %s :%s\r\n", key,
|
||||||
nick, nick, host, fullname ? fullname : nick);
|
nick, nick, host, fullname ? fullname : nick);
|
||||||
else
|
else
|
||||||
snprintf(message, PIPE_BUF, "NICK %s\r\nUSER %s localhost %s :%s\r\n",
|
snprintf(message, PIPE_BUF, "NICK %s\r\nUSER %s localhost %s :%s\r\n",
|
||||||
nick, nick, host, fullname ? fullname : nick);
|
nick, nick, host, fullname ? fullname : nick);
|
||||||
write(irc, message, strlen(message)); /* login */
|
write(irc, message, strlen(message)); /* login */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,54 +244,54 @@ static void proc_channels_input(Channel *c, char *buf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (buf[1]) {
|
switch (buf[1]) {
|
||||||
case 'j':
|
case 'j':
|
||||||
p = strchr(&buf[3], ' ');
|
p = strchr(&buf[3], ' ');
|
||||||
if(p) *p = 0;
|
if(p) *p = 0;
|
||||||
if((buf[3]=='#')||(buf[3]=='&')||(buf[3]=='+')||(buf[3]=='!')){
|
if((buf[3]=='#')||(buf[3]=='&')||(buf[3]=='+')||(buf[3]=='!')){
|
||||||
snprintf(message, PIPE_BUF, "JOIN %s\r\n", &buf[3]);
|
snprintf(message, PIPE_BUF, "JOIN %s\r\n", &buf[3]);
|
||||||
add_channel(&buf[3]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(p){
|
|
||||||
add_channel(&buf[3]);
|
add_channel(&buf[3]);
|
||||||
proc_channels_privmsg(&buf[3], p + 1);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
else{
|
||||||
break;
|
if(p){
|
||||||
case 't':
|
add_channel(&buf[3]);
|
||||||
snprintf(message, PIPE_BUF, "TOPIC %s :%s\r\n", c->name, &buf[3]);
|
proc_channels_privmsg(&buf[3], p + 1);
|
||||||
break;
|
return;
|
||||||
case 'a':
|
}
|
||||||
snprintf(message, PIPE_BUF, "-!- %s is away \"%s\"", nick, &buf[3]);
|
}
|
||||||
print_out(c->name, message);
|
break;
|
||||||
if(buf[2] == 0)
|
case 't':
|
||||||
snprintf(message, PIPE_BUF, "AWAY\r\n");
|
snprintf(message, PIPE_BUF, "TOPIC %s :%s\r\n", c->name, &buf[3]);
|
||||||
else
|
break;
|
||||||
snprintf(message, PIPE_BUF, "AWAY :%s\r\n", &buf[3]);
|
case 'a':
|
||||||
break;
|
snprintf(message, PIPE_BUF, "-!- %s is away \"%s\"", nick, &buf[3]);
|
||||||
case 'n':
|
print_out(c->name, message);
|
||||||
snprintf(nick, sizeof(nick),"%s", &buf[3]);
|
if(buf[2] == 0)
|
||||||
snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]);
|
snprintf(message, PIPE_BUF, "AWAY\r\n");
|
||||||
break;
|
else
|
||||||
case 'l':
|
snprintf(message, PIPE_BUF, "AWAY :%s\r\n", &buf[3]);
|
||||||
if(c->name[0] == 0)
|
break;
|
||||||
|
case 'n':
|
||||||
|
snprintf(nick, sizeof(nick),"%s", &buf[3]);
|
||||||
|
snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
if(c->name[0] == 0)
|
||||||
|
return;
|
||||||
|
if(buf[2] == ' ')
|
||||||
|
snprintf(message, PIPE_BUF, "PART %s :%s\r\n", c->name, &buf[3]);
|
||||||
|
else
|
||||||
|
snprintf(message, PIPE_BUF,
|
||||||
|
"PART %s :ii - 500SLOC are too much\r\n", c->name);
|
||||||
|
write(irc, message, strlen(message));
|
||||||
|
close(c->fd);
|
||||||
|
create_filepath(infile, sizeof(infile), c->name, "in");
|
||||||
|
unlink(infile);
|
||||||
|
rm_channel(c);
|
||||||
return;
|
return;
|
||||||
if(buf[2] == ' ')
|
break;
|
||||||
snprintf(message, PIPE_BUF, "PART %s :%s\r\n", c->name, &buf[3]);
|
default:
|
||||||
else
|
snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
|
||||||
snprintf(message, PIPE_BUF,
|
break;
|
||||||
"PART %s :ii - 500SLOC are too much\r\n", c->name);
|
|
||||||
write(irc, message, strlen(message));
|
|
||||||
close(c->fd);
|
|
||||||
create_filepath(infile, sizeof(infile), c->name, "in");
|
|
||||||
unlink(infile);
|
|
||||||
rm_channel(c);
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
write(irc, message, strlen(message));
|
write(irc, message, strlen(message));
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ static void proc_server_cmd(char *buf)
|
|||||||
or NUL or CR or LF, the first of which may not be ':'>
|
or NUL or CR or LF, the first of which may not be ':'>
|
||||||
<trailing> ::= <Any, possibly *empty*, sequence of octets not including NUL or CR or LF>
|
<trailing> ::= <Any, possibly *empty*, sequence of octets not including NUL or CR or LF>
|
||||||
<crlf> ::= CR LF
|
<crlf> ::= CR LF
|
||||||
*/
|
*/
|
||||||
if(buf[0] == ':') { /* check prefix */
|
if(buf[0] == ':') { /* check prefix */
|
||||||
if (!(p = strchr(buf, ' '))) return;
|
if (!(p = strchr(buf, ' '))) return;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
@@ -356,8 +356,8 @@ static void proc_server_cmd(char *buf)
|
|||||||
else if(!strncmp("JOIN", argv[TOK_CMD], 5)) {
|
else if(!strncmp("JOIN", argv[TOK_CMD], 5)) {
|
||||||
if(argv[TOK_TEXT]!=nil){
|
if(argv[TOK_TEXT]!=nil){
|
||||||
p = strchr(argv[TOK_TEXT], ' ');
|
p = strchr(argv[TOK_TEXT], ' ');
|
||||||
if(p)
|
if(p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
}
|
}
|
||||||
argv[TOK_CHAN] = argv[TOK_TEXT];
|
argv[TOK_CHAN] = argv[TOK_TEXT];
|
||||||
snprintf(message, PIPE_BUF, "-!- %s(%s) has joined %s", argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_TEXT]);
|
snprintf(message, PIPE_BUF, "-!- %s(%s) has joined %s", argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_TEXT]);
|
||||||
@@ -451,8 +451,8 @@ static void run()
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if(r == 0) {
|
} else if(r == 0) {
|
||||||
if(time(NULL) - last_response >= PING_TIMEOUT) {
|
if(time(NULL) - last_response >= PING_TIMEOUT) {
|
||||||
print_out(NULL, "-!- ii shutting down: ping timeout");
|
print_out(NULL, "-!- ii shutting down: ping timeout");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
write(irc, ping_msg, strlen(ping_msg));
|
write(irc, ping_msg, strlen(ping_msg));
|
||||||
continue;
|
continue;
|
||||||
@@ -488,13 +488,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for(i = 1; (i + 1 < argc) && (argv[i][0] == '-'); i++) {
|
for(i = 1; (i + 1 < argc) && (argv[i][0] == '-'); i++) {
|
||||||
switch (argv[i][1]) {
|
switch (argv[i][1]) {
|
||||||
case 'i': snprintf(prefix,sizeof(prefix),"%s", argv[++i]); break;
|
case 'i': snprintf(prefix,sizeof(prefix),"%s", argv[++i]); break;
|
||||||
case 's': host = argv[++i]; break;
|
case 's': host = argv[++i]; break;
|
||||||
case 'p': port = atoi(argv[++i]); break;
|
case 'p': port = atoi(argv[++i]); break;
|
||||||
case 'n': snprintf(nick,sizeof(nick),"%s", argv[++i]); break;
|
case 'n': snprintf(nick,sizeof(nick),"%s", argv[++i]); break;
|
||||||
case 'k': key = argv[++i]; break;
|
case 'k': key = argv[++i]; break;
|
||||||
case 'f': fullname = argv[++i]; break;
|
case 'f': fullname = argv[++i]; break;
|
||||||
default: usage(); break;
|
default: usage(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irc = tcpopen(port);
|
irc = tcpopen(port);
|
||||||
|
|||||||
Reference in New Issue
Block a user