2 * libdpkg - Debian packaging suite library routines
3 * dpkg.h - general header for Debian package handling
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2000,2001 Wichert Akkerman <wichert@debian.org>
7 * Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
9 * This is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 #ifndef LIBDPKG_DPKG_H
24 #define LIBDPKG_DPKG_H
26 #include <sys/types.h>
31 #include <dpkg/macros.h>
36 * @mainpage libdpkg C API
38 * This is the documentation for the libdpkg C API. It is divided in an
39 * @ref dpkg-internal "internal API" and a @ref dpkg-public "public API".
40 * Applications closely tied to dpkg can make use of the internal API, the
41 * rest should only assume the availability of the public API.
43 * Applications need to define the LIBDPKG_VOLATILE_API macro to acknowledge
44 * that the API is to be considered volatile, please read doc/README.api for
47 * @defgroup dpkg-internal Internal libdpkg C API
49 * @defgroup dpkg-public Public libdpkg C API
52 #define MAXCONFFILENAME 1000
53 #define MAXDIVERTFILENAME 1024
54 #define MAXCONTROLFILENAME 100
56 #define REMOVECONFFEXTS "~", ".bak", "%", \
57 DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT
59 #define NEWCONFFILEFLAG "newconffile"
60 #define NONEXISTENTFLAG "nonexistent"
61 #define EMPTYHASHFLAG "-"
63 #define DPKGTEMPEXT ".dpkg-tmp"
64 #define DPKGNEWEXT ".dpkg-new"
65 #define DPKGOLDEXT ".dpkg-old"
66 #define DPKGDISTEXT ".dpkg-dist"
68 #define CONTROLFILE "control"
69 #define CONFFILESFILE "conffiles"
70 #define PREINSTFILE "preinst"
71 #define POSTINSTFILE "postinst"
72 #define PRERMFILE "prerm"
73 #define POSTRMFILE "postrm"
74 /* Debconf config maintainer script. */
75 #define MAINTSCRIPT_FILE_CONFIG "config"
76 #define TRIGGERSCIFILE "triggers"
78 #define STATUSFILE "status"
79 #define AVAILFILE "available"
80 #define LOCKFILE "lock"
81 #define FRONTENDLOCKFILE "lock-frontend"
82 #define DIVERSIONSFILE "diversions"
83 #define STATOVERRIDEFILE "statoverride"
84 #define UPDATESDIR "updates/"
85 #define INFODIR "info"
86 #define TRIGGERSDIR "triggers"
87 #define TRIGGERSFILEFILE "File"
88 #define TRIGGERSDEFERREDFILE "Unincorp"
89 #define TRIGGERSLOCKFILE "Lock"
90 #define CONTROLDIRTMP "tmp.ci"
91 #define IMPORTANTTMP "tmp.i"
92 #define REASSEMBLETMP "reassemble" DEBEXT
93 #define IMPORTANTMAXLEN 10
94 #define IMPORTANTFMT "%04d"
95 #define MAXUPDATES 250
97 #define DEFAULTSHELL "sh"
98 #define DEFAULTPAGER "pager"
100 #define MD5HASHLEN 32
101 #define MAXTRIGDIRECTIVE 256
103 #define BACKEND "dpkg-deb"
104 #define SPLITTER "dpkg-split"
105 #define DPKGQUERY "dpkg-query"
106 #define DPKGDIVERT "dpkg-divert"
107 #define DPKGSTAT "dpkg-statoverride"
108 #define DPKGTRIGGER "dpkg-trigger"
110 #define DEBSIGVERIFY "debsig-verify"
116 #include <dpkg/progname.h>
117 #include <dpkg/ehandle.h>
118 #include <dpkg/report.h>
119 #include <dpkg/string.h>
120 #include <dpkg/program.h>
124 extern const char *log_file
;
125 void log_message(const char *fmt
, ...) DPKG_ATTR_PRINTF(1);
127 void statusfd_add(int fd
);
128 void statusfd_send(const char *fmt
, ...) DPKG_ATTR_PRINTF(1);
132 void cu_closestream(int argc
, void **argv
);
133 void cu_closepipe(int argc
, void **argv
);
134 void cu_closedir(int argc
, void **argv
);
135 void cu_closefd(int argc
, void **argv
);
136 void cu_filename(int argc
, void **argv
);
138 /*** from mlib.c ***/
140 void setcloexec(int fd
, const char *fn
);
141 void *m_malloc(size_t);
142 void *m_calloc(size_t nmemb
, size_t size
);
143 void *m_realloc(void *, size_t);
144 char *m_strdup(const char *str
);
145 char *m_strndup(const char *str
, size_t n
);
146 int m_asprintf(char **strp
, const char *fmt
, ...) DPKG_ATTR_PRINTF(2);
147 int m_vasprintf(char **strp
, const char *fmt
, va_list args
)
148 DPKG_ATTR_VPRINTF(2);
149 int m_dup(int oldfd
);
150 void m_dup2(int oldfd
, int newfd
);
151 void m_pipe(int fds
[2]);
152 void m_output(FILE *f
, const char *name
);
154 /*** from utils.c ***/
156 int fgets_checked(char *buf
, size_t bufsz
, FILE *f
, const char *fn
);
157 int fgets_must(char *buf
, size_t bufsz
, FILE *f
, const char *fn
);
161 #endif /* LIBDPKG_DPKG_H */