X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Firc_src%2Fmain.c;h=4ca24155e0afb994899b927c777b0afd0f91cb04;hb=94d9540cae85d2f9e145fe4d2986e84b46bbd052;hp=901e8ac1853ee5f6a8c0e1cd8be2879e526d6799;hpb=385aa5c4b5e509d298b3341dcd27ca26c3ce2358;p=tpg%2Facess2.git diff --git a/Usermode/Applications/irc_src/main.c b/Usermode/Applications/irc_src/main.c index 901e8ac1..4ca24155 100644 --- a/Usermode/Applications/irc_src/main.c +++ b/Usermode/Applications/irc_src/main.c @@ -78,7 +78,7 @@ char *gsNickname = "acess"; tServer *gpServers; tWindow gWindow_Status = { NULL, NULL, NULL, // No next, empty list, no server - 0, "" // No activity, empty name (rendered as status) + 0, {""} // No activity, empty name (rendered as status) }; tWindow *gpWindows = &gWindow_Status; tWindow *gpCurrentWindow = &gWindow_Status; @@ -102,8 +102,8 @@ int main(int argc, const char *argv[], const char *envp[]) atexit(ExitHandler); - giTerminal_Width = ioctl(1, 5, NULL); // getset_width - giTerminal_Height = ioctl(1, 6, NULL); // getset_height + giTerminal_Width = _SysIOCtl(1, 5, NULL); // getset_width + giTerminal_Height = _SysIOCtl(1, 6, NULL); // getset_height printf("\x1B[?1047h"); printf("\x1B[%i;%ir", 0, giTerminal_Height-1); @@ -194,7 +194,7 @@ int main(int argc, const char *argv[], const char *envp[]) { tServer *srv; for( srv = gpServers; srv; srv = srv->Next ) - close(srv->FD); + _SysClose(srv->FD); } return 0; } @@ -340,7 +340,7 @@ tMessage *Message_AppendF(tServer *Server, int Type, const char *Source, const c va_list args; int len; va_start(args, Message); - len = vsnprintf(NULL, 1000, Message, args); + len = vsnprintf(NULL, 0, Message, args); { char buf[len+1]; vsnprintf(buf, len+1, Message, args); @@ -578,6 +578,7 @@ void ParseServerLine(tServer *Server, char *Line) Message_Append(Server, MSG_TYPE_SERVER, user, user, message); break; case 372: // MOTD Data + case 375: // MOTD Start case 376: // MOTD End default: @@ -601,6 +602,10 @@ void ParseServerLine(tServer *Server, char *Line) } //printf("[%s] NOTICE %s: %s\n", Server->Name, ident, message); + char *ident_bang = strchr(ident, '!'); + if( ident_bang ) { + *ident_bang = '\0'; + } Message_Append(Server, MSG_TYPE_NOTICE, ident, "", message); } else if( strcmp(cmd, "PRIVMSG") == 0 ) @@ -618,7 +623,10 @@ void ParseServerLine(tServer *Server, char *Line) // TODO: Catch when the privmsg is addressed to the user // Cmd_PRIVMSG(Server, dest, ident, message); - *strchr(ident, '!') = '\0'; // Hello SIGSEGV + char *ident_bang = strchr(ident, '!'); + if( ident_bang ) { + *ident_bang = '\0'; + } Message_Append(Server, MSG_TYPE_STANDARD, ident, dest, message); } else if( strcmp(cmd, "JOIN" ) == 0 ) @@ -659,11 +667,11 @@ int ProcessIncoming(tServer *Server) // ioctl#8 on a TCP client gets the number of bytes in the recieve buffer // - Used to avoid blocking #if NON_BLOCK_READ - while( (len = ioctl(Server->FD, 8, NULL)) > 0 ) + while( (len = _SysIOCtl(Server->FD, 8, NULL)) > 0 ) { #endif // Read data - len = read(Server->FD, &Server->InBuf[Server->ReadPos], BUFSIZ - Server->ReadPos); + len = _SysRead(Server->FD, &Server->InBuf[Server->ReadPos], BUFSIZ - Server->ReadPos); if( len == -1 ) { return -1; } @@ -708,7 +716,7 @@ int writef(int FD, const char *Format, ...) int len; va_start(args, Format); - len = vsnprintf(NULL, 1000, Format, args); + len = vsnprintf(NULL, 0, Format, args); va_end(args); { @@ -717,7 +725,7 @@ int writef(int FD, const char *Format, ...) vsnprintf(buf, len+1, Format, args); va_end(args); - return write(FD, buf, len); + return _SysWrite(FD, buf, len); } } @@ -747,12 +755,12 @@ int OpenTCP(const char *AddressString, short PortNumber) // Set remote port and address // printf("Setting port and remote address\n"); - ioctl(fd, 5, &PortNumber); - ioctl(fd, 6, addrBuffer); + _SysIOCtl(fd, 5, &PortNumber); + _SysIOCtl(fd, 6, addrBuffer); // Connect // printf("Initiating connection\n"); - if( ioctl(fd, 7, NULL) == 0 ) { + if( _SysIOCtl(fd, 7, NULL) == 0 ) { // Shouldn't happen :( fprintf(stderr, "Unable to start connection\n"); return -1; @@ -797,7 +805,7 @@ int SetCursorPos(int Row, int Col) Row = Col / giTerminal_Width; Col = Col % giTerminal_Width; } - rv = ioctl(1, 9, NULL); // Ugh, constants + rv = _SysIOCtl(1, 9, NULL); // Ugh, constants printf("\x1B[%i;%iH", Col, Row); return rv; }