Go Back > Great Internet Mersenne Prime Search > Software

Thread Tools
Old 2017-03-01, 16:22   #1
May 2014

3·11 Posts
Default [Patch] "Test/Primenet" prompts improvements on console version

The askStr() function in Linux / OS X console builds work differently
than a GUI textbox. Specifically it doesn't yet allow inputting empty
strings (really!). If you press Enter without typing anything (not even
a whitespace), askStr() will assume the default value that has been
present in the original buffer.

Since we cannot have empty fields in here. Questions about optional
text fields have to be worked around.

This patch changes these:

1. In the user ID question, the user will now have to explicity type
"ANONYMOUS" to run anonymously. The "ANONYMOUS" value will be the
default upon the first time the user starts mprime, so that the flow
isn't changed for anonymous people setting up mprime. What's added is
that user may now re-login as ANONYMOUS by explicitly typing the name.

2. A "Use a proxy server?" Yes/No question has been added before asking
the proxy host name. This now allows users to disable proxy server.
Previously user will have to edit the INI to remove the ProxyHost field.

3. Fix "proxy user name" and "proxy password" prompts' off-by-one.

4. Limit the length of "proxy host name" prompt to 79. Sorry, this is
the limit on the get_line() function and the console. And I don't think
it's wise to expand the get_line() function buffer to above 80.

5. Ask "Output debug info to prime.log" even when proxy server is
disabled. (It didn't ask previously and it's a bug)

diff -r -u -p a/linux/menu.c b/linux/menu.c
--- a/linux/menu.c	2016-09-15 10:15:10.000000000 +0800
+++ b/linux/menu.c	2017-03-01 23:33:18.226177357 +0800
@@ -287,20 +287,19 @@
 void test_primenet (void)
-	int	m_primenet, m_dialup;
+	int	m_primenet, m_dialup, m_use_proxy;
 	unsigned long m_proxy_port, m_debug;
-	char	m_userid[21], m_compid[21], m_proxy_host[121];
-	char	m_proxy_user[51], m_proxy_pwd[51], orig_proxy_pwd[51];
+	char	m_userid[21], m_compid[21], m_proxy_host[120];
+	char	m_proxy_user[50], m_proxy_pwd[50], orig_proxy_pwd[50];
 	unsigned short proxy_port;
 	int	update_computer_info, primenet_debug;
-	char	m_username[81], m_userpwd[14];
 	update_computer_info = FALSE;
 	primenet_debug = IniSectionGetInt (INI_FILE, "PrimeNet", "Debug", 0);
 	m_primenet = USE_PRIMENET;
-	if (strcmp (USERID, "ANONYMOUS") == 0)
-		m_userid[0] = 0;
+	if (USERID[0] == 0)
+		strcpy (m_userid, "ANONYMOUS");
 		strcpy (m_userid, USERID);
 	strcpy (m_compid, COMPID);
@@ -313,18 +312,26 @@ void test_primenet (void)
 	askYN ("Use PrimeNet to get work and report results", &m_primenet);
 	if (!m_primenet) goto done;
-	outputLongLine ("\nYou must first create your user ID at or leave user ID blank to run anonymously.  See the readme.txt file for details.\n");
-	askStr ("Optional user ID", m_userid, 20);
+	printf ("\nCreate a user account at\n"
+		"You may join GIMPS with anonymous ID but it's not recommended.\n"
+		"See the readme.txt file for details.\n");
+	askStr ("User ID, or \"ANONYMOUS\"", m_userid, 20);
 	askStr ("Optional computer name", m_compid, 20);
 	askYN ("Computer uses a dial-up connection to the Internet", &m_dialup);
-	askStr ("Optional proxy host name", m_proxy_host, 120);
-	if (!m_proxy_host[0]) goto done;
-	askNum ("Proxy port number", &m_proxy_port, 1, 65535);
-	askStr ("Optional proxy user name", m_proxy_user, 50);
-	askStr ("Optional proxy password", m_proxy_pwd, 50);
+	askYN ("Use a proxy server", &m_use_proxy);
+	if (m_use_proxy) {
+		/* Sorry but we can only ask for up to 79 chars for this */
+		/* field on the console. User that needs a longer host name */
+		/* have to write it in INI directly. */
+		askStr ("Proxy host name", m_proxy_host, 79);
+		askNum ("Proxy port number", &m_proxy_port, 1, 65535);
+		askStr ("Optional proxy user name", m_proxy_user, 49);
+		askStr ("Optional proxy password", m_proxy_pwd, 49);
+	} else {
+		m_proxy_host[0] = 0;
+	}
 	askNum ("Output debug info to prime.log (0=none, 1=some, 2=lots)", &m_debug, 0, 2);
 done:	if (askOkCancel ()) {
@@ -348,9 +355,6 @@ void test_primenet (void)
-		if (m_userid[0] == 0)
-			strcpy (m_userid, "ANONYMOUS");
 		if (strcmp (USERID, m_userid) != 0) {
 			strcpy (USERID, m_userid);
 			sanitizeString (USERID);
Attached Files
File Type: txt mprime-test-primenet-console.patch.txt (12.5 KB, 214 views)
Explorer09 is offline   Reply With Quote
Old 2017-03-08, 02:14   #2
P90 years forever!
Prime95's Avatar
Aug 2002
Yeehaw, FL

52·307 Posts

Fixed pretty much as suggested.

Note that fields like optional computer name have the same problem, once you've given a value for the computer name you change it to <blank>.
Prime95 is online now   Reply With Quote
Old 2017-03-09, 04:14   #3
May 2014

3×11 Posts

Originally Posted by Prime95 View Post
Fixed pretty much as suggested.

Note that fields like optional computer name have the same problem, once you've given a value for the computer name you change it to <blank>.
Thank you.

Regarding the computer name, I'm not sure how much effect it can have by setting it to blank, and I think having a Yes/No question before prompting the computer name would be overkill, hence I have no fix suggestions for now.
Explorer09 is offline   Reply With Quote

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
GQQ: a "deterministic" "primality" test in O(ln n)^2 Chair Zhuang Miscellaneous Math 21 2018-03-26 22:33
Aouessare-El Haddouchi-Essaaidi "test": "if Mp has no factor, it is prime!" wildrabbitt Miscellaneous Math 11 2015-03-06 08:17
"Attention all Windows users: patch your systems now" cheesehead Soap Box 6 2012-06-16 18:15
P-1 B1/B2 selection with "Test=" vs "Pfactor=" James Heinrich Software 2 2005-03-19 21:58
Primenet individual account report "current iteration" Peter Nelson PrimeNet 7 2005-02-15 00:12

All times are UTC. The time now is 23:18.

Sun Nov 28 23:18:17 UTC 2021 up 128 days, 17:47, 0 users, load averages: 1.03, 1.06, 1.12

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.