Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=c8888af25b2e273fe9b4b225a39bffbc89bd25da

commit c8888af25b2e273fe9b4b225a39bffbc89bd25da
Author: James Buren <[email protected]>
Date:   Sun Aug 25 17:51:28 2013 -0500

utility: add readlink0 function

diff --git a/src/local.h b/src/local.h
index 07e0552..1518d8a 100644
--- a/src/local.h
+++ b/src/local.h
@@ -181,6 +181,7 @@ struct tool
};

extern void iniparser_unset_section(dictionary *d,const char *s);
+extern bool readlink0(const char *path,char *buf,size_t size);
extern int charpp_qsort(const void *A,const void *B);
extern void charpp_free(char **pp);
extern void account_free(struct account *account);
diff --git a/src/utility.c b/src/utility.c
index 4a6ff23..d3582f2 100644
--- a/src/utility.c
+++ b/src/utility.c
@@ -56,6 +56,28 @@ extern void iniparser_unset_section(dictionary *d,const char 
*s)
free(p);
}

+extern bool readlink0(const char *path,char *buf,size_t size)
+{
+  ssize_t n = -1;
+
+  if(path == 0 || buf == 0 || size == 0)
+  {
+    errno = EINVAL;
+    error(strerror(errno));
+    return false;
+  }
+
+  n = readlink(path,buf,size);
+
+  if(n > 0 && n < size)
+  {
+    buf[n] = 0;
+    return true;
+  }
+
+  return false;
+}
+
extern int charpp_qsort(const void *A,const void *B)
{
const char *a = *(const char **) A;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to