thread.h \
timer.cpp \
timer.h \
+ unix.cpp \
unix.h \
+ win32.cpp \
win32.h
<ClCompile Include="tcpsocket.cpp" />
<ClCompile Include="thread.cpp" />
<ClCompile Include="timer.cpp" />
+ <ClCompile Include="unix.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="application.h" />
#define PLATFORM_UNIX 2
#ifdef _WIN32
-# define I2_PLATFORM Platform_Windows
+# define I2_PLATFORM PLATFORM_WINDOWS
# include "win32.h"
#else
-# define I2_PLATFORM Platform_Unix
+# define I2_PLATFORM PLATFORM_UNIX
# include "unix.h"
#endif
#else /* _WIN32 */
pthread_join(m_Thread, NULL);
#endif
-}
\ No newline at end of file
+}
--- /dev/null
+#include "i2-base.h"
+
+#if I2_PLATFORM == PLATFORM_UNIX
+#include <ltdl.h>
+
+using namespace icinga;
+
+void Sleep(unsigned long milliseconds)
+{
+ usleep(milliseconds * 1000);
+}
+
+inline void closesocket(SOCKET fd)
+{
+ close(fd);
+}
+
+inline HMODULE LoadLibrary(const char *filename)
+{
+ lt_dlhandle handle = 0;
+ lt_dladvise advise;
+
+ if (!lt_dladvise_init(&advise) && !lt_dladvise_global(&advise)) {
+ handle = lt_dlopenadvise(filename, advise);
+ }
+
+ lt_dladvise_destroy(&advise);
+
+ return handle;
+}
+
+inline void FreeLibrary(HMODULE module)
+{
+ if (module)
+ lt_dlclose(module);
+}
+
+inline void *GetProcAddress(HMODULE module, const char *function)
+{
+ return lt_dlsym(module, function);
+}
+
+#endif /* I2_PLATFORM == PLATFORM_UNIX */
#ifndef UNIX_H
#define UNIX_H
-#include <ltdl.h>
-#include <execinfo.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <pthread.h>
-typedef int SOCKET;
+void Sleep(unsigned long milliseconds);
+typedef int SOCKET;
#define INVALID_SOCKET (-1)
-
-inline void Sleep(unsigned long milliseconds)
-{
- usleep(milliseconds * 1000);
-}
-
-inline void closesocket(int fd)
-{
- close(fd);
-}
+void closesocket(SOCKET fd);
#define ioctlsocket ioctl
#define I2_EXPORT
#define I2_IMPORT
-typedef lt_dlhandle HMODULE;
+typedef void *HMODULE;
#define INVALID_HANDLE_VALUE NULL
-inline HMODULE LoadLibrary(const char *filename)
-{
- lt_dlhandle handle = 0;
- lt_dladvise advise;
-
- if (!lt_dladvise_init(&advise) && !lt_dladvise_global(&advise)) {
- handle = lt_dlopenadvise(filename, advise);
- }
-
- lt_dladvise_destroy(&advise);
-
- return handle;
-}
-
-inline void FreeLibrary(HMODULE module)
-{
- if (module)
- lt_dlclose(module);
-}
-
-inline void *GetProcAddress(HMODULE module, const char *function)
-{
- return lt_dlsym(module, function);
-}
+HMODULE LoadLibrary(const char *filename);
+void FreeLibrary(HMODULE module);
+void *GetProcAddress(HMODULE module, const char *function);
#endif /* UNIX_H */
--- /dev/null
+#include "i2-base.h"
+
+#if I2_PLATFORM == PLATFORM_WINDOWS
+
+using namespace icinga;
+
+/* nothing here (yet) */
+
+#endif /* I2_PLATFORM == PLATFORM_WINDOWS */