Mailfromd Manual (split by node):   Section:   Chapter:FastBack: MFL   Up: Constants   FastForward: Library   Contents: Table of ContentsIndex: Concept Index

4.8.1 Built-in constants

Several constants are built into the MFL compiler. To discern them from user-defined ones, their names start and end with two underscores (‘__’).

The following constants are defined in mailfromd version 8.7:

Built-in constant: string __file__

Expands to the name of the current source file.

Built-in constant: string __function__

Expands to the name of the current lexical context, i.e. the function or handler name.

Built-in constant: string __git__

This built-in constant is defined for alpha versions only. Its value is the Git tag of the recent commit corresponding to that version of the package. If the release contains some uncommitted changes, the value of the ‘__git__’ constant ends with the suffix ‘-dirty’.

Built-in constant: number __line__

Expands to the current line number in the input source file.

Built-in constant: number __major__

Expands to the major version number.

The following example uses __major__ constant to determine if some version-dependent feature can be used:

if __major__ > 2
  # Use some version-specific feature
fi  
Built-in constant: number __minor__

Expands to the minor version number.

Built-in constant: string __module__

Expands to the name of the current module (see Modules).

Built-in constant: string __package__

Expands to the package name (‘mailfromd’)

Built-in constant: number __patch__

For alpha versions and maintenance releases expands to the version patch level. For stable versions, expands to ‘0’.

Built-in constant: string __defpreproc__

Expands to the default external preprocessor command line, if the preprocessor is used, or to an empty string if it is not, e.g.:

__defpreproc__ ⇒ "/usr/bin/m4 -s"

See Preprocessor, for information on preprocessor and its features.

Built-in constant: string __preproc__

Expands to the current external preprocessor command line, if the preprocessor is used, or to an empty string if it is not. Notice, that it equals __defpreproc__, unless the preprocessor was redefined using --preprocessor command line option (see –preprocessor).

Built-in constant: string __version__

Expands to the textual representation of the program version (e.g. ‘3.0.90’)

Built-in constant: string __defstatedir__

Expands to the default state directory (see statedir).

Built-in constant: string __statedir__

Expands to the current value of the program state directory (see statedir). Notice, that it is the same as __defstatedir__ unless the state directory was redefined at run time.

Built-in constants can be used as variables, this allows to expand them within strings or here-documents. The following example illustrates the common practice used for debugging configuration scripts:

func foo(number x)
do
  echo "%__file__:%__line__: foo called with arg %x"
  …
done

If the function foo were called in line 28 of the script file /etc/mailfromd.mf, like this: foo(10), you will see the following string in your logs:

/etc/mailfromd.mf:28: foo called with arg 10

Mailfromd Manual (split by node):   Section:   Chapter:FastBack: MFL   Up: Constants   FastForward: Library   Contents: Table of ContentsIndex: Concept Index