3864ca39e3348a60fbef3823181991de1766d4a2
[pspp-builds.git] / src / data / sfm-private.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 /* PORTME: There might easily be alignment problems with some of these
21    structures. */
22
23 #include <libpspp/compiler.h>
24 #include "variable.h"
25
26 /* This attribute might avoid some problems.  On the other hand... */
27 #define P ATTRIBUTE ((packed))
28
29 #if __BORLANDC__
30 #pragma option -a-              /* Turn off alignment. */
31 #endif
32
33 /* Find 32-bit signed integer type. */
34 #if SIZEOF_SHORT == 4
35   #define int32 short
36 #elif SIZEOF_INT == 4
37   #define int32 int
38 #elif SIZEOF_LONG == 4
39   #define int32 long
40 #else
41   #error Which one of your basic types is 32-bit signed integer?
42 #endif
43
44 /* Find 64-bit floating-point type. */
45 #if SIZEOF_FLOAT == 8
46   #define flt64 float
47   #define FLT64_MAX FLT_MAX
48 #elif SIZEOF_DOUBLE == 8
49   #define flt64 double
50   #define FLT64_MAX DBL_MAX
51 #elif SIZEOF_LONG_DOUBLE == 8
52   #define flt64 long double
53   #define FLT64_MAX LDBL_MAX
54 #else
55   #error Which one of your basic types is 64-bit floating point?
56   #define flt64 double
57   #define FLT64_MAX DBL_MAX
58 #endif
59
60 /* Figure out SYSMIS value for flt64. */
61 #include <libpspp/magic.h>
62 #if SIZEOF_DOUBLE == 8
63 #define second_lowest_flt64 second_lowest_value
64 #else
65 #error Must define second_lowest_flt64 for your architecture.
66 #endif
67
68 /* Record Type 1: General Information. */
69 struct sysfile_header
70   {
71     char rec_type[4] P;         /* 00: Record-type code, "$FL2". */
72     char prod_name[60] P;       /* 04: Product identification. */
73     int32 layout_code P;        /* 40: 2. */
74     int32 case_size P;          /* 44: Number of `value's per case. 
75                                    Note: some systems set this to -1 */
76     int32 compress P;           /* 48: 1=compressed, 0=not compressed. */
77     int32 weight_idx P;         /* 4c: 1-based index of weighting var, or 0. */
78     int32 case_cnt P;           /* 50: Number of cases, -1 if unknown. */
79     flt64 bias P;               /* 54: Compression bias (100.0). */
80     char creation_date[9] P;    /* 5c: `dd mmm yy' creation date of file. */
81     char creation_time[8] P;    /* 65: `hh:mm:ss' 24-hour creation time. */
82     char file_label[64] P;      /* 6d: File label. */
83     char padding[3] P;          /* ad: Ignored padding. */
84   };
85
86 /* Record Type 2: Variable. */
87 struct sysfile_variable
88   {
89     int32 rec_type P;           /* 2. */
90     int32 type P;               /* 0=numeric, 1-255=string width,
91                                    -1=continued string. */
92     int32 has_var_label P;      /* 1=has a variable label, 0=doesn't. */
93     int32 n_missing_values P;   /* Missing value code of -3,-2,0,1,2, or 3. */
94     int32 print P;      /* Print format. */
95     int32 write P;      /* Write format. */
96     char name[SHORT_NAME_LEN] P; /* Variable name. */
97     /* The rest of the structure varies. */
98   };
99
100 #if __BORLANDC__
101 #pragma -a4
102 #endif