blob: c9dfd36cf2612701c2ac8ee4f98561df7e00e8de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/* 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);
#if defined(__APPLE__) || defined(_WIN32)
#define NEED_STRNDUP 1
char *strndup(const char *s, size_t n);
#endif
#ifndef SLEN
/* Calculate length of a string constant */
#define SLEN(s) (sizeof((s)) - 1) /* -1 for '\0' */
#endif
#ifndef UNUSED
#define UNUSED(x) ((void)(x))
#endif
#endif
|