|
Packit |
0986c0 |
/* GNUPLOT - datafile.h */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/*[
|
|
Packit |
0986c0 |
* Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
|
|
Packit |
0986c0 |
*
|
|
Packit |
0986c0 |
* Permission to use, copy, and distribute this software and its
|
|
Packit |
0986c0 |
* documentation for any purpose with or without fee is hereby granted,
|
|
Packit |
0986c0 |
* provided that the above copyright notice appear in all copies and
|
|
Packit |
0986c0 |
* that both that copyright notice and this permission notice appear
|
|
Packit |
0986c0 |
* in supporting documentation.
|
|
Packit |
0986c0 |
*
|
|
Packit |
0986c0 |
* Permission to modify the software is granted, but not the right to
|
|
Packit |
0986c0 |
* distribute the complete modified source code. Modifications are to
|
|
Packit |
0986c0 |
* be distributed as patches to the released version. Permission to
|
|
Packit |
0986c0 |
* distribute binaries produced by compiling modified sources is granted,
|
|
Packit |
0986c0 |
* provided you
|
|
Packit |
0986c0 |
* 1. distribute the corresponding source modifications from the
|
|
Packit |
0986c0 |
* released version in the form of a patch file along with the binaries,
|
|
Packit |
0986c0 |
* 2. add special version identification to distinguish your version
|
|
Packit |
0986c0 |
* in addition to the base release version number,
|
|
Packit |
0986c0 |
* 3. provide your name and address as the primary contact for the
|
|
Packit |
0986c0 |
* support of your modified version, and
|
|
Packit |
0986c0 |
* 4. retain our contact information in regard to use of the base
|
|
Packit |
0986c0 |
* software.
|
|
Packit |
0986c0 |
* Permission to distribute the released version of the source code along
|
|
Packit |
0986c0 |
* with corresponding source modifications in the form of a patch file is
|
|
Packit |
0986c0 |
* granted with same provisions 2 through 4 for binary distributions.
|
|
Packit |
0986c0 |
*
|
|
Packit |
0986c0 |
* This software is provided "as is" without express or implied warranty
|
|
Packit |
0986c0 |
* to the extent permitted by applicable law.
|
|
Packit |
0986c0 |
]*/
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
#ifndef GNUPLOT_DATAFILE_H
|
|
Packit |
0986c0 |
# define GNUPLOT_DATAFILE_H
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* #if... / #include / #define collection: */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
#include "axis.h"
|
|
Packit |
0986c0 |
#include "graph3d.h"
|
|
Packit |
0986c0 |
#include "graphics.h"
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* returns from DF_READLINE in datafile.c */
|
|
Packit |
0986c0 |
/* +ve is number of columns read */
|
|
Packit |
0986c0 |
enum DF_STATUS {
|
|
Packit |
0986c0 |
DF_BAD = 0,
|
|
Packit |
0986c0 |
DF_GOOD = 1,
|
|
Packit |
0986c0 |
DF_EOF = -1,
|
|
Packit |
0986c0 |
DF_UNDEFINED = -2,
|
|
Packit |
0986c0 |
DF_FIRST_BLANK = -3,
|
|
Packit |
0986c0 |
DF_SECOND_BLANK = -4,
|
|
Packit |
0986c0 |
DF_MISSING = -5,
|
|
Packit |
0986c0 |
DF_FOUND_KEY_TITLE = -6,
|
|
Packit |
0986c0 |
DF_KEY_TITLE_MISSING = -7,
|
|
Packit |
0986c0 |
DF_STRINGDATA = -8,
|
|
Packit |
0986c0 |
DF_COLUMN_HEADERS = -9
|
|
Packit |
0986c0 |
};
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* large file support (offsets potentially > 2GB) */
|
|
Packit |
0986c0 |
#if defined(HAVE_FSEEKO) && defined(HAVE_OFF_T)
|
|
Packit |
0986c0 |
# define fseek(stream,pos,whence) fseeko(stream,pos,whence)
|
|
Packit |
0986c0 |
# define ftell(stream) ftello(stream)
|
|
Packit |
0986c0 |
#elif defined(_MSC_VER)
|
|
Packit |
0986c0 |
# define fseek(stream,pos,whence) _fseeki64(stream,pos,whence)
|
|
Packit |
0986c0 |
# define ftell(stream) _ftelli64(stream)
|
|
Packit |
0986c0 |
#elif defined(__MINGW32__)
|
|
Packit |
0986c0 |
# define fseek(stream,pos,whence) fseeko64(stream,pos,whence)
|
|
Packit |
0986c0 |
# define ftell(stream) ftello64(stream)
|
|
Packit |
0986c0 |
#endif
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Variables of datafile.c needed by other modules: */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* how many using columns were specified in the current command */
|
|
Packit |
0986c0 |
extern int df_no_use_specs;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Maximum number of columns returned to caller by df_readline */
|
|
Packit |
0986c0 |
/* Various data structures are dimensioned to hold this many entries. */
|
|
Packit |
0986c0 |
/* As of June 2013, plot commands never ask for more than 7 columns of */
|
|
Packit |
0986c0 |
/* data, but fit commands can use more. "fit" is also limited by */
|
|
Packit |
0986c0 |
/* the number of parameters that can be passed to a user function, so */
|
|
Packit |
0986c0 |
/* let's try setting MAXDATACOLS to match. */
|
|
Packit |
0986c0 |
/* At present this bumps it from 7 to 14. */
|
|
Packit |
0986c0 |
#define MAXDATACOLS (MAX_NUM_VAR+2)
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* suggested x value if none given */
|
|
Packit |
0986c0 |
extern int df_datum;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* is this a matrix splot? */
|
|
Packit |
0986c0 |
extern TBOOLEAN df_matrix;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* is this a binary file? */
|
|
Packit |
0986c0 |
extern TBOOLEAN df_binary;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
extern char *df_filename;
|
|
Packit |
0986c0 |
extern int df_line_number;
|
|
Packit |
0986c0 |
extern AXIS_INDEX df_axis[];
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
#ifdef BACKWARDS_COMPATIBLE
|
|
Packit |
0986c0 |
extern struct udft_entry ydata_func; /* deprecated "thru" function */
|
|
Packit |
0986c0 |
#endif
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Returned to caller by df_readline() */
|
|
Packit |
0986c0 |
extern char *df_tokens[];
|
|
Packit |
0986c0 |
extern struct value df_strings[]; /* used only by TABLESTYLE */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* number of columns in first row of data return to user in STATS_columns */
|
|
Packit |
0986c0 |
extern int df_last_col;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* string representing missing values, ascii datafiles */
|
|
Packit |
0986c0 |
extern char *missing_val;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* input field separators, NULL if whitespace is the separator */
|
|
Packit |
0986c0 |
extern char *df_separators;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* comments chars */
|
|
Packit |
0986c0 |
extern char *df_commentschars;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* flag if any 'inline' data are in use, for the current plot */
|
|
Packit |
0986c0 |
extern TBOOLEAN plotted_data_from_stdin;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Setting this allows the parser to recognize Fortran D or Q */
|
|
Packit |
0986c0 |
/* format constants in the input file. But it slows things down */
|
|
Packit |
0986c0 |
extern TBOOLEAN df_fortran_constants;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Setting this disables initialization of the floating point exception */
|
|
Packit |
0986c0 |
/* handler before every expression evaluation in a using specifier. */
|
|
Packit |
0986c0 |
/* This can speed data input significantly, but assumes valid input. */
|
|
Packit |
0986c0 |
extern TBOOLEAN df_nofpe_trap;
|
|
Packit |
0986c0 |
extern TBOOLEAN evaluate_inside_using;
|
|
Packit |
0986c0 |
extern TBOOLEAN df_warn_on_missing_columnheader;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Used by plot title columnhead, stats name columnhead */
|
|
Packit |
0986c0 |
extern char *df_key_title;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Prototypes of functions exported by datafile.c */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
int df_open __PROTO((const char *, int, struct curve_points *));
|
|
Packit |
0986c0 |
int df_readline __PROTO((double [], int));
|
|
Packit |
0986c0 |
void df_close __PROTO((void));
|
|
Packit |
0986c0 |
void df_init __PROTO((void));
|
|
Packit |
0986c0 |
char * df_fgets __PROTO((FILE *));
|
|
Packit |
0986c0 |
void df_showdata __PROTO((void));
|
|
Packit |
0986c0 |
int df_2dbinary __PROTO((struct curve_points *));
|
|
Packit |
0986c0 |
int df_3dmatrix __PROTO((struct surface_points *, int));
|
|
Packit |
0986c0 |
void df_set_key_title __PROTO((struct curve_points *));
|
|
Packit |
0986c0 |
void df_set_key_title_columnhead __PROTO((struct curve_points *));
|
|
Packit |
0986c0 |
char * df_parse_string_field __PROTO((char *));
|
|
Packit |
0986c0 |
int expect_string __PROTO((const char column ));
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
void df_reset_after_error __PROTO((void));
|
|
Packit |
0986c0 |
void f_dollars __PROTO((union argument *x));
|
|
Packit |
0986c0 |
void f_column __PROTO((union argument *x));
|
|
Packit |
0986c0 |
void f_columnhead __PROTO((union argument *x));
|
|
Packit |
0986c0 |
void f_valid __PROTO((union argument *x));
|
|
Packit |
0986c0 |
void f_timecolumn __PROTO((union argument *x));
|
|
Packit |
0986c0 |
void f_stringcolumn __PROTO((union argument *x));
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
struct use_spec_s {
|
|
Packit |
0986c0 |
int column;
|
|
Packit |
0986c0 |
int expected_type;
|
|
Packit |
0986c0 |
struct at_type *at;
|
|
Packit |
0986c0 |
int depends_on_column;
|
|
Packit |
0986c0 |
};
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Details about the records contained in a binary data file. */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
typedef enum df_translation_type {
|
|
Packit |
0986c0 |
DF_TRANSLATE_DEFAULT, /* Gnuplot will position in first quadrant at origin. */
|
|
Packit |
0986c0 |
DF_TRANSLATE_VIA_ORIGIN,
|
|
Packit |
0986c0 |
DF_TRANSLATE_VIA_CENTER
|
|
Packit |
0986c0 |
} df_translation_type;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
typedef enum df_sample_scan_type {
|
|
Packit |
0986c0 |
DF_SCAN_POINT = -3, /* fastest */
|
|
Packit |
0986c0 |
DF_SCAN_LINE = -4,
|
|
Packit |
0986c0 |
DF_SCAN_PLANE = -5 /* slowest */
|
|
Packit |
0986c0 |
} df_sample_scan_type;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* To generate a swap, take the bit-wise complement of the lowest two bits. */
|
|
Packit |
0986c0 |
typedef enum df_endianess_type {
|
|
Packit |
0986c0 |
DF_LITTLE_ENDIAN,
|
|
Packit |
0986c0 |
DF_PDP_ENDIAN,
|
|
Packit |
0986c0 |
DF_DPD_ENDIAN,
|
|
Packit |
0986c0 |
DF_BIG_ENDIAN,
|
|
Packit |
0986c0 |
DF_ENDIAN_TYPE_LENGTH /* Must be last */
|
|
Packit |
0986c0 |
} df_endianess_type;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* The various types of numerical types that can be read from a data file. */
|
|
Packit |
0986c0 |
typedef enum df_data_type {
|
|
Packit |
0986c0 |
DF_CHAR, DF_UCHAR, DF_SHORT, DF_USHORT, DF_INT,
|
|
Packit |
0986c0 |
DF_UINT, DF_LONG, DF_ULONG, DF_FLOAT, DF_DOUBLE,
|
|
Packit |
0986c0 |
DF_LONGLONG, DF_ULONGLONG,
|
|
Packit |
0986c0 |
DF_BAD_TYPE
|
|
Packit |
0986c0 |
} df_data_type;
|
|
Packit |
0986c0 |
#define DF_DEFAULT_TYPE DF_FLOAT
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Some macros for making the compiler figure out what function
|
|
Packit |
0986c0 |
* the "machine independent" names should execute to read the
|
|
Packit |
0986c0 |
* appropriately sized variable from a data file.
|
|
Packit |
0986c0 |
*/
|
|
Packit |
0986c0 |
#define SIGNED_TEST(val) ((val)==sizeof(long) ? DF_LONG : \
|
|
Packit |
0986c0 |
((val)==sizeof(long long) ? DF_LONGLONG : \
|
|
Packit |
0986c0 |
((val)==sizeof(int) ? DF_INT : \
|
|
Packit |
0986c0 |
((val)==sizeof(short) ? DF_SHORT : \
|
|
Packit |
0986c0 |
((val)==sizeof(char) ? DF_CHAR : DF_BAD_TYPE)))))
|
|
Packit |
0986c0 |
#define UNSIGNED_TEST(val) ((val)==sizeof(unsigned long) ? DF_ULONG : \
|
|
Packit |
0986c0 |
((val)==sizeof(unsigned long long) ? DF_ULONGLONG : \
|
|
Packit |
0986c0 |
((val)==sizeof(unsigned int) ? DF_UINT : \
|
|
Packit |
0986c0 |
((val)==sizeof(unsigned short) ? DF_USHORT : \
|
|
Packit |
0986c0 |
((val)==sizeof(unsigned char) ? DF_UCHAR : DF_BAD_TYPE)))))
|
|
Packit |
0986c0 |
#define FLOAT_TEST(val) ((val)==sizeof(float) ? DF_FLOAT : \
|
|
Packit |
0986c0 |
((val)==sizeof(double) ? DF_DOUBLE : DF_BAD_TYPE))
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
typedef enum df_records_type {
|
|
Packit |
0986c0 |
DF_CURRENT_RECORDS,
|
|
Packit |
0986c0 |
DF_DEFAULT_RECORDS
|
|
Packit |
0986c0 |
} df_records_type;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
typedef struct df_binary_type_struct {
|
|
Packit |
0986c0 |
df_data_type read_type;
|
|
Packit |
0986c0 |
unsigned short read_size;
|
|
Packit |
0986c0 |
} df_binary_type_struct;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
typedef struct df_column_bininfo_struct {
|
|
Packit |
0986c0 |
long skip_bytes;
|
|
Packit |
0986c0 |
df_binary_type_struct column;
|
|
Packit |
0986c0 |
} df_column_bininfo_struct;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* NOTE TO THOSE WRITING FILE TYPE FUNCTIONS
|
|
Packit |
0986c0 |
*
|
|
Packit |
0986c0 |
* "cart" means Cartesian, i.e., the (x,y,z) [or (r,t,z)] coordinate
|
|
Packit |
0986c0 |
* system of the plot. "scan" refers to the scanning method of the
|
|
Packit |
0986c0 |
* file in question, i.e., first points, then lines, then planes.
|
|
Packit |
0986c0 |
* The important variables for a file type function to fill in are
|
|
Packit |
0986c0 |
* those beginning with "scan". There is a tricky set of rules
|
|
Packit |
0986c0 |
* related to the "scan_cart" mapping, the file-specified variables,
|
|
Packit |
0986c0 |
* the default variables, and the command-line variables. Basically,
|
|
Packit |
0986c0 |
* command line overrides data file which overrides default. (Yes,
|
|
Packit |
0986c0 |
* like a confusing version of rock, paper, scissors.) So, from the
|
|
Packit |
0986c0 |
* file type function perspective, it is better to leave those
|
|
Packit |
0986c0 |
* variables which are not specifically known from file data or
|
|
Packit |
0986c0 |
* otherwise (e.g., sample periods "scan_delta") unaltered in case
|
|
Packit |
0986c0 |
* the user has issued "set datafile" to define defaults.
|
|
Packit |
0986c0 |
*/
|
|
Packit |
0986c0 |
typedef struct df_binary_file_record_struct {
|
|
Packit |
0986c0 |
int cart_dim[3]; /* dimension array size, x/y/z */
|
|
Packit |
0986c0 |
int cart_dir[3]; /* 1 scan in positive direction, -1 negative, x/y/z */
|
|
Packit |
0986c0 |
double cart_delta[3]; /* spacing between array points, x/y/z */
|
|
Packit |
0986c0 |
df_translation_type cart_trans; /* translate via origin, center or default */
|
|
Packit |
0986c0 |
double cart_cen_or_ori[3]; /* vector representing center or origin, x/y/z */
|
|
Packit |
0986c0 |
double cart_alpha; /* 2D rotation angle (rotate) */
|
|
Packit |
0986c0 |
double cart_p[3]; /* 3D rotation normal vector (perpendicular) */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
df_sample_scan_type cart_scan[3]; /* how to assign the dimensions read from file when generating coordinates */
|
|
Packit |
0986c0 |
TBOOLEAN scan_generate_coord; /* whether or not Gnuplot should generate coordinates. */
|
|
Packit |
0986c0 |
off_t scan_skip[3]; /* skip bytes before the record, line, plane */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Not controllable by the user, only by file type functions.
|
|
Packit |
0986c0 |
* These are all points/lines/planes format.
|
|
Packit |
0986c0 |
*/
|
|
Packit |
0986c0 |
int scan_dim[3]; /* number of points, lines, planes */
|
|
Packit |
0986c0 |
int scan_dir[3]; /* 1 scan in positive direction wrt Cartesian coordinate system, -1 negative */
|
|
Packit |
0986c0 |
double scan_delta[3]; /* sample period along points, lines, planes */
|
|
Packit |
0986c0 |
df_translation_type scan_trans; /* translate via origin, center or default */
|
|
Packit |
0986c0 |
double scan_cen_or_ori[3]; /* vector representing center or origin, x/y/z */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* *** Do not modify outside of datafile.c!!! *** */
|
|
Packit |
0986c0 |
char GPFAR *memory_data;
|
|
Packit |
0986c0 |
} df_binary_file_record_struct;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
extern df_binary_file_record_struct *df_bin_record;
|
|
Packit |
0986c0 |
extern int df_num_bin_records;
|
|
Packit |
0986c0 |
extern struct coordinate blank_data_line;
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
extern struct use_spec_s use_spec[];
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
/* Prototypes of functions exported by datafile.c */
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
void df_show_binary __PROTO((FILE *fp));
|
|
Packit |
0986c0 |
void df_show_datasizes __PROTO((FILE *fp));
|
|
Packit |
0986c0 |
void df_show_filetypes __PROTO((FILE *fp));
|
|
Packit |
0986c0 |
void df_set_datafile_binary __PROTO((void));
|
|
Packit |
0986c0 |
void df_unset_datafile_binary __PROTO((void));
|
|
Packit |
0986c0 |
void df_add_binary_records __PROTO((int, df_records_type));
|
|
Packit |
0986c0 |
void df_extend_binary_columns __PROTO((int));
|
|
Packit |
0986c0 |
void df_set_skip_before __PROTO((int col, int bytes)); /* Number of bytes to skip before a binary column. */
|
|
Packit |
0986c0 |
#define df_set_skip_after(col,bytes) df_set_skip_before(col+1,bytes) /* Number of bytes to skip after a binary column. */
|
|
Packit |
0986c0 |
void df_set_read_type __PROTO((int col, df_data_type type)); /* Type of data in the binary column. */
|
|
Packit |
0986c0 |
df_data_type df_get_read_type __PROTO((int col)); /* Type of data in the binary column. */
|
|
Packit |
0986c0 |
int df_get_read_size __PROTO((int col)); /* Size of data in the binary column. */
|
|
Packit |
0986c0 |
int df_get_num_matrix_cols __PROTO((void));
|
|
Packit |
0986c0 |
void df_set_plot_mode __PROTO((int));
|
|
Packit |
0986c0 |
|
|
Packit |
0986c0 |
#endif /* GNUPLOT_DATAFILE_H */
|