{
    "content": [
        {
            "type": "text",
            "text": "# FMTTEST (info)\n\n## NAME\n\nfmttest - test programs in nmh's mh-format(5) language\n\n## SYNOPSIS\n\nfmttest [-help] [-version] [-form formatfile] [-format formatstring]\n[-address | -raw | -date | -message] [-file | -nofile] [--compo-\nnent component-text] [-dupaddrs | -nodupaddrs] [-ccme | -noccme]\n[-outsize size-in-characters] [-width column-width] [-msgnum num-\nber] [-msgcur flag] [-msgsize size] [-unseen flag] [-dump |\n-nodump] [-trace | -notrace] [+folder] [msgs | strings]\n\n## DESCRIPTION\n\nfmttest is used to test programs written for the nmh format language as\nspecified  by mh-format(5).  It is also intended to replace the ap, dp,\nand fmtdump programs.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SEE ALSO**\n- **DEFAULTS**\n- **BUGS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "FMTTEST",
        "section": "",
        "mode": "info",
        "summary": "fmttest - test programs in nmh's mh-format(5) language",
        "synopsis": "fmttest [-help] [-version] [-form formatfile] [-format formatstring]\n[-address | -raw | -date | -message] [-file | -nofile] [--compo-\nnent component-text] [-dupaddrs | -nodupaddrs] [-ccme | -noccme]\n[-outsize size-in-characters] [-width column-width] [-msgnum num-\nber] [-msgcur flag] [-msgsize size] [-unseen flag] [-dump |\n-nodump] [-trace | -notrace] [+folder] [msgs | strings]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "mh-format",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/mh-format/5/json"
            },
            {
                "name": "repl",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/repl/1/json"
            },
            {
                "name": "ap",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/ap/8/json"
            },
            {
                "name": "dp",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/dp/8/json"
            },
            {
                "name": "fmtdump",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/fmtdump/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 211,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DEFAULTS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "fmttest - test programs in nmh's mh-format(5) language\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "fmttest [-help] [-version] [-form formatfile] [-format formatstring]\n[-address | -raw | -date | -message] [-file | -nofile] [--compo-\nnent component-text] [-dupaddrs | -nodupaddrs] [-ccme | -noccme]\n[-outsize size-in-characters] [-width column-width] [-msgnum num-\nber] [-msgcur flag] [-msgsize size] [-unseen flag] [-dump |\n-nodump] [-trace | -notrace] [+folder] [msgs | strings]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "fmttest is used to test programs written for the nmh format language as\nspecified  by mh-format(5).  It is also intended to replace the ap, dp,\nand fmtdump programs.\n\nFormat Program Selection\nThe -format string and -form formatfile specify a format string or file\nto  read.   A format string, if given, must be a single argument to the\n-format switch.  If a format file name is passed to the -form,  switch,\nthe file is searched for using the normal nmh rules: absolute pathnames\nare accessed directly, tilde expansion is done on usernames, and  files\nare  searched  for  in  the user's Mail directory as specified in their\nprofile.  If not found there, the directory \"/etc/nmh\" is checked.\n\nMode Selection and Component Specification\nfmttest has four operating modes - address, raw, date,  and  message  -\nwhich are selected by the -address, -raw, -date, and -message switches,\nrespectively.\n\nAddress mode treats every argument as an email address to be  processed\nby  nmh's  email parser using the specified format program.  The parsed\naddress is made available as a special %{text}  component  escape,  and\nthe  output  from  the program is printed on standard output.  If there\nwas an error parsing the email address the error message is  stored  in\nthe  %{error}  component  escape.  If no format program is given on the\ncommand line, the following default program is used:\n\n%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>\n\nAddress mode is equivalent to ap(8).\n\nIn raw mode, no processing of the specified arguments  is  done.   Each\nargument  is run against the specified format program with the argument\ntext available in the %{text} component.  You  must  specify  a  format\nwith -form or -format when using raw mode.\n\nDate mode is identical to raw mode, with one exception: if no format is\nspecified, the following format string is used:\n\n%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>\n\nDate mode is equivalent to dp(8).\n\nIn message mode the arguments to fmttest are interpreted as an optional\nfolder and messages.  fmttest will read each specified message and make\nall of the components in the message available to the  format  program.\nAlso,  the  appropriate  information for the %(msg), %(cur), %(unseen),\nand %(size) function escapes will be made available for  each  message.\nIf  the  -file  switch is given, the arguments are interpreted as file-\nnames instead of message numbers, but otherwise  the  behavior  is  the\nsame  (except  that  the %(msg), %(cur), and %(unseen) function escapes\nwill not provide any useful information).\n\nThe default format used in address mode is the default format  used  by\nscan.   The  following  command  can replicate the functionality of the\nrepl command.\n\nfmttest -nodupaddrs -form replcomps -outsize max [+folder] message\n\nRegardless of the mode, other components can be provided to the  format\nprogram by the use of the --component switch.  For example, the follow-\ning program will test the use of the \"encrypted\" component:\n\nfmttest --encrypted yes -message cur\n\nIn message mode, components supplied on the command line will  override\ncomponents from messages.\n\nAdditional Switches\nThe  -dupaddrs  and  -nodupaddrs switches control whether duplicate ad-\ndresses are allowed or suppressed by the FORMATADDR instruction,  which\nis  used  by  the `%(formataddr)' function escape.  In normal operation\nduplicate addresses are only suppressed by repl.\n\nThe -ccme and -noccme switches control whether  or  not  to  count  the\nuser's  local  mailbox as a duplicate address.  This replicates the be-\nhavior of the -cc me switch to repl, and only applies if -nodupaddrs is\nin effect.\n\nThe -outsize switch controls the maximum number of printable characters\nthat the format engine will produce.  Characters marked as non-printing\nby the format engine with `%(zputlit)', characters with zero width, and\nextra bytes that are part of a  multibyte  character  are  not  counted\nagainst  this  total.   Two  special values are supported: \"max\", which\nmeans as many characters as the format engine can produce  (limited  by\ninternal  buffers),  and \"width\", which will set the value to the width\nof the terminal.  In message mode it defaults to \"width\", otherwise the\ndefault is \"max\".\n\nThe  -width  switch  controls  the  column  width  which is used by the\n`%(width)' function escape.  It defaults to the terminal width.\n\nThe -msgnum, -msgcur, -msgsize, and the -unseen  switches  all  control\nthe  values  used,  respectively,  by  the  following function escapes:\n`%(num)', `%(cur)', `%(size)', and `%(unseen)'.  If none are  supplied,\nthese  values  are taken from the message in message mode; in all other\nmodes the default values are 0.\n\nCompiling and Tracing Format Programs\nThe -dump switch outputs the complete set of  format  instructions  for\nthe  specified format program.  The -trace switch will output each for-\nmat instruction as it is being executed, and show the values of the num\nand  str  registers if they have changed from the previous instruction.\nThe output buffer is also printed if it has changed from  the  previous\ninstruction.\n\nFormat Instructions\nIt  should  be  noted that there is not a one-to-one correspondence be-\ntween format escapes and format instructions;  many  instructions  have\nside effects.  Instructions prefixed with \"LV\" generally return a inte-\nger into the num (value) register; instructions prefixed  with  a  \"LS\"\nreturn a string into the str register.\n\nInstruction   Description\nCOMP          Output component\nCOMPF         Formatted output component\nLIT           Output literal text\nLITF          Formatted literal text output\nCHAR          Output single character\nNUM           Output the num register\nNUMF          Formatted output of the num register\nSTR           Output the str register\nSTRF          Formatted output of the str register\nSTRFW         Not used\nPUTADDR       Output address list in str register\nSTRLIT        Output str, no space compression\nSTRLITZ       Like STRLIT, but not counted against width\nLSCOMP       Write component to str register\nLSLIT        Write literal to str register\nLSGETENV     Write environment var to str register\nLSDECODECOMP Decode RFC 2047 encoded component to str register\nLSDECODE     Decode RFC 2047 encoded string to str register\nLSTRIM       Trim trailing whitespace from str register\nLVCOMP       Convert component to integer, store in num register\nLVCOMPFLAG   Set num to 1 if TRUE set in component\nLVLIT        Load literal value into num register\nLVDAT        Load value from dat array into num register (see note)\nLVSTRLEN     Set num to the length of str\nLVPLUSL     Add value to num register\nLVMINUSL    Subtract value from num register\nLVDIVIDEL   Divide num register by value\nLVMODULOL   num modulo value\nLVCHARLEFT  Store remaining number of printable chars in num\nLSMONTH      Write short name of month to str from date component\nLSLMONTH     Write long name of month to str from date component\nLSZONE       Write time zone offset to str from date component\nLSDAY        Write short name of day of week to str from date component\nLSWEEKDAY    Write long name of day of week to str from date component\nLS822DATE    Write RFC 822 compatible date to str from date component\nLSPRETTY     Write date with \"pretty\" timezone to str\nLVSEC        Write date component seconds to num\nLVMIN        Write date component minutes to num\nLVHOUR       Write date component hour to num\nLVMON        Write date component numeric month to num (start at 1)\nLVYEAR       Write date component year to num\nLVYDAY       Write date component Julian day to num\nLVWDAY       Write date component day of week to num (0 == Sunday)\nLVZONE       Write date component time zone offset to num\nLVCLOCK      Write date component in Unix epoch time to num\nLVRCLOCK     Write offset of date component from current time to num\nLVDAYF       Write 1 to num if day of week is explicit\nLVDST        Write 1 to num if DST is in effect for date component\nLVZONEF      Write 1 to num if timezone is explicit\nLSADDR       Write email address of addr component to str\nLSPERS       Write personal name of addr component to str\nLSMBOX       Write mailbox (username) of addr component to str\nLSHOST       Write host of addr component to str\nLSPATH       Write host route of addr component to str\nLSGNAME      Write group name of addr component to str\nLSNOTE       Write note portion of addr component to str\nLS822ADDR    Write \"proper\" RFC 822 version of addr component to str\nLSFRIENDLY   Write friendly (name or note) of address component to str\nLSUNQUOTE    Remove RFC 2822 quotes from string\nLVHOSTTYPE   Set num to type of host (0=local, 1=network)\nLVINGRPF     Set num to 1 if address was inside of group\nLVNOHOSTF    Set num to 1 of no host was present in address component\nLOCALDATE     Convert date component to local timezone\nGMTDATE       Convert date component to GMT\nPARSEDATE     Parse date component\nPARSEADDR     Parse address component\nFORMATADDR    Add address component to list in str\nCONCATADDR    Like FORMATADDR, but will not suppress duplicates\nMYMBOX        Set num if address component is a local address\nSAVESTR       Save str register temporarily\nDONE          End program\nNOP           No operation\nGOTO          Jump to new instruction\nIFSNULL     Branch if str is NULL\nIFS          Branch if str is not NULL\nIFVEQ       Branch if num is equal to value\nIFVNE       Branch if num is not equal to value\nIFVGT       Branch if num is greater than value\nIFMATCH      Branch if str contains string\nIFAMATCH     Branch if str starts with string\nSNULL        Set num to 1 if str is NULL\nSNONNULL     Set num to 1 if str is not NULL\nVEQ          Set num to 1 if num equals value\nVNE          Set num to 1 if num does not equal value\nVGT          Set num to 1 if num is greater than value\nVMATCH       Set num to 1 if str contains string\nVAMATCH      Set num to 1 if str starts with string\n\nThe LVDAT instruction is a bit special.  Callers of the format library\npass in an array of integers that are used by certain  format  escapes.\nThe current list of format escapes and the indexes they use are:\n\ndat[0]  %(num)\ndat[1]  %(cur)\ndat[2]  %(size)\ndat[3]  %(width)\ndat[4]  %(unseen)\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "mh-format(5), repl(1), ap(8), dp(8), fmtdump(8)\n",
                "subsections": []
            },
            "DEFAULTS": {
                "content": "`-message'\n`-nofile'\n`-dupaddrs'\n",
                "subsections": []
            },
            "BUGS": {
                "content": "It shouldn't require as much code from other programs as it does.\n\nnmh-1.7.1                         2014-08-31                      FMTTEST(1mh)",
                "subsections": []
            }
        }
    }
}