applink.c

Go to the documentation of this file.
00001 #define APPLINK_STDIN   1
00002 #define APPLINK_STDOUT  2
00003 #define APPLINK_STDERR  3
00004 #define APPLINK_FPRINTF 4
00005 #define APPLINK_FGETS   5
00006 #define APPLINK_FREAD   6
00007 #define APPLINK_FWRITE  7
00008 #define APPLINK_FSETMOD 8
00009 #define APPLINK_FEOF 9
00010 #define APPLINK_FCLOSE  10 /* should not be used */
00011 
00012 #define APPLINK_FOPEN   11 /* solely for completeness */
00013 #define APPLINK_FSEEK   12
00014 #define APPLINK_FTELL   13
00015 #define APPLINK_FFLUSH  14
00016 #define APPLINK_FERROR  15
00017 #define APPLINK_CLEARERR 16
00018 #define APPLINK_FILENO  17 /* to be used with below */
00019 
00020 #define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
00021 #define APPLINK_READ 19
00022 #define APPLINK_WRITE   20
00023 #define APPLINK_LSEEK   21
00024 #define APPLINK_CLOSE   22
00025 #define APPLINK_MAX  22 /* always same as last macro */
00026 
00027 #ifndef APPMACROS_ONLY
00028 #include <stdio.h>
00029 #include <io.h>
00030 #include <fcntl.h>
00031 
00032 static void *app_stdin(void)     { return stdin;  }
00033 static void *app_stdout(void)    { return stdout; }
00034 static void *app_stderr(void)    { return stderr; }
00035 static int   app_feof(FILE *fp)     { return feof(fp); }
00036 static int   app_ferror(FILE *fp)   { return ferror(fp); }
00037 static void  app_clearerr(FILE *fp) { clearerr(fp); }
00038 static int   app_fileno(FILE *fp)   { return _fileno(fp); }
00039 static int   app_fsetmod(FILE *fp,char mod)
00040 { return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); }
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 __declspec(dllexport)
00047 void **
00048 #if defined(__BORLANDC__)
00049 __stdcall   /* __stdcall appears to be the only way to get the name
00050        * decoration right with Borland C. Otherwise it works
00051        * purely incidentally, as we pass no parameters. */
00052 #else
00053 __cdecl
00054 #endif
00055 OPENSSL_Applink(void)
00056 { static int once=1;
00057   static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX};
00058 
00059     if (once)
00060     { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
00061    OPENSSL_ApplinkTable[APPLINK_STDOUT]   = app_stdout;
00062    OPENSSL_ApplinkTable[APPLINK_STDERR]   = app_stderr;
00063    OPENSSL_ApplinkTable[APPLINK_FPRINTF]  = fprintf;
00064    OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
00065    OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
00066    OPENSSL_ApplinkTable[APPLINK_FWRITE]   = fwrite;
00067    OPENSSL_ApplinkTable[APPLINK_FSETMOD]  = app_fsetmod;
00068    OPENSSL_ApplinkTable[APPLINK_FEOF]  = app_feof;
00069    OPENSSL_ApplinkTable[APPLINK_FCLOSE]   = fclose;
00070 
00071    OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
00072    OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
00073    OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
00074    OPENSSL_ApplinkTable[APPLINK_FFLUSH]   = fflush;
00075    OPENSSL_ApplinkTable[APPLINK_FERROR]   = app_ferror;
00076    OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
00077    OPENSSL_ApplinkTable[APPLINK_FILENO]   = app_fileno;
00078 
00079    OPENSSL_ApplinkTable[APPLINK_OPEN]  = _open;
00080    OPENSSL_ApplinkTable[APPLINK_READ]  = _read;
00081    OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
00082    OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
00083    OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
00084 
00085    once = 0;
00086     }
00087 
00088   return OPENSSL_ApplinkTable;
00089 }
00090 
00091 #ifdef __cplusplus
00092 }
00093 #endif
00094 #endif

Generated on Thu Aug 20 22:33:05 2009 for OpenXDAS by  doxygen 1.5.6