LTKCPP-- LLRP Toolkit C Plus Plus Library
|
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) 00033 { 00034 return stdin; 00035 } 00036 00037 static void *app_stdout(void) 00038 { 00039 return stdout; 00040 } 00041 00042 static void *app_stderr(void) 00043 { 00044 return stderr; 00045 } 00046 00047 static int app_feof(FILE *fp) 00048 { 00049 return feof(fp); 00050 } 00051 00052 static int app_ferror(FILE *fp) 00053 { 00054 return ferror(fp); 00055 } 00056 00057 static void app_clearerr(FILE *fp) 00058 { 00059 clearerr(fp); 00060 } 00061 00062 static int app_fileno(FILE *fp) 00063 { 00064 return _fileno(fp); 00065 } 00066 00067 static int app_fsetmod(FILE *fp, char mod) 00068 { 00069 return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT); 00070 } 00071 00072 #ifdef __cplusplus 00073 extern "C" { 00074 #endif 00075 00076 __declspec(dllexport) 00077 void ** 00078 # if defined(__BORLANDC__) 00079 /* 00080 * __stdcall appears to be the only way to get the name 00081 * decoration right with Borland C. Otherwise it works 00082 * purely incidentally, as we pass no parameters. 00083 */ 00084 __stdcall 00085 # else 00086 __cdecl 00087 # endif 00088 OPENSSL_Applink(void) 00089 { 00090 static int once = 1; 00091 static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] = 00092 { (void *)APPLINK_MAX }; 00093 00094 if (once) { 00095 OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; 00096 OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; 00097 OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; 00098 OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; 00099 OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; 00100 OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; 00101 OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; 00102 OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; 00103 OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; 00104 OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; 00105 00106 OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; 00107 OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; 00108 OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; 00109 OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; 00110 OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; 00111 OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; 00112 OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; 00113 00114 OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; 00115 OPENSSL_ApplinkTable[APPLINK_READ] = _read; 00116 OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; 00117 OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; 00118 OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; 00119 00120 once = 0; 00121 } 00122 00123 return OPENSSL_ApplinkTable; 00124 } 00125 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 #endif