/* * SetDirectoryPath * sets full path to the directory in the standard URL form */ char* nsFolderSpec::SetDirectoryPath(char* *errorMsg) { if ((folderID == NULL) || (versionRegistryPath == NULL)) { *errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor", SUERR_INVALID_ARGUMENTS); return NULL; } if (urlPath == NULL) { if (XP_STRCMP(folderID, "User Pick") == 0) { // Default package folder // Try the version registry default path first // urlPath = VersionRegistry.getDefaultDirectory( versionRegistryPath ); // if (urlPath == NULL) urlPath = PickDefaultDirectory(errorMsg); } else if (XP_STRCMP(folderID, "Installed") == 0) { // Then use the Version Registry path urlPath = XP_STRDUP(versionRegistryPath); } else { // Built-in folder /* NativeGetDirectoryPath updates urlPath */ int err = NativeGetDirectoryPath(); if (err != 0) *errorMsg = SU_GetErrorMsg3(folderID, err); } } return urlPath; }
MWContext* xp_FindNamedContextInChildren(MWContext* self, char* name, MWContext* excludeChild) { int i; /* XP_TRACE(("Searching for %s: context %0x, name=%s, title=%s\n", (name ? name : ""), self, (self->name ? self->name : ""), (self->title ? self->title : ""))); */ if (self->name && XP_STRCMP(self->name, name) == 0) { /* XP_TRACE(("Found %s context %0x name=%s\n", (name ? name : ""), self, self->name)); */ return self; } if (self->grid_children) { int count = XP_ListCount(self->grid_children); for (i = 1; i <= count; i++) { MWContext* child = (MWContext*)XP_ListGetObjectNum(self->grid_children, i); if (child != excludeChild) { MWContext* found = xp_FindNamedContextInChildren(child, name, NULL); if (found) return found; } } } return NULL; }
static void SaltPseudoClass(const char * pseudo_class, StyleBuffer sb) { if (! pseudo_class) return; /* The parser always gives these strings in lower case. */ if (0 == XP_STRCMP(pseudo_class, "link")) sb->pseudo_class_state = CSS_PSEUDO_CLASS_LINK; else if (0 == XP_STRCMP(pseudo_class, "visited")) sb->pseudo_class_state = CSS_PSEUDO_CLASS_VISITED; else if (0 == XP_STRCMP(pseudo_class, "active")) { #if (! ALLOW_ACTIVE_PSEUDO_CLASS) IgnoreRule(sb); #endif sb->pseudo_class_state = CSS_PSEUDO_CLASS_ACTIVE; } }
/* * Look through the list of finished maps to find one with * a matching name. If found, remove it. */ static lo_MapRec * lo_remove_named_map(MWContext *context, lo_DocState *state, char *map_name) { lo_MapRec *prev_map; lo_MapRec *map_list; if (map_name == NULL) { return(NULL); } prev_map = NULL; map_list = state->top_state->map_list; while (map_list != NULL) { /* * Found a map with a matching name, return it. */ if (XP_STRCMP(map_name, map_list->name) == 0) { break; } prev_map = map_list; map_list = map_list->next; } /* * No map by that name found. */ if (map_list == NULL) { return(NULL); } /* * If no prev_map, our match is the head of the map_list. */ if (prev_map == NULL) { state->top_state->map_list = map_list->next; } else { prev_map->next = map_list->next; } map_list->next = NULL; return(map_list); }
loc_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { JSURL *url; MochaDecoder *decoder; MWContext *context; const char *url_string; JSString *str; if (!JSVAL_IS_INT(id) || JSVAL_TO_INT(id) < 0) return JS_TRUE; url = JS_GetInstancePrivate(cx, obj, &lm_location_class, NULL); if (!url) return JS_TRUE; decoder = url->url_decoder; context = decoder->window_context; if (!context) return JS_TRUE; if (context->type == MWContextMail || context->type == MWContextNews || context->type == MWContextMailMsg || context->type == MWContextNewsMsg) { /* * Don't give out the location of a the mail folder to a script * embedded in a mail message. Just return the empty string. */ url->href = JSVAL_TO_STRING(JS_GetEmptyStringValue(cx)); } else { /* * Only need to check permissions for native getters */ if (!lm_CheckPermissions(cx, obj, JSTARGET_UNIVERSAL_BROWSER_READ)) return JS_FALSE; url_string = get_url_string(cx, obj); if (url_string && (!url->href || XP_STRCMP(JS_GetStringBytes(url->href), url_string) != 0)) { str = JS_NewStringCopyZ(cx, url_string); if (!str) return JS_FALSE; url->href = str; } } return url_getProperty(cx, obj, id, vp); }
PRBool nsFolderSpec::NativeIsJavaDir() { char* folderName; /* Get the name of the package to prompt for */ folderName = folderID; PR_ASSERT( folderName ); if ( folderName != NULL) { int i; for (i=0; DirectoryTable[i].directoryName[0] != 0; i++ ) { if ( XP_STRCMP(folderName, DirectoryTable[i].directoryName) == 0 ) return DirectoryTable[i].bJavaDir; } } return PR_FALSE; }
static XP_Bool IsReservedWord(const char * css_name) { int lower = 0; int upper = (sizeof(reserved_words) / sizeof(char *)) - 1; int x; int32 result; while (upper >= lower) { x = (lower + upper) / 2; result = XP_STRCMP(css_name, reserved_words[x]); if (result < 0) upper = x - 1; else if (result > 0) lower = x + 1; else return 1; } return 0; }
/* Backend is not calling FE_PaneChanged on Ldap Directory change right now, therefore, this method is not in use. However, the backend should really call FE_PaneChanged when directory order is changed in the prefs. That notification is hooked up for address book not for ldap search. Has filed a bug to phil */ void XFE_LdapSearchView::paneChanged(XP_Bool /*asynchronous*/, MSG_PANE_CHANGED_NOTIFY_CODE /* notify_code */, int32 /*value*/) { /* Shall we free existing list ? */ m_directories = FE_GetDirServers(); int nDirs = XP_ListCount(m_directories); XP_Bool found = False; for (int i=0; i < nDirs; i++) { DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1); if (dir == m_dir || (dir && m_dir && (dir->dirType == m_dir->dirType))) { if ((dir->serverName==NULL && m_dir->serverName==NULL) || (dir->serverName && m_dir->serverName && !XP_STRCMP(dir->serverName, m_dir->serverName))) { found = True; break; }/* if */ }/* if */ }/* for i*/ if (!found) { /* m_dir got deleted */ m_dir = NULL; if ( !m_dir && nDirs ) { /* there are still some directories installed, pick the first one for best guess */ m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1 ); } } if (!m_dir) /* non-directory left.... close search dialog*/ handleClose(); }
int main(int argc, char **argv) { char url[4028]; struct stat stat_s; net_CacheObject * cache_obj; DB * ext_cache_database=0; DBT key; DBT data; int len; char *end; memset(&cache_obj, 0, sizeof(net_CacheObject)); if(argc != 2) { printf("Usage:\n" "%s database\n" "\n" "database: path and name of the database\n", argv[0]); exit(1); } /* open the cache database */ ext_cache_database = net_OpenExtCacheFatDB(argv[1]); if(!ext_cache_database) { perror("Could not open cache database"); exit(1); } while(!(ext_cache_database->seq)(ext_cache_database, &key, &data, 0)) { if(key.size == XP_STRLEN(EXT_CACHE_NAME_STRING) && !XP_STRCMP(key.data, EXT_CACHE_NAME_STRING)) { /* make sure it's a terminated string */ if(((char *)data.data)[data.size-1] == '\0') printf("\n\nDatabase Name: %s\n", (char*)data.data); else printf("\n\nDatabase Name is corrupted!\n"); printf("\n--------------------------------------\n"); continue; } /* try and convert the db struct to a cache struct */ cache_obj = net_DBDataToCacheStruct(&data); if(!cache_obj) { printf("Malformed database entry:\n"); printf("key: "); fwrite(key.data, 1, key.size, stdout); printf("\ndata: "); fwrite(data.data, 1, data.size, stdout); printf("\n"); printf("--------------------------------------\n"); continue; } /* the URL is 8 bytes into the key struct */ printf("URL: %s\n",(char*)key.data+8); printf("file: %s\n", cache_obj->filename); printf("is_relative_path: %s\n", cache_obj->is_relative_path ? "TRUE" : "FALSE"); printf("content_type: %s\n", cache_obj->content_type); printf("content_length: %d\n", cache_obj->content_length); printf("last_modified: %s\n", ctime(&cache_obj->last_modified)); printf("--------------------------------------\n"); } }
MWContext * XP_FindNamedContextInList(MWContext * context, char *name) { int i; if ((name == NULL) || (xp_GlobalContextList == NULL)) return context; /* * Check for special magic window target names */ if (name[0] == '_') { if (XP_STRNCMP(name, "_self", 5) == 0) { return context; } else if (XP_STRNCMP(name, "_parent", 7) == 0) { if ((context)&&(context->grid_parent)) { return context->grid_parent; } else { return context; } } else if (XP_STRNCMP(name, "_top", 4) == 0) { MWContext *top; top = context; while ((top)&&(top->grid_parent)) { top = top->grid_parent; } return top; } else if (XP_STRNCMP(name, "_blank", 6) == 0) { return NULL; } /* else, search for the name, below */ } { MWContext* cx = context; MWContext* found; if (context) { /* If our current context has the right name, go there */ if (cx->name && (XP_STRCMP(cx->name, name) == 0)) return cx; found = xp_FindNamedContextInChildren(cx, name, NULL); if (found) return found; while (cx->is_grid_cell) { MWContext* parent = cx->grid_parent; found = xp_FindNamedContextInChildren(parent, name, cx); if (found) return found; cx = parent; } } /* otherwise, just get any other context */ for (i=1; i<= XP_ListCount(xp_GlobalContextList); i++) { MWContext* compContext = (MWContext *)XP_ListGetObjectNum(xp_GlobalContextList, i); /* Only search other top-level contexts that aren't the one we just came from: */ if (!compContext->is_grid_cell && compContext != cx) { found = xp_FindNamedContextInChildren(compContext, name, NULL); if (found) return found; } } } return NULL; }
PUBLIC NET_StreamClass * net_ColorHTMLStream (int format_out, void *data_obj, URL_Struct *URL_s, MWContext *window_id) { DataObject* obj; char *new_markup=0; char *new_url=0; char *old_url; int status, type; NET_StreamClass *next_stream, *new_stream; Bool is_html_stream = FALSE; INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(window_id); INTL_CharSetInfo next_csi; TRACEMSG(("Setting up ColorHTML stream. Have URL: %s\n", URL_s->address)); /* treat the stream as html if the closure data says * it's HTML and it is also not a mail or news message */ type = NET_URL_Type(URL_s->address); if(data_obj && !XP_STRCMP((char *)data_obj, TEXT_HTML) && type != MAILBOX_TYPE_URL && type != IMAP_TYPE_URL && type != NEWS_TYPE_URL) is_html_stream = TRUE; /* use a new named window */ StrAllocCopy(URL_s->window_target, VIEW_SOURCE_TARGET_WINDOW_NAME); /* add the url address to the name so that there can be * one view source window per url */ StrAllocCat(URL_s->window_target, URL_s->address); /* zero position_tag to prevent hash lossage */ URL_s->position_tag = 0; /* alloc a new chrome struct and stick it in the URL * so that we can turn off the relavent stuff */ URL_s->window_chrome = XP_NEW(Chrome); if(URL_s->window_chrome) { /* zero everything to turn off all chrome */ XP_MEMSET(URL_s->window_chrome, 0, sizeof(Chrome)); URL_s->window_chrome->type = MWContextDialog; URL_s->window_chrome->show_scrollbar = TRUE; URL_s->window_chrome->allow_resize = TRUE; URL_s->window_chrome->allow_close = TRUE; } /* call the HTML parser */ StrAllocCopy(URL_s->content_type, INTERNAL_PARSER); /* use the view-source: url instead */ StrAllocCopy(new_url, VIEW_SOURCE_URL_PREFIX); StrAllocCat(new_url, URL_s->address); old_url = URL_s->address; URL_s->address = new_url; format_out = FO_PRESENT; /* open next stream */ next_stream = NET_StreamBuilder(format_out, URL_s, window_id); if(!next_stream) { FREE(old_url); return(NULL); } next_csi = LO_GetDocumentCharacterSetInfo(next_stream->window_id); /* jliu: for international's reason, set the value ASAP, so the following stream can share it */ INTL_SetCSIWinCSID(next_csi, INTL_GetCSIWinCSID(csi)); INTL_SetCSIDocCSID(next_csi, INTL_GetCSIDocCSID(csi)); #define DEF_PICS_LABEL "<META http-equiv=PICS-Label content='(PICS-1.0 \"http://home.netscape.com/default_rating\" l gen true r (s 0))'>" /* add a PICS label */ StrAllocCopy(new_markup, DEF_PICS_LABEL); StrAllocCat(new_markup, "<TITLE>"); StrAllocCat(new_markup, XP_GetString(MK_CVCOLOR_SOURCE_OF)); StrAllocCat(new_markup, old_url); StrAllocCat(new_markup, "</TITLE><BODY BGCOLOR=#C0C0C0>"); if(!is_html_stream) StrAllocCat(new_markup, "<PLAINTEXT>"); else StrAllocCat(new_markup, "<PRE>"); FREE(old_url); status = (*next_stream->put_block)(next_stream, new_markup, XP_STRLEN(new_markup)); FREE(new_markup); if(status < 0) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } if(!is_html_stream) return(next_stream); /* else; continue on and build up this stream module * and attach the next stream to it */ new_stream = XP_NEW(NET_StreamClass); if(new_stream == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } obj = XP_NEW(DataObject); if (obj == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); FREE(new_stream); return(NULL); } XP_MEMSET(obj, 0, sizeof(DataObject)); obj->state = IN_CONTENT; obj->next_stream = next_stream; obj->tag_type = P_UNKNOWN; new_stream->name = "HTML Colorer"; new_stream->complete = (MKStreamCompleteFunc) net_ColorHTMLComplete; new_stream->abort = (MKStreamAbortFunc) net_ColorHTMLAbort; new_stream->put_block = (MKStreamWriteFunc) net_ColorHTMLWrite; new_stream->is_write_ready = (MKStreamWriteReadyFunc) net_ColorHTMLWriteReady; new_stream->data_object = (void *) obj; /* document info object */ new_stream->window_id = window_id; TRACEMSG(("Returning stream from HTMLColorConverter\n")); return new_stream; }
static BOOL wfe_IsRegisteredForPlugin(int iFormatOut, URL_Struct *pUrlStruct, MWContext *pContext) { // Find the callers mime/type in the iFormatOut registry list, // and return true if found. CString csMimeType = pUrlStruct->content_type; // Find the relevant mime type in our list. // There should always be a wild on the end of the list, but if not, duh. XP_List *list = NET_GetRegConverterList(iFormatOut); ContentTypeConverter *pConv; while(pConv = (ContentTypeConverter *)XP_ListNextObject(list)) { // Do a wild compare on the mime types if(WildMime(csMimeType, pConv->format_in)) { // May have found an appropriate converter. // Only when the viewer is not automated, // and the mime types are a case insensitive // match, return TRUE. // ZZZ: Make sure it's a plug-in and not an automated viewer. // We're doing it this demented way because pConv->bAutomated is // getting stomped and points to garbage if ((pConv->bAutomated == FALSE) && NPL_FindPluginEnabledForType(pConv->format_in)) { // only check for can handle by OLE when there is no plugin register for // the mine type. // Find out can we handle by OLE. if (strcmp(pConv->format_in, "*") == 0) /* there previously was a call to FE_FileType here, but it is clearly unnecessary given the check of fe_CanHandlebyOLE we've added. byrd. reminder - we should overhaul/remove FE_FileType and it's other call. && FE_FileType(pUrlStruct->address, pUrlStruct->content_type, pUrlStruct->content_encoding)) */ { if(iFormatOut == FO_EMBED){ /* don't have to worry about FO_CACHE_AND_EMBED since cache bit cleared by NET_CacheConverter */ /* also, don't want to interfere w/ full-page case... */ char* ext[1]; ext[0] = FE_FindFileExt(pUrlStruct->address); if(ext[0] && fe_CanHandleByOLE(ext,1)) return FALSE; else return TRUE; } else return FALSE; } else return TRUE; } // Only when the viewer is not automated, // and the handler is for wildcard MIME type, // and OLE doesn't want it, return TRUE. // ZZZ: See above comment if ((pConv->bAutomated == FALSE) && XP_STRCMP(pConv->format_in, "*") == 0 && NPL_FindPluginEnabledForType("*")) { // the following code is copied from EmbedStream(), OLE related stuff // BUG: this code needs to be shared code! // extract the extension of the file name char aExt[_MAX_EXT]; size_t stExt = 0; DWORD dwFlags = EXT_NO_PERIOD; #ifdef XP_WIN16 dwFlags |= EXT_DOT_THREE; #endif aExt[0] = '\0'; stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pUrlStruct->address, pUrlStruct->content_type); CString csFinalExtension = aExt; // Check to see if the embedded file matches any known extensions. // If not, then consider the file of no use to the user. // Use new way if we are in a different style of context. if(wfe_IsExtensionRegistrationValid(csFinalExtension, ABSTRACTCX(pContext)->GetDialogOwner(), FALSE) == FALSE) { return TRUE; } } } } return FALSE; }
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 */
/* 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; }
/* NativeComplete * copies the file to its final location * Tricky, we need to create the directories */ int nsInstallFile::NativeComplete() { char* currentName = NULL; char* finalName = NULL; char* finalNamePlatform; int result = 0; if (tempFile == NULL) { return -1; } /* Get the names */ currentName = tempFile->ToNewCString(); PR_ASSERT(finalFile != NULL); finalNamePlatform = finalFile->ToNewCString(); finalName = XP_PlatformFileToURL(finalNamePlatform); if ( finalName == NULL || currentName == NULL ) { /* memory or JRI problems */ result = -1; goto end; } else { /* convert finalName name to xpURL form by stripping "file://" */ char *temp = XP_STRDUP(&finalName[7]); XP_FREE(finalName); finalName = temp; } if (finalName != NULL) { if ( XP_STRCMP(finalName, currentName) == 0 ) { /* No need to rename, they are the same */ result = 0; } else { XP_StatStruct s; if ( XP_Stat( finalName, &s, xpURL ) != 0 ) { /* Target file doesn't exist, try to rename file */ result = XP_FileRename(currentName, xpURL, finalName, xpURL); } else { /* Target exists, can't trust XP_FileRename--do platform * specific stuff in FE_ReplaceExistingFile() */ result = -1; } } } else { /* memory problem */ result = -1; } if (result != 0) { XP_StatStruct s; if ( XP_Stat( finalName, &s, xpURL ) == 0 ) { /* File already exists, need to remove the original */ result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force); if ( result == SU_REBOOT_NEEDED ) { #ifdef XP_WIN16 if (!utilityScheduled) { utilityScheduled = PR_TRUE; FE_ScheduleRenameUtility(); } #endif } } else { /* Directory might not exist, check and create if necessary */ char separator; char * end; separator = '/'; end = XP_STRRCHR(finalName, separator); if (end) { end[0] = 0; result = XP_MakeDirectoryR( finalName, xpURL); end[0] = separator; if ( 0 == result ) result = XP_FileRename(currentName, xpURL, finalName, xpURL); } } #ifdef XP_UNIX /* Last try, can't rename() across file systems on UNIX */ if ( -1 == result ) { result = FE_CopyFile(currentName, finalName); } #endif } end: XP_FREEIF(finalName); delete currentName; delete finalNamePlatform; return result; }