parsedump.h 3.3 KB

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