Branch data Line data Source code
1 : : /*
2 : : * libdpkg - Debian packaging suite library routines
3 : : * cleanup.c - cleanup functions, used when we need to unwind
4 : : *
5 : : * Copyright © 1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 : : *
7 : : * This is free software; you can redistribute it and/or modify
8 : : * it under the terms of the GNU General Public License as published by
9 : : * the Free Software Foundation; either version 2 of the License, or
10 : : * (at your option) any later version.
11 : : *
12 : : * This is distributed in the hope that it will be useful,
13 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : : * GNU General Public License for more details.
16 : : *
17 : : * You should have received a copy of the GNU General Public License
18 : : * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 : : */
20 : :
21 : : #include <config.h>
22 : : #include <compat.h>
23 : :
24 : : #include <dirent.h>
25 : : #include <unistd.h>
26 : : #include <stdio.h>
27 : :
28 : : #include <dpkg/dpkg.h>
29 : :
30 : : void
31 : 0 : cu_closepipe(int argc, void **argv)
32 : : {
33 : 0 : int *p1 = (int *)argv[0];
34 : :
35 : 0 : close(p1[0]);
36 : 0 : close(p1[1]);
37 : 0 : }
38 : :
39 : : void
40 : 1 : cu_closestream(int argc, void **argv)
41 : : {
42 : 1 : FILE *f = (FILE *)(argv[0]);
43 : :
44 : 1 : fclose(f);
45 : 1 : }
46 : :
47 : : void
48 : 0 : cu_closedir(int argc, void **argv)
49 : : {
50 : 0 : DIR *d = (DIR *)(argv[0]);
51 : :
52 : 0 : closedir(d);
53 : 0 : }
54 : :
55 : : void
56 : 0 : cu_closefd(int argc, void **argv)
57 : : {
58 : 0 : int ip = *(int *)argv[0];
59 : :
60 : 0 : close(ip);
61 : 0 : }
62 : :
63 : : void
64 : 0 : cu_filename(int argc, void **argv)
65 : : {
66 : 0 : const char *filename = argv[0];
67 : :
68 : 0 : (void)unlink(filename);
69 : 0 : }
|