dpkg.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful,
  14. * but 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. #include <sys/types.h>
  24. #include <setjmp.h>
  25. #include <stddef.h>
  26. #include <stdarg.h>
  27. #include <stdio.h>
  28. #include <dpkg/macros.h>
  29. DPKG_BEGIN_DECLS
  30. #define MAXCONFFILENAME 1000
  31. #define MAXDIVERTFILENAME 1024
  32. #define MAXCONTROLFILENAME 100
  33. #define DEBEXT ".deb"
  34. #define OLDDBEXT "-old"
  35. #define NEWDBEXT "-new"
  36. #define REMOVECONFFEXTS "~", ".bak", "%", \
  37. DPKGTEMPEXT, DPKGNEWEXT, DPKGOLDEXT, DPKGDISTEXT
  38. #define DPKG_VERSION_ARCH PACKAGE_VERSION " (" ARCHITECTURE ")"
  39. #define NEWCONFFILEFLAG "newconffile"
  40. #define NONEXISTENTFLAG "nonexistent"
  41. #define DPKGTEMPEXT ".dpkg-tmp"
  42. #define DPKGNEWEXT ".dpkg-new"
  43. #define DPKGOLDEXT ".dpkg-old"
  44. #define DPKGDISTEXT ".dpkg-dist"
  45. #define CONTROLFILE "control"
  46. #define CONFFILESFILE "conffiles"
  47. #define PREINSTFILE "preinst"
  48. #define POSTINSTFILE "postinst"
  49. #define PRERMFILE "prerm"
  50. #define POSTRMFILE "postrm"
  51. #define TRIGGERSCIFILE "triggers"
  52. #define STATUSFILE "status"
  53. #define AVAILFILE "available"
  54. #define LOCKFILE "lock"
  55. #define DIVERSIONSFILE "diversions"
  56. #define STATOVERRIDEFILE "statoverride"
  57. #define UPDATESDIR "updates/"
  58. #define INFODIR "info/"
  59. #define TRIGGERSDIR "triggers/"
  60. #define TRIGGERSFILEFILE "File"
  61. #define TRIGGERSDEFERREDFILE "Unincorp"
  62. #define TRIGGERSLOCKFILE "Lock"
  63. #define CONTROLDIRTMP "tmp.ci/"
  64. #define IMPORTANTTMP "tmp.i"
  65. #define REASSEMBLETMP "reassemble" DEBEXT
  66. #define IMPORTANTMAXLEN 10
  67. #define IMPORTANTFMT "%04d"
  68. #define MAXUPDATES 250
  69. #define MAINTSCRIPTPKGENVVAR "DPKG_MAINTSCRIPT_PACKAGE"
  70. #define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
  71. #define MAINTSCRIPTNAMEENVVAR "DPKG_MAINTSCRIPT_NAME"
  72. #define MAINTSCRIPTLIBDIRENVVAR "DPKG_LIBDIR"
  73. #define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
  74. #define SHELLENV "SHELL"
  75. #define DEFAULTSHELL "sh"
  76. #define PAGERENV "PAGER"
  77. #define DEFAULTPAGER "pager"
  78. #define MD5HASHLEN 32
  79. #define MAXTRIGDIRECTIVE 256
  80. #define BACKEND "dpkg-deb"
  81. #define DPKGQUERY "dpkg-query"
  82. #define SPLITTER "dpkg-split"
  83. #define DPKG "dpkg"
  84. #define DEBSIGVERIFY "/usr/bin/debsig-verify"
  85. #define TAR "tar"
  86. #define RM "rm"
  87. #define FIND "find"
  88. #define DIFF "diff"
  89. #define FIND_EXPRSTARTCHARS "-(),!"
  90. extern const char thisname[]; /* defined separately in each program */
  91. /*** from startup.c ***/
  92. #define standard_startup(ejbuf) do {\
  93. if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
  94. error_unwind(ehflag_bombout); exit(2);\
  95. }\
  96. push_error_handler(ejbuf, print_error_fatal, NULL); \
  97. umask(022); /* Make sure all our status databases are readable. */\
  98. } while (0)
  99. #define standard_shutdown() do { \
  100. set_error_display(NULL, NULL); \
  101. error_unwind(ehflag_normaltidy);\
  102. } while (0)
  103. /*** from ehandle.c ***/
  104. extern volatile int onerr_abort;
  105. typedef void error_printer(const char *emsg, const char *contextstring);
  106. void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
  107. const char *contextstring);
  108. void set_error_display(error_printer *printerror, const char *contextstring);
  109. void print_error_fatal(const char *emsg, const char *contextstring);
  110. void error_unwind(int flagset);
  111. void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
  112. void (*f2)(int argc, void **argv), int flagmask2,
  113. unsigned int nargs, ...);
  114. void push_checkpoint(int mask, int value);
  115. void pop_cleanup(int flagset);
  116. enum { ehflag_normaltidy=01, ehflag_bombout=02, ehflag_recursiveerror=04 };
  117. void do_internerr(const char *file, int line, const char *fmt, ...)
  118. DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3);
  119. #define internerr(...) do_internerr(__FILE__, __LINE__, __VA_ARGS__)
  120. void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  121. void ohshitv(const char *fmt, va_list al) DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
  122. void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  123. void werr(const char *what) DPKG_ATTR_NORET;
  124. void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  125. /*** log.c ***/
  126. extern const char *log_file;
  127. void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  128. /* FIXME: pipef and status_pipes should not be publicly exposed. */
  129. struct pipef {
  130. int fd;
  131. struct pipef *next;
  132. };
  133. extern struct pipef *status_pipes;
  134. void statusfd_send(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  135. /*** cleanup.c ***/
  136. void cu_closefile(int argc, void **argv);
  137. void cu_closepipe(int argc, void **argv);
  138. void cu_closedir(int argc, void **argv);
  139. void cu_closefd(int argc, void **argv);
  140. /*** from mlib.c ***/
  141. void setcloexec(int fd, const char* fn);
  142. void *m_malloc(size_t);
  143. void *m_realloc(void*, size_t);
  144. char *m_strdup(const char *str);
  145. void m_dup2(int oldfd, int newfd);
  146. void m_pipe(int fds[2]);
  147. void m_output(FILE *f, const char *name);
  148. /*** from utils.c ***/
  149. int cisdigit(int c);
  150. int cisalpha(int c);
  151. int cisspace(int c);
  152. int fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn);
  153. int fgets_must(char *buf, size_t bufsz, FILE *f, const char *fn);
  154. DPKG_END_DECLS
  155. #endif /* LIBDPKG_DPKG_H */