.\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) .\" Distributed under GPL .\" adapted glibc info page .\" .\" This should run as 'Guru Meditation' (amiga joke :) .\" The function is quite complex and deserves an example .\" .\" Polished, aeb, 2003-11-01 .\" .\" Japanese Version Copyright (c) 2004 Yuichi SATO .\" all rights reserved. .\" Translated Sat Jul 24 20:19:54 JST 2004 .\" by Yuichi SATO .\" .TH FMTMSG 3 2008-06-14 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O fmtmsg \- print formatted error messages fmtmsg \- 整形されたエラーメッセージを表示する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "int fmtmsg(long " classification ", const char *" label , .br .BI " int " severity ", const char *" text , .br .BI " const char *" action ", const char *" tag ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O This function displays a message described by its arguments on the device(s) .\"O specified in the .\"O .I classification .\"O argument. .\"O For messages written to .\"O .IR stderr , .\"O the format depends on the .\"O .B MSGVERB .\"O environment variable. この関数は、引き数で記述されたメッセージを、 .I classification 引き数で指定されたデバイス上に表示する。 .I stderr に書き出されるメッセージのフォーマットは、 .B MSGVERB 環境変数に依存する。 .LP .\"O The .\"O .I label .\"O argument identifies the source of the message. .\"O The string must consist .\"O of two colon separated parts where the first part has not more .\"O than 10 and the second part not more than 14 characters. .I label 引き数はメッセージの発生源を識別する。 この文字列はコロンで区切られた 2 つの部分から構成されていなければならない。 1 つ目の部分は 10 文字以内でなければならず、 2 つ目の部分は 14 文字以内でなければならない。 .LP .\"O The .\"O .I text .\"O argument describes the condition of the error. .I text 引き数にはエラー条件を記述する。 .LP .\"O The .\"O .I action .\"O argument describes possible steps to recover from the error. .\"O If it is printed, it is prefixed by "TO FIX: ". .I action 引き数にはエラーから回復するために利用可能なステップを記述する。 これが表示される場合、"TO FIX: " が前に付く。 .LP .\"O The .\"O .I tag .\"O argument is a reference to the online documentation where more .\"O information can be found. .\"O It should contain the .\"O .I label .\"O value and a unique identification number. .I tag 引き数はより多くの情報を見つけるためのオンラインドキュメントへの参照である。 これは .I label 値とユニークな識別番号を含んでいるべきである。 .\"O .SS "Dummy arguments" .SS ダミー引き数 .\"O Each of the arguments can have a dummy value. .\"O The dummy classification value .\"O .B MM_NULLMC .\"O (0L) does not specify any output, so nothing is printed. 各引き数にはダミーの値を入れることができる。 ダミーの .I classification 値 .B MM_NULLMC (0L) は出力を何も指定しない。そのため何も表示されない。 .\"O The dummy severity value .\"O .B NO_SEV .\"O (0) says that no severity is supplied. ダミーの .I severity 値 .B NO_SEV (0) は重大度 (severity) が与えられていないことを表す。 .\"O The values .\"O .BR MM_NULLLBL , .\"O .BR MM_NULLTXT , .\"O .BR MM_NULLACT , .\"O .B MM_NULLTAG .\"O are synonyms for .\"O .IR "((char *) 0)" , .\"O the empty string, and .\"O .B MM_NULLSEV .\"O is a synonym for .\"O .BR NO_SEV . 値 .BR MM_NULLLBL , .BR MM_NULLTXT , .BR MM_NULLACT , .B MM_NULLTAG は .I "((char *) 0)" と空文字列の別名であり、 .B MM_NULLSEV は .B NO_SEV の別名である。 .\"O .SS "The classification argument" .SS "classification 引き数" .\"O The .\"O .I classification .\"O argument is the sum of values describing 4 types of information. .I classification 引き数は 4 種類の情報を記述する値の和である。 .br .sp .\"O The first value defines the output channel. 最初の値は出力チャンネルを定義する。 .TP 12n .B MM_PRINT .\"O Output to .\"O .IR stderr . .I stderr に出力する。 .TP .B MM_CONSOLE .\"O Output to the system console. システムコンソールに出力する。 .TP .B "MM_PRINT | MM_CONSOLE" .\"O Output to both. 両方に出力する。 .PP .\"O The second value is the source of the error: 2 番目の値はエラーの発生源である: .TP 12n .B MM_HARD .\"O A hardware error occurred. ハードウェアエラーが起こった。 .TP .B MM_FIRM .\"O A firmware error occurred. ファームウェアエラーが起こった。 .TP .B MM_SOFT .\"O A software error occurred. ソフトウェアエラーが起こった。 .PP .\"O The third value encodes the detector of the problem: 3 番目の値は問題の検知を行ったものをエンコードする: .TP 12n .B MM_APPL .\"O It is detected by an application. アプリケーションによって検知された。 .TP .B MM_UTIL .\"O It is detected by a utility. ユーティリティによって検知された。 .TP .B MM_OPSYS .\"O It is detected by the operating system. オペレーティングシステムによって検知された。 .PP .\"O The fourth value shows the severity of the incident: 4 番目の値は問題の重大度を表す: .TP 12n .B MM_RECOVER .\"O It is a recoverable error. 回復可能なエラーである。 .TP .B MM_NRECOV .\"O It is a nonrecoverable error. 回復不可能なエラーである。 .\"O .SS "The severity argument" .SS "severity 引き数" .\"O The .\"O .I severity .\"O argument can take one of the following values: .I severity 引き数は以下の 1 つの値をとることができる。 .TP 12n .B MM_NOSEV .\"O No severity is printed. 重大度は表示されない。 .TP .B MM_HALT .\"O This value is printed as HALT. この値は HALT として表示される。 .TP .B MM_ERROR .\"O This value is printed as ERROR. この値は ERROR として表示される。 .TP .B MM_WARNING .\"O This value is printed as WARNING. この値は WARNING として表示される。 .TP .B MM_INFO .\"O This value is printed as INFO. この値は INFO として表示される。 .PP .\"O The numeric values are between 0 and 4. .\"O Using .\"O .BR addseverity (3) .\"O or the environment variable .\"O .B SEV_LEVEL .\"O you can add more levels and strings to print. 数値の場合は 0 から 4 である。 .BR addseverity (3) または環境変数 .B SEV_LEVEL を使うことにより、表示するレベルと文字列を更に追加できる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The function can return 4 values: 関数は 4 つの値を返す: .TP 12n .B MM_OK .\"O Everything went smooth. 全てがうまくいった。 .TP .B MM_NOTOK .\"O Complete failure. 完全に失敗した。 .TP .B MM_NOMSG .\"O Error writing to .\"O .IR stderr . .I stderr に書き込むときにエラーが起こった。 .TP .B MM_NOCON .\"O Error writing to the console. コンソールに書き込むときにエラーが起こった。 .\"O .SH ENVIRONMENT .SH 環境変数 .\"O The environment variable .\"O .B MSGVERB .\"O ("message verbosity") can be used to suppress parts of .\"O the output to .\"O .IR stderr . 環境変数 .B MSGVERB ("message verbosity") は .I stderr への出力の一部を抑制するのに使うことができる。 .\"O (It does not influence output to the console.) (コンソールへの出力には影響しない。) .\"O When this variable is defined, is non-NULL, and is a colon-separated .\"O list of valid keywords, then only the parts of the message corresponding .\"O to these keywords is printed. この変数が定義されて、NULL でなく、 コロンで区切られた有効なキーワードのリストである場合、 キーワードに対応するメッセージの一部のみが表示される。 .\"O Valid keywords are "label", "severity", "text", "action" and "tag". 有効なキーワードは "label", "severity", "text", "action", "tag" である。 .PP .\"O The environment variable .\"O .B SEV_LEVEL .\"O can be used to introduce new severity levels. 環境変数 .B SEV_LEVEL は新しい重大度レベルを導入するのに使用できる。 .\"O By default, only the five severity levels described .\"O above are available. .\"O Any other numeric value would make .\"O .BR fmtmsg () .\"O print nothing. デフォルトでは、上記の 5 つの重大度レベルのみが利用可能である。 他の数値の場合、 .BR fmtmsg () は何も表示しない。 .\"O If the user puts .\"O .B SEV_LEVEL .\"O with a format like .\"O .sp .\"O .RS .\"O SEV_LEVEL=[description[:description[:...]]] .\"O .RE .\"O .sp .\"O in the environment of the process before the first call to .\"O .BR fmtmsg (), .\"O where each description is of the form .\"O .sp .\"O .RS .\"O severity-keyword,level,printstring .\"O .RE .\"O .sp .\"O then .\"O .BR fmtmsg () .\"O will also accept the indicated values for the level (in addition to .\"O the standard levels 0-4), and use the indicated printstring when .\"O such a level occurs. .BR fmtmsg () を初めて呼び出す前に、ユーザが .B SEV_LEVEL を .sp .RS SEV_LEVEL=[description[:description[:...]]] .RE .sp のような形式でプロセスの環境に設定すると、 .BR fmtmsg () は (標準のレベル 0-4 に加えて) level に指定された値も受け付け、 そのようなレベルの問題が発生すると指定された printstring を表示する。 各 description は .sp .RS severity-keyword,level,printstring .RE .sp という形式である。 .LP .\"O The severity-keyword part is not used by .\"O .BR fmtmsg () .\"O but it has to be present. severity-keyword 部は .BR fmtmsg () に使用されないが、存在しなければならない。 .\"O The level part is a string representation of a number. level 部は数値を文字列で表したものである。 .\"O The numeric value must be a number greater than 4. 数値は 4 より大きい値でなければならない。 .\"O This value must be used in the severity argument of .\"O .BR fmtmsg () .\"O to select this class. .\"O It is not possible to overwrite .\"O any of the predefined classes. .\"O The printstring .\"O is the string printed when a message of this class is processed by .\"O .BR fmtmsg (). この値は .BR fmtmsg () の severity 引き数で使用されなければならず、この重大度を選択する。 前もって宣言された重大度を上書きすることはできない。 printstring は、 この重大度のメッセージが .BR fmtmsg () によって生成された場合に表示される文字列である。 .\"O .SH VERSIONS .SH バージョン .\"O .BR fmtmsg () .\"O is provided in glibc since version 2.1. .BR fmtmsg () は、バージョン 2.1 以降の glibc で提供されている。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O The functions .\"O .BR fmtmsg () .\"O and .\"O .BR addseverity (3), .\"O and environment variables .\"O .B MSGVERB .\"O and .\"O .B SEV_LEVEL .\"O come from System V. 関数 .BR fmtmsg () と .BR addseverity (3) と環境変数 .B MSGVERB と .B SEV_LEVEL は System V に由来している。 .\"O The function .\"O .BR fmtmsg () .\"O and the environment variable .\"O .B MSGVERB .\"O are described in POSIX.1-2001. 関数 .BR fmtmsg () と環境変数 .B MSGVERB は POSIX.1-2001 に記述されている。 .\"O .SH NOTES .SH 注意 .\"O System V and UnixWare man pages tell us that these functions .\"O have been replaced by "pfmt() and addsev()" or by "pfmt(), .\"O vpfmt(), lfmt(), and vlfmt()", and will be removed later. System V と UnixWare の man ページには、 「これらの関数は "pfmt() と addsev()" または "pfmt(), vpfmt(), lfmt(), vlfmt()" で置き換えられており、 将来は削除される予定である」と書かれている。 .\"O .SH EXAMPLE .SH 例 .nf #include #include #include int main(void) { long class = MM_PRINT | MM_SOFT | MM_OPSYS | MM_RECOVER; int err; err = fmtmsg(class, "util\-linux:mount", MM_ERROR, "unknown mount option", "See mount(8).", "util\-linux:mount:017"); switch (err) { case MM_OK: break; case MM_NOTOK: printf("Nothing printed\en"); break; case MM_NOMSG: printf("Nothing printed to stderr\en"); break; case MM_NOCON: printf("No console output\en"); break; default: printf("Unknown error from fmtmsg()\en"); } exit(EXIT_SUCCESS); } .fi .PP .\"O The output should be: 出力は .nf util\-linux:mount: ERROR: unknown mount option TO FIX: See mount(8). util\-linux:mount:017 .fi .\"O and after のようになり、 .nf MSGVERB=text:action; export MSGVERB .fi .\"O the output becomes: を実行した後では .nf unknown mount option TO FIX: See mount(8). .fi となる。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR addseverity (3), .BR perror (3)