# phpman > man > fmttest(1)

[FMTTEST(1mh)](https://www.chedong.com/phpMan.php/man/FMTTEST/1mh/markdown)                                                                            [FMTTEST(1mh)](https://www.chedong.com/phpMan.php/man/FMTTEST/1mh/markdown)



## NAME
       fmttest - test programs in nmh's [_mh-format_(5)](https://www.chedong.com/phpMan.php/man/mh-format/5/markdown) language

## SYNOPSIS
       **fmttest** [**-help**] [**-version**] [**-form** _formatfile_] [**-format** _formatstring_] [**-address** | **-raw** | **-date**
            | **-message**] [**-file** | **-nofile**] [**--component** _component-text_] [**-dupaddrs** | **-nodupaddrs**]
            [**-ccme** | **-noccme**] [**-outsize** _size-in-characters_] [**-width** _column-width_] [**-msgnum** _number_]
            [**-msgcur** _flag_] [**-msgsize** _size_] [**-unseen** _flag_] [**-dump** | **-nodump**] [**-trace** | **-notrace**]
            [_+folder_] [_msgs_ | _strings_]

## DESCRIPTION
       **fmttest**  is used to test programs written for the **nmh** format language as specified by _mh-for__‐
       [_mat_(5)](https://www.chedong.com/phpMan.php/man/mat/5/markdown).  It is also intended to replace the **ap**, **dp**, and **fmtdump** programs.

### Format Program Selection
       The **-format** _string_ and **-form** _formatfile_ specify a format string or file to  read.   A  format
       string,  if given, must be a single argument to the **-format** switch.  If a format file name is
       passed to the **-form**, switch, the file is searched for using the normal  **nmh**  rules:  absolute
       pathnames are accessed directly, tilde expansion is done on usernames, and files are searched
       for in the user's _Mail_ directory as specified in their profile.  If not found there, the  di‐
       rectory “_/etc/nmh_” is checked.

### Mode Selection and Component Specification
       **fmttest**  has  four  operating modes - address, raw, date, and message - which are selected by
       the **-address**, **-raw**, **-date**, and **-message** switches, respectively.

       Address mode treats every argument as an email address to be processed by nmh's email  parser
       using  the  specified  format  program.   The  parsed  address is made available as a special
       %{_text_} component escape, and the output from the program is printed on standard output.   If
       there was an error parsing the email address the error message is stored in the %{_error_} com‐
       ponent escape.  If no format program is given on the command line, the following default pro‐
       gram is used:

            %<{error}%{error}: %{text}%|%(putstr(proper{text}))%>

       Address mode is equivalent to [_ap_(8)](https://www.chedong.com/phpMan.php/man/ap/8/markdown).

       In  raw mode, no processing of the specified arguments is done.  Each argument is run against
       the specified format program with the argument text available in the %{_text_} component.   You
       must specify a format with **-form** or **-format** when using raw mode.

       Date  mode  is identical to raw mode, with one exception: if no format is specified, the fol‐
       lowing format string is used:

            %<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>

       Date mode is equivalent to [_dp_(8)](https://www.chedong.com/phpMan.php/man/dp/8/markdown).

       In message mode the arguments to **fmttest** are interpreted as an optional folder and  messages.
       **fmttest** will read each specified message and make all of the components in the message avail‐
       able to the format program.  Also, the appropriate information for the %(_msg_), %(_cur_),  %(_un__‐
       _seen_),  and  %(_size_)  function escapes will be made available for each message.  If the **-file**
       switch is given, the arguments are interpreted as filenames instead of message  numbers,  but
       otherwise  the  behavior  is the same (except that the %(_msg_), %(_cur_), and %(_unseen_) function
       escapes will not provide any useful information).

       The default format used in address mode is the default format used by  **scan**.   The  following
       command can replicate the functionality of the **repl** command.

            fmttest -nodupaddrs -form replcomps -outsize max [+folder] message

       Regardless  of the mode, other components can be provided to the format program by the use of
       the **--component** switch.  For example, the following program will test the  use  of  the  “**en**‐‐
       **crypted**” component:

            fmttest --encrypted yes -message cur

       In  message  mode, components supplied on the command line will override components from mes‐
       sages.

### Additional Switches
       The **-dupaddrs** and **-nodupaddrs** switches control whether duplicate  addresses  are  allowed  or
       suppressed  by  the **FORMATADDR** instruction, which is used by the `%(_formataddr_)' function es‐
       cape.  In normal operation duplicate addresses are only suppressed by **repl**.

       The **-ccme** and **-noccme** switches control whether or not to count the user's local mailbox as  a
       duplicate  address.   This replicates the behavior of the **-cc** _me_ switch to **repl**, and only ap‐
       plies if **-nodupaddrs** is in effect.

       The **-outsize** switch controls the maximum number of printable characters that the  format  en‐
       gine will produce.  Characters marked as non-printing by the format engine with `%(_zputlit_)',
       characters with zero width, and extra bytes that are part of a multibyte  character  are  not
       counted  against  this  total.   Two special values are supported: “_max_”, which means as many
       characters as the format engine can produce (limited by internal buffers), and “_width_”, which
       will  set  the  value  to the width of the terminal.  In message mode it defaults to “_width_”,
       otherwise the default is “_max_”.

       The **-width** switch controls the column width which is used by the `%(_width_)' function  escape.
       It defaults to the terminal width.

       The **-msgnum**, **-msgcur**, **-msgsize**, and the **-unseen** switches all control the values used, respec‐
       tively, by the following function escapes: `%(_num_)', `%(_cur_)',  `%(_size_)',  and  `%(_unseen_)'.
       If  none  are supplied, these values are taken from the message in message mode; in all other
       modes the default values are 0.

### Compiling and Tracing Format Programs
       The **-dump** switch outputs the complete set of format instructions  for  the  specified  format
       program.   The **-trace** switch will output each format instruction as it is being executed, and
       show the values of the _num_ and _str_ registers if they have changed from the previous  instruc‐
       tion.  The output buffer is also printed if it has changed from the previous instruction.

### Format Instructions
       It  should  be noted that there is not a one-to-one correspondence between format escapes and
       format instructions; many instructions have side effects.  Instructions  prefixed  with  “_LV_”
       generally  return  a integer into the _num_ (value) register; instructions prefixed with a “_LS_”
       return a string into the _str_ register.

       _Instruction_   _Description_
       COMP          Output component
       COMPF         Formatted output component
       LIT           Output literal text
       LITF          Formatted literal text output
       CHAR          Output single character
       NUM           Output the _num_ register
       NUMF          Formatted output of the _num_ register
       STR           Output the _str_ register
       STRF          Formatted output of the _str_ register
       STRFW         Not used
       PUTADDR       Output address list in _str_ register
       STRLIT        Output _str_, no space compression
       STRLITZ       Like **STRLIT**, but not counted against width
       LS_COMP       Write component to _str_ register
       LS_LIT        Write literal to _str_ register
       LS_GETENV     Write environment var to _str_ register
       LS_DECODECOMP Decode RFC 2047 encoded component to _str_ register
       LS_DECODE     Decode RFC 2047 encoded string to _str_ register
       LS_TRIM       Trim trailing whitespace from _str_ register
       LV_COMP       Convert component to integer, store in _num_ register
       LV_COMPFLAG   Set _num_ to 1 if **TRUE** set in component
       LV_LIT        Load literal value into _num_ register
       LV_DAT        Load value from _dat_ array into _num_ register (see note)
       LV_STRLEN     Set _num_ to the length of _str_
       LV_PLUS_L     Add value to _num_ register
       LV_MINUS_L    Subtract value from _num_ register
       LV_DIVIDE_L   Divide _num_ register by value
       LV_MODULO_L   _num_ modulo value
       LV_CHAR_LEFT  Store remaining number of printable chars in _num_
       LS_MONTH      Write short name of month to _str_ from date component
       LS_LMONTH     Write long name of month to _str_ from date component
       LS_ZONE       Write time zone offset to _str_ from date component
       LS_DAY        Write short name of day of week to _str_ from date component
       LS_WEEKDAY    Write long name of day of week to _str_ from date component
       LS_822DATE    Write RFC 822 compatible date to _str_ from date component
       LS_PRETTY     Write date with “pretty” timezone to _str_
       LV_SEC        Write date component seconds to _num_
       LV_MIN        Write date component minutes to _num_
       LV_HOUR       Write date component hour to _num_
       LV_MON        Write date component numeric month to _num_ (start at 1)
       LV_YEAR       Write date component year to _num_
       LV_YDAY       Write date component Julian day to _num_
       LV_WDAY       Write date component day of week to _num_ (0 == Sunday)
       LV_ZONE       Write date component time zone offset to _num_
       LV_CLOCK      Write date component in Unix epoch time to _num_
       LV_RCLOCK     Write offset of date component from current time to _num_
       LV_DAYF       Write 1 to _num_ if day of week is explicit
       LV_DST        Write 1 to _num_ if DST is in effect for date component
       LV_ZONEF      Write 1 to _num_ if timezone is explicit
       LS_ADDR       Write email address of addr component to _str_
       LS_PERS       Write personal name of addr component to _str_
       LS_MBOX       Write mailbox (username) of addr component to _str_
       LS_HOST       Write host of addr component to _str_
       LS_PATH       Write host route of addr component to _str_
       LS_GNAME      Write group name of addr component to _str_
       LS_NOTE       Write note portion of addr component to _str_
       LS_822ADDR    Write “proper” RFC 822 version of addr component to _str_
       LS_FRIENDLY   Write friendly (name or note) of address component to _str_
       LS_UNQUOTE    Remove RFC 2822 quotes from string
       LV_HOSTTYPE   Set _num_ to type of host (0=local, 1=network)
       LV_INGRPF     Set _num_ to 1 if address was inside of group
       LV_NOHOSTF    Set _num_ to 1 of no host was present in address component
       LOCALDATE     Convert date component to local timezone
       GMTDATE       Convert date component to GMT
       PARSEDATE     Parse date component
       PARSEADDR     Parse address component
       FORMATADDR    Add address component to list in _str_
       CONCATADDR    Like **FORMATADDR**, but will not suppress duplicates
       MYMBOX        Set _num_ if address component is a local address
       SAVESTR       Save _str_ register temporarily
       DONE          End program
       NOP           No operation
       GOTO          Jump to new instruction
       IF_S_NULL     Branch if _str_ is **NULL**
       IF_S          Branch if _str_ is not **NULL**
       IF_V_EQ       Branch if _num_ is equal to value
       IF_V_NE       Branch if _num_ is not equal to value
       IF_V_GT       Branch if _num_ is greater than value
       IF_MATCH      Branch if _str_ contains string
       IF_AMATCH     Branch if _str_ starts with string
       S_NULL        Set _num_ to 1 if _str_ is **NULL**
       S_NONNULL     Set _num_ to 1 if _str_ is not **NULL**
       V_EQ          Set _num_ to 1 if _num_ equals value
       V_NE          Set _num_ to 1 if _num_ does not equal value
       V_GT          Set _num_ to 1 if _num_ is greater than value
       V_MATCH       Set _num_ to 1 if _str_ contains string
       V_AMATCH      Set _num_ to 1 if _str_ starts with string

       The **LV**___**DAT** instruction is a bit special.  Callers of the format library pass in an  array  of
       integers that are used by certain format escapes.  The current list of format escapes and the
       indexes they use are:

            dat[0]  %(_num_)
            dat[1]  %(_cur_)
            dat[2]  %(_size_)
            dat[3]  %(_width_)
            dat[4]  %(_unseen_)

## SEE ALSO
       [_mh-format_(5)](https://www.chedong.com/phpMan.php/man/mh-format/5/markdown), [_repl_(1)](https://www.chedong.com/phpMan.php/man/repl/1/markdown), [_ap_(8)](https://www.chedong.com/phpMan.php/man/ap/8/markdown), [_dp_(8)](https://www.chedong.com/phpMan.php/man/dp/8/markdown), [_fmtdump_(8)](https://www.chedong.com/phpMan.php/man/fmtdump/8/markdown)

## DEFAULTS
       `**-message**'
       `**-nofile**'
       `**-dupaddrs**'

## BUGS
       It shouldn't require as much code from other programs as it does.



nmh-1.7.1                                    2014-08-31                                 [FMTTEST(1mh)](https://www.chedong.com/phpMan.php/man/FMTTEST/1mh/markdown)
