dpkg.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * dpkg.h - general header for Debian package handling
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2000,2001 Wichert Akkerman <wichert@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef LIBDPKG_DPKG_H
  22. #define LIBDPKG_DPKG_H
  23. #ifdef HAVE_SYS_CDEFS_H
  24. #include <sys/cdefs.h>
  25. #endif
  26. #include <sys/types.h>
  27. #include <setjmp.h>
  28. #ifdef HAVE_STDDEF_H
  29. #include <stddef.h>
  30. #endif
  31. #include <stdarg.h>
  32. #include <stdio.h>
  33. #include <dpkg/macros.h>
  34. DPKG_BEGIN_DECLS
  35. #define MAXCONFFILENAME 1000
  36. #define MAXDIVERTFILENAME 1024
  37. #define MAXCONTROLFILENAME 100
  38. #define DEBEXT ".deb"
  39. #define OLDDBEXT "-old"
  40. #define NEWDBEXT "-new"
  41. #define REMOVECONFFEXTS "~", ".bak", "%", \
  42. DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT
  43. #define DPKG_VERSION_ARCH PACKAGE_VERSION " (" ARCHITECTURE ")"
  44. #define NEWCONFFILEFLAG "newconffile"
  45. #define NONEXISTENTFLAG "nonexistent"
  46. #define DPKGTEMPEXT ".dpkg-tmp"
  47. #define DPKGNEWEXT ".dpkg-new"
  48. #define DPKGOLDEXT ".dpkg-old"
  49. #define DPKGDISTEXT ".dpkg-dist"
  50. #define CONTROLFILE "control"
  51. #define CONFFILESFILE "conffiles"
  52. #define PREINSTFILE "preinst"
  53. #define POSTINSTFILE "postinst"
  54. #define PRERMFILE "prerm"
  55. #define POSTRMFILE "postrm"
  56. #define TRIGGERSCIFILE "triggers"
  57. #define STATUSFILE "status"
  58. #define AVAILFILE "available"
  59. #define LOCKFILE "lock"
  60. #define DIVERSIONSFILE "diversions"
  61. #define STATOVERRIDEFILE "statoverride"
  62. #define UPDATESDIR "updates/"
  63. #define INFODIR "info/"
  64. #define TRIGGERSDIR "triggers/"
  65. #define TRIGGERSFILEFILE "File"
  66. #define TRIGGERSDEFERREDFILE "Unincorp"
  67. #define TRIGGERSLOCKFILE "Lock"
  68. #define CONTROLDIRTMP "tmp.ci/"
  69. #define IMPORTANTTMP "tmp.i"
  70. #define REASSEMBLETMP "reassemble" DEBEXT
  71. #define IMPORTANTMAXLEN 10
  72. #define IMPORTANTFMT "%04d"
  73. #define MAXUPDATES 250
  74. #define MAINTSCRIPTPKGENVVAR "DPKG_MAINTSCRIPT_PACKAGE"
  75. #define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
  76. #define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
  77. #define NOJOBCTRLSTOPENV "DPKG_NO_TSTP"
  78. #define SHELLENV "SHELL"
  79. #define DEFAULTSHELL "sh"
  80. #define PAGERENV "PAGER"
  81. #define DEFAULTPAGER "pager"
  82. #define PKGSCRIPTMAXARGS 10
  83. #define MD5HASHLEN 32
  84. #define MAXTRIGDIRECTIVE 256
  85. #define ARCHIVE_FILENAME_PATTERN "*.deb"
  86. #define BACKEND "dpkg-deb"
  87. #define DPKGQUERY "dpkg-query"
  88. #define SPLITTER "dpkg-split"
  89. #define DPKG "dpkg"
  90. #define DEBSIGVERIFY "/usr/bin/debsig-verify"
  91. #define TAR "tar"
  92. #define GZIP "gzip"
  93. #define BZIP2 "bzip2"
  94. #define LZMA "lzma"
  95. #define RM "rm"
  96. #define FIND "find"
  97. #define DIFF "diff"
  98. #define FIND_EXPRSTARTCHARS "-(),!"
  99. #define TARBLKSZ 512
  100. extern const char thisname[]; /* defined separately in each program */
  101. /*** from startup.c ***/
  102. #define standard_startup(ejbuf) do {\
  103. if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
  104. error_unwind(ehflag_bombout); exit(2);\
  105. }\
  106. push_error_handler(ejbuf, print_error_fatal, NULL); \
  107. umask(022); /* Make sure all our status databases are readable. */\
  108. } while (0)
  109. #define standard_shutdown() do { \
  110. set_error_display(NULL, NULL); \
  111. error_unwind(ehflag_normaltidy);\
  112. } while (0)
  113. /*** from ehandle.c ***/
  114. extern volatile int onerr_abort;
  115. typedef void error_printer(const char *emsg, const char *contextstring);
  116. void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
  117. const char *contextstring);
  118. void set_error_display(error_printer *printerror, const char *contextstring);
  119. void print_error_fatal(const char *emsg, const char *contextstring);
  120. void error_unwind(int flagset);
  121. void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
  122. void (*f2)(int argc, void **argv), int flagmask2,
  123. unsigned int nargs, ...);
  124. void push_checkpoint(int mask, int value);
  125. void pop_cleanup(int flagset);
  126. enum { ehflag_normaltidy=01, ehflag_bombout=02, ehflag_recursiveerror=04 };
  127. void do_internerr(const char *file, int line, const char *fmt, ...) DPKG_ATTR_NORET;
  128. #if HAVE_C99
  129. #define internerr(...) do_internerr(__FILE__, __LINE__, __VA_ARGS__)
  130. #else
  131. #define internerr(args...) do_internerr(__FILE__, __LINE__, args)
  132. #endif
  133. void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  134. void ohshitv(const char *fmt, va_list al) DPKG_ATTR_NORET;
  135. void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  136. void werr(const char *what) DPKG_ATTR_NORET;
  137. void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  138. /*** log.c ***/
  139. extern const char *log_file;
  140. void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  141. /* FIXME: pipef and status_pipes should not be publicly exposed. */
  142. struct pipef {
  143. int fd;
  144. struct pipef *next;
  145. };
  146. extern struct pipef *status_pipes;
  147. void statusfd_send(const char *fmt, ...);
  148. /*** cleanup.c ***/
  149. void cu_closefile(int argc, void **argv);
  150. void cu_closepipe(int argc, void **argv);
  151. void cu_closedir(int argc, void **argv);
  152. void cu_closefd(int argc, void **argv);
  153. /*** lock.c ***/
  154. void lock_file(int *lockfd, const char *filename,
  155. const char *emsg, const char *emsg_eagain);
  156. void unlock_file(void);
  157. /*** from mlib.c ***/
  158. void setcloexec(int fd, const char* fn);
  159. void *m_malloc(size_t);
  160. void *m_realloc(void*, size_t);
  161. char *m_strdup(const char *str);
  162. int m_fork(void);
  163. void m_dup2(int oldfd, int newfd);
  164. void m_pipe(int fds[2]);
  165. void m_output(FILE *f, const char *name);
  166. /*** from utils.c ***/
  167. int cisdigit(int c);
  168. int cisalpha(int c);
  169. int cisspace(int c);
  170. int fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn);
  171. int fgets_must(char *buf, size_t bufsz, FILE *f, const char *fn);
  172. /*** from compression.c ***/
  173. enum compress_type {
  174. compress_type_cat,
  175. compress_type_gzip,
  176. compress_type_bzip2,
  177. compress_type_lzma,
  178. };
  179. void decompress_cat(enum compress_type type, int fd_in, int fd_out,
  180. const char *desc, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(4);
  181. void compress_cat(enum compress_type type, int fd_in, int fd_out,
  182. const char *compression, const char *desc, ...)
  183. DPKG_ATTR_NORET DPKG_ATTR_PRINTF(5);
  184. DPKG_END_DECLS
  185. #endif /* LIBDPKG_DPKG_H */