dpkg.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. #ifndef LIBDPKG_DPKG_H
  23. #define LIBDPKG_DPKG_H
  24. #include <sys/types.h>
  25. #include <stddef.h>
  26. #include <stdio.h>
  27. #include <dpkg/macros.h>
  28. DPKG_BEGIN_DECLS
  29. /**
  30. * @mainpage libdpkg C API
  31. *
  32. * This is the documentation for the libdpkg C API. It is divided in an
  33. * @ref dpkg-internal "internal API" and a @ref dpkg-public "public API".
  34. * Applications closely tied to dpkg can make use of the internal API, the
  35. * rest should only assume the availability of the public API.
  36. *
  37. * Applications need to define the LIBDPKG_VOLATILE_API macro to acknowledge
  38. * that the API is to be considered volatile, please read doc/README.api for
  39. * more information.
  40. *
  41. * @defgroup dpkg-internal Internal libdpkg C API
  42. *
  43. * @defgroup dpkg-public Public libdpkg C API
  44. */
  45. #define MAXCONFFILENAME 1000
  46. #define MAXDIVERTFILENAME 1024
  47. #define MAXCONTROLFILENAME 100
  48. #define DEBEXT ".deb"
  49. #define REMOVECONFFEXTS "~", ".bak", "%", \
  50. DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT
  51. #define NEWCONFFILEFLAG "newconffile"
  52. #define NONEXISTENTFLAG "nonexistent"
  53. #define EMPTYHASHFLAG "-"
  54. #define DPKGTEMPEXT ".dpkg-tmp"
  55. #define DPKGNEWEXT ".dpkg-new"
  56. #define DPKGOLDEXT ".dpkg-old"
  57. #define DPKGDISTEXT ".dpkg-dist"
  58. #define CONTROLFILE "control"
  59. #define CONFFILESFILE "conffiles"
  60. #define PREINSTFILE "preinst"
  61. #define EXTRAINSTFILE "extrainst_"
  62. #define POSTINSTFILE "postinst"
  63. #define PRERMFILE "prerm"
  64. #define POSTRMFILE "postrm"
  65. #define TRIGGERSCIFILE "triggers"
  66. #define STATUSFILE "status"
  67. #define AVAILFILE "available"
  68. #define LOCKFILE "lock"
  69. #define DIVERSIONSFILE "diversions"
  70. #define STATOVERRIDEFILE "statoverride"
  71. #define UPDATESDIR "updates/"
  72. #define INFODIR "info"
  73. #define TRIGGERSDIR "triggers"
  74. #define TRIGGERSFILEFILE "File"
  75. #define TRIGGERSDEFERREDFILE "Unincorp"
  76. #define TRIGGERSLOCKFILE "Lock"
  77. #define CONTROLDIRTMP "tmp.ci"
  78. #define IMPORTANTTMP "tmp.i"
  79. #define REASSEMBLETMP "reassemble" DEBEXT
  80. #define IMPORTANTMAXLEN 10
  81. #define IMPORTANTFMT "%04d"
  82. #define MAXUPDATES 250
  83. #define DEFAULTSHELL "sh"
  84. #define DEFAULTPAGER "pager"
  85. #define MD5HASHLEN 32
  86. #define MAXTRIGDIRECTIVE 256
  87. #define BACKEND "dpkg-deb"
  88. #define SPLITTER "dpkg-split"
  89. #define DPKGQUERY "dpkg-query"
  90. #define DPKGDIVERT "dpkg-divert"
  91. #define DPKGSTAT "dpkg-statoverride"
  92. #define DPKGTRIGGER "dpkg-trigger"
  93. #define DPKG "dpkg"
  94. #define DEBSIGVERIFY "debsig-verify"
  95. #define RM "rm"
  96. #define CAT "cat"
  97. #define DIFF "diff"
  98. #include <dpkg/progname.h>
  99. #include <dpkg/ehandle.h>
  100. #include <dpkg/report.h>
  101. #include <dpkg/string.h>
  102. #include <dpkg/program.h>
  103. /*** log.c ***/
  104. extern const char *log_file;
  105. void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  106. void statusfd_add(int fd);
  107. void statusfd_send(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  108. /*** cleanup.c ***/
  109. void cu_closestream(int argc, void **argv);
  110. void cu_closepipe(int argc, void **argv);
  111. void cu_closedir(int argc, void **argv);
  112. void cu_closefd(int argc, void **argv);
  113. void cu_filename(int argc, void **argv);
  114. /*** from mlib.c ***/
  115. void setcloexec(int fd, const char *fn);
  116. void *m_malloc(size_t);
  117. void *m_calloc(size_t nmemb, size_t size);
  118. void *m_realloc(void *, size_t);
  119. char *m_strdup(const char *str);
  120. char *m_strndup(const char *str, size_t n);
  121. int m_asprintf(char **strp, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
  122. int m_vasprintf(char **strp, const char *fmt, va_list args)
  123. DPKG_ATTR_VPRINTF(2);
  124. void m_dup2(int oldfd, int newfd);
  125. void m_pipe(int fds[2]);
  126. void m_output(FILE *f, const char *name);
  127. /*** from utils.c ***/
  128. int fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn);
  129. int fgets_must(char *buf, size_t bufsz, FILE *f, const char *fn);
  130. DPKG_END_DECLS
  131. #endif /* LIBDPKG_DPKG_H */