LLVM  6.0.0svn
FuzzerIO.h
Go to the documentation of this file.
1 //===- FuzzerIO.h - Internal header for IO utils ----------------*- C++ -* ===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // IO interface.
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_FUZZER_IO_H
13 #define LLVM_FUZZER_IO_H
14 
15 #include "FuzzerDefs.h"
16 
17 namespace fuzzer {
18 
19 long GetEpoch(const std::string &Path);
20 
21 Unit FileToVector(const std::string &Path, size_t MaxSize = 0,
22  bool ExitOnError = true);
23 
24 std::string FileToString(const std::string &Path);
25 
26 void CopyFileToErr(const std::string &Path);
27 
28 void WriteToFile(const Unit &U, const std::string &Path);
29 
30 void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V,
31  long *Epoch, size_t MaxSize, bool ExitOnError);
32 
33 // Returns "Dir/FileName" or equivalent for the current OS.
34 std::string DirPlusFile(const std::string &DirPath,
35  const std::string &FileName);
36 
37 // Returns the name of the dir, similar to the 'dirname' utility.
38 std::string DirName(const std::string &FileName);
39 
40 // Returns path to a TmpDir.
41 std::string TmpDir();
42 
43 bool IsInterestingCoverageFile(const std::string &FileName);
44 
45 void DupAndCloseStderr();
46 
47 void CloseStdout();
48 
49 void Printf(const char *Fmt, ...);
50 
51 // Print using raw syscalls, useful when printing at early init stages.
52 void RawPrint(const char *Str);
53 
54 // Platform specific functions:
55 bool IsFile(const std::string &Path);
56 
57 void ListFilesInDirRecursive(const std::string &Dir, long *Epoch,
58  std::vector<std::string> *V, bool TopDir);
59 
60 char GetSeparator();
61 
62 FILE* OpenFile(int Fd, const char *Mode);
63 
64 int CloseFile(int Fd);
65 
66 int DuplicateFile(int Fd);
67 
68 void RemoveFile(const std::string &Path);
69 
70 void DiscardOutput(int Fd);
71 
73 
74 } // namespace fuzzer
75 
76 #endif // LLVM_FUZZER_IO_H
int CloseFile(int Fd)
SI Whole Quad Mode
int DuplicateFile(int Fd)
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, std::vector< std::string > *V, bool TopDir)
bool IsFile(const std::string &Path)
void CloseStdout()
Definition: FuzzerIO.cpp:108
void DupAndCloseStderr()
Definition: FuzzerIO.cpp:94
std::string FileToString(const std::string &Path)
Definition: FuzzerIO.cpp:53
void ReadDirToVectorOfUnits(const char *Path, std::vector< Unit > *V, long *Epoch, size_t MaxSize, bool ExitOnError)
Definition: FuzzerIO.cpp:71
long GetEpoch(const std::string &Path)
Definition: FuzzerIO.cpp:26
void Printf(const char *Fmt,...)
Definition: FuzzerIO.cpp:112
FILE * OpenFile(int Fd, const char *Mode)
std::string DirPlusFile(const std::string &DirPath, const std::string &FileName)
Definition: FuzzerIO.cpp:89
intptr_t GetHandleFromFd(int fd)
void CopyFileToErr(const std::string &Path)
Definition: FuzzerIO.cpp:59
void WriteToFile(const Unit &U, const std::string &Path)
Definition: FuzzerIO.cpp:63
Unit FileToVector(const std::string &Path, size_t MaxSize, bool ExitOnError)
Definition: FuzzerIO.cpp:33
void RemoveFile(const std::string &Path)
std::string TmpDir()
void DiscardOutput(int Fd)
std::vector< uint8_t > Unit
Definition: FuzzerDefs.h:105
std::string DirName(const std::string &FileName)
bool IsInterestingCoverageFile(const std::string &FileName)
char GetSeparator()
void RawPrint(const char *Str)