/*++ Copyright (c) 1992 Microsoft Corporation Module Name: ImpGet.c Abstract: Read an API record with import directory info from the registry. Callable even if the replicator service is not started. Author: John Rogers (JohnRo) 09-Nov-1992 Environment: User Mode - Win32 Revision History: 09-Nov-1992 JohnRo Created for RAID 7962: Repl APIs in wrong role kill svc. --*/ // These must be included first: //#include // Needed by temporarily. //#include // Needed by temporarily. #include // IN, DWORD, etc. #include // NET_API_STATUS, etc. //#include // Needed by . //#include // Needed by . //#include // Needed by . // These may be included in any order: //#include // LPNET_CONFIG_HANDLE, Netp config routines. //#include // SECT_NT_ equates. #include // ReplIsDirNameValid(). #include // My ptototype, ImportDirIsApiRecordValid(), etc. #include // NetApiBufferFree(). //#include // My prototypes, etc. //#include // SERVICE_ equates. #include // NetpAssert(). //#include // NetpSetParmError() macro. //#include // NET_REMOTE macros. //#include // PREFIX_ equates. //#include // MIDL-generated NetrRepl prototypes. //#include // GENERIC_INFO_CONTAINER, etc. //#include // NetpReplImportDirStructureInfo(). #include // ERROR_ equates, NO_ERROR. NET_API_STATUS ImportDirGetApiRecord ( IN LPTSTR UncServerName OPTIONAL, IN LPTSTR DirName, IN DWORD Level, OUT LPBYTE * BufPtr ) { NET_API_STATUS ApiStatus; LPVOID ApiRecord = NULL; DWORD LockCount; LPTSTR MasterName; DWORD State; LPBYTE StringLocation; // Points just past top of data. DWORD TimeOfFirstLock; // Seconds since 1970. DWORD TimeOfLastUpdate; // Seconds since 1970. TCHAR UncMaster[UNCLEN+1]; if ( !ReplIsDirNameValid( DirName )) { ApiStatus = ERROR_INVALID_PARAMETER; goto Cleanup; } else if ( !ImportDirIsLevelValid( Level ) ) { ApiStatus = ERROR_INVALID_LEVEL; goto Cleanup; } else if (BufPtr == NULL) { ApiStatus = ERROR_INVALID_PARAMETER; goto Cleanup; } // // Read config data for a single import directory. // ApiStatus = ImportDirReadConfigData ( UncServerName, DirName, & State, UncMaster, & TimeOfLastUpdate, // Seconds since 1970. & LockCount, & TimeOfFirstLock ); // Seconds since 1970. if (ApiStatus != NO_ERROR) { goto Cleanup; } ApiStatus = ImportDirAllocApiRecords ( Level, 1, // only 1 record. (LPBYTE *) & ApiRecord, // alloc and set ptr (LPBYTE *) & StringLocation ); // Points just past top of data. if (ApiStatus != NO_ERROR) { goto Cleanup; } NetpAssert( ApiRecord != NULL ); if (*UncMaster) { MasterName = UncMaster + 2; // Chg from UNC to non. } else { MasterName = NULL; } ApiStatus = ImportDirBuildApiRecord ( Level, DirName, State, MasterName, TimeOfLastUpdate, // Seconds since 1970 LockCount, TimeOfFirstLock, // Seconds since 1970. ApiRecord, (LPBYTE *) (LPVOID) & StringLocation); NetpAssert( ApiStatus == NO_ERROR ); // We checked all parms. Cleanup: if (ApiStatus == NO_ERROR) { NetpAssert( ApiRecord != NULL ); *BufPtr = ApiRecord; } else { *BufPtr = NULL; if (ApiRecord != NULL) { (VOID) NetApiBufferFree( ApiRecord ); } } return ApiStatus; }