X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fcommon%2Freadwrite.h;h=ce7b749bc251c9ebea8f6be257b230b74ca0cb35;hb=21ba1d03b1e883564d301c2781039017dd704b20;hp=eddd0e66e1875922f5bc7b15be06305080b07d73;hpb=6ac951c41a091ffc723840894ddf1e774739511d;p=plomrogue diff --git a/src/common/readwrite.h b/src/common/readwrite.h index eddd0e6..ce7b749 100644 --- a/src/common/readwrite.h +++ b/src/common/readwrite.h @@ -1,4 +1,8 @@ /* src/common/readwrite.h: + * + * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3 + * or any later version. For details on its copyright, license, and warranties, + * see the file NOTICE in the root directory of the PlomRogue source package. * * Routines for reading and writing files. */ @@ -14,11 +18,11 @@ /* Wrappers to fopen(), fclose(), fgets() and fwrite() from function called "f", * calling exit_err() upon error with appropriate error messages. */ -extern FILE * try_fopen(char * path, char * mode, char * f); -extern void try_fclose(FILE * file, char * f); +extern FILE * try_fopen(char * path, char * mode, const char * f); +extern void try_fclose(FILE * file, const char * f); extern void try_fwrite(void * ptr, size_t size, size_t nmemb, FILE * stream, - char * f); -extern void try_fputc(uint8_t c, FILE * file, char * f); + const char * f); +extern void try_fputc(uint8_t c, FILE * file, const char * f); /* Wrapper to calling fgetc() and fgets() from function "f". The return code is * returned unless ferror() indicates an error (i.e. to signify an end of file, @@ -26,8 +30,11 @@ extern void try_fputc(uint8_t c, FILE * file, char * f); * on "file" before fgetc(), because some Unixes fgetc() remember old EOFs and * only return those until explicitely cleared. */ -extern int try_fgetc(FILE * file, char * f); -extern char * try_fgets(char * line, int size, FILE * file, char * f); +extern int try_fgetc(FILE * file, const char * f); +extern char * try_fgets(char * line, int size, FILE * file, const char * f); + +/* Return "path" + suffix "_tmp". Value is malloc'd, must be freed externally.*/ +extern char * build_temp_path(char * path); /* Write to "path_tmp" "path" + "_tmp" and return a new file at that "path_tmp" * open for writing. "path_tmp" is malloc()'d, must be freed externally. @@ -46,6 +53,14 @@ extern void detect_atomic_leftover(char * path); /* Return largest line length from "file" (including newline chars). */ extern uint32_t textfile_width(FILE * file); +/* Read "file" for load of non-zero bytes to put onto "queue" string. */ +extern uint8_t read_file_into_queue(FILE * file, char ** queue); + +/* Return message from "queue" (identified as \n-delimited string, with \n as + * \0 in the returned message; return nothing if no \n delimiter found). + */ +extern char * get_message_from_queue(char ** queue); + #endif