parsedump.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * parse.c - declarations for in-core database reading/writing
  4. *
  5. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2001 Wichert Akkerman
  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_PARSEDUMP_H
  22. #define LIBDPKG_PARSEDUMP_H
  23. struct fieldinfo;
  24. struct parsedb_state {
  25. enum parsedbflags flags;
  26. const char *filename;
  27. int lno;
  28. FILE *warnto;
  29. int warncount;
  30. };
  31. #define PKGIFPOFF(f) (offsetof(struct pkginfoperfile, f))
  32. #define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))
  33. #define FILEFOFF(f) (offsetof(struct filedetails, f))
  34. #define FILEFFIELD(filedetail,of,type) (*(type*)((char*)(filedetail)+(of)))
  35. typedef void freadfunction(struct pkginfo *pigp, struct pkginfoperfile *pifp,
  36. struct parsedb_state *ps,
  37. const char *value, const struct fieldinfo *fip);
  38. freadfunction f_name, f_charfield, f_priority, f_section, f_status, f_filecharf;
  39. freadfunction f_boolean, f_dependency, f_conffiles, f_version, f_revision;
  40. freadfunction f_configversion;
  41. freadfunction f_trigpend, f_trigaw;
  42. enum fwriteflags {
  43. fw_printheader = 001 /* print field header and trailing newline */
  44. };
  45. typedef void fwritefunction(struct varbuf*,
  46. const struct pkginfo*, const struct pkginfoperfile*,
  47. enum fwriteflags flags, const struct fieldinfo*);
  48. fwritefunction w_name, w_charfield, w_priority, w_section, w_status, w_configversion;
  49. fwritefunction w_version, w_null, w_booleandefno, w_dependency, w_conffiles;
  50. fwritefunction w_filecharf;
  51. fwritefunction w_trigpend, w_trigaw;
  52. struct fieldinfo {
  53. const char *name;
  54. freadfunction *rcall;
  55. fwritefunction *wcall;
  56. size_t integer;
  57. };
  58. void parse_error(struct parsedb_state *ps, const struct pkginfo *pigp,
  59. const char *fmt, ...) DPKG_ATTR_PRINTF(3);
  60. void parse_warn(struct parsedb_state *ps, const struct pkginfo *pigp,
  61. const char *fmt, ...) DPKG_ATTR_PRINTF(3);
  62. void parse_must_have_field(struct parsedb_state *ps,
  63. const struct pkginfo *pigp,
  64. const char *value, const char *what);
  65. void parse_ensure_have_field(struct parsedb_state *ps,
  66. const struct pkginfo *pigp,
  67. const char **value, const char *what);
  68. #define MSDOS_EOF_CHAR '\032' /* ^Z */
  69. struct nickname {
  70. const char *nick;
  71. const char *canon;
  72. };
  73. extern const struct fieldinfo fieldinfos[];
  74. extern const struct nickname nicknames[];
  75. extern const int nfields; /* = elements in fieldinfos, including the sentinels */
  76. #endif /* LIBDPKG_PARSEDUMP_H */