From a8957c032dac1bcdb02989fc9a72a52a5049b43f Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Tue, 11 Dec 2001 22:41:19 +0000 Subject: [PATCH] big libpref cleanup: remove lots and lots of unused functions git-svn-id: svn://10.0.0.236/trunk@110304 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpref/macbuild/libpref.xml | 92 +-- mozilla/modules/libpref/src/nsPrefService.cpp | 2 +- mozilla/modules/libpref/src/prefapi.cpp | 637 ++---------------- mozilla/modules/libpref/src/prefapi.h | 113 ---- .../libpref/src/prefapi_private_data.h | 35 - 5 files changed, 62 insertions(+), 817 deletions(-) diff --git a/mozilla/modules/libpref/macbuild/libpref.xml b/mozilla/modules/libpref/macbuild/libpref.xml index 2c533e63cb2..adab999ddf9 100644 --- a/mozilla/modules/libpref/macbuild/libpref.xml +++ b/mozilla/modules/libpref/macbuild/libpref.xml @@ -507,7 +507,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0<s + MWFTP_Post_password2643ymd6646adc2pD†è MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -799,10 +799,15 @@ PathRootProject MWProject_PPC_flatrsrcfilename - PPCAsm Panel - 0002000000030002000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000 - + + + MWAssembler_PPC_auxheader0 + MWAssembler_PPC_symmodeMac + MWAssembler_PPC_dialectPPC + MWAssembler_PPC_prefixfile + MWAssembler_PPC_typecheck0 + MWAssembler_PPC_warnings0 + MWAssembler_PPC_casesensitive0 MWRez_Language_maxwidth80 @@ -947,13 +952,6 @@ Library Debug - - Name - macpref.cp - MacOS - Text - Debug - Name JavaScriptDebug.shlb @@ -961,13 +959,6 @@ Library Debug - - Name - MacPrefUtils.cpp - MacOS - Text - Debug - Name NSComponentStartup.o @@ -1017,21 +1008,11 @@ NSComponentStartup.o MacOS - - Name - macpref.cp - MacOS - Name nsPref.cpp MacOS - - Name - MacPrefUtils.cpp - MacOS - Name NSPR20Debug.shlb @@ -1543,7 +1524,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password0<s + MWFTP_Post_password2643ymd6646adc2pD†è MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -1835,10 +1816,15 @@ PathRootProject MWProject_PPC_flatrsrcfilename - PPCAsm Panel - 0002000000030002000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000 - + + + MWAssembler_PPC_auxheader0 + MWAssembler_PPC_symmodeMac + MWAssembler_PPC_dialectPPC + MWAssembler_PPC_prefixfile + MWAssembler_PPC_typecheck0 + MWAssembler_PPC_warnings0 + MWAssembler_PPC_casesensitive0 MWRez_Language_maxwidth80 @@ -1955,20 +1941,6 @@ Library Debug - - Name - macpref.cp - MacOS - Text - - - - Name - MacPrefUtils.cpp - MacOS - Text - - Name JavaScript.shlb @@ -2058,16 +2030,6 @@ nsPref.cpp MacOS - - Name - macpref.cp - MacOS - - - Name - MacPrefUtils.cpp - MacOS - Name InterfacesStubs @@ -2170,20 +2132,6 @@ prefapi.cpp MacOS - mac - - libprefDebug.shlb - Name - macpref.cp - MacOS - - - libprefDebug.shlb - Name - MacPrefUtils.cpp - MacOS - - NS Libraries Optimized diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp index 5d5c815f884..11eebd440e3 100644 --- a/mozilla/modules/libpref/src/nsPrefService.cpp +++ b/mozilla/modules/libpref/src/nsPrefService.cpp @@ -584,7 +584,7 @@ inplaceSortCallback(const void *data1, const void *data2, void *privateData) } //---------------------------------------------------------------------------------------- -extern "C" JSBool pref_InitInitialObjects() +JSBool pref_InitInitialObjects() // Initialize default preference JavaScript buffers from // appropriate TEXT resources //---------------------------------------------------------------------------------------- diff --git a/mozilla/modules/libpref/src/prefapi.cpp b/mozilla/modules/libpref/src/prefapi.cpp index 947cfaa31e1..807fe01d2ab 100644 --- a/mozilla/modules/libpref/src/prefapi.cpp +++ b/mozilla/modules/libpref/src/prefapi.cpp @@ -50,10 +50,6 @@ #include "windows.h" #endif /* _WIN32 */ -#ifdef MOZ_ADMIN_LIB -#include "prefldap.h" -#endif - #ifdef MOZ_SECURITY #include "sechash.h" #endif @@ -65,6 +61,7 @@ #include "prprf.h" #include "nsQuickSort.h" #include "nsString.h" +#include "prlink.h" #ifdef XP_OS2 #define INCL_DOS @@ -76,7 +73,7 @@ extern JSRuntime* PREF_GetJSRuntime(); #define BOGUS_DEFAULT_INT_PREF_VALUE (-5632) #define BOGUS_DEFAULT_BOOL_PREF_VALUE (-2) -void PR_CALLBACK +PR_STATIC_CALLBACK(void) clearPrefEntry(PLDHashTable *table, PLDHashEntryHdr *entry) { PrefHashEntry *pref = NS_STATIC_CAST(PrefHashEntry *, entry); @@ -89,7 +86,7 @@ clearPrefEntry(PLDHashTable *table, PLDHashEntryHdr *entry) memset(entry, 0, table->entrySize); } -PRBool PR_CALLBACK +PR_STATIC_CALLBACK(PRBool) matchPrefEntry(PLDHashTable*, const PLDHashEntryHdr* entry, const void* key) { @@ -110,8 +107,6 @@ PR_STATIC_CALLBACK(JSBool) pref_NativeLockPref(JSContext *cx, JSObject *obj, uns PR_STATIC_CALLBACK(JSBool) pref_NativeUnlockPref(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); PR_STATIC_CALLBACK(JSBool) pref_NativeSetConfig(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); PR_STATIC_CALLBACK(JSBool) pref_NativeGetPref(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); -PR_STATIC_CALLBACK(JSBool) pref_NativeGetLDAPAttr(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); - /*----------------------------------------------------------------------------------------*/ #include "prefapi_private_data.h" @@ -129,26 +124,29 @@ global_resolve(JSContext *cx, JSObject *obj, jsval id) return JS_ResolveStandardClass(cx, obj, id, &resolved); } -JSRuntime * gMochaTaskState = NULL; JSContext * gMochaContext = NULL; -JSObject * gMochaPrefObject = NULL; -JSObject * gGlobalConfigObject = NULL; -JSClass global_class = { +PRBool gErrorOpeningUserPrefs = PR_FALSE; +PLDHashTable gHashTable = { nsnull }; + +static JSRuntime * gMochaTaskState = NULL; +static JSObject * gMochaPrefObject = NULL; +static JSObject * gGlobalConfigObject = NULL; +static JSClass global_class = { "global", 0, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, global_enumerate, global_resolve, JS_ConvertStub, JS_FinalizeStub, JSCLASS_NO_OPTIONAL_MEMBERS }; -JSClass autoconf_class = { +static JSClass autoconf_class = { "PrefConfig", 0, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, JSCLASS_NO_OPTIONAL_MEMBERS }; -JSPropertySpec autoconf_props[] = { +static JSPropertySpec autoconf_props[] = { {0,0,0,0,0} }; -JSFunctionSpec autoconf_methods[] = { +static JSFunctionSpec autoconf_methods[] = { { "pref", pref_NativeDefaultPref, 2,0,0 }, { "defaultPref", pref_NativeDefaultPref, 2,0,0 }, { "user_pref", pref_NativeUserPref, 2,0,0 }, @@ -156,22 +154,18 @@ JSFunctionSpec autoconf_methods[] = { { "unlockPref", pref_NativeUnlockPref, 1,0,0 }, { "config", pref_NativeSetConfig, 2,0,0 }, { "getPref", pref_NativeGetPref, 1,0,0 }, - { "getLDAPAttributes", pref_NativeGetLDAPAttr, 4,0,0 }, { "localPref", pref_NativeDefaultPref, 1,0,0 }, { "localUserPref", pref_NativeUserPref, 2,0,0 }, { "localDefPref", pref_NativeDefaultPref, 2,0,0 }, { NULL, NULL, 0,0,0 } }; -struct CallbackNode* gCallbacks = NULL; -PRBool gErrorOpeningUserPrefs = PR_FALSE; -PRBool gCallbacksEnabled = PR_FALSE; -PRBool gIsAnyPrefLocked = PR_FALSE; -PRBool gLockInfoRead = PR_FALSE; -PLDHashTable gHashTable = { nsnull }; -char * gSavedLine = NULL; -char * gLockFileName = NULL; -char * gLockVendor = NULL; +static struct CallbackNode* gCallbacks = NULL; +static PRBool gCallbacksEnabled = PR_FALSE; +static PRBool gIsAnyPrefLocked = PR_FALSE; +static char * gSavedLine = NULL; +static char * gLockFileName = NULL; +static char * gLockVendor = NULL; static PLDHashTableOps pref_HashTableOps = { @@ -197,10 +191,6 @@ static PLDHashTableOps pref_HashTableOps = { static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action); static PRBool pref_ValueChanged(PrefValue oldValue, PrefValue newValue, PrefType type); -#include "prlink.h" -extern PRLibrary *pref_LoadAutoAdminLib(void); -PRLibrary *gAutoAdminLib = NULL; - /* -- Privates */ struct CallbackNode { char* domain; @@ -210,14 +200,14 @@ struct CallbackNode { }; /* -- Prototypes */ -PrefResult pref_DoCallback(const char* changed_pref); -PRBool pref_VerifyLockFile(char* buf, long buflen); +static PrefResult pref_DoCallback(const char* changed_pref); +static PRBool pref_VerifyLockFile(char* buf, long buflen); -JSBool PR_CALLBACK pref_BranchCallback(JSContext *cx, JSScript *script); -void JS_DLL_CALLBACK pref_ErrorReporter(JSContext *cx, const char *message,JSErrorReport *report); -void pref_Alert(char* msg); -PrefResult pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction action); +PR_STATIC_CALLBACK(JSBool) pref_BranchCallback(JSContext *cx, JSScript *script); +PR_STATIC_CALLBACK(void) pref_ErrorReporter(JSContext *cx, const char *message,JSErrorReport *report); +static void pref_Alert(char* msg); +static PrefResult pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction action); static inline PrefHashEntry* pref_HashTableLookup(const void *key); /* Computes the MD5 hash of the given buffer (not including the first line) @@ -273,6 +263,9 @@ PRBool pref_VerifyLockFile(char* buf, long buflen) return PR_TRUE; #endif } + + + PRBool PREF_Init(const char *filename) { PRBool ok = PR_TRUE, request = PR_FALSE; @@ -348,39 +341,6 @@ PRBool PREF_Init(const char *filename) return ok; } /*PREF_Init*/ -PrefResult -PREF_GetConfigContext(JSContext **js_context) -{ - if (!js_context) return PREF_ERROR; - - *js_context = gMochaContext; - return PREF_NOERROR; -} - -PrefResult -PREF_GetGlobalConfigObject(JSObject **js_object) -{ - if (!js_object) return PREF_ERROR; - - *js_object = NULL; - if (gGlobalConfigObject) - *js_object = gGlobalConfigObject; - - return PREF_NOERROR; -} - -PrefResult -PREF_GetPrefConfigObject(JSObject **js_object) -{ - if (!js_object) return PREF_ERROR; - - *js_object = NULL; - if (gMochaPrefObject) - *js_object = gMochaPrefObject; - - return PREF_NOERROR; -} - /* Frees the callback list. */ void PREF_Cleanup() { @@ -434,25 +394,6 @@ void PREF_CleanupPrefs() gSavedLine = NULL; } -PrefResult -PREF_ReadLockFile(const char *filename) -{ -/* - return pref_OpenFile(filename, PR_FALSE, PR_FALSE, PR_TRUE); - - Lock files are obscured, and the security code to read them has - been removed from the free source. So don't even try to read one. - This is benign: no one listens closely to this error return, - and no one mourns the missing lock file. -*/ - return PREF_ERROR; -} - -void PREF_SetCallbacksStatus( PRBool status ) -{ - gCallbacksEnabled = status; -} - /* This is more recent than the below 3 routines which should be obsoleted */ JSBool PREF_EvaluateConfigScript(const char * js_buffer, size_t length, @@ -520,7 +461,7 @@ PREF_EvaluateConfigScript(const char * js_buffer, size_t length, } // note that this appends to aResult, and does not assign! -void str_escape(const char * original, nsAFlatCString& aResult) +static void str_escape(const char * original, nsAFlatCString& aResult) { const char *p; @@ -575,62 +516,6 @@ PREF_SetBoolPref(const char *pref_name, PRBool value) return pref_HashPref(pref_name, pref, PREF_BOOL, PREF_SETUSER); } -PrefResult -PREF_SetBinaryPref(const char *pref_name, void * value, long size) -{ - char* buf = PL_Base64Encode((const char*)value, (PRUint32)size, NULL); - - if (buf) { - PrefValue pref; - pref.stringVal = buf; - return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER); - } - else - return PREF_ERROR; -} - -PrefResult -PREF_SetColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue) -{ - char colstr[63]; - PrefValue pref; - PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue); - - pref.stringVal = colstr; - return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER); -} - -#define MYGetboolVal(rgb) ((PRUint8) ((rgb) >> 16)) -#define MYGetGValue(rgb) ((PRUint8) (((PRUint16) (rgb)) >> 8)) -#define MYGetRValue(rgb) ((PRUint8) (rgb)) - -PrefResult -PREF_SetColorPrefDWord(const char *pref_name, PRUint32 colorref) -{ - int red,green,blue; - char colstr[63]; - PrefValue pref; - - red = MYGetRValue(colorref); - green = MYGetGValue(colorref); - blue = MYGetboolVal(colorref); - PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue); - - pref.stringVal = colstr; - return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER); -} - -PrefResult -PREF_SetRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom) -{ - char rectstr[63]; - PrefValue pref; - PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom); - - pref.stringVal = rectstr; - return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER); -} - /* ** DEFAULT VERSIONS: Call internal with (set_default == PR_TRUE) */ @@ -662,38 +547,6 @@ PREF_SetDefaultBoolPref(const char *pref_name,PRBool value) return pref_HashPref(pref_name, pref, PREF_BOOL, PREF_SETDEFAULT); } -PrefResult -PREF_SetDefaultBinaryPref(const char *pref_name,void * value,long size) -{ - char* buf = PL_Base64Encode((const char*)value, (PRUint32)size, NULL); - if (buf) { - PrefValue pref; - pref.stringVal = buf; - return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETDEFAULT); - } - else - return PREF_ERROR; -} - -PrefResult -PREF_SetDefaultColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue) -{ - char colstr[63]; - PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue); - - return PREF_SetDefaultCharPref(pref_name, colstr); -} - -PrefResult -PREF_SetDefaultRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom) -{ - char rectstr[63]; - PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom); - - return PREF_SetDefaultCharPref(pref_name, rectstr); -} - - PLDHashOperator pref_savePref(PLDHashTable *table, PLDHashEntryHdr *heh, PRUint32 i, void *arg) { @@ -896,123 +749,8 @@ PrefResult PREF_GetBoolPref(const char *pref_name, PRBool * return_value, PRBool return result; } - - -PrefResult -PREF_GetColorPref(const char *pref_name, PRUint8 *red, PRUint8 *green, PRUint8 *blue, PRBool isDefault) -{ - char colstr[8]; - int iSize = 8; - - PrefResult result = PREF_GetCharPref(pref_name, colstr, &iSize, isDefault); - - if (result == PREF_NOERROR) - { - unsigned int r, g, b; - sscanf(colstr, "#%02x%02x%02x", &r, &g, &b); - *red = r; - *green = g; - *blue = b; - } - return result; -} - -#define MYRGB(r, g ,b) ((PRUint32) (((PRUint8) (r) | ((PRUint16) (g) << 8)) | (((PRUint32) (PRUint8) (b)) << 16))) - -PrefResult -PREF_GetColorPrefDWord(const char *pref_name, PRUint32 *colorref, PRBool isDefault) -{ - PRUint8 red, green, blue; - PrefResult result; - PR_ASSERT(colorref); - result = PREF_GetColorPref(pref_name, &red, &green, &blue, isDefault); - if (result == PREF_NOERROR) - *colorref = MYRGB(red,green,blue); - return result; -} - - -PrefResult -PREF_GetBinaryPref(const char *pref_name, void * return_value, int *size, PRBool isDefault) -{ - char* buf; - PrefResult result; - - if (!gMochaPrefObject || !return_value) return PREF_ERROR; - - result = PREF_CopyCharPref(pref_name, &buf, isDefault); - - if (result == PREF_NOERROR) - { - if (PL_strlen(buf) == 0) - { /* don't decode empty string ? */ - PR_Free(buf); - return PREF_ERROR; - } - - PL_Base64Decode(buf, (PRUint32)(*size), (char*)return_value); - - PR_Free(buf); - } - return result; -} - -typedef PrefResult (* PR_CALLBACK CharPrefReadFunc)(const char*, char**, PRBool); - -static PrefResult -ReadCharPrefUsing(const char *pref_name, void** return_value, int *size, CharPrefReadFunc inFunc, PRBool isDefault) -{ - char* buf; - PrefResult result; - - if (!gMochaPrefObject || !return_value) - return PREF_ERROR; - *return_value = NULL; - - result = inFunc(pref_name, &buf, isDefault); - - if (result == PREF_NOERROR) - { - if (PL_strlen(buf) == 0) - { /* do not decode empty string? */ - PR_Free(buf); - return PREF_ERROR; - } - - *return_value = PL_Base64Decode(buf, 0, NULL); - *size = PL_strlen(buf); - - PR_Free(buf); - } - return result; -} - -PrefResult -PREF_CopyBinaryPref(const char *pref_name, void ** return_value, int *size, PRBool isDefault) -{ - return ReadCharPrefUsing(pref_name, return_value, size, PREF_CopyCharPref, isDefault); -} - -#ifndef XP_MAC -PrefResult -PREF_CopyPathPref(const char *pref_name, char ** return_buffer, PRBool isDefault) -{ - return PREF_CopyCharPref(pref_name, return_buffer, isDefault); -} - -PrefResult -PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default) -{ - PrefAction action = set_default ? PREF_SETDEFAULT : PREF_SETUSER; - PrefValue pref; - pref.stringVal = (char*) path; - - return pref_HashPref(pref_name, pref, PREF_STRING, action); -} -#endif /* XP_MAC */ - /* Delete a branch. Used for deleting mime types */ -PLDHashOperator PR_CALLBACK +PR_STATIC_CALLBACK(PLDHashOperator) pref_DeleteItem(PLDHashTable *table, PLDHashEntryHdr *heh, PRUint32 i, void *arg) { PrefHashEntry* he = NS_STATIC_CAST(PrefHashEntry*,heh); @@ -1118,7 +856,7 @@ PrefResult pref_UnlockPref(const char *key) return PREF_OK; } -PrefResult pref_LockPref(const char *key) +PrefResult PREF_LockPref(const char *key) { PrefHashEntry* pref; if (!gHashTable.ops) @@ -1131,12 +869,6 @@ PrefResult pref_LockPref(const char *key) return pref_HashPref(key, pref->defaultPref, (PrefType)pref->flags, PREF_LOCK); } -PrefResult -PREF_LockPref(const char *key) -{ - return pref_LockPref(key); -} - /* * Hash table functions */ @@ -1309,25 +1041,25 @@ PREF_GetPrefType(const char *pref_name) return PREF_INVALID; } -JSBool PR_CALLBACK pref_NativeDefaultPref +PR_STATIC_CALLBACK(JSBool) pref_NativeDefaultPref (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { return pref_HashJSPref(argc, argv, PREF_SETDEFAULT); } -JSBool PR_CALLBACK pref_NativeUserPref +PR_STATIC_CALLBACK(JSBool) pref_NativeUserPref (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { return pref_HashJSPref(argc, argv, PREF_SETUSER); } -JSBool PR_CALLBACK pref_NativeLockPref +PR_STATIC_CALLBACK(JSBool) pref_NativeLockPref (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { return pref_HashJSPref(argc, argv, PREF_LOCK); } -JSBool PR_CALLBACK pref_NativeUnlockPref +PR_STATIC_CALLBACK(JSBool) pref_NativeUnlockPref (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { if (argc >= 1 && JSVAL_IS_STRING(argv[0])) @@ -1345,13 +1077,13 @@ JSBool PR_CALLBACK pref_NativeUnlockPref return JS_TRUE; } -JSBool PR_CALLBACK pref_NativeSetConfig +PR_STATIC_CALLBACK(JSBool) pref_NativeSetConfig (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { return pref_HashJSPref(argc, argv, PREF_SETCONFIG); } -JSBool PR_CALLBACK pref_NativeGetPref +PR_STATIC_CALLBACK(JSBool) pref_NativeGetPref (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) { /*void* value = NULL;*/ @@ -1412,7 +1144,7 @@ typedef struct and entry is "a.b.c" or "a.b" then add "a.b" to the list. */ -PLDHashOperator PR_CALLBACK +PR_STATIC_CALLBACK(PLDHashOperator) pref_addChild(PLDHashTable *table, PLDHashEntryHdr* heh,PRUint32 number,void *arg) { PrefHashEntry* he = NS_STATIC_CAST(PrefHashEntry*,heh); @@ -1458,17 +1190,13 @@ pref_addChild(PLDHashTable *table, PLDHashEntryHdr* heh,PRUint32 number,void *ar return PL_DHASH_NEXT; } -PrefResult +static PrefResult PREF_CreateChildList(const char* parent_node, char **child_list) { PrefChildIter pcs; if (!gHashTable.ops) return PREF_NOT_INITIALIZED; -#ifdef XP_WIN16 - pcs.bufsize = 20480; -#else pcs.bufsize = 2048; -#endif pcs.childList = (char*) malloc(sizeof(char) * pcs.bufsize); if (*parent_node > 0) pcs.parent = PR_smprintf("%s.", parent_node); @@ -1486,139 +1214,6 @@ PREF_CreateChildList(const char* parent_node, char **child_list) return (pcs.childList == NULL) ? PREF_OUT_OF_MEMORY : PREF_OK; } -char* -PREF_NextChild(char *child_list, int *indx) -{ - char *nextstr; - char* child = PL_strtok_r(&child_list[*indx], ";", &nextstr); - if (child) - *indx += PL_strlen(child) + 1; - return child; -} - -/*---------------------------------------------------------------------------------------- -* pref_copyTree -* -* A recursive function that copies all the prefs in some subtree to -* another subtree. Either srcPrefix or dstPrefix can be empty strings, -* but not NULL pointers. Preferences in the destination are created if -* they do not already exist; otherwise the old values are replaced. -* -* Example calls: -* -* Copy all the prefs to another tree: pref_copyTree("", "temp", "") -* -* Copy all the prefs under mail. to newmail.: pref_copyTree("mail", "newmail", "mail") -* ---------------------------------------------------------------------------------------*/ -PrefResult pref_copyTree(const char *srcPrefix, const char *destPrefix, const char *curSrcBranch) -{ - PrefResult result = PREF_NOERROR; - - char* children = NULL; - - if ( PREF_CreateChildList(curSrcBranch, &children) == PREF_NOERROR ) - { - int indx = 0; - int srcPrefixLen = PL_strlen(srcPrefix); - char* child = NULL; - - while ( (child = PREF_NextChild(children, &indx)) != NULL) - { - PrefType prefType; - char *destPrefName = NULL; - char *childStart = (srcPrefixLen > 0) ? (child + srcPrefixLen + 1) : child; - - /*NS_ASSERTION( PL_strncmp(child, curSrcBranch, (PRUint32)srcPrefixLen) == 0, "bad pref child in pref_copyTree" );*/ - - if (*destPrefix > 0) - destPrefName = PR_smprintf("%s.%s", destPrefix, childStart); - else - destPrefName = PR_smprintf("%s", childStart); - - if (!destPrefName) - { - result = PREF_OUT_OF_MEMORY; - break; - } - - if ( ! PREF_PrefIsLocked(destPrefName) ) /* returns true if the prefs exists, and is locked */ - { - /* PREF_GetPrefType masks out the other bits of the pref flag, so we only - ever get the values in the switch. - */ - prefType = PREF_GetPrefType(child); - - switch (prefType) - { - case PREF_STRING: - { - char *prefVal = NULL; - - result = PREF_CopyCharPref(child, &prefVal, PR_FALSE); - if (result == PREF_NOERROR) - result = PREF_SetCharPref(destPrefName, prefVal); - - PR_FREEIF(prefVal); - } - break; - - case PREF_INT: - { - PRInt32 prefValInt; - - result = PREF_GetIntPref(child, &prefValInt, PR_FALSE); - if (result == PREF_NOERROR) - result = PREF_SetIntPref(destPrefName, prefValInt); - } - break; - - case PREF_BOOL: - { - PRBool prefBool; - - result = PREF_GetBoolPref(child, &prefBool, PR_FALSE); - if (result == PREF_NOERROR) - result = PREF_SetBoolPref(destPrefName, prefBool); - } - break; - - case PREF_INVALID: - /* this is probably just a branch. Since we can have both - a.b and a.b.c as valid prefs, this is OK. - */ - break; - - default: - /* we should never get here */ - PR_ASSERT(PR_FALSE); - break; - } - - } /* is not locked */ - - PR_FREEIF(destPrefName); - - /* Recurse */ - if (result == PREF_NOERROR || result == PREF_VALUECHANGED) - result = pref_copyTree(srcPrefix, destPrefix, child); - } - - PR_Free(children); - } - - return result; -} - -PrefResult -PREF_CopyPrefsTree(const char *srcRoot, const char *destRoot) -{ - PR_ASSERT(srcRoot != NULL); - PR_ASSERT(destRoot != NULL); - - return pref_copyTree(srcRoot, destRoot, srcRoot); -} - /* Adds a node to the beginning of the callback list. */ void PREF_RegisterCallback(const char *pref_node, @@ -1672,7 +1267,7 @@ PREF_UnregisterCallback(const char *pref_node, return result; } -PrefResult pref_DoCallback(const char* changed_pref) +static PrefResult pref_DoCallback(const char* changed_pref) { PrefResult result = PREF_OK; struct CallbackNode* node; @@ -1688,84 +1283,9 @@ PrefResult pref_DoCallback(const char* changed_pref) return result; } -/* !! Front ends need to implement */ -#ifndef XP_MAC /* see macpref.cp */ -PRBool -PREF_IsAutoAdminEnabled() -{ - return PR_TRUE; -} -#endif /* XP_MAC */ - -/* Called from JavaScript */ -typedef char* (*ldap_func)(char*, char*, char*, char*, char**); - -JSBool PR_CALLBACK pref_NativeGetLDAPAttr - (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) -{ -#ifdef MOZ_ADMIN_LIB - ldap_func get_ldap_attributes = NULL; -#if (defined (XP_MAC) && defined(powerc)) || defined (XP_WIN) || defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_OS2) - if (!gAutoAdminLib) - gAutoAdminLib = pref_LoadAutoAdminLib(); - - if (gAutoAdminLib) - { - get_ldap_attributes = (ldap_func) - PR_FindSymbol( - gAutoAdminLib, -#ifndef XP_WIN16 - "pref_get_ldap_attributes" -#else - MAKEINTRESOURCE(1) -#endif - ); - } - if (get_ldap_attributes == NULL) - { - /* This indicates the AutoAdmin dll was not found. */ - *rval = JSVAL_NULL; - return JS_TRUE; - } -#else - get_ldap_attributes = pref_get_ldap_attributes; -#endif /* MOZ_ADMIN_LIB */ - - if (argc >= 4 && JSVAL_IS_STRING(argv[0]) - && JSVAL_IS_STRING(argv[1]) - && JSVAL_IS_STRING(argv[2]) - && JSVAL_IS_STRING(argv[3])) - { - char *return_error = NULL; - char *value = get_ldap_attributes( - JS_GetStringBytes(JSVAL_TO_STRING(argv[0])), - JS_GetStringBytes(JSVAL_TO_STRING(argv[1])), - JS_GetStringBytes(JSVAL_TO_STRING(argv[2])), - JS_GetStringBytes(JSVAL_TO_STRING(argv[3])), - &return_error ); - - if (value) - { - JSString* str = JS_NewStringCopyZ(cx, value); - PR_Free(value); - if (str) - { - *rval = STRING_TO_JSVAL(str); - return JS_TRUE; - } - } - if (return_error) - pref_Alert(return_error); - } -#endif - - *rval = JSVAL_NULL; - return JS_TRUE; -} - #define MAYBE_GC_BRANCH_COUNT_MASK 4095 -JSBool PR_CALLBACK +PR_STATIC_CALLBACK(JSBool) pref_BranchCallback(JSContext *cx, JSScript *script) { static PRUint32 count = 0; @@ -1864,68 +1384,6 @@ void pref_Alert(char* msg) #endif -#ifdef XP_WIN16 -#define ADMNLIBNAME "adm1640.dll" -#elif defined XP_WIN || defined XP_OS2 -#define ADMNLIBNAME "adm3240.dll" -#elif defined(XP_UNIX) || defined(XP_BEOS) -#define ADMNLIBNAME "libAutoAdmin.so" -extern void fe_GetProgramDirectory(char *path, int len); -#else -#define ADMNLIBNAME "AutoAdmin" /* internal fragment name */ -#endif - -/* Try to load AutoAdminLib */ -PRLibrary * -pref_LoadAutoAdminLib() -{ - PRLibrary *lib = NULL; - -#ifdef XP_MAC - const char *oldpath = PR_GetLibraryPath(); - PR_SetLibraryPath( "/usr/local/netscape/" ); -#endif - -#if defined(XP_UNIX) && !defined(B_ONE_M) - { - char aalib[MAXPATHLEN]; - - if (getenv("NS_ADMIN_LIB")) - { - lib = PR_LoadLibrary(getenv("NS_ADMIN_LIB")); - } - else - { - if (getenv("MOZILLA_FIVE_HOME")) - { - PL_strcpy(aalib, getenv("MOZILLA_FIVE_HOME")); - lib = PR_LoadLibrary(PL_strcat(aalib, ADMNLIBNAME)); - } - if (lib == NULL) - { - fe_GetProgramDirectory(aalib, sizeof(aalib)-1); - lib = PR_LoadLibrary(PL_strcat(aalib, ADMNLIBNAME)); - } - if (lib == NULL) - { - (void) PL_strcpy(aalib, "/usr/local/netscape/"); - lib = PR_LoadLibrary(PL_strcat(aalib, ADMNLIBNAME)); - } - } - } - /* Make sure it's really libAutoAdmin.so */ - - if ( lib && PR_FindSymbol(lib, "_POLARIS_SplashPro") == NULL ) return NULL; -#else - lib = PR_LoadLibrary( ADMNLIBNAME ); -#endif - -#ifdef XP_MAC - PR_SetLibraryPath(oldpath); -#endif - - return lib; -} /*--------------------------------------------------------------------------------------*/ static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action) @@ -1964,16 +1422,3 @@ static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action) return JS_TRUE; } -/*--------------------------------------------------------------------------------------*/ -static int pref_CountListMembers(char* list) -/*--------------------------------------------------------------------------------------*/ -{ - int members = 0; - char* p = list = PL_strdup(list); - char* nextstr; - for ( p = PL_strtok_r(p, ",", &nextstr); p != NULL; p = PL_strtok_r(nextstr, ",", &nextstr) ) - members++; - PR_FREEIF(list); - return members; -} - diff --git a/mozilla/modules/libpref/src/prefapi.h b/mozilla/modules/libpref/src/prefapi.h index 075f7bde30f..9632ba312d7 100644 --- a/mozilla/modules/libpref/src/prefapi.h +++ b/mozilla/modules/libpref/src/prefapi.h @@ -131,30 +131,12 @@ typedef enum { // */ -#if defined (XP_WIN) || defined (XP_MAC) || defined(XP_OS2) -/* PREF_Init actually returns a profile object */ -void * -PREF_InitProfile(void); - -void * -PREF_GetCurrentProfile(void); -#endif - PRBool PREF_Init(const char *filename); PrefResult PREF_LockPref(const char *key); -PrefResult -PREF_GetConfigContext(JSContext **js_context); - -PrefResult -PREF_GetGlobalConfigObject(JSObject **js_object); - -PrefResult -PREF_GetPrefConfigObject(JSObject **js_object); - /* // Cleanup should be called at program exit to free the // list of registered callbacks. @@ -165,16 +147,6 @@ PREF_Cleanup(); void PREF_CleanupPrefs(); -/* -// -// Given a path to a local Lock file, unobscures the file (not implemented yet) -// and verifies the MD5 hash. Returns PREF_BAD_LOCKFILE if hash failed; -// otherwise, evaluates the contents of the file as a JS buffer. -// -*/ -PrefResult -PREF_ReadLockFile(const char *filename); - JSBool PREF_EvaluateConfigScript(const char * js_buffer, size_t length, const char* filename, PRBool bGlobalContext, PRBool bCallbacks, @@ -234,10 +206,6 @@ typedef enum { PREF_INVALID = 0, PrefResult PREF_SetCharPref(const char *pref,const char* value); PrefResult PREF_SetIntPref(const char *pref,PRInt32 value); PrefResult PREF_SetBoolPref(const char *pref,PRBool value); -PrefResult PREF_SetBinaryPref(const char *pref,void * value, long size); -PrefResult PREF_SetColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue); -PrefResult PREF_SetColorPrefDWord(const char *pref_name, PRUint32 colorref); -PrefResult PREF_SetRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom); /* // @@ -251,9 +219,6 @@ PrefResult PREF_SetRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PR PrefResult PREF_SetDefaultCharPref(const char *pref,const char* value); PrefResult PREF_SetDefaultIntPref(const char *pref,PRInt32 value); PrefResult PREF_SetDefaultBoolPref(const char *pref,PRBool value); -PrefResult PREF_SetDefaultBinaryPref(const char *pref,void * value, long size); -PrefResult PREF_SetDefaultColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue); -PrefResult PREF_SetDefaultRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom); PRBool PREF_HasUserPref(const char* pref_name); @@ -265,11 +230,6 @@ PRBool PREF_HasUserPref(const char* pref_name); // They also take a pointer to fill in with the return value and return an // error value. At the moment, this is simply an int but it may // be converted to an enum once the global error strategy is worked out. -// In addition, the GetChar and GetBinary versions take an (int *) which -// should contain the length of the buffer which is passed to be filled -// in. If the length passed in is 0, the function will not copy the -// preference but will instead return the length necessary for the buffer, -// including null terminator. // // They will perform conversion if the type doesn't match what was requested. // (if it is reasonably possible) @@ -278,9 +238,6 @@ PRBool PREF_HasUserPref(const char* pref_name); PrefResult PREF_GetIntPref(const char *pref, PRInt32 * return_int, PRBool isDefault); PrefResult PREF_GetBoolPref(const char *pref, PRBool * return_val, PRBool isDefault); -PrefResult PREF_GetBinaryPref(const char *pref, void * return_val, int * buf_length, PRBool isDefault); -PrefResult PREF_GetColorPref(const char *pref_name, PRUint8 *red, PRUint8 *green, PRUint8 *blue, PRBool isDefault); -PrefResult PREF_GetColorPrefDWord(const char *pref_name, PRUint32 *colorref, PRBool isDefault); /* // // These functions are similar to the above "Get" version with the significant @@ -289,20 +246,6 @@ PrefResult PREF_GetColorPrefDWord(const char *pref_name, PRUint32 *colorref, PRB // */ PrefResult PREF_CopyCharPref(const char *pref, char ** return_buf, PRBool isDefault); -PrefResult PREF_CopyBinaryPref(const char *pref_name, void ** return_value, int *size, PRBool isDefault); - -/* -// -// Get and set encoded full file/directory pathname strings -// (i.e. file URLs without the file:// part). -// On Windows and Unix, these are just stored as string preferences. -// On Mac, paths should be stored as aliases. These calls convert -// between paths and aliases flattened into binary strings. -// -*/ -PrefResult PREF_CopyPathPref(const char *pref, char ** return_buf, PRBool isDefault); -PrefResult PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default); - /* // // PRBool function that returns whether or not the preference is locked and therefore @@ -313,19 +256,6 @@ PRBool PREF_PrefIsLocked(const char *pref_name); PrefType PREF_GetPrefType(const char *pref_name); -/* -// -// Cause the preference file to be written to disk -// -*/ -PrefResult PREF_SavePrefFile(void); - -/* - * Called to handle the "about:config" command. - * Currently dumps out some debugging information. - */ -char * PREF_AboutConfig(); - /* * Delete a branch of the tree */ @@ -341,33 +271,6 @@ PrefResult PREF_ClearUserPref(const char *pref_name); */ PrefResult PREF_ClearAllUserPrefs(); -/* - * Creates an iterator over the children of a node. Sample code: - char* children; - if ( PREF_CreateChildList("mime", &children) == 0 ) - { - int indx = 0; - while (char* child = PREF_NextChild(children, &indx)) { - ... - } - XP_FREE(children); - } - * e.g. subsequent calls to Next() return - * "mime.image_gif", then - * "mime.image_jpeg", etc. - */ -PrefResult PREF_CreateChildList(const char* parent_node, char **child_list); -char* PREF_NextChild(char *child_list, int *indx); - -/* The following function parts of the hierarchy from one root to another. - * For example, PREF_CopyPrefsTree("mail","newmail") copies all - * the "mail." prefs to "newmail." prefs. It does not delete the - * source tree; you should do that yourself. - * - * Either srcRoot or destRoot can be empty strings, to denote - * the root of the entire tree, but cannot be NULL. - */ -PrefResult PREF_CopyPrefsTree(const char *srcRoot, const char *destRoot); /* // @@ -400,21 +303,5 @@ void PREF_RegisterCallback( const char* domain, PrefResult PREF_UnregisterCallback( const char* domain, PrefChangedFunc callback, void* instance_data ); -/* -// Front ends implement to determine whether AutoAdmin library is installed. -*/ -PRBool PREF_IsAutoAdminEnabled(void); - -#ifdef XP_UNIX -struct fe_icon_data; -typedef void* XmStringPtr; -typedef void* KeySymPtr; -/* void PREF_AlterSplashIcon(struct fe_icon_data*); */ -PRBool PREF_GetLabelAndMnemonic(char*, char**, XmStringPtr xmstring, KeySymPtr keysym); -PRBool PREF_GetUrl(char*, char**); -void PREF_SetCallbacksStatus(PRBool status); -PrefResult PREF_LoadLDAPPrefs(void); -#endif - NSPR_END_EXTERN_C #endif diff --git a/mozilla/modules/libpref/src/prefapi_private_data.h b/mozilla/modules/libpref/src/prefapi_private_data.h index 0bcda4c5612..cfebc7690eb 100644 --- a/mozilla/modules/libpref/src/prefapi_private_data.h +++ b/mozilla/modules/libpref/src/prefapi_private_data.h @@ -37,58 +37,23 @@ /* Data shared between prefapi.c and nsPref.cpp */ -NSPR_BEGIN_EXTERN_C -extern JSTaskState * gMochaTaskState; extern JSContext * gMochaContext; extern JSObject * gMochaPrefObject; -extern JSObject * gGlobalConfigObject; -extern JSClass global_class; -extern JSClass autoconf_class; -extern JSPropertySpec autoconf_props[]; -extern JSFunctionSpec autoconf_methods[]; - -#ifdef PREF_SUPPORT_OLD_PATH_STRINGS -extern char * gFileName; -extern char * gLIFileName; -#endif /*PREF_SUPPORT_OLD_PATH_STRINGS*/ - -extern struct CallbackNode* gCallbacks; extern PRBool gErrorOpeningUserPrefs; -extern PRBool gCallbacksEnabled; -extern PRBool gIsAnyPrefLocked; -extern PRBool gLockInfoRead; -extern PRBool gHashTableInitialized; extern PLDHashTable gHashTable; -extern char * gSavedLine; -extern char * gLockFileName; -extern char * gLockVendor; - -JSBool PR_CALLBACK pref_BranchCallback(JSContext *cx, JSScript *script); PLDHashOperator pref_savePref(PLDHashTable*, PLDHashEntryHdr *, PRUint32, void *arg); -PRBool pref_VerifyLockFile(char* buf, long buflen); int pref_CompareStrings(const void *v1, const void *v2, void* unused); extern JSBool pref_InitInitialObjects(void); extern PRIntn pref_HashTableEnumerateEntries(PLDHashEnumerator f, void *arg); -NSPR_END_EXTERN_C - -/* Possibly exportable */ -#if defined(__cplusplus) #include "nsIFileSpec.h" -PrefResult PREF_SavePrefFileSpecWith( - nsIFileSpec* fileSpec, - PLHashEnumerator heSaveProc); -#endif /*__cplusplus*/ #ifdef XP_MAC # define LINEBREAK "\012" -# define LINEBREAK_LEN 1 #elif defined(XP_WIN) || defined(XP_OS2) # define LINEBREAK "\015\012" -# define LINEBREAK_LEN 2 #elif defined(XP_UNIX) || defined(XP_BEOS) # define LINEBREAK "\012" -# define LINEBREAK_LEN 1 #endif /* XP_MAC */