compile:forms/2'> file:name()'> dictionary file'> %also; %here; ]>
2012 2014 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diameter_make(3) Anders Svensson diameter_make.xml
diameter_make Diameter dictionary compilation.

The function &codec; is used to compile a diameter &dictionary; into Erlang source. The resulting source implements the interface diameter requires to encode and decode the dictionary's messages and AVPs.

The utility &man_compile; provides an alternate compilation interface.

codec(File :: iolist() | binary(), [Opt]) -> ok | {ok, [Out]} | {error, Reason} Compile a dictionary file into Erlang source.

Compile a single dictionary file. The input File can be either a path or a literal dictionary, the occurrence of newline (ascii NL) or carriage return (ascii CR) identifying the latter. Opt determines the format of the results and whether they are written to file or returned, and can have the following types.

parse | forms | erl | hrl

Specifies an output format. Whether the output is returned or written to file depends on whether or not option return is specified. When written to file, the resulting file(s) will have extensions .D, .F, .erl, and .hrl respectively, basenames defaulting to dictionary if the input dictionary is literal and does not specify &dict_name;. When returned, results are in the order of the corresponding format options. Format options default to erl and hrl (in this order) if unspecified.

The parse format is an internal representation that can be passed to &flatten; and &format;, while the forms format can be passed to &compile_forms2;. The erl and hrl formats are returned as iolists.

{include, string()}

Prepend the specified directory to the code path. Use to point at beam files compiled from inherited dictionaries, &dict_inherits; in a dictionary file creating a beam dependency, not an erl/hrl dependency.

Multiple include options can be specified.

{outdir, string()}

Write generated source to the specified directory. Defaults to the current working directory. Has no effect if option return is specified.

return

Return results in a {ok, [Out]} tuple instead of writing to file and returning ok.

{name|prefix, string()}

Transform the input dictionary before compilation, setting &dict_name; or &dict_prefix; to the specified string.

{inherits, string()}

Transform the input dictionary before compilation, appending &dict_inherits; of the specified string.

Two forms have special meaning:

{inherits, "-"}
{inherits, "Prev/Mod"}

The first has the effect of clearing any previous inherits, the second of replacing a previous inherits of Prev to one of Mod. This allows the semantics of the input dictionary to be changed without modifying the file itself.

Multiple inherits options can be specified.

Note that a dictionary's &dict_name;, together with the outdir option, determine the output paths when the return option is not specified. The &dict_name; of a literal input dictionary defaults to dictionary.

A returned error reason can be converted into a readable string using &format_error;.

format(Parsed) -> iolist() Format a parsed dictionary.

Turns a parsed dictionary, as returned by &codec;, back into the dictionary format.

flatten(Parsed) -> term() Flatten a parsed dictionary.

Reconstitute a parsed dictionary, as returned by &codec;, without using &dict_inherits;. That is, construct an equivalent dictionary in which all AVP's are definined in the dictionary itself. The return value is also a parsed dictionary.

format_error(Reason) -> string() Turn an error reason into a readable string.

Turn an error reason returned by &codec; into a readable string.

BUGS

Unrecognized options are silently ignored.

SEE ALSO

&man_compile;, &man_dict;