dpkg (1.18.25) stretch; urgency=medium
[dpkg] / lib / dpkg / dpkg.h
CommitLineData
1479465f
GJ
1/*
2 * libdpkg - Debian packaging suite library routines
3 * dpkg.h - general header for Debian package handling
4 *
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>
8 *
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.
13 *
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.
18 *
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/>.
21 */
22
23#ifndef LIBDPKG_DPKG_H
24#define LIBDPKG_DPKG_H
25
26#include <sys/types.h>
27
28#include <stddef.h>
29#include <stdio.h>
30
31#include <dpkg/macros.h>
32
33DPKG_BEGIN_DECLS
34
35/**
36 * @mainpage libdpkg C API
37 *
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.
42 *
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
45 * more information.
46 *
47 * @defgroup dpkg-internal Internal libdpkg C API
48 *
49 * @defgroup dpkg-public Public libdpkg C API
50 */
51
52#define MAXCONFFILENAME 1000
53#define MAXDIVERTFILENAME 1024
54#define MAXCONTROLFILENAME 100
55#define DEBEXT ".deb"
56#define REMOVECONFFEXTS "~", ".bak", "%", \
57 DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT
58
59#define NEWCONFFILEFLAG "newconffile"
60#define NONEXISTENTFLAG "nonexistent"
61#define EMPTYHASHFLAG "-"
62
63#define DPKGTEMPEXT ".dpkg-tmp"
64#define DPKGNEWEXT ".dpkg-new"
65#define DPKGOLDEXT ".dpkg-old"
66#define DPKGDISTEXT ".dpkg-dist"
67
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#define TRIGGERSCIFILE "triggers"
75
76#define STATUSFILE "status"
77#define AVAILFILE "available"
78#define LOCKFILE "lock"
79#define DIVERSIONSFILE "diversions"
80#define STATOVERRIDEFILE "statoverride"
81#define UPDATESDIR "updates/"
82#define INFODIR "info"
83#define TRIGGERSDIR "triggers"
84#define TRIGGERSFILEFILE "File"
85#define TRIGGERSDEFERREDFILE "Unincorp"
86#define TRIGGERSLOCKFILE "Lock"
87#define CONTROLDIRTMP "tmp.ci"
88#define IMPORTANTTMP "tmp.i"
89#define REASSEMBLETMP "reassemble" DEBEXT
90#define IMPORTANTMAXLEN 10
91#define IMPORTANTFMT "%04d"
92#define MAXUPDATES 250
93
94#define DEFAULTSHELL "sh"
95#define DEFAULTPAGER "pager"
96
97#define MD5HASHLEN 32
98#define MAXTRIGDIRECTIVE 256
99
100#define BACKEND "dpkg-deb"
101#define SPLITTER "dpkg-split"
102#define DPKGQUERY "dpkg-query"
103#define DPKGDIVERT "dpkg-divert"
104#define DPKGSTAT "dpkg-statoverride"
105#define DPKGTRIGGER "dpkg-trigger"
106#define DPKG "dpkg"
107#define DEBSIGVERIFY "debsig-verify"
108
109#define RM "rm"
110#define CAT "cat"
111#define DIFF "diff"
112
113#include <dpkg/progname.h>
114#include <dpkg/ehandle.h>
115#include <dpkg/report.h>
116#include <dpkg/string.h>
117#include <dpkg/program.h>
118
119/*** log.c ***/
120
121extern const char *log_file;
122void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
123
124void statusfd_add(int fd);
125void statusfd_send(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
126
127/*** cleanup.c ***/
128
129void cu_closestream(int argc, void **argv);
130void cu_closepipe(int argc, void **argv);
131void cu_closedir(int argc, void **argv);
132void cu_closefd(int argc, void **argv);
133void cu_filename(int argc, void **argv);
134
135/*** from mlib.c ***/
136
137void setcloexec(int fd, const char *fn);
138void *m_malloc(size_t);
139void *m_calloc(size_t nmemb, size_t size);
140void *m_realloc(void *, size_t);
141char *m_strdup(const char *str);
142char *m_strndup(const char *str, size_t n);
143int m_asprintf(char **strp, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
144int m_vasprintf(char **strp, const char *fmt, va_list args)
145 DPKG_ATTR_VPRINTF(2);
146void m_dup2(int oldfd, int newfd);
147void m_pipe(int fds[2]);
148void m_output(FILE *f, const char *name);
149
150/*** from utils.c ***/
151
152int fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn);
153int fgets_must(char *buf, size_t bufsz, FILE *f, const char *fn);
154
155DPKG_END_DECLS
156
157#endif /* LIBDPKG_DPKG_H */