parsedump.h 3.2 KB

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