{
/* Hack -- drop permissions */
safe_setuid_drop();
- path_build(buf, 1024, ANGBAND_DIR_USER, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
}
else
{
- path_build(buf, 1024, ANGBAND_DIR_PREF, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
}
/* Open the file */
C_MAKE(lines_list, MAX_LINES, cptr);
/* Parse it */
- while (0 == my_fgets(fff, buf, 1024))
+ while (0 == my_fgets(fff, buf, sizeof(buf)))
{
lines_list[lines++] = string_make(buf);
if (lines >= MAX_LINES - 1) break;
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
/* Open the file */
fff = my_fopen(buf, "w");
autopick_entry_from_object(entry, &autopick_last_destroyed_object);
last_destroyed = autopick_line_from_entry_kill(entry);
- strncpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), WID_DESC+2);
- last_destroyed_command[WID_DESC+2] = '\0';
+ my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
}
else
{
char buf[1024];
FILE *fp;
- path_build(buf, 1024, ANGBAND_DIR_XTRA, prf_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA, prf_name);
fp = my_fopen(buf, "r");
if (!fp) return (-1);
server_name[0] = 0;
browse_delay = DEFAULT_DELAY;
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* ¥µ¡¼¥Ð̾ */
if (!strncmp(buf, "server:", 7))
while (1)
{
- if (my_fgets(orig_fff, buf, 1024))
+ if (my_fgets(orig_fff, buf, sizeof(buf)))
{
if (between_mark)
{
tmp_fff = my_fopen(tmp_file, "r");
orig_fff = my_fopen(orig_file, "w");
- while (!my_fgets(tmp_fff, buf, 1024))
+ while (!my_fgets(tmp_fff, buf, sizeof(buf)))
fprintf(orig_fff, "%s\n", buf);
my_fclose(orig_fff);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_MONK || p_ptr->pclass == CLASS_SAMURAI || p_ptr->pclass == CLASS_BERSERKER)
strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)]);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
/* Remove the file */
fd_kill(buf);
char buf[1024];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
if (!askfor_aux(tmp, 70)) continue;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
/* Append to the file */
fff = open_auto_dump(buf, mark, &line_num);
if (!askfor_aux(tmp, 70)) continue;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
/* Append to the file */
fff = open_auto_dump(buf, mark, &line_num);
if (!askfor_aux(tmp, 70)) continue;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
/* Append to the file */
fff = open_auto_dump(buf, mark, &line_num);
if (!askfor_aux(tmp, 70)) continue;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
/* Append to the file */
fff = open_auto_dump(buf, mark, &line_num);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
/* Append to the file */
fff = my_fopen(buf, "r");
}
/* Get the blank line */
- if (my_fgets(fff, buf, 1024)) okay = FALSE;
+ if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
/* Dump the screen */
/* Get the blank line */
- if (my_fgets(fff, buf, 1024)) okay = FALSE;
+ if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
/* Close it */
screen_save();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, "htmldump.prf");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
tmpfff = my_fopen(buf, "r");
if (!tmpfff) {
for (i = 0; html_head[i]; i++)
}
else {
yomikomu = 0;
- while (!my_fgets(tmpfff, buf, 1024)) {
+ while (!my_fgets(tmpfff, buf, sizeof(buf))) {
if (!yomikomu) {
if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
yomikomu = 1;
else {
rewind(tmpfff);
yomikomu = 0;
- while (!my_fgets(tmpfff, buf, 1024)) {
+ while (!my_fgets(tmpfff, buf, sizeof(buf))) {
if (!yomikomu) {
if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
yomikomu = 1;
return;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
msg_print(NULL);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
if (!randint0(10) || p_ptr->image)
{
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_FILE, "timefun_j.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
#else
- path_build(buf, 1024, ANGBAND_DIR_FILE, "timefun.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
#endif
}
else
{
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_FILE, "timenorm_j.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
#else
- path_build(buf, 1024, ANGBAND_DIR_FILE, "timenorm.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
#endif
}
if (!fff) return;
/* Find this time */
- while (!my_fgets(fff, buf, 1024))
+ while (!my_fgets(fff, buf, sizeof(buf)))
{
/* Ignore comments */
if (!buf[0] || (buf[0] == '#')) continue;
object_desc(o_name, o_ptr, TRUE, 0);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_FILE, q);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
/* Peruse the help file */
(void)show_file(TRUE, buf, o_name, 0, 0);
character_icky = TRUE;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
/* Open the high score file, for reading/writing */
highscore_fd = fd_open(buf, O_RDWR);
extern void build_gamma_table(int gamma);
#endif /* SUPPORT_GAMMA */
+extern size_t my_strcpy(char *buf, const char *src, size_t bufsize);
+extern size_t my_strcat(char *buf, const char *src, size_t bufsize);
+
+
/* xtra1.c */
extern bool is_daytime(void);
extern void extract_day_hour_min(int *day, int *hour, int *min);
extern void jverb3( const char *in , char *out);
extern void jverb( const char *in , char *out , int flag);
extern char* strstr_j(cptr str1, cptr str2);
-extern size_t mb_strlcpy(char *dst, const char *src, size_t size);
extern void codeconv(char *str);
extern bool iskanji2(cptr s, int x);
#endif
if (!fp) return (-1);
/* Process the file */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Count lines */
line++;
errr err1, err2;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_PREF, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
/* Process the system pref file */
err1 = process_pref_file_aux(buf, FALSE);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
/* Process the user pref file */
err2 = process_pref_file_aux(buf, FALSE);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
/* Open the file */
fp = my_fopen(buf, "r");
check_time_flag = TRUE;
/* Parse the file */
- while (0 == my_fgets(fp, buf, 80))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Skip comments and blank lines */
if (!buf[0] || (buf[0] == '#')) continue;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
/* Open the "load" file */
fp = my_fopen(buf, "r");
(void)gethostname(thishost, (sizeof thishost) - 1);
/* Parse it */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
int value;
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* Build the filename */
- path_build(path, 1024, ANGBAND_DIR_HELP, name);
+ path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
/* Open the file */
fff = my_fopen(path, "r");
/* Build the filename */
- path_build(path, 1024, ANGBAND_DIR_INFO, name);
+ path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
/* Open the file */
fff = my_fopen(path, "r");
if (!fff)
{
/* Build the filename */
- path_build(path, 1024, ANGBAND_DIR, name);
+ path_build(path, sizeof(path), ANGBAND_DIR, name);
for (i = 0; path[i]; i++)
if ('\\' == path[i])
char *str;
/* Read a line or stop */
- if (my_fgets(fff, buf, 1024)) break;
+ if (my_fgets(fff, buf, sizeof(buf))) break;
/* Get a color */
if (prefix(buf, "#####")) str = &buf[6];
while (next < line)
{
/* Get a line */
- if (my_fgets(fff, buf, 1024)) break;
+ if (my_fgets(fff, buf, sizeof(buf))) break;
/* Skip tags/links */
if (prefix(buf, "***** ")) continue;
if (!i) line = next;
/* Get a line of the file or stop */
- if (my_fgets(fff, buf, 1024)) break;
+ if (my_fgets(fff, buf, sizeof(buf))) break;
/* Hack -- skip "special" lines */
if (prefix(buf, "***** ")) continue;
safe_setuid_drop();
/* Build the filename */
- path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
+ path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
/* Hack -- Re-Open the file */
fff = my_fopen(path, "r");
my_fputs(ffp, xtmp, 80);
my_fputs(ffp, "\n", 80);
- while (!my_fgets(fff, buff, 80))
+ while (!my_fgets(fff, buff, sizeof(buff)))
my_fputs(ffp, buff, 80);
/* Close it */
#endif /* VM */
/* Build the filename */
- path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
+ path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
}
}
sprintf(tmp, "bone.%03d", dun_level);
/* Build the filename */
- path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
+ path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
/* Attempt to open the bones file */
fp = my_fopen(str, "r");
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
#else
- path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
#endif
int i = 0;
/* Dump the file to the screen */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Display and advance */
put_str(buf, i++, 0);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
/* Open the high score file, for reading/writing */
highscore_fd = fd_open(buf, O_RDWR);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
/* Open the file */
fp = my_fopen(buf, "r");
while (TRUE)
{
/* Get a line from the file */
- if (my_fgets(fp, buf, 1024) == 0)
+ if (my_fgets(fp, buf, sizeof(buf)) == 0)
{
/* Count the lines */
line_num++;
while (TRUE)
{
/* Get the line */
- if (my_fgets(fp, buf, 1024) == 0)
+ if (my_fgets(fp, buf, sizeof(buf)) == 0)
{
/* Count the lines */
line_num++;
while(TRUE)
{
- test = my_fgets(fp, buf, 1024);
+ test = my_fgets(fp, buf, sizeof(buf));
if(test || buf[0] != '#')
break;
}
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
err = process_pref_file_aux(buf, TRUE);
char buf[1024];
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
#endif
fd = fd_open(buf, O_RDONLY);
char buf[1024];
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
#endif
fd = fd_open(buf, O_RDWR);
if (fd < 0)
char tmp[8];
#endif
- path_build(buf, 1024, ANGBAND_DIR_PREF, "proxy.prf");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, "proxy.prf");
/* ¥Õ¥¡¥¤¥ë¤«¤éÀßÄê¤òÆɤࡣ */
fp = my_fopen(buf, "r");
return;
}
- while (my_fgets(fp, buf, 1024)==0)
+ while (my_fgets(fp, buf, sizeof(buf))==0)
{
if (buf[0] != '#' && buf[0] != '\0') break;
}
head->text_size = 0;
/* Parse */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Advance the line number */
error_line++;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_EDIT, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
/* Open the file */
fp = my_fopen(buf, "r");
/* Process the file */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Count lines */
num++;
#ifdef PRIVATE_USER_PATH
/* Build the path to the user specific directory */
- path_build(buf, 1024, PRIVATE_USER_PATH, VERSION_NAME);
+ path_build(buf, sizeof(buf), PRIVATE_USER_PATH, VERSION_NAME);
/* Build a relative path name */
ANGBAND_DIR_USER = string_make(buf);
struct stat txt_stat, raw_stat;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_EDIT, template_file);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, template_file);
/* Access stats on text file */
if (stat(buf, &txt_stat))
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s_j.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s_j.raw", filename));
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s.raw", filename));
#endif
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_EDIT, format("%s_j.txt", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, format("%s_j.txt", filename));
/* Open the file */
fp = my_fopen(buf, "r");
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s_j.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s_j.raw", filename));
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s.raw", filename));
#endif
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s_j.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s_j.raw", filename));
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, format("%s.raw", filename));
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format("%s.raw", filename));
#endif
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_FILE, "news_j.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news_j.txt");
#else
- path_build(buf, 1024, ANGBAND_DIR_FILE, "news.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt");
#endif
/* Build the filename */
#ifdef JP
- path_build(buf, 1024, ANGBAND_DIR_FILE, "news_j.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news_j.txt");
#else
- path_build(buf, 1024, ANGBAND_DIR_FILE, "news.txt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt");
#endif
int i = 0;
/* Dump the file to the screen */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Display and advance */
Term_putstr(0, i++, -1, TERM_WHITE, buf);
/*** Verify (or create) the "high score" file ***/
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
/* Attempt to open the high score file */
fd = fd_open(buf, O_RDONLY);
return NULL;
}
-/* 2¥Ð¥¤¥Èʸ»ú¤ò¹Íθ¤·¤Ê¤¬¤éºÇÂç n ¥Ð¥¤¥Èʸ»úÎó¤ò¥³¥Ô¡¼¤¹¤ë */
-size_t mb_strlcpy(char *dst, const char *src, size_t size)
-{
- unsigned char *d = (unsigned char*)dst;
- const unsigned char *s = (unsigned char*)src;
- size_t n = 0;
-
- /* reserve for NUL termination */
- size--;
-
- /* Copy as many bytes as will fit */
- while(n < size) {
- if (iskanji(*s)) {
- if(n + 2 >= size || !*(s+1)) break;
- *d++ = *s++;
- *d++ = *s++;
- n += 2;
- } else {
- *d++ = *s++;
- n++;
- }
- }
- *d = '\0';
- while(*s++) n++;
- return n;
-}
/*
* str¤ò´Ä¶¤Ë¹ç¤Ã¤¿Ê¸»ú¥³¡¼¥É¤ËÊÑ´¹¤¹¤ë¡£
rd_byte(&o_ptr->feeling);
/* Inscription */
- rd_string(buf, 128);
+ rd_string(buf, sizeof(buf));
/* Save the inscription */
if (buf[0]) o_ptr->inscription = quark_add(buf);
- rd_string(buf, 128);
+ rd_string(buf, sizeof(buf));
if (buf[0]) o_ptr->art_name = quark_add(buf);
/* The Python object */
}
else
{
- rd_string(buf, 128);
+ rd_string(buf, sizeof(buf));
if (buf[0]) m_ptr->nickname = quark_add(buf);
}
char buf[64];
/* Strip name */
- rd_string(buf, 64);
+ rd_string(buf, sizeof(buf));
/* Strip old data */
strip_bytes(60);
for (i = 0; i < 8; i++) rd_s16b(&previous_char.vir_types[i]);
- for (i = 0; i < 4; i++) rd_string(previous_char.history[i], 60);
+ for (i = 0; i < 4; i++) rd_string(previous_char.history[i], sizeof(previous_char.history[i]));
rd_byte(&previous_char.quests);
byte tmp8u;
s16b tmp16s;
- rd_string(player_name, 32);
+ rd_string(player_name, sizeof(player_name));
- rd_string(p_ptr->died_from, 80);
+ rd_string(p_ptr->died_from, sizeof(p_ptr->died_from));
load_quick_start();
for (i = 0; i < 4; i++)
{
- rd_string(p_ptr->history[i], 60);
+ rd_string(p_ptr->history[i], sizeof(p_ptr->history[i]));
}
/* Class/Race/Seikaku/Gender/Spells */
for (i = 0; i < num; i++)
{
/* Read the message */
- rd_string(buf, 128);
+ rd_string(buf, sizeof(buf));
/* Save the message */
message_add(buf);
if (!z_older_than(11, 0, 9))
{
char buf[SCREEN_BUF_SIZE];
- rd_string(buf, SCREEN_BUF_SIZE);
+ rd_string(buf, sizeof(buf));
if (buf[0]) screen_dump = string_make(buf);
}
get_palette(pal);
/* Build the filename for the screen-dump */
- path_build(filename, 1024, ANGBAND_DIR_USER, "dump.bmp");
+ path_build(filename, sizeof(filename), ANGBAND_DIR_USER, "dump.bmp");
/* Save it */
save_bmp(filename, bmp, pal);
strcpy(buf, get_config_string(section, "font_file", "xm8x13.fnt"));
/* Build the name of the font file */
- path_build(filename, 1024, xtra_font_dir, buf);
+ path_build(filename, sizeof(filename), xtra_font_dir, buf);
/* Load a "*.fnt" file */
if (suffix(filename, ".fnt"))
strcpy(buf, get_config_string("Background", format("Background-%d", i), ""));
/* Build the filename for the background-bitmap */
- path_build(filename, 1024, xtra_graf_dir, buf);
+ path_build(filename, sizeof(filename), xtra_graf_dir, buf);
/* Try to open the bitmap file */
background[i] = load_bitmap(filename, background_pallete);
num_windows = get_config_int(section, "num_windows", 1);
/* Build the name of the bitmap file */
- path_build(filename, 1024, xtra_graf_dir, name_tiles);
+ path_build(filename, sizeof(filename), xtra_graf_dir, name_tiles);
/* Open the bitmap file */
if ((tiles = load_bitmap(filename, tiles_pallete)) != NULL)
#endif /* USE_MOD_FILES */
/* Access the new sample */
- path_build(filename, 1024, xtra_sound_dir, "sound.cfg");
+ path_build(filename, sizeof(filename), xtra_sound_dir, "sound.cfg");
/* Read config info from "lib/xtra/sound/sound.cfg" */
override_config_file(filename);
for (j = 0; j < sample_count[i]; j++)
{
/* Access the new sample */
- path_build(filename, 1024, xtra_sound_dir, argv[j]);
+ path_build(filename, sizeof(filename), xtra_sound_dir, argv[j]);
/* Load the sample */
samples[i][j] = load_sample(filename);
#endif /* USE_MOD_FILES */
/* Access the new song */
- path_build(filename, 1024, xtra_music_dir, music_files[current_song - 1]);
+ path_build(filename, sizeof(filename), xtra_music_dir, music_files[current_song - 1]);
/* Load and play the new song */
midi_song = load_midi(filename);
quit_aux = dos_quit_hook;
/* Build the "graf" path */
- path_build(xtra_graf_dir, 1024, ANGBAND_DIR_XTRA, "graf");
+ path_build(xtra_graf_dir, sizeof(xtra_graf_dir), ANGBAND_DIR_XTRA, "graf");
/* Build the "font" path */
- path_build(xtra_font_dir, 1024, ANGBAND_DIR_XTRA, "font");
+ path_build(xtra_font_dir, sizeof(xtra_font_dir), ANGBAND_DIR_XTRA, "font");
/* Build the "sound" path */
- path_build(xtra_sound_dir, 1024, ANGBAND_DIR_XTRA, "sound");
+ path_build(xtra_sound_dir, sizeof(xtra_sound_dir), ANGBAND_DIR_XTRA, "sound");
/* Build the "music" path */
- path_build(xtra_music_dir, 1024, ANGBAND_DIR_XTRA, "music");
+ path_build(xtra_music_dir, sizeof(xtra_music_dir), ANGBAND_DIR_XTRA, "music");
/* Initialize the windows */
init_windows();
sprintf(wav, "%s.wav", angband_sound_name[i]);
/* Access the sound */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, wav);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_SOUND, wav);
/* Save the sound filename, if it exists */
if (check_file(buf)) sound_file[i] = string_make(buf);
#ifdef USE_SOUND
/* Build the "sound" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "sound");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
/* Allocate the path */
ANGBAND_DIR_XTRA_SOUND = string_make(path);
char buf[4096];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_XTRA, "angband.fnt");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA, "angband.fnt");
/* Open the file */
f = fopen(buf, "rb");
{
int x = 0;
char buf[256];
- if (0 == my_fgets(fff, buf, 256)) x = atoi(buf);
+ if (0 == my_fgets(fff, buf, sizeof(buf))) x = atoi(buf);
return (x);
}
char tmp[1024];
FILE *fp;
- path_build(path, 1024, ANGBAND_DIR_XTRA, "chuukei.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "chuukei.txt");
fp = fopen(path, "r");
if(!fp)
/* Build the filename */
#ifdef JP
- path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
#else
- path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
#endif
/* Attempt to open and close that file */
{
int x = 0;
char buf[256];
- if (0 == my_fgets(fff, buf, 256)) x = atoi(buf);
+ if (0 == my_fgets(fff, buf, sizeof(buf))) x = atoi(buf);
return (x);
}
char tmp[1024];
FILE *fp;
- path_build(path, 1024, ANGBAND_DIR_XTRA, "chuukei.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "chuukei.txt");
fp = fopen(path, "r");
if(!fp)
/* Build the filename */
#ifdef JP
- path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
#else
- path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
#endif
/* Attempt to open and close that file */
}
/* Access the bitmap file */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_GRAF, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
/* Load the bitmap or quit */
if (!ReadDIB(data[0].w, buf, &infGraph))
if (arg_graphics == GRAPHICS_ADAM_BOLT)
{
/* Access the mask file */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
/* Load the bitmap or quit */
if (!ReadDIB(data[0].w, buf, &infMask))
sprintf(wav, "%s.wav", angband_sound_name[i]);
/* Access the sound */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, wav);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_SOUND, wav);
/* Save the sound filename, if it exists */
if (check_file(buf)) sound_file[i] = string_make(buf);
if (term_force_font(td, tmp))
{
/* Access the standard font file */
- path_build(tmp, 1024, ANGBAND_DIR_XTRA_FONT, "8X13.FON");
+ path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
/* Force the use of that font */
(void)term_force_font(td, tmp);
td->tile_hgt = td->font_hgt;
#else
/* Access the standard font file */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_FONT, td->font_want);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
/* Activate the chosen font */
if (term_force_font(td, buf))
{
/* Access the standard font file */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_FONT, "8X13.FON");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
/* Force the use of that font */
(void)term_force_font(td, buf);
char buf[1024];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
/* Open the binary high score file, for reading */
highscore_fd = fd_open(buf, O_RDONLY);
{
#ifdef HTML_HELP
char tmp[1024];
- path_build(tmp, 1024, ANGBAND_DIR_XTRA_HELP, "zangband.chm");
+ path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
if (check_file(tmp))
{
HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
#else /* HTML_HELP */
char buf[1024];
char tmp[1024];
- path_build(tmp, 1024, ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
+ path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
if (check_file(tmp))
{
sprintf(buf, "winhelp.exe %s", tmp);
/* Build the filename */
#ifdef JP
- path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
#else
- path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
#endif
#ifndef JP
/* Build the "font" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "font");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
/* Allocate the path */
ANGBAND_DIR_XTRA_FONT = string_make(path);
validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
/* Build the filename */
- path_build(path, 1024, ANGBAND_DIR_XTRA_FONT, "8X13.FON");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
/* Hack -- Validate the basic font */
validate_file(path);
#ifdef USE_GRAPHICS
/* Build the "graf" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "graf");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
/* Allocate the path */
ANGBAND_DIR_XTRA_GRAF = string_make(path);
#ifdef USE_SOUND
/* Build the "sound" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "sound");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
/* Allocate the path */
ANGBAND_DIR_XTRA_SOUND = string_make(path);
#ifdef USE_MUSIC
/* Build the "music" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "music");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
/* Allocate the path */
ANGBAND_DIR_XTRA_MUSIC = string_make(path);
#endif /* USE_MUSIC */
/* Build the "help" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "help");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
/* Allocate the path */
ANGBAND_DIR_XTRA_HELP = string_make(path);
char dir_xtra_sound[1024];
/* Build the "sound" path */
- path_build(dir_xtra_sound, 1024, ANGBAND_DIR_XTRA, "sound");
+ path_build(dir_xtra_sound, sizeof(dir_xtra_sound), ANGBAND_DIR_XTRA, "sound");
/* Prepare the sounds */
for (i = 1; i < SOUND_MAX; i++)
sprintf(wav, "%s.wav", angband_sound_name[i]);
/* Access the sound */
- path_build(buf, 1024, dir_xtra_sound, wav);
+ path_build(buf, sizeof(buf), dir_xtra_sound, wav);
/* Save the sound filename, if it exists */
if (check_file(buf)) sound_file[i] = string_make(buf);
{
case GRAPHICS_ORIGINAL:
/* Try the "8x8.bmp" file */
- path_build(filename, 1024, ANGBAND_DIR_XTRA, "graf/8x8.bmp");
+ path_build(filename, sizeof(filename), ANGBAND_DIR_XTRA, "graf/8x8.bmp");
/* Use the "8x8.bmp" file if it exists */
if (0 == fd_close(fd_open(filename, O_RDONLY)))
case GRAPHICS_ADAM_BOLT:
/* Try the "16x16.bmp" file */
- path_build(filename, 1024, ANGBAND_DIR_XTRA, "graf/16x16.bmp");
+ path_build(filename, sizeof(filename), ANGBAND_DIR_XTRA, "graf/16x16.bmp");
/* Use the "16x16.bmp" file if it exists */
if (0 == fd_close(fd_open(filename, O_RDONLY)))
mkdir(dirpath, 0700);
/* Build the path to the variant-specific sub-directory */
- path_build(subdirpath, 1024, dirpath, VERSION_NAME);
+ path_build(subdirpath, sizeof(subdirpath), dirpath, VERSION_NAME);
/* Create the directory */
mkdir(subdirpath, 0700);
/* Build the filename */
#ifdef JP
-path_build(buf, 1024, ANGBAND_DIR_DATA, "r_info_j.raw");
+path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "r_info_j.raw");
#else
- path_build(buf, 1024, ANGBAND_DIR_DATA, "r_info.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "r_info.raw");
#endif
char buf[1024];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
/* Open the binary high score file, for reading */
highscore_fd = fd_open(buf, O_RDONLY);
sprintf(the_score.max_dun, "%3d", max_dlv[dungeon_type]);
/* Save the cause of death (31 chars) */
-#ifdef JP
-#if 0
+ if (strlen(p_ptr->died_from) >= sizeof(the_score.how))
{
- /* 2byte ʸ»ú¤ò¹Íθ¤·¤Ê¤¬¤é¥³¥Ô¡¼(EUC ¤ò²¾Äê) */
- int cnt = 0;
- unsigned char *d = (unsigned char*)p_ptr->died_from;
- unsigned char *h = (unsigned char*)the_score.how;
- while(*d && cnt < 31){
- if(iskanji(*d)){
- if(cnt + 2 > 31) break;
- *h++ = *d++;
- *h++ = *d++;
- cnt += 2;
- }else{
- if(cnt + 1 > 31) break;
- *h++ = *d++;
- cnt++;
- }
- }
- *h = '\0';
- }
-#endif
- if (strlen(p_ptr->died_from) >= 39)
- {
- mb_strlcpy(the_score.how, p_ptr->died_from, 37+1);
+#ifdef JP
+ my_strcpy(the_score.how, p_ptr->died_from, sizeof(the_score.how) - 2);
strcat(the_score.how, "¡Ä");
+#else
+ my_strcpy(the_score.how, p_ptr->died_from, sizeof(the_score.how) - 3);
+ strcat(the_score.how, "...");
+#endif
}
else
+ {
strcpy(the_score.how, p_ptr->died_from);
-
-#else
- sprintf(the_score.how, "%-.31s", p_ptr->died_from);
-#endif
-
+ }
/* Lock (for writing) the highscore file, or fail */
if (fd_lock(highscore_fd, F_WRLCK)) return (1);
screen_save();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
highscore_fd = fd_open(buf, O_RDONLY);
prt(tmp_str, 5, 15);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
highscore_fd = fd_open(buf, O_RDONLY);
if (name[0] != '\0')
{
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_SCRIPT, name);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_SCRIPT, name);
}
else
{
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_SCRIPT, "idle.py");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_SCRIPT, "idle.py");
}
fff = my_fopen(buf, "rw");
ascii_to_text(path, ANGBAND_DIR_SCRIPT);
/* Build the path to the Python modules */
- path_build(buf, 1024, ANGBAND_DIR_SCRIPT, "python");
+ path_build(buf, sizeof(buf), ANGBAND_DIR_SCRIPT, "python");
/* Convert the script path to a nice string */
ascii_to_text(path1, buf);
/* Hack -- Build a "useful" prompt */
if (mode & CHECK_OKAY_CANCEL)
{
-#ifdef JP
- /* (79-8)¥Ð¥¤¥È¤Î»ØÄê, prompt¤¬Ä¹¤«¤Ã¤¿¾ì¹ç,
- (79-9)ʸ»ú¤Î¸å½ªÃ¼Ê¸»ú¤¬½ñ¤¹þ¤Þ¤ì¤ë.
- ±Ñ¸ì¤ÎÊý¤Îstrncpy¤È¤Ï°ã¤¦¤Î¤ÇÃí°Õ.
- else¤ÎÊý¤Îʬ´ô¤âƱÍÍ. --henkma
- */
- mb_strlcpy(buf, prompt, 80-15);
-#else
- strncpy(buf, prompt, 79-15);
- buf[79-8]='\0';
-#endif
+ my_strcpy(buf, prompt, sizeof(buf)-15);
strcat(buf, "[(O)k/(C)ancel]");
-
}
else
{
-#ifdef JP
- mb_strlcpy(buf, prompt, 80-5);
-#else
- strncpy(buf, prompt, 79-5);
- buf[79-5]='\0';
-#endif
+ my_strcpy(buf, prompt, sizeof(buf)-5);
strcat(buf, "[y/n]");
}
return;
}
+
+/*
+ * The my_strcpy() function copies up to 'bufsize'-1 characters from 'src'
+ * to 'buf' and NUL-terminates the result. The 'buf' and 'src' strings may
+ * not overlap.
+ *
+ * my_strcpy() returns strlen(src). This makes checking for truncation
+ * easy. Example: if (my_strcpy(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
+ *
+ * This function should be equivalent to the strlcpy() function in BSD.
+ */
+size_t my_strcpy(char *buf, const char *src, size_t bufsize)
+{
+#ifdef JP
+
+ char *d = buf;
+ const char *s = src;
+ size_t len = 0;
+
+ /* reserve for NUL termination */
+ bufsize--;
+
+ /* Copy as many bytes as will fit */
+ while (len < bufsize)
+ {
+ if (iskanji(*s))
+ {
+ if (len + 1 >= bufsize || !*(s+1)) break;
+ *d++ = *s++;
+ *d++ = *s++;
+ len += 2;
+ }
+ else
+ {
+ *d++ = *s++;
+ len++;
+ }
+ }
+ *d = '\0';
+ while(*s++) len++;
+
+ return len;
+
+#else
+
+ size_t len = strlen(src);
+ size_t ret = len;
+
+ /* Paranoia */
+ if (bufsize == 0) return ret;
+
+ /* Truncate */
+ if (len >= bufsize) len = bufsize - 1;
+
+ /* Copy the string and terminate it */
+ (void)memcpy(buf, src, len);
+ buf[len] = '\0';
+
+ /* Return strlen(src) */
+ return ret;
+
+#endif
+}
+
+
+/*
+ * The my_strcat() tries to append a string to an existing NUL-terminated string.
+ * It never writes more characters into the buffer than indicated by 'bufsize' and
+ * NUL-terminates the buffer. The 'buf' and 'src' strings may not overlap.
+ *
+ * my_strcat() returns strlen(buf) + strlen(src). This makes checking for
+ * truncation easy. Example:
+ * if (my_strcat(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
+ *
+ * This function should be equivalent to the strlcat() function in BSD.
+ */
+size_t my_strcat(char *buf, const char *src, size_t bufsize)
+{
+ size_t dlen = strlen(buf);
+
+ /* Is there room left in the buffer? */
+ if (dlen < bufsize - 1)
+ {
+ /* Append as much as possible */
+ return (dlen + my_strcpy(buf + dlen, src, bufsize - dlen));
+ }
+ else
+ {
+ /* Return without appending */
+ return (dlen + strlen(src));
+ }
+}
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
char exp[80];
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
s16b *who;
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
safe_setuid_drop();
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
/* Normal */
else
{
-#ifdef JP
- mb_strlcpy(str, player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5], 14);
-#else
- strncpy(str, player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5], 13);
- str[13] = '\0';
-#endif
+ my_strcpy(str, player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5], sizeof(str));
p = str;
}
prt_field(mimic_info[p_ptr->mimic_form].title, ROW_RACE, COL_RACE);
else
{
-#ifdef JP
char str[14];
- mb_strlcpy(str, rp_ptr->title, 14);
+ my_strcpy(str, rp_ptr->title, sizeof(str));
prt_field(str, ROW_RACE, COL_RACE);
-#else
- prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
-#endif
}
/* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
/* prt_field(ap_ptr->title, ROW_SEIKAKU, COL_SEIKAKU); */
#include "z-util.h"
-
-/*
- * Global variables for temporary use
- */
-char char_tmp = 0;
-byte byte_tmp = 0;
-sint sint_tmp = 0;
-uint uint_tmp = 0;
-long long_tmp = 0;
-huge huge_tmp = 0;
-errr errr_tmp = 0;
-
-
-/*
- * Global pointers for temporary use
- */
-cptr cptr_tmp = NULL;
-vptr vptr_tmp = NULL;
-
-
-
-
-/*
- * Constant bool meaning true
- */
-bool bool_true = 1;
-
-/*
- * Constant bool meaning false
- */
-bool bool_false = 0;
-
-
-/*
- * Global NULL cptr
- */
-cptr cptr_null = NULL;
-
-
-/*
- * Global NULL vptr
- */
-vptr vptr_null = NULL;
-
-
-
-/*
- * Global SELF vptr
- */
-vptr vptr_self = (vptr)(&vptr_self);
-
-
-
/*
* Convenient storage of the program name
*/
cptr argv0 = NULL;
-
-/*
- * A routine that does nothing
- */
-void func_nothing(void)
-{
- /* Do nothing */
-}
-
-
-/*
- * A routine that always returns "success"
- */
-errr func_success(void)
-{
- return (0);
-}
-
-
-/*
- * A routine that always returns a simple "problem code"
- */
-errr func_problem(void)
-{
- return (1);
-}
-
-
-/*
- * A routine that always returns a simple "failure code"
- */
-errr func_failure(void)
-{
- return (-1);
-}
-
-
-
-/*
- * A routine that always returns "true"
- */
-bool func_true(void)
-{
- return (1);
-}
-
-
-/*
- * A routine that always returns "false"
- */
-bool func_false(void)
-{
- return (0);
-}
-
-
-
-
/*
* Determine if string "t" is equal to string "t"
*/
/**** Available variables ****/
-/* Temporary Vars */
-extern char char_tmp;
-extern byte byte_tmp;
-extern sint sint_tmp;
-extern uint uint_tmp;
-extern long long_tmp;
-extern huge huge_tmp;
-extern errr errr_tmp;
-
-/* Temporary Pointers */
-extern cptr cptr_tmp;
-extern vptr vptr_tmp;
-
-
-/* Constant pointers (NULL) */
-extern cptr cptr_null;
-extern vptr vptr_null;
-
-
-/* A bizarre vptr that always points at itself */
-extern vptr vptr_self;
-
-
/* A cptr to the name of the program */
extern cptr argv0;
/**** Available Functions ****/
-/* Function that does nothing */
-extern void func_nothing(void);
-
-/* Functions that return basic "errr" codes */
-extern errr func_success(void);
-extern errr func_problem(void);
-extern errr func_failure(void);
-
-/* Functions that return bools */
-extern bool func_true(void);
-extern bool func_false(void);
-
-
/* Test equality, prefix, suffix */
extern bool streq(cptr s, cptr t);
extern bool prefix(cptr s, cptr t);