return REGERR_OK;
reg = ((REGHANDLE*)hReg)->pReg;   err = nr_Lock( reg ); if ( err != REGERR_OK ) return err;  PR_Lock(reglist_lock); XP_STRCPY(tempfilename, reg->filename); err = nr_createTempRegName(tempfilename, sizeof(tempfilename)); if ( err != REGERR_OK ) goto safe_exit;   fh = vr_fileOpen(tempfilename, XP_FILE_WRITE_BIN); if ( !VALID_FILEHANDLE(fh) ) { err = REGERR_FAIL; goto safe_exit; } XP_FileClose(fh);  err = NR_RegOpen(tempfilename, &hRegTemp); if ( err != REGERR_OK ) goto safe_exit; bCloseTempFile = TRUE;   XP_STRCPY(oldfilename, reg->filename); err = nr_createTempRegName(oldfilename, sizeof(oldfilename)); if ( err != REGERR_OK ) goto safe_exit;  key = ROOTKEY_PRIVATE; err = nr_addNodesToNewReg( hReg, key, hRegTemp, userData, fn); if ( err != REGERR_OK  ) goto safe_exit; key = ROOTKEY_VERSIONS; err = nr_addNodesToNewReg( hReg, key, hRegTemp, userData, fn); if ( err != REGERR_OK  ) goto safe_exit; key = ROOTKEY_COMMON; err = nr_addNodesToNewReg( hReg, key, hRegTemp, userData, fn); if ( err != REGERR_OK  ) goto safe_exit; key = ROOTKEY_USERS; err = nr_addNodesToNewReg( hReg, key, hRegTemp, userData, fn); if ( err != REGERR_OK  ) goto safe_exit;  err = NR_RegClose(hRegTemp); bCloseTempFile = FALSE;   XP_FileClose(reg->fh);   err = nr_RenameFile(reg->filename, oldfilename); if ( err == -1 ) {  remove(tempfilename); reg->fh = vr_fileOpen(reg->filename, XP_FILE_UPDATE_BIN); goto safe_exit; }   err = nr_RenameFile(tempfilename, reg->filename); if ( err == -1 ) {  err = nr_RenameFile(oldfilename, reg->filename); remove(tempfilename); reg->fh = vr_fileOpen(reg->filename, XP_FILE_UPDATE_BIN); goto safe_exit;  } else { remove(oldfilename); } reg->fh = vr_fileOpen(reg->filename, XP_FILE_UPDATE_BIN);  safe_exit: if ( bCloseTempFile ) { NR_RegClose(hRegTemp); } PR_Unlock( reglist_lock ); nr_Unlock(reg); return err; #endif
VR_INTERFACE(REGERR) NR_RegGetUsername(char **name){    /* XXX: does this need locking? */    if ( name == NULL )        return REGERR_PARAM;    *name = XP_STRDUP(nr_GetUsername());    if ( NULL == *name )        return REGERR_MEMORY;    return REGERR_OK;}