99 lines
1.9 KiB
C
99 lines
1.9 KiB
C
/*
|
|
* Written by Carsten Larsen.
|
|
* Public domain.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <clib/exec_protos.h>
|
|
#include <clib/timer_protos.h>
|
|
|
|
#include <dos/var.h>
|
|
#include <devices/timer.h>
|
|
#include <libraries/locale.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "version.h"
|
|
|
|
#define OPEN_ERROR "Cannot open %s.\n"
|
|
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
|
|
#define DOSLIB_NAME "dos.library"
|
|
#define DOSLIB_REV 33L
|
|
#define BSDLIB_NAME "bsdsocket.library"
|
|
#define BSDLIB_REV 03L
|
|
|
|
int CreateTimer();
|
|
void DeleteTimer();
|
|
|
|
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (" PACKAGE_DATE ")";
|
|
|
|
struct Library *DOSBase;
|
|
struct Library *SocketBase;
|
|
|
|
void amiga_open_error(char *name)
|
|
{
|
|
printf(OPEN_ERROR, name);
|
|
}
|
|
|
|
void amiga_open_lib_error(char *name, int version)
|
|
{
|
|
printf(OPEN_VER_ERROR, name, version);
|
|
}
|
|
|
|
void close_libs()
|
|
{
|
|
if (DOSBase != NULL) {
|
|
CloseLibrary(DOSBase);
|
|
DOSBase = NULL;
|
|
}
|
|
|
|
if (SocketBase != NULL) {
|
|
CloseLibrary(SocketBase);
|
|
SocketBase = NULL;
|
|
}
|
|
}
|
|
|
|
int open_libs()
|
|
{
|
|
atexit(close_libs);
|
|
|
|
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
|
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
|
return 5;
|
|
}
|
|
|
|
if(!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV))) {
|
|
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
|
return 5;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int gettimeofday(struct timeval *tv, struct timezone* tz)
|
|
{
|
|
struct timeval tv1;
|
|
|
|
if (CreateTimer() != 0) {
|
|
tv->tv_secs = 0;
|
|
tv->tv_micro = 0;
|
|
return -1;
|
|
}
|
|
|
|
GetSysTime(&tv1);
|
|
*tv = tv1;
|
|
|
|
DeleteTimer();
|
|
return 0;
|
|
}
|
|
|
|
void srandom(unsigned int x) { }
|
|
|
|
#ifdef USE_SSL
|
|
int getuid() { return 55; }
|
|
void sigaction(int signum, void *act, void *oldact) { }
|
|
void tcgetattr(int fd, void *termios_p) { }
|
|
int tcsetattr(int fd, void *termios_p) { return 0; }
|
|
#endif
|