changeset 33:e49ea6febfeb

Cleanups. Added option to specify/fake "site" where logging in from.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Aug 2008 08:42:57 +0300
parents 67ec4073e38c
children f5d335771b16
files nnchat.c
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/nnchat.c	Mon Aug 04 06:44:11 2008 +0300
+++ b/nnchat.c	Tue Aug 05 08:42:57 2008 +0300
@@ -29,7 +29,8 @@
 		*optUserName2 = NULL,
 		*optPassword = NULL,
 		*optLogFilename = NULL,
-		*setTarget = NULL;
+		*setTarget = NULL,
+		*optSite = "NN";
 BOOL	optDaemon = FALSE;
 FILE	*optLogFile = NULL;
 WINDOW  *mainWin = NULL,
@@ -37,6 +38,7 @@
 		*editWin = NULL;
 BOOL    setPrvMode = FALSE;
 
+
 /* Arguments
  */
 optarg_t optList[] = {
@@ -47,6 +49,7 @@
 	{ 4, 'C', "color",      "Initial color in RGB hex 000000", OPT_ARGREQ },
 	{ 5, 'l', "logfile",    "Log filename", OPT_ARGREQ },
 	{ 6, 'D', "daemon",     "A pseudo-daemon mode for logging", OPT_NONE },
+	{ 7, 'S', "site",       "Site (default: NN)", OPT_ARGREQ },
 };
 
 const int optListN = (sizeof(optList) / sizeof(optarg_t));
@@ -111,6 +114,10 @@
 		optLogFilename = optArg;
 		break;
 
+	case 7:
+		optSite = optArg;
+		break;
+
 	case 6:
 		optDaemon = TRUE;
 		THMSG(1, "Running in pseudo-daemon mode.\n");
@@ -1047,13 +1054,13 @@
 		goto err_exit;
 	}
 	
-	THMSG(1, "Connected, logging in as '%s'.\n", optUserName);
+	THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite);
 	optUserName2 = encodeStr1(optUserName);
+	tmpStr = encodeStr1(optSite);
+	sendUserMsg(tmpSocket, optUserName2, "%%2Flogin%%20%%2Dsite%%20%s%%20%%2Dpassword%%20%s", tmpStr, optPassword);
+	th_free(tmpStr);
 	
-	sendUserMsg(tmpSocket, optUserName2, "%%2Flogin%%20%%2Dsite%%20NN%%20%%2Dpassword%%20%s", optPassword);
-	
-	/* Initialize curses */
-	
+	/* Initialize NCurses */
 	if (!optDaemon) {
 		initscr();
 		raw();
@@ -1243,7 +1250,7 @@
 				break;
 				
 			case 0x111: /* F9 */
-				printMsg("Quitting per user request.");
+				printMsg("Quitting per user request.\n");
 				exitProg = TRUE;
 				break;