parsedump.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * parse.c - declarations for in-core database reading/writing
  4. *
  5. * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright (C) 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. enum fwriteflags {
  37. fw_printheader = 001 /* print field header and trailing newline */
  38. };
  39. typedef void fwritefunction(struct varbuf*,
  40. const struct pkginfo*, const struct pkginfoperfile*,
  41. enum fwriteflags flags, const struct fieldinfo*);
  42. fwritefunction w_name, w_charfield, w_priority, w_section, w_status, w_configversion;
  43. fwritefunction w_version, w_null, w_booleandefno, w_dependency, w_conffiles;
  44. fwritefunction w_filecharf;
  45. struct fieldinfo {
  46. const char *name;
  47. freadfunction *rcall;
  48. fwritefunction *wcall;
  49. size_t integer;
  50. };
  51. void parseerr(FILE *file, const char *filename, int lno, FILE *warnto, int *warncount,
  52. const struct pkginfo *pigp, int warnonly,
  53. const char *fmt, ...) PRINTFFORMAT(8,9);
  54. void parsemustfield(FILE *file, const char *filename, int lno,
  55. FILE *warnto, int *warncount,
  56. const struct pkginfo *pigp, int warnonly,
  57. const char **value, const char *what);
  58. #define MSDOS_EOF_CHAR '\032' /* ^Z */
  59. struct nickname {
  60. const char *nick;
  61. const char *canon;
  62. };
  63. extern const struct fieldinfo fieldinfos[];
  64. extern const struct nickname nicknames[];
  65. extern const int nfields; /* = elements in fieldinfos, including the sentinels */
  66. #endif /* DPKG_PARSEDUMP_H */