1 /*============================================================================
2 FILE  pp_ifs.c
3 
4 MEMBER OF process cmpp
5 
6 Public Domain
7 
8 Georgia Tech Research Corporation
9 Atlanta, Georgia 30332
10 PROJECT A-8503
11 
12 AUTHORS
13 
14     9/12/91  Bill Kuhn
15 
16 MODIFICATIONS
17 
18     <date> <person name> <nature of modifications>
19 
20 SUMMARY
21 
22     This file contains the main function for processing an Interface Spec
23     File (ifspec.ifs).
24 
25 INTERFACES
26 
27     preprocess_ifs_file()
28 
29 REFERENCED FILES
30 
31     None.
32 
33 NON-STANDARD FEATURES
34 
35     None.
36 
37 ============================================================================*/
38 
39 #include <stdlib.h>
40 #include  "cmpp.h"
41 
42 
43 
44 /*
45 preprocess_ifs_file
46 
47 Function preprocess_ifs_file is the top-level driver function for
48 preprocessing an Interface Specification file (ifspec.ifs).  This
49 function calls read_ifs_file() requesting it to read and parse
50 the Interface Specification file and place the information
51 contained in it into an internal data structure.  Then
52 write_ifs_c_file() is called to write the information out in a C
53 file that will be compiled and linked with the simulator.
54 */
55 
56 
preprocess_ifs_file(void)57 void preprocess_ifs_file(void)
58 {
59 
60     Ifs_Table_t     ifs_table;   /* Repository for info read from ifspec.ifs file */
61 
62     int status;      /* Return status */
63 
64     /* Read the entire ifspec.ifs file and load the data into ifs_table */
65 
66     status = read_ifs_file(IFSPEC_FILENAME,GET_IFS_TABLE,&ifs_table);
67 
68     if(status != 0) {
69         exit(1);
70     }
71 
72 
73     /* Write the ifspec.c file required by the spice simulator */
74 
75     status = write_ifs_c_file("ifspec.c",&ifs_table);
76 
77     if(status != 0) {
78         exit(1);
79     }
80     rem_ifs_table(&ifs_table);
81 }
82 
rem_ifs_table(Ifs_Table_t * ifs_table)83 void rem_ifs_table(Ifs_Table_t *ifs_table)
84 {
85     /* Remove the ifs_table */
86     free(ifs_table->name.c_fcn_name);
87     free(ifs_table->name.description);
88     free(ifs_table->name.model_name);
89 
90     {
91         Conn_Info_t * const p_conn = ifs_table->conn;
92         const int num_conn = ifs_table->num_conn;
93         int i;
94         for (i = 0; i < num_conn; ++i) {
95             Conn_Info_t *p_conn_cur = p_conn + i;
96             free(p_conn_cur->name);
97             free(p_conn_cur->description);
98             free(p_conn_cur->default_type);
99         }
100     }
101 
102     {
103         Param_Info_t * const p_param = ifs_table->param;
104         const int num_param = ifs_table->num_param;
105         int i;
106         for (i = 0; i < num_param; ++i) {
107             Param_Info_t *p_param_cur = p_param + i;
108             free(p_param_cur->name);
109             free(p_param_cur->description);
110         }
111     }
112 
113     {
114         Inst_Var_Info_t * const p_inst_var = ifs_table->inst_var;
115         const int num_inst_var = ifs_table->num_inst_var;
116         int i;
117         for(i = 0; i < num_inst_var; ++i) {
118             Inst_Var_Info_t *p_inst_var_cur = p_inst_var + i;
119             free(p_inst_var_cur->name);
120             free(p_inst_var_cur->description);
121         }
122     }
123 
124     free(ifs_table->conn);
125     free(ifs_table->param);
126     free(ifs_table->inst_var);
127 } /* end of function rem_ifs_table */
128 
129 
130 
131 
132 
133