orbea / cross / slibtool

Forked from cross/slibtool 3 years ago
Clone

Blame src/internal/slibtool_readlink_impl.h

e8159c
/*******************************************************************/
e8159c
/*  slibtool: a skinny libtool implementation, written in C        */
78d96a
/*  Copyright (C) 2016--2017  Z. Gilboa                            */
e8159c
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
e8159c
/*******************************************************************/
e8159c
e8159c
#include <unistd.h>
e8159c
e8159c
static inline int slbt_readlink(
e8159c
	const char *	restrict path,
e8159c
	char *		restrict buf,
e8159c
	ssize_t		bufsize)
e8159c
{
e8159c
	ssize_t ret;
e8159c
e8159c
	if ((ret = readlink(path,buf,bufsize)) <= 0)
e8159c
		return -1;
e8159c
	else if (ret == bufsize)
e8159c
		return -1;
e8159c
	else {
869ddd
		buf[ret] = 0;
e8159c
		return 0;
e8159c
	}
e8159c
}