CHANGE add get_current_dir_name() implementation missing on some platforms
diff --git a/src/common.c b/src/common.c
index f21c97c..f5aeed1 100644
--- a/src/common.c
+++ b/src/common.c
@@ -16,6 +16,7 @@
#include <assert.h>
#include <errno.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -144,6 +145,22 @@
[LYS_DEV_REPLACE] = "replace",
};
+#ifndef __USE_GNU
+char *
+get_current_dir_name(void)
+{
+ char tmp[PATH_MAX];
+ char *retval;
+
+ if (getcwd(tmp, sizeof(tmp))) {
+ retval = strdup(tmp);
+ LY_CHECK_ERR_RETURN(!retval, LOGMEM(NULL), NULL);
+ return retval;
+ }
+ return NULL;
+}
+#endif
+
void *
ly_realloc(void *ptr, size_t size)
{
diff --git a/src/common.h b/src/common.h
index 55201c5..4d044d7 100644
--- a/src/common.h
+++ b/src/common.h
@@ -23,6 +23,7 @@
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
+#include <unistd.h>
#include "config.h"
#include "log.h"
@@ -53,6 +54,13 @@
*/
#define API __attribute__((visibility("default")))
+#ifndef __USE_GNU
+/*
+ * If we don't have GNU extension, implement these function on your own
+ */
+char *get_current_dir_name(void);
+#endif
+
/******************************************************************************
* Logger
*****************************************************************************/