/**********************************************************************
 * uniqname.c -- return unique filename
 *
 * $Source$
 * $Author$
 * $Header$
 *
 * Copyright 1990 by the Massachusetts Institute of Technology.
 * For copying and distribution information, see the file
 * "mit-copyright.h".
 **********************************************************************/
#include "mit-copyright.h"

#ifndef lint
static char rcsid_uniqname_c[] = "$Header$";
#endif /* lint */

#include <stdio.h>
#include <sys/errno.h>
#include "lucy/lucy.h"
tfile unix_tfile();		/* XXX should be in discuss .h file */

long
uniqname(s)
     char *s;
{
  static int initialized = 0;
  static char dirname[16];
  char tmp[80];

  if (!initialized) {
    strcpy(dirname, "/tmp/dirXXXXXX");
    if (mkdir(mktemp(dirname), 0700)) return((long) errno);
    initialized++;
  }
  sprintf(tmp, "%s/%s", dirname, s);
  strcpy(s, mktemp(tmp));
  return(0L);
}
