summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Miller <mtmiller@ieee.org>2015-02-17 22:04:51 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-02-17 22:05:16 -0800
commit4f2e9100023b9ca5c4844133a53816c079214eab (patch)
tree7277929e9155c92243bdf17968f278c6de650faa /lib
parentc74a873bd68ee24b0f01c8828dd6ecb6397d6c72 (diff)
downloadgnulib-4f2e9100023b9ca5c4844133a53816c079214eab.tar.gz
tempname: allow compilation with C++ (trivial)
* lib/tempname.h [C++]: Specify extern "C" linkage. * lib/tempname.h (try_tempname): * lib/tempname.c (__try_tempname, __gen_tempname): Rename 'try' to 'tryfunc'.
Diffstat (limited to 'lib')
-rw-r--r--lib/tempname.c14
-rw-r--r--lib/tempname.h14
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/tempname.c b/lib/tempname.c
index 49c7df1d1b..8e6d26cc48 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -179,7 +179,7 @@ static const char letters[] =
int
__try_tempname (char *tmpl, int suffixlen, void *args,
- int (*try) (char *, void *))
+ int (*tryfunc) (char *, void *))
{
int len;
char *XXXXXX;
@@ -244,7 +244,7 @@ __try_tempname (char *tmpl, int suffixlen, void *args,
v /= 62;
XXXXXX[5] = letters[v % 62];
- fd = try (tmpl, args);
+ fd = tryfunc (tmpl, args);
if (fd >= 0)
{
__set_errno (save_errno);
@@ -300,25 +300,25 @@ try_nocreate (char *tmpl, void *flags)
int
__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
{
- int (*try) (char *, void *);
+ int (*tryfunc) (char *, void *);
switch (kind)
{
case __GT_FILE:
- try = try_file;
+ tryfunc = try_file;
break;
case __GT_DIR:
- try = try_dir;
+ tryfunc = try_dir;
break;
case __GT_NOCREATE:
- try = try_nocreate;
+ tryfunc = try_nocreate;
break;
default:
assert (! "invalid KIND in __gen_tempname");
abort ();
}
- return __try_tempname (tmpl, suffixlen, &flags, try);
+ return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
}
diff --git a/lib/tempname.h b/lib/tempname.h
index 0df4381c6c..e609360746 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -32,6 +32,10 @@
# define GT_NOCREATE 2
# endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
The name constructed does not exist at the time of the call to
@@ -47,11 +51,15 @@
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
-/* Similar to gen_tempname, but TRY is called for each temporary
- name to try. If TRY returns a non-negative number, TRY_GEN_TEMPNAME
+/* Similar to gen_tempname, but TRYFUNC is called for each temporary
+ name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
returns with this value. Otherwise, if errno is set to EEXIST, another
name is tried, or else TRY_GEN_TEMPNAME returns -1. */
extern int try_tempname (char *tmpl, int suffixlen, void *args,
- int (*try) (char *, void *));
+ int (*tryfunc) (char *, void *));
+
+#ifdef __cplusplus
+}
+#endif
#endif /* GL_TEMPNAME_H */