dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit c4d73fa0397601a4aa9bfae828e877b12951d893
parent 72547956200a556af43a61983e239ec2ddd3514d
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Mon, 16 Jun 2008 00:54:58 +0200

Implement a portable realpath(3)

Implement a portable realpath(3) which doesn't require a destination
buffer.

Diffstat:
cmdfifo.c | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/cmdfifo.c b/cmdfifo.c @@ -1,6 +1,27 @@ int cmdfd = -1; const char *cmdpath = NULL; +/* glibc has a non-standard realpath(3) implementation which allocates + * the destination buffer, other C libraries may have a broken implementation + * which expect an already allocated destination buffer. + */ + +#ifndef __GLIBC__ +# include <limits.h> +# ifndef PATH_MAX +# define PATH_MAX 1024 +# endif +#endif + +char *get_realpath(const char *path) { +#ifdef __GLIBC__ + return realpath(path, NULL); +#else + static char buf[PATH_MAX]; + return realpath(path, buf); +#endif +} + Cmd * get_cmd_by_name(const char *name) { for (int i = 0; i < countof(commands); i++) {