parsedump.h 3.1 KB

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