Freeciv-3.2
|
#include "fc_prehdrs.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "support.h"
#include "ioz.h"
Go to the source code of this file.
Data Structures | |
struct | mem_fzFILE |
struct | fz_FILE_s |
Macros | |
#define | PLAIN_FILE_BUF_SIZE (8096*1024) |
#define | fz_method_validate(method) |
Functions | |
static bool | fz_method_is_valid (enum fz_method method) |
fz_FILE * | fz_from_memory (char *buffer, int size, bool control) |
fz_FILE * | fz_from_file (const char *filename, const char *in_mode, enum fz_method method, int compress_level) |
fz_FILE * | fz_from_stream (FILE *stream) |
int | fz_fclose (fz_FILE *fp) |
char * | fz_fgets (char *buffer, int size, fz_FILE *fp) |
int | fz_fprintf (fz_FILE *fp, const char *format,...) |
int | fz_ferror (fz_FILE *fp) |
const char * | fz_strerror (fz_FILE *fp) |
#define fz_method_validate | ( | method | ) |
Close file, like fclose. Returns 0 on success, or non-zero for problems (but don't call fz_ferror in that case because the struct has already been free'd; wishlist: better interface for errors?) (For FZ_PLAIN returns EOF and could check errno; for FZ_ZLIB: returns zlib error number; see zlib.h.)
Definition at line 571 of file ioz.c.
Referenced by get_token_value(), inf_close_partial(), and secfile_save().
Return non-zero if there is an error status associated with this stream. Check fz_strerror for details.
Definition at line 1099 of file ioz.c.
Referenced by inf_close_partial(), and secfile_save().
Get a line, like fgets. Returns NULL in case of error, or when end-of-file reached and no characters have been read.
Definition at line 655 of file ioz.c.
Referenced by get_token_value(), and read_a_line().
Print formatted, like fprintf.
Note: zlib doesn't have gzvfprintf, but that's ok because its fprintf only does similar to what we do here (print to fixed buffer), and in addition this way we get to use our safe snprintf.
Returns number of (uncompressed) bytes actually written, or 0 on error.
Definition at line 971 of file ioz.c.
Referenced by entry_to_file(), and secfile_save().
fz_FILE * fz_from_file | ( | const char * | filename, |
const char * | in_mode, | ||
enum fz_method | method, | ||
int | compress_level | ||
) |
Open file for reading/writing, like fopen. Parameters compress_method and compress_level only apply for writing: for reading try to use the most appropriate available method. Returns NULL if there was a problem; check errno for details. (If errno is 0, and using FZ_ZLIB, probably had zlib error Z_MEM_ERROR. Wishlist: better interface for errors?)
Definition at line 230 of file ioz.c.
Referenced by get_token_value(), inf_from_file(), and secfile_save().
Open memory buffer for reading as fz_FILE. If control is TRUE, caller gives up control of the buffer so ioz will free it when fz_FILE closed.
Definition at line 207 of file ioz.c.
Referenced by netfile_get_section_file().
Open uncompressed stream for reading/writing.
Definition at line 548 of file ioz.c.
Referenced by fc_querysocket().
Return string (pointer to static memory) containing an error description associated with the file. Should only call this is you know there is an error (eg, from fz_ferror()). Note the error string may be based on errno, so should call this immediately after problem, or possibly something else might overwrite errno.
Definition at line 1157 of file ioz.c.
Referenced by inf_close_partial(), and secfile_save().