summaryrefslogtreecommitdiffstats
path: root/src/util/profile/prof_init.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2002-12-31 09:21:12 +0000
committerKen Raeburn <raeburn@mit.edu>2002-12-31 09:21:12 +0000
commit279dfdc141bb3fc23c8fe25ea133c021b3a586ac (patch)
treed1945398b4cdb2809664d5aa527cfe5059c5bb7f /src/util/profile/prof_init.c
parente33427c7b4b006b206719bc9256c55d20860d1ec (diff)
downloadkrb5-279dfdc141bb3fc23c8fe25ea133c021b3a586ac.tar.gz
krb5-279dfdc141bb3fc23c8fe25ea133c021b3a586ac.tar.xz
krb5-279dfdc141bb3fc23c8fe25ea133c021b3a586ac.zip
Merge some Mac-specific changes from meeroh's branch:
* profile.hin: Don't test MACINTOSH any more. On Mac OS X, include TargetConditionals.h, set some pragmas, define COPY_RESOURCE_FORK, and error out if TARGET_RT_MAC_CFM is defined; don't set the old m68k CFM pragmas. Always use PROFILE_USES_PATHS code, don't test or define it. (FSp_profile_init, FSp_profile_init_path): Declare, on Mac OS X. * prof_int.h (NO_SYS_TYPES_H, NO_SYS_STAT_H) [macintosh]: Don't define these. * prof_file.c: Always inclued sys/types.h and sys/stat.h. (GetMacOSTempFilespec): Deleted. (profile_flush_file_data) [COPY_RESOURCE_FORK]: Copy Mac resource fork from old file to new before renaming. (rw_access, profile_update_file_data, profile_flush_file_data, profile_free_file_data): Assume PROFILE_USES_PATHS, don't test. * prof_init.c (profile_ser_size, profile_ser_externalize, profile_ser_internalize): Likewise. (FSp_profile_init, FSp_profile_init_path): Define, on MacOS X. * profile.exp: Add FSp_* functions. * prof_file.c (r_access): New function. (profile_open_file): Use it. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15073 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile/prof_init.c')
-rw-r--r--src/util/profile/prof_init.c88
1 files changed, 70 insertions, 18 deletions
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index 46ebf2dbd..af7c6a3ec 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -10,6 +10,10 @@
#endif
#include <errno.h>
+#if TARGET_OS_MAC
+#include <Kerberos/FullPOSIXPath.h>
+#endif
+
#include "prof_int.h"
/* Find a 4-byte integer type */
@@ -125,6 +129,72 @@ profile_init_path(filepath, ret_profile)
return retval;
}
+#if TARGET_OS_MAC
+KRB5_DLLIMP errcode_t KRB5_CALLCONV
+FSp_profile_init(files, ret_profile)
+ const FSSpec* files;
+ profile_t *ret_profile;
+{
+ UInt32 fileCount = 0;
+ const FSSpec* nextSpec;
+ char** pathArray = NULL;
+ UInt32 i;
+ errcode_t retval = 0;
+
+ for (nextSpec = files; ; nextSpec++) {
+ if ((nextSpec -> vRefNum == 0) &&
+ (nextSpec -> parID == 0) &&
+ (StrLength (nextSpec -> name) == 0))
+ break;
+ fileCount++;
+ }
+
+ pathArray = malloc ((fileCount + 1) * sizeof (char*));
+ if (pathArray == NULL) {
+ retval = ENOMEM;
+ }
+
+ if (retval == 0) {
+ for (i = 0; i < fileCount + 1; i++) {
+ pathArray [i] = NULL;
+ }
+
+ for (i = 0; i < fileCount; i++) {
+ OSErr err = FSpGetFullPOSIXPath (&files [i], &pathArray [i]);
+ if (err == memFullErr) {
+ retval = ENOMEM;
+ break;
+ } else if (err != noErr) {
+ retval = ENOENT;
+ break;
+ }
+ }
+ }
+
+ if (retval == 0) {
+ retval = profile_init (pathArray, ret_profile);
+ }
+
+ if (pathArray != NULL) {
+ for (i = 0; i < fileCount; i++) {
+ if (pathArray [i] != 0)
+ free (pathArray [i]);
+ }
+ free (pathArray);
+ }
+
+ return retval;
+}
+
+KRB5_DLLIMP errcode_t KRB5_CALLCONV
+FSp_profile_init_path(files, ret_profile)
+ const FSSpec* files;
+ profile_t *ret_profile;
+{
+ return FSp_profile_init (files, ret_profile);
+}
+#endif /* TARGET_OS_MAC */
+
errcode_t KRB5_CALLCONV
profile_flush(profile)
profile_t profile;
@@ -186,12 +256,8 @@ errcode_t profile_ser_size(unused, profile, sizep)
required = 3*sizeof(prof_int32);
for (pfp = profile->first_file; pfp; pfp = pfp->next) {
required += sizeof(prof_int32);
-#ifdef PROFILE_USES_PATHS
if (pfp->data->filespec)
required += strlen(pfp->data->filespec);
-#else
- required += sizeof (profile_filespec_t);
-#endif
}
*sizep += required;
return 0;
@@ -237,7 +303,6 @@ errcode_t profile_ser_externalize(unused, profile, bufpp, remainp)
pack_int32(PROF_MAGIC_PROFILE, &bp, &remain);
pack_int32(fcount, &bp, &remain);
for (pfp = profile->first_file; pfp; pfp = pfp->next) {
-#ifdef PROFILE_USES_PATHS
slen = (pfp->data->filespec) ?
(prof_int32) strlen(pfp->data->filespec) : 0;
pack_int32(slen, &bp, &remain);
@@ -246,13 +311,6 @@ errcode_t profile_ser_externalize(unused, profile, bufpp, remainp)
bp += slen;
remain -= (size_t) slen;
}
-#else
- slen = sizeof (FSSpec);
- pack_int32(slen, &bp, &remain);
- memcpy (bp, &(pfp->data->filespec), (size_t) slen);
- bp += slen;
- remain -= (size_t) slen;
-#endif
}
pack_int32(PROF_MAGIC_PROFILE, &bp, &remain);
retval = 0;
@@ -317,15 +375,11 @@ errcode_t profile_ser_internalize(unused, profilep, bufpp, remainp)
memset(flist, 0, sizeof(char *) * (fcount+1));
for (i=0; i<fcount; i++) {
if (!unpack_int32(&tmp, &bp, &remain)) {
-#ifdef PROFILE_USES_PATHS
flist[i] = (char *) malloc((size_t) (tmp+1));
if (!flist[i])
goto cleanup;
memcpy(flist[i], bp, (size_t) tmp);
flist[i][tmp] = '\0';
-#else
- memcpy (&flist[i], bp, (size_t) tmp);
-#endif
bp += tmp;
remain -= (size_t) tmp;
}
@@ -346,12 +400,10 @@ errcode_t profile_ser_internalize(unused, profilep, bufpp, remainp)
cleanup:
if (flist) {
-#ifdef PROFILE_USES_PATHS
for (i=0; i<fcount; i++) {
if (flist[i])
free(flist[i]);
}
-#endif
free(flist);
}
return(retval);