long CreateLWIComputer( PCSTR szName, PCSTR szShortname, PCSTR szComment, PCSTR szGUID, PCSTR szEthernetID, PCSTR szIPaddress, PCSTR szKeyword, PMCXVALUE pMCXValues, PLWICOMPUTER* ppLWIComputer ) { long macError = eDSNoErr; PLWICOMPUTER pComputer = NULL; macError = LwAllocateMemory(sizeof(LWICOMPUTER), (PVOID*)&pComputer); GOTO_CLEANUP_ON_MACERROR(macError); if (szName) { macError = LwAllocateString(szName, &pComputer->name); GOTO_CLEANUP_ON_MACERROR(macError); } if (szShortname) { macError = LwAllocateString(szShortname, &pComputer->shortname); GOTO_CLEANUP_ON_MACERROR(macError); } if (szComment) { macError = LwAllocateString(szComment, &pComputer->comment); GOTO_CLEANUP_ON_MACERROR(macError); } if (szGUID) { macError = LwAllocateString(szGUID, &pComputer->guid); GOTO_CLEANUP_ON_MACERROR(macError); } if (szEthernetID) { macError = LwAllocateString(szEthernetID, &pComputer->ethernetID); GOTO_CLEANUP_ON_MACERROR(macError); } if (szIPaddress) { macError = LwAllocateString(szIPaddress, &pComputer->IPaddress); GOTO_CLEANUP_ON_MACERROR(macError); } if (szKeyword) { macError = LwAllocateMemory(sizeof(pComputer->keywords[0]) * 2, (PVOID*)&pComputer->keywords); GOTO_CLEANUP_ON_MACERROR(macError); macError = LwAllocateString(szKeyword, &pComputer->keywords[0]); GOTO_CLEANUP_ON_MACERROR(macError); } if (pMCXValues) { macError = CopyMCXValueList(pMCXValues, &pComputer->pMCXValues); GOTO_CLEANUP_ON_MACERROR(macError); } *ppLWIComputer = pComputer; pComputer = NULL; cleanup: if (pComputer) { FreeLWIComputer(pComputer); } return macError; }
long CreateLWIUser( PCSTR pszName, PCSTR pszDisplayName, PCSTR pszNameAsQueried, PCSTR pszPassword, PCSTR pszClass, PCSTR pszGecos, PCSTR pszNFSHomeDirectory, PCSTR pszHomeDirectory, PCSTR pszOrigNFSHomeDirectory, PCSTR pszOrigHomeDirectory, PCSTR pszShell, uid_t uid, gid_t gid, PMCXVALUE pMCXValues, PAD_USER_ATTRIBUTES padUserADInfo, PLWIUSER* ppLWIUser ) { long macError = eDSNoErr; PLWIUSER pUser = NULL; macError = LwAllocateMemory(sizeof(LWIUSER), (PVOID*)&pUser); GOTO_CLEANUP_ON_MACERROR(macError); if (pszName) { macError = LwAllocateString(pszName, &pUser->pw_name); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszDisplayName) { macError = LwAllocateString(pszDisplayName, &pUser->pw_display_name); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszNameAsQueried) { macError = LwAllocateString(pszNameAsQueried, &pUser->pw_name_as_queried); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszPassword) { macError = LwAllocateString(pszPassword, &pUser->pw_passwd); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszClass) { macError = LwAllocateString(pszClass, &pUser->pw_class); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszGecos) { macError = LwAllocateString(pszGecos, &pUser->pw_gecos); GOTO_CLEANUP_ON_MACERROR(macError); } if (!pszNFSHomeDirectory && pszHomeDirectory && *pszHomeDirectory) { macError = LwAllocateString(pszHomeDirectory, &pUser->pw_nfs_home_dir); GOTO_CLEANUP_ON_MACERROR(macError); } else if (pszNFSHomeDirectory) { macError = LwAllocateString(pszNFSHomeDirectory, &pUser->pw_nfs_home_dir); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszHomeDirectory) { macError = LwAllocateString(pszHomeDirectory, &pUser->pw_home_dir); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszOrigNFSHomeDirectory) { macError = LwAllocateString(pszOrigNFSHomeDirectory, &pUser->pw_orig_nfs_home_dir); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszOrigHomeDirectory) { macError = LwAllocateString(pszOrigHomeDirectory, &pUser->pw_orig_home_dir); GOTO_CLEANUP_ON_MACERROR(macError); } if (pszShell) { macError = LwAllocateString(pszShell, &pUser->pw_shell); GOTO_CLEANUP_ON_MACERROR(macError); } if (pMCXValues) { macError = CopyMCXValueList(pMCXValues, &pUser->pMCXValues); GOTO_CLEANUP_ON_MACERROR(macError); } if (padUserADInfo) { macError = CopyADUserInfo(padUserADInfo, &pUser->padUserInfo); GOTO_CLEANUP_ON_MACERROR(macError); } pUser->pw_uid = uid; pUser->pw_gid = gid; *ppLWIUser = pUser; pUser = NULL; cleanup: FreeLWIUser(pUser); return macError; }