68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
/*
|
|
* Written by Carsten Larsen.
|
|
* Public domain.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <clib/dos_protos.h>
|
|
#include <clib/exec_protos.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 37L
|
|
#define BSDLIB_NAME "bsdsocket.library"
|
|
#define BSDLIB_REV 03L
|
|
|
|
#include "config.h"
|
|
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (18.02.2016)";
|
|
|
|
#ifdef AOS3
|
|
int h_errno;
|
|
#endif
|
|
|
|
struct Library *DOSBase = NULL;
|
|
struct Library *SocketBase = NULL;
|
|
|
|
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);
|
|
InitSemaphore(&GetaddrinfoSemaphore);
|
|
|
|
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;
|
|
}
|