1/* 2 * prof_FSp_glue.c --- Deprecated FSSpec functions. Mac-only. 3 */ 4 5#include "prof_int.h" 6 7#include <limits.h> 8 9#include <CoreServices/CoreServices.h> 10 11#ifdef __cplusplus 12extern "C" { 13#endif 14OSStatus FSSpecToPOSIXPath (const FSSpec *inSpec, char *ioPath, unsigned long inPathLength); 15OSStatus POSIXPathToFSSpec (const char *inPath, FSSpec *outSpec); 16#ifdef __cplusplus 17} 18#endif 19 20 21long KRB5_CALLCONV FSp_profile_init (const FSSpec* files, profile_t *ret_profile); 22 23long KRB5_CALLCONV FSp_profile_init_path (const FSSpec* files, profile_t *ret_profile); 24 25errcode_t KRB5_CALLCONV 26FSp_profile_init(files, ret_profile) 27 const FSSpec* files; 28 profile_t *ret_profile; 29{ 30 unsigned int fileCount = 0; 31 const FSSpec *nextSpec; 32 profile_filespec_t *pathArray = NULL; 33 unsigned int i; 34 errcode_t retval = 0; 35 36 for (nextSpec = files; ; nextSpec++) { 37#if 0 38 if ((nextSpec -> vRefNum == 0) && 39 (nextSpec -> parID == 0) && 40 (StrLength (nextSpec -> name) == 0)) 41 break; 42#endif 43 fileCount++; 44 } 45 46 pathArray = (profile_filespec_t *) malloc ((fileCount + 1) * sizeof(const_profile_filespec_t)); 47 if (pathArray == NULL) { 48 retval = ENOMEM; 49 } 50 51 if (retval == 0) { 52 for (i = 0; i < fileCount + 1; i++) { 53 pathArray [i] = NULL; 54 } 55 } 56 57 if (retval == 0) { 58 for (i = 0; i < fileCount; i++) { 59 OSStatus err = noErr; 60 61 if (err == noErr) { 62 pathArray[i] = (char *) malloc (sizeof(char) * PATH_MAX); 63 if (pathArray[i] == NULL) { 64 err = memFullErr; 65 } 66 } 67 /* convert the FSSpec to an path */ 68 if (err == noErr) { 69 err = FSSpecToPOSIXPath (&files[i], pathArray[i], PATH_MAX); 70 } 71 72 if (err == memFullErr) { 73 retval = ENOMEM; 74 break; 75 } else if (err != noErr) { 76 retval = ENOENT; 77 break; 78 } 79 } 80 } 81 82 if (retval == 0) { 83 retval = profile_init ((const_profile_filespec_t *) pathArray, 84 ret_profile); 85 } 86 87 if (pathArray != NULL) { 88 for (i = 0; i < fileCount; i++) { 89 if (pathArray [i] != 0) 90 free (pathArray [i]); 91 } 92 free (pathArray); 93 } 94 95 return retval; 96} 97 98errcode_t KRB5_CALLCONV 99FSp_profile_init_path(files, ret_profile) 100 const FSSpec* files; 101 profile_t *ret_profile; 102{ 103 return FSp_profile_init (files, ret_profile); 104} 105