1 .TH FMTTEST %manext1% "February 19, 2013" "%nmhversion%"
6 fmttest \- test tool for the
17 .RB [ \-address " | " \-raw " | " \-date " | " \-message ]
20 .RB [ \-dupaddrs " | " \-nodupaddrs ]
21 .RB [ \-ccme " | " \-noccme ]
22 .RB [ \-normalize " | " \-nonormalize ]
24 .IR size-in-characters ]
37 .RB [ \-dump " | " \-nodump ]
38 .RB [ \-trace " | " \-notrace ]
40 .RI [ msgs " | " strings ]
44 is used to test programs written for the
46 format language as specified by
48 It is also intended to replace the
55 .SS FORMAT PROGRAM SELECTION
62 switches may be used to specify a format string or a format file to read.
63 If given a format string, it must be specified as a single argument to
66 switch. If given a format file name with
68 the file is searched for using the normal
70 rules: absolute pathnames are accessed directly, tilde expansion is
71 done on usernames, and files are searched for in the user's
73 directory as specified in their profile. If not found there, the directory
74 .RI \*(lq %etcdir% \*(rq
76 .SS MODE SELECTION AND COMPONENT SPECIFICATION
78 has four operating modes: address mode, raw mode, date mode, and message
79 mode. These modes are selected by the
85 switches respectively.
87 Address mode treats every argument as an email address and processes it
88 with nmh's email parser. Each argument is processed with the specified
89 format program with the parsed email address available as a special
91 component escape, and the output from the program is printed on standard output.
92 If there was an error parsing the email address the error message is
95 component escape. If no format program is given on the command line, the
96 following default program is used:
100 %<{error}%{error}: %{text}%|%(putstr(proper{text}))%>
109 In raw mode, no processing of the specified arguments is done. Each argument
110 is run against the specified format program with the argument text available
113 component. You must specify a format with
119 Date mode is identical to raw mode, with one exception: if no format is
120 specified, the following format string is used:
124 %<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>
128 Date mode is equivalent to
131 In message mode the arguments to
133 are interpreted as an optional folder and messages.
135 will read each specified message and make all of the components in the
136 message available to the format program. Also, the appropriate information
143 function escapes will be made available for each message.
145 The default format used in address mode is the default format used by
147 The following command can replicate the functionality of the
153 fmttest \-nodupaddrs \-form replcomps \-outsize max [+folder] message
157 Regardless of the mode, other components can be provided to the format
158 program by the use of the
160 switch. For example, the following program will test out the use of
162 .RB \*(lq encrypted \*(rq
167 fmttest \-\|\-encrypted yes \-message cur
171 In message mode components supplied on the command line will override
172 components from messages.
173 .SS ADDITIONAL SWITCHES
178 switches control whether duplicate addresses are allowed or suppressed by the
180 instruction, which is used by the
181 .RI `%( formataddr )'
182 function escape. In normal operation duplicate addresses are only
190 switches control whether or not to count the user's local mailbox as a
191 duplicate address. This replicates the behavior of the
204 switches control whether or not email addresses are normalized by the
205 address parsing routines. This is only functional when in address
206 mode and is designed to replicate the switch of the same name to
211 switch controls the maximum number of printable characters that the format
212 engine will produce. Characters marked as non-printing by the format
215 characters with zero width, and extra bytes that are
216 part of a multibyte character are not counted against this total.
217 Two special values are supported:
219 which will set the value
220 to the size of the output buffer, and
221 .RI \*(lq width \*(rq,
223 value to the width of the terminal. In message mode it defaults to the
224 terminal width, otherwise the default is the output buffer size.
228 switch controls the size of the output buffer. By default it is set
231 C preprocessor symbol, which is system-dependent.
235 switch controls the column width which is used by the
237 function escape. By default is set to the terminal width.
245 switches all control the values used, respectively, by the following
252 If none are supplied these values are taken from the message in message mode;
253 in all other modes the default values are 0.
254 .SS COMPILING AND TRACING FORMAT PROGRAMS
257 switch outputs the complete set of format instructions for the specified
260 switch will output each format instruction as it is being
261 executed, and show the values of the
265 registers if they have changed from the previous instruction.
266 The output buffer is also printed if it has changed from the previous
268 .SS FORMAT INSTRUCTIONS
269 It should be noted that there is not a one-to-one correspondence between
270 format escapes and format instructions; many instructions have side
271 effects. Instructions prefixed with
273 generally return a integer into the
275 (value) register; instructions prefixed with a
277 return a string into the
282 .ta \w'LS_DECODECOMP 'u
283 .I "Instruction Description"
284 COMP Output component
285 COMPF Formatted output component
286 LIT Output literal text
287 LITF Formatted literal text output
288 CHAR Output single character
289 NUM Output the \fInum\fR register
290 NUMF Formatted output of the \fInum\fR register
291 STR Output the \fIstr\fR register
292 STRF Formatted output of the \fIstr\fR register
294 PUTADDR Output address list in \fIstr\fR register
295 STRLIT Output \fIstr\fR, no space compression
296 STRLITZ Like \fBSTRLIT\fR, but not counted against width
297 LS_COMP Write component to \fIstr\fR register
298 LS_LIT Write literal to \fIstr\fR register
299 LS_GETENV Write environment var to \fIstr\fR register
300 LS_DECODECOMP Decode RFC-2047 encoded component to \fIstr\fR register
301 LS_DECODE Decode RFC-2047 encoded string to \fIstr\fR register
302 LS_TRIM Trim trailing whitespace from \fIstr\fR register
303 LV_COMP Convert component to integer, store in \fInum\fR register
304 LV_COMPFLAG Set \fInum\fR to 1 if \fBTRUE\fR set in component
305 LV_LIT Load literal value into \fInum\fR register
306 LV_DAT Load value from \fIdat\fR array into \fInum\fR register (see note)
307 LV_STRLEN Set \fInum\fR to the length of \fIstr\fR
308 LV_PLUS_L Add value to \fInum\fR register
309 LV_MINUS_L Substract value from \fInum\fR register
310 LV_DIVIDE_L Divide \fInum\fR register by value
311 LV_MODULO_L \fInum\fR modulo value
312 LV_CHAR_LEFT Store remaining number of printable chars in \fInum\fR
313 LS_MONTH Write short name of month to \fIstr\fR from date component
314 LS_LMONTH Write long name of month to \fIstr\fR from date component
315 LS_ZONE Write time zone offset to \fIstr\fR from date component
316 LS_DAY Write short name of day of week to \fIstr\fR from date component
317 LS_WEEKDAY Write long name of day of week to \fIstr\fR from date component
318 LS_822DATE Write RFC-822 compatible date to \fIstr\fR from date component
319 LS_PRETTY Write date with \*(lqpretty\*(rq timezone to \fIstr\fR
320 LV_SEC Write date component seconds to \fInum\fR
321 LV_MIN Write date component minutes to \fInum\fR
322 LV_HOUR Write date component hour to \fInum\fR
323 LV_MON Write date component numeric month to \fInum\fR (start at 1)
324 LV_YEAR Write date component year to \fInum\fR
325 LV_YDAY Write date component Julian day to \fInum\fR
326 LV_WDAY Write date component day of week to \fInum\fR (0 == Sunday)
327 LV_ZONE Write date component time zone offset to \fInum\fR
328 LV_CLOCK Write date component in Unix epoch time to \fInum\fR
329 LV_RCLOCK Write offset of date component from current time to \fInum\fR
330 LV_DAYF Write 1 to \fInum\fR if day of week is explicit
331 LV_DST Write 1 to \fInum\fR if DST is in effect for date component
332 LV_ZONEF Write 1 to \fInum\fR if timezone is explicit
333 LS_ADDR Write email address of addr component to \fIstr\fR
334 LS_PERS Write personal name of addr component to \fIstr\fR
335 LS_MBOX Write mailbox (username) of addr component to \fIstr\fR
336 LS_HOST Write host of addr component to \fIstr\fR
337 LS_PATH Write host route of addr component to \fIstr\fR
338 LS_GNAME Write group name of addr component to \fIstr\fR
339 LS_NOTE Write note portion of addr component to \fIstr\fR
340 LS_822ADDR Write \*(lqproper\*(rq RFC-822 version of addr component to \fIstr\fR
341 LS_FRIENDLY Write friendly (name or note) of address component to \fIstr\fR
342 LS_UNQUOTE Remove RFC-2822 quotes from string
343 LV_HOSTTYPE Set \fInum\fR to type of host (0=local, 1=network)
344 LV_INGRPF Set \fInum\fR to 1 if address was inside of group
345 LV_NOHOSTF Set \fInum\fR to 1 of no host was present in address component
346 LOCALDATE Convert date component to local timezone
347 GMTDATE Convert date component to GMT
348 PARSEDATE Parse date component
349 PARSEADDR Parse address component
350 FORMATADDR Add address component to list in \fIstr\fR
351 CONCATADDR Like \fBFORMATADDR\fR, but will not suppress duplicates
352 MYMBOX Set \fInum\fR if address component is a local address
353 SAVESTR Save \fIstr\fR register temporarily
356 GOTO Jump to new instruction
357 IF_S_NULL Branch if \fIstr\fR is \fBNULL\fR
358 IF_S Branch if \fIstr\fR is not \fBNULL\fR
359 IF_V_EQ Branch if \fInum\fR is equal to value
360 IF_V_NE Branch if \fInum\fR is not equal to value
361 IF_V_GT Branch if \fInum\fR is greater than value
362 IF_MATCH Branch if \fIstr\fR contains string
363 IF_AMATCH Branch if \fIstr\fR starts with string
364 S_NULL Set \fInum\fR to 1 if \fIstr\fR is \fBNULL\fR
365 S_NONNULL Set \fInum\fR to 1 if \fIstr\fR is not \fBNULL\fR
366 V_EQ Set \fInum\fR to 1 if \fInum\fR equals value
367 V_NE Set \fInum\fR to 1 if \fInum\fR does not equal value
368 V_GT Set \fInum\fR to 1 if \fInum\fR is greater than value
369 V_MATCH Set \fInum\fR to 1 if \fIstr\fR contains string
370 V_AMATCH Set \fInum\fR to 1 if \fIstr\fR starts with string
375 instruction is a bit special. Callers of the format library pass in an
376 array of integers that are used by certain format escapes. The current
377 list of format escapes and the indexes they use are:
385 dat[3] %(\fIwidth\fR)
386 dat[4] %(\fIunseen\fR)
400 It shouldn't require as much code from other programs as it does.