2 * spicefile.h - definitions for a file reader for the analog
3 * output files of various spice-like simulators.
5 * Copyright 1998,1999 Stephen G. Tell.
14 typedef struct _SpiceStream SpiceStream
;
15 typedef struct _SpiceVar SpiceVar
;
26 typedef enum SSMsgLevel_tag
{DBG
= -1, INFO
= 0, WARN
= 1, ERR
= 2} SSMsgLevel
;
27 extern FILE *ss_error_file
;
28 typedef void (*SSMsgHook
) (char *s
);
29 extern SSMsgHook ss_error_hook
;
30 extern SSMsgLevel spicestream_msg_level
;
32 /* header data on each variable mentioned in the file
33 * For sweep parameters, ncols will be 0.
38 int col
; /* index of (first) column of data that goes with this variable */
39 int ncols
; /* number of columns of data for this variable; complex numbers have two */
42 typedef int (*SSReadRow
) (SpiceStream
*sf
, double *ivar
, double *dvars
);
43 typedef int (*SSReadSweep
) (SpiceStream
*sf
, double *spar
);
48 int ndv
; /* number of dependent variables */
49 int ncols
; /* number of columns of data readrow will fill in */
50 SpiceVar
*ivar
; /* ptr to independent-variable info */
51 SpiceVar
*dvar
; /* ptr to array of dependent variable info */
52 SpiceVar
*spar
; /* ptr to array of sweep parameter info */
54 SSReadRow readrow
; /* func to read one row of data points */
55 SSReadSweep readsweep
; /* func to read one row of data points */
56 int ntables
; /* number of data tables in the file; not
57 * reliable for all file formats */
58 int nsweepparam
; /* number of implicit sweep parameter values at the start
59 * of each table; may be 0 even for a multi-variate
60 * sweep in some file formats */
62 /* the following stuff is for private use of reader routines */
77 /* following for nsout format */
78 double voltage_resolution
;
79 double current_resolution
;
80 double time_resolution
;
82 double *datrow
; /* temporary data row indexed by ns indices */
83 int *nsindexes
; /* indexed by dvar, contains ns index number */
86 /* values for flags field */
88 #define SSF_PUSHBACK 2
90 #define ss_readrow(sf, ivp, dvp) ((sf->readrow)(sf, ivp, dvp))
91 #define ss_readsweep(sf, swp) ((sf->readsweep)(sf, swp))
93 extern SpiceStream
*ss_open(char *filename
, char *type
);
94 extern SpiceStream
*ss_open_fp(FILE *fp
, char *type
);
95 extern SpiceStream
*ss_open_internal(FILE *fp
, char *name
, char *type
);
96 extern SpiceStream
*ss_new(FILE *fp
, char *name
, int ndv
, int nspar
);
97 extern void ss_close(SpiceStream
*sf
);
98 extern void ss_delete(SpiceStream
*ss
);
99 extern char *ss_var_name(SpiceVar
*sv
, int col
, char *buf
, int n
);
100 extern char *vartype_name_str(VarType type
);
101 extern int fread_line(FILE *fp
, char **bufp
, int *bufsize
);
102 extern void ss_msg(SSMsgLevel type
, const char *id
, const char *msg
, ...);
103 extern char *ss_filetype_name(int n
);