Jspice3
types.c File Reference
#include "spice.h"
#include "ftedefs.h"
Include dependency graph for types.c:

Go to the source code of this file.

Data Structures

struct  type
 
struct  plotab
 

Macros

#define NUMTYPES   128 /* If this is too little we can use a list. */
 
#define NUMPLOTTYPES   512 /* Since there may be more than 1 pat/type. */
 

Functions

void com_dftype (wordlist *wl)
 
char * ft_typabbrev (int typenum)
 
char * ft_typenames (int typenum)
 
int ft_typnum (char *name)
 
char * ft_plotabbrev (char *string)
 
void com_stype (wordlist *wl)
 

Variables

struct type types [NUMTYPES]
 
struct plotab plotabs [NUMPLOTTYPES]
 
int notypes = 14
 
int noplotabs = 22
 

Macro Definition Documentation

#define NUMPLOTTYPES   512 /* Since there may be more than 1 pat/type. */

Definition at line 16 of file types.c.

#define NUMTYPES   128 /* If this is too little we can use a list. */

Definition at line 15 of file types.c.

Function Documentation

void com_dftype ( wordlist wl)

Definition at line 96 of file types.c.

99 {
100  char *name, *abb;
101  int i;
102 
103  switch (*wl->wl_word) {
104  case 'v':
105  case 'V':
106  wl = wl->wl_next;
107  name = copy(wl->wl_word);
108  wl = wl->wl_next;
109  abb = copy(wl->wl_word);
110  for (i = 0; i < notypes; i++)
111  if (cieq(types[i].t_name, name)) {
112  types[i].t_abbrev = abb;
113  break;
114  }
115  if (notypes >= NUMTYPES - 1) {
116  fprintf(cp_err, "Error: too many types defined\n");
117  return;
118  }
119  types[notypes].t_name = name;
120  types[notypes].t_abbrev = abb;
121  notypes++;
122  break;
123 
124  case 'p':
125  case 'P':
126  wl = wl->wl_next;
127  name = copy(wl->wl_word);
128  wl = wl->wl_next;
129  while (wl) {
130  for (i = 0; i < noplotabs; i++)
131  if (cieq(plotabs[i].p_pattern, wl->wl_word)) {
132  plotabs[i].p_name = name;
133  wl = wl->wl_next;
134  break;
135  }
136  if (i != noplotabs)
137  continue;
138  if (noplotabs >= NUMPLOTTYPES - 1) {
139  fprintf(cp_err, "Error: too many plot abs\n");
140  return;
141  }
142  plotabs[noplotabs].p_name = name;
144  wl = wl->wl_next;
145  noplotabs++;
146  }
147  break;
148 
149  default:
150  fprintf(cp_err, "Error: missing 'p' or 'v' argument\n");
151  break;
152  }
153  return;
154 }
int notypes
Definition: types.c:82
char * p_pattern
Definition: types.c:27
int noplotabs
Definition: types.c:83
int cieq()
#define NUMTYPES
Definition: types.c:15
struct type types[NUMTYPES]
Definition: types.c:31
char * copy()
char * p_name
Definition: types.c:26
FILE * cp_err
Definition: help.c:101
#define NUMPLOTTYPES
Definition: types.c:16
struct plotab plotabs[NUMPLOTTYPES]
Definition: types.c:57
char * t_name
Definition: types.c:19
struct wordlist * wl_next
Definition: cpstd.h:23
char * wl_word
Definition: cpstd.h:22
char * t_abbrev
Definition: types.c:20
void com_stype ( wordlist wl)

Definition at line 228 of file types.c.

231 {
232  char *type = wl->wl_word;
233  int tt;
234  struct dvec *v;
235  struct dvlist *dl;
236  char *s;
237 
238  for (tt = 0; ; tt++) {
239  if (!(s = ft_typenames(tt)) || eq(type, s))
240  break;
241  }
242  if (!s) {
243  fprintf(cp_err, "Error: no such type as '%s'\n", type);
244  return;
245  }
246  for (wl = wl->wl_next; wl; wl = wl->wl_next) {
247  v = vec_get(wl->wl_word);
248  if (!v)
249  fprintf(cp_err, "Error: no such vector %s.\n",
250  wl->wl_word);
251  else {
252  if (v->v_link2) {
253  for (dl = v->v_link2; dl; dl = dl->dl_next)
254  dl->dl_dvec->v_type = tt;
255  }
256  else
257  v->v_type = tt;
258  }
259  }
260  return;
261 }
#define eq(a, b)
Definition: misc.h:29
char * ft_typenames(int typenum)
Definition: types.c:173
struct dvlist * v_link2
Definition: ftedata.h:44
Definition: cddefs.h:119
Definition: ftedata.h:49
Definition: xforms.c:16
struct dvlist * dl_next
Definition: ftedata.h:51
FILE * cp_err
Definition: help.c:101
struct dvec * vec_get()
Definition: types.c:18
Definition: ftedata.h:24
struct dvec * dl_dvec
Definition: ftedata.h:50
int v_type
Definition: ftedata.h:26
struct wordlist * wl_next
Definition: cpstd.h:23
char * wl_word
Definition: cpstd.h:22
char* ft_plotabbrev ( char *  string)

Definition at line 204 of file types.c.

207 {
208  char buf[128];
209  int i;
210 
211  if (!string)
212  return (NULL);
213  for (i = 0; string[i]; i++)
214  buf[i] = isupper(string[i]) ? tolower(string[i]) : string[i];
215  buf[i] = '\0';
216 
217  for (i = 0; plotabs[i].p_name; i++)
218  if (substring(plotabs[i].p_pattern, buf))
219  return (plotabs[i].p_name);
220 
221  return (NULL);
222 }
static char buf[MAXPROMPT]
Definition: arg.c:18
char * p_name
Definition: types.c:26
struct plotab plotabs[NUMPLOTTYPES]
Definition: types.c:57
int substring()
#define NULL
Definition: spdefs.h:121
char* ft_typabbrev ( int  typenum)

Definition at line 160 of file types.c.

162 {
163  if ((typenum < NUMTYPES) && (typenum >= 0))
164  return (types[typenum].t_abbrev);
165  else
166  return (NULL);
167 }
#define NUMTYPES
Definition: types.c:15
struct type types[NUMTYPES]
Definition: types.c:31
#define NULL
Definition: spdefs.h:121
char* ft_typenames ( int  typenum)

Definition at line 173 of file types.c.

175 {
176  if ((typenum < NUMTYPES) && (typenum >= 0))
177  return (types[typenum].t_name);
178  else
179  return (NULL);
180 }
#define NUMTYPES
Definition: types.c:15
struct type types[NUMTYPES]
Definition: types.c:31
#define NULL
Definition: spdefs.h:121
int ft_typnum ( char *  name)

Definition at line 186 of file types.c.

189 {
190  int i;
191 
192  if (eq(name, "none"))
193  name = "notype";
194  for (i = 0; (i < NUMTYPES) && types[i].t_name; i++)
195  if (cieq(name, types[i].t_name))
196  return (i);
197  return (0);
198 }
#define eq(a, b)
Definition: misc.h:29
int cieq()
#define NUMTYPES
Definition: types.c:15
struct type types[NUMTYPES]
Definition: types.c:31

Variable Documentation

int noplotabs = 22

Definition at line 83 of file types.c.

int notypes = 14

Definition at line 82 of file types.c.

struct plotab plotabs[NUMPLOTTYPES]
Initial value:
= {
{ "tran", "transient" } ,
{ "op", "op" } ,
{ "tf", "function" },
{ "dc", "d.c." } ,
{ "dc", "dc" } ,
{ "dc", "transfer" } ,
{ "ac", "a.c." } ,
{ "ac", "ac" } ,
{ "pz", "pz" } ,
{ "pz", "p.z." } ,
{ "pz", "pole-zero"} ,
{ "disto", "disto" } ,
{ "dist", "dist" } ,
{ "noise", "noise" } ,
{ "sens", "sens" } ,
{ "sens", "sensitivity" } ,
{ "sp", "s.p." } ,
{ "sp", "sp" } ,
{ "harm", "harm" } ,
{ "spect", "spect" } ,
{ "range", "range" } ,
{ "test", "testrun" }
}

Definition at line 57 of file types.c.

struct type types[NUMTYPES]
Initial value:
= {
{ "notype", NULL } ,
{ "time", "S" } ,
{ "frequency", "Hz" } ,
{ "voltage", "V" } ,
{ "current", "A" } ,
{ "onoise-spectrum", "(V or A)^2/Hz" } ,
{ "onoise-integrated", "V or A" } ,
{ "inoise-spectrum", "(V or A)^2/Hz" } ,
{ "inoise-integrated", "V or A" } ,
{ "output-noise", NULL } ,
{ "input-noise", NULL } ,
{ "pole", NULL } ,
{ "zero", NULL } ,
{ "s-param", NULL }
}
#define NULL
Definition: spdefs.h:121

Definition at line 31 of file types.c.