⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filestub.c

📁 支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509v3证书等安全协议或标准的开发库编译用到NSPR
💻 C
📖 第 1 页 / 共 3 页
字号:
        /*  Requested name is thought to be impossible to generate. */    /* */    TRACE("No more temp file names....\n");    return(NULL);}PUBLIC char *WH_TempFileName(int type, const char * request_prefix, const char * extension){    static char file_buf[_MAX_PATH]; /* protected by _pr_TempName_lock */    char* result;    if (_pr_TempName_lock == NULL)	_pr_TempName_lock = PR_NewNamedMonitor("TempName-lock");    PR_EnterMonitor(_pr_TempName_lock);    result = XP_STRDUP(xp_TempFileName(type, request_prefix, extension, file_buf));    PR_ExitMonitor(_pr_TempName_lock);    return result;}#endif /* CMD_STUB *//* *//* Return a string that is equal to the NetName string but with the *//*  cross-platform characters changed back into DOS characters *//* The caller is responsible for XP_FREE()ing the string *//* */MODULE_PRIVATE char * XP_NetToDosFileName(const char * NetName){    char *p, *newName;    BOOL bChopSlash = FALSE;    if(!NetName)        return NULL;            /*  If the name is only '/' or begins '//' keep the */    /*    whole name else strip the leading '/' */    if(NetName[0] == '/')        bChopSlash = TRUE;    /* save just / as a path */    if(NetName[0] == '/' && NetName[1] == '\0')	bChopSlash = FALSE;    /* spanky Win9X path name */    if(NetName[0] == '/' && NetName[1] == '/')	bChopSlash = FALSE;    if(bChopSlash)        newName = XP_STRDUP(&(NetName[1]));    else        newName = XP_STRDUP(NetName);    if(!newName)        return NULL;    for(p = newName; *p; p++) {        switch(*p) {            case '|':                *p = ':';                break;            case '/':                *p = '\\';                break;            default:                break;        }    }    return(newName);}/* *//* Returns the absolute name of a file  *//*  *//* The result of this function can be used with the standard *//* open/fopen ansi file functions *//* */PUBLIC char * xp_FileName(const char * name, XP_FileType type, char* *myName){    char * newName    = NULL;    char * netLibName = NULL;    char * tempName   = NULL;    char * prefStr    = NULL;    BOOL   bNeedToRegister = FALSE;   /* == do we need to register a new  */                                      /*   newshost->file name mapping */    struct _stat sInfo;    int iDot;    int iColon;#ifndef CMD_STUB    CString csHostName;    CString csHost;    CString fileName;#endif    switch(type) {#ifndef CMD_STUB    case xpCacheFAT:	newName = (char *) XP_ALLOC(_MAX_PATH);	sprintf(newName, "%s\\fat.db", (const char *)theApp.m_pCacheDir);	break;    case xpExtCacheIndex:	newName = (char *) XP_ALLOC(_MAX_PATH);	sprintf(newName, "%s\\extcache.fat", (const char *)theApp.m_pCacheDir);	break;    case xpSARCacheIndex:        newName = (char *) XP_ALLOC(_MAX_PATH);        sprintf(newName, "%s\\archive.fat", theApp.m_pSARCacheDir);        break;    case xpHTTPCookie:	newName = (char *) XP_ALLOC(_MAX_PATH);	/*sprintf(newName, "%s\\cookies.txt", theApp.m_pInstallDir->GetCharValue()); */	/* changed to support multi-profile */	sprintf(newName, "%s\\cookies.txt", (const char *)theApp.m_UserDirectory);	break;#ifndef MOZ_LITE          case xpSNewsRC:    case xpNewsRC:        /* see if we are asking about the default news host */        /* else look up in netlib */        if ( !name || !strlen(name) )            name = g_MsgPrefs.m_csNewsHost;        netLibName = NET_MapNewsrcHostToFilename((char *)name,                                                  (type == xpSNewsRC),                                                 FALSE);                /* if we found something in our map just skip the rest of this */        if(netLibName && *netLibName) {            newName = XP_STRDUP(netLibName);            break;        }        /* whatever name we eventually end up with we will need to register it */        /*   before we leave the function */        bNeedToRegister = TRUE;        /* If we are on the default host see if there is a newsrc file in the */        /*   news directory.  If so, that is what we want */        if(!stricmp(name, g_MsgPrefs.m_csNewsHost)) {            csHostName = g_MsgPrefs.m_csNewsDir;            csHostName += "\\newsrc";            if(_stat((const char *) csHostName, &sInfo) == 0) {                newName = XP_STRDUP((const char *) csHostName);                break;            }        }                                /* See if we are going to be able to build a file name based  */        /*   on the hostname */        csHostName = g_MsgPrefs.m_csNewsDir;        csHostName += '\\';        /* build up '<hostname>.rc' so we can tell how long its going to be */        /*   we will use that as the default name to try */		if(type == xpSNewsRC)			csHost += 's';        csHost += name;        /* if we have a news host news.foo.com we just want to use the "news" */        /*   part */        iDot = csHost.Find('.');        if(iDot != -1)            csHost = csHost.Left(iDot);#ifdef XP_WIN16        if(csHost.GetLength() > 8)            csHost = csHost.Left(8);#endif	iColon = csHost.Find(':');	if (iColon != -1) {		/* Windows file system seems to do horrid things if you have */		/* a filename with a colon in it. */		csHost = csHost.Left(iColon);	}        csHost += ".rc";        /* csHost is now of the form <hostname>.rc and is in 8.3 format */        /*   if we are on a Win16 box */        csHostName += csHost;        /* looks like a file with that name already exists -- panic */        if(_stat((const char *) csHostName, &sInfo) != -1) {                        char host[5];            /* else generate a new file in news directory */            strncpy(host, name, 4);            host[4] = '\0';            newName = WH_TempFileName(type, host, ".rc");            if(!newName)                return(NULL);        } else {            newName = XP_STRDUP((const char *) csHostName);        } 		break;    case xpNewsrcFileMap:        /* return name of FAT file in news directory */		newName = (char *) XP_ALLOC(_MAX_PATH);		sprintf(newName, "%s\\fat", (const char *)g_MsgPrefs.m_csNewsDir);		break;    case xpNewsgroups:    case xpSNewsgroups:        /* look up in netlib */        if ( !name || !strlen(name) )            name = g_MsgPrefs.m_csNewsHost;        netLibName = NET_MapNewsrcHostToFilename((char *)name,                                                  (type == xpSNewsgroups),                                                 TRUE);        if(!netLibName) {            csHostName = g_MsgPrefs.m_csNewsDir;            csHostName += '\\';	    if(type == xpSNewsgroups)		    csHost += 's';            csHost += name;            /* see if we can just use "<hostname>.rcg" */            /* it might be news.foo.com so just take "news" */            int iDot = csHost.Find('.');            if(iDot != -1)                csHost = csHost.Left(iDot);#ifdef XP_WIN16            if(csHost.GetLength() > 8)                csHost = csHost.Left(8);#endif	    iColon = csHost.Find(':');	    if (iColon != -1) {		    /* Windows file system seems to do horrid things if you have */		    /* a filename with a colon in it. */		    csHost = csHost.Left(iColon);	    }            csHost += ".rcg";            /* csHost is now of the form <hostname>.rcg */            csHostName += csHost;            /* looks like a file with that name already exists -- panic */            if(_stat((const char *) csHostName, &sInfo) != -1) {                                char host[5];                /* else generate a new file in news directory */                strncpy(host, name, 4);                host[4] = '\0';                newName = WH_TempFileName(type, host, ".rcg");                if(!newName)                    return(NULL);            } else {                newName = XP_STRDUP((const char *) csHostName);            }            if ( !name || !strlen(name))                NET_RegisterNewsrcFile(newName,(char *)(const char *)g_MsgPrefs.m_csNewsHost,                    (type == xpSNewsgroups), TRUE );            else                NET_RegisterNewsrcFile(newName,(char*)name,(type == xpSNewsgroups), TRUE );        } else {            newName = XP_STRDUP(netLibName);        }        break;    case xpMimeTypes:	name = NULL;	break;#endif /* MOZ_LITE       */    case xpGlobalHistory:	newName = (char *) XP_ALLOC(_MAX_PATH);	/* changed to support multi-profile */	/*sprintf(newName, "%s\\netscape.hst", theApp.m_pInstallDir->GetCharValue()); */	sprintf(newName, "%s\\netscape.hst", (const char *)theApp.m_UserDirectory);	break;    case xpGlobalHistoryList:        newName = (char *) XP_ALLOC(_MAX_PATH);        sprintf( newName, "%s\\ns_hstry.htm" );        break;    case xpKeyChain:	name = NULL;	break;      /* larubbio */    case xpSARCache:        if(!name) {            return NULL;        }	newName = (char *) XP_ALLOC(_MAX_PATH);	sprintf(newName, "%s\\%s", theApp.m_pSARCacheDir, name);	break;    case xpCache:        if(!name) {            tempName = WH_TempFileName(xpCache, NULL, NULL);	    if (!tempName) return NULL;	    name = tempName;	}        newName = (char *) XP_ALLOC(_MAX_PATH);        if ((strchr(name,'|')  || strchr(name,':')))  { /* Local File URL if find a | */            if(name[0] == '/')            	strcpy(newName,name+1); /* skip past extra slash */	    else		strcpy(newName,name); /* absolute path is valid */        } else {	    sprintf(newName, "%s\\%s", (const char *)theApp.m_pCacheDir, name);	}        break;    case xpBookmarks:    case xpHotlist: 	if (!name || !strlen(name)) 	    name = theApp.m_pBookmarkFile;	break;#endif /* CMD_STUB */    case xpSocksConfig:	prefStr = NULL;#ifndef CMD_STUB	PREF_CopyCharPref("browser.socksfile_location", &prefStr);#else	ASSERT(0);#endif	name = prefStr;	break;		#ifndef CMD_STUB    case xpCertDB:        newName = (char *) XP_ALLOC(_MAX_PATH);        if ( name ) {	    sprintf(newName, "%s\\cert%s.db", (const char *)theApp.m_UserDirectory, name);        } else {	    sprintf(newName, "%s\\cert.db", (const char *)theApp.m_UserDirectory);        }	break;    case xpCertDBNameIDX:        newName = (char *) XP_ALLOC(_MAX_PATH);	sprintf(newName, "%s\\certni.db", (const char *)theApp.m_UserDirectory);	break;    case xpKeyDB:        newName = (char *) XP_ALLOC(_MAX_PATH);	if ( name ) {	  sprintf(newName, "%s\\key%s.db", (const char *)theApp.m_UserDirectory, name);	} else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -