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