| Author |
Message |
|
goliathdrakken
Joined: Sat Oct 29, 2005 4:27 pm Posts: 393 Location: Cleveland, Ohio, USA
|
 b0rg installer
a while ago i started to work on a b0rg installer. i found out that the config file has to be a binary file in order to work. i didnt kno how to do this in c++ so i took a break. here is what i had come up with. let me know if u have any suggestions.
Code: // b0rg.cpp : written by goliathdrakken //hack-a-day fah b0rg installer
#include "stdafx.h" #include <fstream> #include <windows.h> using namespace std;
// Use to change the divisor from Kb to Mb.
#define DIV 1024 // #define DIV 1
char *divisor = "K"; // char *divisor = "";
// Handle the width of the field in which to print numbers this way to // make changes easier. The asterisk in the print format specifier // "%*ld" takes an int from the argument list, and uses it to pad and // right-justify the number being formatted. #define WIDTH 6
void main(int argc, char *argv[]) { ofstream fout; ofstream log; int x; int big; MEMORYSTATUS stat;
GlobalMemoryStatus (&stat);
log.open ("install.log");
printf ("Welcome to the hack-a-day folding@home installer.\n\n"); log << "Welcome to the hack-a-day folding@home installer.\n\n"; printf ("There are %*ld total %sbytes of physical memory.\n", WIDTH, stat.dwTotalPhys/DIV/DIV, divisor); log << "There are %*ld total %sMbytes of physical memory.\n", WIDTH, stat.dwTotalPhys/DIV/DIV, divisor;
if (stat.dwTotalPhys/DIV/DIV < 450) { big=0; printf ("Based on your memory size F@H will install with\n"); log << "Based on your memory size F@H will install with\n"; printf ("large work units DISABLED.\n\n"); log << "large work units DISABLED.\n\n"; } else { big=1; printf ("Based on your memory size F@H will install with\n"); log << "Based on your memory size F@H will install with\n"; printf ("large work units ENABLED.\n\n"); log << "large work units ENABLED.\n\n"; }
fout.open ("client.cfg"); fout << "[settings]" << endl; log << "[settings]" << endl; fout << "username=goliathdrakken" << endl; log << "username=goliathdrakken" << endl; fout << "team=44851" << endl; log << "team=44851" << endl; fout << "asknet=no" << endl; log << "asknet=no" << endl; if (big = 0) {fout << "bigpackets=no" << endl; log << "bigpackets=no" << endl;} else {fout << "bigpackets=yes" << endl; log << "bigpackets=yes" << endl;} fout << "machineid=1" << endl; log << "machineid=1" << endl; fout << "local=11" << endl << endl; log << "local=11" << endl << endl; fout << "[http]" << endl; log << "[http]" << endl; fout << "active=no" << endl; log << "active=no" << endl; fout << "host=localhost" << endl; log << "host=localhost" << endl; fout << "port=8080" << endl; log << "port=8080" << endl; fout << "usereg=yes" << endl << endl; log << "usereg=yes" << endl << endl; fout << "[power]" << endl; log << "[power]" << endl; fout << "battery=yes" << endl << endl; log << "battery=yes" << endl << endl; fout << "[core]" << endl; log << "[core]" << endl; fout << "checkpoint=5" << endl << endl; log << "checkpoint=5" << endl << endl;
system("pause"); }
The thing i liked about this script is it detected the system ram and it made the config file accordingly. i also want to have it check for hyperthreading and multipule cpu's.
_________________
Last edited by goliathdrakken on Wed Nov 02, 2005 11:15 am, edited 1 time in total.
|
| Tue Nov 01, 2005 8:00 pm |
|
|
 |
|
grayskies
Joined: Tue Nov 01, 2005 11:37 am Posts: 1639 Location: South Bend / Mishawaka, IN
|
looks good, cept my c++ is hella rusty.
I use Java more. 
_________________ “In the destructive element immerse!”
|
| Wed Nov 02, 2005 1:08 am |
|
|
|
 |
|
goliathdrakken
Joined: Sat Oct 29, 2005 4:27 pm Posts: 393 Location: Cleveland, Ohio, USA
|
i originally had started this in java, however i could not find a method of detecting system ram without using 3 pages of code. so i resorted to trusty olde c++. and plus i already knew how to manipulate files using c++ and i didnt feel like learning another language just for one project. but now that i ran into a dead end w/ the config file im back to step one.
_________________
|
| Wed Nov 02, 2005 1:52 am |
|
|
|
 |
|
Orange
Joined: Fri Oct 28, 2005 8:37 pm Posts: 47 Location: elgin.il
|
Nice, except a 5 minute checkpoint increases file fragmentation, switching it back to 15 generally is better.
Maybe also a couple pre-compiled binaries for people to use too?
Don't take this the wrong way just offering suggestions.
|
| Wed Nov 02, 2005 9:43 am |
|
|
|
 |
|
lexr3000
Joined: Sun Oct 30, 2005 9:44 am Posts: 528 Location: UK
|
It wont compile in Dev C++ so there is a bug in it.
_________________
|
| Thu Nov 03, 2005 11:21 am |
|
|
|
 |
|
goliathdrakken
Joined: Sat Oct 29, 2005 4:27 pm Posts: 393 Location: Cleveland, Ohio, USA
|
do you have all the include files, like stdafx.h? This was created in studio .net so mostlikely u dont have all the necessary header files.
_________________
|
| Thu Nov 03, 2005 11:38 am |
|
|
|
 |
|
lexr3000
Joined: Sun Oct 30, 2005 9:44 am Posts: 528 Location: UK
|
Where do i get the files? Microsoft?
_________________
|
| Thu Nov 03, 2005 11:38 am |
|
|
|
 |
|
goliathdrakken
Joined: Sat Oct 29, 2005 4:27 pm Posts: 393 Location: Cleveland, Ohio, USA
|
do you have all the include files, like stdafx.h? This was created in studio .net so mostlikely u dont have all the necessary header files.
_________________
|
| Thu Nov 03, 2005 11:41 am |
|
|
|
 |
|
BillytheImpaler
Joined: Thu Oct 27, 2005 12:39 pm Posts: 4517 Location: Cleveland, Ohio, USA
|
It can't be that broken as my compiled version works just fine.
All it needs is to be implemented into a script of some sort that uses its output to make decisions based on computer specs.
_________________ [img:468:100]http://img386.imageshack.us/img386/4585/shinerbockbf4.gif[/img]
(1.21 gigawatts) / (88 miles per hour) = 30757874 newtons
|
| Thu Nov 03, 2005 11:48 am |
|
|
|
 |
|
lexr3000
Joined: Sun Oct 30, 2005 9:44 am Posts: 528 Location: UK
|
Thats what I thought (the errors were all NT subsystem based im running XP
)
_________________
|
| Thu Nov 03, 2005 12:33 pm |
|
|
|
 |
|