⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pp_lst.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 3 页
字号:
/*============================================================================FILE  pp_lst.cMEMBER OF process cmppCopyright 1991Georgia Tech Research CorporationAtlanta, Georgia 30332All Rights ReservedPROJECT A-8503AUTHORS    9/12/91  Bill KuhnMODIFICATIONS    <date> <person name> <nature of modifications>SUMMARY    This file contains functions used in processing the files:        modpath.lst        udnpath.lst    The files 'modpath.lst' and 'udnpath.lst' are read to get    the pathnames to directories containing the models and node types    desired in the simulator to be built.  Files in each of these    directories are then examined to get the names of functions and/or    data structures that the simulator must know about.  The names    are then checked for uniqueness, and finally, a collection of    files needed in the 'make' for the simulator are written.INTERFACES    preprocess_lst_files()REFERENCED FILES    None.NON-STANDARD FEATURES    None.============================================================================*/#include  "cmpp.h"#include  <ctype.h>#include  <stdlib.h>#include  <string.h>extern int str_to_lower(char *s);/*void    *malloc(unsigned size);void    *realloc(void *ptr, unsigned size);*//* *********************************************************************** *//* * Information for processing the pathname files */typedef struct {    char        *path_name;     /* Pathname read from model path file */    char        *spice_name;    /* Name of model from ifspec.ifs  */    char        *cfunc_name;    /* Name of C fcn from ifspec.ifs  */    Boolean_t   spice_unique;   /* True if spice name unique */    Boolean_t   cfunc_unique;   /* True if C fcn name unique */} Model_Info_t;typedef struct {    char        *path_name;     /* Pathname read from udn path file */    char        *node_name;     /* Name of node type  */    Boolean_t   unique;         /* True if node type name unique */} Node_Info_t;/* *********************************************************************** */static Status_t read_modpath(int *num_models, Model_Info_t **model_info);static Status_t read_udnpath(int *num_nodes, Node_Info_t **node_info);static Status_t read_model_names(int num_models, Model_Info_t *model_info);static Status_t read_node_names(int num_nodes, Node_Info_t *node_info);static Status_t check_uniqueness(int num_models, Model_Info_t *model_info,                                 int num_nodes, Node_Info_t *node_info);static Status_t write_CMextrn(int num_models, Model_Info_t *model_info);static Status_t write_CMinfo(int num_models, Model_Info_t *model_info);static Status_t write_UDNextrn(int num_nodes, Node_Info_t *node_info);static Status_t write_UDNinfo(int num_nodes, Node_Info_t *node_info);static Status_t write_objects_inc(int num_models, Model_Info_t *model_info,                                  int num_nodes, Node_Info_t *node_info);static Status_t read_udn_type_name(char *path, char **node_name);/* *********************************************************************** *//*preprocess_lst_filesFunction preprocess_lst_files is the top-level driver function forpreprocessing a simulator model path list file (modpath.lst). This function calls read_ifs_file() requesting it to read andparse the Interface Specification file (ifspec.ifs) to extractthe model name and associated C function name and place thisinformation into an internal data structure.  It then callscheck_uniqueness() to verify that the model names and functionnames are unique with respect to each other and to the models andfunctions internal to SPICE 3C1.  Following this check, it callswrite_CMextrn(), write_CMinfo(), and write_make_include() towrite out the C include files CMextrn.h and CMinfo.h required bySPICE function SPIinit.c to define the models known to thesimulator, and to write out a make include file used by the makeutility to locate the object modules necessary to link the modelsinto the simulator.*/void preprocess_lst_files(void){    Status_t        status;      /* Return status */    Model_Info_t    *model_info; /* Info about each model */    Node_Info_t     *node_info;  /* Info about each user-defined node type */    int             num_models;  /* The number of models */    int             num_nodes;   /* The number of user-defined nodes */    /* Get list of models from model pathname file */    status = read_modpath(&num_models, &model_info);    if(status != OK) {        exit(1);    }    /* Get list of node types from udn pathname file */    status = read_udnpath(&num_nodes, &node_info);    if(status != OK) {        exit(1);    }    /* Get the spice and C function names from the ifspec.ifs files */    status = read_model_names(num_models, model_info);    if(status != OK) {        exit(1);    }    /* Get the user-defined node type names */    status = read_node_names(num_nodes, node_info);    if(status != OK) {        exit(1);    }    /* Check to be sure the names are unique */    status = check_uniqueness(num_models, model_info,                              num_nodes, node_info);    if(status != OK) {        exit(1);    }    /* Write out the CMextrn.h file used to compile SPIinit.c */    status = write_CMextrn(num_models, model_info);    if(status != OK) {        exit(1);    }    /* Write out the CMinfo.h file used to compile SPIinit.c */    status = write_CMinfo(num_models, model_info);    if(status != OK) {        exit(1);    }    /* Write out the UDNextrn.h file used to compile SPIinit.c */    status = write_UDNextrn(num_nodes, node_info);    if(status != OK) {        exit(1);    }    /* Write out the UDNinfo.h file used to compile SPIinit.c */    status = write_UDNinfo(num_nodes, node_info);    if(status != OK) {        exit(1);    }    /* Write the make_include file used to link the models and */    /* user-defined node functions with the simulator */    status = write_objects_inc(num_models, model_info,                              num_nodes, node_info);    if(status != OK) {        exit(1);    }}/* *********************************************************************** *//*read_modpathThis function opens the modpath.lst file, reads the pathnames from thefile, and puts them into an internal data structure for futureprocessing.*/static Status_t read_modpath(    int            *num_models,       /* Number of model pathnames found */    Model_Info_t   **model_info       /* Info about each model */){    FILE     *fp;                     /* Model pathname file pointer */    char     msg[MAX_PATH_LEN+257];   /* space for an error message */    char     path[MAX_PATH_LEN+2];    /* space to read pathnames into */    Model_Info_t  *model = NULL;      /* temporary pointer to model info */    int     n;    int     i;    int     j;    int     len;    int     line_num;    static char *filename = MODPATH_FILENAME;    /* Initialize number of models to zero in case of error */    *num_models = 0;    /* Open the model pathname file */    fp = fopen(filename, "r");    if(fp == NULL) {        sprintf(msg, "ERROR - File not found: %s", filename);        print_error(msg);        return(ERROR);    }    /* Read the pathnames from the file, one line at a time until EOF */    n = 0;    line_num = 0;    while( fgets(path, sizeof(path), fp) ) {        line_num++;        len = strlen(path);        /* If line was too long for buffer, exit with error */        if(len > MAX_PATH_LEN) {            sprintf(msg, "ERROR - Line %d of %s exceeds %d characters",                    line_num, filename, MAX_PATH_LEN);            print_error(msg);            return(ERROR);        }        /* Strip white space including newline */        for(i = 0, j = 0; i < len; ) {            if(isspace(path[i])) {                i++;            }            else {                path[j] = path[i];                i++;                j++;            }        }        path[j] = '\0';        len = j;        /* Strip trailing '/' if any */        if(path[len - 1] == '/')            path[--len] = '\0';        /* If blank line, continue */        if(len == 0)            continue;        /* Make sure pathname is short enough to add a filename at the end */        if(len > (MAX_PATH_LEN - (MAX_FN_LEN + 1)) ) {            sprintf(msg, "ERROR - Pathname on line %d of %s exceeds %d characters",                    line_num, filename, (MAX_PATH_LEN - (MAX_FN_LEN + 1)));            print_error(msg);            return(ERROR);        }        /* Allocate and initialize a new model info structure */        if(n == 0)            model = (void *) malloc(sizeof(Model_Info_t));        else            model = (void *) realloc(model, (n + 1) * sizeof(Model_Info_t));        model[n].path_name = NULL;        model[n].spice_name = NULL;        model[n].cfunc_name = NULL;        model[n].spice_unique = TRUE;        model[n].cfunc_unique = TRUE;        /* Put pathname into info structure */        model[n].path_name = malloc(len+1);        strcpy(model[n].path_name, path);        /* Increment count of paths read */        n++;    }    /* Close model pathname file and return data read */    fclose(fp);    *num_models = n;    *model_info = model;    return(OK);}/* *********************************************************************** *//*read_udnpathThis function opens the udnpath.lst file, reads the pathnames from thefile, and puts them into an internal data structure for futureprocessing.*/static Status_t read_udnpath(    int            *num_nodes,       /* Number of node pathnames found */    Node_Info_t    **node_info       /* Info about each node */){    FILE     *fp;                     /* Udn pathname file pointer */    char     msg[MAX_PATH_LEN+257];   /* space for an error message */    char     path[MAX_PATH_LEN+2];    /* space to read pathnames into */    Node_Info_t  *node = NULL;        /* temporary pointer to node info */    int     n;    int     i;    int     j;    int     len;    int     line_num;    static char *filename = UDNPATH_FILENAME;    /* Initialize number of nodes to zero in case of error */    *num_nodes = 0;    /* Open the node pathname file */    fp = fopen(filename, "r");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -