/*
 * suputils.c -
 *	Useful routines.
 */

#include <strings.h>
#include "tmp/c.h"
#include "suputils.h"
#include "installinfo.h"

RcsId("$Header: RCS/suputils.c,v 1.6 90/08/17 08:55:19 cimarron Exp $");


#define	RM_PATH		"/bin/rm"
#define	RM_FLAGS	"-rf"

/*
 *	PathRemoveRecursively
 *
 *	Remove "absolutePath" and its descendants.
 */
void
PathRemoveRecursively(path)
	char	*path;
{
	char	buffer[MAXPATHLEN];

	IFDEBUG(printf("PathRemoveRecursively: removing file: %s...\n",
		       path));
	FlushOutput();
	FlushErrors();
	sprintf(buffer, "%s %s %s\0", RM_PATH, RM_FLAGS, path);
	(void) system(buffer);
}


/*
 *	PathGetRoot
 *
 *	Extract the file name from an absolute or relative path.
 */
char *
PathGetRoot(path)
	char	*path;
{
	register char	*root;
	
	root = rindex(path, '/');
	return(root ? ++root : path);
}


/*
 *	ProcessExit
 *
 *	Useful as a signal handler (since it takes no arguments).
 */
ProcessExit()
{
	exitpg(0);
}
