xref: /386bsd/usr/src/usr.bin/tar/junk/testpad.c (revision a2142627)
1*a2142627SBen Jolitz /* Find out if we need the pad field in the header for this machine
2*a2142627SBen Jolitz    Copyright (C) 1991 Free Software Foundation
3*a2142627SBen Jolitz 
4*a2142627SBen Jolitz    This program is free software; you can redistribute it and/or
5*a2142627SBen Jolitz    modify it under the terms of the GNU General Public License as
6*a2142627SBen Jolitz    published by the Free Software Foundation; either version 2, or (at
7*a2142627SBen Jolitz    your option) any later version.
8*a2142627SBen Jolitz 
9*a2142627SBen Jolitz    This program is distributed in the hope that it will be useful, but
10*a2142627SBen Jolitz    WITHOUT ANY WARRANTY; without even the implied warranty of
11*a2142627SBen Jolitz    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*a2142627SBen Jolitz    General Public License for more details.
13*a2142627SBen Jolitz 
14*a2142627SBen Jolitz    You should have received a copy of the GNU General Public License
15*a2142627SBen Jolitz    along with this program; if not, write to the Free Software
16*a2142627SBen Jolitz    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*a2142627SBen Jolitz */
18*a2142627SBen Jolitz 
19*a2142627SBen Jolitz #include <stdio.h>
20*a2142627SBen Jolitz 
21*a2142627SBen Jolitz struct inc
22*a2142627SBen Jolitz {
23*a2142627SBen Jolitz   char a[20];
24*a2142627SBen Jolitz   char b[20];
25*a2142627SBen Jolitz };
26*a2142627SBen Jolitz 
27*a2142627SBen Jolitz struct test1
28*a2142627SBen Jolitz {
29*a2142627SBen Jolitz   char a;
30*a2142627SBen Jolitz   struct inc in[5];
31*a2142627SBen Jolitz };
32*a2142627SBen Jolitz 
33*a2142627SBen Jolitz struct test2
34*a2142627SBen Jolitz {
35*a2142627SBen Jolitz   char a;
36*a2142627SBen Jolitz   char b;
37*a2142627SBen Jolitz   struct inc in[5];
38*a2142627SBen Jolitz };
39*a2142627SBen Jolitz 
40*a2142627SBen Jolitz void
main()41*a2142627SBen Jolitz main ()
42*a2142627SBen Jolitz {
43*a2142627SBen Jolitz   struct test1 t1;
44*a2142627SBen Jolitz   struct test2 t2;
45*a2142627SBen Jolitz   int t1diff, t2diff;
46*a2142627SBen Jolitz   FILE *fp = fopen ("testpad.h", "w");
47*a2142627SBen Jolitz 
48*a2142627SBen Jolitz   if (fp == 0)
49*a2142627SBen Jolitz     {
50*a2142627SBen Jolitz       fprintf (stderr, "testpad: cannot open ");
51*a2142627SBen Jolitz       fflush (stderr);
52*a2142627SBen Jolitz       perror ("testpad.h");
53*a2142627SBen Jolitz       exit (1);
54*a2142627SBen Jolitz     }
55*a2142627SBen Jolitz 
56*a2142627SBen Jolitz   t1diff = (char *) &t1.in[0] - (char *) &t1;
57*a2142627SBen Jolitz   t2diff = (char *) &t2.in[0] - (char *) &t2;
58*a2142627SBen Jolitz 
59*a2142627SBen Jolitz   if (t2diff == t1diff + 1)
60*a2142627SBen Jolitz     fprintf (fp, "#define NEEDPAD\n");
61*a2142627SBen Jolitz   else if (t1diff != t2diff)
62*a2142627SBen Jolitz     fprintf (stderr, "Cannot determine padding for tar struct, \n\
63*a2142627SBen Jolitz will try with none.\n");
64*a2142627SBen Jolitz 
65*a2142627SBen Jolitz   fclose (fp);
66*a2142627SBen Jolitz   exit (0);
67*a2142627SBen Jolitz }
68