aboutsummaryrefslogblamecommitdiffstats
path: root/libexec_destroy_pluming.c
blob: 6aae3c76d68f071b3351ce5edfede2c9b8b5d35e (plain) (tree)






























                                                               
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


void
libexec_destroy_pluming(struct libexec_pluming *pluming)
{
	if (!pluming)
		return;

	if (pluming->type == LIBEXEC_PLUMING_OPENAT ||
	    pluming->type == LIBEXEC_PLUMING_OPENAT2) {
		free(pluming->target.file);
		pluming->target.file = NULL;

	} else if (pluming->type == LIBEXEC_PLUMING_DOCUMENT) {
		free(pluming->target.text);
		pluming->target.text = NULL;

	} else if (pluming->type == LIBEXEC_PLUMING_PIPE) {
		if (pluming->target.fd >= 0)
			close(pluming->target.fd);
		pluming->target.fd = -1;
	}
}


#else
LIBEXEC_CONST__ int main(void) {return 0;} /* TODO test */
#endif