prof_file.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* prof_file.c ---- routines that manipulate an individual profile file.
*/
#include <autoconf.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include "prof_int.h"
#ifndef NO_SYS_TYPES_H
#endif
#ifndef NO_SYS_STAT_H
#endif
#include <errno.h>
#include <io.h>
#define HAVE_STAT
#endif
#ifndef PROFILE_USES_PATHS
#include <FSp_fopen.h>
static OSErr GetMacOSTempFilespec (
const FSSpec* inFilespec,
#endif
{
#ifdef HAVE_ACCESS
return 1;
else
return 0;
#else
/*
* We're on a substandard OS that doesn't support access. So
* we kludge a test using stdio routines, and hope fopen
* checks the r/w permissions.
*/
FILE *f;
#ifdef PROFILE_USES_PATHS
#else
#endif
if (f) {
fclose(f);
return 1;
}
return 0;
#endif
}
{
char *home_env = 0;
int len;
if (!prf)
return ENOMEM;
#ifndef macintosh
if (home_env)
}
return ENOMEM;
}
if (home_env) {
} else
#else
#endif
if (retval) {
return retval;
}
return 0;
}
{
#ifdef HAVE_STAT
#endif
FILE *f;
#ifdef HAVE_STAT
return errno;
return 0;
}
}
#else
/*
* If we don't have the stat() call, assume that our in-core
* memory image is correct. That is, we won't reread the
* profile file if it changes.
*/
return 0;
#endif
errno = 0;
#ifdef PROFILE_USES_PATHS
#else
#endif
if (f == NULL) {
if (retval == 0)
return retval;
}
prf->upd_serial++;
fclose(f);
if (retval)
return retval;
#ifdef HAVE_STAT
#endif
return 0;
}
#ifndef PROFILE_USES_PATHS
const FSSpec* inFileSpec,
{
return err;
return noErr;
}
#endif
{
FILE *f;
return PROF_MAGIC_FILE;
return 0;
#ifdef PROFILE_USES_PATHS
if (!new_file)
goto errout;
if (!old_file)
goto errout;
errno = 0;
#else
/* On MacOS, we do this by writing to a new file and then atomically
swapping the files with a file system call */
#endif
if (!f) {
if (retval == 0)
goto errout;
}
if (fclose(f) != 0) {
goto errout;
}
#ifdef PROFILE_USES_PATHS
goto errout;
}
goto errout;
}
#else
{
goto errout;
}
}
#endif
retval = 0;
#ifdef PROFILE_USES_PATHS
if (new_file)
if (old_file)
#endif
return retval;
}
void profile_free_file(prf)
{
#ifdef PROFILE_USES_PATHS
#endif
return;
}
{
if (retval)
return retval;
return 0;
}