"Fossies" - the Fresh Open Source Software Archive

Member "dpkg-1.19.7/lib/dpkg/cleanup.c" (28 Mar 2019, 1422 Bytes) of package /linux/misc/dpkg_1.19.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cleanup.c" see the Fossies "Dox" file reference documentation.

    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 cu_closepipe(int argc, void **argv)
   32 {
   33     int *p1 = (int *)argv[0];
   34 
   35     close(p1[0]);
   36     close(p1[1]);
   37 }
   38 
   39 void
   40 cu_closestream(int argc, void **argv)
   41 {
   42     FILE *f = (FILE *)(argv[0]);
   43 
   44     fclose(f);
   45 }
   46 
   47 void
   48 cu_closedir(int argc, void **argv)
   49 {
   50     DIR *d = (DIR *)(argv[0]);
   51 
   52     closedir(d);
   53 }
   54 
   55 void
   56 cu_closefd(int argc, void **argv)
   57 {
   58     int ip = *(int *)argv[0];
   59 
   60     close(ip);
   61 }
   62 
   63 void
   64 cu_filename(int argc, void **argv)
   65 {
   66     const char *filename = argv[0];
   67 
   68     (void)unlink(filename);
   69 }