From ddf8086d83e4c130df0ac73c849d94e4e1ee2fe7 Mon Sep 17 00:00:00 2001 From: "dveditz%netscape.com" Date: Mon, 18 Oct 1999 12:06:19 +0000 Subject: [PATCH] generate unique regkeys (6986) git-svn-id: svn://10.0.0.236/trunk@50979 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libreg/include/NSReg.h | 19 ++++++++ mozilla/modules/libreg/macbuild/libreg.exp | 1 + mozilla/modules/libreg/src/reg.c | 50 ++++++++++++++++++++++ mozilla/modules/libreg/src/reg.h | 1 + 4 files changed, 71 insertions(+) diff --git a/mozilla/modules/libreg/include/NSReg.h b/mozilla/modules/libreg/include/NSReg.h index d8e10b16d13..881f1f2a5a7 100644 --- a/mozilla/modules/libreg/include/NSReg.h +++ b/mozilla/modules/libreg/include/NSReg.h @@ -210,6 +210,25 @@ VR_INTERFACE(REGERR) NR_RegSetUsername( const char *name /* name of current user */ ); + +/* --------------------------------------------------------------------- + * NR_RegGetUniqueName + * + * Returns a unique name that can be used for anonymous key/value names + * + * Parameters: + * hReg - handle of open registry + * outbuf - where to put the string + * buflen - how big the buffer is + * --------------------------------------------------------------------- + */ +VR_INTERFACE(REGERR) NR_RegGetUniqueName( + HREG hReg, /* handle of open registry */ + char* outbuf, /* buffer to hold key name */ + uint32 buflen /* size of buffer */ + ); + + /* --------------------------------------------------------------------- * DO NOT USE -- Will be removed * --------------------------------------------------------------------- diff --git a/mozilla/modules/libreg/macbuild/libreg.exp b/mozilla/modules/libreg/macbuild/libreg.exp index 4acb6a50437..8937fbce813 100644 --- a/mozilla/modules/libreg/macbuild/libreg.exp +++ b/mozilla/modules/libreg/macbuild/libreg.exp @@ -21,6 +21,7 @@ NR_RegOpen NR_RegFlush NR_RegSetUsername NR_RegGetUsername +NR_RegGetUniqueName VR_SetRegDirectory VR_CreateRegistry VR_PackRegistry diff --git a/mozilla/modules/libreg/src/reg.c b/mozilla/modules/libreg/src/reg.c index 928f3d458d4..3071ffd1278 100644 --- a/mozilla/modules/libreg/src/reg.c +++ b/mozilla/modules/libreg/src/reg.c @@ -63,6 +63,7 @@ #include "prtypes.h" #include "prlog.h" #include "prerror.h" +#include "prprf.h" #endif /*STANDALONE_REGISTRY*/ @@ -2050,6 +2051,10 @@ static REGERR nr_RegOpen( char *filename, HREG *hReg ) /* ...other misc initialization */ pReg->refCount = 0; +#ifndef STANDALONE_REGISTRY + pReg->uniqkey = PR_Now(); +#endif + status = nr_InitStdRkeys( pReg ); if ( status == REGERR_OK ) { /* ...and add it to the list */ @@ -2254,6 +2259,51 @@ VR_INTERFACE(REGERR) NR_RegSetUsername(const char *name) +#ifndef STANDALONE_REGISTRY +/* --------------------------------------------------------------------- + * NR_RegGetUniqueName + * + * Returns a unique name that can be used for anonymous key/value names + * + * Parameters: + * hReg - handle of open registry + * outbuf - where to put the string + * buflen - how big the buffer is + * --------------------------------------------------------------------- + */ +VR_INTERFACE(REGERR) NR_RegGetUniqueName(HREG hReg, char* outbuf, uint32 buflen) +{ + PRUint64 one; + PRUint64 tmp; + REGERR err; + REGFILE* reg; + + /* verify parameters */ + err = VERIFY_HREG( hReg ); + if ( err != REGERR_OK ) + return err; + + reg = ((REGHANDLE*)hReg)->pReg; + + if ( !outbuf ) + return REGERR_PARAM; + + if ( buflen <= (sizeof(PRUint64)*2) ) + return REGERR_BUFTOOSMALL; + + PR_snprintf(outbuf,buflen,"%llx",reg->uniqkey); + + one = LL_INIT(0,1); + tmp = reg->uniqkey; + + LL_ADD(reg->uniqkey, tmp, one); + return REGERR_OK; +} +#endif + + + + /* --------------------------------------------------------------------- * NR_RegOpen - Open a netscape XP registry * diff --git a/mozilla/modules/libreg/src/reg.h b/mozilla/modules/libreg/src/reg.h index 3a280bb7855..d0c5eb5d0be 100644 --- a/mozilla/modules/libreg/src/reg.h +++ b/mozilla/modules/libreg/src/reg.h @@ -163,6 +163,7 @@ typedef struct _regfile struct _regfile *prev; #ifndef STANDALONE_REGISTRY PRLock *lock; + PRUint64 uniqkey; #endif } REGFILE;