rogue > open_score()


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

呼び出し元

rogue/main()

環境変数

SCOREFILE

NUMSCORES

NUMNAME

void
open_score(void)
{
#ifdef SCOREFILE
    char *scorefile = SCOREFILE;

    numscores = NUMSCORES;
    Numname = NUMNAME;

#ifdef ALLSCORES
    allscore = TRUE;
#else  /* ALLSCORES */
    allscore = FALSE;
#endif /* ALLSCORES */

     /* 
      * We drop setgid privileges after opening the score file, so subsequent 
      * open()'s will fail.  Just reuse the earlier filehandle. 
      */

    if (scoreboard != NULL) { 
        rewind(scoreboard); 
        return; 
    } 

    scoreboard = fopen(scorefile, "r+");

    if ((scoreboard == NULL) && (errno == ENOENT))
    {
        scoreboard = fopen(scorefile, "w+");
        md_chmod(scorefile,0664);
    }

    if (scoreboard == NULL) { 
         fprintf(stderr, "Could not open %s for writing: %s\n", scorefile, strerror(errno)); 
         fflush(stderr); 
    } 
#else
    scoreboard = NULL;
#endif
}
||