diff options
Diffstat (limited to 'sal/osl/os2/profile.c')
-rw-r--r-- | sal/osl/os2/profile.c | 526 |
1 files changed, 0 insertions, 526 deletions
diff --git a/sal/osl/os2/profile.c b/sal/osl/os2/profile.c index 38901fedb3d4..ac2e2b67daa1 100644 --- a/sal/osl/os2/profile.c +++ b/sal/osl/os2/profile.c @@ -873,224 +873,6 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff return (n); } -#if 0 // YD -sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName) -{ - sal_Bool bFailed; - sal_Char File[_MAX_PATH]; - sal_Char Path[_MAX_PATH]; - sal_uInt32 nFileLen; - sal_uInt32 nPathLen = 0; - - rtl_uString * strTmp = NULL; - oslFileError nError; - - /* build file name */ - if (strName && strName->length) - { - if(strName->length >= _MAX_PATH) - return sal_False; - - strcpy(File, (char*)strName->buffer); - nFileLen = strName->length; - - if (rtl_ustr_indexOfChar( File, L'.' ) == -1) - { - if (nFileLen + strlen(STR_INI_EXTENSION) >= _MAX_PATH) - return sal_False; - - /* add default extension */ - strcpy(File + nFileLen, STR_INI_EXTENSION); - nFileLen += strlen(STR_INI_EXTENSION); - } - } - else - { - rtl_uString *strProgName = NULL; - sal_Unicode *pProgName; - sal_Int32 nOffset = 0; - sal_Int32 nLen; - sal_Int32 nPos; - - if (osl_getExecutableFile(&strProgName) != osl_Process_E_None) - return sal_False; - - /* remove path and extension from filename */ - pProgName = strProgName->buffer; - nLen = strProgName->length ; - - if ((nPos = rtl_ustr_lastIndexOfChar( pProgName, L'/' )) != -1) - nOffset = nPos + 1; - else if ((nPos = rtl_ustr_lastIndexOfChar( pProgName, L':' )) != -1) - nOffset = nPos + 1; - - if ((nPos = rtl_ustr_lastIndexOfChar( pProgName, L'.' )) != -1 ) - nLen -= 4; - - if ((nFileLen = nLen - nOffset) >= _MAX_PATH) - return sal_False; - - strncpy(File, pProgName + nOffset, nFileLen); - - if (nFileLen + strlen(STR_INI_EXTENSION) >= _MAX_PATH) - return sal_False; - - /* add default extension */ - strcpy(File + nFileLen, STR_INI_EXTENSION); - nFileLen += strlen(STR_INI_EXTENSION); - - rtl_uString_release( strProgName ); - } - - if (File[0] == 0) - return sal_False; - - /* build directory path */ - if (strPath && strPath->length) - { - sal_Unicode *pPath = rtl_uString_getStr(strPath); - sal_Int32 nLen = rtl_uString_getLength(strPath); - - if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METAHOME) , STR_INI_METAHOME) == 0) && - ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METAHOME)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAHOME)] == '/'))) - { - rtl_uString * strHome = NULL; - oslSecurity security = osl_getCurrentSecurity(); - - bFailed = ! osl_getHomeDir(security, &strHome); - osl_freeSecurityHandle(security); - - if (bFailed) return (sal_False); - - if (strHome->length >= _MAX_PATH) - return sal_False; - - strcpy( Path, strHome->buffer); - nPathLen = strHome->length; - - if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METAHOME)) - { - pPath += RTL_CONSTASCII_LENGTH(STR_INI_METAHOME); - nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METAHOME); - - if (nLen + nPathLen >= _MAX_PATH) - return sal_False; - - strcpy(Path + nPathLen, pPath); - nPathLen += nLen; - } - - rtl_uString_release(strHome); - } - - else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METACFG), STR_INI_METACFG) == 0) && - ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METACFG)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METACFG)] == '/'))) - { - rtl_uString * strConfig = NULL; - oslSecurity security = osl_getCurrentSecurity(); - - bFailed = ! osl_getConfigDir(security, &strConfig); - osl_freeSecurityHandle(security); - - if (bFailed) return (sal_False); - - if (strConfig->length >= _MAX_PATH) - return sal_False; - - strcpy( Path, strConfig->buffer); - nPathLen = strConfig->length; - - if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METACFG)) - { - pPath += RTL_CONSTASCII_LENGTH(STR_INI_METACFG); - nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METACFG); - - if (nLen + nPathLen >= _MAX_PATH) - return sal_False; - - strcpy(Path + nPathLen, pPath); - nPathLen += nLen; - } - - rtl_uString_release(strConfig); - } - - else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METASYS), STR_INI_METASYS) == 0) && - ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METASYS)] == '/'))) - { - if (((nPathLen = GetWindowsDirectoryW(Path, _MAX_PATH)) == 0) || (nPathLen >= _MAX_PATH)) - return (sal_False); - - if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) - { - pPath += RTL_CONSTASCII_LENGTH(STR_INI_METASYS); - nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METASYS); - - if (nLen + nPathLen >= MAX_PATH) - return sal_False; - - strcpy(Path + nPathLen, pPath); - nPathLen += nLen; - } - } - - else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METAINS), STR_INI_METAINS) == 0) && - ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METAINS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAINS)] == '/') || - (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAINS)] == '"') ) ) - { - if (! lookupProfile(pPath + RTL_CONSTASCII_LENGTH(STR_INI_METAINS), File, Path)) - return (sal_False); - - nPathLen = strlen(Path); - } - - else if(nLen < MAX_PATH) - { - strcpy(Path, pPath); - nPathLen = strlen(Path); - } - else - return sal_False; - } - else - { - rtl_uString * strConfigDir = NULL; - oslSecurity security = osl_getCurrentSecurity(); - - bFailed = ! osl_getConfigDir(security, &strConfigDir); - osl_freeSecurityHandle(security); - - if (bFailed) return (sal_False); - if (strConfigDir->length >= MAX_PATH) - return sal_False; - - strcpy(Path, strConfigDir->buffer); - nPathLen = strConfigDir->length; - } - - if (nPathLen && (Path[nPathLen - 1] != L'/') && (Path[nPathLen - 1] != L'\\')) - { - Path[nPathLen++] = L'\\'; - Path[nPathLen] = 0; - } - - if (nPathLen + nFileLen >= MAX_PATH) - return sal_False; - - /* append file name */ - strcpy(Path + nPathLen, File); - nPathLen += nFileLen; - - /* copy filename */ - rtl_uString_newFromStr_WithLength(&strTmp, Path, nPathLen); - nError = osl_getFileURLFromSystemPath(strTmp, strProfileName); - rtl_uString_release(strTmp); - - return nError == osl_File_E_None; -} -#endif // 0 // YD - - /*****************************************************************************/ /* Static Module Functions */ /*****************************************************************************/ @@ -1983,311 +1765,3 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile) #endif return (sal_True); } - -#if 0 // YD -static sal_Bool lookupProfile(const sal_Char *pszPath, const sal_Char *pszFile, sal_Char *pPath) -{ - sal_Char *pChr, *pStr; - sal_Char Path[_MAX_PATH] = ""; - sal_Char Product[132] = ""; - sal_Char Buffer[1024]; - - if (*pszPath == '"') - { - int i = 0; - - pszPath++; - - while ((*pszPath != '"') && (*pszPath != '\0')) - Product[i++] = *pszPath++; - - Product[i] = '\0'; - - if (*pszPath == '"') - pszPath++; - - if ( (*pszPath == '/') || (*pszPath == '\\') ) - { - pszPath++; - } - } - else - { - /* if we have not product identfication, do a special handling for soffice.ini */ - if (stricmp(SVERSION_PROFILE, pszFile) == 0) - { - sal_Char Profile[_MAX_PATH]; - sal_Char Dir[_MAX_PATH]; - oslProfile hProfile; - - /* open sversion.ini in the system directory, and try to locate the entry - with the highest version for StarOffice */ - if ((osl_getProfileName(SVERSION_FALLBACK, SVERSION_NAME, Profile, sizeof(Profile))) && - (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) - { - osl_getProfileSectionEntries(hProfile, SVERSION_SECTION, - Buffer, sizeof(Buffer)); - - for (pChr = Buffer; *pChr != '\0'; pChr += strlen(pChr) + 1) - { - if ((strnicmp(pChr, SVERSION_SOFFICE, sizeof(SVERSION_SOFFICE) - 1) == 0) && - (stricmp(Product, pChr) < 0)) - { - osl_readProfileString(hProfile, SVERSION_SECTION, pChr, - Dir, sizeof(Dir), ""); - - /* check for existence of path */ - if (access(Dir, 0) >= 0) - strcpy(Product, pChr); - } - } - - osl_closeProfile(hProfile); - } - - /* open sversion.ini in the users directory, and try to locate the entry - with the highest version for StarOffice */ - if ((strcmp(SVERSION_LOCATION, SVERSION_FALLBACK) != 0) && - (osl_getProfileName(SVERSION_LOCATION, SVERSION_NAME, Profile, sizeof(Profile))) && - (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) - { - osl_getProfileSectionEntries(hProfile, SVERSION_SECTION, - Buffer, sizeof(Buffer)); - - for (pChr = Buffer; *pChr != '\0'; pChr += strlen(pChr) + 1) - { - if ((strnicmp(pChr, SVERSION_SOFFICE, sizeof(SVERSION_SOFFICE) - 1) == 0) && - (stricmp(Product, pChr) < 0)) - { - osl_readProfileString(hProfile, SVERSION_SECTION, pChr, - Dir, sizeof(Dir), ""); - - /* check for existence of path */ - if (access(Dir, 0) >= 0) - strcpy(Product, pChr); - } - } - - osl_closeProfile(hProfile); - } - - /* remove any trailing build number */ - if ((pChr = strrchr(Product, '/')) != NULL) - *pChr = '\0'; - } - } - - - /* if we have an userid option eg. "-userid:rh[/usr/home/rh/staroffice]", - this will supercede all other locations */ - if (osl_getCommandArgs(Buffer, sizeof(Buffer)) == osl_Process_E_None) - { - sal_Char *pStart, *pEnd; - - for (pChr = Buffer; *pChr != '\0'; pChr += strlen(pChr) + 1) - if (((*pChr == '-') || (*pChr == '+')) && - (strnicmp(pChr + 1, SVERSION_OPTION, sizeof(SVERSION_OPTION) - 1) == 0)) - { - if (((pStart = strchr(pChr + sizeof(SVERSION_OPTION), '[')) != NULL) && - ((pEnd = strchr(pStart + 1, ']')) != NULL)) - { - strncpy(Path, pStart + 1, pEnd - (pStart + 1)); - Path[pEnd - (pStart + 1)] = '\0'; - - /* build full path */ - if ((Path[strlen(Path) - 1] != '/') && (Path[strlen(Path) - 1] != '\\')) - { - strcat(Path, "\\"); - } - - pChr =&Path[strlen(Path)]; - if ( strlen(pszPath) <= 0 ) - { - strcat(Path,SVERSION_USER); - - if ( access(Path, 0) < 0 ) - { - *pChr='\0'; - } - } - else - { - strcat(Path, pszPath); - } - - break; - } - } - } - - if (strlen(Path) <= 0) - { - /* try to find the file in the directory of the executbale */ - if (osl_getExecutableFile(Path, sizeof(Path)) != osl_Process_E_None) - return (sal_False); - - /* seperate path from filename */ - if ((pChr = strrchr(Path, '\\')) == NULL) - if ((pChr = strrchr(Path, ':')) == NULL) - return (sal_False); - else - *pChr = '\0'; - else - *pChr = '\0'; - - /* if we have no product identification use the executable file name */ - if (strlen(Product) <= 0) - { - strcpy(Product, pChr + 1); - - /* remove extension */ - if ((pChr = strrchr(Product, '.')) != NULL) - *pChr = '\0'; - } - - /* remember last subdir */ - pStr = strrchr(Path, '\\'); - - strcat(Path, "\\"); - - if ( strlen(pszPath) <= 0 ) - { - strcat(Path, pszPath); - } - else - { - strcat(Path,pszPath); - } - - /* if file not exists, remove any specified subdirectories - like "bin" or "program" */ - if (((access(Path, 0) < 0) && (pStr != NULL)) || (strlen(pszPath) <= 0)) - { - static sal_Char *SubDirs[] = SVERSION_DIRS; - - int i = 0; - - for (i = 0; i < SAL_N_ELEMENTS(SubDirs); i++) - if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0) - { - if ( strlen(pszPath) <= 0) - { - strcpy(pStr + 1,SVERSION_USER); - if ( access(Path, 0) < 0 ) - { - *(pStr+1)='\0'; - } - } - else - { - strcpy(pStr + 1, pszPath); - } - - break; - } - } - - pChr = &Path[strlen(Path)]; - if ((Path[strlen(Path) - 1] != '/') && (Path[strlen(Path) - 1] != '\\')) - strcat(Path, "\\"); - strcat(Path, pszFile); - - if ((access(Path, 0) < 0) && (strlen(Product) > 0)) - { - sal_Char Profile[_MAX_PATH]; - oslProfile hProfile; - - /* remove appended filename */ - *pChr = '\0'; - - /* open sversion.ini in the system directory, and try to locate the entry - with the highest version for StarOffice */ - if ((osl_getProfileName(SVERSION_LOCATION, SVERSION_NAME, Profile, sizeof(Profile))) && - (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) - { - pChr = &Product[strlen(Product)]; - - /* append build number */ - strcat(Product, "/"); - strcat(Product, BUILD_STR(SUPD)); - - osl_readProfileString(hProfile, SVERSION_SECTION, Product, - Buffer, sizeof(Buffer), ""); - - /* if not found, try it without build number */ - if (strlen(Buffer) <= 0) - { - *pChr = '\0'; - - osl_readProfileString(hProfile, SVERSION_SECTION, Product, - Buffer, sizeof(Buffer), ""); - - osl_closeProfile(hProfile); - - /* if not found, try the fallback */ - if ((strlen(Buffer) <= 0) && (strcmp(SVERSION_LOCATION, SVERSION_FALLBACK) != 0)) - { - if ((osl_getProfileName(SVERSION_FALLBACK, SVERSION_NAME, Profile, sizeof(Profile))) && - (hProfile = osl_openProfile(Profile, osl_Profile_READLOCK))) - { - /* prepare build number */ - *pChr = '/'; - - osl_readProfileString(hProfile, SVERSION_SECTION, Product, - Buffer, sizeof(Buffer), ""); - - /* if not found, try it without build number */ - if (strlen(Buffer) <= 0) - { - *pChr = '\0'; - - osl_readProfileString(hProfile, SVERSION_SECTION, Product, - Buffer, sizeof(Buffer), ""); - } - - osl_closeProfile(hProfile); - } - } - } - else - osl_closeProfile(hProfile); - - if (strlen(Buffer) > 0) - { - strcpy(Path, Buffer); - - /* build full path */ - if ((Path[strlen(Path) - 1] != '/') && (Path[strlen(Path) - 1] != '\\')) - { - if ((*pszPath != '/') && (*pszPath != '\\')) - strcat(Path, "\\"); - } - - pChr=&Path[strlen(pszPath)]; - if ( strlen(pszPath) > 0 ) - { - strcat(Path, pszPath); - } - else - { - strcat(Path,SVERSION_USER); - if ( access(Path, 0) < 0 ) - { - *pChr='\0'; - } - } - } - } - } - else - /* remove appended filename */ - *pChr = '\0'; - } - - strcpy(pPath, Path); - - return (sal_True); -} - -#endif // 0 // YD - |