dpkg.h 6.8 KB

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