1 /* 2 * 3 * honggfuzz - file operations 4 * ----------------------------------------- 5 * 6 * Author: Robert Swiecki <swiecki@google.com> 7 * 8 * Copyright 2010-2015 by Google Inc. All Rights Reserved. 9 * 10 * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 * not use this file except in compliance with the License. You may obtain 12 * a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 19 * implied. See the License for the specific language governing 20 * permissions and limitations under the License. 21 * 22 */ 23 24 #ifndef _HF_FILES_H_ 25 #define _HF_FILES_H_ 26 27 #include <stdint.h> 28 #include <unistd.h> 29 30 extern bool files_init(honggfuzz_t * hfuzz); 31 32 extern size_t files_readFileToBufMax(char *fileName, uint8_t * buf, size_t fileMaxSz); 33 34 extern bool files_writeBufToFile(char *fileName, uint8_t * buf, size_t fileSz, int flags); 35 36 extern bool files_writeToFd(int fd, uint8_t * buf, size_t fileSz); 37 38 extern bool files_writeStrToFd(int fd, char *str); 39 40 extern size_t files_readFromFd(int fd, uint8_t * buf, size_t fileSz); 41 42 extern bool files_writePatternToFd(int fd, off_t size, unsigned char p); 43 44 extern bool files_exists(char *fileName); 45 46 extern char *files_basename(char *fileName); 47 48 extern bool files_parseDictionary(honggfuzz_t * hfuzz); 49 50 extern bool files_copyFile(const char *source, const char *destination, bool * dstExists); 51 52 extern bool files_parseBlacklist(honggfuzz_t * hfuzz); 53 54 extern uint8_t *files_mapFile(char *fileName, off_t * fileSz, int *fd, bool isWritable); 55 56 extern bool files_readPidFromFile(const char *fileName, pid_t * pidPtr); 57 58 #endif 59