//////////////////////////////////////////// // AliWin by Edwin C. Hall // // Built to compile using Dev-C++ 4.9.9.2 // // All sources contained within this file // // Provided "As-Is" with no warranty // // Compile and Use at own risk // //////////////////////////////////////////// #include #include #include using namespace std; //defines added here to make source self-contained #define IDC_STATIC 1000 #define IDR_ALIMENU 4000 #define ID_ALIQUEITINI_OPEN 4001 #define ID_FACTMSIEVEPY_OPEN 4002 #define ID_FACTMSIEVEPL_OPEN 4003 #define ID_ALIQUEITLOG_OPEN 4004 #define ID_ALINUMTXT_OPEN 4005 #define ID_CURRENTELF_OPEN 4006 #define ID_FILE_EXIT 4007 #define ID_HELP_HELP 4008 #define ID_HELP_HELP2 4009 #define ID_HELP_HELP3 4033 #define ID_HELP_ABOUT 4010 #define IDD_ABOUT 4011 #define ID_ALIQUEIT_RUN 4012 #define ID_ALIQUEIT_CFG 4013 #define ID_ALIQUEIT_ECM 4014 #define ID_ALIQUEIT_CALL 4015 #define ID_ALIQUEIT_IDLE 4016 #define ID_ALIQUEIT_ONEI 4017 #define ID_ALIQUEIT_NAME 4018 #define ID_ALIQUEIT_XECM 4019 #define ID_ALIQUEIT_NUMBER 4020 #define ID_ALIQUEIT_DIGIT 4021 #define ID_ALIQUEIT_NUM 4022 #define ID_ALIQUEIT_STAT 4023 #define ID_ALIQUEIT_WGET 4024 #define ID_ALIQUEIT_SENDELF 4025 #define ID_ALIQUEIT_ASENDELF 4026 #define ID_ALIRUN_TEXT 4027 #define ID_ALILOG_TEXT 4028 #define ID_MESSAGES 4029 #define ID_TIMER 4030 #define ID_TIMER2 4031 #define ID_CLEAR_BUFFER 4032 //startup and process info for all the createprocess procedures STARTUPINFO info={sizeof(info)}, einfo={sizeof(einfo)}, alinfo={sizeof(alinfo)},\ aiinfo={sizeof(aiinfo)}, pyinfo={sizeof(pyinfo)}, plinfo={sizeof(pyinfo)},\ atinfo={sizeof(atinfo)}, ceinfo={sizeof(ceinfo)}; PROCESS_INFORMATION processInfo, eprocessInfo, alprocessInfo, aiprocessInfo,\ pyprocessInfo, plprocessInfo, atprocessInfo, ceprocessInfo; //variable declarations const char g_szClassName[] = "AliWin"; char* version = "20100526"; char aliNumber[1000][256], currentSize[5], currentIndex[6], status[10], aliDigit[1000][5], CRLF[3]; char buffer[512], alilogBuffer[512], currentelf[256], aliRunBuffer[40000], statBuf[2048] = ""; char aliqueitCall[512], helpMsg[256], elfPrefix[64], aliLog[128], elfTest[256], validateString[512]; char origIndex[5] = "", iniCall[2048] = "\"Notepad.exe\"", logCall[2048] = "\"Notepad.exe\""; char txtCall[2048] = "\"Notepad.exe\"", elfCall[2048] = "\"Notepad.exe\""; char pyCall[2048] = "\"c:\\program files\\Windows NT\\Accessories\\wordpad.exe\""; char plCall[2048] = "\"c:\\program files\\Windows NT\\Accessories\\wordpad.exe\""; char clearEnterButton[12]; char* aliqueitName = "aliqueit"; char* skipECMSw = " -e"; char* idlePriSw = " -p"; char* oneISw = " -q"; DWORD dwBytesRead, logSize = 0, elfSizeH = 0, elfSizeL = 0; BOOL bAliRunning = 0, bECM = 0, elfNew = 0; UINT aliTimer, aliTimer2; HWND alilogText, AliWinHwnd; int configureN = 0, termyn, termynS = 0, temp, lastNumber = 0, timerDelay = 1000*3,\ timerDelay2 = 1000*60*60*4, wgetDelay = 1000*60; streampos logPosition; ifstream elf; ofstream ASVal; WIN32_FIND_DATA FindLogData, FindElfData; HANDLE logFind, elfFind; //structure for options - this was created to make a file save easy // this now includes applications to open files struct switches{ BOOL bSkipECM, bIdlePri, bOneI, bSendI, bCutoff, bXECM, bWGET, bAutoSendElf; char ini[2048], log[2048], txt[2048], elf[2048], py[2048], pl[2048]; BOOL bAcceptance; } sw; //Help Information is displayed in MessageBoxes //The text is included here to keep source fully self-contained char* helpTextPage1 = "AliWin is a crude attempt at a Win32 Graphical Interface \ for the Aliqueit program written by Mikael Klasson. Among the reasons for this \ project are, the further move to full automation by allowing for several numbers \ to be 'queued,' the ability to have aliqueit stop after a chosen number of digits \ has been reached and the ability to continue past that chosen digit size until a \ smaller composite no longer factors under ECM. Aliqueit uses several other \ programs to advance aliqout sequences. Among these programs are GMP-ECM, YAFU, \ Msieve, the ggnfs set of programs and the scripts that further run these.\ \r\r\ Currently, this program is designed to have several directly associated files in \ the same directory as this application. This is the list of files in the \ aliqueit directory after the standard installation, as per the AliWin web page:\ \r\r\ alinum.txt\t\taliqueit.exe\t\taliqueit.log\t\taliqueit.ini\r\ aliqueit.txt\t\tAliWin.cfg\t\tAliWin.exe\t\tecm.exe\r\ factMsieve.pl\t\tfactmsieve.py\t\tfactor.log\t\t\tmsieve.log\r\ session.log\t\tyafu-64k-Win32.exe\ \r\r\ To use WGET communication for retrieval and reporting you will need an active \ Internet connection and to move the following files to the aliqueit directory:\ \r\r\ wget.exe\t\tlibeay32.dll\tlibiconv2.dll\tlibintl3.dll\t\tlibssl32.dll\ \r\r\ In addition to the above files, a current version of Perl or Python is needed for \ the respective factmsieve script. Additionally, the absolute file paths will \ need to be used in the aliqueit.ini and factMsieve.pl/factmsieve.py files. These \ files can be edited from within AliWin, if located in the same directory. If \ alinum.txt is opened, a prompt will appear allowing for reloading the edited list. \ To properly pick up changes, this prompt must only be acknowledged after the \ changes have been saved.\r\ \r\r\ Would you like to review page 2?\ "; char* helpTextPage2 = "On the left of the AliWin window, is a series of buttons \ that will allow opening/editing of the respective files. See below for \ additional information about Alinum.txt. The first three buttons down the right \ side of the window allow you to choose certain options for Aliqueit, such as \ first run ECM skip, the priority and single iteration. The fourth button down \ will allow for aliqueit to continue past the digit cutoff, until all ECM has been \ completed on a cofactor larger than 80% of the original composite. The fifth \ button allows WGET to retrieve the last line from the database, if an active \ Internet connection is availabe and WGET is installed. If no connection is \ available and/or no file exists, Aliqueit simply starts from index 0. Next, is \ an \"Auto send\" button that tells AliWin to automatically send lines to the \ database when either of two conditions is met. These conditions are based on \ time - every four hours, and completion of sequence work. The last button is \ \"Send now\" and immediately sends the current iterations to the database. This \ is done in a separate thread without stopping the running thread of Aliqueit. \ \r\r\ In the center of the display, are listed the current number, status and Aliqueit \ command line. The \"Current #:\" button will cycle through the numbers remaining \ in the list. The \"Status:\" and \"Command Line:\" buttons perform no action. \ Below these are three more buttons. The first will be described later. The \ second and third will Run/Stop Aliqueit, which starts with the displayed number, \ and Edit config, respectively. The area below these buttons displays a list of \ completed numbers while Aliqueit is running. \ \r\r\ The first button, of the three referenced earlier, can either say, \"Enter ## #\" \ or, \"Clear list\" depending on the file Alinum.txt. If the file is not found \ upon starting AliWin, the buton will say \"Enter ## #\" and the area below can be \ used to enter the number and the size to work to. Otherwise, the button will say \ \"Clear list\" and can be used to clear the list of completed numbers.\ \r\r\ Would you like to review page 3?\ "; char* helpTextPage3 = "Additional notes:\r\rThe format for numbers vs. size to \ work to, differs between the alinum.txt file and entering via the \"Enter ## #\" \ routine. For direct entry, use NUMBER SIZE. For the alinum.txt file, use the \ following format:\ \r\r\ Size1 Number1 Number2 Number3\r\ Size2 Number4\r\ Size3 Number5 Number6\r\ Size4 Number2\ \r\r\ Commas can also be used within the Alinum.txt list. For example, an entire line \ of numbers from the 100 digit aliqueit reservations page (or 110) can be copied \ and pasted directly into the file:\ \r\r\ 100 834216, 834264, 834282, 834732, 834762, 834870\r110 37128, 37332, 37620, \ 37632, 37968\ \r\r\ Important Note: Size 0 is a special function, designed to validate elf files. \ By using 0 for the size, the elf files will be checked by Aliqueit and the \ results will be appended to \"ASValidate.txt\" in the current directory. Any \ terminations or errors will show \"validation ended early!\" in the file. For \ an accurate test of the db, remove any local elf files and make sure \"Use WGET \ to retrieve data\" is selected.\ \r\r\ Aliqueit allows adding factors to the command line. To add factors to the call \ for AliWin, place -f ######## (multiple -f ###'s are OK) in the large window \ below the \"Open current elf\" button prior to running Aliqueit. It will then \ run for the next number in the list only.\ \r\r\ If Aliqueit is stopped during its first run on a number that was retrieved from \ the db, it will retrieve it again. This is because Aliqueit removes the final \ incomplete line from the elf file and only that one line is retrieved.\ \r\r\ If Aliqueit doesn't like the elf file, it will sometimes simply skip to the next \ number. It will also do this if it detects a merge. AliWin doesn't detect \ terminations, yet, either, but Aliqueit will stop and move to the next number \ if a termination occurs. In the above cases, the finished number list will show \ it stopped before completion.\ "; //function declarations void terminateAliqueit(HWND hwnd); void cutoffCheck(HWND hwnd); void saveSwitches(); void loadSwitches(); void readElf(HWND hwnd); void getNumbers(HWND hwnd); void makeAliqueitString(HWND hwnd); void startAliqueit(HWND hwnd); void cycleNumbers(HWND hwnd); void clearOrEnter(HWND hwnd); void readAliLog(HWND hwnd); void sendElf(HWND hwnd); void readAliqueitini(HWND hwnd); void sendLogFactors(HWND hwnd); void configure(HWND hwnd); // routine to cycle through configuration options void configure(HWND hwnd){ // MessageBox(hwnd, "configure routine called!", "Tracking/Tracing Message", MB_OK); char* fListpre = "The current program to open"; char* fListpost = " is:"; char fList[512], currentList[10000]; strcpy(fList, CRLF); strcat(fList, fListpre); strcat(fList, CRLF); strcat(fList, CRLF); switch (configureN){ case 1:{ strcpy(currentList, "Following is the current list of applications for the files on the left hand buttons:\r\r"); strcat(currentList, "Aliqueit.ini\t"); strcat(currentList, iniCall); strcat(currentList, "\rfactmsieve.py\t"); strcat(currentList, pyCall); strcat(currentList, "\rfactmsieve.pl\t"); strcat(currentList, plCall); strcat(currentList, "\r"); strcat(currentList, aliLog); strcat(currentList, "\t"); strcat(currentList, logCall); strcat(currentList, "\r"); strcat(currentList, "Alinum.txt\t"); strcat(currentList, txtCall); strcat(currentList, "\r"); strcat(currentList, "current.elf\t"); strcat(currentList, elfCall); strcat(currentList, "\r\rIf you want to change any, simply overwrite the current item when it \r\ appears in the edit box. Then click \"Save config\" to move to the next\r\ item. (Quotes may or may not be necessary.)\r\r\ You can have all files use the same application by chosing Yes,\r\ or, use separate applications by chosing No. Same application for all?"); termyn = MessageBox(hwnd, currentList, "Configuration Routine", MB_YESNOCANCEL); if (termyn == IDCANCEL){ configureN = 0; break; } if (termyn == IDYES){ configureN = 7; SetDlgItemText(hwnd, ID_ALILOG_TEXT, "The following application will be used to open Aliqueit.ini, \ factmsieve.py, factMsieve.pl, Aliqueit.log, Alinum.txt and current.elf:"); SetDlgItemText(hwnd, ID_ALIQUEIT_CFG, "Save config"); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, iniCall); break; } configureN++; SetDlgItemText(hwnd, ID_ALIQUEIT_CFG, "Save config"); } case 2:{ strcat(fList, "aliqueit.ini"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, iniCall); break; } case 3:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, iniCall, 511); strcpy(sw.ini, iniCall); strcat(fList, "factmsieve.py"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, pyCall); break; } case 4:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, pyCall, 511); strcpy(sw.py, pyCall); strcat(fList, "factMsieve.pl"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, plCall); break; } case 5:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, plCall, 511); strcpy(sw.pl, plCall); strcat(fList, "aliqueit.log"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, logCall); break; } case 6:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, logCall, 511); strcpy(sw.log, logCall); strcat(fList, "alinum.txt"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, txtCall); break; } case 7:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, txtCall, 511); strcpy(sw.txt, txtCall); strcat(fList, "current.elf"); strcat(fList, fListpost); SetDlgItemText(hwnd, ID_ALILOG_TEXT, fList); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, elfCall); configureN++; break; } case 8:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, iniCall, 511); strcpy(sw.ini, iniCall); GetDlgItemText(hwnd, ID_ALIRUN_TEXT, pyCall, 511); strcpy(sw.py, pyCall); GetDlgItemText(hwnd, ID_ALIRUN_TEXT, plCall, 511); strcpy(sw.pl, plCall); GetDlgItemText(hwnd, ID_ALIRUN_TEXT, logCall, 511); strcpy(sw.log, logCall); GetDlgItemText(hwnd, ID_ALIRUN_TEXT, txtCall, 511); strcpy(sw.txt, txtCall); } case 9:{ GetDlgItemText(hwnd, ID_ALIRUN_TEXT, elfCall, 511); strcpy(sw.elf, elfCall); } default:{ configureN = 0; SetDlgItemText(hwnd, ID_ALIQUEIT_CFG, "Edit config"); SetDlgItemText(hwnd, ID_ALILOG_TEXT, ""); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); } } } // routine to retrieve current factors from unfinished index // and send them to the database void sendLogFactors(HWND hwnd){ // MessageBox(hwnd, "sendLogFactors routine called!", "Tracking/Tracing Message", MB_OK); char numIndex[2048], logLine[2048], factors[100][100], number[256], index[6]; char* pos; int i, j, icount = 0; //, cSize; strcpy(logLine, "wget \"http://factordb.com/search.php?se=1&aq="); strcat(logLine, aliNumber[0]); strcat(logLine, "&action=last&text=Text&raw=1\" -O temp.elf"); // MessageBox(hwnd, logLine, "Tracking/Tracing Message - sendLogFactors1", MB_OK); ZeroMemory( &einfo, sizeof(einfo) ); einfo.cb = sizeof(einfo); einfo.dwX = 640; einfo.dwY = 0; einfo.dwFlags = STARTF_USEPOSITION; CreateProcess(NULL, logLine, NULL, NULL, TRUE, 0, NULL, NULL, &einfo, &eprocessInfo); WaitForSingleObject(eprocessInfo.hProcess, wgetDelay); TerminateProcess(eprocessInfo.hProcess, 0); ifstream tempelf("temp.elf"); if (tempelf){ tempelf.getline(logLine, 2047); i = 0; j = 0; while (logLine[i] != '.' && logLine[i] != 0) index[j++] = logLine[i++]; index[j] = 0; i--; while (logLine[i] != '.' && logLine[i] != 0) i++; i++; while (logLine[i] == ' ') i++; j = 0; while (logLine[i] != ' ') number[j++] = logLine[i++]; number[j] = 0; tempelf.close(); } strcpy(numIndex, aliNumber[0]); strcat(numIndex, ":"); strcat(numIndex, index); ifstream log(aliLog); if (log){ while (!log.eof()){ log.getline(logLine, 2047); if (strstr(logLine, numIndex)){ icount = 0; while(!log.eof()){ log.getline(logLine, 2047); if (strstr(logLine, numIndex) || icount > 99){ icount = 0; log.getline(logLine, 2047); } if (strstr(logLine, "Starting")) break; pos = strstr(logLine, " = "); if (pos){ strcpy(factors[icount++], pos+3); } } } } log.close(); } strcpy(logLine, "wget \"http://factordb.com/search.php?query="); strcat(logLine, number); strcat(logLine, "&reportfac="); while (icount > 0){ strcat(logLine, factors[icount-1]); strcat(logLine, "*"); icount--; } logLine[strlen(logLine)-1] = 0; strcat(logLine, "\" -O temp.html"); // MessageBox(hwnd, logLine, "Tracking/Tracing Message - sendLogFactors2", MB_OK); CreateProcess(NULL, logLine, NULL, NULL, TRUE, 0, NULL, NULL, &einfo, &eprocessInfo); WaitForSingleObject(eprocessInfo.hProcess, wgetDelay); TerminateProcess(eprocessInfo.hProcess, 0); } //routine to read aliqueit.ini for several values void readAliqueitini(HWND hwnd){ // MessageBox(hwnd, "readAliqueitini routine called!", "Tracking/Tracing Message", MB_OK); strcpy(elfPrefix, ""); strcpy(aliLog, ""); char iniBuffer[256]; char* inip; ifstream ini("aliqueit.ini"); if (ini){ while (!ini.eof()){ ini.getline(iniBuffer, 255); if (strstr(iniBuffer, "result_file_prefix")){ inip = strstr(iniBuffer, "result_file_prefix"); strcpy(elfPrefix, inip+21); } if (strstr(iniBuffer, "log_file =")){ inip = strstr(iniBuffer, "log_file ="); strcpy(aliLog, inip+11); } } } ini.close(); } // routine to submit data to the database // if wget and Internet are available void sendElf(HWND hwnd){ // MessageBox(hwnd, "sendElf routine called!", "Tracking/Tracing Message", MB_OK); int i, j; char logLine[2047], index[6], indexE[6], temp1[256], temp2[256]; ifstream tempelf; strcpy(logLine, "wget \"http://factordb.com/search.php?se=1&aq="); strcat(logLine, aliNumber[0]); strcat(logLine, "&action=last&text=Text&raw=1\" -O temp.elf"); // MessageBox(hwnd, logLine, "Tracking/Tracing Message - sendElf", MB_OK); ZeroMemory( &einfo, sizeof(einfo) ); einfo.cb = sizeof(einfo); einfo.dwX = 640; einfo.dwY = 0; einfo.dwFlags = STARTF_USEPOSITION; CreateProcess(NULL, logLine, NULL, NULL, TRUE, 0, NULL, NULL, &einfo, &eprocessInfo); WaitForSingleObject(eprocessInfo.hProcess, wgetDelay); TerminateProcess(eprocessInfo.hProcess, 0); tempelf.open("temp.elf"); if (tempelf){ tempelf.getline(logLine, 2047); i = 0; j = 0; while (logLine[i] != '.' && logLine[i] != 0) index[j++] = logLine[i++]; index[j] = 0; tempelf.close(); } strcpy(logLine, elfPrefix); strcat(logLine, aliNumber[0]); strcat(logLine, ".elf"); tempelf.open(logLine); if (tempelf){ while(!tempelf.eof()){ tempelf.getline(logLine, 2047); if (strlen(logLine) > 3){ i = 0; j = 0; if (logLine[i] == ' ') i++; if (logLine[i] == ' ') i++; while (logLine[i] != '.' && logLine[i] != 0) indexE[j++] = logLine[i++]; indexE[j-1] = 0; } } tempelf.close(); } if (strcmp(indexE, index) > 0){ strcpy(logLine, aliqueitName); strcat(logLine, " "); strcat(logLine, aliNumber[0]); strcat(logLine, " -s "); strcat(logLine, index); // SetDlgItemText(hwnd, ID_ALIRUN_TEXT, logLine); // for tracing/troubleshooting ZeroMemory( &einfo, sizeof(einfo) ); einfo.cb = sizeof(einfo); einfo.dwX = 640; einfo.dwY = 0; einfo.dwFlags = STARTF_USEPOSITION; CreateProcess(NULL, logLine, NULL, NULL, TRUE, 0, NULL, NULL, &einfo, &eprocessInfo); WaitForSingleObject(eprocessInfo.hProcess, wgetDelay); TerminateProcess(eprocessInfo.hProcess, 0); } // sendLogFactors(hwnd); } // this routine either clears the completed list // or accepts a manually entered number and size void clearOrEnter(HWND hwnd){ // MessageBox(hwnd, "clearOrEnter routine called!", "Tracking/Tracing Message", MB_OK); char temp[2048]; GetDlgItemText(hwnd, ID_CLEAR_BUFFER, temp, 2047); if (strstr(temp, "Clear")){ // if (lastNumber){ strcpy(statBuf, ""); SetDlgItemText(hwnd, ID_ALILOG_TEXT, statBuf); if (!lastNumber){ strcpy(temp, "Enter ## #"); SetDlgItemText(hwnd, ID_CLEAR_BUFFER, temp); } } else{ int i=0, j=0; GetDlgItemText(hwnd, ID_ALILOG_TEXT, statBuf, 2047); while (statBuf[i] != ' ' && statBuf[i] != 0) aliNumber[0][i] = statBuf[i++]; aliNumber[0][i] = 0; while (statBuf[i] == ' ' && statBuf[i] != 0) i++; while (statBuf[i] != ' ' && statBuf[i] != 0) aliDigit[0][j++] = statBuf[i++]; aliDigit[0][j] = 0; i = atoi(aliNumber[0]); j = atoi(aliDigit[0]); if (i * j){ lastNumber = 1; makeAliqueitString(hwnd); readElf(hwnd); makeAliqueitString(hwnd); strcpy(statBuf, ""); SetDlgItemText(hwnd, ID_ALILOG_TEXT, statBuf); SetDlgItemText(hwnd, ID_ALIQUEIT_NUMBER, aliNumber[0]); SetDlgItemText(hwnd, ID_ALIQUEIT_DIGIT, status); SetDlgItemText(hwnd, ID_CLEAR_BUFFER, "Clear list"); } else MessageBox(hwnd, "Please use the following format:\r\r###### ###", "Error reading number and/or digits!", MB_OK | MB_ICONEXCLAMATION); } } //this routine cycles the series of numbers to run void cycleNumbers(HWND hwnd){ // MessageBox(hwnd, "cycleNumbers routine called!", "Tracking/Tracing Message", MB_OK); if (!bAliRunning){ int i = 0; char tempN[256], tempD[5]; strcpy(currentSize, ""); strcpy(tempN, aliNumber[0]); strcpy(tempD, aliDigit[0]); for (i=0;i= j && bAliRunning && bECM) || (k == 1000 && bAliRunning)){ readElf(hwnd); if (strcmp(aliDigit[0], "0") == 0){ // strcpy(string, "Verifying elf "); // strcat(string, aliNumber[0]); // SetDlgItemText(hwnd, ID_ALIRUN_TEXT, string); // used for tracking/troubleshooting if (k == 1000){ log.open(aliLog); if (log){ log.seekg(logPosition, ios::beg); while (!log.eof() && !strstr(aliRunBufferTemp, string)) log.getline(aliRunBufferTemp, 2047); if (!log.eof()) log.getline(aliRunBufferTemp, 2047); if (!log.eof() && strlen(aliRunBufferTemp) < 3) log.getline(aliRunBufferTemp, 2047); pos = strstr(aliRunBufferTemp, "] "); strcpy(validateString, pos+1); if (!log.eof()) log.getline(aliRunBufferTemp, 2047); if (strlen(aliRunBufferTemp) > 30){ pos = strstr(aliRunBufferTemp, "] "); strcpy(validateString, pos+1); } } logPosition = log.tellg(); log.close(); } else{ strcpy(validateString, origIndex); strcat(validateString, " "); strcat(validateString, currentSize); } } else{ if (k == 1000){ pos = 0; log.open(aliLog); if (log){ log.seekg(logPosition, ios::beg); while (!log.eof() && !pos){ log.getline(aliRunBufferTemp, 2047); pos = strstr(aliRunBufferTemp, " ERROR: "); if (!pos) pos = strstr(aliRunBufferTemp, " Woah! "); } if (pos){ strcpy(string, aliNumber[0]); strcat(string, pos); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, string); strcat(statBuf, "**"); } } logPosition = log.tellg(); log.close(); } } terminateAliqueit(hwnd); if (sw.bAutoSendElf && strcmp(aliDigit[0], "0") != 0){ sendElf(hwnd); sendLogFactors(hwnd); } i = 0; strcat(statBuf, status); strcat(statBuf, " "); strcat(statBuf, aliNumber[0]); strcat(statBuf, CRLF); SetDlgItemText(hwnd, ID_ALILOG_TEXT, statBuf); while (i < lastNumber){ strcpy(aliNumber[i], aliNumber[i+1]); strcpy(aliDigit[i], aliDigit[i+1]); i++; } lastNumber--; if (i>0){ strcpy(currentSize, ""); readElf(hwnd); makeAliqueitString(hwnd); SetDlgItemText(hwnd, ID_ALIQUEIT_DIGIT, status); SetDlgItemText(hwnd, ID_ALIQUEIT_NUMBER, aliNumber[0]); if (!bAliRunning) startAliqueit(hwnd); } } bECM = 0; } FindClose(logFind); } //this saves the settings of the various options when AliWin is closed void saveSwitches() { ofstream file; file.open("AliWin.cfg", ios::binary); if (file) file.write((char *)(&sw), sizeof(sw)); file.close(); } //this loads the last settings of the options when AliWin starts void loadSwitches() { ifstream file; file.open("AliWin.cfg", ios::binary); if (file) while (!file.eof()) file.read((char *)(&sw), sizeof(sw)); file.close(); } //this reads in the elf file and processes the next to last line //to retrieve the size of the composite void readElf(HWND hwnd){ if (lastNumber){ // MessageBox(hwnd, "readElf routine called!", "Tracking/Tracing Message", MB_OK); int i = 0, j, k, size; char elfName[256], elfBuf[2048]; strcpy(elfName, elfPrefix); strcat(elfName, aliNumber[0]); strcat(elfName, ".elf"); elfFind = FindFirstFile(elfName, &FindElfData); if ((elfFind == INVALID_HANDLE_VALUE || (FindElfData.nFileSizeLow < 5 && !bAliRunning)) && sw.bWGET){ strcpy(elfBuf, "wget \"http://factordb.com/search.php?se=1&aq="); strcat(elfBuf, aliNumber[0]); if (strcmp(aliDigit[0], "0") == 0) strcat(elfBuf, "&action=all&text=Text&raw=1\" -O "); else strcat(elfBuf, "&action=last&text=Text&raw=1\" -O "); strcat(elfBuf, elfName); ZeroMemory( &einfo, sizeof(einfo) ); einfo.cb = sizeof(einfo); einfo.dwX = 640; einfo.dwY = 0; einfo.dwFlags = STARTF_USEPOSITION; CreateProcess(NULL, elfBuf, NULL, NULL, TRUE, 0, NULL, NULL, &einfo, &eprocessInfo); WaitForSingleObject(eprocessInfo.hProcess, wgetDelay); TerminateProcess(eprocessInfo.hProcess, 0); } else{ FindClose(elfFind); } strcpy(elfBuf, ""); strcpy(buffer, ""); ifstream elf(elfName); if (elf){ int index; while (!elf.eof()){ strcpy(elfBuf, buffer); elf.getline(buffer, 511); } if (strlen(elfBuf) > 3){ index = atoi(elfBuf) + 1; itoa (index, currentIndex, 10); while (elfBuf[i] != '.' && strlen(elfBuf)>10) i++; i++; while (elfBuf[i] != '1' && elfBuf[i] != '2' && elfBuf[i] != '3' && elfBuf[i] != '4' && elfBuf[i] != '5' && elfBuf[i] != '6' && elfBuf[i] != '7' && elfBuf[i] != '8' && elfBuf[i] != '9' && elfBuf[i] != '0') i++; j = 0; while (elfBuf[i] != ' '){ i++; j++; } elf.close(); i = atoi(currentSize); if (j>i) itoa (j, currentSize, 10); } } } } // this reads the last line of the aliqueit.log file and checks for // size of composite and finish of ECM void readAliLog(HWND hwnd){ // MessageBox(hwnd, "readAliLog routine called!", "Tracking/Tracing Message", MB_OK); if (lastNumber){ int i = 0, j, k, cSize; char aliTemp[1024], aliBuf[2048], numSearch[512], *pos; strcpy(numSearch, aliNumber[0]); strcat(numSearch, ":"); strcpy(aliBuf, ""); ifstream ali(aliLog); if (ali){ ali.seekg(logPosition, ios::beg); while (!ali.eof()){ strcpy(aliBuf, aliTemp); ali.getline(aliTemp, 1023); if (strstr(aliTemp, numSearch)){ pos = strstr(aliTemp, "("); cSize = atoi(pos+1); itoa(cSize, currentSize, 10); } } // SetDlgItemText(hwnd, ID_ALIRUN_TEXT, aliBuf); // used for tracking/troubleshooting if ((strstr(aliBuf, "running qs") || strstr(aliBuf, "running gnfs")) && sw.bXECM){ char* cLocation; int tempSize1, tempSize2; cLocation = strstr(aliBuf, "c"); tempSize1 = atoi(cLocation+1); tempSize2 = atoi(currentSize); if (tempSize1 > tempSize2 * .8){ bECM = 1; } } } ali.close(); } } //this reads and parses the numbers and respective digit cutoff //for each and places them in arrays void getNumbers(HWND hwnd){ // MessageBox(hwnd, "getNumbers routine called!", "Tracking/Tracing Message", MB_OK); int i = 0, j, k; char tempD[5]; ZeroMemory( &aliNumber, sizeof(aliNumber) ); ZeroMemory( &aliDigit, sizeof(aliDigit) ); ifstream aliNum("aliNum.txt"); if (aliNum){ while (!aliNum.eof()){ aliNum.getline(buffer, 511); if (strlen(buffer)>2){ j=0; while (j 5) strcpy(elfCall, sw.elf); if (strlen(sw.ini) > 5) strcpy(iniCall, sw.ini); if (strlen(sw.py) > 5) strcpy(pyCall, sw.py); if (strlen(sw.pl) > 5) strcpy(plCall, sw.pl); if (strlen(sw.log) > 5) strcpy(logCall, sw.log); if (strlen(sw.txt) > 5) strcpy(txtCall, sw.txt); makeAliqueitString(hwnd); HWND bGround = CreateWindow( "STATIC", "", WS_VISIBLE | WS_CHILD | WS_BORDER, 420, 0, 209, 150, hwnd, (HMENU) IDC_STATIC, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliProg = CreateWindow( "BUTTON", "Command line:", WS_VISIBLE | WS_CHILD | WS_BORDER, 140, 25, 110, 25, hwnd, (HMENU) ID_ALIQUEIT_NAME, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliNum = CreateWindow( "BUTTON", "Current #:", WS_VISIBLE | WS_CHILD | WS_BORDER, 140, 0, 80, 25, hwnd, (HMENU) ID_ALIQUEIT_NUM, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliDCut = CreateWindow( "BUTTON", "Status:", WS_VISIBLE | WS_CHILD | WS_BORDER, 290, 0, 60, 25, hwnd, (HMENU) ID_ALIQUEIT_STAT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliini = CreateWindow( "BUTTON", "Open Aliqueit.ini", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 0, 140, 25, hwnd, (HMENU) ID_ALIQUEITINI_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND fmpy = CreateWindow( "BUTTON", "Open factmsieve.py", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 25, 140, 25, hwnd, (HMENU) ID_FACTMSIEVEPY_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND fmpl = CreateWindow( "BUTTON", "Open factMsieve.pl", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 50, 140, 25, hwnd, (HMENU) ID_FACTMSIEVEPL_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND clear = CreateWindow( "BUTTON", clearEnterButton, WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 140, 50, 80, 25, hwnd, (HMENU) ID_CLEAR_BUFFER, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND alirun = CreateWindow( "BUTTON", "Run aliqueit", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 220, 50, 100, 25, hwnd, (HMENU) ID_ALIQUEIT_RUN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliend = CreateWindow( "BUTTON", "Edit config", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 320, 50, 100, 25, hwnd, (HMENU) ID_ALIQUEIT_CFG, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND skip1ECM = CreateWindow( "BUTTON", "Skip ECM for first run", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 1, 180, 25, hwnd, (HMENU) ID_ALIQUEIT_ECM, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND idlepri = CreateWindow( "BUTTON", "Run at idle priority", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 26, 180, 25, hwnd, (HMENU) ID_ALIQUEIT_IDLE, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND quit1 = CreateWindow( "BUTTON", "Run one iteration only", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 51, 200, 25, hwnd, (HMENU) ID_ALIQUEIT_ONEI, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND xecm = CreateWindow( "BUTTON", "Run ECM above digit cutoff", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 75, 200, 25, hwnd, (HMENU) ID_ALIQUEIT_XECM, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND wget = CreateWindow( "BUTTON", "Use WGET to retrieve data", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 99, 200, 25, hwnd, (HMENU) ID_ALIQUEIT_WGET, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aSendElf = CreateWindow( "BUTTON", "Auto Send", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 123, 100, 25, hwnd, (HMENU) ID_ALIQUEIT_ASENDELF, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND SendElf = CreateWindow( "BUTTON", "Send now", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_BORDER, 525, 123, 100, 25, hwnd, (HMENU) ID_ALIQUEIT_SENDELF, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND alilog = CreateWindow( "BUTTON", "Open Aliqueit.log", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 75, 140, 25, hwnd, (HMENU) ID_ALIQUEITLOG_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliNumT = CreateWindow( "BUTTON", "Open Alinum.txt", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 100, 140, 25, hwnd, (HMENU) ID_ALINUMTXT_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND currentElf = CreateWindow( "BUTTON", "Open current .elf", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 0, 125, 140, 25, hwnd, (HMENU) ID_CURRENTELF_OPEN, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliNumb = CreateWindow( "edit", aliNumber[0], WS_VISIBLE | WS_CHILD | WS_BORDER, 220, 0, 70, 25, hwnd, (HMENU) ID_ALIQUEIT_NUMBER, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliDig = CreateWindow( "edit", status, WS_VISIBLE | WS_CHILD | WS_BORDER, 350, 0, 70, 25, hwnd, (HMENU) ID_ALIQUEIT_DIGIT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND alistring = CreateWindow( "edit", aliqueitCall, WS_VISIBLE | WS_CHILD | WS_BORDER, 250, 25, 170, 25, hwnd, (HMENU) ID_ALIQUEIT_CALL, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); alilogText = CreateWindow( "edit", alilogBuffer, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN | ES_MULTILINE , 140, 75, 280, 75, hwnd, (HMENU) ID_ALILOG_TEXT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND alioutput = CreateWindow( "edit", aliRunBuffer, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | ES_MULTILINE , 0, 150, 628, 100, hwnd, (HMENU) ID_ALIRUN_TEXT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); CheckDlgButton(hwnd, ID_ALIQUEIT_ECM, sw.bSkipECM); CheckDlgButton(hwnd, ID_ALIQUEIT_IDLE, sw.bIdlePri); CheckDlgButton(hwnd, ID_ALIQUEIT_ONEI, sw.bOneI); CheckDlgButton(hwnd, ID_ALIQUEIT_XECM, sw.bXECM); CheckDlgButton(hwnd, ID_ALIQUEIT_WGET, sw.bWGET); CheckDlgButton(hwnd, ID_ALIQUEIT_ASENDELF, sw.bAutoSendElf); strcpy(helpMsg, "AliWin, version ."); strcat(helpMsg, version); strcat(helpMsg, ", by Edwin C. Hall - a GUI for Aliqueit, a program by Mikael Klasson"); } break; case WM_TIMER: switch(wParam) { case ID_TIMER:{ // used to check for size of composite readElf(hwnd); readAliLog(hwnd); makeAliqueitString(hwnd); SetDlgItemText(hwnd, ID_ALIQUEIT_DIGIT, status); cutoffCheck(hwnd); } break; case ID_TIMER2:{ // used for auto data submission if (sw.bAutoSendElf){ sendElf(hwnd); sendLogFactors(hwnd); } } break; } case WM_COMMAND: switch(LOWORD(wParam)) { case ID_ALIQUEIT_STAT: // MessageBox(hwnd, "Correct", "Get Aliquot Info", MB_OK); // getAliquotInfo(hwnd); // temp use SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); break; case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case ID_CLEAR_BUFFER:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); clearOrEnter(hwnd); } break; case ID_ALIQUEIT_RUN:{ if (!bAliRunning) startAliqueit(hwnd); else{ terminateAliqueit(hwnd); if (sw.bAutoSendElf && strcmp(aliDigit[0], "0") != 0){ sendElf(hwnd); sendLogFactors(hwnd); } } SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); } break; case ID_ALIQUEIT_SENDELF:{ sendElf(hwnd); sendLogFactors(hwnd); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); } break; case ID_ALIQUEIT_NUM:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (lastNumber) cycleNumbers(hwnd); } break; case ID_CURRENTELF_OPEN:{ if (lastNumber){ char elfOpen[2048]; strcpy(elfOpen, elfCall); strcat(elfOpen, " "); strcat(elfOpen, currentelf); CreateProcess(NULL, elfOpen, NULL, NULL, TRUE, 0, NULL, NULL, &aiinfo, &aiprocessInfo); } else SetDlgItemText(hwnd, ID_ALIRUN_TEXT, "No current elf exists!"); } break; case ID_ALIQUEITINI_OPEN:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char iniOpen[2048]; strcpy(iniOpen, iniCall); strcat(iniOpen, " aliqueit.ini"); CreateProcess(NULL, iniOpen, NULL, NULL, TRUE, 0, NULL, NULL, &aiinfo, &aiprocessInfo); temp = MessageBox(hwnd, "Did you change the elf prefix or log filename?", "Retrieve ini info necessary?", MB_YESNO | MB_ICONQUESTION); if (temp == IDYES){ if (!bAliRunning){ readAliqueitini(hwnd); readElf(hwnd); makeAliqueitString(hwnd); SetDlgItemText(hwnd, ID_ALIQUEIT_DIGIT, status); SetDlgItemText(hwnd, ID_ALIQUEIT_NUMBER, aliNumber[0]); clearOrEnter(hwnd); } else MessageBox(hwnd, "Can't update info because aliqueit is\rrunning. Plese re-open and close\raliqueit.ini when aliqueit is not running.", "Problem with reading aliqueit.ini!", MB_OK); } } break; case ID_ALINUMTXT_OPEN:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char txtOpen[2048]; strcpy(txtOpen, txtCall); strcat(txtOpen, " alinum.txt"); CreateProcess(NULL, txtOpen, NULL, NULL, TRUE, 0, NULL, NULL, &atinfo, &atprocessInfo); if (!bAliRunning) temp = MessageBox(hwnd, "Reload numbers?", "Possible alinum.txt edit!", MB_YESNO | MB_ICONQUESTION); if (temp == IDYES){ getNumbers(hwnd); readElf(hwnd); makeAliqueitString(hwnd); SetDlgItemText(hwnd, ID_ALIQUEIT_DIGIT, status); SetDlgItemText(hwnd, ID_ALIQUEIT_NUMBER, aliNumber[0]); SetDlgItemText(hwnd, ID_ALILOG_TEXT, ""); // clearOrEnter(hwnd); } } break; case ID_ALIQUEITLOG_OPEN:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char aliLogOpen[2048]; strcpy(aliLogOpen, logCall); strcat(aliLogOpen, " "); strcat(aliLogOpen, aliLog); CreateProcess(NULL, aliLogOpen, NULL, NULL, TRUE, 0, NULL, NULL, &aiinfo, &alprocessInfo); } break; case ID_FACTMSIEVEPY_OPEN:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char pyOpen[2048]; strcpy(pyOpen, pyCall); strcat(pyOpen, " factmsieve.py"); CreateProcess(NULL, pyOpen, NULL, NULL, TRUE, 0, NULL, NULL, &pyinfo, &pyprocessInfo); } break; case ID_FACTMSIEVEPL_OPEN:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char plOpen[2048]; strcpy(plOpen, plCall); strcat(plOpen, " factMsieve.pl"); CreateProcess(NULL, plOpen, NULL, NULL, TRUE, 0, NULL, NULL, &plinfo, &plprocessInfo); } break; case ID_ALIQUEIT_ECM:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ECM)) CheckDlgButton(hwnd, ID_ALIQUEIT_ECM, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_ECM, 1); sw.bSkipECM = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ECM); makeAliqueitString(hwnd); } break; case ID_ALIQUEIT_XECM:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_XECM)) CheckDlgButton(hwnd, ID_ALIQUEIT_XECM, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_XECM, 1); sw.bXECM = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_XECM); makeAliqueitString(hwnd); } break; case ID_ALIQUEIT_WGET:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_WGET)) CheckDlgButton(hwnd, ID_ALIQUEIT_WGET, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_WGET, 1); sw.bWGET = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_WGET); // makeAliqueitString(hwnd); } break; case ID_ALIQUEIT_ASENDELF:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ASENDELF)) CheckDlgButton(hwnd, ID_ALIQUEIT_ASENDELF, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_ASENDELF, 1); sw.bAutoSendElf = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ASENDELF); } break; case ID_ALIQUEIT_IDLE:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_IDLE)) CheckDlgButton(hwnd, ID_ALIQUEIT_IDLE, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_IDLE, 1); sw.bIdlePri = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_IDLE); makeAliqueitString(hwnd); } break; case ID_ALIQUEIT_ONEI:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ONEI)) CheckDlgButton(hwnd, ID_ALIQUEIT_ONEI, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_ONEI, 1); sw.bOneI = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_ONEI); makeAliqueitString(hwnd); } break; case ID_ALIQUEIT_CFG:{ configureN++; configure(hwnd); } break; case ID_HELP_HELP:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); termyn = MessageBox(hwnd, helpTextPage1, helpMsg, MB_YESNO); if (termyn != IDYES) break; } case ID_HELP_HELP2:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); termyn = MessageBox(hwnd, helpTextPage2, helpMsg, MB_YESNO); if (termyn != IDYES) break; } case ID_HELP_HELP3:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); MessageBox(hwnd, helpTextPage3, helpMsg, MB_OK); } break; case ID_HELP_ABOUT:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char about[1024]; strcpy(about, "AliWin, version ."); strcat(about, version); strcat(about, ", by Edwin C. Hall - a GUI for Aliqueit\r\rThis program was built to further automate Aliqueit, which\ruses several other programs to advance Aliquot Sequences.\r\rFor more information, visit the Aliquot Sequences forum:\r\rhttp://www.mersenneforum.org/forumdisplay.php?f=90"); MessageBox(hwnd, about, "About", MB_ICONINFORMATION | MB_OK); } break; } break; case WM_CLOSE:{ if (!sw.bAcceptance) DestroyWindow(hwnd); else{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); int ret = IDYES; if (bAliRunning) ret = MessageBox(hwnd, "Close all windows and exit AliWin?", "Exit Program?", MB_YESNO); if (ret != IDYES) break; else { saveSwitches(); if (bAliRunning) terminateAliqueit(hwnd); TerminateProcess(eprocessInfo.hProcess, 0); TerminateProcess(ceprocessInfo.hProcess, 0); TerminateProcess(aiprocessInfo.hProcess, 0); TerminateProcess(atprocessInfo.hProcess, 0); TerminateProcess(processInfo.hProcess, 0); TerminateProcess(alprocessInfo.hProcess, 0); TerminateProcess(pyprocessInfo.hProcess, 0); TerminateProcess(plprocessInfo.hProcess, 0); DestroyWindow(hwnd); } } } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char titleBar[128]; strcpy(titleBar, "AliWin by Edwin C. Hall version ."); strcat(titleBar, version); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = MAKEINTRESOURCE(IDR_ALIMENU); wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HMENU hmenu = CreateMenu(); hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, titleBar, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX, 0, 0, 640, 300, NULL, hmenu, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }