Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:12:02

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: laszlocsomor@google.com (Laszlo Csomor)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 // This file contains the declarations for Windows implementations of
0013 // commonly used POSIX functions such as open(2) and access(2), as well
0014 // as macro definitions for flags of these functions.
0015 //
0016 // By including this file you'll redefine open/access/etc. to
0017 // ::google::protobuf::io::win32::{open/access/etc.}.
0018 // Make sure you don't include a header that attempts to redeclare or
0019 // redefine these functions, that'll lead to confusing compilation
0020 // errors. It's best to #include this file as the last one to ensure that.
0021 //
0022 // This file is only used on Windows, it's empty on other platforms.
0023 
0024 #ifndef GOOGLE_PROTOBUF_IO_IO_WIN32_H__
0025 #define GOOGLE_PROTOBUF_IO_IO_WIN32_H__
0026 
0027 #if defined(_WIN32)
0028 
0029 #include <functional>
0030 #include <string>
0031 
0032 #include "google/protobuf/port.h"
0033 
0034 // Must be included last.
0035 #include "google/protobuf/port_def.inc"
0036 
0037 // Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
0038 // following functions already, except for mkdir.
0039 namespace google {
0040 namespace protobuf {
0041 namespace io {
0042 namespace win32 {
0043 
0044 PROTOBUF_EXPORT FILE* fopen(const char* path, const char* mode);
0045 PROTOBUF_EXPORT int access(const char* path, int mode);
0046 PROTOBUF_EXPORT int chdir(const char* path);
0047 PROTOBUF_EXPORT int close(int fd);
0048 PROTOBUF_EXPORT int dup(int fd);
0049 PROTOBUF_EXPORT int dup2(int fd1, int fd2);
0050 PROTOBUF_EXPORT int mkdir(const char* path, int _mode);
0051 PROTOBUF_EXPORT int open(const char* path, int flags, int mode = 0);
0052 PROTOBUF_EXPORT int read(int fd, void* buffer, size_t size);
0053 PROTOBUF_EXPORT int setmode(int fd, int mode);
0054 PROTOBUF_EXPORT int stat(const char* path, struct _stat* buffer);
0055 PROTOBUF_EXPORT int write(int fd, const void* buffer, size_t size);
0056 PROTOBUF_EXPORT std::wstring testonly_utf8_to_winpath(const char* path);
0057 
0058 enum class ExpandWildcardsResult {
0059   kSuccess = 0,
0060   kErrorNoMatchingFile = 1,
0061   kErrorInputPathConversion = 2,
0062   kErrorOutputPathConversion = 3,
0063 };
0064 
0065 // Expand wildcards in a path pattern, feed the result to a consumer function.
0066 //
0067 // `path` must be a valid, Windows-style path. It may be absolute, or relative
0068 // to the current working directory, and it may contain wildcards ("*" and "?")
0069 // in the last path segment. This function passes all matching file names to
0070 // `consume`. The resulting paths may not be absolute nor normalized.
0071 //
0072 // The function returns a value from `ExpandWildcardsResult`.
0073 PROTOBUF_EXPORT ExpandWildcardsResult ExpandWildcards(
0074     const std::string& path, std::function<void(const std::string&)> consume);
0075 
0076 namespace strings {
0077 
0078 // Convert from UTF-16 to Active-Code-Page-encoded or to UTF-8-encoded text.
0079 PROTOBUF_EXPORT bool wcs_to_mbs(const wchar_t* s, std::string* out,
0080                                 bool outUtf8);
0081 
0082 // Convert from Active-Code-Page-encoded or UTF-8-encoded text to UTF-16.
0083 PROTOBUF_EXPORT bool mbs_to_wcs(const char* s, std::wstring* out, bool inUtf8);
0084 
0085 // Convert from UTF-8-encoded text to UTF-16.
0086 PROTOBUF_EXPORT bool utf8_to_wcs(const char* input, std::wstring* out);
0087 
0088 // Convert from UTF-16-encoded text to UTF-8.
0089 PROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out);
0090 
0091 }  // namespace strings
0092 
0093 }  // namespace win32
0094 }  // namespace io
0095 }  // namespace protobuf
0096 }  // namespace google
0097 
0098 #ifndef W_OK
0099 #define W_OK 02  // not defined by MSVC for whatever reason
0100 #endif
0101 
0102 #ifndef F_OK
0103 #define F_OK 00  // not defined by MSVC for whatever reason
0104 #endif
0105 
0106 #ifndef STDIN_FILENO
0107 #define STDIN_FILENO 0
0108 #endif
0109 
0110 #ifndef STDOUT_FILENO
0111 #define STDOUT_FILENO 1
0112 #endif
0113 
0114 #include "google/protobuf/port_undef.inc"
0115 
0116 #endif  // defined(_WIN32)
0117 
0118 #endif  // GOOGLE_PROTOBUF_IO_IO_WIN32_H__