xsum_os_specific.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef XSUM_OS_SPECIFIC_H
  26. #define XSUM_OS_SPECIFIC_H
  27. #include "xsum_config.h"
  28. #include <stdio.h>
  29. #include <stdarg.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*
  34. * Declared here to be implemented in user code.
  35. *
  36. * Functions like main(), but is passed UTF-8 arguments even on Windows.
  37. */
  38. XSUM_API int XSUM_main(int argc, char* argv[]);
  39. /*
  40. * Returns whether stream is a console.
  41. *
  42. * Functionally equivalent to isatty(fileno(stream)).
  43. */
  44. XSUM_API int XSUM_isConsole(FILE* stream);
  45. /*
  46. * Sets stream to pure binary mode (a.k.a. no CRLF conversions).
  47. */
  48. XSUM_API void XSUM_setBinaryMode(FILE* stream);
  49. /*
  50. * Returns whether the file at filename is a directory.
  51. */
  52. XSUM_API int XSUM_isDirectory(const char* filename);
  53. /*
  54. * Returns the file size of the file at filename.
  55. */
  56. XSUM_API XSUM_U64 XSUM_getFileSize(const char* filename);
  57. /*
  58. * UTF-8 stdio wrappers primarily for Windows
  59. */
  60. /*
  61. * fopen() wrapper. Accepts UTF-8 filenames on Windows.
  62. *
  63. * Specifically, on Windows, the arguments will be converted to UTF-16
  64. * and passed to _wfopen().
  65. */
  66. XSUM_API FILE* XSUM_fopen(const char* filename, const char* mode);
  67. /*
  68. * vfprintf() wrapper which prints UTF-8 strings to Windows consoles
  69. * if applicable.
  70. */
  71. XSUM_ATTRIBUTE((__format__(__printf__, 2, 0)))
  72. XSUM_API int XSUM_vfprintf(FILE* stream, const char* format, va_list ap);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* XSUM_OS_SPECIFIC_H */