/*
 * Copyright (c) 2004 - 2022 Marcus Glocker <marcus@nazgul.ch>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <string.h>

/* strcuti()
 *	cuts a string from array position start to end
 * Return:
 *	0 = success, -1 = failed
 *
 */

int
strcuti(char *dst, const char *src, const int start, const int end,
	const int dsize)
{
	int	i, j, len;

	len = strlen(src);

	if (start > len || end > len || start == end)
		return -1;

	for (i = 0, j = start; j <= end && j != dsize - 1; i++, j++)
		dst[i] = src[j];

	dst[i] = '\0';

	return 0;
}
