Branch data Line data Source code
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/debug.h> 30 : : #include <dpkg/report.h> 31 : : #include <dpkg/ehandle.h> 32 : : #include <dpkg/program.h> 33 : : 34 : : /** 35 : : * Standard initializations when starting a dpkg-based program. 36 : : * 37 : : * @param progname The program name. 38 : : */ 39 : : void 40 : 371 : dpkg_program_init(const char *progname) 41 : : { 42 : 371 : dpkg_set_progname(progname); 43 : 371 : dpkg_set_report_buffer(stdout); 44 : 371 : dpkg_debug_init(); 45 : : 46 : 371 : push_error_context(); 47 : : 48 : : /* Set sane default permissions for newly created files. */ 49 : 371 : umask(022); 50 : 371 : } 51 : : 52 : : /** 53 : : * Standard cleanups before terminating a dpkg-based program. 54 : : */ 55 : : void 56 : 306 : dpkg_program_done(void) 57 : : { 58 : 306 : pop_error_context(ehflag_normaltidy); 59 : 306 : }