diff --git a/src/interpreter.c b/src/interpreter.c index acea86f..23d4b0e 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -76,24 +76,24 @@ void interpretCommand(char *cmd) } else if (!strcmp(token1, "nick")) { if (strlen(token2) > 0) - { + { renameUserInList(sysState.myNick, token2, userList); - doNick(token2); - } + doNick(token2); + } } else if (!strcmp(token1, "join")) - { - if (strlen(token2) > 0) { - doJoin(token2); - } - } else if (!strcmp(token1, "ns")) - { + if (strlen(token2) > 0) + { + doJoin(token2); + } + } else if (!strcmp(token1, "ns")) + { if (strlen(token2) > 0) doPrivateMsg("nickserv", cmd+token2Start); else appendText("You fool, no message specified\n"); - } else if (!strcmp(token1, "mode")) - { + } else if (!strcmp(token1, "mode")) + { char token4[MAX_INPUT_LEN+1]; char token5[MAX_INPUT_LEN+1]; char token6[MAX_INPUT_LEN+1]; @@ -102,7 +102,7 @@ void interpretCommand(char *cmd) token5[0] = '\0'; token6[0] = '\0'; if (strlen(token2) > 0) - { + { int l; l = 0; cmdCursor++; @@ -113,7 +113,7 @@ void interpretCommand(char *cmd) printf("token3: %s\n", token3); #endif if (cmdCursor < cmdLen) - { + { cmdCursor++; l = 0; while (cmdCursor < cmdLen && cmd[cmdCursor] != ' ') @@ -173,7 +173,7 @@ void interpretCommand(char *cmd) } } else if (!strcmp(token1, "user")) { - doUser(sysState.myUnixname, sysState.myHostName, sysState.serverName, sysState.myName); + doUser(sysState.myUnixname, sysState.myHostName, sysState.serverName, sysState.myName); } else if (!strcmp(token1, "whois")) { if (strlen(token2) > 0) diff --git a/src/main.c b/src/main.c index c2600d4..92353c5 100644 --- a/src/main.c +++ b/src/main.c @@ -230,6 +230,16 @@ int main (int argc, char *argv[]) } strcpy(sysState.myUnixname, tempName); } + + { + /* We need to replace this with code to load the user's nickname as specified in the configuration file. */ + /* We also need to do this for realname, and (perhaps) other elements of the struct, as well. */ + /* What a pain. */ + /* For now we're going to set the nickname to the user's unix username. */ + strcpy(sysState.myNick, getenv("USER")); + + } + /* create unmanaged dialogs */ createAboutBox(mainWindow); diff --git a/src/main.h b/src/main.h index 9b26ba4..7c20fee 100644 --- a/src/main.h +++ b/src/main.h @@ -5,6 +5,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include /* for MAXHOSTNAMELEN */ +#include #define PREF_FILE_NAME ".nebula.rc" diff --git a/src/network.c b/src/network.c index ac443ce..db3f73b 100644 --- a/src/network.c +++ b/src/network.c @@ -77,8 +77,9 @@ int connectToServer(char *servName, int port) /* we add our socket to the select file descriptors as an Event source for X */ nebulaNetworkEventId = XtAppAddInput(nebulaIrcAppContext, sysState.socket, (XtPointer)(XtInputReadMask), readLine, NULL); - doNick(sysState.myNick); doUser(sysState.myUnixname, sysState.myHostName, sysState.serverName, sysState.myName); + printf("nick: %s\n", sysState.myNick); + doNick(sysState.myNick); return 0; } @@ -321,7 +322,17 @@ void doUser(char *username, char *hostname, char *servername, char *realname) strcat(outBuff, " "); strcat(outBuff, servername); strcat(outBuff, " :"); - strcat(outBuff, realname); + /* Right now, realname is never set. We need to fix that in main(). */ + /* Anyway, using the user's username as a realname when realname isn't set should be fine. */ + /* It's a hell of a lot better than fighting with cryptic error messages, that's for sure. */ + if(strlen(realname)) + { + strcat(outBuff, realname); + } + else + { + strcat(outBuff, username); + } printf("sending: %s\n", outBuff); sendLine(outBuff); } diff --git a/src/preferences.c b/src/preferences.c index 2efb560..a6e67d5 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -57,22 +57,29 @@ void okButtStartupCbk() if (strlen(nick) > 0 && strlen(nick) <= MAX_NICK_LEN) strcpy(sysState.myNick, nick); else - strcpy(sysState.myNick, ""); + strcpy(sysState.myNick, "johndoe"); if (strlen(name) > 0 && strlen(name) <= MAX_NAME_LEN) - strcpy(sysState.myName, name); + { + printf("first branch of name set: %s\n", name); + strcpy(sysState.myName, name); + } else - strcpy(sysState.myName, "noname"); + { + printf("second branch of name set: %s\n", name); + strcpy(sysState.myName, "John Doe"); + } if (strlen(server) > 0 &&strlen(server) <= MAX_SERVERNAME_LEN) strcpy(theServer, server); else - strcpy(theServer, ""); + strcpy(theServer, "*"); printf("port: %s, %d\n", port, atoi(port)); if (strlen(port) > 0 && strlen(port) <= 5) { sysState.port = atoi(port); if (sysState.port <= 0) sysState.port = 6666; - } else + } + else sysState.port = 6666; connectToServer(theServer, sysState.port);