blob: e68c3904337f6f96f92f7c2af0d8f366174f6cbb [file] [log] [blame]
Lutz Justen85e0c392019-02-14 13:05:57 +01001// 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
14namespace base {
15class FilePath;
16}
17
18namespace 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).
24base::Optional<std::string> ReadPipeToString(int fd);
25
Lutz Justen2d857e12019-07-16 15:58:09 +020026// 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.
28base::ScopedFD WriteStringToPipe(const std::string& str);
29
Lutz Justen85e0c392019-02-14 13:05:57 +010030} // namespace kerberos
31
32#endif // KERBEROS_PLATFORM_HELPER_H_