/****************************************************************************
 * I myself add no terms or conditions to this code, simply because I don't *
 * care. If you're going to steal it, you will whether I tell you you can or*
 * not, likewise if you wish to do something special like mention me or the *
 * other authors or whatever, somewhere, this is also entirely up to you,   *
 * and not something I can force you to do, etc.                            *
 *                                         -Aurora                          *
 *                                          EternalEmpress@Lostprophecy.com *
 ****************************************************************************/


/* Declare with your other prototypes */
void	update_logfile	args( ( ) );

/* Place this function in a file somewhere */

void update_logfile()
{
  char logfile[MAX_INPUT_LENGTH];
  sh_int filenumber=0; 

/* If you wish to keep it on the standard 1000.log, etc, change
   filenumber to 1000 to start and remove the timestamp. */


  sprintf(logfile, "%s%s.%d.log", "../log/", timestamp(), filenumber);
   
  while( exists_file(logfile))
  {
    filenumber++;
    sprintf(logfile, "%s%s.%d.log", "../log/", timestamp(), filenumber);
  }

  fflush(stderr);
  freopen(logfile, "w", stderr);

  return;
}

/* if you wish to keep my date stamp in there and you do not have a copy of it
   declare this as well somewhere, and its prototype */

char *char *	timestamp		args( ( ) );
()
{
   static char buf[MAX_STRING_LENGTH];
   struct tm *t = localtime(&current_time);

   sprintf( buf, "%04d-%02d-%02d", t->tm_year+1900, t->tm_mon+1,  t->tm_mday );
   return buf;
}

/* if you do not have exists_file this is it */

bool exists_file( char *filen )
{
   struct stat fst;

   if( stat(filen, &fst) == -1 )
     return FALSE;
   else
     return TRUE;
  return TRUE;
}

/* to install, inside db.c after
    unlink( BOOTLOG_FILE );
    boot_log( "---------------------[ Boot Log ]--------------------" );

add:
    update_logfile();
    log_string ("Updating Logfile");
and every copyover/reboot will automatically get its own file.

*/

