41 #include <sys/types.h>
44 #define STD_FILE_BUF 4096
57 size_t file_length = 0;
58 string *result_string;
60 fd = open(filename, O_RDONLY);
61 file_length = lseek(fd, 0, SEEK_END) + 1;
62 lseek(fd, 0, SEEK_SET);
64 cstring = malloc(
sizeof(
char) * file_length);
79 memcpy(cstring + (str_size - n), buf, (
size_t)n);
82 cstring[str_size] =
'\0';
89 result_string =
ntru_malloc(
sizeof(*result_string));
90 result_string->
ptr = cstring;
91 result_string->
len = str_size;
107 write_file(
string const *wstring,
char const *
const filename)
111 fp = fopen(filename,
"w");
118 for (uint32_t i = 0; i < wstring->
len; i++)
119 fprintf(fp,
"%c", wstring->
ptr[i]);
bool write_file(string const *wstring, char const *const filename)
string * read_file(char const *const filename)
#define NTRU_WARN_DEBUG(...)
void * ntru_malloc(size_t size)