Exemplo n.º 1
0
void askUser()
{
	char choice;
	int x;
	int loop;
	
	system("cls");
	printf("---MAIN MENU---\n");
	printf("\n[1]-ENTER STRING\n[2]-DISPLAY\n[3]-SORT\n\n");
	choice=getch();

	switch(choice)
	{
		case '1':
			printf("How many number(s)?");
			scanf("%d",&loop);
			
			for(x=0;x<loop;x++)
				askStr();
				
			getch();
			askUser();
			break;
		case '2':
			displayMenu();
			getch();
			askUser();
			break;
		case '3':
			sortMenu();
			getch();
			askUser();
			break;
		default:
			getch();
			break;	
	}	
}
Exemplo n.º 2
0
void options_cpu (void)
{
	unsigned int day_memory, night_memory, day_start_time, day_end_time;
	unsigned long m_hours, m_day_memory, m_night_memory, max_mem;
	int	m_memory_editable;
	char m_start_time[13];
	char m_end_time[13];
	char buf[512];

	m_memory_editable =
		read_memory_settings (&day_memory, &night_memory,
				      &day_start_time, &day_end_time);
//again:
	m_hours = CPU_HOURS;
	m_day_memory = day_memory;
	m_night_memory = night_memory;
	minutesToStr (day_start_time, m_start_time);
	minutesToStr (day_end_time, m_end_time);

	askNum ("Hours per day this program will run", &m_hours, 1, 24);

	printf ("\nPlease see the readme.txt file for important\n");
	printf ("information on the P-1/ECM stage 2 memory settings.\n\n");

	if (m_memory_editable) {
		max_mem = physical_memory () - 8;
		if (max_mem < 8) max_mem = 8;
		askNum ("Daytime P-1/ECM stage 2 memory in MB", &m_day_memory, 8, max_mem);
		askNum ("Nighttime P-1/ECM stage 2 memory in MB", &m_night_memory, 8, max_mem);
		if (m_day_memory != m_night_memory) {
			askStr ("Daytime begins at", (char *) &m_start_time, 12);
			askStr ("Daytime ends at", (char *) &m_end_time, 12);
		}
	}

	getCpuDescription (buf, 0);
	printf ("\nCPU Information:\n%s\n", buf);

	if (askOkCancel ()) {
		unsigned int new_day_start_time, new_day_end_time;

		if (CPU_HOURS != m_hours) {
			CPU_HOURS = m_hours;
			IniWriteInt (LOCALINI_FILE, "CPUHours", CPU_HOURS);
			ROLLING_AVERAGE = 1000;
			IniWriteInt (LOCALINI_FILE, "RollingAverage", 1000);
			IniWriteInt (LOCALINI_FILE, "RollingStartTime", 0);
			spoolMessage (PRIMENET_UPDATE_COMPUTER_INFO, NULL);
			delete_timed_event (TE_COMM_SERVER);
			UpdateEndDates ();
		}
		new_day_start_time = strToMinutes ((char *) &m_start_time);
		new_day_end_time = strToMinutes ((char *) &m_end_time);
		if (m_memory_editable &&
		    (day_memory != m_day_memory ||
		     night_memory != m_night_memory ||
		     day_start_time != new_day_start_time ||
		     day_end_time != new_day_end_time)) {
			write_memory_settings (m_day_memory, m_night_memory,
					       new_day_start_time, new_day_end_time);
			mem_settings_have_changed ();
		}
		spoolMessage (PRIMENET_PROGRAM_OPTIONS, NULL);

// Now that Primenet almost always hands out LL assignments that are P-1'ed,
// there is little reason to prompt user into allowing us to use more memory.
//		if (!IniGetInt (INI_FILE, "AskedAboutMemory", 0)) {
//			IniWriteInt (INI_FILE, "AskedAboutMemory", 1);
//			if (m_day_memory == 8 && m_night_memory == 8) {
//				outputLongLine (MSG_MEMORY);
//				if (askYesNo ('Y')) goto again;
//			}
//		}
	} else
		STARTUP_IN_PROGRESS = 0;
}
Exemplo n.º 3
0
void test_primenet (void)
{
	int	m_primenet, m_dialup;
	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];
	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;
	else
		strcpy (m_userid, USERID);
	strcpy (m_compid, COMPID);
	m_dialup = DIAL_UP;
	getProxyInfo (m_proxy_host, &proxy_port, m_proxy_user, m_proxy_pwd);
	m_proxy_port = proxy_port;
	strcpy (orig_proxy_pwd, m_proxy_pwd);
	m_debug = primenet_debug;

	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 mersenne.org or leave user ID blank to run anonymously.  See the readme.txt file for details.\n");
	askStr ("Optional user ID", 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);
	askNum ("Output debug info to prime.log (0=none, 1=some, 2=lots)", &m_debug, 0, 2);

done:	if (askOkCancel ()) {
		DIAL_UP = m_dialup;
		IniWriteInt (INI_FILE, "DialUp", DIAL_UP);

		if (m_proxy_host[0] && m_proxy_port != 8080)
			sprintf (m_proxy_host + strlen (m_proxy_host), ":%lu", m_proxy_port);
		IniSectionWriteString (INI_FILE, "PrimeNet", "ProxyHost", m_proxy_host);
		if (m_proxy_host[0]) {
			IniSectionWriteString (INI_FILE, "PrimeNet", "ProxyUser", m_proxy_user);
			if (strcmp (m_proxy_pwd, orig_proxy_pwd)) {
				IniSectionWriteString (INI_FILE, "PrimeNet",
					"ProxyPass", m_proxy_pwd);
				IniSectionWriteInt (INI_FILE, "PrimeNet",
					"ProxyMask", 0);
			}
		}
		if (m_debug != primenet_debug) {
			IniSectionWriteInt (INI_FILE, "PrimeNet", "Debug",
					    m_debug);
		}

		if (m_userid[0] == 0)
			strcpy (m_userid, "ANONYMOUS");

		if (strcmp (USERID, m_userid) != 0) {
			strcpy (USERID, m_userid);
			sanitizeString (USERID);
			IniWriteString (INI_FILE, "V5UserID", USERID);
			update_computer_info = TRUE;
		}
		if (strcmp (COMPID, m_compid) != 0) {
			strcpy (COMPID, m_compid);
			sanitizeString (COMPID);
			IniWriteString (LOCALINI_FILE, "ComputerID", COMPID);
			update_computer_info = TRUE;
		}

		if (!USE_PRIMENET && m_primenet) {
			USE_PRIMENET = 1;
			create_window (COMM_THREAD_NUM);
			base_title (COMM_THREAD_NUM, "Communication thread");
			if (!STARTUP_IN_PROGRESS) set_comm_timers ();
			spoolMessage (PRIMENET_UPDATE_COMPUTER_INFO, NULL);
			spoolExistingResultsFile ();
		} else if (USE_PRIMENET && !m_primenet) {
			USE_PRIMENET = 0;
			if (!STARTUP_IN_PROGRESS) set_comm_timers ();
		} else if (update_computer_info)
			spoolMessage (PRIMENET_UPDATE_COMPUTER_INFO, NULL);

		IniWriteInt (INI_FILE, "UsePrimenet", USE_PRIMENET);
		spoolMessage (PRIMENET_PROGRAM_OPTIONS, NULL);
	} else
		STARTUP_IN_PROGRESS = 0;
}