Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes16kdownloads
applink.c145 linesDownload Raw Back to openssl
1/*2 * Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.3 *4 * Licensed under the Apache License 2.0 (the "License").  You may not use5 * this file except in compliance with the License.  You can obtain a copy6 * in the file LICENSE in the source distribution or at7 * https://www.openssl.org/source/license.html8 */9 10#define APPLINK_STDIN   111#define APPLINK_STDOUT  212#define APPLINK_STDERR  313#define APPLINK_FPRINTF 414#define APPLINK_FGETS   515#define APPLINK_FREAD   616#define APPLINK_FWRITE  717#define APPLINK_FSETMOD 818#define APPLINK_FEOF    919#define APPLINK_FCLOSE  10      /* should not be used */20 21#define APPLINK_FOPEN   11      /* solely for completeness */22#define APPLINK_FSEEK   1223#define APPLINK_FTELL   1324#define APPLINK_FFLUSH  1425#define APPLINK_FERROR  1526#define APPLINK_CLEARERR 1627#define APPLINK_FILENO  17      /* to be used with below */28 29#define APPLINK_OPEN    18      /* formally can't be used, as flags can vary */30#define APPLINK_READ    1931#define APPLINK_WRITE   2032#define APPLINK_LSEEK   2133#define APPLINK_CLOSE   2234#define APPLINK_MAX     22      /* always same as last macro */35 36#ifndef APPMACROS_ONLY37# include <stdio.h>38# include <io.h>39# include <fcntl.h>40 41# ifdef __BORLANDC__42   /* _lseek in <io.h> is a function-like macro so we can't take its address */43#  undef _lseek44#  define _lseek lseek45# endif46 47static void *app_stdin(void)48{49    return stdin;50}51 52static void *app_stdout(void)53{54    return stdout;55}56 57static void *app_stderr(void)58{59    return stderr;60}61 62static int app_feof(FILE *fp)63{64    return feof(fp);65}66 67static int app_ferror(FILE *fp)68{69    return ferror(fp);70}71 72static void app_clearerr(FILE *fp)73{74    clearerr(fp);75}76 77static int app_fileno(FILE *fp)78{79    return _fileno(fp);80}81 82static int app_fsetmod(FILE *fp, char mod)83{84    return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);85}86 87#ifdef __cplusplus88extern "C" {89#endif90 91__declspec(dllexport)92void **93# if defined(__BORLANDC__)94/*95 * __stdcall appears to be the only way to get the name96 * decoration right with Borland C. Otherwise it works97 * purely incidentally, as we pass no parameters.98 */99__stdcall100# else101__cdecl102# endif103OPENSSL_Applink(void)104{105    static int once = 1;106    static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =107        { (void *)APPLINK_MAX };108 109    if (once) {110        OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;111        OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;112        OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;113        OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;114        OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;115        OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;116        OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;117        OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;118        OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;119        OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;120 121        OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;122        OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;123        OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;124        OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;125        OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;126        OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;127        OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;128 129        OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;130        OPENSSL_ApplinkTable[APPLINK_READ] = _read;131        OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;132        OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;133        OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;134 135        once = 0;136    }137 138    return OPENSSL_ApplinkTable;139}140 141#ifdef __cplusplus142}143#endif144#endif145 
codekingpro/portable-devtools · Team Ai