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