2 * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #define APPLINK_STDIN 1
11 #define APPLINK_STDOUT 2
12 #define APPLINK_STDERR 3
13 #define APPLINK_FPRINTF 4
14 #define APPLINK_FGETS 5
15 #define APPLINK_FREAD 6
16 #define APPLINK_FWRITE 7
17 #define APPLINK_FSETMOD 8
18 #define APPLINK_FEOF 9
19 #define APPLINK_FCLOSE 10 /* should not be used */
21 #define APPLINK_FOPEN 11 /* solely for completeness */
22 #define APPLINK_FSEEK 12
23 #define APPLINK_FTELL 13
24 #define APPLINK_FFLUSH 14
25 #define APPLINK_FERROR 15
26 #define APPLINK_CLEARERR 16
27 #define APPLINK_FILENO 17 /* to be used with below */
29 #define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
30 #define APPLINK_READ 19
31 #define APPLINK_WRITE 20
32 #define APPLINK_LSEEK 21
33 #define APPLINK_CLOSE 22
34 #define APPLINK_MAX 22 /* always same as last macro */
36 #ifndef APPMACROS_ONLY
41 static void *app_stdin(void)
46 static void *app_stdout(void)
51 static void *app_stderr(void)
56 static int app_feof(FILE *fp)
61 static int app_ferror(FILE *fp)
66 static void app_clearerr(FILE *fp)
71 static int app_fileno(FILE *fp)
76 static int app_fsetmod(FILE *fp, char mod)
78 return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
87 # if defined(__BORLANDC__)
89 * __stdcall appears to be the only way to get the name
90 * decoration right with Borland C. Otherwise it works
91 * purely incidentally, as we pass no parameters.
100 static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
101 { (void *)APPLINK_MAX };
104 OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
105 OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
106 OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
107 OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
108 OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
109 OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
110 OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
111 OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
112 OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
113 OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
115 OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
116 OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
117 OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
118 OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
119 OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
120 OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
121 OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
123 OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
124 OPENSSL_ApplinkTable[APPLINK_READ] = _read;
125 OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
126 OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
127 OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
132 return OPENSSL_ApplinkTable;