📄 pp_lst.c
字号:
/* Skip if already seen once */ if(node_info[i].unique == FALSE) continue; /* Then check against other names in list */ for(j = 0; j < num_nodes; j++) { /* Skip checking against itself */ if(i == j) continue; /* Compare the names */ if(strcmp(node_info[i].node_name, node_info[j].node_name) == 0) { all_unique = FALSE; node_info[i].unique = FALSE; node_info[j].unique = FALSE; sprintf(msg, "ERROR - Node type '%s' in directory: %s", node_info[i].node_name, node_info[i].path_name); print_error(msg); print_error(" is same as"); sprintf(msg, " node type '%s' in directory: %s\n", node_info[j].node_name, node_info[j].path_name); print_error(msg); } } } /* Return error status */ if(all_unique) return(OK); else return(ERROR);}/* *********************************************************************** *//*write_CMextrnFunction write_CMextrn writes the CMextrn.h file used incompiling SPIinit.c immediately prior to linking the simulatorand code models. This SPICE source file uses the structuresmentioned in the include file to define the models known to thesimulator.*/static Status_t write_CMextrn( int num_models, /* Number of model pathnames */ Model_Info_t *model_info /* Info about each model */){ int i; /* A temporary counter */ FILE *fp; /* File pointer for writing CMextrn.h */ /* Open the file to be written */ fp = fopen("cmextrn.h", "w"); if(fp == NULL) { print_error("ERROR - Problems opening CMextrn.h for write"); return(ERROR); } /* Write out the data */ for(i = 0; i < num_models; i++) { fprintf(fp, "extern SPICEdev %s_info;\n", model_info[i].cfunc_name); } /* Close the file and return */ fclose(fp); return(OK);}/* *********************************************************************** *//*write_CMinfoFunction write_CMinfo writes the CMinfo.h file used in compilingSPIinit.c immediately prior to linking the simulator and codemodels. This SPICE source file uses the structures mentioned inthe include file to define the models known to the simulator.*/static Status_t write_CMinfo( int num_models, /* Number of model pathnames */ Model_Info_t *model_info /* Info about each model */){ int i; /* A temporary counter */ FILE *fp; /* File pointer for writing CMinfo.h */ /* Open the file to be written */ fp = fopen("cminfo.h", "w"); if(fp == NULL) { print_error("ERROR - Problems opening CMinfo.h for write"); return(ERROR); } /* Write out the data */ for(i = 0; i < num_models; i++) { fprintf(fp, "&%s_info,\n", model_info[i].cfunc_name); } /* Close the file and return */ fclose(fp); return(OK);}/* *********************************************************************** *//*write_UDNextrnFunction write_UDNextrn writes the UDNextrn.h file used incompiling SPIinit.c immediately prior to linking the simulatorand user-defined nodes. This SPICE source file uses the structuresmentioned in the include file to define the node types known to thesimulator.*/static Status_t write_UDNextrn( int num_nodes, /* Number of node pathnames */ Node_Info_t *node_info /* Info about each node */){ int i; /* A temporary counter */ FILE *fp; /* File pointer for writing UDNextrn.h */ /* Open the file to be written */ fp = fopen("udnextrn.h", "w"); if(fp == NULL) { print_error("ERROR - Problems opening UDNextrn.h for write"); return(ERROR); } /* Write out the data */ for(i = 0; i < num_nodes; i++) { fprintf(fp, "extern Evt_Udn_Info_t udn_%s_info;\n", node_info[i].node_name); } /* Close the file and return */ fclose(fp); return(OK);}/* *********************************************************************** *//*write_UDNinfoFunction write_UDNinfo writes the UDNinfo.h file used incompiling SPIinit.c immediately prior to linking the simulatorand user-defined nodes. This SPICE source file uses the structuresmentioned in the include file to define the node types known to thesimulator.*/static Status_t write_UDNinfo( int num_nodes, /* Number of node pathnames */ Node_Info_t *node_info /* Info about each node */){ int i; /* A temporary counter */ FILE *fp; /* File pointer for writing UDNinfo.h */ /* Open the file to be written */ fp = fopen("udninfo.h", "w"); if(fp == NULL) { print_error("ERROR - Problems opening UDNinfo.h for write"); return(ERROR); } /* Write out the data */ for(i = 0; i < num_nodes; i++) { fprintf(fp, "&udn_%s_info,\n", node_info[i].node_name); } /* Close the file and return */ fclose(fp); return(OK);}/* *********************************************************************** *//*write_objects_incFunction write_objects_inc writes a make include file used bythe make utility to locate the object modules needed to link thesimulator with the code models and user-defined node types.*/static Status_t write_objects_inc( int num_models, /* Number of model pathnames */ Model_Info_t *model_info, /* Info about each model */ int num_nodes, /* Number of udn pathnames */ Node_Info_t *node_info /* Info about each node type */){ int i; /* A temporary counter */ FILE *fp; /* File pointer for writing make_include */ /* Open the file to be written */ fp = fopen("objects.inc", "w"); if(fp == NULL) { print_error("ERROR - Problems opening objects.inc file for write"); return(ERROR); } /* Write out the data */ for(i = 0; i < num_models; i++) { fprintf(fp, "%s/*.o", model_info[i].path_name); if((i < (num_models - 1)) || (num_nodes > 0)) fprintf(fp, " \\\n"); else fprintf(fp, "\n"); } for(i = 0; i < num_nodes; i++) { fprintf(fp, "%s/*.o", node_info[i].path_name); if(i < (num_nodes - 1)) fprintf(fp, " \\\n"); else fprintf(fp, "\n"); } /* Close the file and return */ fclose(fp); return(OK);}/*read_udn_type_nameThis function reads a User-Defined Node Definition File untilthe definition of the Evt_Udn_Info_t structis found, and then gets the name of the node type from the firstmember of the structure.*/static Status_t read_udn_type_name( char *path, /* the path to the node definition file */ char **node_name /* the node type name found in the file */){ FILE *fp; /* file pointer for opened file */ /*char msg[MAX_PATH_LEN+257];*/ /* space for an error message */ Boolean_t found; /* true if name found successfully */ Boolean_t in_struct; /* true if found struct with name */ char name[MAX_NAME_LEN + 1]; /* temporary storage for name read */ int c; /* a character read from the file */ int i; /* a counter */ static char *struct_type = "Evt_Udn_Info_t"; /* Open the file from which the node type name will be read */ fp = fopen(path, "r"); if(fp == NULL) return(ERROR); /* Read the file until the definition of the Evt_Udn_Info_t struct */ /* is found, then get the name of the node type from the first */ /* member of the structure */ found = FALSE; do { /* read the next character */ c = fgetc(fp); /* check for and gobble up comments */ if(c == '/') { c = fgetc(fp); if(c == '*') { do { c = fgetc(fp); if(c == '*') { c = fgetc(fp); if((c == '/') || (c == EOF)) break; else ungetc(c, fp); } } while(c != EOF); } } if(c == EOF) break; /* read until "Evt_Udn_Info_t" is encountered */ for(i = 0, in_struct = FALSE; ; i++) { if(c != struct_type[i]) break; else if(i == (sizeof(struct_type) - 2)) { in_struct = TRUE; break; } else c = fgetc(fp); } /* if found it, read until open quote found */ /* and then read the name until the closing quote is found */ if(in_struct) { do { c = fgetc(fp); if(c == '"') { i = 0; do { c = fgetc(fp); if(c == '"') { found = TRUE; name[i] = '\0'; } else if(c != EOF) name[i++] = c; } while((c != EOF) && (! found)); } } while((c != EOF) && (! found)); } } while((c != EOF) && (! found)); /* Close the file and return */ fclose(fp); if(found) { *node_name = malloc(strlen(name) + 1); strcpy(*node_name, name); return(OK); } else { *node_name = NULL; return(ERROR); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -