diff options
Diffstat (limited to 'lib/snmp/src/compile')
-rw-r--r-- | lib/snmp/src/compile/snmpc.erl | 6 | ||||
-rw-r--r-- | lib/snmp/src/compile/snmpc.src | 49 | ||||
-rw-r--r-- | lib/snmp/src/compile/snmpc_mib_gram.yrl | 67 |
3 files changed, 30 insertions, 92 deletions
diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index a3a893dd51..c4b3d7090f 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -1031,12 +1031,6 @@ definitions_loop([{#mc_module_compliance{name = Name, end, definitions_loop(T, Data); -%% definitions_loop([{#mc_module_compliance{name = Name},Line}|T], Data) -> -%% ?vlog2("defloop -> module_compliance:" -%% "~n Name: ~p", [Name], Line), -%% ensure_macro_imported('MODULE-COMPLIANCE', Line), -%% definitions_loop(T, Data); - definitions_loop([{#mc_object_group{name = Name, objects = GroupObjects, status = Status, diff --git a/lib/snmp/src/compile/snmpc.src b/lib/snmp/src/compile/snmpc.src index 03044c6454..e0734c056e 100644 --- a/lib/snmp/src/compile/snmpc.src +++ b/lib/snmp/src/compile/snmpc.src @@ -24,10 +24,13 @@ -mode(compile). -include_lib("kernel/include/file.hrl"). +-include_lib("snmp/include/snmp_types.hrl"). + -record(state, { version = "%VSN%", + mfv, file, % .mib or .bin depending on which are compiled outdir = "./", db = volatile, @@ -87,7 +90,7 @@ main(_) -> usage(). compile(State) -> - io:format("snmpc: ~p~n", [State]), + %% io:format("snmpc: ~p~n", [State]), case mk_file(State) of {mib, File} -> Options = mk_mib_options(State), @@ -189,7 +192,9 @@ mk_hrl_options(#state{outdir = OutDir, process_args([]) -> e("No input file"); process_args(Args) -> - process_args(Args, #state{}). + #mib{mib_format_version = MFV} = #mib{}, + State = #state{}, + process_args(Args, State#state{mfv = MFV}). process_args([], #state{verbosity = Verbosity0, file = MIB} = State) -> if @@ -209,21 +214,10 @@ process_args([], #state{verbosity = Verbosity0, file = MIB} = State) -> include_dirs = IPath, include_lib_dirs = IlPath}} end; -process_args([MIB], State) -> - case (catch file:read_file_info(MIB)) of - {ok, #file_info{type = regular}} -> - process_args([], State#state{file = MIB}); - {ok, #file_info{type = BadType}} -> - e(lists:flatten(io_lib:format("~s not a file: ~w", [MIB, BadType]))); - {error, enoent} -> - e(lists:flatten(io_lib:format("No such file: ~s", [MIB]))); - _ -> - e(lists:flatten(io_lib:format("Bad file: ~s", [MIB]))) - end; process_args(["--help"|_Args], _State) -> ok; -process_args(["--version"|_Args], State) -> - {ok, lists:flatten(io_lib:format("snmpc ~s", [State#state.version]))}; +process_args(["--version"|_Args], #state{version = Version, mfv = MFV} = _State) -> + {ok, lists:flatten(io_lib:format("snmpc ~s (~s)", [Version, MFV]))}; process_args(["--verbosity", Verbosity0|Args], #state{verbosity = V} = State) when (V =:= undefined) -> Verbosity = list_to_atom(Verbosity0), @@ -298,6 +292,23 @@ process_args(["--nd"|Args], State) -> process_args(Args, State#state{no_defaults = true}); process_args(["--rrnac"|Args], State) -> process_args(Args, State#state{relaxed_row_name_assigne_check = true}); +process_args([MIB], State) -> + Ext = filename:extension(MIB), + if + ((Ext =:= ".mib") orelse (Ext =:= ".bin")) -> + case (catch file:read_file_info(MIB)) of + {ok, #file_info{type = regular}} -> + process_args([], State#state{file = MIB}); + {ok, #file_info{type = BadType}} -> + e(lists:flatten(io_lib:format("~s not a file: ~w", [MIB, BadType]))); + {error, enoent} -> + e(lists:flatten(io_lib:format("No such file: ~s", [MIB]))); + _ -> + e(lists:flatten(io_lib:format("Bad file: ~s", [MIB]))) + end; + true -> + e(lists:flatten(io_lib:format("Unknown option: ~s", [MIB]))) + end; process_args([Arg|Args], _State) when Args =/= [] -> e(lists:flatten(io_lib:format("Unknown option: ~s", [Arg]))). @@ -345,8 +356,8 @@ usage() -> "~n --ac - The AGENT-CAPABILITIES field will be included." "~n --mod <module> - The module which implements all the instrumentation" "~n functions. " - "~n The name of the of all instrumentation functions" - "~n must be the same as the corresponding managed object" + "~n The name of all instrumentation functions must" + "~n be the same as the corresponding managed object" "~n it implements." "~n --nd - The default instrumentation functions will *not* be used" "~n if a managed object have no instrumentation function. " @@ -355,11 +366,11 @@ usage() -> "~n --rrnac - This option, if present, specifies that the row name " "~n assign check shall not be done strictly according to" "~n the SMI (which allows only the value 1). " - "~n With this option, all values gŕeater than zero is allowed" + "~n With this option, all values greater than zero is allowed" "~n (>= 1). This means that the error will be converted to " "~n a warning. " "~n By default it is not included, but if this option is " - "~n is present it will be. " + "~n present it will be. " "~n " "~n", []), halt(1). diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index a0c59059d2..74b9ddaa25 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -589,64 +589,35 @@ prodrel -> string : lreverse(prodrel, val('$1')). ac_status -> atom : ac_status('$1'). ac_modulepart -> ac_modules : -%% i("ac_modulepart -> " -%% "~n $1: ~p", ['$1']), lreverse(ac_modulepart, '$1'). ac_modulepart -> '$empty' : -%% i("ac_modulepart -> empty", []), []. ac_modules -> ac_module : -%% i("ac_modules -> " -%% "~n $1: ~p", ['$1']), ['$1']. ac_modules -> ac_module ac_modules : -%% i("ac_modules -> " -%% "~n $1: ~p" -%% "~n $2: ~p", ['$1', '$2']), ['$1' | '$2']. ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variationpart : -%% i("ac_module -> " -%% "~n $2: ~p" -%% "~n $5: ~p" -%% "~n $7: ~p", ['$2', '$5', '$7']), make_ac_module('$2', '$5', '$7'). ac_modulenamepart -> mibname : '$1'. ac_modulenamepart -> '$empty' : undefined. ac_variationpart -> '$empty' : -%% i("ac_variationpart -> empty", []), []. ac_variationpart -> ac_variations : -%% i("ac_variationpart -> " -%% "~n $1: ~p", ['$1']), lreverse(ac_variationpart, '$1'). ac_variations -> ac_variation : -%% i("ac_variations -> " -%% "~n $1: ~p", ['$1']), ['$1']. ac_variations -> ac_variation ac_variations : -%% i("ac_variations -> " -%% "~n $1: ~p" -%% "~n $2: ~p", ['$1', '$2']), ['$1' | '$2']. %% ac_variation -> ac_objectvariation. %% ac_variation -> ac_notificationvariation. ac_variation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart defvalpart description : -%% i("mc_module -> " -%% "~n $2: ~p" -%% "~n $3: ~p" -%% "~n $4: ~p" -%% "~n $5: ~p" -%% "~n $6: ~p" -%% "~n $7: ~p" -%% "~n $8: ~p" -%% "~n", ['$2', '$3', '$4', '$5', '$6', '$7', '$8']), make_ac_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). ac_accesspart -> 'ACCESS' ac_access : '$2'. @@ -655,88 +626,50 @@ ac_accesspart -> '$empty' : undefined. ac_access -> atom: ac_access('$1'). ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : -%% io:format("ac_creationpart -> $3: ~p~n", ['$3']), lreverse(ac_creationpart, '$3'). ac_creationpart -> '$empty' : []. mc_modulepart -> '$empty' : -%% i("mc_modulepart -> empty", []), []. mc_modulepart -> mc_modules : -%% i("mc_modulepart -> $1: ~p", ['$1']), lreverse(mc_modulepart, '$1'). mc_modules -> mc_module : -%% i("mc_modules -> " -%% "~n $1: ~p", ['$1']), ['$1']. mc_modules -> mc_module mc_modules : -%% i("mc_modules -> " -%% "~n $1: ~p" -%% "~n $2: ~p", ['$1', '$2']), ['$1' | '$2']. mc_module -> 'MODULE' mc_modulenamepart mc_mandatorypart mc_compliancepart : -%% i("mc_module -> " -%% "~n $2: ~p" -%% "~n $3: ~p" -%% "~n $4: ~p" -%% "~n", ['$2', '$3', '$4']), make_mc_module('$2', '$3', '$4'). mc_modulenamepart -> mibname : '$1'. mc_modulenamepart -> '$empty' : undefined. mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : -%% io:format("mc_mandatorypart -> $3: ~p~n", ['$3']), lreverse(mc_mandatorypart, '$3'). mc_mandatorypart -> '$empty' : -%% io:format("mc_mandatorypart -> empty~n", []), []. mc_compliancepart -> mc_compliances : -%% i("mc_compliancepart -> " -%% "~n $1: ~p", ['$1']), lreverse(mc_compliancepart, '$1'). mc_compliancepart -> '$empty' : -%% i("mc_compliancepart -> empty", []), []. mc_compliances -> mc_compliance : -%% i("mc_compliances -> " -%% "~n $1: ~p", ['$1']), ['$1']. mc_compliances -> mc_compliance mc_compliances : -%% i("mc_compliances -> " -%% "~n $1: ~p" -%% "~n $2: ~p", ['$1', '$2']), ['$1' | '$2']. mc_compliance -> mc_compliancegroup : -%% i("mc_compliance -> " -%% "~n [compliancegroup] $1: ~p", ['$1']), '$1'. mc_compliance -> mc_object : -%% i("mc_compliance -> " -%% "~n [object] $1: ~p", ['$1']), '$1'. mc_compliancegroup -> 'GROUP' objectname description : -%% i("mc_compliancegroup -> " -%% "~n $2: ~p" -%% "~n $3: ~p" -%% "~n", ['$2', '$3']), make_mc_compliance_group('$2', '$3'). mc_object -> 'OBJECT' objectname syntaxpart writesyntaxpart mc_accesspart description : -%% i("mc_object -> " -%% "~n $2: ~p" -%% "~n $3: ~p" -%% "~n $4: ~p" -%% "~n $5: ~p" -%% "~n $6: ~p" -%% "~n", ['$2', '$3', '$4', '$5', '$6']), make_mc_object('$2', '$3', '$4', '$5', '$6'). syntaxpart -> 'SYNTAX' syntax : '$2'. |