| < Prev | Back to Table of Contents | Next > |
Modules may be imported into a database, either by reading
directly from a file or by passing the module data to be parsed
directly, using the import subcommand. Any errors or
warnings that are generated during parsing will be logged to the file
channel configured for the database (see Logging Compiler Messages).
% dbcmd import option value
?option value ...?
..where dbcmd is the name of the database
into which modules are to be imported, and a series of option/value
pairs specify how the data is to be processed, which are listed
below.
1 if the data was parsed successfully (i.e., either
there were no errors during the parse or any errors that occurred
were "recoverable").
0 if the data was not parsed successfully (i.e., one
or more non-recoverable errors occurred). If any module fails to be
parsed successfully, then all imported data is discarded, including
the file record its self if the -in option (see below)
was not specified.
| Option | Argument | Purpose |
|---|---|---|
-filename |
path |
Specifies the name of the file to be imported from if reading directly. May also specify the filename for data that has been preprocessed (such as stripping RFC headers/documentation) and passed directly to the command. If the extension is ".xml" then the data is passed to the XML parser; otherwise, the data is parsed as an SMI module. |
-rawdata |
text |
Specifies module data to be parsed directly, rather than read from file. This option is useful if the data to be parsed has been pre-processed to conform to the XML-SMI Schema or SMI format by the Tcl script that is importing modules. |
-yylineno |
value |
Specifies an integer offset value to for the line number indicated when logging any parse errors resulting from the import. For example, if extracting modules from a file and importing those modules individually, it may be useful to inform the parser of the "real" line number corresponding to the first line of data being parsed if, as a result of the extraction, the module begins on a different line number than in the source file. |
-in |
recordName |
Specifies the handle for the file record that the module(s)
are to be imported into. Note that this is NOT the path for the
file on disk: file record handles take the form
@File#, where # is an integer suffix
that uniquely identifies the file within its database. If this
property is unspecified, then a new file record will be created
to hold the imported records. |
-errors |
variable |
Specifies the name of a local variable that is to be assigned a count of the number of errors (if any) that occurred during the parse. |
-warnings |
variable |
Specifies the name of a local variable that is to be assigned a count of the number of warnings (if any) that occurred during the parse. |
% smilib import -filename /path/to/module.mib \
-errors errCount -warnings warnCount
1
% smilib log "$errCount error(s), $warnCount warning(s)"
0 error(s), 0 warning(s)
% smilib import -filename /path/to/module.xml \
-errors errCount -warnings warnCount
1
% smilib log "$errCount error(s), $warnCount warning(s)"
0 error(s), 0 warning(s)
% set channel [open "example.mib" r] % set rawData [read $channel] % close $channel % set file [smilib new -file -filename "example.mib"] % smilib import -rawdata $rawData -in $file 1
| < Prev | Back to Table of Contents | Next > |