This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
cleanup-funcs.h
83 lines (73 loc) · 2.06 KB
/
cleanup-funcs.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2015 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SNAP_CONFINE_CLEANUP_FUNCS_H
#define SNAP_CONFINE_CLEANUP_FUNCS_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_SECCOMP
#include <seccomp.h>
#endif // HAVE_SECCOMP
#include <sys/types.h>
#include <dirent.h>
/**
* Free a dynamically allocated string.
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_string))).
**/
void sc_cleanup_string(char **ptr);
/**
* Close an open file.
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_file))).
**/
void sc_cleanup_file(FILE ** ptr);
/**
* Close an open file with endmntent(3)
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_endmntent))).
**/
void sc_cleanup_endmntent(FILE ** ptr);
#ifdef HAVE_SECCOMP
/**
* Release a seccomp context with seccomp_release(3)
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_seccomp_release))).
**/
void sc_cleanup_seccomp_release(scmp_filter_ctx * ptr);
#endif // HAVE_SECCOMP
/**
* Close an open directory with closedir(3)
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_closedir))).
**/
void sc_cleanup_closedir(DIR ** ptr);
/**
* Close an open file descriptor with close(2)
*
* This function is designed to be used with
* __attribute__((cleanup(sc_cleanup_close))).
**/
void sc_cleanup_close(int *ptr);
#endif