RFC - Program to schedule download of winetest.exe
Jakob Eriksson
jakov at vmlinux.org
Wed Mar 24 00:01:19 CST 2004
I have hacked together a little program to download winetest.exe and run
it every 24h.
Here is the URL:
http://vmlinux.org/jakov/Wine/testloader/
There are more binaries and stuff there too.
I know this is not a windows service, but at least it is something. Keep
this
console aplication open and it will download winetest.exe every 24h, with
some randomness, to go easy on the server.
.----------------------------------.
What the code looks like:
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <windows.h>
#include <io.h>
#include <process.h>
using namespace std;
static void await(int hour)
{
int right_time = 0;
do {
time_t now = time(NULL);
struct tm comp = *gmtime(&now);
if (comp.tm_hour == hour) {
Sleep((rand()%60) * 60000); // Introduce randomness
right_time = 1;
} else {
Sleep(10000);
}
} while(!right_time);
}
#define WINETESTS "winetests.exe"
#define TESTCOPY "testcopy.exe"
static void runtest()
{
SetCurrentDirectory(getenv("TEMP"));
_unlink(WINETESTS);
system("wget --no-clobber http://vmlinux.org/jakov/Wine/" WINETESTS);
// Validate GPG signature for winetest.exe -- TODO
// silly wget makes file not executable
if (!CopyFile(WINETESTS, TESTCOPY, FALSE)) {
printf("Problem with file " WINETESTS "\n");
return;
}
_unlink(WINETESTS);
rename(TESTCOPY, WINETESTS);
printf("execl %s returns: %d\n", WINETESTS, _execl(WINETESTS,
WINETESTS, NULL));
}
int main(int argc, char **argv)
{
int run_once = 0;
if (argc != 2) {
printf("Usage:\n%s < hour_of_download | once >\n", argv[0]);
return 0;
}
srand((unsigned int)time(NULL));
if (2 == argc) {
if (string(argv[1]) == "once") {
run_once = 1;
}
}
if (run_once) {
runtest();
return 0;
}
while (1) {
await(atoi(argv[1]));
runtest();
}
return 0;
}
More information about the wine-devel
mailing list