diff options
author | Andy Polyakov <appro@openssl.org> | 2004-05-25 20:31:03 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2004-05-25 20:31:03 +0000 |
commit | 3fc378aa0b464d6296fbf4f0d84b66a207b3f8a2 (patch) | |
tree | 969a0b60ab40e424b7a57e9ac6802796058015a2 /ms/applink.c | |
parent | f2bfbcef76d4a5d5cd8bccb51efd2441aaf88254 (diff) |
Framework for glueing BIO layer and Win32 compiler run-time. Goal is to
make it possible to produce for a unified binary build, which can be
used with a variety of Win32 compilers.
Diffstat (limited to 'ms/applink.c')
-rw-r--r-- | ms/applink.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ms/applink.c b/ms/applink.c new file mode 100644 index 0000000000..4333d2639d --- /dev/null +++ b/ms/applink.c @@ -0,0 +1,45 @@ +#define APPLINK_STDIN 1 +#define APPLINK_STDOUT 2 +#define APPLINK_STDERR 3 +#define APPLINK_FPRINTF 4 +#define APPLINK_FGETS 5 +#define APPLINK_FREAD 6 +#define APPLINK_FWRITE 7 +#define APPLINK_FSETMOD 8 +#define APPLINK_FEOF 9 +#define APPLINK_FCLOSE 10 /* should not be used */ +#define APPLINK_MAX 10 /* always same as last macro */ + +#ifndef APPMACROS_ONLY +#include <stdio.h> +#include <io.h> +#include <fcntl.h> + +static void *app_stdin() { return stdin; } +static void *app_stdout() { return stdout; } +static void *app_stderr() { return stderr; } +static int app_feof(FILE *fp) { return feof(fp); } +static int app_fsetmod(FILE *fp,char mod) +{ return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); } + +__declspec(dllexport) void **OPENSSL_Applink() +{ static int once=1; + static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX}; + + if (once) + { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; + OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; + OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; + OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; + OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; + OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; + OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; + OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; + OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; + OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; + once = 0; + } + + return OPENSSL_ApplinkTable; +} +#endif |