Add a temporary kludge to work around the state struct not being

initialized properly.
This commit is contained in:
Mid Favila 2022-08-21 23:20:27 -04:00
parent 2a49564ca9
commit 2904cd9426
5 changed files with 50 additions and 21 deletions

View File

@ -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)

View File

@ -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);

View File

@ -5,6 +5,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <sys/param.h> /* for MAXHOSTNAMELEN */
#include <netdb.h>
#define PREF_FILE_NAME ".nebula.rc"

View File

@ -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);
}

View File

@ -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);