📄 mh-format.rf
字号:
.\" @(MHWARNING).\" @(#)$Id: mh-format.rf,v 1.1 90/07/20 09:41:11 sharpe Exp Locker: sharpe $.SC MH\-FORMAT 5.NAmh\-format \- format file for MH message system.SYsome \fIMH\fR commands.DESeveral \fIMH\fR commands utilize either a \fIformat\fR string or a\fIformat\fR file during their execution.For example,\fIscan\fR\0(1) uses a format string which directs it how to generate thescan listing for each message;\fIrepl\fR\0(1) uses a format file which directs it how to generate thereply to a message, and so on.Format strings are designed to be efficiently parsed by \fIMH\fR whichmeans they are not necessarily simple to write and understand.This means that novice, casual, or even advanced users of \fIMH\fR shouldnot have to deal with them.Some canned scan listing formats are in@(MHETCPATH)/scan.time, @(MHETCPATH)/scan.size, and @(MHETCPATH)/scan.timely.Look in @(MHETCPATH) for other \fIscan\fR and \fIrepl\fR format fileswhich may have been written at your site.It suffices to have your local \fIMH\fR expert actually write new formatcommands or modify existing ones.This manual section explains how to do that.Note: familiarity with the C \fIprintf\fR routine is assumed.A format string consists of ordinary text, and specialmulti\-character \fIescape\fR sequences which begin with `%'.When specifying a format string,the usual C backslash characters are honored:`\\b', `\\f', `\\n', `\\r', and `\\t'.Continuation lines in format files end with `\\' followedby the newline character..\" talk about syntax first, then semanticsThere are three types of \fIescape\fR sequences:header \fIcomponents\fR, built\-in \fIfunctions\fR, and, flow \fIcontrol\fR.A \fIcomponent\fR escape is specified as `%{\fIcomponent\fR\^}',and exists for each header found in the message being processed.For example `%{date}' refers to the \*(lqDate:\*(rq field of the appropriatemessage.All component escapes have a string value.Normally, component values are compressed byconverting any control characters (tab and newline included) to spaces,then eliding any leading or multiple spaces.However,commands may give different interpretations to some component escapes; be sure to refer to each command's manual entry for complete details.A \fIfunction\fR escape is specified as `%(\fIfunction\fR\^)'.All functions are built\-in, and most have a string or numeric value..ne 7A \fIcontrol\fR escape is one of: `%<', `%|', or `%>'.These form one of four conditional execution constructs with thefollowing syntax:.sp 1.nf %<(\fIfunction\fR\^)Command-String%> %<{\fIcomponent\fR\^}Command-String%> %<(\fIfunction\fR\^)Then-Command-String%|Else-Command-String%> %<{\fIcomponent\fR\^}Then-Command-String%|Else-Command-String%>.fi.spThese constructs may be nested without ambiguity.In the first two forms of the construct,if the function or component value is non\-zero (for integer\-valued escapes),or non\-empty (for string\-valued escapes),then everything up to the corresponding `%>'is interpreted, otherwise, skip to the corresponding '%>' andstart interpreting again.In the second two forms of the construct, the first command string is interpretedif the function or component value is non\-zero or non\-null,and the second command string is interpreted otherwise. Only oneof the command strings will be interpreted.Interpreting the '%|' control escape causes a skip to the corresponding '%>'. .ne 10Most functions expect an argument of a particular type:.sp 1.nf.ta +\w'Argument 'u +\w'An optional component, 'u\fIArgument\fR \fIDescription\fR \fIExample Syntax\fRliteral A literal number, %(\fIfunc\fR 1234) or string %(\fIfunc\fR text string)comp Any header component %(\fIfunc\fR\^{\fIin-reply-to\fR\^})date A date component %(\fIfunc\fR\^{\fIdate\fR\^})addr An address component %(\fIfunc\fR\^{\fIfrom\fR\^})expr An optional component, %(\fIfunc\fR\^(\fIfunc2\fR\^)) function or control, %(\fIfunc\fR %<{\fIreply-to\fR\^}%|%{\fIfrom\fR\^}%>) perhaps nested %(\fIfunc\fR\^(\fIfunc2\fR\^{\fIcomp\fR\^})).re.fiThe types \fIdate\fR and \fIaddr\fR have the same syntaxas \fIcomp\fR, but require that the header component be a date string, or address string, respectively.All arguments except those of type \fIexpr\fR are required.For the \fIexpr\fR argument type, the leading `%' must be omitted for component and function escape arguments,and must be present (with a leading space) for control escape arguments.The evaluation of format stringsis based on a simple machine with aninteger register \fInum\fR, and a text string register \fIstr\fR.When a function escape is processed,if it accepts an optional \fIexpr\fR argument which is not present, it reads the current value of either \fInum\fR or \fIstr\fR as appropriate..\" return valuesComponent escapes write the value of their message header in \fIstr\fR.Function escapes write their return value in\fInum\fR for functions returning \fIinteger\fR or \fIboolean\fR values,and in \fIstr\fR for functions returning string values.(The \fIboolean\fR type is a subset of integers with usualvalues 0=false and 1=true.)All component escapes, and thosefunction escapes which return an \fIinteger\fR or \fIstring\fR value,pass this value back to their callerin addition to setting \fIstr\fR or \fInum\fR.These escapes will print out this valueunless called as part of an argument to another escape sequence.Function escapes which return a \fIboolean\fR value do pass this valueback to their caller, but will never print out the value..nf.ta \w'Formataddr 'u +\w'Argument 'u +\w'Rboolean 'u\fIFunction\fR \fIArgument\fR \fIReturn\fR \fIDescription\fRmsg integer message numbercur integer message is currentsize integer size of messagestrlen integer length of \fIstr\fRwidth integer output buffer size in bytescharleft integer bytes left in output buffertimenow integer seconds since the UNIX epochme string the user's mailboxeq literal boolean \fInum\fR == \fIarg\fRne literal boolean \fInum\fR != \fIarg\fRgt literal boolean \fInum\fR > \fIarg\fRmatch literal boolean \fIstr\fR contains \fIarg\fRamatch literal boolean \fIstr\fR starts with \fIarg\fRplus literal integer \fIarg\fR plus \fInum\fRminus literal integer \fIarg\fR minus \fInum\fRdivide literal integer \fInum\fR divided by \fIarg\fRnum literal integer Set \fInum\fR to \fIarg\fRlit literal string Set \fIstr\fR to \fIarg\fR.\" dat literal int ?nonzero expr boolean \fInum\fR is non\-zerozero expr boolean \fInum\fR is zeronull expr boolean \fIstr\fR is emptynonnull expr boolean \fIstr\fR is non\-emptyvoid expr Set \fIstr\fR or \fInum\fRcomp comp string Set \fIstr\fR to component textcompval comp integer \fInum\fR set to \*(lq\fBatoi\fR(\fIstr\fR\^)\*(rq.\" compflag comp integer Set \fInum\fR to component flags bitstrim expr trim trailing white\-space from \fIstr\fRputstr expr print \fIstr\fRputstrf expr print \fIstr\fR in a fixed widthputnum expr print \fInum\fRputnumf expr print \fInum\fR in a fixed width.re .fiThese functions require a date component as an argument:.sp 1.nf.ta \w'Formataddr 'u +\w'Argument 'u +\w'Rboolean 'u\fIFunction\fR \fIArgument\fR \fIReturn\fR \fIDescription\fRsec date integer seconds of the minutemin date integer minutes of the hourhour date integer hours of the day (0-23)wday date integer day of the week (Sun=0)day date string day of the week (abbrev.)weekday date string day of the weeksday date integer day of the week known? (0=implicit,\-1=unknown)mday date integer day of the monthyday date integer day of the yearmon date integer month of the yearmonth date string month of the year (abbrev.)lmonth date string month of the yearyear date integer year of the centuryzone date integer timezone in hourstzone date string timezone stringszone date integer timezone explicit? (0=implicit,\-1=unknown)date2local date coerce date to local timezonedate2gmt date coerce date to GMTdst date integer daylight savings in effect?clock date integer seconds since the UNIX epochrclock date integer seconds prior to current timetws date string official 822 renderingpretty date string user\-friendly renderingnodate date integer \fIstr\fR not a date string.re .fi.ne 12These functions require an address component as an argument. The return value of functions noted with `*' pertain only tothe first address present in the header component..sp 1.nf.ta \w'Formataddr 'u +\w'Argument 'u +\w'Rboolean 'u\fIFunction\fR \fIArgument\fR \fIReturn\fR \fIDescription\fRproper addr string official 822 renderingfriendly addr string user\-friendly renderingpers addr string the personal name*note addr string commentary text*mbox addr string the local mailbox*mymbox addr integer the user's addresses? (0=no,1=yes)host addr string the host domain*nohost addr integer no host was present*type addr integer host type* (0=local,1=network, \-1=uucp,2=unknown)path addr string any leading host route*ingrp addr integer address was inside a group*gname addr string name of group*formataddr expr append \fIarg\fR to \fIstr\fR as a (comma separated) address list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -