aboutsummaryrefslogtreecommitdiffstats
path: root/libexec_destroy_pluming.c
blob: 6aae3c76d68f071b3351ce5edfede2c9b8b5d35e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* 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