Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
129
cde/programs/dtsearchpath/dtsp/AppSearchPath.C
Normal file
129
cde/programs/dtsearchpath/dtsp/AppSearchPath.C
Normal file
@@ -0,0 +1,129 @@
|
||||
/* $XConsortium: AppSearchPath.C /main/2 1995/07/17 14:08:52 drk $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include "Environ.h"
|
||||
#include "Options.h"
|
||||
#include "TTFile.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* AppSearchPath - this constructor creates DTAPPSEARCHPATH in a three-
|
||||
* step process.
|
||||
*
|
||||
* 1. gathers environment variables and defaults
|
||||
* to create a comma-separated list of paths
|
||||
* 2. normalizes the list into host:/path format
|
||||
* 3. builds the final version of the path
|
||||
*
|
||||
* Hierarchy of search paths:
|
||||
* DTSPUSERAPPHOSTS
|
||||
* User's home directory
|
||||
* System Administrator's configuration directory
|
||||
* DTSPSYSAPPHOSTS
|
||||
* Factory location
|
||||
*
|
||||
**********************************************************************/
|
||||
AppSearchPath::AppSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : SearchPath(user, envvar, sep)
|
||||
{
|
||||
if (user->DTAPPSP()) {
|
||||
if (user->DTUSERAPPSP()) {
|
||||
search_path = *user->DTUSERAPPSP() + "," +
|
||||
user->HOME() + ",";
|
||||
if (!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTAPPSP() + "," +
|
||||
user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
search_path = user->HOME() + ",";
|
||||
if (!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTAPPSP() + "," +
|
||||
user->FactoryInstall();
|
||||
}
|
||||
}
|
||||
|
||||
else if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + "," + user->DefaultSearchPath();
|
||||
|
||||
else
|
||||
search_path = user->DefaultSearchPath();
|
||||
|
||||
if (options->CheckingUser())
|
||||
search_path = user->DefaultSearchPath();
|
||||
|
||||
// Now convert the initial list to host:/path format
|
||||
|
||||
NormalizePath();
|
||||
|
||||
// Convert the host:/path list to a colon-separated list of
|
||||
// valid paths
|
||||
|
||||
TraversePath();
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* MakePath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTAPPSEARCHPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
************************************************************************/
|
||||
void AppSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":,");
|
||||
CString host_element = element.next();
|
||||
CString path_element = element.next();
|
||||
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
if (user->OS()->isDirectory(path_element) || options->dontOptimize())
|
||||
AddToPath (path_element);
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element, &host_element));
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize())
|
||||
AddToPath (dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AppSearchPath::FixUp()
|
||||
{
|
||||
if (!final_search_path.isNull()) {
|
||||
CTokenizedString subpath(final_search_path,",");
|
||||
CString dirname = subpath.next();
|
||||
CString result_sp(dirname);
|
||||
while (1) {
|
||||
result_sp += "/appmanager";
|
||||
if (!dirname.contains(user->HOME()))
|
||||
result_sp += "/%L:" + dirname + "/appmanager/C";
|
||||
dirname = subpath.next();
|
||||
if (dirname.isNull())
|
||||
break;
|
||||
result_sp += ":" + dirname;
|
||||
}
|
||||
final_search_path = result_sp;
|
||||
setSeparator(":");
|
||||
}
|
||||
}
|
||||
230
cde/programs/dtsearchpath/dtsp/DbSearchPath.C
Normal file
230
cde/programs/dtsearchpath/dtsp/DbSearchPath.C
Normal file
@@ -0,0 +1,230 @@
|
||||
/* $XConsortium: DbSearchPath.C /main/2 1995/07/17 14:09:00 drk $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include "Environ.h"
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* DatabaseSearchPath - this constructor creates DTDATAVASESEARCHPATH
|
||||
* in a three-step process.
|
||||
*
|
||||
* 1. gathers environment variables and defaults
|
||||
* to create a comma-separated list of paths
|
||||
* 2. normalizes the list into host:/path format
|
||||
* 3. builds the final version of the path
|
||||
*
|
||||
* Hierarchy of search paths:
|
||||
* DTSPUSERDATABASEHOSTS
|
||||
* User's home directory
|
||||
* System Administrator's configuration directory
|
||||
* DTSPSYSDATABASEHOSTS
|
||||
* Factory location
|
||||
*
|
||||
**********************************************************************/
|
||||
DatabaseSearchPath::DatabaseSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : SearchPath(user, envvar, sep)
|
||||
{
|
||||
if (user->DTDBSP()) {
|
||||
if (user->DTUSERDBSP()) {
|
||||
|
||||
// Add the DTSPUSER and Home paths
|
||||
|
||||
search_path = *user->DTUSERDBSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
|
||||
// if localhost: is not specified in the database or app
|
||||
// input paths, add the local configuration directory here.
|
||||
|
||||
if (!user->DTDBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
(!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":")))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
|
||||
// now, add the system database path
|
||||
|
||||
search_path += *user->DTDBSP() + ",";
|
||||
|
||||
// before adding the app path, see if localhost: is specified
|
||||
// in both paths and if it is, remove the first occurrence of
|
||||
// localhost:
|
||||
|
||||
if (user->DTDBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
|
||||
// finally, add the factory location
|
||||
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTDBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
(!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":")))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTDBSP() + ",";
|
||||
if (user->DTDBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
}
|
||||
else if (user->DTUSERDBSP()) {
|
||||
search_path = *user->DTUSERDBSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
|
||||
if (options->CheckingUser()) {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP();
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP();
|
||||
else
|
||||
search_path += user->DefaultSearchPath();
|
||||
}
|
||||
|
||||
NormalizePath();
|
||||
TraversePath();
|
||||
}
|
||||
|
||||
|
||||
CString DatabaseSearchPath::ConstructPath
|
||||
(
|
||||
const CString & path,
|
||||
const CString * host,
|
||||
unsigned char useTT
|
||||
)
|
||||
{
|
||||
if (useTT) {
|
||||
CString final_path;
|
||||
if (host) {
|
||||
if (options->doingTooltalk()) {
|
||||
TTFile * file;
|
||||
Try {
|
||||
file = new TTFile(*host,path);
|
||||
if (!file->ttFileOpFailed())
|
||||
final_path = *file;
|
||||
}
|
||||
Catch (TTFile::TT_Exception *, file) {
|
||||
final_path = user->OS()->MountPoint() + *host + path;
|
||||
}
|
||||
delete file;
|
||||
}
|
||||
else
|
||||
final_path = user->OS()->MountPoint() + *host + path;
|
||||
}
|
||||
else
|
||||
final_path = path;
|
||||
return final_path;
|
||||
}
|
||||
|
||||
if (host)
|
||||
return (*host + ":" + path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* MakeActionSearchPath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTDATABASESEARCHPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
************************************************************************/
|
||||
void DatabaseSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":");
|
||||
CString host_e = element.next();
|
||||
CString path_e = element.next();
|
||||
|
||||
if (path_e.contains(user->HOME())) {
|
||||
if (host_e == user->OS()->LocalHost()) {
|
||||
if (user->OS()->isDirectory(path_e + "/types")
|
||||
|| options->dontOptimize())
|
||||
AddToPath (path_e + "/types");
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_e + "/types", &host_e, 1));
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize())
|
||||
AddToPath (dir);
|
||||
}
|
||||
}
|
||||
else if (host_e == user->OS()->LocalHost()) {
|
||||
CString dir(path_e);
|
||||
if (validSearchPath(dir)) {
|
||||
dir += "/types";
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize())
|
||||
AddToPath (dir + "/%L");
|
||||
dir += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize())
|
||||
AddToPath (dir);
|
||||
}
|
||||
else {
|
||||
CString dirname(ConstructPath(path_e, &host_e,1));
|
||||
if (validSearchPath(path_e)) {
|
||||
dirname += "/types";
|
||||
if (user->OS()->isDirectory(dirname) || options->dontOptimize())
|
||||
AddToPath (ConstructPath(path_e + "/types/%L", &host_e));
|
||||
dirname += "/C";
|
||||
if (user->OS()->isDirectory(dirname) || options->dontOptimize())
|
||||
AddToPath (ConstructPath(path_e + "/types/C", &host_e));
|
||||
}
|
||||
else {
|
||||
if (user->OS()->isDirectory(dirname) || options->dontOptimize())
|
||||
AddToPath (ConstructPath(path_e, &host_e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
238
cde/programs/dtsearchpath/dtsp/HelpSearchPath.C
Normal file
238
cde/programs/dtsearchpath/dtsp/HelpSearchPath.C
Normal file
@@ -0,0 +1,238 @@
|
||||
/* $XConsortium: HelpSearchPath.C /main/3 1995/11/03 12:30:59 rswiston $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include "Environ.h"
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* HelpSearchPath
|
||||
*
|
||||
* this constructor creates DTHELPSEARCHPATH in a three-step
|
||||
* process.
|
||||
*
|
||||
* 1. gathers environment variables and defaults to create a
|
||||
colon-separated list of paths
|
||||
* 2. normalizes the list into host:/path format
|
||||
* 3. builds the final version of the path
|
||||
*
|
||||
* Hierarchy of search paths:
|
||||
* DTSPUSERHELP
|
||||
* User's home directory
|
||||
* System Administrator's configuration directory
|
||||
* DTSPSYSHELP
|
||||
* Factory location
|
||||
*
|
||||
**********************************************************************/
|
||||
HelpSearchPath::HelpSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : SearchPath(user, envvar, sep)
|
||||
{
|
||||
if (user->DTHELPSP()) {
|
||||
if (user->DTUSERHELPSP()) {
|
||||
search_path = *user->DTUSERHELPSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTHELPSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTHELPSP() + ",";
|
||||
if (user->DTHELPSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTHELPSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTHELPSP() + ",";
|
||||
if (user->DTHELPSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
}
|
||||
else if (user->DTUSERHELPSP()) {
|
||||
search_path = *user->DTUSERHELPSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += *user->DTAPPSP();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += *user->DTAPPSP();
|
||||
}
|
||||
|
||||
if (options->CheckingUser())
|
||||
search_path = *user->DTAPPSP();
|
||||
|
||||
NormalizePath();
|
||||
TraversePath();
|
||||
|
||||
#if defined(hpux)
|
||||
AddToPath ("/etc/vhelp/%T/%L/%H");
|
||||
AddToPath ("/etc/vhelp/%T/%H");
|
||||
AddToPath ("/etc/vhelp/%T/%L/%H.hv");
|
||||
AddToPath ("/etc/vhelp/%T/%H.hv");
|
||||
AddToPath ("/etc/vhelp/%T/C/%H");
|
||||
AddToPath ("/etc/vhelp/%T/C/%H.hv");
|
||||
AddToPath ("/usr/vhelp/%T/%L/%H");
|
||||
AddToPath ("/usr/vhelp/%T/%H");
|
||||
AddToPath ("/usr/vhelp/%T/%L/%H.hv");
|
||||
AddToPath ("/usr/vhelp/%T/%H.hv");
|
||||
AddToPath ("/usr/vhelp/%T/C/%H");
|
||||
AddToPath ("/usr/vhelp/%T/C/%H.hv");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MakePath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTHELPSEARCHPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
***********************************************************************/
|
||||
void HelpSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":");
|
||||
CString host_element = element.next();
|
||||
CString path_element = element.next();
|
||||
|
||||
if (path_element.contains(user->HOME())) {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
CString helpPath(path_element);
|
||||
if (user->OS()->isDirectory(helpPath + "/help")
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (helpPath + "/help/" + user->UserHostDir() + "/%H");
|
||||
AddToPath (helpPath + "/help/" + user->UserHostDir() + "/%H.sdl");
|
||||
AddToPath (helpPath + "/help/" + user->UserHostDir() + "/%H.hv");
|
||||
AddToPath (helpPath + "/help/%H");
|
||||
AddToPath (helpPath + "/help/%H.sdl");
|
||||
AddToPath (helpPath + "/help/%H.hv");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element + "/help", &host_element));
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/" + user->UserHostDir() + "/%H");
|
||||
AddToPath (dir + "/" + user->UserHostDir() + "/%H.sdl");
|
||||
AddToPath (dir + "/" + user->UserHostDir() + "/%H.hv");
|
||||
AddToPath (dir + "/%H");
|
||||
AddToPath (dir + "/%H.sdl");
|
||||
AddToPath (dir + "/%H.hv");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
CString helpPath(path_element);
|
||||
if (validSearchPath(helpPath)) {
|
||||
helpPath += "/help";
|
||||
if (user->OS()->isDirectory(helpPath)
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (helpPath + "/%L/%H");
|
||||
AddToPath (helpPath + "/%L/%H.sdl");
|
||||
AddToPath (helpPath + "/%L/%H.hv");
|
||||
}
|
||||
helpPath += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(helpPath) || options->dontOptimize()) {
|
||||
AddToPath (helpPath + "/%H");
|
||||
AddToPath (helpPath + "/%H.sdl");
|
||||
AddToPath (helpPath + "/%H.hv");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element, &host_element));
|
||||
if (validSearchPath(dir)) {
|
||||
dir += "/help";
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%L/%H");
|
||||
AddToPath (dir + "/%L/%H.sdl");
|
||||
AddToPath (dir + "/%L/%H.hv");
|
||||
}
|
||||
dir += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%H");
|
||||
AddToPath (dir + "/%H.sdl");
|
||||
AddToPath (dir + "/%H.hv");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* validSearchPath()
|
||||
*
|
||||
* This member function verifies that the path in question is a
|
||||
* standard CDE location, i.e. /etc/dt/appconfig or /usr/dt/appconfig
|
||||
* so that the appropriate massaging can take place.
|
||||
*
|
||||
*********************************************************************/
|
||||
int HelpSearchPath::validSearchPath
|
||||
(
|
||||
const CString & st
|
||||
) const
|
||||
{
|
||||
if (st == user->SysAdmConfig()) // ...,/etc/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
if (st == user->FactoryInstall()) // ...,/usr/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/etc/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->SysAdmConfig(), "", Separator().data()))
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/usr/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->FactoryInstall(),"",Separator().data()))
|
||||
return 1;
|
||||
|
||||
// If this is an APP-specified path, it also needs to be massaged.
|
||||
// The elements in the APP paths were originally specified using
|
||||
// host:/path, but were converted to /path for Help searchpaths
|
||||
// so use the comma as the leader and the trailer.
|
||||
|
||||
if (user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
if (user->DTUSERAPPSP() &&
|
||||
user->DTUSERAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
225
cde/programs/dtsearchpath/dtsp/IconSearchPath.C
Normal file
225
cde/programs/dtsearchpath/dtsp/IconSearchPath.C
Normal file
@@ -0,0 +1,225 @@
|
||||
/* $XConsortium: IconSearchPath.C /main/3 1995/11/03 12:31:13 rswiston $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include <stdlib.h>
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* IconSearchPath
|
||||
*
|
||||
* This constructor creates DTICONSEARCHPATH in a three-step
|
||||
* process.
|
||||
*
|
||||
* 1. gathers environment variables and defaults to create a
|
||||
* colon-separated list of paths
|
||||
* 2. normalizes the list into host:/path format
|
||||
* 3. builds the final version of the path
|
||||
*
|
||||
* Hierarchy of search paths:
|
||||
* DTSPUSERICON
|
||||
* User's home directory
|
||||
* System Administrator's configuration directory
|
||||
* DTSPSYSICON
|
||||
* Factory location
|
||||
*
|
||||
**********************************************************************/
|
||||
IconSearchPath::IconSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * ist,
|
||||
const char * znd,
|
||||
const char * sep
|
||||
) : SearchPath(user,envvar,sep),
|
||||
first(ist),
|
||||
second(znd)
|
||||
{
|
||||
if (user->DTICONSP()) {
|
||||
if (user->DTUSERICONSP()) {
|
||||
search_path = *user->DTUSERICONSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTICONSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTICONSP() + ",";
|
||||
if (user->DTICONSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->SysAdmConfig() + "," +
|
||||
user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += user->HOME() + ",";
|
||||
if (!user->DTICONSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":"))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTICONSP() + ",";
|
||||
if (user->DTICONSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->SysAdmConfig() + "," +
|
||||
user->FactoryInstall();
|
||||
}
|
||||
}
|
||||
else if (user->DTUSERICONSP()) {
|
||||
search_path = *user->DTUSERICONSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
search_path += *user->DTAPPSP();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
search_path += *user->DTAPPSP();
|
||||
}
|
||||
|
||||
// NormalizePath should remove duplicates
|
||||
AddPredefinedPath();
|
||||
|
||||
if (options->CheckingUser())
|
||||
search_path = *user->DTAPPSP();
|
||||
|
||||
NormalizePath();
|
||||
TraversePath();
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* MakeIconSearchPath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTICONSEARCHPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
************************************************************************/
|
||||
void IconSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":");
|
||||
CString host_element = element.next();
|
||||
CString path_element = element.next();
|
||||
|
||||
if (path_element.contains(user->HOME())) {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
if (user->OS()->isDirectory(path_element + "/icons")
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (path_element + "/icons/%B%M" + first);
|
||||
AddToPath (path_element + "/icons/%B%M" + second);
|
||||
AddToPath (path_element + "/icons/%B");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element + "/icons", &host_element));
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%B%M" + first);
|
||||
AddToPath (dir + "/%B%M" + second);
|
||||
AddToPath (dir + "/%B");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
CString dirname(path_element);
|
||||
if (validSearchPath(dirname)) {
|
||||
dirname += "/icons";
|
||||
if (user->OS()->isDirectory (dirname)
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (dirname + "/%L/%B%M" + first);
|
||||
AddToPath (dirname + "/%L/%B%M" + second);
|
||||
AddToPath (dirname + "/%L/%B");
|
||||
}
|
||||
dirname += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory (dirname) || options->dontOptimize()) {
|
||||
AddToPath (dirname + "/%B%M" + first);
|
||||
AddToPath (dirname + "/%B%M" + second);
|
||||
AddToPath (dirname + "/%B");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir = ConstructPath(path_element, &host_element);
|
||||
if (validSearchPath(dir)) {
|
||||
dir += "/icons";
|
||||
if (user->OS()->isDirectory (dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%L/%B%M" + first);
|
||||
AddToPath (dir + "/%L/%B%M" + second);
|
||||
AddToPath (dir + "/%L/%B");
|
||||
}
|
||||
dir += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%B%M" + first);
|
||||
AddToPath (dir + "/%B%M" + second);
|
||||
AddToPath (dir + "/%B");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* validSearchPath()
|
||||
*
|
||||
* This member function verifies that the path in question is a
|
||||
* standard CDE location, i.e. /etc/dt/appconfig or /usr/dt/appconfig
|
||||
* so that the appropriate massaging can take place.
|
||||
*
|
||||
*********************************************************************/
|
||||
int IconSearchPath::validSearchPath
|
||||
(
|
||||
const CString & st
|
||||
) const
|
||||
{
|
||||
if (st == user->SysAdmConfig()) // ...,/etc/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
if (st == user->FactoryInstall()) // ...,/usr/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/etc/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->SysAdmConfig(),"",Separator().data()))
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/usr/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->FactoryInstall(),"",Separator().data()))
|
||||
return 1;
|
||||
|
||||
// If this is an APP-specified path, it also needs to be massaged.
|
||||
// The elements in the APP paths were originally specified using
|
||||
// host:/path, but were converted to /path for Icon searchpaths
|
||||
// so use the comma as the leader and the trailer.
|
||||
|
||||
if (user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
if (user->DTUSERAPPSP() &&
|
||||
user->DTUSERAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
cde/programs/dtsearchpath/dtsp/Imakefile
Normal file
45
cde/programs/dtsearchpath/dtsp/Imakefile
Normal file
@@ -0,0 +1,45 @@
|
||||
XCOMM $TOG: Imakefile /main/15 1998/08/05 13:21:49 mgreess $
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
|
||||
|
||||
INCLUDES = -I. -I../libCliSrv
|
||||
|
||||
LOCAL_LIBRARIES = ../libCliSrv/libCliSrv.a $(TTLIB) $(XTOOLLIB) $(XLIB)
|
||||
DEPLIBS = ../libCliSrv/libCliSrv.a $(DEPTTLIB) $(DEPXTOOLLIB) $(DEPXLIB)
|
||||
SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs
|
||||
|
||||
#ifdef SunArchitecture
|
||||
EXTRA_DEFINES = -DIOSTREAMSWORKS
|
||||
#endif
|
||||
|
||||
#ifdef RsArchitecture
|
||||
EXTRA_DEFINES = -DIOSTREAMSWORKS
|
||||
#endif
|
||||
|
||||
SRCS = \
|
||||
AppSearchPath.C \
|
||||
DbSearchPath.C \
|
||||
HelpSearchPath.C \
|
||||
IconSearchPath.C \
|
||||
InfoLibSearchPath.C \
|
||||
ManSearchPath.C \
|
||||
Options.C \
|
||||
SearchPath.C \
|
||||
dtsearchpath.C
|
||||
|
||||
OBJS = \
|
||||
AppSearchPath.o \
|
||||
DbSearchPath.o \
|
||||
HelpSearchPath.o \
|
||||
IconSearchPath.o \
|
||||
InfoLibSearchPath.o \
|
||||
ManSearchPath.o \
|
||||
Options.o \
|
||||
SearchPath.o \
|
||||
dtsearchpath.o
|
||||
|
||||
NormalCplusplusObjectRule()
|
||||
|
||||
ComplexCplusplusProgramTarget(dtsp)
|
||||
236
cde/programs/dtsearchpath/dtsp/InfoLibSearchPath.C
Normal file
236
cde/programs/dtsearchpath/dtsp/InfoLibSearchPath.C
Normal file
@@ -0,0 +1,236 @@
|
||||
/* $TOG: InfoLibSearchPath.C /main/5 1998/08/17 10:33:55 mgreess $
|
||||
/*
|
||||
* (c) Copyright 1996 Digital Equipment Corporation.
|
||||
* (c) Copyright 1996 Hewlett-Packard Company.
|
||||
* (c) Copyright 1996 International Business Machines Corp.
|
||||
* (c) Copyright 1996 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1996 Novell, Inc.
|
||||
* (c) Copyright 1996 FUJITSU LIMITED.
|
||||
* (c) Copyright 1996 Hitachi.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "SearchPath.h"
|
||||
#include "Environ.h"
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* InfoLibSearchPath
|
||||
*
|
||||
* this constructor creates DTINFOLIBSEARCHPATH in a three-step
|
||||
* process.
|
||||
*
|
||||
* 1. gathers environment variables and defaults to create a
|
||||
* colon-separated list of paths
|
||||
* 2. normalizes the list into host:/path format
|
||||
* 3. builds the final version of the path
|
||||
*
|
||||
* Hierarchy of search paths:
|
||||
* DTSPUSERINFOLIB
|
||||
* DTSPUSERAPPHOSTS
|
||||
* System Administrator's configuration directory
|
||||
* DTSPSYSINFOLIB
|
||||
* DTSPSYSAPPHOSTS
|
||||
* Factory location
|
||||
*
|
||||
**********************************************************************/
|
||||
InfoLibSearchPath::InfoLibSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : SearchPath(user, envvar, sep)
|
||||
{
|
||||
CString oldSysAdmConfig = user->sysAdmConfig;
|
||||
CString oldFactoryInstall = user->factoryInstall;
|
||||
|
||||
// Need to re-initialize the defaults.
|
||||
user->sysAdmConfig = "/etc/dt";
|
||||
user->factoryInstall = "/usr/dt";
|
||||
|
||||
if (user->DTINFOLIBSP()) {
|
||||
if (user->DTUSERINFOLIBSP()) {
|
||||
search_path = *user->DTUSERINFOLIBSP() + ",";
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
if (!user->DTINFOLIBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
(!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":")))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTINFOLIBSP() + ",";
|
||||
if (user->DTINFOLIBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
if (!user->DTINFOLIBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
(!user->DTAPPSP() ||
|
||||
!user->DTAPPSP()->contains(user->OS()->LocalHost(),",",":")))
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
search_path += *user->DTINFOLIBSP() + ",";
|
||||
if (user->DTINFOLIBSP()->contains(user->OS()->LocalHost(),",",":") &&
|
||||
user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains(user->SysAdmConfig(),",",","))
|
||||
search_path.replace(user->OS()->LocalHost() + ":,","");
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
}
|
||||
else if (user->DTUSERINFOLIBSP()) {
|
||||
search_path = *user->DTUSERINFOLIBSP() + ",";
|
||||
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path += *user->DTUSERAPPSP() + ",";
|
||||
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
else {
|
||||
if (user->DTUSERAPPSP())
|
||||
search_path = *user->DTUSERAPPSP() + ",";
|
||||
|
||||
search_path += user->SysAdmConfig() + ",";
|
||||
if (user->DTAPPSP())
|
||||
search_path += *user->DTAPPSP() + ",";
|
||||
search_path += user->FactoryInstall();
|
||||
}
|
||||
|
||||
if (options->CheckingUser())
|
||||
{
|
||||
if (user->DTAPPSP())
|
||||
search_path = *user->DTAPPSP();
|
||||
}
|
||||
|
||||
NormalizePath();
|
||||
TraversePath();
|
||||
|
||||
user->sysAdmConfig = oldSysAdmConfig;
|
||||
user->factoryInstall = oldFactoryInstall;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MakePath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTINFOLIBSEARCHPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
***********************************************************************/
|
||||
void InfoLibSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":");
|
||||
CString host_element = element.next();
|
||||
CString path_element = element.next();
|
||||
|
||||
if (path_element.contains(user->HOME())) {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
CString infolibPath(path_element);
|
||||
if (user->OS()->isDirectory(infolibPath + "/infolib")
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (infolibPath + "/infolib/" + user->UserHostDir() +
|
||||
"%I.dti");
|
||||
AddToPath (infolibPath + "/infolib/%L/%I.dti");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element + "/infolib", &host_element));
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/" + user->UserHostDir() + "/%I.dti");
|
||||
AddToPath (dir + "/%I.dti");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
CString infolibPath(path_element);
|
||||
if (validSearchPath(infolibPath)) {
|
||||
infolibPath += "/infolib";
|
||||
if (user->OS()->isDirectory(infolibPath)
|
||||
|| options->dontOptimize()) {
|
||||
AddToPath (infolibPath + "/%L/%I.dti");
|
||||
}
|
||||
infolibPath += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(infolibPath) ||
|
||||
options->dontOptimize()) {
|
||||
AddToPath (infolibPath + "/%I.dti");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CString dir(ConstructPath(path_element, &host_element));
|
||||
if (validSearchPath(dir)) {
|
||||
dir += "/infolib";
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%L/%I.dti");
|
||||
}
|
||||
dir += "/C";
|
||||
}
|
||||
if (user->OS()->isDirectory(dir) || options->dontOptimize()) {
|
||||
AddToPath (dir + "/%I.dti");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* validSearchPath()
|
||||
*
|
||||
* This member function verifies that the path in question is a
|
||||
* standard CDE location, i.e. /etc/dt/appconfig or /usr/dt/appconfig
|
||||
* so that the appropriate massaging can take place.
|
||||
*
|
||||
*********************************************************************/
|
||||
int InfoLibSearchPath::validSearchPath
|
||||
(
|
||||
const CString & st
|
||||
) const
|
||||
{
|
||||
if (st == user->SysAdmConfig()) // ...,/etc/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
if (st == user->FactoryInstall()) // ...,/usr/dt/appconfig,...
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/etc/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->SysAdmConfig(), "", Separator().data()))
|
||||
return 1;
|
||||
|
||||
// ...,/nfs/machine/usr/dt/appconfig,...
|
||||
|
||||
if (st.contains(user->FactoryInstall(),"",Separator().data()))
|
||||
return 1;
|
||||
|
||||
// If this is an APP-specified path, it also needs to be massaged.
|
||||
// The elements in the APP paths were originally specified using
|
||||
// host:/path, but were converted to /path for InfoLib searchpaths
|
||||
// so use the comma as the leader and the trailer.
|
||||
|
||||
if (user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
if (user->DTUSERAPPSP() &&
|
||||
user->DTUSERAPPSP()->contains (st, ",", ","))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
108
cde/programs/dtsearchpath/dtsp/ManSearchPath.C
Normal file
108
cde/programs/dtsearchpath/dtsp/ManSearchPath.C
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $XConsortium: ManSearchPath.C /main/3 1995/11/03 12:31:46 rswiston $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
ManSearchPath::ManSearchPath
|
||||
(
|
||||
CDEEnvironment * user,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : SearchPath(user, envvar, sep)
|
||||
{
|
||||
if (user->DTMANPATH())
|
||||
search_path = user->FactoryManPath() + "," + *user->DTMANPATH();
|
||||
else
|
||||
search_path = user->FactoryManPath();
|
||||
|
||||
// add OS manpath now so duplicate path elements can be removed by Normalize
|
||||
// Normalize should recognize both ':' and ',' as separators.
|
||||
|
||||
if (!user->OS()->MANPATH().isNull())
|
||||
search_path += ":" + user->OS()->MANPATH();
|
||||
|
||||
NormalizePath();
|
||||
TraversePath();
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* MakePath()
|
||||
*
|
||||
* Given a search path element (host name:path name pair), construct
|
||||
* the appropriate path for this particular desktop subsystem:
|
||||
*
|
||||
* DTMANPATH
|
||||
*
|
||||
* A path is constructed so that each host:/path pair is appended.
|
||||
************************************************************************/
|
||||
void ManSearchPath::MakePath
|
||||
(
|
||||
const CString & pair
|
||||
)
|
||||
{
|
||||
CTokenizedString element(pair,":");
|
||||
CString host_element = element.next();
|
||||
CString path_element = element.next();
|
||||
|
||||
if (host_element == user->OS()->LocalHost()) {
|
||||
if (user->OS()->isDirectory(path_element) || options->dontOptimize())
|
||||
AddToPath (path_element);
|
||||
}
|
||||
else {
|
||||
CString dirname(ConstructPath(path_element, &host_element));
|
||||
if (user->OS()->isDirectory(dirname) || options->dontOptimize())
|
||||
AddToPath (dirname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* ExportPath()
|
||||
*
|
||||
* Export the variable value to the rest of the session.
|
||||
*
|
||||
*****************************************************************/
|
||||
void ManSearchPath::ExportPath()
|
||||
{
|
||||
CString env(GetEnvVar());
|
||||
user->OS()->shell()->putToEnv(env,
|
||||
final_search_path.data());
|
||||
}
|
||||
|
||||
|
||||
void ManSearchPath::Print()
|
||||
{
|
||||
printf("%s:\n", GetEnvVar());
|
||||
CString sp(GetSearchPath());
|
||||
if (!sp.isNull()) {
|
||||
CTokenizedString path (sp,Separator().data());
|
||||
CString subpath = path.next();
|
||||
while (!subpath.isNull()) {
|
||||
printf("\t%s\n",subpath.data());
|
||||
subpath = path.next();
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
ostream & operator<<
|
||||
(
|
||||
ostream & os,
|
||||
const ManSearchPath & sp
|
||||
)
|
||||
{
|
||||
os << sp.GetEnvVar() << endl;
|
||||
sp.PrettyPrint(os);
|
||||
return os;
|
||||
}
|
||||
107
cde/programs/dtsearchpath/dtsp/Options.C
Normal file
107
cde/programs/dtsearchpath/dtsp/Options.C
Normal file
@@ -0,0 +1,107 @@
|
||||
/* $XConsortium: Options.C /main/4 1996/01/25 15:55:11 rswiston $ */
|
||||
/*******************************************************************
|
||||
*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
*
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "Options.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* Two options are available for dtsearchpath:
|
||||
*
|
||||
* -v Verbose - prints the Search Path environment
|
||||
* variables to standard output.
|
||||
* -u Check User - determines the Search Path for a
|
||||
* particular user.
|
||||
* -a AutoMount - remove the autmounter's mount point
|
||||
*
|
||||
* -csh force Csh style environment set commands
|
||||
*
|
||||
* -ksh force Ksh style environment set commands
|
||||
**************************************************************/
|
||||
|
||||
Options::Options
|
||||
(
|
||||
unsigned int argc,
|
||||
char ** argv
|
||||
) : flags(0), user_id(0), home_dir(0), automountpoint(0)
|
||||
{
|
||||
CString Usage ("Usage: dtsearchpath [ -v | -T | -o | -a | -csh | -ksh ] "
|
||||
"[ -u <login-name> ]");
|
||||
|
||||
if (argc > 1) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i],"-v") == 0)
|
||||
flags |= 1;
|
||||
else if (strcmp(argv[i],"-T") == 0)
|
||||
flags |= 4;
|
||||
else if (strcmp(argv[i],"-o") == 0)
|
||||
flags |= 8;
|
||||
else if (strcmp(argv[i],"-a") == 0)
|
||||
flags |= 16;
|
||||
else if (strcmp(argv[i],"-csh") == 0)
|
||||
flags |= 32;
|
||||
else if (strcmp(argv[i],"-c") == 0) // for bc with sun version
|
||||
flags |= 32;
|
||||
else if (strcmp(argv[i],"-ksh") == 0)
|
||||
flags |= 64;
|
||||
else if (strcmp(argv[i],"-u") == 0) {
|
||||
flags |= 2;
|
||||
if (++i < argc && argv[i][0] != '-') {
|
||||
user_id = new CString(argv[i]);
|
||||
struct passwd * pwd = getpwnam(user_id->data());
|
||||
home_dir = new CString(pwd->pw_dir);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s\n",Usage.data());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s\n",Usage.data());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(hpux) || defined(hpV4)
|
||||
flags |= 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Options::~Options()
|
||||
{
|
||||
delete user_id;
|
||||
delete automountpoint;
|
||||
delete home_dir;
|
||||
}
|
||||
|
||||
|
||||
void Options::setUserID
|
||||
(
|
||||
const CString & login
|
||||
)
|
||||
{
|
||||
user_id = new CString(login);
|
||||
}
|
||||
|
||||
void Options::setAutoMountPoint
|
||||
(
|
||||
const CString & mountpoint
|
||||
)
|
||||
{
|
||||
if (mountpoint.isNull())
|
||||
automountpoint = new CString("/tmp_mnt");
|
||||
else
|
||||
automountpoint = new CString(mountpoint);
|
||||
}
|
||||
43
cde/programs/dtsearchpath/dtsp/Options.h
Normal file
43
cde/programs/dtsearchpath/dtsp/Options.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* $XConsortium: Options.h /main/3 1995/11/03 12:32:15 rswiston $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#ifndef _OPTIONS_H_
|
||||
#define _OPTIONS_H_
|
||||
|
||||
#include "cstring.h"
|
||||
|
||||
class Options {
|
||||
public:
|
||||
Options (unsigned int, char **);
|
||||
~Options ();
|
||||
|
||||
int Verbose () const { return (flags & 1); }
|
||||
int CheckingUser () const { return (flags & 2); }
|
||||
int doingTooltalk () const { return !doingICCCM(); }
|
||||
int doingICCCM () const { return (flags & 4); }
|
||||
int dontOptimize () const { return (flags & 8); }
|
||||
int removeAutoMountPoint() const { return (flags & 16); }
|
||||
int useCshEnv() const { return (flags & 32); }
|
||||
int useKshEnv() const { return (flags & 64); }
|
||||
|
||||
CString getAutoMountPoint () const { return *automountpoint; }
|
||||
CString * getUserID () const { return user_id; }
|
||||
CString * getHomeDir () const { return home_dir; }
|
||||
|
||||
void setUserID (const CString &);
|
||||
void setAutoMountPoint (const CString &);
|
||||
|
||||
private:
|
||||
unsigned char flags;
|
||||
CString * user_id;
|
||||
CString * home_dir;
|
||||
CString * automountpoint;
|
||||
};
|
||||
|
||||
#endif
|
||||
385
cde/programs/dtsearchpath/dtsp/SearchPath.C
Normal file
385
cde/programs/dtsearchpath/dtsp/SearchPath.C
Normal file
@@ -0,0 +1,385 @@
|
||||
/* $XConsortium: SearchPath.C /main/3 1995/11/03 12:32:30 rswiston $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#include "SearchPath.h"
|
||||
#include "TTFile.h"
|
||||
#include "Options.h"
|
||||
|
||||
extern Options * options;
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* SearchPath() - the constructor simply initializes the member data.
|
||||
*
|
||||
**********************************************************************/
|
||||
SearchPath::SearchPath
|
||||
(
|
||||
CDEEnvironment * user_,
|
||||
const char * envvar,
|
||||
const char * sep
|
||||
) : user(user_),
|
||||
environment_var(envvar),
|
||||
separator(sep),
|
||||
parse_state(0),
|
||||
final_search_path(""),
|
||||
norm_search_path("")
|
||||
{
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* ~SearchPath() - the destructor - nothing to do
|
||||
*
|
||||
**********************************************************************/
|
||||
SearchPath::~SearchPath()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* constructPath - this member function takes a host and a path and
|
||||
* either calls the Tooltalk filemapping library or
|
||||
* constructs it in the standard fashion.
|
||||
*
|
||||
**********************************************************************/
|
||||
CString SearchPath::ConstructPath
|
||||
(
|
||||
const CString & path,
|
||||
const CString * host,
|
||||
unsigned char
|
||||
)
|
||||
{
|
||||
CString final_path;
|
||||
|
||||
if (host) {
|
||||
if (options->doingTooltalk()) {
|
||||
TTFile * file;
|
||||
Try {
|
||||
file = new TTFile(*host,path);
|
||||
if (!file->ttFileOpFailed())
|
||||
final_path = *file;
|
||||
if (options->removeAutoMountPoint()) {
|
||||
if (final_path.contains(options->getAutoMountPoint(),
|
||||
"","/"))
|
||||
final_path.replace(options->getAutoMountPoint(),"");
|
||||
}
|
||||
}
|
||||
Catch (TTFile::TT_Exception *, file) {
|
||||
final_path = user->OS()->MountPoint() + *host + path;
|
||||
}
|
||||
delete file;
|
||||
}
|
||||
else
|
||||
final_path = user->OS()->MountPoint() + *host + path;
|
||||
}
|
||||
else
|
||||
final_path = path;
|
||||
|
||||
return final_path;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* AssembleString()
|
||||
*
|
||||
* Given a series of string elements one at a time--either a host
|
||||
* or a path, in any order--tokenize them, and create
|
||||
* a normalized path of the form:
|
||||
*
|
||||
* "host:/path,host:/path"
|
||||
*
|
||||
* Return this normalized path in $RETURN_STRING.
|
||||
*
|
||||
*************************************************************************/
|
||||
void SearchPath::AssembleString
|
||||
(
|
||||
const CString & path_element
|
||||
)
|
||||
{
|
||||
if (parse_state == 1 && norm_search_path.length())
|
||||
if (norm_search_path[norm_search_path.length()-1] != ',')
|
||||
norm_search_path += ",";
|
||||
|
||||
if (path_element.length() == 0) {
|
||||
|
||||
if (parse_state == 2) {
|
||||
CString path(save_host + ":" + user->SysAdmConfig());
|
||||
if (!norm_search_path.contains(path, ",", ","))
|
||||
norm_search_path += path;
|
||||
parse_state = 1;
|
||||
}
|
||||
}
|
||||
else if (path_element[0] == '/') {
|
||||
|
||||
// B -- a path
|
||||
|
||||
if (parse_state == 1) {
|
||||
CString path(user->OS()->LocalHost() + ":" + path_element);
|
||||
if (!norm_search_path.contains(path, ",", ","))
|
||||
norm_search_path += path;
|
||||
parse_state = 1;
|
||||
}
|
||||
else if (parse_state == 2) {
|
||||
CString path(save_host + ":" + path_element);
|
||||
if (!norm_search_path.contains(path, ",", ","))
|
||||
norm_search_path += path;
|
||||
parse_state = 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (path_element[0] == '>') {
|
||||
|
||||
// terminator--write out the saved host and default path.
|
||||
|
||||
CString path(save_host + ":" + user->SysAdmConfig());
|
||||
if (!norm_search_path.contains(path, ",", ","))
|
||||
norm_search_path += path;
|
||||
parse_state = 3;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
// A -- a host
|
||||
|
||||
if (parse_state == 1) {
|
||||
save_host = path_element;
|
||||
parse_state = 2;
|
||||
}
|
||||
|
||||
else if (parse_state == 2) {
|
||||
CString path(save_host + ":" + user->SysAdmConfig());
|
||||
if (!norm_search_path.contains(path, ",", ","))
|
||||
norm_search_path += path;
|
||||
save_host = path_element;
|
||||
parse_state = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* NormalizePath()
|
||||
*
|
||||
* This function takes a complete string and calls the helper
|
||||
* function AssembleString() to build a normalized path.
|
||||
*
|
||||
*****************************************************************/
|
||||
void SearchPath::NormalizePath()
|
||||
{
|
||||
parse_state = 1;
|
||||
|
||||
if (search_path.length()) {
|
||||
CTokenizedString subpath(search_path,":,");
|
||||
CString dirname = subpath.next();
|
||||
while (!subpath.Finished()) {
|
||||
AssembleString (dirname);
|
||||
dirname = subpath.next();
|
||||
}
|
||||
}
|
||||
|
||||
// flush the buffer
|
||||
|
||||
if (parse_state == 2)
|
||||
AssembleString(">");
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* AddToPath()
|
||||
*
|
||||
* Take the second parameter (if it exists), and add the
|
||||
* first parameter (always assumed) to its end separated by the
|
||||
* specified separator
|
||||
*********************************************************************/
|
||||
|
||||
void SearchPath::AddToPath
|
||||
(
|
||||
const CString & path
|
||||
)
|
||||
{
|
||||
if (!final_search_path.isNull()) {
|
||||
if (!final_search_path.contains (path, Separator().data(),
|
||||
Separator().data())) {
|
||||
final_search_path += Separator();
|
||||
final_search_path += path;
|
||||
}
|
||||
}
|
||||
else
|
||||
final_search_path += path;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* TraversePath()
|
||||
*
|
||||
* Parse a given search path, using comma (,) and colon (:) as
|
||||
* delimiters. Pass the normalized path to the virtual MakePath.
|
||||
* function.
|
||||
*
|
||||
* N.B. We assume that we have a normalized path at this point.
|
||||
*
|
||||
*********************************************************************/
|
||||
void SearchPath::TraversePath()
|
||||
{
|
||||
if (!norm_search_path.isNull()) {
|
||||
CTokenizedString subpath(norm_search_path,",");
|
||||
CString dirname = subpath.next();
|
||||
while (!dirname.isNull()) {
|
||||
MakePath (dirname);
|
||||
dirname = subpath.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* AddPredefinedPath()
|
||||
*
|
||||
* If it is possible that an environment variable can be set
|
||||
* before dtsearchpath is run, check for its existence, and if it
|
||||
* exists, append it to the searchpath.
|
||||
*
|
||||
*********************************************************************/
|
||||
void SearchPath::AddPredefinedPath()
|
||||
{
|
||||
CString envVar_in(environment_var);
|
||||
envVar_in += "SEARCHPATH";
|
||||
CString envVar_out = user->OS()->getEnvironmentVariable(envVar_in.data());
|
||||
if (!envVar_out.isNull()) {
|
||||
CString specified_path(envVar_out);
|
||||
if (!specified_path.contains(search_path))
|
||||
search_path += Separator() + specified_path;
|
||||
else
|
||||
search_path = specified_path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* validSearchPath()
|
||||
*
|
||||
* This member function verifies that the path in question is a
|
||||
* standard CDE location, i.e. /etc/dt/appconfig or /usr/dt/appconfig
|
||||
* so that the appropriate massaging can take place.
|
||||
*
|
||||
*********************************************************************/
|
||||
int SearchPath::validSearchPath
|
||||
(
|
||||
const CString & st
|
||||
) const
|
||||
{
|
||||
if (st == user->SysAdmConfig())
|
||||
return 1;
|
||||
|
||||
if (st == user->FactoryInstall())
|
||||
return 1;
|
||||
|
||||
// If this is an APP-specified path, it also needs to be massaged.
|
||||
|
||||
// The elements in the APP paths may be host:/path so use the
|
||||
// colon as the leader.
|
||||
|
||||
if (user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains (st, ":", separator.data()))
|
||||
return 1;
|
||||
|
||||
if (user->DTUSERAPPSP() &&
|
||||
user->DTUSERAPPSP()->contains (st, ":", separator.data()))
|
||||
return 1;
|
||||
|
||||
// they may also be there by themselves: "host:,/path" so use the
|
||||
// comma as the leader.
|
||||
|
||||
if (user->DTAPPSP() &&
|
||||
user->DTAPPSP()->contains (st, ",", separator.data()))
|
||||
return 1;
|
||||
|
||||
if (user->DTUSERAPPSP() &&
|
||||
user->DTUSERAPPSP()->contains (st, ",", separator.data()))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* ExportPath()
|
||||
*
|
||||
* Export the variable value to the rest of the session.
|
||||
*
|
||||
*****************************************************************/
|
||||
void SearchPath::ExportPath()
|
||||
{
|
||||
CString env(environment_var);
|
||||
env += "SEARCHPATH";
|
||||
|
||||
user->OS()->shell()->putToEnv(env, final_search_path.data());
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* Print()
|
||||
*
|
||||
* In the absence of iostreams, use printf to output information
|
||||
*
|
||||
*****************************************************************/
|
||||
void SearchPath::Print()
|
||||
{
|
||||
printf("%sSEARCHPATH:\n", GetEnvVar());
|
||||
CString sp(GetSearchPath());
|
||||
if (!sp.isNull()) {
|
||||
CTokenizedString path (sp,Separator().data());
|
||||
CString subpath = path.next();
|
||||
while (!subpath.isNull()) {
|
||||
printf("\t%s\n",subpath.data());
|
||||
subpath = path.next();
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* PrettyPrint()
|
||||
*
|
||||
* Print the list such that each entry occupys its own line
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
void SearchPath::PrettyPrint
|
||||
(
|
||||
ostream & os
|
||||
) const
|
||||
{
|
||||
CTokenizedString path (GetSearchPath(), Separator().data());
|
||||
CString subpath = path.next();
|
||||
while (!subpath.isNull()) {
|
||||
os << " " << subpath << endl;
|
||||
subpath = path.next();
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* operator<<()
|
||||
*
|
||||
* Allow SearchPath types to be output using iostreams.
|
||||
*
|
||||
****************************************************************/
|
||||
|
||||
ostream & operator<<
|
||||
(
|
||||
ostream & os,
|
||||
const SearchPath & sp
|
||||
)
|
||||
{
|
||||
os << sp.GetEnvVar() << "SEARCHPATH:" << endl;
|
||||
sp.PrettyPrint(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
163
cde/programs/dtsearchpath/dtsp/SearchPath.h
Normal file
163
cde/programs/dtsearchpath/dtsp/SearchPath.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/* $XConsortium: SearchPath.h /main/4 1996/03/27 14:39:41 barstow $ */
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
#ifndef _SEARCHPATH_H_
|
||||
#define _SEARCHPATH_H_
|
||||
|
||||
#include "Environ.h"
|
||||
#include "cstring.h"
|
||||
#include <iostream.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class SearchPath {
|
||||
public:
|
||||
SearchPath() {}
|
||||
SearchPath (CDEEnvironment *, const char *, const char *);
|
||||
virtual ~SearchPath();
|
||||
|
||||
virtual void ExportPath();
|
||||
virtual void Print();
|
||||
virtual void AddPredefinedPath();
|
||||
virtual void PrettyPrint (ostream &) const;
|
||||
|
||||
friend ostream & operator<< (ostream &, const SearchPath &);
|
||||
|
||||
const char * GetEnvVar() const { return environment_var; }
|
||||
CString GetSearchPath() const { return final_search_path; }
|
||||
|
||||
protected:
|
||||
void AssembleString (const CString &);
|
||||
void NormalizePath();
|
||||
void AddToPath (const CString &);
|
||||
void TraversePath();
|
||||
|
||||
virtual void MakePath (const CString &) {}
|
||||
virtual CString ConstructPath (const CString &, const CString *,
|
||||
unsigned char useTT = 1);
|
||||
|
||||
int ParseState() const { return parse_state; }
|
||||
CString Separator() const { return separator; }
|
||||
|
||||
virtual int validSearchPath (const CString &) const;
|
||||
|
||||
void setSeparator (const char * sep) { separator = sep; }
|
||||
|
||||
CString search_path;
|
||||
CString norm_search_path;
|
||||
CString final_search_path;
|
||||
CDEEnvironment * user;
|
||||
|
||||
private:
|
||||
const char * environment_var;
|
||||
int parse_state;
|
||||
CString save_host;
|
||||
CString separator;
|
||||
};
|
||||
|
||||
|
||||
class AppSearchPath : public SearchPath {
|
||||
public:
|
||||
AppSearchPath (CDEEnvironment *,
|
||||
const char * = "DTAPP",
|
||||
const char * = ",");
|
||||
virtual ~AppSearchPath() {}
|
||||
|
||||
void FixUp();
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class IconSearchPath : public SearchPath {
|
||||
public:
|
||||
IconSearchPath (CDEEnvironment *,
|
||||
const char * = "XMICON",
|
||||
const char * = ".pm",
|
||||
const char * = ".bm",
|
||||
const char * = ":");
|
||||
virtual ~IconSearchPath() {}
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
virtual int validSearchPath (const CString &) const;
|
||||
|
||||
private:
|
||||
CString first;
|
||||
CString second;
|
||||
};
|
||||
|
||||
|
||||
class DatabaseSearchPath : public SearchPath {
|
||||
public:
|
||||
DatabaseSearchPath (CDEEnvironment *,
|
||||
const char * = "DTDATABASE",
|
||||
const char * = ",");
|
||||
virtual ~DatabaseSearchPath() {}
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
virtual CString ConstructPath (const CString &, const CString *,
|
||||
unsigned char useTT = 0);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class HelpSearchPath : public SearchPath {
|
||||
public:
|
||||
HelpSearchPath (CDEEnvironment *,
|
||||
const char * = "DTHELP",
|
||||
const char * = ":");
|
||||
virtual ~HelpSearchPath() {}
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
virtual int validSearchPath (const CString &) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class InfoLibSearchPath : public SearchPath {
|
||||
public:
|
||||
InfoLibSearchPath (CDEEnvironment *,
|
||||
const char * = "DTINFOLIB",
|
||||
const char * = ":");
|
||||
virtual ~InfoLibSearchPath() {}
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
virtual int validSearchPath (const CString &) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class ManSearchPath : public SearchPath {
|
||||
public:
|
||||
ManSearchPath (CDEEnvironment *,
|
||||
const char * = "MANPATH",
|
||||
const char * = ":");
|
||||
virtual ~ManSearchPath() {}
|
||||
|
||||
virtual void ExportPath ();
|
||||
virtual void Print();
|
||||
|
||||
friend ostream & operator<< (ostream &, const ManSearchPath &);
|
||||
|
||||
protected:
|
||||
virtual void MakePath (const CString &);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
208
cde/programs/dtsearchpath/dtsp/dtsearchpath.C
Normal file
208
cde/programs/dtsearchpath/dtsp/dtsearchpath.C
Normal file
@@ -0,0 +1,208 @@
|
||||
/*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are reserved. Copying or other reproduction of this
|
||||
** program except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
****************************<+>*************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* File: dtsearchpath
|
||||
*
|
||||
* Purpose: Set up the application search paths for
|
||||
* the desktop components.
|
||||
*
|
||||
* Description: This client is invoked by the Xsession file
|
||||
* at user login. It sets the local and remote locations
|
||||
* that the desktop components should look, for application
|
||||
* icons, help files, and other application configuration
|
||||
* information on behalf of the user.
|
||||
*
|
||||
* Invoked by: Xsession after the scripts in /etc/dt/Xsession.d
|
||||
* are sourced in.
|
||||
*
|
||||
* Product: @(#)Common Desktop Environment 1.0
|
||||
*
|
||||
* Revision: $XConsortium: dtsearchpath.C /main/9 1996/07/10 16:38:27 rswiston $
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DTMOUNTPOINT
|
||||
* Description: The directory where this system mounts remote discs.
|
||||
* Used for constructing pathnames to remote files, for
|
||||
* systems that are not using a global file name space.
|
||||
* Default: Vendor specific: /nfs
|
||||
*
|
||||
* DTAPPSEARCHPATH
|
||||
* Description: The directories where we will look for applications.
|
||||
* Default: $HOME/.dt/appmanager,
|
||||
* /etc/dt/appconfig/appmanager,
|
||||
* /usr/dt/appconfig/appmanager
|
||||
*
|
||||
* DTDATABASESEARCHPATH
|
||||
* Description: The directories where we will look for actions/filetypes.
|
||||
* Default: Derived from DTAPPSEARCHPATH:
|
||||
* $HOME/.dt/types,
|
||||
* /etc/dt/appconfig/types/%L,
|
||||
* /usr/dt/appconfig/types/%L
|
||||
*
|
||||
* DTHELPSEARCHPATH
|
||||
* Description: The directories where we will look for online help.
|
||||
* Default: Derived from $DTAPPSEARCHPATH:
|
||||
* $HOME/.dt/help/[%H | %H.hv]
|
||||
* /etc/dt/appconfig/help/%L/[%H | %H.sdl | %H.hv],
|
||||
* /usr/dt/appconfig/help/%L/[%H | %H.sdl | %H.hv]
|
||||
*
|
||||
* DTINFOLIBSEARCHPATH
|
||||
* Description: The directories where we will look for online information.
|
||||
* Default: Derived from $DTAPPSEARCHPATH:
|
||||
* $HOME/.dt/infolib/%L/%I.dti,
|
||||
* /etc/dt/appconfig/infolib/%L/%I.dti,
|
||||
* /usr/dt/appconfig/infolib/%L/%I.dti
|
||||
*
|
||||
* DTICONSEARCHPATH
|
||||
* Description: The directories where we will look for icons.
|
||||
* Default: Derived from $DTAPPSEARCHPATH:
|
||||
* $HOME/.dt/icons/%B,
|
||||
* /etc/dt/appconfig/icons/%L/[%B | %B.pm | %B.bm]
|
||||
* /usr/dt/appconfig/icons/%L/[%B | %B.pm | %B.bm]
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* If you specify a value for one of the search paths, then that value
|
||||
* will be added to the default search path after the sys-admin config-
|
||||
* uration location but before the factory-default location. For ex-
|
||||
* ample, if you specify a value for the DTSPSYSAPPHOSTS of /foo, then
|
||||
* the search path will be:
|
||||
*
|
||||
* $HOME/.dt:/etc/dt/appconfig:/foo:/usr/dt/appconfig
|
||||
*
|
||||
* Remember that you can also set the USER equivalents of these
|
||||
* search paths. They are useful for specifying locations other
|
||||
* than the defaults. Their names are:
|
||||
*
|
||||
* DTSPUSERAPPHOSTS
|
||||
* Default: <null>
|
||||
*
|
||||
* DTSPUSERDATABASEHOSTS
|
||||
* Default: <null>
|
||||
*
|
||||
* DTSPUSERHELP
|
||||
* Default: <null>
|
||||
*
|
||||
* DTSPUSERINFOLIB
|
||||
* Default: <null>
|
||||
*
|
||||
* DTSPUSERICON
|
||||
* Default: <null>
|
||||
*
|
||||
* These values will be prepended to the system paths, and hence will
|
||||
* will take precedence.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "SearchPath.h"
|
||||
#include "Options.h"
|
||||
#include "Environ.h"
|
||||
|
||||
const char * DTINFOLIBDEFAULT_NAME = "DTINFOLIBDEFAULT";
|
||||
const char * DTINFOLIBDEFAULT_VALUE = "cde";
|
||||
|
||||
Options * options;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
CString newShell("SHELL="); // Keep in scope for duration of program.
|
||||
|
||||
options = new Options(argc, argv);
|
||||
|
||||
if ( options->useKshEnv() ) {
|
||||
newShell += UnixEnvironment::kshString();
|
||||
putenv(newShell.data());
|
||||
}
|
||||
else if ( options->useCshEnv() ) {
|
||||
newShell += UnixEnvironment::cshString();
|
||||
putenv(newShell.data());
|
||||
}
|
||||
|
||||
UnixEnvironment * os = new UnixEnvironment;
|
||||
|
||||
CDEEnvironment * user = new CDEEnvironment(options->getHomeDir(), os);
|
||||
user->CreateHomeAppconfigDir();
|
||||
|
||||
if (options->removeAutoMountPoint())
|
||||
options->setAutoMountPoint(os->getEnvironmentVariable("DTAUTOMOUNTPOINT"));
|
||||
|
||||
InfoLibSearchPath infolib (user);
|
||||
|
||||
AppSearchPath app (user);
|
||||
DatabaseSearchPath database (user);
|
||||
|
||||
user->setDTAPPSP(app.GetSearchPath());
|
||||
|
||||
IconSearchPath icon (user);
|
||||
IconSearchPath iconbm (user, "XMICONBM", ".bm", ".pm");
|
||||
|
||||
HelpSearchPath help (user);
|
||||
|
||||
ManSearchPath man(user);
|
||||
|
||||
app.FixUp();
|
||||
|
||||
if (options->Verbose() || options->CheckingUser()) {
|
||||
CString mp(user->OS()->MountPoint());
|
||||
#ifdef IOSTREAMSWORKS
|
||||
cout << "DTMOUNTPOINT: " << mp << "\n" << endl;
|
||||
cout << app << endl;
|
||||
cout << database << endl;
|
||||
cout << icon << endl;
|
||||
cout << iconbm << endl;
|
||||
cout << help << endl;
|
||||
cout << infolib << endl;
|
||||
cout << DTINFOLIBDEFAULT_NAME << ": " << DTINFOLIBDEFAULT_VALUE << "\n" << endl;
|
||||
#else
|
||||
printf("DTMOUNTPOINT: %s\n",mp.data());
|
||||
app.Print();
|
||||
database.Print();
|
||||
icon.Print();
|
||||
iconbm.Print();
|
||||
help.Print();
|
||||
infolib.Print();
|
||||
printf ("%s: %s\n", DTINFOLIBDEFAULT_NAME, DTINFOLIBDEFAULT_VALUE);
|
||||
#endif
|
||||
man.Print();
|
||||
}
|
||||
|
||||
if (!options->CheckingUser() && !options->Verbose()) {
|
||||
app.ExportPath();
|
||||
database.ExportPath();
|
||||
icon.ExportPath();
|
||||
iconbm.ExportPath();
|
||||
help.ExportPath();
|
||||
infolib.ExportPath();
|
||||
|
||||
#ifdef IOSTREAMSWORKS
|
||||
if ( os->cshFormat ) {
|
||||
cout << "setenv " << DTINFOLIBDEFAULT_NAME << " " << DTINFOLIBDEFAULT_VALUE << endl;
|
||||
} else {
|
||||
cout << DTINFOLIBDEFAULT_NAME << "=" << DTINFOLIBDEFAULT_VALUE << endl;
|
||||
cout << "export " << DTINFOLIBDEFAULT_NAME << ";" << endl;
|
||||
}
|
||||
#else
|
||||
if ( os->cshFormat ) {
|
||||
printf("setenv %s %s;\n", DTINFOLIBDEFAULT_NAME, DTINFOLIBDEFAULT_VALUE);
|
||||
} else {
|
||||
printf("%s=%s;\n", DTINFOLIBDEFAULT_NAME, DTINFOLIBDEFAULT_VALUE);
|
||||
printf("export %s;\n", DTINFOLIBDEFAULT_NAME);
|
||||
}
|
||||
#endif /* IOSTREAMSWORKS */
|
||||
|
||||
man.ExportPath();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user