Lutz Justen | 85e0c39 | 2019-02-14 13:05:57 +0100 | [diff] [blame] | 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef KERBEROS_PLATFORM_HELPER_H_ |
| 6 | #define KERBEROS_PLATFORM_HELPER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/files/scoped_file.h> |
| 11 | #include <base/macros.h> |
| 12 | #include <base/optional.h> |
| 13 | |
| 14 | namespace base { |
| 15 | class FilePath; |
| 16 | } |
| 17 | |
| 18 | namespace kerberos { |
| 19 | |
| 20 | // Reads the whole contents of the file descriptor |fd| into the returned |
| 21 | // string. If fd is a blocking pipe this call will block until the pipe is |
| 22 | // closed. Returns nullopt if the pipe could not be read or some limit was |
| 23 | // exceeded (see code). |
| 24 | base::Optional<std::string> ReadPipeToString(int fd); |
| 25 | |
Lutz Justen | 2d857e1 | 2019-07-16 15:58:09 +0200 | [diff] [blame] | 26 | // Creates a non-blocking pipe and writes the given string to it. |str| must be |
| 27 | // small enough to fit into the pipe buffer. Returns base::ScopedFD() on error. |
| 28 | base::ScopedFD WriteStringToPipe(const std::string& str); |
| 29 | |
Lutz Justen | 85e0c39 | 2019-02-14 13:05:57 +0100 | [diff] [blame] | 30 | } // namespace kerberos |
| 31 | |
| 32 | #endif // KERBEROS_PLATFORM_HELPER_H_ |