41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
// LemonOSLib (lolib): simple system abstractions made specifically for LemonBBS
|
|
|
|
#ifndef LEMONBBS_OSLIB_H
|
|
#define LEMONBBS_OSLIB_H
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#ifdef _WIN32
|
|
#include <Ws2tcpip.h>
|
|
#elif defined(unix)
|
|
typedef int SOCKET;
|
|
#define INVALID_SOCKET -1
|
|
#include <sys/socket.h>
|
|
#include <arpa/inet.h>
|
|
#include <unistd.h>
|
|
#else
|
|
#error Platform not supported.
|
|
#endif
|
|
|
|
struct LemonClientSocket {
|
|
int type;
|
|
union Descriptor {
|
|
SSL* sslDescriptor;
|
|
SOCKET tcpDescriptor;
|
|
} descriptor;
|
|
};
|
|
|
|
typedef SOCKET LemonServerSocket;
|
|
|
|
int lolib_init();
|
|
int lolib_quit();
|
|
int lolib_finalize(struct LemonClientSocket *socket);
|
|
int lolib_enableSsl(const char* certfilePath, const char* keyfilePath, char* keyfilePassword);
|
|
int lolib_createServerSocket(const char* bindAddress, unsigned short port, LemonServerSocket *dst);
|
|
int lolib_acceptTcpSocket(LemonServerSocket serverSocket, struct LemonClientSocket *dst);
|
|
int lolib_acceptSslSocket(LemonServerSocket serverSocket, struct LemonClientSocket *dst);
|
|
int lolib_writeSocket(struct LemonClientSocket *socket, const char* data, unsigned int dataLength);
|
|
int lolib_readSocket(struct LemonClientSocket *socket, char *data, unsigned int bytesToRead);
|
|
|
|
#endif
|