Document that the character_code field can be a Windows code page
[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 <stdint.h>
25 #include "variable.h"
26
27
28 #if __BORLANDC__
29 #pragma option -a-              /* Turn off alignment. */
30 #endif
31
32 /* Find 64-bit floating-point type. */
33 #if SIZEOF_FLOAT == 8
34   #define flt64 float
35   #define FLT64_MAX FLT_MAX
36 #elif SIZEOF_DOUBLE == 8
37   #define flt64 double
38   #define FLT64_MAX DBL_MAX
39 #elif SIZEOF_LONG_DOUBLE == 8
40   #define flt64 long double
41   #define FLT64_MAX LDBL_MAX
42 #else
43   #error Which one of your basic types is 64-bit floating point?
44 #endif
45
46 /* Figure out SYSMIS value for flt64. */
47 #include <libpspp/magic.h>
48 #if SIZEOF_DOUBLE == 8
49 #define second_lowest_flt64 second_lowest_value
50 #else
51 #error Must define second_lowest_flt64 for your architecture.
52 #endif
53
54 /* Record Type 1: General Information. */
55 struct sysfile_header
56   {
57     char rec_type[4] ;          /* 00: Record-type code, "$FL2". */
58     char prod_name[60] ;        /* 04: Product identification. */
59     int32_t layout_code ;       /* 40: 2. */
60     int32_t nominal_case_size ; /* 44: Number of `value's per case. 
61                                    Note: some systems set this to -1 */
62     int32_t compress ;          /* 48: 1=compressed, 0=not compressed. */
63     int32_t weight_idx ;         /* 4c: 1-based index of weighting var, or 0. */
64     int32_t case_cnt ;          /* 50: Number of cases, -1 if unknown. */
65     flt64 bias ;                /* 54: Compression bias (100.0). */
66     char creation_date[9] ;     /* 5c: `dd mmm yy' creation date of file. */
67     char creation_time[8] ;     /* 65: `hh:mm:ss' 24-hour creation time. */
68     char file_label[64] ;       /* 6d: File label. */
69     char padding[3] ;           /* ad: Ignored padding. */
70   } ATTRIBUTE((packed)) ;
71
72 /* Record Type 2: Variable. */
73 struct sysfile_variable
74   {
75     int32_t rec_type ;          /* 2. */
76     int32_t type ;              /* 0=numeric, 1-255=string width,
77                                    -1=continued string. */
78     int32_t has_var_label ;     /* 1=has a variable label, 0=doesn't. */
79     int32_t n_missing_values ;  /* Missing value code of -3,-2,0,1,2, or 3. */
80     int32_t print ;             /* Print format. */
81     int32_t write ;             /* Write format. */
82     char name[SHORT_NAME_LEN] ; /* Variable name. */
83     /* The rest of the structure varies. */
84   } ATTRIBUTE((packed)) ;
85
86 #if __BORLANDC__
87 #pragma -a4
88 #endif