//////////////////////////////////////////// // AliWin2 by Edwin C. Hall // //for use ONLY with Aliqueit 1.10 or later// // // // 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 #define ID_ALIQUEIT_SETECMCVAL 4034 #define ID_HELP_ABOUTALIQ 4035 #define ID_ALIQUEIT_AR 4036 //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[] = "AliWin2"; char* version = "20120229"; char aliNumber[1000][1000], 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], ECMText[30], ECMText2[30], cofactor[5]; char* aliqueitName = "aliqueit"; char* digitSw = " -d "; char* skipECMSw = " -e"; char* idlePriSw = " -p"; char* oneISw = " -q"; DWORD dwBytesRead, logSize = 0, elfSizeH = 0, elfSizeL = 0; BOOL bAliRunning = 0, bECM = 0, bECMC = 0, elfNew = 0, bReloadNums = 0; UINT aliTimer, aliTimer2; HWND alilogText, AliWin2Hwnd; int configureN = 0, termyn, termynS = 0, temp, lastNumber = 0, timerDelay = 1000*3,\ timerDelay2 = 1000*60*60*4, wgetDelay = 1000*120, elfIndex = 0; 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/*, bXECMM*/, bWGET, bAutoSendElf, bAR; char ini[2048], log[2048], txt[2048], elf[2048], py[2048], pl[2048]; int ECMVal; BOOL bAcceptance; } sw; //Help Information is displayed in MessageBoxes //The text is included here to keep source fully self-contained char* helpTextPage1 = "SPECIAL NOTE: This version of AliWin2 will only work \ properly with Aliqueit 1.10 or later!\r\r\ AliWin2 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. (Note that the last two items have \ now been added to the Aliqueit program itself.) 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\ As a basic install, 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 AliWin2 web page:\ \r\r\ alinum.txt\t\taliqueit.exe\t\taliqueit.log\t\taliqueit.ini\r\ aliqueit.txt\t\tAliWin2.cfg\t\tAliWin2.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 AliWin2, 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 AliWin2 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 checkboxes 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 checkbox down \ will allow for aliqueit to continue past the digit cutoff, until all ECM has been \ completed on a cofactor larger than either a direct size or a percentage of the \ digits value (size to work to). The Set button allows setting the value by \ capturing that value from the large edit box at the bottom of the AliWin2 window. \ The fifth \ checkbox 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\" checkbox that tells AliWin2 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 bottom 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. \ Also found in this section, is an Autorun checkbox, which can start Aliqueit when \ AliWin2 is started. This, in conjunction with a shortcut placed in the Startup \ directory of the Windows Menu, can allow for automatically running sequences, even \ from a powerup or reset condition.\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 \"Cmd:\" buttons perform no action. \ The status shown is cofactor size / composite size / size to work to. \ 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 AliWin2, the button 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 AliWin2, 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.\ \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. This will also occur if the number is larger than 199 digits, because \ Windows would have trouble with the elf filename if it is longer. It will also \ do this if it detects a merge. AliWin2 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 that 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 configure(HWND hwnd); void setECMc(HWND hwnd); void elfFix(HWND hwnd); // added because factordb elf files have garbage void elfFix(HWND hwnd){ ifstream inT; ofstream outT; char buffT[512]; strcpy(buffT, elfPrefix); strcat(buffT, aliNumber[0]); strcat(buffT, ".elf"); inT.open("temp.elf"); outT.open(buffT); if (inT && outT){ while (!inT.eof()){ inT.getline(buffT, 511); if (strstr(buffT, " . ")) outT << buffT << endl; } outT.close(); inT.close(); } } // routine to set -c value for ECM above cutoff void setECMc(HWND hwnd){ char ECMtemp[31], ECMtemp2[31]; int v, d; GetDlgItemText(hwnd, ID_ALIRUN_TEXT, ECMtemp, 20); if (strlen(ECMtemp) > 0){ bECMC = 0; v = atoi(ECMtemp); if (strstr(ECMtemp, "%") > 0){ d = atoi(aliDigit[0]); sw.ECMVal = (d * v)/100; itoa(sw.ECMVal, ECMtemp2, 10); sw.ECMVal = v + 8000; } else{ sw.ECMVal = v; itoa(sw.ECMVal, ECMtemp2, 10); } } else{ v = sw.ECMVal; if (v > 8000){ v -= 8000; v = (atoi(aliDigit[0]) * v)/100; } itoa(v, ECMtemp2, 10); } strcpy(ECMtemp, "Cofactor > "); strcat(ECMtemp, ECMtemp2); strcat(ECMtemp, " digits"); strcpy(ECMText2, ECMtemp); strcpy(ECMText, " -b -c "); strcat(ECMText, ECMtemp2); strcat(ECMText, " "); SetDlgItemText(hwnd, ID_ALIQUEIT_XECM, ECMtemp); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); if (bECMC){ MessageBox(hwnd, "Enter value (max_cofactor) in the space under the\r\ 'Open current.elf' button before pressing 'Set.'\r\ To enter a percentage, follow the value with '%.'", "ECM Cofactor Entry", MB_OK); bECMC = 0; } } // 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 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 logLineT[2047], 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); logLineT[0]=0; tempelf.open("temp.elf"); if (tempelf){ while (strlen(logLineT)>3){ tempelf.getline(logLineT, 2047); strcpy(logLine, logLineT); } 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){ */ itoa(elfIndex, index, 10); strcpy(logLine, aliqueitName); strcat(logLine, " "); strcat(logLine, aliNumber[0]); strcat(logLine, " -s "); strcat(logLine, index); // MessageBox(hwnd, logLine, "Send string!", MB_OK); // 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); // } // removed because db not accepting second connection } // 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 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; strcpy(string, ""); 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) pos = strstr(aliRunBufferTemp, " Cycle detected"); if (!pos) pos = strstr(aliRunBufferTemp, " Sequence merges"); } if (pos){ // strcpy(string, aliNumber[0]); strcpy(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); } i = 0; strcat(statBuf, status); strcat(statBuf, " "); strcat(statBuf, aliNumber[0]); strcat(statBuf, " "); strcat(statBuf, string); 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 AliWin2 is closed void saveSwitches() { ofstream file; file.open("AliWin2.cfg", ios::binary); if (file) file.write((char *)(&sw), sizeof(sw)); file.close(); } //this loads the last settings of the options when AliWin2 starts void loadSwitches() { ifstream file; file.open("AliWin2.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="); strcpy(elfBuf, "wget \"http://factordb.com/elf.php?seq="); strcat(elfBuf, aliNumber[0]); if (strcmp(aliDigit[0], "0") == 0) // strcat(elfBuf, "&action=all&text=Text&raw=1\" -O "); strcat(elfBuf, "&type=1\" -O "); else // strcat(elfBuf, "&action=last&text=Text&raw=1\" -O "); strcat(elfBuf, "&type=1\" -O Temp.elf"); // strcat(elfBuf, elfName); // changed due to db garbage!! 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); // MessageBox(hwnd, "File created", "Elf Check Pause", MB_OK); elfFix(hwnd); } 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); } if (strstr(aliTemp, "] c")){ char* cTempSize = strstr(aliTemp, "] c"); int cTemp = atoi(cTempSize+3); itoa(cTemp, cofactor, 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+3); tempSize2 = atoi(currentSize); //MessageBox(hwnd, cLocation, aliBuf, MB_OK); // itoa(tempSize1, cofactor, 10); 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); setECMc(hwnd); 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", "Cmd:", WS_VISIBLE | WS_CHILD | WS_BORDER, 140, 25, 40, 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, 70, 25, hwnd, (HMENU) ID_ALIQUEIT_NUM, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND aliDCut = CreateWindow( "BUTTON", "Status:", WS_VISIBLE | WS_CHILD | WS_BORDER, 280, 0, 50, 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", "Idle priority", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 26, 95, 25, hwnd, (HMENU) ID_ALIQUEIT_IDLE, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND autoRun = CreateWindow( "BUTTON", "AutoRun", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 550, 26, 75, 25, hwnd, (HMENU) ID_ALIQUEIT_AR, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND quit1 = CreateWindow( "BUTTON", "One index", WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 51, 90, 25, hwnd, (HMENU) ID_ALIQUEIT_ONEI, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND xecm = CreateWindow( "BUTTON", ECMText2, WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 430, 75, 155, 25, hwnd, (HMENU) ID_ALIQUEIT_XECM, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND setecmc = CreateWindow( "button", "Set", WS_VISIBLE | WS_CHILD | WS_BORDER, 595, 75, 30, 25, hwnd, (HMENU) ID_ALIQUEIT_SETECMCVAL, (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, 210, 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, 330, 0, 90, 25, hwnd, (HMENU) ID_ALIQUEIT_DIGIT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); HWND alistring = CreateWindow( "edit", aliqueitCall, WS_VISIBLE | WS_CHILD | WS_BORDER, 180, 25, 240, 25, hwnd, (HMENU) ID_ALIQUEIT_CALL, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); alilogText = CreateWindow( "edit", alilogBuffer, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | WS_HSCROLL | 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_AR, sw.bAR); CheckDlgButton(hwnd, ID_ALIQUEIT_ONEI, sw.bOneI); CheckDlgButton(hwnd, ID_ALIQUEIT_XECM, sw.bXECM); // CheckDlgButton(hwnd, ID_ALIQUEIT_XECMM, sw.bXECMM); CheckDlgButton(hwnd, ID_ALIQUEIT_WGET, sw.bWGET); CheckDlgButton(hwnd, ID_ALIQUEIT_ASENDELF, sw.bAutoSendElf); strcpy(helpMsg, "AliWin2, v ."); strcat(helpMsg, version); strcat(helpMsg, ", by Edwin C. Hall - a GUI for Aliqueit (>=v1.10), by Mikael Klasson"); if (sw.bAR) startAliqueit(hwnd); } 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); } } 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); } } SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); } break; case ID_ALIQUEIT_SENDELF:{ sendElf(hwnd); SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); } break; case ID_ALIQUEIT_SETECMCVAL:{ bECMC = 1; setECMc(hwnd); } 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) bReloadNums = 1; 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); } 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_AR:{ if (IsDlgButtonChecked(hwnd, ID_ALIQUEIT_AR)) CheckDlgButton(hwnd, ID_ALIQUEIT_AR, 0); else CheckDlgButton(hwnd, ID_ALIQUEIT_AR, 1); sw.bAR = IsDlgButtonChecked(hwnd, ID_ALIQUEIT_AR); } 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, " AliWin2, version ."); strcat(about, version); strcat(about, ", by Edwin C. Hall\r a GUI for Aliqueit version 1.10 or later ONLY\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; case ID_HELP_ABOUTALIQ:{ SetDlgItemText(hwnd, ID_ALIRUN_TEXT, ""); char aliLogOpen[2048]; strcpy(aliLogOpen, logCall); strcat(aliLogOpen, " aliqueit.txt"); CreateProcess(NULL, aliLogOpen, NULL, NULL, TRUE, 0, NULL, NULL, &aiinfo, &alprocessInfo); } 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 AliWin2?", "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, "AliWin2 by Edwin C. Hall version ."); strcat(titleBar, version); strcat(titleBar, " (For >= Aliqueit 1.10 ONLY.)"); 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, 305, 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; }