void lm_RegisterComponentProp(const char *comp, const char *targetName, uint8 retType, ETCompPropSetterFunc setter, ETCompPropGetterFunc getter) { JSContext *cx; JSObject *arrayObj, *obj; jsval val; char *type, *set, *get; if (!comp || !targetName || !(cx = lm_crippled_decoder->js_context)) return; arrayObj = lm_DefineComponents(lm_crippled_decoder); if (!arrayObj) return; if (!JS_GetProperty(cx, arrayObj, comp, &val) || !JSVAL_IS_OBJECT(val)) return; obj = JSVAL_TO_OBJECT(val); if (!JS_DefineProperty(cx, obj, targetName, JSVAL_VOID, component_mozilla_getProperty, component_mozilla_setProperty, 0)) { } type = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(targetName) + 1); if (type) { XP_STRCPY(type, lm_typePrefix_str); XP_STRCAT(type, targetName); if (!JS_DefineProperty(cx, obj, type, INT_TO_JSVAL((int32)retType), 0, 0, JSPROP_READONLY)) { } JS_free(cx, type); } get = JS_malloc(cx, XP_STRLEN(lm_getPrefix_str) + XP_STRLEN(targetName) + 1); if (get) { XP_STRCPY(get, lm_getPrefix_str); XP_STRCAT(get, targetName); if (!JS_DefineProperty(cx, obj, get, INT_TO_JSVAL(getter), 0, 0, JSPROP_READONLY)) { } JS_free(cx, get); } set = JS_malloc(cx, XP_STRLEN(lm_setPrefix_str) + XP_STRLEN(targetName) + 1); if (set) { XP_STRCPY(set, lm_setPrefix_str); XP_STRCAT(set, targetName); if (!JS_DefineProperty(cx, obj, set, INT_TO_JSVAL(setter), 0, 0, JSPROP_READONLY)) { } JS_free(cx, set); } }
/* ** This function deletes a directory and everything under it. ** Deleting directories with "non-file" files, such as links, ** will produce behavior of XP_RemoveFile, since that's what is ** ultimately called. ** ** Return values: zero on failure, non-zero for success. */ int XP_RemoveDirectoryRecursive(const char *name, XP_FileType type) { XP_DirEntryStruct *entry; XP_StatStruct statbuf; int status; char* child; char* dot = "."; char* dotdot = ".."; int ret = 1; XP_Dir dir = XP_OpenDir(name, type); if (!dir) return 0; /* ** Go through the directory entries and delete appropriately */ while ((entry = XP_ReadDir(dir))) { /* ** Allocate space for current name + path separator + directory name + NULL */ child = XP_ALLOC( strlen(name) + 2 + strlen(entry->d_name) ); XP_STRCAT(child,"/"); XP_STRCAT(child,entry->d_name); if (!(status = XP_Stat(child, &statbuf, type))) { if (entry->d_name == dot || entry->d_name == dotdot) { /* Do nothing, rmdir will clean these up */ } else if (S_ISDIR(statbuf.st_mode)) { /* Recursive call to clean out subdirectory */ if (!XP_RemoveDirectoryRecursive(child, type)) ret = 0; } else { /* Everything that's not a directory is a file! */ if (XP_FileRemove(child, type) != 0) ret = 0; } } XP_FREE(child); } /* OK, remove the top-level directory if we can */ if (XP_RemoveDirectory(name, type) != 0) ret = 0; XP_CloseDir(dir); return ret; }
/* * used for ARCHIVE= and SRC= * Create name of form "archive.jar/src.js" */ static char * lo_BuildJSArchiveURL( char *archive_name, char *filename ) { uint32 len = XP_STRLEN(archive_name) + XP_STRLEN(filename) + 2; char *path = XP_ALLOC(len); if (path) { XP_STRCPY(path, archive_name); XP_STRCAT(path, "/"); XP_STRCAT(path, filename); } return path; }
char* vr_findVerRegName () { if ( verRegName != NULL ) return verRegName; #ifndef STANDALONE_REGISTRY { char *def = NULL; char settings[1024]; find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, settings, sizeof(settings)); if (settings != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(settings) + XP_STRLEN(BEOS_VERREG)+1); if (def != NULL) { XP_STRCPY(def, settings); XP_STRCAT(def, BEOS_VERREG); } } if (def != NULL) { verRegName = XP_STRDUP(def); } XP_FREEIF(def); } #else verRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ return verRegName; }
char* vr_findVerRegName () { if ( verRegName != NULL ) return verRegName; #ifndef STANDALONE_REGISTRY { char *def = NULL; char *home = getenv("HOME"); if (home != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(home) + XP_STRLEN(DEF_VERREG)+1); if (def != NULL) { XP_STRCPY(def, home); XP_STRCAT(def, DEF_VERREG); } } if (def != NULL) { verRegName = XP_STRDUP(def); } XP_FREEIF(def); } #else verRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ return verRegName; }
component_mozilla_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { char *name, *type_str, *set_str, *prop_val; jsval type, func; if (!JSVAL_IS_STRING(id)) return JS_TRUE; name = JS_GetStringBytes(JSVAL_TO_STRING(id)); type_str = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(name) + 1); set_str = JS_malloc(cx, XP_STRLEN(lm_setPrefix_str) + XP_STRLEN(name) + 1); if (!type_str || !set_str) return JS_TRUE; XP_STRCPY(type_str, lm_typePrefix_str); XP_STRCAT(type_str, name); XP_STRCPY(set_str, lm_setPrefix_str); XP_STRCAT(set_str, name); if (!JS_GetProperty(cx, obj, type_str, &type) || !JSVAL_IS_INT(type) || !JS_GetProperty(cx, obj, set_str, &func)) return JS_TRUE; JS_free(cx, type_str); JS_free(cx, set_str); switch(JSVAL_TO_INT(type)) { case ARGTYPE_INT32: if (JSVAL_IS_INT(*vp)) ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)JSVAL_TO_INT(*vp)); break; case ARGTYPE_BOOL: if (JSVAL_IS_BOOLEAN(*vp)) ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)JSVAL_TO_BOOLEAN(*vp)); break; case ARGTYPE_STRING: if (JSVAL_IS_STRING(*vp)) { prop_val = JS_GetStringBytes(JSVAL_TO_STRING(*vp)); ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)prop_val); } break; } return JS_TRUE; }
VR_INTERFACE(REGERR) VR_UninstallDeleteSharedFilesKey(char *component_path) { REGERR err; char *regbuf; char *converted_component_path; uint32 convertedDataLength = 0; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( component_path == NULL ) err = REGERR_PARAM; convertedDataLength = 2 * XP_STRLEN(component_path) + 1; converted_component_path = (char*)XP_ALLOC(convertedDataLength); if (converted_component_path == NULL ) { err = REGERR_MEMORY; return err; } err = vr_convertPackageName(component_path, converted_component_path, convertedDataLength); if (err != REGERR_OK) { XP_FREEIF(converted_component_path); return err; } regbuflen = 256 + XP_STRLEN(converted_component_path); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(converted_component_path, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegDeleteKey( vreg, ROOTKEY_PRIVATE, regbuf ); } else err = REGERR_BUFTOOSMALL; } XP_FREE(regbuf); } else { err = REGERR_MEMORY; } XP_FREE(converted_component_path); return err; } /* UninstallDeleteSharedFilesKey */
component_mozilla_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { char *name, *type_str, *get_str; jsval type, func; if (!JSVAL_IS_STRING(id)) return JS_TRUE; name = JS_GetStringBytes(JSVAL_TO_STRING(id)); type_str = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(name) + 1); get_str = JS_malloc(cx, XP_STRLEN(lm_getPrefix_str) + XP_STRLEN(name) + 1); if (!type_str || !get_str) return JS_TRUE; XP_STRCPY(type_str, lm_typePrefix_str); XP_STRCAT(type_str, name); XP_STRCPY(get_str, lm_getPrefix_str); XP_STRCAT(get_str, name); if (!JS_GetProperty(cx, obj, type_str, &type) || !JSVAL_IS_INT(type) || !JS_GetProperty(cx, obj, get_str, &func)) return JS_TRUE; JS_free(cx, type_str); JS_free(cx, get_str); switch(JSVAL_TO_INT(type)) { case ARGTYPE_INT32: *vp = INT_TO_JSVAL((int32)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name)); break; case ARGTYPE_BOOL: *vp = BOOLEAN_TO_JSVAL((JSBool)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name)); break; case ARGTYPE_STRING: *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char*)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name))); break; } return JS_TRUE; }
char * XP_PlatformFileToURL (const char *name) { char *prefix = "file://"; char *retVal = XP_ALLOC (XP_STRLEN(name) + XP_STRLEN(prefix) + 1); if (retVal) { XP_STRCPY (retVal, "file://"); XP_STRCAT (retVal, name); } return retVal; }
VR_INTERFACE(REGERR) VR_CreateRegistry( char *installation, char *programPath, char *versionStr ) { REGERR err; char * regname = vr_findVerRegName(); #if defined(XP_UNIX) && !defined(XP_MACOSX) char * regbuf = NULL; #endif if ( installation == NULL || *installation == '\0' ) return REGERR_PARAM; #if defined(XP_UNIX) && !defined(XP_MACOSX) #ifndef STANDALONE_REGISTRY if (bGlobalRegistry) #endif { regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(programPath) ); if (regbuf == NULL) return REGERR_MEMORY; XP_STRCPY( regbuf, programPath ); XP_STRCAT( regbuf, "registry" ); regname = regbuf; } #endif /* XP_UNIX */ PR_Lock(vr_lock); /* automatically creates it if not found */ err = NR_RegOpen( regname, &vreg ); if (err == REGERR_OK) { /* create default tree with 'installation' under Navigator */ /* set Current to the installation string */ err = vr_SetCurrentNav( installation, programPath, versionStr ); if ( REGERR_OK == err ) isInited = 1; else NR_RegClose( vreg ); } PR_Unlock(vr_lock); #if defined(XP_UNIX) && !defined(XP_MACOSX) XP_FREEIF( regbuf ); #endif return err; } /* CreateRegistry */
VR_INTERFACE(REGERR) VR_UninstallFileExistsInList(char *regPackageName, char *vrName) { REGERR err; RKEY key = 0; char *regbuf; char sharedfilesstr[MAXREGNAMELEN]; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( regPackageName == NULL ) err = REGERR_PARAM; if ( vrName == NULL ) err = REGERR_PARAM; regbuflen = 256 + XP_STRLEN(regPackageName); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(regPackageName, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegGetKey( vreg, ROOTKEY_PRIVATE, regbuf, &key ); } else err = REGERR_BUFTOOSMALL; } XP_FREEIF(regbuf); } else { err = REGERR_MEMORY; } if (err == REGERR_OK) err = NR_RegGetEntryString( vreg, key, vrName, sharedfilesstr, sizeof(sharedfilesstr) ); return err; } /* UninstallFileExistsInList */
char * hk_TagIndexToFunctionString(int32 tag_indx) { char *total_name; total_name = NULL; if (tag_indx == P_TEXT) { total_name = XP_STRDUP("TEXT_hook"); } else if (tag_indx == P_UNKNOWN) { total_name = NULL; } else if (tag_indx >= P_MAX) { total_name = NULL; } else { const char *tag_name; tag_name = PA_TagString(tag_indx); if (tag_name == NULL) { total_name = NULL; } else { int32 len; len = XP_STRLEN(tag_name) + XP_STRLEN("_hook") + 1; total_name = XP_ALLOC(len); if (total_name != NULL) { XP_STRCPY(total_name, tag_name); XP_STRCAT(total_name, "_hook"); } } } return(total_name); }
extern void vr_findGlobalRegName () { #ifndef STANDALONE_REGISTRY char *def = NULL; char *home = getenv("HOME"); if (home != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(home) + XP_STRLEN(DEF_REG)+1); if (def != NULL) { XP_STRCPY(def, home); XP_STRCAT(def, DEF_REG); } } if (def != NULL) { globalRegName = XP_STRDUP(def); } else { globalRegName = XP_STRDUP(TheRegistry); } XP_FREEIF(def); #else globalRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ }
extern void vr_findGlobalRegName () { #ifndef STANDALONE_REGISTRY char *def = NULL; char settings[1024]; find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, settings, sizeof(settings)); if (settings != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(settings) + XP_STRLEN(BEOS_REG)+1); if (def != NULL) { XP_STRCPY(def, settings); XP_STRCAT(def, BEOS_REG); } } if (def != NULL) { globalRegName = XP_STRDUP(def); } else { globalRegName = XP_STRDUP(TheRegistry); } XP_FREEIF(def); #else globalRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ }
/* Generate mimetype string corresponding to this script language. Specifically, <SCRIPT language = blah> should yield a mimetype of "script/blah" */ char * npl_Script2mimeType(MWContext *context, PA_Tag *tag) { PA_Block buff; char * language; char * preface = "script/"; uint32 prefLen = XP_STRLEN(preface); char * mimebuf = NULL; uint32 len; buff = lo_FetchParamValue(context, tag, PARAM_LANGUAGE); if (buff != NULL) { PA_LOCK(language, char *, buff); len = prefLen + XP_STRLEN(language); mimebuf = XP_ALLOC(len+1); if (mimebuf) { XP_STRCPY(mimebuf, preface); XP_STRCAT(mimebuf, language); } PA_FREE(buff); } return mimebuf; }
/* returns a unmalloced static string * that is only available for temporary use. */ PUBLIC char * xp_FileName (const char *name, XP_FileType type, char* buf, char* configBuf) { const char *conf_dir = xp_unix_config_directory(configBuf); switch (type) { case xpSARCacheIndex: { const char *sar_cache_dir = FE_SARCacheDir; if (!sar_cache_dir || !*sar_cache_dir) sar_cache_dir = conf_dir; if (sar_cache_dir [strlen (sar_cache_dir) - 1] == '/') sprintf (buf, "%.900sarchive.fat", sar_cache_dir); else sprintf (buf, "%.900s/archive.fat", sar_cache_dir); name = buf; break; } case xpSARCache: { /* WH_TempName() returns relative pathnames for the cache files, so that relative paths get written into the cacheFAT database. WH_FileName() converts them to absolute if they aren't already so that the logic of XP_FileOpen() and XP_FileRename() and who knows what else is simpler. */ if (name != NULL && *name == '/') break ; { char *tmp = FE_SARCacheDir; if (!tmp || !*tmp) tmp = "/tmp"; if (tmp [strlen (tmp) - 1] == '/') sprintf (buf, "%.500s%.500s", tmp, name); else sprintf (buf, "%.500s/%.500s", tmp, name); name = buf; } break; } case xpCacheFAT: { const char *cache_dir = FE_CacheDir; if (!cache_dir || !*cache_dir) cache_dir = conf_dir; if (cache_dir [strlen (cache_dir) - 1] == '/') sprintf (buf, "%.900sindex.db", cache_dir); else sprintf (buf, "%.900s/index.db", cache_dir); name = buf; break; } case xpCache: { /* WH_TempName() returns relative pathnames for the cache files, so that relative paths get written into the cacheFAT database. WH_FileName() converts them to absolute if they aren't already so that the logic of XP_FileOpen() and XP_FileRename() and who knows what else is simpler. */ if (*name != '/') { char *tmp = FE_CacheDir; if (!tmp || !*tmp) tmp = "/tmp"; if (tmp [strlen (tmp) - 1] == '/') sprintf (buf, "%.500s%.500s", tmp, name); else sprintf (buf, "%.500s/%.500s", tmp, name); name = buf; } break; } case xpHTTPCookie: { #ifndef OLD_UNIX_FILES sprintf (buf, "%.900s/cookies", conf_dir); #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-cookies", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; } case xpRegistry: { if ( name == NULL || *name == '\0' ) { #ifndef OLD_UNIX_FILES sprintf (buf, "%.900s/registry", conf_dir); #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-registry", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; } else { XP_ASSERT( name[0] == '/' ); } break; } case xpProxyConfig: { sprintf(buf, "%.900s/proxyconf", conf_dir); name = buf; break; } case xpTemporary: { if (*name != '/') { char *tmp = FE_TempDir; if (!tmp || !*tmp) tmp = "/tmp"; if (tmp [strlen (tmp) - 1] == '/') sprintf (buf, "%.500s%.500s", tmp, name); else sprintf (buf, "%.500s/%.500s", tmp, name); name = buf; } break; } case xpNewsRC: case xpSNewsRC: case xpTemporaryNewsRC: { /* In this case, `name' is "" or "host" or "host:port". */ char *home = getenv ("HOME"); const char *newsrc_dir = ((FE_UserNewsRC && *FE_UserNewsRC) ? FE_UserNewsRC : (home ? home : "")); const char *basename = (type == xpSNewsRC ? ".snewsrc" : ".newsrc"); const char *suffix = (type == xpTemporaryNewsRC ? ".tmp" : ""); if (*name) sprintf (buf, "%.800s%.1s%.8s-%.128s%.4s", newsrc_dir, (newsrc_dir[XP_STRLEN(newsrc_dir)-1] == '/' ? "" : "/"), basename, name, suffix); else sprintf (buf, "%.800s%.1s%.128s%.4s", newsrc_dir, (newsrc_dir[XP_STRLEN(newsrc_dir)-1] == '/' ? "" : "/"), basename, suffix); name = buf; break; } case xpNewsgroups: case xpSNewsgroups: { #ifndef OLD_UNIX_FILES sprintf (buf, "%.800s/%snewsgroups-%.128s", conf_dir, type == xpSNewsgroups ? "s" : "", name); #else /* OLD_UNIX_FILES */ sprintf (buf, "%.800s/.netscape-%snewsgroups-%.128s", conf_dir, type == xpSNewsgroups ? "s" : "", name); #endif /* OLD_UNIX_FILES */ name = buf; break; } case xpExtCacheIndex: #ifndef OLD_UNIX_FILES sprintf (buf, "%.900s/cachelist", conf_dir); #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-cache-list", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpGlobalHistory: name = FE_GlobalHist; break; case xpCertDB: #ifndef OLD_UNIX_FILES if ( name ) { sprintf (buf, "%.900s/cert%s.db", conf_dir, name); } else { sprintf (buf, "%.900s/cert.db", conf_dir); } #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-certdb", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpCertDBNameIDX: #ifndef OLD_UNIX_FILES sprintf (buf, "%.900s/cert-nameidx.db", conf_dir); #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-certdb-nameidx", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpKeyDB: #ifndef OLD_UNIX_FILES if ( name ) { sprintf (buf, "%.900s/key%s.db", conf_dir, name); } else { sprintf (buf, "%.900s/key.db", conf_dir); } #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-keydb", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpSecModuleDB: sprintf (buf, "%.900s/secmodule.db", conf_dir); name = buf; break; case xpSignedAppletDB: { #ifndef OLD_UNIX_FILES if ( name ) { sprintf (buf, "%.900s/signedapplet%s.db", conf_dir, name); } else { sprintf (buf, "%.900s./signedapplet.db", conf_dir); } #else /* OLD_UNIX_FILES */ sprintf (buf, "%.900s/.netscape-signedappletdb", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; } case xpFileToPost: case xpSignature: /* These are always absolute pathnames. * BUT, the user can type in whatever so * we can't assert if it doesn't begin * with a slash */ break; case xpExtCache: case xpKeyChain: case xpURL: case xpHotlist: case xpBookmarks: case xpMimeTypes: case xpSocksConfig: case xpMailFolder: #ifdef BSDI /* In bsdi, mkdir fails if the directory name is terminated * with a '/'. - dp */ if (name[strlen(name)-1] == '/') { strcpy(buf, name); buf[strlen(buf)-1] = '\0'; name = buf; } #endif #ifndef MCC_PROXY /* * These are always absolute pathnames for the Navigator. * Only the proxy (servers) may have pathnames relative * to their current working directory (the servers chdir * to their admin/config directory on startup. * */ if (name) XP_ASSERT (name[0] == '/'); #endif /* ! MCC_PROXY */ break; case xpMailFolderSummary: /* Convert /a/b/c/foo to /a/b/c/.foo.summary (note leading dot) */ { const char *slash; slash = strrchr (name, '/'); if (name) XP_ASSERT (name[0] == '/'); XP_ASSERT (slash); if (!slash) return 0; XP_MEMCPY (buf, name, slash - name + 1); buf [slash - name + 1] = '.'; XP_STRCPY (buf + (slash - name) + 2, slash + 1); XP_STRCAT (buf, ".summary"); name = buf; break; } case xpAddrBookNew: /* Convert foo.db to /a/b/c/foo.db */ { if ( name ) { sprintf (buf, "%.900s/%s", conf_dir, name); } else { sprintf (buf, "%.900s/abook.nab", conf_dir); } #if defined(DEBUG_tao) printf("\n xpAddrBookNew, xp_FileName, buf=%s\n", buf); #endif name = buf; break; } case xpAddrBook: /* Convert /a/b/c/foo to /a/b/c/foo.db (note leading dot) */ { /* Tao_27jan97 */ char *dot = NULL; int len = 0; const char *base = NULL; if (name) XP_ASSERT (name[0] == '/'); dot = XP_STRRCHR(name, '.'); if (dot) { len = dot - name + 1; XP_STRNCPY_SAFE(buf, name, len); }/* if */ XP_STRCAT (buf, ".nab"); /* Tao_02jun97 don't convert addrbook.db * reuse len, dot */ base = XP_STRRCHR(name, '/'); if (base && *base == '/') base++; #if defined(DEBUG_tao) printf("\n++++ xpAddrBook, before xp_FileName=%s\n", name); #endif if (!base || XP_STRCMP(base, "addrbook.db")) /* not old addrbook.db file */ name = buf; #if defined(DEBUG_tao) printf("\n xpAddrBook, xp_FileName=%s\n", name); #endif break; } case xpVCardFile: /* Convert /a/b/c/foo to /a/b/c/foo.vcf (note leading dot) */ { #if 1 /* Tao_27jan97 */ char *dot = NULL; int len = 0; if (name) XP_ASSERT (name[0] == '/'); dot = XP_STRRCHR(name, '.'); if (dot) { len = dot - name + 1; XP_STRNCPY_SAFE(buf, name, len); }/* if */ XP_STRCAT (buf, ".vcf"); name = buf; #if defined(DEBUG_tao_) printf("\n xp_FileName=%s\n", name); #endif #else const char *slash; slash = strrchr (name, '/'); if (name) XP_ASSERT (name[0] == '/'); XP_ASSERT (slash); if (!slash) return 0; XP_MEMCPY (buf, name, slash - name + 1); XP_STRCAT (buf, ".vcf"); name = buf; #endif break; } case xpLDIFFile: /* Convert /a/b/c/foo to /a/b/c/foo.ldif (note leading dot) */ { #if 1 /* Tao_27jan97 */ char *dot = NULL; int len = 0; if (name) XP_ASSERT (name[0] == '/'); dot = XP_STRRCHR(name, '.'); if (dot) { len = dot - name + 1; XP_STRNCPY_SAFE(buf, name, len); }/* if */ XP_STRCAT (buf, ".ldif"); name = buf; #if defined(DEBUG_tao_) printf("\n xp_FileName=%s\n", name); #endif #else const char *slash; slash = strrchr (name, '/'); if (name) XP_ASSERT (name[0] == '/'); XP_ASSERT (slash); if (!slash) return 0; XP_MEMCPY (buf, name, slash - name + 1); XP_STRCAT (buf, ".ldif"); name = buf; #endif break; } case xpJSMailFilters: sprintf(buf, "%.900s/filters.js", conf_dir); name = buf; break; case xpJSHTMLFilters: sprintf(buf, "%.900s/hook.js", conf_dir); name = buf; break; case xpNewsSort: sprintf(buf, "%.800s/xover-cache/%.128snetscape-newsrule", conf_dir, name); break; case xpMailSort: #ifndef OLD_UNIX_FILES sprintf(buf, "%.900s/mailrule", conf_dir); #else /* OLD_UNIX_FILES */ sprintf(buf, "%.900s/.netscape-mailrule", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpMailPopState: #ifndef OLD_UNIX_FILES sprintf(buf, "%.900s/popstate", conf_dir); #else /* OLD_UNIX_FILES */ sprintf(buf, "%.900s/.netscape-popstate", conf_dir); #endif /* OLD_UNIX_FILES */ name = buf; break; case xpMailFilterLog: sprintf(buf, "%.900s/.netscape-mailfilterlog", conf_dir); name = buf; break; case xpNewsFilterLog: sprintf(buf, "%.900s/.netscape-newsfilterlog", conf_dir); name = buf; break; case xpMailSubdirectory: { char * pEnd = strrchr(name, '/'); strcpy(buf, name); /* strip off the extension */ if(!pEnd) pEnd = buf; pEnd = strchr(pEnd, '.'); if(pEnd) *pEnd = '\0'; strcat(buf, ".sbd/"); name = buf; } break; case xpXoverCache: sprintf(buf, "%.800s/xover-cache/%.128s", conf_dir, name); name = buf; break; case xpNewsHostDatabase: sprintf(buf, "%.800s/newsdb", conf_dir); name = buf; break; case xpImapRootDirectory: { char prefbuf[1024]; int len = sizeof prefbuf / sizeof *prefbuf; if ((PREF_GetCharPref("mail.imap.root_dir", prefbuf, &len) == PREF_NOERROR) && *prefbuf == '/') /* guard against assert: line 806, file xp_file.c */ XP_STRNCPY_SAFE(buf, prefbuf, len); /* Copy back to the buffer that was passed in. * We couldn't have PREF_GetCharPref() just put it there * initially because the size of buf wasn't passed in * (it happens to be 1024) and PREF_GetCharPref() insists * on having a size. Sigh. */ else { char *home = getenv ("HOME"); sprintf(buf, "%s/ns_imap", (home ? home : "")); } name = buf; break; } case xpImapServerDirectory: { char prefbuf[1024]; int len = sizeof prefbuf / sizeof *prefbuf; if ((PREF_GetCharPref("mail.imap.root_dir", prefbuf, &len) == PREF_NOERROR) && *prefbuf == '/') /* guard against assert: line 806, file xp_file.c */ sprintf(buf, "%s/%s", prefbuf, name); else { char *home = getenv ("HOME"); sprintf(buf, "%s/ns_imap/%s", (home ? home : ""), name); } name = buf; break; } case xpFolderCache: sprintf (buf, "%s/summary.dat", conf_dir); name = buf; break; case xpCryptoPolicy: { extern void fe_GetProgramDirectory(char *path, int len); char *policyFN = "moz40p3"; char *mozHome = getenv("MOZILLA_HOME"); char *lang = getenv("LANG"); int result; char dirName[1024]; name = buf; if (!xp_unix_sprintf_stat(buf, conf_dir, lang, policyFN)) break; if (!xp_unix_sprintf_stat(buf, mozHome, lang, policyFN)) break; fe_GetProgramDirectory(dirName, sizeof dirName); if (!xp_unix_sprintf_stat(buf, dirName, lang, policyFN)) break; /* couldn't find it, but must leave a valid file name in buf */ sprintf(buf, "%.900s/%s", conf_dir, policyFN); break; } case xpPKCS12File: /* Convert /a/b/c/foo to /a/b/c/foo.p12 (note leading dot) */ { int len = 0; if(name) { XP_ASSERT(name[0] == '/'); /* only append if there is enough space in the buffer */ /* this should be changed if the size of the buf changes */ if((XP_STRLEN(name) + 4) <= 1020) { /* include NULL in length */ len = XP_STRLEN(name) + 1; XP_STRNCPY_SAFE(buf, name, len); /* we want to concatenate ".p12" if it is not the * last 4 characters of the name already. * If len is less than 5 (including the terminating * NULL), it is not ".p12". * If the len is > 5 it may have the .p12, so we want * to check and only append .p12 if the name * specified does not end in .p12. * only side effect -- this allows for the filename * ".p12" which is fine. */ if((len >= 5) && XP_STRCASECMP(&(name[len-4-1]), ".p12")) { XP_STRCAT(buf, ".p12"); } else if(len < 5) { /* can't be ".p12", so we append ".p12" */ XP_STRCAT(buf, ".p12"); } name = buf; } } break; } case xpJSCookieFilters: { sprintf(buf, "%.900s/cookies.js", conf_dir); name = buf; break; } case xpLIPrefs: { sprintf(buf, "%.900s/liprefs.js", conf_dir); name = buf; break; } default: abort (); } return (char *) name; }
static const char * xfe_netcaster_path(void) /* * description: * Determine a path to tab.htm, which is * loaded into a browser window to start * Netcaster by checking * the following locations in order: * $HOME/.netscape/netcast/tab.htm * $MOZILLA_HOME/netcast/tab.htm * Version Registry via VR_GetPath() * fe_GetProgramDirectory()/netcast/tab.htm * * The reason for precedence is as follows: * $HOME first. Preferences set in a user's * $HOME override everything else. * This allows users some chance of running in * the case where the system admin won't install * Netcaster in globally accessible location. * This can also be useful for debugging purposes. * * $MOZILLA_HOME is now recommended as the standard * for finding Communicator and related components. * It comes next. * * The registry should get set correctly during ASD install. * However the registry's role in tracking versions has * been emphasized over its role in tracking location. * (although you can't have the former without the latter). * Rumor also has it that some people are in the habit * of deleting the registry to fix problems, so it * may not always be available. * * Last resort is to do our best effort at determining * where Communicator was invoked by getting the program directory * by looking at the invocation path. * * returns: * On success returns a path to tab.htm * On failure returns NULL * ****************************************/ { const char * result = 0; char * home; REGERR code; if (!private_xfe_netcaster_path) { private_xfe_netcaster_path = (char*)XP_ALLOC(MAXPATHLEN); if (private_xfe_netcaster_path) private_xfe_netcaster_path[0] = '\0'; else return result; } if (private_xfe_netcaster_path[0]) { result = private_xfe_netcaster_path; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path a %s\n",result); #endif return result; } // // CHECK $HOME/.netscape // home = getenv("HOME"); if (home) { XP_STRCPY(private_xfe_netcaster_path, home); if (xfe_last_character(private_xfe_netcaster_path) != '/') XP_STRCAT(private_xfe_netcaster_path,"/"); XP_STRCAT(private_xfe_netcaster_path,".netscape/"); XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath); if (xfe_path_exists(private_xfe_netcaster_path)) { result = private_xfe_netcaster_path; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path b %s\n",result); #endif return result; } } // // CHECK $MOZILLA_HOME // home = getenv("MOZILLA_HOME"); if (home) { XP_STRCPY(private_xfe_netcaster_path, home); if (xfe_last_character(private_xfe_netcaster_path) != '/') XP_STRCAT(private_xfe_netcaster_path,"/"); XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath); if (xfe_path_exists(private_xfe_netcaster_path)) { result = private_xfe_netcaster_path; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path c %s\n",result); #endif return result; } } // // CHECK THE REGISTRY // // Could also call VR_InRegistry("Netcaster") but it would be redundant // Note that VR_ValidateComponent also calls VR_GetPath() but it doesn't // return any path information // code = VR_GetPath(netcasterTabHtmlRegistryNode, sizeof(private_xfe_netcaster_path)-1, private_xfe_netcaster_path); if (code == REGERR_OK) { code = VR_ValidateComponent(netcasterTabHtmlRegistryNode); if (code == REGERR_OK && xfe_path_exists(private_xfe_netcaster_path)) // extra check { result = private_xfe_netcaster_path; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path d %s\n",result); #endif return result; } } private_xfe_netcaster_path[0] = '\0'; // // CHECK THE PROGRAM DIRECTORY // fe_GetProgramDirectory(private_xfe_netcaster_path, MAXPATHLEN - 1); if (private_xfe_netcaster_path[0]) { if (xfe_last_character(private_xfe_netcaster_path) != '/') XP_STRCAT(private_xfe_netcaster_path,"/"); XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath); if (xfe_path_exists(private_xfe_netcaster_path)) { result = private_xfe_netcaster_path; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path e %s\n",result); #endif return result; } } private_xfe_netcaster_path[0] = '\0'; #ifdef DEBUG_rodt printf("DEBUG_rodt: Netcaster path not found\n"); #endif return result; }
static REGERR vr_GetUninstallItemPath(char *regPackageName, char *regbuf, uint32 regbuflen) { XP_Bool bSharedUninstall = FALSE; XP_Bool bNavPackage = FALSE; uint32 len = 0; uint32 sharedstrlen = 0; uint32 curstrlen = 0; uint32 curregbuflen = 0; /* determine install type */ if (*regPackageName == '\0') { bNavPackage = TRUE; } else if ( *regPackageName == PATHDEL) { bSharedUninstall = TRUE; } /* create uninstall path prefix */ len = XP_STRLEN(REG_UNINSTALL_DIR); if (len < regbuflen) { XP_STRCPY( regbuf, REG_UNINSTALL_DIR ); } else { return REGERR_BUFTOOSMALL; } if (bSharedUninstall) { sharedstrlen = XP_STRLEN(SHAREDSTR); if (sharedstrlen < (regbuflen - len)) XP_STRCAT( regbuf, SHAREDSTR ); else return REGERR_BUFTOOSMALL; } else { curstrlen = XP_STRLEN(gCurstr); if (curstrlen < (regbuflen - len)) XP_STRCAT( regbuf, gCurstr ); else return REGERR_BUFTOOSMALL; if (1 < (regbuflen - len - curstrlen)) XP_STRCAT( regbuf, "/" ); else return REGERR_BUFTOOSMALL; } /* add final uninstall node name */ len = 0; curregbuflen = XP_STRLEN(regbuf); if ( bNavPackage ) { len = XP_STRLEN(UNINSTALL_NAV_STR); if (len < (regbuflen - curregbuflen)) XP_STRCAT( regbuf, UNINSTALL_NAV_STR ); else return REGERR_BUFTOOSMALL; } else { len = XP_STRLEN(regPackageName); if (len < (regbuflen - curregbuflen)) XP_STRCAT( regbuf, regPackageName ); else return REGERR_BUFTOOSMALL; } return REGERR_OK; }
VR_INTERFACE(REGERR) VR_UninstallEnumSharedFiles(char *component_path, REGENUM *state, char *buffer, uint32 buflen) { REGERR err; RKEY key = 0; char *regbuf; char *converted_component_path; uint32 convertedDataLength = 0; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( component_path == NULL ) return REGERR_PARAM; convertedDataLength = 2 * XP_STRLEN(component_path) + 1; converted_component_path = (char*)XP_ALLOC(convertedDataLength); if (converted_component_path == NULL ) { err = REGERR_MEMORY; return err; } err = vr_convertPackageName(component_path, converted_component_path, convertedDataLength); if (err != REGERR_OK) { XP_FREEIF(converted_component_path); return err; } regbuflen = 256 + XP_STRLEN(converted_component_path); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(converted_component_path, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegGetKey( vreg, ROOTKEY_PRIVATE, regbuf, &key ); } else err = REGERR_BUFTOOSMALL; } XP_FREE(regbuf); } else { err = REGERR_MEMORY; } XP_FREE(converted_component_path); if (err == REGERR_OK) err = NR_RegEnumEntries( vreg, key, state, buffer, buflen, NULL); return err; } /* UninstallEnumSharedFiles */
// tooltips and doc string char *XFE_AddrBookView::getDocString(CommandType cmd) { uint32 count = 0; const int *indices = 0; m_outliner->getSelection(&indices, (int *) &count); if (count > 0) { char *names = 0; char a_line[512]; a_line[0] = '\0'; int len = 0; for (int i=0; i < count && len < 512; i++) { /* Take the first one */ #if defined(USE_ABCOM) AB_AttributeValue *value = NULL; int error = AB_GetEntryAttributeForPane(m_pane, (MSG_ViewIndex) indices[i], AB_attribFullName, &value); XP_ASSERT(value && value->attrib == AB_attribFullName); XP_SAFE_SPRINTF(a_line, sizeof(a_line), "%s", value->u.string?value->u.string:""); AB_FreeEntryAttributeValue(value); #else ABID entry; entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) indices[i]); AB_GetFullName(m_dir, m_AddrBook, entry, a_line); #endif /* USE_ABCOM */ if (a_line) { len += XP_STRLEN(a_line); if (i) len += 2; names = names? ((char *) XP_REALLOC(names, (len+1)*sizeof(char))): ((char *) XP_CALLOC(1+len, sizeof(char))); if (i) names = XP_STRCAT(names, ", "); names = XP_STRCAT(names, a_line); }/* if */ }/* for i */ char *cstr = 0; if (cmd == xfeCmdComposeMessage || cmd == xfeCmdComposeMessageHTML || cmd == xfeCmdComposeMessagePlain) { cstr = XP_STRDUP(XP_GetString(XFE_SEND_MSG_TO)); } else if (cmd == xfeCmdABCall) { cstr = XP_STRDUP(XP_GetString(XFE_PLACE_CONFERENCE_CALL_TO)); } len += XP_STRLEN(cstr); cstr = (char *) XP_REALLOC(cstr, (1+len)*sizeof(char)); cstr = (char *) XP_STRCAT(cstr, names); return cstr; }/* if */ return NULL; }
PA_Block lo_ValueToRoman(int32 value, Bool large, intn *len_ptr) { int i, j; int indx[4]; char str[4][6]; char *fives; char *ones; char str2[22]; char *ptr; PA_Block buff; char *bptr; *len_ptr = 0; if (large != FALSE) { fives = Fives[1]; ones = Ones[1]; } else { fives = Fives[0]; ones = Ones[0]; } if (value >= 4000) { value = value % 3999; value++; } for (i=0; i<4; i++) { indx[i] = (int) value % 10; value = value / 10; } for (i=0; i<4; i++) { if (indx[i] >= 5) { indx[i] -= 5; str[i][0] = fives[i]; } else { str[i][0] = ' '; } if (indx[i] == 4) { if (str[i][0] == ' ') { str[i][1] = fives[i]; } else { str[i][1] = ones[i + 1]; } str[i][0] = ones[i]; str[i][2] = '\0'; } else { for (j=0; j<indx[i]; j++) { str[i][j + 1] = ones[i]; } str[i][indx[i] + 1] = '\0'; } } XP_STRCPY(str2, ""); for (i=3; i>=0; i--) { ptr = str[i]; if (*ptr == ' ') { ptr++; } XP_STRCAT(str2, ptr); } XP_STRCAT(str2, "."); *len_ptr = XP_STRLEN(str2); buff = PA_ALLOC(*len_ptr + 1); if (buff != NULL) { PA_LOCK(bptr, char *, buff); XP_STRCPY(bptr, str2); PA_UNLOCK(buff); } return(buff); }
static REGERR vr_Init(void) { REGERR err = REGERR_OK; char *regname = vr_findVerRegName(); #if defined(XP_UNIX) && !defined(XP_MACOSX) || defined(STANDALONE_REGISTRY) char curstr[MAXREGNAMELEN]; RKEY navKey; #endif #if defined(XP_UNIX) && !defined(XP_MACOSX) char *regbuf = NULL; #endif #ifndef STANDALONE_REGISTRY if (vr_lock == NULL) return REGERR_FAIL; #endif PR_Lock(vr_lock); if (!isInited) { #if defined(XP_UNIX) && !defined(XP_MACOSX) /* need browser directory to find the correct registry */ if (app_dir != NULL) { regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(app_dir) ); if (regbuf != NULL ) { XP_STRCPY( regbuf, app_dir ); XP_STRCAT( regbuf, "/registry" ); } else { err = REGERR_MEMORY; } } if ( err != REGERR_OK ) goto done; if (bGlobalRegistry) regname = regbuf; #endif /* Open version registry */ err = NR_RegOpen( regname, &vreg ); #ifndef STANDALONE_REGISTRY if (err == REGERR_OK) { /* find/set the current nav node */ err = vr_SetCurrentNav( VERSION_NAME, app_dir, NULL ); if ( REGERR_OK != err ) { /* couldn't find or set current nav -- big problems! */ NR_RegClose( vreg ); goto done; } } #if defined(XP_UNIX) && !defined(XP_MACOSX) /* try to open shared Unix registry, but not an error if you can't */ unixreg = NULL; if (!bGlobalRegistry && err == REGERR_OK ) { unixver = 0; if (NR_RegOpen( regbuf, &unixreg ) == REGERR_OK) { if (NR_RegGetKey( unixreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey) == REGERR_OK) { if (NR_RegGetEntryString( unixreg, navKey, CURRENT_VER, curstr, sizeof(curstr)) == REGERR_OK ) { NR_RegGetKey( unixreg, navKey, curstr, &unixver ); } } } } #endif if (err == REGERR_OK) { /* successfully opened! */ isInited = 1; } goto done; #else if (err != REGERR_OK) goto done; /* Determine 'curver' key and ensure correct structure by adding */ /* ...find top-level "Navigator" node (add if missing) */ err = NR_RegAddKey( vreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey ); if (err != REGERR_OK) goto done; /* ...look for "Current Version" entry */ err = NR_RegGetEntryString( vreg, navKey, CURRENT_VER, curstr, sizeof(curstr) ); if ( err == REGERR_NOFIND ) { /* If not found create one with the built-in version */ err = NR_RegSetEntryString( vreg, navKey, CURRENT_VER, VERSION_NAME ); XP_STRCPY( curstr, VERSION_NAME ); } if ( err != REGERR_OK ) goto done; /* ...look for "curstr" child key of the navigator node */ err = NR_RegAddKey( vreg, navKey, curstr, &curver ); if (err == REGERR_OK) { /* successfully opened! */ isInited = 1; } #endif } done: PR_Unlock(vr_lock); #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(STANDALONE_REGISTRY) XP_FREEIF(regbuf); #endif return err; } /* Init */
char * xp_TempName (XP_FileType type, const char * prefix, char* buf, char* buf2, unsigned int *count) { #define NS_BUFFER_SIZE 1024 char *value = buf; time_t now; *buf = 0; XP_ASSERT (type != xpTemporaryNewsRC); if (type == xpCache || type == xpSARCache) { /* WH_TempName() must return relative pathnames for the cache files, so that relative paths get written into the cacheFAT database, making the directory relocatable. */ *buf = 0; } else if ( (type == xpURL) && prefix ) { if ( XP_STRRCHR(prefix, '/') ) { XP_StatStruct st; XP_SPRINTF (buf, "%.500s", prefix); if (XP_Stat (buf, &st, xpURL)) XP_MakeDirectoryR (buf, xpURL); prefix = "su"; } } else { char *tmp = FE_TempDir; if (!tmp || !*tmp) tmp = "/tmp"; XP_SPRINTF (buf, "%.500s", tmp); if (!prefix || !*prefix) prefix = "tmp"; } XP_ASSERT (!XP_STRCHR (prefix, '/')); if (*buf && buf[XP_STRLEN (buf)-1] != '/') XP_STRCAT (buf, "/"); /* It's good to have the cache file names be pretty long, with a bunch of inputs; this makes the variant part be 15 chars long, consisting of the current time (in seconds) followed by a counter (to differentiate documents opened in the same second) followed by the current pid (to differentiate simultanious processes.) This organization of the bits has the effect that they are ordered the same lexicographically as by creation time. If name length was an issue we could cut the character count a lot by printing them in base 72 [A-Za-z0-9@%-_=+.,~:]. */ now = time ((time_t *) 0); sprintf (buf2, "%08X%03X%04X", (unsigned int) now, (unsigned int) *count, (unsigned int) (getpid () & 0xFFFF)); if (++(*count) > 4095) (*count) = 0; /* keep it 3 hex digits */ #ifdef CACHE_SUBDIRS if (type == xpCache || type == xpSARCache) { XP_StatStruct st; char *s; char *tmp = (type == xpCache) ? FE_CacheDir : FE_SARCacheDir; if (!tmp || !*tmp) tmp = "/tmp"; sprintf (buf, "%.500s", tmp); if (buf [XP_STRLEN(buf)-1] != '/') XP_STRCAT (buf, "/"); s = buf + XP_STRLEN (buf); value = s; /* return a relative path! */ /* The name of the subdirectory is the bottom 5 bits of the time part, in hex (giving a total of 32 directories.) */ sprintf (s, "%02X", (now & 0x1F)); if (XP_Stat (buf, &st, xpURL)) /* create the dir if necessary */ XP_MakeDirectory (buf, type); s[2] = '/'; s[3] = 0; } #endif /* !CACHE_SUBDIRS */ XP_STRNCAT (value, prefix, NS_BUFFER_SIZE - XP_STRLEN(value)); XP_STRNCAT (value, buf2, NS_BUFFER_SIZE - XP_STRLEN(value)); /* Tao */ if (type == xpAddrBook) { XP_STRNCAT (value, ".nab", NS_BUFFER_SIZE - XP_STRLEN(value)); }/* if */ value[NS_BUFFER_SIZE - 1] = '\0'; /* just in case */ DO_TRACE(("WH_TempName called: returning: %s", value)); return(value); }
VR_INTERFACE(REGERR) VR_EnumUninstall(REGENUM *state, char* userPackageName, int32 len1, char*regPackageName, int32 len2, XP_Bool bSharedList) { REGERR err; RKEY key; RKEY key1; char regbuf[MAXREGPATHLEN+1] = {0}; char temp[MAXREGPATHLEN+1] = {0}; err = vr_Init(); if (err != REGERR_OK) return err; XP_STRCPY( regbuf, REG_UNINSTALL_DIR ); if (bSharedList) { XP_STRCAT( regbuf, SHAREDSTR ); } else { XP_STRCAT( regbuf, gCurstr ); } err = NR_RegGetKey( vreg, ROOTKEY_PRIVATE, regbuf, &key ); if (err != REGERR_OK) return err; *regbuf = '\0'; *userPackageName = '\0'; err = NR_RegEnumSubkeys( vreg, key, state, regbuf, sizeof(regbuf), REGENUM_CHILDREN); if (err == REGERR_OK && !bSharedList ) { if (XP_STRCMP(regbuf, UNINSTALL_NAV_STR) == 0) { /* skip Communicator package, get the next one instead */ err = NR_RegEnumSubkeys( vreg, key, state, regbuf, sizeof(regbuf), REGENUM_CHILDREN); } } if (err != REGERR_OK) return err; err = NR_RegGetKey( vreg, key, regbuf, &key1 ); if (err != REGERR_OK) return err; err = NR_RegGetEntryString( vreg, key1, PACKAGENAMESTR, userPackageName, len1); if (err != REGERR_OK) { *userPackageName = '\0'; return err; } if (len2 <= (int32)XP_STRLEN(regbuf)) { err = REGERR_BUFTOOSMALL; *userPackageName = '\0'; return err; } *regPackageName = '\0'; if (bSharedList) { XP_STRCPY(temp, "/"); XP_STRCAT(temp, regbuf); *regbuf = '\0'; XP_STRCPY(regbuf, temp); } err = vr_unmanglePackageName(regbuf, regPackageName, len2); return err; } /* EnumUninstall */
char * XFE_ABDirListView::DragConvert(Atom atom) { /* pack data */ if (atom == XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV) { #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::DragConvert:_XA_NETSCAPE_DIRSERV\n"); #endif uint32 count = 0; const int *indices = 0; m_outliner->getSelection(&indices, (int *) &count); char tmp[32]; sprintf(tmp, "%d", count); int len = XP_STRLEN(tmp); char *buf = (char *) XtCalloc(len, sizeof(char)); buf = XP_STRCAT(buf, tmp); for (int i=0; i < count; i++) { sprintf(tmp, "%d", indices[i]); len += XP_STRLEN(tmp)+1; buf = XtRealloc(buf, len); buf = XP_STRCAT(buf, " "); buf = XP_STRCAT(buf, tmp); }/* for i */ #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::DragConvert:_XA_NETSCAPE_DIRSERV=%x\n", buf); #endif return buf; }/* if */ else if (atom == XFE_OutlinerDrop::_XA_NETSCAPE_PAB) { #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::DragConvert:_XA_NETSCAPE_PAB\n"); #endif uint32 count = 0; const int *indices = 0; m_outliner->getSelection(&indices, (int *) &count); char tmp[32]; sprintf(tmp, "%d", count); int len = XP_STRLEN(tmp); char *buf = (char *) XtCalloc(len, sizeof(char)); buf = XP_STRCAT(buf, tmp); for (int i=0; i < count; i++) { sprintf(tmp, "%d", indices[i]); len += XP_STRLEN(tmp)+1; buf = XtRealloc(buf, len); buf = XP_STRCAT(buf, " "); buf = XP_STRCAT(buf, tmp); }/* for i */ #if defined(DEBUG_tao) printf("\nXFE_ABDirListView::DragConvert:_XA_NETSCAPE_PAB=%x\n", buf); #endif return buf; }/* else if */ return (char *) NULL; }
/* * Unlike hk_TagIndexToFunctionString (above) this function is passed * a PA_Tag inside extra, so it can even make the dynamic hook * name for UNKNOWN HTML tags. */ char * hk_TagFunctionString(const char *func_name, void *extra) { PA_Tag *tag; char *tag_text; char *total_name; tag_text = NULL; tag = (PA_Tag *)extra; if ((tag == NULL)||(func_name == NULL)) { return NULL; } if (tag->type == P_TEXT) { tag_text = XP_STRDUP("TEXT"); } else if (tag->type == P_UNKNOWN) { char *tptr; int32 cnt; tptr = (char *)tag->data; cnt = 0; while ((*tptr != '>')&&(!XP_IS_SPACE(*tptr))&& (cnt < tag->data_len)) { tptr++; cnt++; } if ((cnt > 0)&&(cnt < tag->data_len)) { char tchar; tchar = *tptr; *tptr = '\0'; tag_text = XP_STRDUP((char *)tag->data); *tptr = tchar; } else { tag_text = XP_STRDUP("UNKNOWN"); } } else { const char *tag_name; tag_name = PA_TagString((int32)tag->type); if (tag_name == NULL) { tag_text = XP_STRDUP("UNKNOWN"); } else { tag_text = XP_STRDUP(tag_name); } } if (tag_text != NULL) { int32 total_len; total_len = XP_STRLEN(func_name) + XP_STRLEN(tag_text) + 3; total_name = XP_ALLOC(total_len); if (total_name == NULL) { XP_FREE(tag_text); return NULL; } XP_STRCPY(total_name, tag_text); XP_STRCAT(total_name, func_name); return total_name; } else { return NULL; } }