summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2018-01-04 20:23:16 +0900
committerAkira TAGOH <akira@tagoh.org>2018-01-04 20:39:14 +0900
commit3642d71724e7c40f44753c1f2e6d8fb2c88a3e50 (patch)
tree7d7cb5522c73a39c421c2f52c54ddafc1b2f3cb1 /src
parent767e3aa7c50c2a707b42d9eda879b1046558bb6f (diff)
Add FcReadLink to wrap up readlink impl.
Diffstat (limited to 'src')
-rw-r--r--src/fccfg.c4
-rw-r--r--src/fccompat.c19
-rw-r--r--src/fcint.h5
3 files changed, 26 insertions, 2 deletions
diff --git a/src/fccfg.c b/src/fccfg.c
index a55bcef0..2351ac23 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -2218,7 +2218,7 @@ FcConfigRealFilename (FcConfig *config,
if (n)
{
- char buf[PATH_MAX];
+ FcChar8 buf[PATH_MAX];
ssize_t len;
if (sysroot)
@@ -2227,7 +2227,7 @@ FcConfigRealFilename (FcConfig *config,
nn = FcStrdup (n);
FcStrFree (n);
- if ((len = readlink ((const char *) nn, buf, sizeof (buf) - 1)) != -1)
+ if ((len = FcReadLink (nn, buf, sizeof (buf) - 1)) != -1)
{
buf[len] = 0;
FcStrFree (nn);
diff --git a/src/fccompat.c b/src/fccompat.c
index 31d80bef..16f108d1 100644
--- a/src/fccompat.c
+++ b/src/fccompat.c
@@ -37,6 +37,9 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -256,6 +259,22 @@ FcMakeDirectory (const FcChar8 *dir)
return ret;
}
+ssize_t
+FcReadLink (const FcChar8 *pathname,
+ FcChar8 *buf,
+ size_t bufsiz)
+{
+#ifdef HAVE_READLINK
+ return readlink ((const char *) pathname, (char *)buf, bufsiz);
+#else
+ /* XXX: this function is only used for FcConfigRealFilename() so far
+ * and returning -1 as an error still just works.
+ */
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
#define __fccompat__
#include "fcaliastail.h"
#undef __fccompat__
diff --git a/src/fcint.h b/src/fcint.h
index 6185f5a8..537023fc 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -822,6 +822,11 @@ FcRandom (void);
FcPrivate FcBool
FcMakeDirectory (const FcChar8 *dir);
+FcPrivate ssize_t
+FcReadLink (const FcChar8 *pathname,
+ FcChar8 *buf,
+ size_t bufsiz);
+
/* fcdbg.c */
FcPrivate void