/****************************************************************************
 *
 * $Source: /cvsroot/riscossmbserver/smbserver/src/unix/c/utime,v $
 * $Date: 1999/11/23 22:05:12 $
 * $Revision: 1.2 $
 * $State: Exp $
 * $Author: david $
 *
 * $Log: utime,v $
 * Revision 1.2  1999/11/23 22:05:12  david
 * Increased filename length to MAXPATHLEN
 * uname and dirent - support for spaces in a filename which
 * is translated to 0xa0 on RISCOS and mapping of obscure DOS
 * filename characters to RICOS characters as 2-327 or the PRMs
 *
 * Revision 1.1  1999/05/16 12:00:09  david
 * Initial revision
 *
 * Revision 1.2  1996/10/30 22:04:51  unixlib
 * Massive changes made by Nick Burret and Peter Burwood.
 *
 * Revision 1.1  1996/04/19 21:35:27  simon
 * Initial revision
 *
 ***************************************************************************/

static const char rcs_id[] = "$Id: utime,v 1.2 1999/11/23 22:05:12 david Exp $";

#if 0

#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include <sys/os.h>

#else


#include "includes.h"
#include "swis.h"
#include "my_os.h"



#endif


int utime (const char *filename, const struct utimbuf *times)
{
  int r[6];
  char *file;
  _kernel_oserror *e;
  time_t t;

  file = getFileName(__uname ((char *)filename, 0));

  DEBUG(3,("utime %s , %s\n",filename, file)); 

  if (e = myos_file (0x05, file, r))
    {
     /* __seterr (e); */
      return -1;
    }
  if (!r[0])
    {
      errno = ENOENT;
      return -1;
    }

  /* If times is null then get the current time.  */
  t = (times) ? times->modtime : time (0);

  r[2] = (r[2] & 0x000fff00U) | 0xfff00000U |
    ((((t >> 8) * 100) >> 24) + 0x33);
  r[3] = t * 100 + 0x6e996a00U;

  if (e = myos_file (0x01, file, r))
    {
    /*  __seterr (e);  */
      return -1;
    }

  return 0;
}          



