1 /* 2 * xxhsum - Command line interface for xxhash algorithms 3 * Copyright (C) 2013-2020 Yann Collet 4 * 5 * GPL v2 License 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * You can contact the author at: 22 * - xxHash homepage: https://www.xxhash.com 23 * - xxHash source repository: https://github.com/Cyan4973/xxHash 24 */ 25 26 #ifndef XSUM_OS_SPECIFIC_H 27 #define XSUM_OS_SPECIFIC_H 28 29 #include "xsum_config.h" 30 #include <stdio.h> 31 #include <stdarg.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * Declared here to be implemented in user code. 39 * 40 * Functions like main(), but is passed UTF-8 arguments even on Windows. 41 */ 42 XSUM_API int XSUM_main(int argc, char* argv[]); 43 44 /* 45 * Returns whether stream is a console. 46 * 47 * Functionally equivalent to isatty(fileno(stream)). 48 */ 49 XSUM_API int XSUM_isConsole(FILE* stream); 50 51 /* 52 * Sets stream to pure binary mode (a.k.a. no CRLF conversions). 53 */ 54 XSUM_API void XSUM_setBinaryMode(FILE* stream); 55 56 /* 57 * Returns whether the file at filename is a directory. 58 */ 59 XSUM_API int XSUM_isDirectory(const char* filename); 60 61 /* 62 * Returns the file size of the file at filename. 63 */ 64 XSUM_API XSUM_U64 XSUM_getFileSize(const char* filename); 65 66 /* 67 * UTF-8 stdio wrappers primarily for Windows 68 */ 69 70 /* 71 * fopen() wrapper. Accepts UTF-8 filenames on Windows. 72 * 73 * Specifically, on Windows, the arguments will be converted to UTF-16 74 * and passed to _wfopen(). 75 */ 76 XSUM_API FILE* XSUM_fopen(const char* filename, const char* mode); 77 78 /* 79 * vfprintf() wrapper which prints UTF-8 strings to Windows consoles 80 * if applicable. 81 */ 82 XSUM_ATTRIBUTE((__format__(__printf__, 2, 0))) 83 XSUM_API int XSUM_vfprintf(FILE* stream, const char* format, va_list ap); 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 #endif /* XSUM_OS_SPECIFIC_H */ 90