Jspice3
cktgrnd.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8  /* CKTground(ckt,node)
9  * specify the node to be the ground node of the given circuit
10  */
11 
12 #include "spice.h"
13 #include <stdio.h>
14 #include "cktdefs.h"
15 #include "sperror.h"
16 #include "util.h"
17 #include "cktext.h"
18 
19 
20 int
21 CKTground(inCkt,node,name)
22 
23 GENERIC *inCkt;
24 GENERIC **node;
25 IFuid name;
26 {
27  CKTcircuit *ckt = (CKTcircuit *)inCkt;
28 
29  if (ckt->CKTnodes) {
30  if (ckt->CKTnodes->name) {
31  /*already exists - keep old name, but return it */
32  if (node) *node = (char *)ckt->CKTnodes;
33  return (E_EXISTS);
34  }
35  ckt->CKTnodes->name = name;
36  ckt->CKTnodes->type = SP_VOLTAGE;
37  ckt->CKTnodes->number = 0;
38  }
39  else {
40  ckt->CKTnodes = (CKTnode *)MALLOC(sizeof(CKTnode));
41  if (ckt->CKTnodes == NULL) return (E_NOMEM);
42  ckt->CKTnodes->name = name;
43  ckt->CKTnodes->type = SP_VOLTAGE;
44  ckt->CKTnodes->number = 0;
45  ckt->CKTnodes->next = (CKTnode *)NULL;
46  ckt->CKTlastNode = ckt->CKTnodes;
47  }
48  if (node) *node = (char *)ckt->CKTnodes;
49  return (OK);
50 }
IFuid name
Definition: cktdefs.h:31
#define E_EXISTS
Definition: iferrmsg.h:20
#define SP_VOLTAGE
Definition: cktdefs.h:34
#define OK
Definition: iferrmsg.h:17
GENERIC * IFuid
Definition: ifsim.h:72
#define MALLOC(x)
Definition: util.h:9
int type
Definition: cktdefs.h:32
#define NULL
Definition: spdefs.h:121
#define E_NOMEM
Definition: iferrmsg.h:27
struct sCKTnode * next
Definition: cktdefs.h:43
int number
Definition: cktdefs.h:39
CKTnode * CKTnodes
Definition: cktdefs.h:135
CKTnode * CKTlastNode
Definition: cktdefs.h:136
int CKTground(GENERIC *inCkt, GENERIC **node, IFuid name)
Definition: cktgrnd.c:21
return(True)
char GENERIC
Definition: ifsim.h:27