X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Ffiles.c;h=cbda30f401ee6f74eee227f680e7e27904daf175;hb=1836893b03f0c01746b0cebebd00019c6c663270;hp=ee77623b70602193b21060ca280b46607f5c81b7;hpb=647fe5deed700a0a90b25564bb20839bdf24314c;p=hengband%2Fhengband.git diff --git a/src/files.c b/src/files.c index ee77623b7..cbda30f40 100644 --- a/src/files.c +++ b/src/files.c @@ -1,14 +1,17 @@ -/* File: files.c */ - -/* +/*! + * @file files.c + * @brief ファイル入出力管理 / Purpose: code dealing with files (and death) + * @date 2014/01/28 + * @author + *
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
  * This software may be copied and distributed for educational, research,
  * and not for profit purposes provided that this copyright and statement
  * are included in all such copies.  Other copyrights may also apply.
+ * 2014 Deskull rearranged comment for Doxygen.\n
+ * 
*/ -/* Purpose: code dealing with files (and death) */ #include "angband.h" @@ -19,8 +22,8 @@ /* #undef _POSIX_SAVED_IDS */ -/* - * Hack -- drop permissions +/*! + * @brief ファイルのドロップパーミッションチェック / Hack -- drop permissions */ void safe_setuid_drop(void) { @@ -33,42 +36,22 @@ void safe_setuid_drop(void) if (setuid(getuid()) != 0) { -#ifdef JP -quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setuid(): cannot set permissions correctly!"); -#endif - + quit(_("setuid(): 正しく許可が取れません!", "setuid(): cannot set permissions correctly!")); } if (setgid(getgid()) != 0) { -#ifdef JP -quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setgid(): cannot set permissions correctly!"); -#endif - + quit(_("setgid(): 正しく許可が取れません!", "setgid(): cannot set permissions correctly!")); } # else if (setreuid(geteuid(), getuid()) != 0) { -#ifdef JP -quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setreuid(): cannot set permissions correctly!"); -#endif - + quit(_("setreuid(): 正しく許可が取れません!", "setreuid(): cannot set permissions correctly!")); } if (setregid(getegid(), getgid()) != 0) { -#ifdef JP -quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setregid(): cannot set permissions correctly!"); -#endif - + quit(_("setregid(): 正しく許可が取れません!", "setregid(): cannot set permissions correctly!")); } # endif @@ -80,8 +63,8 @@ quit("setregid(): } -/* - * Hack -- grab permissions +/*! + * @brief ファイルのグラブパーミッションチェック / Hack -- grab permissions */ void safe_setuid_grab(void) { @@ -94,42 +77,22 @@ void safe_setuid_grab(void) if (setuid(player_euid) != 0) { -#ifdef JP -quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setuid(): cannot set permissions correctly!"); -#endif - + quit(_("setuid(): 正しく許可が取れません!", "setuid(): cannot set permissions correctly!")); } if (setgid(player_egid) != 0) { -#ifdef JP -quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setgid(): cannot set permissions correctly!"); -#endif - + quit(_("setgid(): 正しく許可が取れません!", "setgid(): cannot set permissions correctly!")); } # else if (setreuid(geteuid(), getuid()) != 0) { -#ifdef JP -quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setreuid(): cannot set permissions correctly!"); -#endif - + quit(_("setreuid(): 正しく許可が取れません!", "setreuid(): cannot set permissions correctly!")); } if (setregid(getegid(), getgid()) != 0) { -#ifdef JP -quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª"); -#else - quit("setregid(): cannot set permissions correctly!"); -#endif - + quit(_("setregid(): 正しく許可が取れません!", "setregid(): cannot set permissions correctly!")); } # endif /* SAFE_SETUID_POSIX */ @@ -141,25 +104,27 @@ quit("setregid(): } -/* - * Extract the first few "tokens" from a buffer - * +/*! + * @brief 各種データテキストをトークン単位に分解する / Extract the first few "tokens" from a buffer + * @param buf データテキストの参照ポインタ + * @param num トークンの数 + * @param tokens トークンを保管する文字列参照ポインタ配列 + * @param mode オプション + * @return 解釈した文字列数 + * @details + *
  * This function uses "colon" and "slash" as the delimeter characters.
- *
  * We never extract more than "num" tokens.  The "last" token may include
  * "delimeter" characters, allowing the buffer to include a "string" token.
- *
  * We save pointers to the tokens in "tokens", and return the number found.
- *
  * Hack -- Attempt to handle the 'c' character formalism
- *
  * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
- *
  * Hack -- We will always extract at least one token
+ * 
*/ -s16b tokenize(char *buf, s16b num, char **tokens, int mode) +s16b tokenize(char *buf, s16b num, char **tokens, BIT_FLAGS mode) { - int i = 0; + s16b i = 0; char *s = buf; @@ -237,27 +202,27 @@ static named_num gf_desc[] = {"GF_ACID", GF_ACID }, {"GF_COLD", GF_COLD }, {"GF_FIRE", GF_FIRE }, - {"GF_PSY_SPEAR", GF_PSY_SPEAR }, + {"GF_PSY_SPEAR", GF_PSY_SPEAR }, {"GF_MISSILE", GF_MISSILE }, - {"GF_ARROW", GF_ARROW }, + {"GF_ARROW", GF_ARROW }, {"GF_PLASMA", GF_PLASMA }, - {"GF_WATER", GF_WATER }, + {"GF_WATER", GF_WATER }, {"GF_LITE", GF_LITE }, {"GF_DARK", GF_DARK }, {"GF_LITE_WEAK", GF_LITE_WEAK }, {"GF_DARK_WEAK", GF_DARK_WEAK }, {"GF_SHARDS", GF_SHARDS }, - {"GF_SOUND", GF_SOUND }, + {"GF_SOUND", GF_SOUND }, {"GF_CONFUSION", GF_CONFUSION }, - {"GF_FORCE", GF_FORCE }, - {"GF_INERTIA", GF_INERTIA }, + {"GF_FORCE", GF_FORCE }, + {"GF_INERTIA", GF_INERTIAL }, {"GF_MANA", GF_MANA }, {"GF_METEOR", GF_METEOR }, {"GF_ICE", GF_ICE }, - {"GF_CHAOS", GF_CHAOS }, + {"GF_CHAOS", GF_CHAOS }, {"GF_NETHER", GF_NETHER }, {"GF_DISENCHANT", GF_DISENCHANT }, - {"GF_NEXUS", GF_NEXUS }, + {"GF_NEXUS", GF_NEXUS }, {"GF_TIME", GF_TIME }, {"GF_GRAVITY", GF_GRAVITY }, {"GF_KILL_WALL", GF_KILL_WALL }, @@ -268,24 +233,24 @@ static named_num gf_desc[] = {"GF_MAKE_TRAP", GF_MAKE_TRAP }, {"GF_MAKE_TREE", GF_MAKE_TREE }, {"GF_OLD_CLONE", GF_OLD_CLONE }, - {"GF_OLD_POLY", GF_OLD_POLY }, - {"GF_OLD_HEAL", GF_OLD_HEAL }, + {"GF_OLD_POLY", GF_OLD_POLY }, + {"GF_OLD_HEAL", GF_OLD_HEAL }, {"GF_OLD_SPEED", GF_OLD_SPEED }, - {"GF_OLD_SLOW", GF_OLD_SLOW }, - {"GF_OLD_CONF", GF_OLD_CONF }, + {"GF_OLD_SLOW", GF_OLD_SLOW }, + {"GF_OLD_CONF", GF_OLD_CONF }, {"GF_OLD_SLEEP", GF_OLD_SLEEP }, - {"GF_OLD_DRAIN", GF_OLD_DRAIN }, - {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD }, + {"GF_HYPODYNAMIA", GF_HYPODYNAMIA }, + {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD }, {"GF_AWAY_EVIL", GF_AWAY_EVIL }, - {"GF_AWAY_ALL", GF_AWAY_ALL }, - {"GF_TURN_UNDEAD", GF_TURN_UNDEAD }, + {"GF_AWAY_ALL", GF_AWAY_ALL }, + {"GF_TURN_UNDEAD", GF_TURN_UNDEAD }, {"GF_TURN_EVIL", GF_TURN_EVIL }, - {"GF_TURN_ALL", GF_TURN_ALL }, - {"GF_DISP_UNDEAD", GF_DISP_UNDEAD }, + {"GF_TURN_ALL", GF_TURN_ALL }, + {"GF_DISP_UNDEAD", GF_DISP_UNDEAD }, {"GF_DISP_EVIL", GF_DISP_EVIL }, - {"GF_DISP_ALL", GF_DISP_ALL }, + {"GF_DISP_ALL", GF_DISP_ALL }, {"GF_DISP_DEMON", GF_DISP_DEMON }, - {"GF_DISP_LIVING", GF_DISP_LIVING }, + {"GF_DISP_LIVING", GF_DISP_LIVING }, {"GF_ROCKET", GF_ROCKET }, {"GF_NUKE", GF_NUKE }, {"GF_MAKE_GLYPH", GF_MAKE_GLYPH }, @@ -295,118 +260,105 @@ static named_num gf_desc[] = {"GF_STUN", GF_STUN }, {"GF_HOLY_FIRE", GF_HOLY_FIRE }, {"GF_HELL_FIRE", GF_HELL_FIRE }, - {"GF_DISINTEGRATE", GF_DISINTEGRATE }, - {"GF_CHARM", GF_CHARM }, - {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD }, - {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL }, + {"GF_DISINTEGRATE", GF_DISINTEGRATE }, + {"GF_CHARM", GF_CHARM }, + {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD }, + {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL }, {"GF_PSI", GF_PSI }, {"GF_PSI_DRAIN", GF_PSI_DRAIN }, - {"GF_TELEKINESIS", GF_TELEKINESIS }, - {"GF_JAM_DOOR", GF_JAM_DOOR }, + {"GF_TELEKINESIS", GF_TELEKINESIS }, + {"GF_JAM_DOOR", GF_JAM_DOOR }, {"GF_DOMINATION", GF_DOMINATION }, {"GF_DISP_GOOD", GF_DISP_GOOD }, {"GF_DRAIN_MANA", GF_DRAIN_MANA }, {"GF_MIND_BLAST", GF_MIND_BLAST }, {"GF_BRAIN_SMASH", GF_BRAIN_SMASH }, - {"GF_CAUSE_1", GF_CAUSE_1 }, - {"GF_CAUSE_2", GF_CAUSE_2 }, - {"GF_CAUSE_3", GF_CAUSE_3 }, - {"GF_CAUSE_4", GF_CAUSE_4 }, + {"GF_CAUSE_1", GF_CAUSE_1 }, + {"GF_CAUSE_2", GF_CAUSE_2 }, + {"GF_CAUSE_3", GF_CAUSE_3 }, + {"GF_CAUSE_4", GF_CAUSE_4 }, {"GF_HAND_DOOM", GF_HAND_DOOM }, - {"GF_CAPTURE", GF_CAPTURE }, + {"GF_CAPTURE", GF_CAPTURE }, {"GF_ANIM_DEAD", GF_ANIM_DEAD }, - {"GF_CONTROL_LIVING", GF_CONTROL_LIVING }, - {"GF_IDENTIFY", GF_IDENTIFY }, - {"GF_ATTACK", GF_ATTACK }, - {"GF_ENGETSU", GF_ENGETSU }, - {"GF_GENOCIDE", GF_GENOCIDE }, - {"GF_PHOTO", GF_PHOTO }, - {"GF_CONTROL_DEMON", GF_CONTROL_DEMON }, - {"GF_LAVA_FLOW", GF_LAVA_FLOW }, - {"GF_BLOOD_CURSE", GF_BLOOD_CURSE }, - {"GF_SEEKER", GF_SEEKER }, - {"GF_SUPER_RAY", GF_SUPER_RAY }, - {"GF_STAR_HEAL", GF_STAR_HEAL }, - {"GF_WATER_FLOW", GF_WATER_FLOW }, - {"GF_CRUSADE", GF_CRUSADE }, + {"GF_CHARM_LIVING", GF_CHARM_LIVING }, + {"GF_IDENTIFY", GF_IDENTIFY }, + {"GF_ATTACK", GF_ATTACK }, + {"GF_ENGETSU", GF_ENGETSU }, + {"GF_GENOCIDE", GF_GENOCIDE }, + {"GF_PHOTO", GF_PHOTO }, + {"GF_CONTROL_DEMON", GF_CONTROL_DEMON }, + {"GF_LAVA_FLOW", GF_LAVA_FLOW }, + {"GF_BLOOD_CURSE", GF_BLOOD_CURSE }, + {"GF_SEEKER", GF_SEEKER }, + {"GF_SUPER_RAY", GF_SUPER_RAY }, + {"GF_STAR_HEAL", GF_STAR_HEAL }, + {"GF_WATER_FLOW", GF_WATER_FLOW }, + {"GF_CRUSADE", GF_CRUSADE }, {"GF_STASIS_EVIL", GF_STASIS_EVIL }, - {"GF_WOUNDS", GF_WOUNDS }, - {NULL, 0 } + {"GF_WOUNDS", GF_WOUNDS }, + {NULL, 0 } }; -/* +/*! + * @brief 設定ファイルの各行から各種テキスト情報を取得する / * Parse a sub-file of the "extra info" (format shown below) - * + * @param buf データテキストの参照ポインタ + * @return エラーコード + * @details + *
  * Each "action" line has an "action symbol" in the first column,
  * followed by a colon, followed by some command specific info,
  * usually in the form of "tokens" separated by colons or slashes.
- *
  * Blank lines, lines starting with white space, and lines starting
  * with pound signs ("#") are ignored (as comments).
- *
  * Note the use of "tokenize()" to allow the use of both colons and
  * slashes as delimeters, while still allowing final tokens which
  * may contain any characters including "delimiters".
- *
  * Note the use of "strtol()" to allow all "integers" to be encoded
  * in decimal, hexidecimal, or octal form.
- *
  * Note that "monster zero" is used for the "player" attr/char, "object
  * zero" will be used for the "stack" attr/char, and "feature zero" is
  * used for the "nothing" attr/char.
- *
  * Parse another file recursively, see below for details
- *   %:
- *
+ *   %:\
  * Specify the attr/char values for "monsters" by race index
- *   R:::
- *
+ *   R:\:\:\
  * Specify the attr/char values for "objects" by kind index
- *   K:::
- *
+ *   K:\:\:\
  * Specify the attr/char values for "features" by feature index
- *   F:::
- *
+ *   F:\:\:\
  * Specify the attr/char values for unaware "objects" by kind tval
- *   U:::
- *
+ *   U:\:\:\
  * Specify the attr/char values for inventory "objects" by kind tval
- *   E:::
- *
+ *   E:\:\:\
  * Define a macro action, given an encoded macro action
- *   A:
- *
+ *   A:\
  * Create a normal macro, given an encoded macro trigger
- *   P:
- *
+ *   P:\
  * Create a command macro, given an encoded macro trigger
- *   C:
- *
+ *   C:\
  * Create a keyset mapping
- *   S:::
- *
+ *   S:\:\:\
  * Turn an option off, given its name
- *   X:
- *
+ *   X:\
  * Turn an option on, given its name
- *   Y:
- *
+ *   Y:\
  * Specify visual information, given an index, and some data
- *   V:::::
- *
+ *   V:\:\:\:\:\
  * Specify the set of colors to use when drawing a zapped spell
- *   Z::
- *
+ *   Z:\:\
  * Specify a macro trigger template and macro trigger names.
- *   T: