diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-08-09 11:38:06 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-08-09 11:38:06 +0100 |
commit | 07b24d96b006edaa30ff431c10ff9e938a524aa2 (patch) | |
tree | f5e38528d9b5c7290a7471cd4189128372700be4 /src/utils.h | |
parent | 678ec8cc73d54583906a91f68007a8c29ff3d3e2 (diff) | |
parent | 89f5a327b82d0f15c2988d918c8f9f57a156da36 (diff) | |
download | nsgenbind-07b24d96b006edaa30ff431c10ff9e938a524aa2.tar.gz nsgenbind-07b24d96b006edaa30ff431c10ff9e938a524aa2.tar.bz2 |
Merge branch 'vince/interfacemap'
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..508d1c1 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,46 @@ +/* utility helpers + * + * This file is part of nsnsgenbind. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org> + */ + +#ifndef nsgenbind_utils_h +#define nsgenbind_utils_h + +/** + * get a pathname with the output prefix prepended + * + * \param fname leaf filename. + * \return full prefixed path to file caller must free + */ +char *genb_fpath(const char *fname); + +/** + * Open file allowing for output path prefix + */ +FILE *genb_fopen(const char *fname, const char *mode); + +/** + * Open file allowing for output path prefix + * + * file is opened for reading/writing with a temporary suffix allowing for the + * matching close call to check the output is different before touching the + * target file. + */ +FILE *genb_fopen_tmp(const char *fname); + +/** + * Close file opened with genb_fopen + */ +int genb_fclose_tmp(FILE *filef, const char *fname); + +#ifdef _WIN32 +#define NEED_STRNDUP 1 +char *strndup(const char *s, size_t n); +#endif + +#define SLEN(x) (sizeof((x)) - 1) + +#endif |