diff --git a/src/conio/Makefile b/src/conio/Makefile
index 6b6ef0fb807a113850d6d1b4df12398654806f34..13f6b2b69d32f2a38fff3cffa13246b9094f27e0 100644
--- a/src/conio/Makefile
+++ b/src/conio/Makefile
@@ -1,4 +1,4 @@
-# smblib/Makefile
+# conio/Makefile
 
 #########################################################################
 # Makefile for Synchronet Message Base Library (SMBLIB)					#
@@ -10,6 +10,9 @@
 
 # $Id$
 
+# To build a DLL, use "make [OPTIONS] DLLIBS=1 dl-mtlib"
+# You *MUST* do a clean between a static and dynamic lib on Win32!
+
 # Macros
 #DEBUG	=	1				# Comment out for release (non-debug) version
 
@@ -21,17 +24,31 @@ SRC_ROOT = ..
 OBJS		= $(OBJS) $(MTOBJODIR)$(DIRSEP)sdl_con$(OFILE) $(MTOBJODIR)$(DIRSEP)SDL_win32_main$(OFILE)
 !endif
 
+#The following is necessary only when DLL-exporting wrapper functions
+!ifdef DLLIBS
+CFLAGS  =       $(CFLAGS) -DCIOLIB_EXPORTS=1 -DWRAPPER_IMPORTS=1
+LDFLAGS =	$(LDFLAGS) -L$(LIBODIR)
+!endif
+
 CFLAGS = -w-par -w-csu $(CFLAGS) $(XPDEV-MT_CFLAGS) $(CIOLIB-MT_CFLAGS) $(MT_CFLAGS) -I$(CIOLIB_SRC)
 OBJS = $(OBJS) $(MTOBJODIR)$(DIRSEP)win32cio$(OFILE)
 
 mtlib: $(LIBODIR)$(DIRSEP)ciolib.res
 
+dl-mtlib: $(LIBODIR)$(DIRSEP)ciolib.res
+
 $(LIBODIR)$(DIRSEP)ciolib.res: ciolib.rc syncicon64.ico
 	@echo Creating $< ...
 	$(QUIET)brcc32 -fo$@ -32 ciolib.rc
 
-# SBBS DLL Link Rule
 $(CIOLIB-MT_BUILD): $(OBJS)
 	@echo Creating $< ...
 	-$(QUIET)$(DELETE) $@
 	&$(QUIET)tlib $@ +$**
+
+$(CIOLIB-MT_SHLIB_BUILD): $(OBJS)
+	@echo Linking $@
+	$(QUIET)$(MKSHLIB) $(MT_LDFLAGS) $(XPDEV-MT_LDFLAGS) -lGi -e$@ $(LDFLAGS) $(SHLIBOPTS) $(XPDEV-MT_LIBS) @&&|
+	$**
+	cw32mt.lib
+|
diff --git a/src/conio/ansi_cio.c b/src/conio/ansi_cio.c
index 37983575ff20c17afe393dd8f00a654100c6a489..c96ec2906bb64f88319c2076570fa9a5c564da48 100644
--- a/src/conio/ansi_cio.c
+++ b/src/conio/ansi_cio.c
@@ -44,6 +44,13 @@
 	struct termios tio_default;				/* Initial term settings */
 #endif
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "ansi_cio.h"
 
diff --git a/src/conio/ansi_cio.h b/src/conio/ansi_cio.h
index f8ba908c4f84a4b1cf00fb7bf2b5729d4398d95a..acfe94ce517b648810d51ee10081d8622db8eb40 100644
--- a/src/conio/ansi_cio.h
+++ b/src/conio/ansi_cio.h
@@ -31,6 +31,13 @@
  * Note: If this box doesn't appear square, then you need to fix your tabs.	*
  ****************************************************************************/
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 
 #ifdef __cplusplus
diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c
index e6b69c04abaf688eae61a26cabd220bf9200fa0d..ba0b27351362e0996cf7fafffdd6ab177dab2a77 100644
--- a/src/conio/ciolib.c
+++ b/src/conio/ciolib.c
@@ -58,50 +58,50 @@
 
 #include "ansi_cio.h"
 
-cioapi_t	cio_api;
+CIOLIBEXPORT cioapi_t	cio_api;
 
 static int ungotch;
 static struct text_info cio_textinfo;
 static int lastmode=3;
-int _wscroll=1;
-int directvideo=0;
-int hold_update=0;
+CIOLIBEXPORT int _wscroll=1;
+CIOLIBEXPORT int directvideo=0;
+CIOLIBEXPORT int hold_update=0;
 static int initialized=0;
 
-int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
-char *ciolib_cgets(char *str);
-int ciolib_cscanf (char *format , ...);
-int ciolib_kbhit(void);
-int ciolib_getch(void);
-int ciolib_getche(void);
-int ciolib_ungetch(int ch);
-void ciolib_gettextinfo(struct text_info *info);
-int ciolib_wherex(void);
-int ciolib_wherey(void);
-void ciolib_wscroll(void);
-void ciolib_gotoxy(int x, int y);
-void ciolib_clreol(void);
-void ciolib_clrscr(void);
-int ciolib_cputs(char *str);
-int	ciolib_cprintf(char *fmat, ...);
-void ciolib_textbackground(int colour);
-void ciolib_textcolor(int colour);
-void ciolib_highvideo(void);
-void ciolib_lowvideo(void);
-void ciolib_normvideo(void);
-int ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
-int ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
-void ciolib_textattr(int a);
-void ciolib_delay(long a);
-int ciolib_putch(int a);
-void ciolib_setcursortype(int a);
-void ciolib_textmode(int mode);
-void ciolib_window(int sx, int sy, int ex, int ey);
-void ciolib_delline(void);
-void ciolib_insline(void);
-char *ciolib_getpass(const char *prompt);
-void ciolib_copytext(const char *text, size_t buflen);
-char *ciolib_getcliptext(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str);
+CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...);
+CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch);
+CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info);
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y);
+CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str);
+CIOLIBEXPORT int	CIOLIBCALL ciolib_cprintf(char *fmat, ...);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour);
+CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a);
+CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode);
+CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey);
+CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt);
+CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void);
 
 #define CIOLIB_INIT()		{ if(!initialized) initciolib(CIOLIB_MODE_AUTO); }
 
@@ -258,7 +258,7 @@ int try_conio_init(int mode)
 }
 #endif
 
-int initciolib(int mode)
+CIOLIBEXPORT int CIOLIBCALL initciolib(int mode)
 {
 	memset(&cio_api,0,sizeof(cio_api));
 
@@ -320,7 +320,7 @@ int initciolib(int mode)
 	return(0);
 }
 
-int ciolib_kbhit(void)
+CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void)
 {
 	CIOLIB_INIT();
 	if(ungotch)
@@ -328,7 +328,7 @@ int ciolib_kbhit(void)
 	return(cio_api.kbhit());
 }
 
-int ciolib_getch(void)
+CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void)
 {
 	int ch;
 
@@ -342,7 +342,7 @@ int ciolib_getch(void)
 	return(cio_api.getch());
 }
 
-int ciolib_getche(void)
+CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void)
 {
 	int ch;
 
@@ -357,7 +357,7 @@ int ciolib_getche(void)
 	return(cio_api.getche());
 }
 
-int ciolib_ungetch(int ch)
+CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch)
 {
 	CIOLIB_INIT();
 	
@@ -367,7 +367,7 @@ int ciolib_ungetch(int ch)
 	return(ch);
 }
 
-int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy)
+CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy)
 {
 	int width;
 	int height;
@@ -395,7 +395,7 @@ int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy)
 	return(1);
 }
 
-char *ciolib_cgets(char *str)
+CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str)
 {
 	int	maxlen;
 	int len=0;
@@ -467,7 +467,7 @@ int vsscanf( const char *buffer, const char *format, va_list arg_ptr )
 }
 #endif
 
-int ciolib_cscanf (char *format , ...)
+CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...)
 {
 	char str[255];
     va_list argptr;
@@ -482,7 +482,7 @@ int ciolib_cscanf (char *format , ...)
 	return(ret);
 }
 
-char *ciolib_getpass(const char *prompt)
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt)
 {
 	static char pass[9];
 	int len=0;
@@ -517,7 +517,7 @@ char *ciolib_getpass(const char *prompt)
 	return(pass);
 }
 
-void ciolib_gettextinfo(struct text_info *info)
+CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info)
 {
 	if(!initialized)
 		initciolib(CIOLIB_MODE_AUTO);
@@ -540,7 +540,7 @@ void ciolib_gettextinfo(struct text_info *info)
 	}
 }
 
-void ciolib_wscroll(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void)
 {
 	int os;
 	struct text_info ti;
@@ -564,7 +564,7 @@ void ciolib_wscroll(void)
 	ciolib_gotoxy(ti.curx,ti.cury);
 }
 
-int ciolib_wherex(void)
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void)
 {
 	int x;
 
@@ -575,7 +575,7 @@ int ciolib_wherex(void)
 	return(x);
 }
 
-int ciolib_wherey(void)
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void)
 {
 	int y;
 
@@ -586,7 +586,7 @@ int ciolib_wherey(void)
 	return(y);
 }
 
-void ciolib_gotoxy(int x, int y)
+CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y)
 {
 	int nx;
 	int ny;
@@ -605,7 +605,7 @@ void ciolib_gotoxy(int x, int y)
 	cio_api.gotoxy(nx,ny);
 }
 
-void ciolib_textmode(int mode)
+CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode)
 {
 	CIOLIB_INIT();
 	
@@ -626,7 +626,7 @@ void ciolib_textmode(int mode)
 	cio_textinfo.winbottom=cio_textinfo.screenheight;
 }
 
-void ciolib_window(int sx, int sy, int ex, int ey)
+CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey)
 {
 	CIOLIB_INIT();
 	
@@ -649,7 +649,7 @@ void ciolib_window(int sx, int sy, int ex, int ey)
 	ciolib_gotoxy(1,1);
 }
 
-void ciolib_clreol(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void)
 {
 	unsigned char *buf;
 	int i;
@@ -671,7 +671,7 @@ void ciolib_clreol(void)
 	free(buf);
 }
 
-void ciolib_clrscr(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void)
 {
 	unsigned char *buf;
 	int i;
@@ -693,7 +693,7 @@ void ciolib_clrscr(void)
 	free(buf);
 }
 
-void ciolib_delline(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void)
 {
 	struct text_info ti;
 
@@ -707,7 +707,7 @@ void ciolib_delline(void)
 	ciolib_gotoxy(ti.curx,ti.cury);
 }
 
-void ciolib_insline(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void)
 {
 	struct text_info ti;
 
@@ -721,7 +721,7 @@ void ciolib_insline(void)
 	ciolib_gotoxy(ti.curx,ti.cury);
 }
 
-int ciolib_cprintf(char *fmat, ...)
+CIOLIBEXPORT int CIOLIBCALL ciolib_cprintf(char *fmat, ...)
 {
     va_list argptr;
 	int		ret;
@@ -756,7 +756,7 @@ int ciolib_cprintf(char *fmat, ...)
     return(ret);
 }
 
-int ciolib_cputs(char *str)
+CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str)
 {
 	int		pos;
 	int		ret=0;
@@ -778,7 +778,7 @@ int ciolib_cputs(char *str)
 	return(ret);
 }
 
-void ciolib_textbackground(int colour)
+CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour)
 {
 	unsigned char attr;
 	unsigned char col;
@@ -793,7 +793,7 @@ void ciolib_textbackground(int colour)
 	ciolib_textattr(attr);
 }
 
-void ciolib_textcolor(int colour)
+CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour)
 {
 	unsigned char attr;
 	unsigned char col;
@@ -808,7 +808,7 @@ void ciolib_textcolor(int colour)
 	ciolib_textattr(attr);
 }
 
-void ciolib_highvideo(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void)
 {
 	int attr;
 
@@ -820,7 +820,7 @@ void ciolib_highvideo(void)
 	ciolib_textattr(attr);
 }
 
-void ciolib_lowvideo(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void)
 {
 	int attr;
 
@@ -832,42 +832,42 @@ void ciolib_lowvideo(void)
 	ciolib_textattr(attr);
 }
 
-void ciolib_normvideo(void)
+CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void)
 {
 	CIOLIB_INIT();
 	
 	ciolib_textattr(0x07);
 }
 
-int ciolib_puttext(int a,int b,int c,int d,unsigned char *e)
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e)
 {
 	CIOLIB_INIT();
 	
 	return(cio_api.puttext(a,b,c,d,e));
 }
 
-int ciolib_gettext(int a,int b,int c,int d,unsigned char *e)
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e)
 {
 	CIOLIB_INIT();
 	
 	return(cio_api.gettext(a,b,c,d,e));
 }
 
-void ciolib_textattr(int a)
+CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a)
 {
 	CIOLIB_INIT();
 	
 	cio_api.textattr(a);
 }
 
-void ciolib_delay(long a)
+CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a)
 {
 	CIOLIB_INIT();
 	
 	cio_api.delay(a);
 }
 
-int ciolib_putch(int a)
+CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a)
 {
 	unsigned char a1=a;
 	CIOLIB_INIT();
@@ -875,14 +875,14 @@ int ciolib_putch(int a)
 	return(cio_api.putch(a1));
 }
 
-void ciolib_setcursortype(int a)
+CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a)
 {
 	CIOLIB_INIT();
 	
 	cio_api.setcursortype(a);
 }
 
-int ciolib_showmouse(void) {
+CIOLIBEXPORT int CIOLIBCALL ciolib_showmouse(void) {
 	CIOLIB_INIT();
 
 	if(cio_api.showmouse!=NULL)
@@ -890,7 +890,7 @@ int ciolib_showmouse(void) {
 	return(-1);
 }
 
-int ciolib_hidemouse(void) {
+CIOLIBEXPORT int CIOLIBCALL ciolib_hidemouse(void) {
 	CIOLIB_INIT();
 
 	if(cio_api.hidemouse!=NULL)
@@ -898,21 +898,21 @@ int ciolib_hidemouse(void) {
 	return(-1);
 }
 
-void ciolib_setname(const char *name) {
+CIOLIBEXPORT void CIOLIBCALL ciolib_setname(const char *name) {
 	CIOLIB_INIT();
 
 	if(cio_api.setname!=NULL)
 		cio_api.setname(name);
 }
 
-void ciolib_settitle(const char *title) {
+CIOLIBEXPORT void CIOLIBCALL ciolib_settitle(const char *title) {
 	CIOLIB_INIT();
 
 	if(cio_api.settitle!=NULL)
 		cio_api.settitle(title);
 }
 
-void ciolib_copytext(const char *text, size_t buflen)
+CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen)
 {
 	CIOLIB_INIT();
 
@@ -920,7 +920,7 @@ void ciolib_copytext(const char *text, size_t buflen)
 		cio_api.copytext(text,buflen);
 }
 
-char *ciolib_getcliptext(void)
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void)
 {
 	CIOLIB_INIT();
 
diff --git a/src/conio/ciolib.h b/src/conio/ciolib.h
index e238aa829aa7126cb8c58aeab9c2599d2a638b74..1d63eb09c8024660e3bcf9ab53d35ce66a547f83 100644
--- a/src/conio/ciolib.h
+++ b/src/conio/ciolib.h
@@ -37,6 +37,36 @@
 #include <string.h>	/* size_t */
 #include "mouse.h"
 
+#ifdef CIOLIBEXPORT
+        #undef CIOLIBEXPORT
+#endif
+
+#ifdef _WIN32
+        #ifdef __BORLANDC__
+                #define CIOLIBCALL __stdcall
+        #else
+                #define CIOLIBCALL
+        #endif
+        #if defined(CIOLIB_IMPORTS) || defined(CIOLIB_EXPORTS)
+                #if defined(CIOLIB_IMPORTS)
+                        #define CIOLIBEXPORT __declspec( dllimport )
+                        #define CIOLIBEXPORTVAR __declspec( dllimport )
+                #else
+                        #define CIOLIBEXPORT __declspec( dllexport )
+                        #define CIOLIBEXPORTVAR __declspec( dllexport )
+                #endif
+        #else   /* self-contained executable */
+                #define CIOLIBEXPORT
+                #define CIOLIBEXPORTVAR	extern
+        #endif
+#elif defined __unix__
+        #define CIOLIBCALL
+        #define CIOLIBEXPORT
+#else
+        #define CIOLIBCALL
+        #define CIOLIBEXPORT
+#endif
+
 enum {
 	 CIOLIB_MODE_AUTO
 	,CIOLIB_MODE_CURSES
@@ -201,56 +231,56 @@ typedef struct {
 	char 	*(*getcliptext)	(void);
 } cioapi_t;
 
-extern cioapi_t cio_api;
-extern int _wscroll;
-extern int directvideo;
-extern int hold_update;
+CIOLIBEXPORTVAR cioapi_t cio_api;
+CIOLIBEXPORTVAR int _wscroll;
+CIOLIBEXPORTVAR int directvideo;
+CIOLIBEXPORTVAR int hold_update;
 
 #define _conio_kbhit()		kbhit()
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-int initciolib(int mode);
-
-int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
-char *ciolib_cgets(char *str);
-int ciolib_cscanf (char *format , ...);
-int ciolib_kbhit(void);
-int ciolib_getch(void);
-int ciolib_getche(void);
-int ciolib_ungetch(int ch);
-void ciolib_gettextinfo(struct text_info *info);
-int ciolib_wherex(void);
-int ciolib_wherey(void);
-void ciolib_wscroll(void);
-void ciolib_gotoxy(int x, int y);
-void ciolib_clreol(void);
-void ciolib_clrscr(void);
-int ciolib_cputs(char *str);
-int	ciolib_cprintf(char *fmat, ...);
-void ciolib_textbackground(int colour);
-void ciolib_textcolor(int colour);
-void ciolib_highvideo(void);
-void ciolib_lowvideo(void);
-void ciolib_normvideo(void);
-int ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
-int ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
-void ciolib_textattr(int a);
-void ciolib_delay(long a);
-int ciolib_putch(int a);
-void ciolib_setcursortype(int a);
-void ciolib_textmode(int mode);
-void ciolib_window(int sx, int sy, int ex, int ey);
-void ciolib_delline(void);
-void ciolib_insline(void);
-char *ciolib_getpass(const char *prompt);
-void ciolib_settitle(const char *title);
-void ciolib_setname(const char *title);
-int ciolib_showmouse(void);
-int ciolib_hidemouse(void);
-void ciolib_copytext(const char *text, size_t buflen);
-char *ciolib_getcliptext(void);
+CIOLIBEXPORT int CIOLIBCALL initciolib(int mode);
+
+CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str);
+CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...);
+CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch);
+CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info);
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y);
+CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str);
+CIOLIBEXPORT int	CIOLIBCALL ciolib_cprintf(char *fmat, ...);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour);
+CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a);
+CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a);
+CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode);
+CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey);
+CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt);
+CIOLIBEXPORT void CIOLIBCALL ciolib_settitle(const char *title);
+CIOLIBEXPORT void CIOLIBCALL ciolib_setname(const char *title);
+CIOLIBEXPORT int CIOLIBCALL ciolib_showmouse(void);
+CIOLIBEXPORT int CIOLIBCALL ciolib_hidemouse(void);
+CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen);
+CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/conio/cterm.c b/src/conio/cterm.c
index 903a1bf28a9912d6ebefd1fb0b195a6cd94d008b..4deeb47248d5a081a5ba346763caf097bf2f6265 100644
--- a/src/conio/cterm.c
+++ b/src/conio/cterm.c
@@ -36,9 +36,17 @@
 #include <string.h>
 
 #include <genwrap.h>
-#include <ciolib.h>
 #include <xpbeep.h>
-#include <keys.h>
+
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
+#include "ciolib.h"
+#include "keys.h"
 
 #include "cterm.h"
 
diff --git a/src/conio/curs_cio.c b/src/conio/curs_cio.c
index cc710062cdd47421d6c3f0aa312d2242062d8e86..05e563c9e83deaad0b92d60aa61ee4df9c462390 100644
--- a/src/conio/curs_cio.c
+++ b/src/conio/curs_cio.c
@@ -39,6 +39,13 @@
 
 #include "gen_defs.h"	/* xpdev, for BOOL/TRUE/FALSE */
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "curs_cio.h"
 #include "keys.h"
diff --git a/src/conio/curs_cio.h b/src/conio/curs_cio.h
index f14a8ad104bb48ce6763a2f5ec2ba8d34f774179..e74172635c070f8254ea619ee94aff9635cd4b59 100644
--- a/src/conio/curs_cio.h
+++ b/src/conio/curs_cio.h
@@ -32,6 +32,13 @@
  ****************************************************************************/
 
 #ifdef __unix__
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #undef getch
 #undef ungetch
diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c
index f351bcf3ebac6a3128c07a3b8087dd6984fcf34f..d4d56f156d457ccac2fc89385f8d170570521470 100644
--- a/src/conio/sdl_con.c
+++ b/src/conio/sdl_con.c
@@ -14,6 +14,13 @@
 #include "genwrap.h"
 #include "xpbeep.h"
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "keys.h"
 #include "vidmodes.h"
diff --git a/src/conio/vidmodes.h b/src/conio/vidmodes.h
index 227c4d67cd5cb7323563b15b5b2c36494dc8260f..4123c7d513b2ac63141f7450127f7349827f3f6c 100644
--- a/src/conio/vidmodes.h
+++ b/src/conio/vidmodes.h
@@ -34,6 +34,13 @@
 #ifndef _VIDMODES_H_
 #define _VIDMODES_H_
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 
 struct  video_params {
diff --git a/src/conio/win32cio.c b/src/conio/win32cio.c
index e19724ee4a0e05ae35abd66ffb3ba27fdd639529..1c699e2cd9d00153437c770092d2b4c718caa70e 100644
--- a/src/conio/win32cio.c
+++ b/src/conio/win32cio.c
@@ -35,6 +35,13 @@
 #include <genwrap.h>
 #include <stdio.h>		/* stdin */
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "keys.h"
 #include "vidmodes.h"
diff --git a/src/conio/x_cio.c b/src/conio/x_cio.c
index 3b766058643c14551302e7afe50e1ee58ca19a19..4188ed56ab624df06db3175f9eef6a51fdd73722 100644
--- a/src/conio/x_cio.c
+++ b/src/conio/x_cio.c
@@ -38,6 +38,13 @@
 
 #include <threadwrap.h>
 
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "x_cio.h"
 #include "console.h"
diff --git a/src/conio/x_cio.h b/src/conio/x_cio.h
index 95c7f59de65d89ee8b4c4277bb70568257611a48..0af06fb9c3c1eddd6c7588e11cafddf1643917e4 100644
--- a/src/conio/x_cio.h
+++ b/src/conio/x_cio.h
@@ -32,6 +32,13 @@
  ****************************************************************************/
 
 #ifdef __unix__
+#if (defined CIOLIB_IMPORTS)
+ #undef CIOLIB_IMPORTS
+#endif
+#if (defined CIOLIB_EXPORTS)
+ #undef CIOLIB_EXPORTS
+#endif
+
 #include "ciolib.h"
 #include "console.h"