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

@ -231,6 +231,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);
createCommandsHelpBox(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, " :");
/* 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)
{
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);