1#ifdef __cplusplus 2extern "C" { 3#endif 4 5#include "removefile.h" 6 7#include <sys/stat.h> 8#include <sys/param.h> 9#include <sys/mount.h> 10 11#include <err.h> 12#include <errno.h> 13#include <fcntl.h> 14#include <fts.h> 15#include <stdio.h> 16#include <stdlib.h> 17#include <string.h> 18#include <sysexits.h> 19#include <unistd.h> 20 21/* 22 * This structure contains variables necessary to keep track of verification, 23 * the flags set by the user, as well as associated buffers and file 24 * attributes. These were defined previously by srm as global variables but a 25 * structure is a much cleaner way of organizing the information and passing 26 * it between functions. 27 */ 28 29struct _removefile_state { 30 removefile_callback_t confirm_callback; 31 void * confirm_context; 32 removefile_callback_t error_callback; 33 void * error_context; 34 int error_num; // clear on proceed 35 removefile_callback_t status_callback; 36 void * status_context; 37 38 // globals for srm 39 int urand_file; 40 off_t random_bytes_read; 41 int file; 42 off_t file_size; 43 unsigned char * buffer; 44 uint32_t buffsize; 45 uint32_t allocated_buffsize; 46 int unlink_flags; 47 int cancelled; 48}; 49 50int __removefile_rename_unlink(const char*path, removefile_state_t state); 51int __removefile_tree_walker(char ** trees, removefile_state_t state); 52int __removefile_sunlink(const char * path, removefile_state_t state); 53void __removefile_init_random(const unsigned int seed, removefile_state_t state); 54char __removefile_random_char(removefile_state_t state); 55void __removefile_randomize_buffer(unsigned char *buffer, size_t length, removefile_state_t state); 56 57#define __removefile_state_test_cancel(s) ((s)->cancelled != 0) 58 59#ifdef __cplusplus 60} 61#endif 62 63