gbloffs.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2000-Apr-09 or later
  4. (the contents of which are also included in unzip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /* Write out a fragment of assembly or C preprocessor source giving offsets
  9. * in "Uz_Globs" and "struct huft". Used by Amiga and Human68k ports.
  10. */
  11. #define UNZIP_INTERNAL
  12. #include "unzip.h"
  13. #include "crypt.h"
  14. #ifndef REENTRANT
  15. Uz_Globs G;
  16. #endif
  17. static int asm_setflag(const char *flagname);
  18. static int ccp_setflag(const char *flagname);
  19. static int asm_setflag(const char *flagname)
  20. {
  21. static const char asm_flagdef[] = " IFND %s\n%-15s EQU 1\n ENDC\n";
  22. return printf(asm_flagdef, flagname, flagname);
  23. }
  24. static int ccp_setflag(const char *flagname)
  25. {
  26. static const char ccp_flagdef[] = "#ifndef %s\n# define %s\n#endif\n";
  27. return printf(ccp_flagdef, flagname, flagname);
  28. }
  29. int main(argc, argv)
  30. int argc;
  31. char **argv;
  32. {
  33. #ifdef REENTRANT
  34. Uz_Globs *pG = NULL;
  35. #endif
  36. struct huft *t = NULL;
  37. static const char asm_offsdef[] = "%-15s EQU %lu\n";
  38. static const char ccp_offsdef[] = "#define %-15s %lu\n";
  39. const char *out_format;
  40. int (*set_flag)(const char *flagname);
  41. int ccp_select = 0;
  42. if (argc > 1 && argv[1] != NULL && !strcmp(argv[1], "-ccp"))
  43. ccp_select = 1;
  44. if (ccp_select) {
  45. out_format = ccp_offsdef;
  46. set_flag = ccp_setflag;
  47. } else {
  48. out_format = asm_offsdef;
  49. set_flag = asm_setflag;
  50. }
  51. printf(out_format, "h_e", (ulg)&t->e - (ulg)t);
  52. printf(out_format, "h_b", (ulg)&t->b - (ulg)t);
  53. printf(out_format, "h_v_n", (ulg)&t->v.n - (ulg)t);
  54. printf(out_format, "h_v_t", (ulg)&t->v.t - (ulg)t);
  55. printf(out_format, "SIZEOF_huft", (ulg)sizeof(struct huft));
  56. printf(out_format, "bb", (ulg)&G.bb - (ulg)&G);
  57. printf(out_format, "bk", (ulg)&G.bk - (ulg)&G);
  58. printf(out_format, "wp", (ulg)&G.wp - (ulg)&G);
  59. #ifdef FUNZIP
  60. printf(out_format, "in", (ulg)&G.in - (ulg)&G);
  61. #else
  62. printf(out_format, "incnt", (ulg)&G.incnt - (ulg)&G);
  63. printf(out_format, "inptr", (ulg)&G.inptr - (ulg)&G);
  64. printf(out_format, "csize", (ulg)&G.csize - (ulg)&G);
  65. printf(out_format, "mem_mode", (ulg)&G.mem_mode - (ulg)&G);
  66. #endif
  67. printf(out_format, "redirslide", (ulg)&redirSlide - (ulg)&G);
  68. printf(out_format, "SIZEOF_slide", (ulg)sizeof(redirSlide));
  69. #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
  70. printf(out_format, "_wsize", (ulg)&G._wsize - (ulg)&G);
  71. #endif /* DLL && !NO_SLIDE_REDIR */
  72. printf(out_format, "CRYPT", (ulg)CRYPT);
  73. #ifdef FUNZIP
  74. (*set_flag)("FUNZIP");
  75. #endif
  76. #ifdef SFX
  77. (*set_flag)("SFX");
  78. #endif
  79. #ifdef REENTRANT
  80. (*set_flag)("REENTRANT");
  81. #endif
  82. #ifdef DLL
  83. (*set_flag)("DLL");
  84. # ifdef NO_SLIDE_REDIR
  85. (*set_flag)("NO_SLIDE_REDIR");
  86. # endif
  87. #endif
  88. #ifdef USE_DEFLATE64
  89. (*set_flag)("USE_DEFLATE64");
  90. #endif
  91. return 0;
  92. }