2
The Cadence® Design Exchange Format (DEF) reader provides several routines that initialize the reader and set global variables that are used by the reader.
The following routines described in this section set options for reading a DEF file.
The following DEF reader setup and control routines are available in the API.
Initializes internal variables in the DEF reader. You must use this routine before using defrRead. You can use other routines to set callback functions before or after this routine.
int defrInit()
Starts a new parsing session and closes any old parsing session, if open. You must use this routine before using defrRead.
int defrInitSession (- int startSession = 1)
startSession
Boolean. If is non-zero, performs the parser initialization in session-based mode; otherwise, the function will initialize parsing in the compatibility mode, working exactly as a defrInit() call.
Releases all parsing session data and closes the parsing session. If the call to defrClear() is skipped, the data cleaning and the session closing is done by the next defrInitSession() call.
int defrClear()
Specifies the DEF file to read. Any callbacks that have been set are called from within this routine. If the file parses with no errors, that is, all callbacks return OK condition codes, this routine returns zero.
int defrRead(- FILE*
file,const char* fileName,defiUserData* data,int case_sensitive)
file
Specifies a pointer to an already open file. This allows the parser to work with either a disk file or a piped stream. This argument is required. Any callbacks that have been set will be called from within this routine.
fileName
Specifies a UNIX filename using either a complete or a relative path specification.
data
Specifies the data type.
case_sensitive
Specifies whether the data is case sensitive.
Sets the user-provided data. The DEF reader does not look at this data, but passes an opaque defiUserData pointer back to the application with each callback. You can set or change the user data at any time using the defrSetUserData and defrGetUserData routines. Every callback returns user data as the third argument.
void defrSetUserData(- defiUserData*
data)
data
Specifies the user-provided data.
Retrieves the user-provided data. The DEF reader returns an opaque defiUserData pointer, which you set using defrSetUserData. You can set or change the user data at any time with the defrSetUserData and defrGetUserData calls. Every callback returns the user data as the third argument.
defiUserData defrGetUserData()
Adds path data to the appropriate net data. When the net callback is used, the net class and structure information and the path information are returned. This statement does not require any additional arguments.
void defrSetAddPathToNet(void)
Ignores component net information. Component nets are valid DEF syntax but are no longer used. By default, the DEF reader reports component net data as a syntax error. This routine overrides the default so no error is reported. This statement does not require any additional arguments.
void defrSetAllowComponentNets(void)
Returns non-zero value if component nets are allowed.
int defrGetAllowComponentNets()
Changes the character used to indicate comments in the DEF file.
void defrSetCommentChar(char c)
c
Specifies the comment character. The default is a pound sign (#).
Keeps track of all the callback routines that are not set. You can use this routine to keep track of DEF constructs that are in the input file but do not trigger a callback. This statement does not require any additional arguments.
void defrSetRegisterUnusedCallbacks(void)
Prints all callback routines that are not set but have constructs in the DEF file.
void defrPrintUnusedCallbacks(FILE* log)
log
Specifies the file to which the unused callbacks are printed.
Returns the number of callback routines that are not set. That is, routines that have constructs in the input file but no callback trigger. This statement does not require any additional arguments.
int* defrUnusedCallbackCount(void)
The following example shows how to initialize the reader.
int setupRoutine() {- FILE* f;
- int res;
- int userData = 0x01020304;
- ...
- // Initialize the reader. This routine has to call first.
- defrInit();
- // Set user data
- defrSetUserData ((void *)3);
- // Open the def file for the reader to read
- if ((f = fopen("defInputFileName","r")) == 0) {
- printf("Couldn't open input file '%s'\n",
- "defInputFileName");
- return(2);
- }
- // Invoke the parser
- res = defrRead(f, "defInputFileName", (void*)userData);
- if (res != 0) {
- printf("DEF parser returns an error\n");
- return(2);
- }
- fclose(f);
- return 0;}