📄 mh-format.rf
字号:
.\" @(MHWARNING).\" @(#)$Id: mh-format.rf,v 1.45 1993/08/19 20:26:17 jromine Exp $.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 12.Uh "Control-flow escapes"A \fIcontrol\fR escape is one of: `%<', `%?', `%|', or `%>'. These are combined into the conditional execution construct:.sp.nf %<condition \fIformat text 1\fP %?condition2 \fIformat text 2\fP %?condition3 \fIformat text 3\fP \.\.\. %| \fIformat text N\fP %>.fi.spExtra white space is shown here only for clarity.These constructs may be nested without ambiguity.They form a general \fBif\-elseif\-else\-endif\fP block whereonly one of the \fIformat text\fP segments is interpreted.The `%<' and `%?' control escapes causes a condition to be evaluated. This conditionmay be either a \fIcomponent\fP or a \fIfunction\fP.The four constructs have the following syntax:.sp 1.nf %<{component} %<(function) %?{component} %?(function).fi.spThese control escapes test whetherthe function or component value is non-zero (for integer-valued escapes),or non-empty (for string-valued escapes).If this test evaulates true,then the format textup to the next corresponding control escape (one of `%|', `%?', or `%>')is interpreted normally.Next,all format text (if any) up to the corresponding `%>' controlescape is skipped.The `%>' control escape is not interpreted;normalinterpretation resumes after the `%>' escape.If the test evaluates false, however,then the format text up to the next corresponding control escape(again, one of `%|', `%?', or `%>')is skipped, instead of being interpreted.If the control escape encountered was `%?',then the condition associated with that control escape isevaluated, and interpretationproceeds after that testas described in the previous paragraph.If the control escape encountered was `%|',then the format textup to the corresponding `%>' escapeis interpreted normally.As above, the `%>' escape is not interpreted and normalinterpretation resumes after the `%>' escape.The `%?' control escape and its following format textis optional, and may be included zero or more times.The `%|' control escape and its following format textis also optional, and may be included zero or one times..Uh "Function escapes".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 values.Uh "Return values"Component 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.)Control escapes return a \fIboolean\fP value, and set \fInum\fP.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.Escapes which return a \fIboolean\fR value do pass this valueback to their caller in \fInum\fP, 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 current.\" unseen integer message is unseensize 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\fRmodulo literal integer \fInum\fR modulo \fIarg\fRnum literal integer Set \fInum\fR to \fIarg\fRlit literal string Set \fIstr\fR to \fIarg\fRgetenv literal string Set \fIstr\fR to environment value of \fIarg\fRprofile literal string Set \fIstr\fR to profile component \fIarg\fR value.\" dat literal int return value of dat[arg]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(\fIcomp\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.\" addtoseq literal add msg to sequence (LBL option).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 (may be > 100)zone 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -