Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * program.c - dpkg-based program support | |
4 | * | |
5 | * Copyright © 2013 Guillem Jover <guillem@debian.org> | |
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 <sys/stat.h> | |
25 | ||
26 | #include <stdio.h> | |
27 | ||
28 | #include <dpkg/progname.h> | |
29 | #include <dpkg/report.h> | |
30 | #include <dpkg/ehandle.h> | |
31 | #include <dpkg/program.h> | |
32 | ||
33 | /** | |
34 | * Standard initializations when starting a dpkg-based program. | |
35 | * | |
36 | * @param progname The program name. | |
37 | */ | |
38 | void | |
39 | dpkg_program_init(const char *progname) | |
40 | { | |
41 | dpkg_set_progname(progname); | |
42 | dpkg_set_report_buffer(stdout); | |
43 | ||
44 | push_error_context(); | |
45 | ||
46 | /* Set sane default permissions for newly created files. */ | |
47 | umask(022); | |
48 | } | |
49 | ||
50 | /** | |
51 | * Standard cleanups before terminating a dpkg-based program. | |
52 | */ | |
53 | void | |
54 | dpkg_program_done(void) | |
55 | { | |
56 | pop_error_context(ehflag_normaltidy); | |
57 | } |