зеркало из https://github.com/mozilla/pjs.git
- Threading fixed. Changed member that stored error from nsRegistry
to be an automatic variable. - Using XPCOM_ComponentRegistry for OpenWellknownRegistry()
This commit is contained in:
Родитель
4418e22473
Коммит
91b58aabba
|
@ -77,7 +77,6 @@ struct nsRegistry : public nsIRegistry {
|
|||
|
||||
protected:
|
||||
HREG mReg; // Registry handle.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
PRLock *mregLock; // libreg isn't threadsafe. Use locks to synchronize.
|
||||
}; // nsRegistry
|
||||
|
||||
|
@ -115,16 +114,17 @@ struct nsRegSubtreeEnumerator : public nsIEnumerator {
|
|||
|
||||
// ctor/dtor
|
||||
nsRegSubtreeEnumerator( HREG hReg, RKEY rKey, PRBool all );
|
||||
virtual ~nsRegSubtreeEnumerator();
|
||||
|
||||
protected:
|
||||
NS_IMETHOD advance(); // Implementation file; does appropriate NR_RegEnum call.
|
||||
PRLock *mregLock;
|
||||
HREG mReg; // Handle to registry we're affiliated with.
|
||||
RKEY mKey; // Base key being enumerated.
|
||||
REGENUM mEnum; // Corresponding libreg "enumerator".
|
||||
REGENUM mNext; // Lookahead value.
|
||||
uint32 mStyle; // Style (indicates all or some);
|
||||
PRBool mDone; // Done flag.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
}; // nsRegSubtreeEnumerator
|
||||
|
||||
|
||||
|
@ -158,12 +158,13 @@ struct nsRegistryNode : public nsIRegistryNode {
|
|||
|
||||
// ctor
|
||||
nsRegistryNode( HREG hReg, RKEY key, REGENUM slot );
|
||||
virtual ~nsRegistryNode();
|
||||
|
||||
protected:
|
||||
HREG mReg; // Handle to registry this node is part of.
|
||||
PRLock *mregLock;
|
||||
RKEY mKey; // Key this node is under.
|
||||
REGENUM mEnum; // Copy of corresponding content of parent enumerator.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
char mName[MAXREGPATHLEN]; // Buffer to hold name.
|
||||
}; // nsRegistryNode
|
||||
|
||||
|
@ -183,13 +184,14 @@ struct nsRegistryValue : public nsIRegistryValue {
|
|||
|
||||
// ctor
|
||||
nsRegistryValue( HREG hReg, RKEY key, REGENUM slot );
|
||||
virtual ~nsRegistryValue();
|
||||
|
||||
protected:
|
||||
nsresult getInfo(); // Get registry info.
|
||||
HREG mReg; // Handle to registry this node is part of.
|
||||
PRLock *mregLock;
|
||||
RKEY mKey; // Key this node is under.
|
||||
REGENUM mEnum; // Copy of corresponding content of parent enumerator.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
REGINFO mInfo; // Value info.
|
||||
char mName[MAXREGNAMELEN]; // Buffer to hold name.
|
||||
}; // nsRegistryValue
|
||||
|
@ -385,6 +387,7 @@ nsRegistry::~nsRegistry() {
|
|||
| it if so. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
||||
REGERR err = REGERR_OK;
|
||||
// Check for default.
|
||||
if( !regFile ) {
|
||||
return OpenDefault();
|
||||
|
@ -393,10 +396,10 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
Close();
|
||||
// Open specified registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*----------------------------- nsRegistry::OpenWellKnownRegistry --------------
|
||||
|
@ -404,19 +407,19 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
| to see if a registry file is already open and close it if so. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Ensure existing registry is closed.
|
||||
Close();
|
||||
|
||||
nsSpecialSystemDirectory reg(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
nsSpecialSystemDirectory *registryLocation = NULL;
|
||||
PRBool foundReg = PR_FALSE;
|
||||
|
||||
switch ( (WellKnownRegistry) regid ) {
|
||||
case ApplicationComponentRegistry:
|
||||
#ifdef XP_MAC
|
||||
reg += "Component Registry";
|
||||
#else
|
||||
reg += "component.reg";
|
||||
#endif /* XP_MAC */
|
||||
registryLocation =
|
||||
new nsSpecialSystemDirectory(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentRegistry);
|
||||
if (registryLocation != NULL)
|
||||
foundReg = PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -431,17 +434,19 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
|||
// WARNING:
|
||||
// regNSPRPath and regFile need to have the same scope
|
||||
// since the regFile will point to data in regNSPRPath
|
||||
nsNSPRPath regNSPRPath(reg);
|
||||
nsNSPRPath regNSPRPath(*registryLocation);
|
||||
const char *regFile = (const char *) regNSPRPath;
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
printf("nsRegistry: Opening std registry %s\n", regFile);
|
||||
#endif /* DEBUG_dp */
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Cleanup
|
||||
delete registryLocation;
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::OpenDefault ---------------------------
|
||||
|
@ -449,28 +454,29 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
|||
| that is done by passing a null file name pointer to NR_RegOpen. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::OpenDefault() {
|
||||
REGERR err = REGERR_OK;
|
||||
// Ensure existing registry is closed.
|
||||
Close();
|
||||
// Open default registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen( 0, &mReg );
|
||||
err = NR_RegOpen( 0, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*----------------------------- nsRegistry::Close ------------------------------
|
||||
| Tests the mReg handle and if non-null, closes the registry via NR_RegClose. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Close() {
|
||||
mErr = REGERR_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
if( mReg ) {
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegClose( mReg );
|
||||
err = NR_RegClose( mReg );
|
||||
PR_Unlock(mregLock);
|
||||
mReg = 0;
|
||||
}
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*--------------------------- nsRegistry::GetString ----------------------------
|
||||
|
@ -479,6 +485,8 @@ NS_IMETHODIMP nsRegistry::Close() {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result ) {
|
||||
*result = 0; // Clear result.
|
||||
|
@ -498,10 +506,10 @@ NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **resul
|
|||
if( *result ) {
|
||||
// Get string from registry into result buffer.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryString( mReg,(RKEY)baseKey,(char*)path, *result, length+1 );
|
||||
err = NR_RegGetEntryString( mReg,(RKEY)baseKey,(char*)path, *result, length+1 );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
// Test result.
|
||||
if( rv != NS_OK ) {
|
||||
// Didn't get result, free buffer.
|
||||
|
@ -527,14 +535,13 @@ NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **resul
|
|||
| Simply sets the registry contents using NR_RegSetEntryString. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetString( Key baseKey, const char *path, const char *value ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntryString( mReg,(RKEY)baseKey,(char*)path,(char*)value );
|
||||
err = NR_RegSetEntryString( mReg,(RKEY)baseKey,(char*)path,(char*)value );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*---------------------------- nsRegistry::GetInt ------------------------------
|
||||
|
@ -544,6 +551,7 @@ NS_IMETHODIMP nsRegistry::SetString( Key baseKey, const char *path, const char *
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result ) {
|
||||
|
@ -557,10 +565,10 @@ NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result )
|
|||
uint32 len = sizeof *result;
|
||||
// Get int from registry into result field.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, result, &len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, result, &len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
// They asked for the wrong type of value.
|
||||
rv = NS_ERROR_REG_BADTYPE;
|
||||
|
@ -576,10 +584,10 @@ NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result )
|
|||
| Write out the value as a one-element int32 array, using NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,
|
||||
err = NR_RegSetEntry( mReg,
|
||||
(RKEY)baseKey,
|
||||
(char*)path,
|
||||
REGTYPE_ENTRY_INT32_ARRAY,
|
||||
|
@ -587,8 +595,7 @@ NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
|||
sizeof value );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*--------------------------- nsRegistry::GetBytes -----------------------------
|
||||
|
@ -596,6 +603,7 @@ NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result, uint32 *len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result && len ) {
|
||||
|
@ -609,10 +617,10 @@ NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result
|
|||
// Get bytes from registry into result field.
|
||||
*result = PR_Malloc(*len);
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
// They asked for the wrong type of value.
|
||||
rv = NS_ERROR_REG_BADTYPE;
|
||||
|
@ -628,15 +636,14 @@ NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result
|
|||
| Set the contents at the specified registry location, using NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetBytes( Key baseKey, const char *path, void *value, uint32 len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
err = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
REGTYPE_ENTRY_BYTES, value, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result;
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::GetIntArray ---------------------------
|
||||
|
@ -646,6 +653,7 @@ NS_IMETHODIMP nsRegistry::SetBytes( Key baseKey, const char *path, void *value,
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **result, uint32 *len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result && len ) {
|
||||
|
@ -666,14 +674,14 @@ NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **re
|
|||
if( *result ) {
|
||||
// Get array from registry into result field.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Convert size in bytes to array dimension.
|
||||
*len /= sizeof(int32);
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
// Free buffer that we allocated(error will tell caller not to).
|
||||
PR_Free( *result );
|
||||
*result = 0;
|
||||
|
@ -698,45 +706,42 @@ NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **re
|
|||
| size in bytes in order to use NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetIntArray( Key baseKey, const char *path, const int32 *value, uint32 len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Convert array dimension to byte count.
|
||||
uint32 size = len * sizeof(int32);
|
||||
// Set contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
err = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
REGTYPE_ENTRY_INT32_ARRAY,(void*)value, size );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::AddSubtree ----------------------------
|
||||
| Add a new registry subkey with the specified name, using NR_RegAddKey. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::AddSubtree( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Add the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegAddKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegAddKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::AddSubtreeRaw--------------------------
|
||||
| Add a new registry subkey with the specified name, using NR_RegAddKeyRaw |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::AddSubtreeRaw( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Add the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegAddKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegAddKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
|
||||
|
@ -744,14 +749,13 @@ NS_IMETHODIMP nsRegistry::AddSubtreeRaw( Key baseKey, const char *path, Key *res
|
|||
| Deletes the subtree at a given location using NR_RegDeleteKey. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::RemoveSubtree( Key baseKey, const char *path ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Delete the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegDeleteKey( mReg,(RKEY)baseKey,(char*)path );
|
||||
err = NR_RegDeleteKey( mReg,(RKEY)baseKey,(char*)path );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
|
||||
|
@ -760,6 +764,7 @@ NS_IMETHODIMP nsRegistry::RemoveSubtree( Key baseKey, const char *path ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// libreg doesn't delete keys if there are subkeys under the key
|
||||
// Hence we have to recurse through to delete the subtree
|
||||
|
@ -770,7 +775,7 @@ NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
|||
REGENUM state = 0;
|
||||
|
||||
PR_Lock(mregLock);
|
||||
REGERR err = NR_RegGetKeyRaw(mReg, baseKey, (char *)keyname, &key);
|
||||
err = NR_RegGetKeyRaw(mReg, baseKey, (char *)keyname, &key);
|
||||
PR_Unlock(mregLock);
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
|
@ -811,14 +816,15 @@ NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place for the result.
|
||||
if( result ) {
|
||||
// Get key.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -831,14 +837,15 @@ NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetSubtreeRaw( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place for the result.
|
||||
if( result ) {
|
||||
// Get key.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegGetKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -902,18 +909,19 @@ NS_IMETHODIMP nsRegistry::EnumerateAllSubtrees( Key baseKey, nsIEnumerator **res
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetValueType( Key baseKey, const char *path, uint32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get registry info into local structure.
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
err = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
PR_Unlock(mregLock);
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Copy info to user's result value.
|
||||
reginfo2DataType( info, *result );
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -927,18 +935,19 @@ NS_IMETHODIMP nsRegistry::GetValueType( Key baseKey, const char *path, uint32 *r
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetValueLength( Key baseKey, const char *path, uint32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get registry info into local structure.
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
err = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
PR_Unlock(mregLock);
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Copy info to user's result value.
|
||||
reginfo2Length( info, *result );
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -975,14 +984,15 @@ NS_IMETHODIMP nsRegistry::EnumerateValues( Key baseKey, nsIEnumerator **result )
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetCurrentUserName( char **result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get the user name.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetUsername( result );
|
||||
err = NR_RegGetUsername( result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -994,12 +1004,13 @@ NS_IMETHODIMP nsRegistry::GetCurrentUserName( char **result ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetCurrentUserName( const char *name ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the user name.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetUsername( name );
|
||||
err = NR_RegSetUsername( name );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1008,12 +1019,13 @@ NS_IMETHODIMP nsRegistry::SetCurrentUserName( const char *name ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Pack() {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Pack the registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegPack( mReg, 0, 0 );
|
||||
err = NR_RegPack( mReg, 0, 0 );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1023,11 +1035,20 @@ NS_IMETHODIMP nsRegistry::Pack() {
|
|||
------------------------------------------------------------------------------*/
|
||||
nsRegSubtreeEnumerator::nsRegSubtreeEnumerator( HREG hReg, RKEY rKey, PRBool all )
|
||||
: mReg( hReg ), mKey( rKey ), mEnum( 0 ), mNext( 0 ),
|
||||
mStyle( all ? REGENUM_DESCEND : 0 ), mDone( PR_FALSE ), mErr( -1 ) {
|
||||
mStyle( all ? REGENUM_DESCEND : 0 ), mDone( PR_FALSE ) {
|
||||
NS_INIT_REFCNT();
|
||||
// Create a registry lock
|
||||
mregLock = PR_NewLock();
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegSubtreeEnumerator::~nsRegSubtreeEnumerator()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::First ------------------------
|
||||
| Set mEnum to 0; this will cause the next NR_RegEnum call to go to |
|
||||
| the beginning. We then do a Next() call in order to do a "lookahead" to |
|
||||
|
@ -1074,16 +1095,19 @@ nsRegSubtreeEnumerator::Next() {
|
|||
| there are no more subkeys. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegSubtreeEnumerator::advance() {
|
||||
REGERR err = REGERR_OK;
|
||||
char name[MAXREGPATHLEN];
|
||||
uint32 len = sizeof name;
|
||||
mErr = NR_RegEnumSubkeys( mReg, mKey, &mNext, name, len, mStyle );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumSubkeys( mReg, mKey, &mNext, name, len, mStyle );
|
||||
// See if we ran off end.
|
||||
if( mErr == REGERR_NOMORE ) {
|
||||
if( err == REGERR_NOMORE ) {
|
||||
// Remember we've run off end.
|
||||
mDone = PR_TRUE;
|
||||
}
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
nsresult rv = regerr2nsresult( mErr );
|
||||
nsresult rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
};
|
||||
|
||||
|
@ -1154,17 +1178,20 @@ nsRegValueEnumerator::CurrentItem( nsISupports **result ) {
|
|||
| there are no more entries. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegValueEnumerator::advance() {
|
||||
REGERR err = REGERR_OK;
|
||||
char name[MAXREGNAMELEN];
|
||||
uint32 len = sizeof name;
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
mErr = NR_RegEnumEntries( mReg, mKey, &mNext, name, len, &info );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumEntries( mReg, mKey, &mNext, name, len, &info );
|
||||
// See if we ran off end.
|
||||
if( mErr == REGERR_NOMORE ) {
|
||||
if( err == REGERR_NOMORE ) {
|
||||
// Remember we've run off end.
|
||||
mDone = PR_TRUE;
|
||||
}
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
nsresult rv = regerr2nsresult( mErr );
|
||||
nsresult rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
};
|
||||
|
||||
|
@ -1175,28 +1202,40 @@ NS_IMETHODIMP nsRegValueEnumerator::advance() {
|
|||
| our name. We use mErr==-1 to indicate we haven't fetched the name yet. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsRegistryNode::nsRegistryNode( HREG hReg, RKEY key, REGENUM slot )
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ), mErr( -1 ) {
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ){
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mregLock = PR_NewLock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegistryNode::~nsRegistryNode()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistryNode::GetName ---------------------------
|
||||
| If we haven't fetched it yet, get the name of the corresponding subkey now, |
|
||||
| using NR_RegEnumSubkeys. |
|
||||
------------------------------------------------------------------------------*/
|
||||
y------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistryNode::GetName( char **result ) {
|
||||
REGERR err = REGERR_OK;
|
||||
nsresult rv = NS_OK;
|
||||
// Make sure there is a place to put the result.
|
||||
if( result ) {
|
||||
// Test whether we haven't tried to get it yet.
|
||||
if( mErr == -1 ) {
|
||||
if( err == -1 ) {
|
||||
REGENUM temp = mEnum;
|
||||
// Get name.
|
||||
mErr = NR_RegEnumSubkeys( mReg, mKey, &temp, mName, sizeof mName, PR_FALSE );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumSubkeys( mReg, mKey, &temp, mName, sizeof mName, PR_FALSE );
|
||||
PR_Unlock(mregLock);
|
||||
}
|
||||
// Convert result from prior libreg call.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
if( rv == NS_OK || rv == NS_ERROR_REG_NO_MORE ) {
|
||||
// worked, return actual result.
|
||||
*result = PR_strdup( mName );
|
||||
|
@ -1218,11 +1257,19 @@ NS_IMETHODIMP nsRegistryNode::GetName( char **result ) {
|
|||
| Implemented the same way as the nsRegistryNode ctor. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsRegistryValue::nsRegistryValue( HREG hReg, RKEY key, REGENUM slot )
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ), mErr( -1 ) {
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ) {
|
||||
NS_INIT_REFCNT();
|
||||
mregLock = PR_NewLock();
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegistryValue::~nsRegistryValue()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------- nsRegistryValue::GetName ---------------------------
|
||||
| See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. |
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -1295,14 +1342,17 @@ NS_IMETHODIMP nsRegistryValue::GetValueLength( uint32 *result ) {
|
|||
| Call NR_RegEnumEntries to set the mInfo/mName data members. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsresult nsRegistryValue::getInfo() {
|
||||
REGERR err = REGERR_OK;
|
||||
nsresult rv = NS_OK;
|
||||
// Test whether we haven't tried to get it yet.
|
||||
if( mErr == -1 ) {
|
||||
if( err == -1 ) {
|
||||
REGENUM temp = mEnum;
|
||||
// Get name and info.
|
||||
mErr = NR_RegEnumEntries( mReg, mKey, &temp, mName, sizeof mName, &mInfo );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumEntries( mReg, mKey, &temp, mName, sizeof mName, &mInfo );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ struct nsRegistry : public nsIRegistry {
|
|||
|
||||
protected:
|
||||
HREG mReg; // Registry handle.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
PRLock *mregLock; // libreg isn't threadsafe. Use locks to synchronize.
|
||||
}; // nsRegistry
|
||||
|
||||
|
@ -115,16 +114,17 @@ struct nsRegSubtreeEnumerator : public nsIEnumerator {
|
|||
|
||||
// ctor/dtor
|
||||
nsRegSubtreeEnumerator( HREG hReg, RKEY rKey, PRBool all );
|
||||
virtual ~nsRegSubtreeEnumerator();
|
||||
|
||||
protected:
|
||||
NS_IMETHOD advance(); // Implementation file; does appropriate NR_RegEnum call.
|
||||
PRLock *mregLock;
|
||||
HREG mReg; // Handle to registry we're affiliated with.
|
||||
RKEY mKey; // Base key being enumerated.
|
||||
REGENUM mEnum; // Corresponding libreg "enumerator".
|
||||
REGENUM mNext; // Lookahead value.
|
||||
uint32 mStyle; // Style (indicates all or some);
|
||||
PRBool mDone; // Done flag.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
}; // nsRegSubtreeEnumerator
|
||||
|
||||
|
||||
|
@ -158,12 +158,13 @@ struct nsRegistryNode : public nsIRegistryNode {
|
|||
|
||||
// ctor
|
||||
nsRegistryNode( HREG hReg, RKEY key, REGENUM slot );
|
||||
virtual ~nsRegistryNode();
|
||||
|
||||
protected:
|
||||
HREG mReg; // Handle to registry this node is part of.
|
||||
PRLock *mregLock;
|
||||
RKEY mKey; // Key this node is under.
|
||||
REGENUM mEnum; // Copy of corresponding content of parent enumerator.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
char mName[MAXREGPATHLEN]; // Buffer to hold name.
|
||||
}; // nsRegistryNode
|
||||
|
||||
|
@ -183,13 +184,14 @@ struct nsRegistryValue : public nsIRegistryValue {
|
|||
|
||||
// ctor
|
||||
nsRegistryValue( HREG hReg, RKEY key, REGENUM slot );
|
||||
virtual ~nsRegistryValue();
|
||||
|
||||
protected:
|
||||
nsresult getInfo(); // Get registry info.
|
||||
HREG mReg; // Handle to registry this node is part of.
|
||||
PRLock *mregLock;
|
||||
RKEY mKey; // Key this node is under.
|
||||
REGENUM mEnum; // Copy of corresponding content of parent enumerator.
|
||||
REGERR mErr; // Last libreg error code.
|
||||
REGINFO mInfo; // Value info.
|
||||
char mName[MAXREGNAMELEN]; // Buffer to hold name.
|
||||
}; // nsRegistryValue
|
||||
|
@ -385,6 +387,7 @@ nsRegistry::~nsRegistry() {
|
|||
| it if so. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
||||
REGERR err = REGERR_OK;
|
||||
// Check for default.
|
||||
if( !regFile ) {
|
||||
return OpenDefault();
|
||||
|
@ -393,10 +396,10 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
Close();
|
||||
// Open specified registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*----------------------------- nsRegistry::OpenWellKnownRegistry --------------
|
||||
|
@ -404,19 +407,19 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
| to see if a registry file is already open and close it if so. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Ensure existing registry is closed.
|
||||
Close();
|
||||
|
||||
nsSpecialSystemDirectory reg(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
nsSpecialSystemDirectory *registryLocation = NULL;
|
||||
PRBool foundReg = PR_FALSE;
|
||||
|
||||
switch ( (WellKnownRegistry) regid ) {
|
||||
case ApplicationComponentRegistry:
|
||||
#ifdef XP_MAC
|
||||
reg += "Component Registry";
|
||||
#else
|
||||
reg += "component.reg";
|
||||
#endif /* XP_MAC */
|
||||
registryLocation =
|
||||
new nsSpecialSystemDirectory(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentRegistry);
|
||||
if (registryLocation != NULL)
|
||||
foundReg = PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -431,17 +434,19 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
|||
// WARNING:
|
||||
// regNSPRPath and regFile need to have the same scope
|
||||
// since the regFile will point to data in regNSPRPath
|
||||
nsNSPRPath regNSPRPath(reg);
|
||||
nsNSPRPath regNSPRPath(*registryLocation);
|
||||
const char *regFile = (const char *) regNSPRPath;
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
printf("nsRegistry: Opening std registry %s\n", regFile);
|
||||
#endif /* DEBUG_dp */
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Cleanup
|
||||
delete registryLocation;
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::OpenDefault ---------------------------
|
||||
|
@ -449,28 +454,29 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( uint32 regid ) {
|
|||
| that is done by passing a null file name pointer to NR_RegOpen. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::OpenDefault() {
|
||||
REGERR err = REGERR_OK;
|
||||
// Ensure existing registry is closed.
|
||||
Close();
|
||||
// Open default registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegOpen( 0, &mReg );
|
||||
err = NR_RegOpen( 0, &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*----------------------------- nsRegistry::Close ------------------------------
|
||||
| Tests the mReg handle and if non-null, closes the registry via NR_RegClose. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Close() {
|
||||
mErr = REGERR_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
if( mReg ) {
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegClose( mReg );
|
||||
err = NR_RegClose( mReg );
|
||||
PR_Unlock(mregLock);
|
||||
mReg = 0;
|
||||
}
|
||||
return regerr2nsresult( mErr );
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*--------------------------- nsRegistry::GetString ----------------------------
|
||||
|
@ -479,6 +485,8 @@ NS_IMETHODIMP nsRegistry::Close() {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result ) {
|
||||
*result = 0; // Clear result.
|
||||
|
@ -498,10 +506,10 @@ NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **resul
|
|||
if( *result ) {
|
||||
// Get string from registry into result buffer.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryString( mReg,(RKEY)baseKey,(char*)path, *result, length+1 );
|
||||
err = NR_RegGetEntryString( mReg,(RKEY)baseKey,(char*)path, *result, length+1 );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
// Test result.
|
||||
if( rv != NS_OK ) {
|
||||
// Didn't get result, free buffer.
|
||||
|
@ -527,14 +535,13 @@ NS_IMETHODIMP nsRegistry::GetString( Key baseKey, const char *path, char **resul
|
|||
| Simply sets the registry contents using NR_RegSetEntryString. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetString( Key baseKey, const char *path, const char *value ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntryString( mReg,(RKEY)baseKey,(char*)path,(char*)value );
|
||||
err = NR_RegSetEntryString( mReg,(RKEY)baseKey,(char*)path,(char*)value );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*---------------------------- nsRegistry::GetInt ------------------------------
|
||||
|
@ -544,6 +551,7 @@ NS_IMETHODIMP nsRegistry::SetString( Key baseKey, const char *path, const char *
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result ) {
|
||||
|
@ -557,10 +565,10 @@ NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result )
|
|||
uint32 len = sizeof *result;
|
||||
// Get int from registry into result field.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, result, &len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, result, &len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
// They asked for the wrong type of value.
|
||||
rv = NS_ERROR_REG_BADTYPE;
|
||||
|
@ -576,10 +584,10 @@ NS_IMETHODIMP nsRegistry::GetInt( Key baseKey, const char *path, int32 *result )
|
|||
| Write out the value as a one-element int32 array, using NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,
|
||||
err = NR_RegSetEntry( mReg,
|
||||
(RKEY)baseKey,
|
||||
(char*)path,
|
||||
REGTYPE_ENTRY_INT32_ARRAY,
|
||||
|
@ -587,8 +595,7 @@ NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
|||
sizeof value );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*--------------------------- nsRegistry::GetBytes -----------------------------
|
||||
|
@ -596,6 +603,7 @@ NS_IMETHODIMP nsRegistry::SetInt( Key baseKey, const char *path, int32 value ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result, uint32 *len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result && len ) {
|
||||
|
@ -609,10 +617,10 @@ NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result
|
|||
// Get bytes from registry into result field.
|
||||
*result = PR_Malloc(*len);
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
// They asked for the wrong type of value.
|
||||
rv = NS_ERROR_REG_BADTYPE;
|
||||
|
@ -628,15 +636,14 @@ NS_IMETHODIMP nsRegistry::GetBytes( Key baseKey, const char *path, void **result
|
|||
| Set the contents at the specified registry location, using NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetBytes( Key baseKey, const char *path, void *value, uint32 len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
err = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
REGTYPE_ENTRY_BYTES, value, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result;
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::GetIntArray ---------------------------
|
||||
|
@ -646,6 +653,7 @@ NS_IMETHODIMP nsRegistry::SetBytes( Key baseKey, const char *path, void *value,
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **result, uint32 *len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Make sure caller gave us place for result.
|
||||
if( result && len ) {
|
||||
|
@ -666,14 +674,14 @@ NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **re
|
|||
if( *result ) {
|
||||
// Get array from registry into result field.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
err = NR_RegGetEntry( mReg,(RKEY)baseKey,(char*)path, *result, len );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert status.
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Convert size in bytes to array dimension.
|
||||
*len /= sizeof(int32);
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
// Free buffer that we allocated(error will tell caller not to).
|
||||
PR_Free( *result );
|
||||
*result = 0;
|
||||
|
@ -698,45 +706,42 @@ NS_IMETHODIMP nsRegistry::GetIntArray( Key baseKey, const char *path, int32 **re
|
|||
| size in bytes in order to use NR_RegSetEntry. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetIntArray( Key baseKey, const char *path, const int32 *value, uint32 len ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Convert array dimension to byte count.
|
||||
uint32 size = len * sizeof(int32);
|
||||
// Set contents.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
err = NR_RegSetEntry( mReg,(RKEY)baseKey,(char*)path,
|
||||
REGTYPE_ENTRY_INT32_ARRAY,(void*)value, size );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::AddSubtree ----------------------------
|
||||
| Add a new registry subkey with the specified name, using NR_RegAddKey. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::AddSubtree( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Add the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegAddKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegAddKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistry::AddSubtreeRaw--------------------------
|
||||
| Add a new registry subkey with the specified name, using NR_RegAddKeyRaw |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::AddSubtreeRaw( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Add the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegAddKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegAddKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
|
||||
|
@ -744,14 +749,13 @@ NS_IMETHODIMP nsRegistry::AddSubtreeRaw( Key baseKey, const char *path, Key *res
|
|||
| Deletes the subtree at a given location using NR_RegDeleteKey. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::RemoveSubtree( Key baseKey, const char *path ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Delete the subkey.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegDeleteKey( mReg,(RKEY)baseKey,(char*)path );
|
||||
err = NR_RegDeleteKey( mReg,(RKEY)baseKey,(char*)path );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
return rv;
|
||||
return regerr2nsresult( err );
|
||||
}
|
||||
|
||||
|
||||
|
@ -760,6 +764,7 @@ NS_IMETHODIMP nsRegistry::RemoveSubtree( Key baseKey, const char *path ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// libreg doesn't delete keys if there are subkeys under the key
|
||||
// Hence we have to recurse through to delete the subtree
|
||||
|
@ -770,7 +775,7 @@ NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
|||
REGENUM state = 0;
|
||||
|
||||
PR_Lock(mregLock);
|
||||
REGERR err = NR_RegGetKeyRaw(mReg, baseKey, (char *)keyname, &key);
|
||||
err = NR_RegGetKeyRaw(mReg, baseKey, (char *)keyname, &key);
|
||||
PR_Unlock(mregLock);
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
|
@ -811,14 +816,15 @@ NS_IMETHODIMP nsRegistry::RemoveSubtreeRaw( Key baseKey, const char *keyname ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place for the result.
|
||||
if( result ) {
|
||||
// Get key.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -831,14 +837,15 @@ NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetSubtreeRaw( Key baseKey, const char *path, Key *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place for the result.
|
||||
if( result ) {
|
||||
// Get key.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
err = NR_RegGetKeyRaw( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -902,18 +909,19 @@ NS_IMETHODIMP nsRegistry::EnumerateAllSubtrees( Key baseKey, nsIEnumerator **res
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetValueType( Key baseKey, const char *path, uint32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get registry info into local structure.
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
err = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
PR_Unlock(mregLock);
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Copy info to user's result value.
|
||||
reginfo2DataType( info, *result );
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -927,18 +935,19 @@ NS_IMETHODIMP nsRegistry::GetValueType( Key baseKey, const char *path, uint32 *r
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetValueLength( Key baseKey, const char *path, uint32 *result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get registry info into local structure.
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
err = NR_RegGetEntryInfo( mReg,(RKEY)baseKey,(char*)path, &info );
|
||||
PR_Unlock(mregLock);
|
||||
if( mErr == REGERR_OK ) {
|
||||
if( err == REGERR_OK ) {
|
||||
// Copy info to user's result value.
|
||||
reginfo2Length( info, *result );
|
||||
} else {
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -975,14 +984,15 @@ NS_IMETHODIMP nsRegistry::EnumerateValues( Key baseKey, nsIEnumerator **result )
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::GetCurrentUserName( char **result ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Make sure we have a place to put the result.
|
||||
if( result ) {
|
||||
// Get the user name.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegGetUsername( result );
|
||||
err = NR_RegGetUsername( result );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert the result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -994,12 +1004,13 @@ NS_IMETHODIMP nsRegistry::GetCurrentUserName( char **result ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::SetCurrentUserName( const char *name ) {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Set the user name.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegSetUsername( name );
|
||||
err = NR_RegSetUsername( name );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1008,12 +1019,13 @@ NS_IMETHODIMP nsRegistry::SetCurrentUserName( const char *name ) {
|
|||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Pack() {
|
||||
nsresult rv = NS_OK;
|
||||
REGERR err = REGERR_OK;
|
||||
// Pack the registry.
|
||||
PR_Lock(mregLock);
|
||||
mErr = NR_RegPack( mReg, 0, 0 );
|
||||
err = NR_RegPack( mReg, 0, 0 );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1023,11 +1035,20 @@ NS_IMETHODIMP nsRegistry::Pack() {
|
|||
------------------------------------------------------------------------------*/
|
||||
nsRegSubtreeEnumerator::nsRegSubtreeEnumerator( HREG hReg, RKEY rKey, PRBool all )
|
||||
: mReg( hReg ), mKey( rKey ), mEnum( 0 ), mNext( 0 ),
|
||||
mStyle( all ? REGENUM_DESCEND : 0 ), mDone( PR_FALSE ), mErr( -1 ) {
|
||||
mStyle( all ? REGENUM_DESCEND : 0 ), mDone( PR_FALSE ) {
|
||||
NS_INIT_REFCNT();
|
||||
// Create a registry lock
|
||||
mregLock = PR_NewLock();
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegSubtreeEnumerator::~nsRegSubtreeEnumerator()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::First ------------------------
|
||||
| Set mEnum to 0; this will cause the next NR_RegEnum call to go to |
|
||||
| the beginning. We then do a Next() call in order to do a "lookahead" to |
|
||||
|
@ -1074,16 +1095,19 @@ nsRegSubtreeEnumerator::Next() {
|
|||
| there are no more subkeys. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegSubtreeEnumerator::advance() {
|
||||
REGERR err = REGERR_OK;
|
||||
char name[MAXREGPATHLEN];
|
||||
uint32 len = sizeof name;
|
||||
mErr = NR_RegEnumSubkeys( mReg, mKey, &mNext, name, len, mStyle );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumSubkeys( mReg, mKey, &mNext, name, len, mStyle );
|
||||
// See if we ran off end.
|
||||
if( mErr == REGERR_NOMORE ) {
|
||||
if( err == REGERR_NOMORE ) {
|
||||
// Remember we've run off end.
|
||||
mDone = PR_TRUE;
|
||||
}
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
nsresult rv = regerr2nsresult( mErr );
|
||||
nsresult rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
};
|
||||
|
||||
|
@ -1154,17 +1178,20 @@ nsRegValueEnumerator::CurrentItem( nsISupports **result ) {
|
|||
| there are no more entries. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegValueEnumerator::advance() {
|
||||
REGERR err = REGERR_OK;
|
||||
char name[MAXREGNAMELEN];
|
||||
uint32 len = sizeof name;
|
||||
REGINFO info = { sizeof info, 0, 0 };
|
||||
mErr = NR_RegEnumEntries( mReg, mKey, &mNext, name, len, &info );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumEntries( mReg, mKey, &mNext, name, len, &info );
|
||||
// See if we ran off end.
|
||||
if( mErr == REGERR_NOMORE ) {
|
||||
if( err == REGERR_NOMORE ) {
|
||||
// Remember we've run off end.
|
||||
mDone = PR_TRUE;
|
||||
}
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
nsresult rv = regerr2nsresult( mErr );
|
||||
nsresult rv = regerr2nsresult( err );
|
||||
return rv;
|
||||
};
|
||||
|
||||
|
@ -1175,28 +1202,40 @@ NS_IMETHODIMP nsRegValueEnumerator::advance() {
|
|||
| our name. We use mErr==-1 to indicate we haven't fetched the name yet. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsRegistryNode::nsRegistryNode( HREG hReg, RKEY key, REGENUM slot )
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ), mErr( -1 ) {
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ){
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mregLock = PR_NewLock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegistryNode::~nsRegistryNode()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------- nsRegistryNode::GetName ---------------------------
|
||||
| If we haven't fetched it yet, get the name of the corresponding subkey now, |
|
||||
| using NR_RegEnumSubkeys. |
|
||||
------------------------------------------------------------------------------*/
|
||||
y------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistryNode::GetName( char **result ) {
|
||||
REGERR err = REGERR_OK;
|
||||
nsresult rv = NS_OK;
|
||||
// Make sure there is a place to put the result.
|
||||
if( result ) {
|
||||
// Test whether we haven't tried to get it yet.
|
||||
if( mErr == -1 ) {
|
||||
if( err == -1 ) {
|
||||
REGENUM temp = mEnum;
|
||||
// Get name.
|
||||
mErr = NR_RegEnumSubkeys( mReg, mKey, &temp, mName, sizeof mName, PR_FALSE );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumSubkeys( mReg, mKey, &temp, mName, sizeof mName, PR_FALSE );
|
||||
PR_Unlock(mregLock);
|
||||
}
|
||||
// Convert result from prior libreg call.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
if( rv == NS_OK || rv == NS_ERROR_REG_NO_MORE ) {
|
||||
// worked, return actual result.
|
||||
*result = PR_strdup( mName );
|
||||
|
@ -1218,11 +1257,19 @@ NS_IMETHODIMP nsRegistryNode::GetName( char **result ) {
|
|||
| Implemented the same way as the nsRegistryNode ctor. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsRegistryValue::nsRegistryValue( HREG hReg, RKEY key, REGENUM slot )
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ), mErr( -1 ) {
|
||||
: mReg( hReg ), mKey( key ), mEnum( slot ) {
|
||||
NS_INIT_REFCNT();
|
||||
mregLock = PR_NewLock();
|
||||
return;
|
||||
}
|
||||
|
||||
nsRegistryValue::~nsRegistryValue()
|
||||
{
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------- nsRegistryValue::GetName ---------------------------
|
||||
| See nsRegistryNode::GetName; we use NR_RegEnumEntries in this case. |
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -1295,14 +1342,17 @@ NS_IMETHODIMP nsRegistryValue::GetValueLength( uint32 *result ) {
|
|||
| Call NR_RegEnumEntries to set the mInfo/mName data members. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsresult nsRegistryValue::getInfo() {
|
||||
REGERR err = REGERR_OK;
|
||||
nsresult rv = NS_OK;
|
||||
// Test whether we haven't tried to get it yet.
|
||||
if( mErr == -1 ) {
|
||||
if( err == -1 ) {
|
||||
REGENUM temp = mEnum;
|
||||
// Get name and info.
|
||||
mErr = NR_RegEnumEntries( mReg, mKey, &temp, mName, sizeof mName, &mInfo );
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegEnumEntries( mReg, mKey, &temp, mName, sizeof mName, &mInfo );
|
||||
PR_Unlock(mregLock);
|
||||
// Convert result.
|
||||
rv = regerr2nsresult( mErr );
|
||||
rv = regerr2nsresult( err );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче