Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,177 @@
XCOMM!/bin/ksh
XCOMM ####################################################################
XCOMM ## File: 0010.dtpaths
XCOMM ##
XCOMM ## Default Location: /usr/dt/config/Xsession.d/
XCOMM ##
XCOMM ## Purpose: Provide syntactical information about
XCOMM ## the CDE searchpaths that the desktop components
XCOMM ## should search, for application icons, help files,
XCOMM ## application manager icons, and datatype and
XCOMM ## action files, on behalf of the user.
XCOMM ##
XCOMM ## Description: This file consists of documentation only.
XCOMM ##
XCOMM ## Invoked by: /usr/dt/bin/Xsession
XCOMM ##
XCOMM ## Product: @(#)Common Desktop Environment 1.0
XCOMM ##
XCOMM ## Note: Please refer to the dtsearchpath(1) man page for
XCOMM ## more information.
XCOMM ##
XCOMM ## Revision: $XConsortium: 0010.dtpaths.src /main/5 1996/04/23 16:35:34 drk $
XCOMM ##
XCOMM ## (c) Copyright 1993, 1994 Hewlett-Packard Company
XCOMM ## (c) Copyright 1993, 1994 International Business Machines Corp.
XCOMM ## (c) Copyright 1993, 1994 Sun Microsystems, Inc.
XCOMM ## (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
XCOMM ## Novell, Inc.
XCOMM ##
XCOMM ####################################################################
XCOMM ####################################################################
XCOMM
XCOMM ************** DO NOT EDIT THIS FILE **************
XCOMM
XCOMM All the files under /usr/dt/config/Xsession.d are factory-default
XCOMM files and will be unconditionally overwritten upon subsequent
XCOMM installation. Before making changes to the file, copy it to the
XCOMM configuration directory, /etc/dt/config/Xsession.d.
XCOMM
XCOMM ####################################################################
XCOMM ####################################################################
XCOMM ## Global variables for system customization:
XCOMM ## -------------------------------------------------
XCOMM ## DTMOUNTPOINT
XCOMM ## Description: The directory where this system mounts remote discs.
XCOMM ## Default: Vendor specific: /nfs
XCOMM ##
XCOMM ## DTAPPSEARCHPATH
XCOMM ## Description: The directories in which we will look for applications.
XCOMM ## Inputs: DTSPSYSAPPHOSTS, DTSPUSERAPPHOSTS
XCOMM ## Default: $HOME/.dt/appmanager,
XCOMM ## /etc/dt/appconfig/appmanager/%L,
XCOMM ## /etc/dt/appconfig/appmanager/C,
XCOMM ## /usr/dt/appconfig/appmanager/%L,
XCOMM ## /usr/dt/appconfig/appmanager/C
XCOMM ##
XCOMM ## DTDATABASESEARCHPATH
XCOMM ## Description: The directories in which we will look for actions and
XCOMM ## filetypes.
XCOMM ## Inputs: DTSPSYSDATABASEHOSTS, DTSPUSERDATABASEHOSTS
XCOMM ## Default: Derived from DTSPSYSAPPHOSTS
XCOMM ## $HOME/.dt/types,
XCOMM ## /etc/dt/appconfig/types/%L,
XCOMM ## /etc/dt/appconfig/types/C,
XCOMM ## /usr/dt/appconfig/types/%L,
XCOMM ## /usr/dt/appconfig/types/C
XCOMM ## DTHELPSEARCHPATH
XCOMM ## Description: The directories in which we will look for online help.
XCOMM ## Inputs: DTSPSYSHELP, DTSPUSERHELP
XCOMM ## Default: Derived from DTSPSYSAPPHOSTS
XCOMM ## $HOME/.dt/help/%T/[ %H | %H.sdl | %H.hv ],
XCOMM ## /etc/dt/appconfig/help/%L/%T/[ %H | %H.sdl | %H.hv ],
XCOMM ## /etc/dt/appconfig/help/C/%T/[ %H | %H.sdl | %H.hv ],
XCOMM ## /usr/dt/appconfig/help/%L/%T/[ %H | %H.sdl | %H.hv ]
XCOMM ## /usr/dt/appconfig/help/C/%T/[ %H | %H.sdl | %H.hv ]
XCOMM ## DTINFOLIBSEARCHPATH
XCOMM ## Description: The directories in which we will look for online help.
XCOMM ## Inputs: DTSPSYSINFOLIB, DTSPUSERINFOLIB
XCOMM ## Default: Derived from DTSPSYSAPPHOSTS and DTSPUSERAPPHOSTS
XCOMM ## $HOME/.dt/infolib/%I.dt
XCOMM ## /etc/dt/appconfig/infolib/%L/%I.dti
XCOMM ## /etc/dt/appconfig/infolib/C/%I.dti
XCOMM ## /usr/dt/appconfig/infolib/%L/%I.dti
XCOMM ## /usr/dt/appconfig/infolib/C/%I.dti
XCOMM ## DTICONSEARCHPATH
XCOMM ## Description: The directories in which we will look for icons.
XCOMM ## Inputs: DTSPSYSICON, DTSPUSERICON
XCOMM ## Default: Derived from DTSPSYSAPPHOSTS
XCOMM ## $HOME/.dt/icons/[ %B.pm | %B.bm | %B ],
XCOMM ## /etc/dt/appconfig/icons/%L/[ %B.pm | %B.bm | %B ],
XCOMM ## /etc/dt/appconfig/icons/C/[ %B.pm | %B.bm | %B ],
XCOMM ## /usr/dt/appconfig/icons/%L/[ %B.pm | %B.bm | %B ]
XCOMM ## /usr/dt/appconfig/icons/C/[ %B.pm | %B.bm | %B ]
XCOMM ##
XCOMM ####################################################################
XCOMM #################################################################
XCOMM ## Search path syntax:
XCOMM ## -------------------------------------------------
XCOMM ## For the APP and DATABASE search path input elements, you may specify a
XCOMM ## host name, a path name or both. For the HELP, INFOLIB and ICON, you
XCOMM ## may specify a pathname only.
XCOMM ##
XCOMM ## Search path element:
XCOMM ## Host | Pathname | Host+Pathname
XCOMM ##
XCOMM ## Host syntax:
XCOMM ## <hostname>:
XCOMM ##
XCOMM ## Pathname syntax:
XCOMM ## /<pathname>
XCOMM ##
XCOMM ## Host+Pathname syntax:
XCOMM ## <hostname>:/<pathname>
XCOMM ##
XCOMM ## You may combine these elements into a comma-separated list:
XCOMM ## <searchpath_element> [,<searchpath_element>]
XCOMM ##
XCOMM ## The list order determines search order--the first located
XCOMM ## element wins.
XCOMM ####################################################################
XCOMM ####################################################################
XCOMM ## Customization notes:
XCOMM ## -------------------------------------------------
XCOMM ## If you specify a value for one of the system search paths (DTSPSYS
XCOMM ## prefix), then that value will be appended to the /etc/dt/appconfig
XCOMM ## default search path. For example, if you specify a value for the
XCOMM ## DTSPSYSHELP, then your value will be appended to the normal
XCOMM ## configuration value -- after "/etc/dt/appconfig/help" -- but before
XCOMM ## the factory default location--"/usr/dt/appconfig/help".
XCOMM ##
XCOMM ## Users may also set the USER equivalents of these search paths. They
XCOMM ## can be done in their $HOME/.dtprofile file, which will be sourced in
XCOMM ## before the scripts under /etc/dt/config/Xsession.d/ and
XCOMM ## /usr/dt/config/Xsession.d/.
XCOMM ##
XCOMM ## The names of these USER variables are:
XCOMM ##
XCOMM ## DTSPUSERAPPHOSTS
XCOMM ## Default: <null>
XCOMM ##
XCOMM ## DTSPUSERDATABASEHOSTS
XCOMM ## Default: <null>
XCOMM ##
XCOMM ## DTSPUSERHELP
XCOMM ## Default: <null>
XCOMM ##
XCOMM ## DTSPUSERINFOLIB
XCOMM ## Default: <null>
XCOMM ##
XCOMM ## DTSPUSERICON
XCOMM ## Default: <null>
XCOMM ##
XCOMM ## These USER values will be prepended to the system paths, and hence
XCOMM ## will take precedence.
XCOMM ##
XCOMM ## All values for a given environment variable must appear on one line.
XCOMM ## You can use embedded white space IF you quote the right-hand side.
XCOMM ####################################################################
XCOMM ####################################################################
XCOMM ## Customization examples:
XCOMM ## -------------------------------------------------
XCOMM ## DTMOUNTPOINT=/net
XCOMM ##
XCOMM ## DTSPSYSAPPHOSTS="remote_machine1:,/localdir"
XCOMM ##
XCOMM ## DTSPSYSICON=/opt/allicons
XCOMM ##
XCOMM ## DTSPUSERHELP=/mydisk/hvs
XCOMM ##
XCOMM ####################################################################
XCOMM ##################### eof ############################

View File

@@ -0,0 +1,88 @@
XCOMM!/bin/ksh
XCOMM ####################################################################
XCOMM ## File: 0030.dttmpdir
XCOMM ##
XCOMM ## Default Location: CDE_INSTALLATION_TOP/config/Xsession.d/
XCOMM ##
XCOMM ## Purpose: Create the temporary directory on a per-user,
XCOMM ## per-session basis, keying on the $DTUSERSESSION
XCOMM ## value, which can also be set by the dtsearchpath
XCOMM ## utility.
XCOMM ##
XCOMM ## Description:
XCOMM ## This script is invoked by means of the Xsession file
XCOMM ## at user login. It creates a temporary directory
XCOMM ## for files on behalf of the user.
XCOMM ##
XCOMM ## Invoked by: CDE_INSTALLATION_TOP/bin/Xsession
XCOMM ##
XCOMM ## Product: @(#)Common Desktop Environment 1.0
XCOMM ##
XCOMM ## Note: Creates the /var/dt directory if one doesn't exist.
XCOMM ## However, root privilege may be required. If /var/dt
XCOMM ## disappears, then logging in as root should restore it.
XCOMM ##
XCOMM ## $TOG: 0030.dttmpdir.src /main/7 1997/04/21 12:08:15 samborn $
XCOMM ##
XCOMM ## (c) Copyright 1993, 1994 Hewlett-Packard Company
XCOMM ## (c) Copyright 1993, 1994 International Business Machines Corp.
XCOMM ## (c) Copyright 1993, 1994 Sun Microsystems, Inc.
XCOMM ## (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
XCOMM ## Novell, Inc.
XCOMM ####################################################################
#define HASH #
if (( ${#DTUSERSESSION} == 0 ))
then
HASH
HASH Set the DTAPPMANDIR directory component, which will control
HASH the location of the user's Application Manager directory,
HASH as well as the location of his or her temporary directory.
HASH
DTAPPDIR_HOST_COMPONENT=${DISPLAY%:*}
DTAPPDIR_DISP_COMPONENT=${DISPLAY#*:}
if [[ ${DTAPPDIR_HOST_COMPONENT} = "" ]]
then
DTAPPDIR_HOST_COMPONENT=`uname -n`
fi
HASH
HASH If the screen number is "0" (e.g., "host:3.0"), then
HASH strip off the screen number.
HASH
if [[ ${DTAPPDIR_DISP_COMPONENT#*.} = "0" ]]
then
DTAPPDIR_DISP_COMPONENT=${DTAPPDIR_DISP_COMPONENT%.0}
fi
DTUSERSESSION=${LOGNAME}-${DTAPPDIR_HOST_COMPONENT}-${DTAPPDIR_DISP_COMPONENT}
export DTUSERSESSION
fi
XCOMM
XCOMM Create the /var/dt subdirectory, if one doesn't exist
XCOMM
if [[ ! -d /var/dt ]]
then
HASH
HASH This step requires root privilege
HASH
mkdir -p /var/dt >/dev/null 2>/dev/null
chmod 755 /var/dt >/dev/null 2>/dev/null
chgrp bin /var/dt >/dev/null 2>/dev/null
chown bin /var/dt >/dev/null 2>/dev/null
fi
if [ ! -d /var/dt/tmp ]
then
HASH
HASH This step requires root privilege
HASH
mkdir -p /var/dt/tmp >/dev/null 2>/dev/null
chmod 755 /var/dt/tmp >/dev/null 2>/dev/null
chgrp bin /var/dt/tmp >/dev/null 2>/dev/null
chown bin /var/dt/tmp >/dev/null 2>/dev/null
fi
XCOMM ######################### eof ########################

View File

@@ -0,0 +1,18 @@
XCOMM $TOG: Imakefile /main/9 1998/08/10 15:50:21 mgreess $
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
SUBDIRS = libCliSrv dtsp dtappg
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
CPP_TARGETS = 0010.dtpaths 0030.dttmpdir
AllTarget($(CPP_TARGETS))
LOCAL_CPP_DEFINES = -DCDE_INSTALLATION_TOP=$(CDE_INSTALLATION_TOP) \
-DCDE_CONFIGURATION_TOP=$(CDE_CONFIGURATION_TOP)
CppSourceFile(0010.dtpaths,0010.dtpaths.src,$(LOCAL_CPP_DEFINES),)
CppSourceFile(0030.dttmpdir,0030.dttmpdir.src,$(LOCAL_CPP_DEFINES),)

View File

@@ -0,0 +1,26 @@
XCOMM $TOG: Imakefile /main/14 1998/08/05 13:21:24 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
SYS_LIBRARIES = -ldl -lintl
#endif
#ifdef RsArchitecture
EXTRA_DEFINES = -DIOSTREAMSWORKS
#endif
SRCS = Options.C dtappgather.C
OBJS = Options.o dtappgather.o
NormalCplusplusObjectRule()
ComplexCplusplusProgramTarget(dtappg)

View File

@@ -0,0 +1,48 @@
/* $XConsortium: Options.C /main/2 1995/07/17 13:54:17 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 "Options.h"
#include <stdlib.h>
#include <iostream.h>
#include <stdio.h>
#include <pwd.h>
/**************************************************************
*
* Two options are available for dtappgather:
*
* -v Verbose - prints the Search Path environment
* variables to standard output.
* -r Retain - Retain previous contents of the
* Application Manager
*
**************************************************************/
Options::Options
(
unsigned int argc,
char ** argv
) : flags(0)
{
CString Usage ("Usage: dtappgather [ -v | -r ]");
if (argc > 1) {
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i],"-v") == 0)
flags += 1;
else if (strcmp(argv[i],"-r") == 0)
flags += 2;
else {
fprintf(stderr,"%s\n",Usage.data());
exit (1);
}
}
}
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: Options.h /main/3 1995/11/03 12:29:53 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 Retain () const { return (flags & 2); }
private:
unsigned char flags;
};
#endif

View File

@@ -0,0 +1,298 @@
/*******************************************************************
** (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: dtappgather.C
*
* Purpose: Create the Application Manager
* the desktop components.
*
* Description: dtappgather is invoked by the Xsession file at
* user login. It collects the application groups
* and subdirectories that are to appear in the
* user's Application Manager view.
*
* It is also invoked by the "ReloadApps" action.
*
* Product: @(#)Common Desktop Environment 1.0
*
* Revision: $TOG: dtappgather.C /main/9 1998/12/14 17:38:54 mgreess $
*
********************************************************************/
/********************************************************************
*
* Environment variables used by this utility
*
* DTMOUNTPOINT
* Default may be vendor specific: /nfs
*
* DTAPPSEARCHPATH
* Default: $HOME/.dt,/etc/dt/appconfig,/usr/dt/appconfig
* Set at login by the dtsearchpath utility.
*
* HOME
* No default.
* Set by the dtlogin program.
*
* DISPLAY
* No default.
* Set by the dtlogin program.
*
* TARGET_APPMAN_DIR
* Default: /var/dt/appconfig/appmanager/$DTUSERSESSION
* Set within this utility.
*
****************************************************************************/
#include "Options.h"
#include "dtappgather.h"
#include "DirIterator.h"
#include <stdlib.h>
#include <iostream.h>
Options * options;
void LegacyCleanUp
(
CDEEnvironment * user
)
{
// For now, remove the old ApplicationManager subdirectory
// so that we don't leave old CDE users with extra baggage
// under $HOME.
CString targetAppmanDir (user->HOME() + ".dt/ApplicationManager");
if (user->OS()->isDirectory(targetAppmanDir) &&
0 == user->OS()->isLink(targetAppmanDir)) {
user->OS()->changePermissions(targetAppmanDir,0777);
user->OS()->removeDirectory(targetAppmanDir);
}
}
AppManagerDirectory::AppManagerDirectory
(
CDEEnvironment * user,
const CString & app
) : user_(user),
langVersionFound(0),
appsp_(app)
{
// Set the users Application Manager subdirectory
CString userhostdir = user->UserHostDir();
if (userhostdir.isNull())
userhostdir = "generic-display-0";
// else if dir is non-NULL and there is a / in DTUSERSESSION,
// dtappgather creates /var/dt/appconfig/appmanager/DTUSERSESSION.
// This is a possible security hole, so
// prevent creation of directories of the form
// /var/dt/appconfig/appmanager/directory1/directory2
//
else if ((char *)strstr(userhostdir.data(),"/"))
userhostdir = "generic-display-0";
dirname_ = "/var/dt/appconfig/appmanager/";
dirname_ += userhostdir;
if (user->OS()->isDirectory(dirname_) &&
0 == user->OS()->isLink(dirname_)) {
user->OS()->changeOwnerGroup(dirname_,"","");
user->OS()->changePermissions(dirname_,0755);
#ifdef sun
user->OS()->removeFiles(dirname_, ".~*");
#else
user->OS()->removeFiles(dirname_, "[.]~*");
#endif
user->OS()->removeDeadLinks(dirname_);
if (!options->Retain())
#ifdef sun
user->OS()->removeFiles(dirname_,"*");
#else
user->OS()->removeFiles(dirname_,"[.]*");
#endif
}
else {
// Make /var/dt/appconfig/appmanager directories if not present
//
// Make user session subdirectory under /var/dt/appconfig/appmanager
CString dir(dirname_);
dir.replace("/" + userhostdir,"");
if (!user->OS()->isDirectory(dir)) { // does appmanager exist?
dir.replace("/appmanager","");
if (!user->OS()->isDirectory(dir)) { // does appconfig exist?
dir.replace("/appconfig","");
if (!user->OS()->isDirectory(dir)) { // does dt exist?
dir.replace("/dt","");
if (!user->OS()->isDirectory(dir)) { // does /var exist?
user->OS()->MakeDirectory(dir,0775);
user->OS()->changeOwnerGroup(dir,"root","other");
user->OS()->changePermissions(dir,0775);
}
dir += "/dt";
user->OS()->MakeDirectory(dir,0755);
user->OS()->changeOwnerGroup(dir,"root","other");
user->OS()->changePermissions(dir,0755);
}
dir += "/appconfig";
user->OS()->MakeDirectory(dir,0755);
user->OS()->changeOwnerGroup(dir,"bin","bin");
user->OS()->changePermissions(dir,0755);
}
dir += "/appmanager";
user->OS()->MakeDirectory(dir,0755);
user->OS()->changeOwnerGroup(dir,"bin","bin");
user->OS()->changePermissions(dir,0755);
}
user->OS()->MakeDirectory(dirname_,0755);
user->OS()->changeOwnerGroup(dirname_,"","");
}
// Make /var/dt/tmp directory if not present
CString tmp("/var/dt/tmp/");
if (!user->OS()->isDirectory(tmp)) { // does tmp exist?
user->OS()->MakeDirectory(tmp,0755);
user->OS()->changeOwnerGroup(tmp,"root","other");
user->OS()->changePermissions(tmp,0755);
}
tmp += userhostdir;
if (!user->OS()->isDirectory(tmp)) { // does tmp/$DTUSERSESSION exist?
user->OS()->MakeDirectory(tmp, 0755);
user->OS()->changeOwnerGroup(tmp,"","");
user->OS()->changePermissions(tmp,0755);
}
}
/********************************************************************
*
* TraversePath()
*
* Parse a given search path, using comma (,) and colon (:) as
* delimiters. Pass each path element to another function.
********************************************************************/
void AppManagerDirectory::TraversePath()
{
if (!appsp_.isNull()) {
CTokenizedString subpath(appsp_,":");
CString dir = subpath.next();
while (!dir.isNull()) {
GatherAppsFromASearchElement (dir);
dir = subpath.next();
if (langVersionFound && dir == "/usr/dt/appconfig/appmanager/C")
dir = subpath.next();
}
}
}
/********************************************************************
*
* goodFile()
*
* Ignore '.' and '..' and make sure file doesn't exist.
*
********************************************************************/
int AppManagerDirectory::goodFile
(
const CString & path,
const CString & fname
) const
{
if (fname == "." || fname == "..")
return 0;
CString filnam(path + "/" + fname);
if (user_->OS()->FileExists(filnam))
return 0;
return 1;
}
/*********************************************************************
*
* GatherAppsFromASearchElement()
*
* Given search path element (host name or path name), construct
* the appropriate path for the various desktop subsystems.
*
* A path is constructed so that each element is appended to
* the tail.
*********************************************************************/
void AppManagerDirectory::GatherAppsFromASearchElement
(
const CString & path
)
{
if (path.length()) {
CString source(path);
if (source.contains("/%L")) {
if (user_->OS()->LANG() != "C") {
source.replace("%L",user_->OS()->LANG());
if (!user_->OS()->isDirectory(source))
return;
if (source.contains("/usr/dt/appconfig/appmanager/"))
langVersionFound = 1;
}
else
return;
}
else if (!user_->OS()->isDirectory(source))
return;
DirectoryIterator iter (source);
struct dirent * direntry;
user_->OS()->setUserId();
while (direntry = iter()) {
CString dname(direntry->d_name);
if (user_->OS()->isDirectory(source + "/" + dname)
|| user_->OS()->isFile(source + "/" + dname))
if (goodFile(dirname_, dname))
user_->OS()->symbolicLink (source + "/" + dname,
dirname_ + "/" + dname);
}
user_->OS()->setUserId();
}
}
int main (int argc, char **argv)
{
options = new Options(argc, argv);
UnixEnvironment * os = new UnixEnvironment;
CDEEnvironment * user = new CDEEnvironment(0, os);
LegacyCleanUp(user);
CString app(getenv("DTAPPSEARCHPATH"));
AppManagerDirectory * appman = new AppManagerDirectory(user, app);
appman->TraversePath();
user->OS()->changePermissions((*appman)(),0555);
return 0;
}

View File

@@ -0,0 +1,42 @@
/*******************************************************************
** (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: dtappgather.h
*
* Purpose: Class definitions for the gathering process
*
* Product: @(#)Common Desktop Environment 1.0
*
* Revision: $XConsortium: dtappgather.h /main/3 1995/11/03 12:30:33 rswiston $
*
********************************************************************/
#include "Environ.h"
class AppManagerDirectory {
public:
AppManagerDirectory() {}
AppManagerDirectory(CDEEnvironment *, const CString &);
~AppManagerDirectory() { delete user_; }
void GatherAppsFromASearchElement (const CString & path);
void TraversePath();
char * operator()() const { return dirname_.data(); }
private:
int goodFile (const CString &, const CString &) const;
CString dirname_;
CDEEnvironment * user_;
CString appsp_;
int langVersionFound;
};

View File

@@ -0,0 +1,10 @@
For instructions on how to customize the Information and System_Admin
directories, refer to the Common Desktop Environment: User's Guide Chapter
6 -- Running Applications from the Desktop. Also, see
The Common Desktop Environment 1.0: Advanced User's and System Administrator's
sections:
Adding and Administering Applications
Registering an Application
Introduction to Actions and Data Types
Creating Actions and Data Types Using Create Action
Creating Actions Manually

View 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(":");
}
}

View 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));
}
}
}

View 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;
}

View 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;
}

View 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)

View 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;
}

View 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;
}

View 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);
}

View 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

View 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;
}

View 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

View 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;
}

View File

@@ -0,0 +1,37 @@
/* $XConsortium: DirIterator.C /main/2 1995/07/17 14:09:48 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 "DirIterator.h"
#include <errno.h>
DirectoryIterator::DirectoryIterator
(
const CString & dir
) : state(good_)
{
theDir = opendir(dir.data());
if (theDir == 0)
state = bad_;
}
DirectoryIterator::~DirectoryIterator()
{
closedir(theDir);
}
struct dirent * DirectoryIterator::operator()()
{
struct dirent * direntry = readdir(theDir);
if (direntry == 0)
state = (errno ? bad_ : done_);
return direntry;
}

View File

@@ -0,0 +1,31 @@
/* $XConsortium: DirIterator.h /main/3 1995/11/03 12:33:19 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 "cstring.h"
#include <dirent.h>
class DirectoryIterator {
public:
DirectoryIterator(const CString &);
~DirectoryIterator();
enum directoryState { good_ = 0, bad_ = 1, done_ = 2 };
struct dirent * operator()();
int bad() { return state & bad_; }
int good() { return state & good_; }
int done() { return state & done_; }
private:
DirectoryIterator() {}
DIR * theDir;
int state;
};

View File

@@ -0,0 +1,147 @@
/* $XConsortium: Environ.C /main/4 1996/04/30 18:12:49 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.
********************************************************************
****************************<+>*************************************/
#include "Environ.h"
OSEnvironment::OSEnvironment()
{
}
CDEEnvironment::CDEEnvironment
(
CString * homedir,
OSEnvironment * os_
) : dtspSysApp(0),
dtspUserApp(0),
dtspSysIcon(0),
dtspUserIcon(0),
dtspSysHelp(0),
dtspUserHelp(0),
dtspSysInfoLib(0),
dtspUserInfoLib(0),
dtspSysDB(0),
dtspUserDB(0),
dtManPath(0),
userHostDir(""),
os(os_)
{
CString envVar;
sysAdmConfig = "/etc/dt/appconfig";
factoryInstall = "/usr/dt/appconfig";
factoryManPath = "/usr/dt/man";
envVar = os->getEnvironmentVariable("DTSPSYSAPPHOSTS");
if (!envVar.isNull())
dtspSysApp = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPUSERAPPHOSTS");
if (!envVar.isNull())
dtspUserApp = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPSYSICON");
if (!envVar.isNull())
dtspSysIcon = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPUSERICON");
if (!envVar.isNull())
dtspUserIcon = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPSYSHELP");
if (!envVar.isNull())
dtspSysHelp = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPUSERHELP");
if (!envVar.isNull())
dtspUserHelp = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPSYSINFOLIB");
if (!envVar.isNull())
dtspSysInfoLib = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPUSERINFOLIB");
if (!envVar.isNull())
dtspUserInfoLib = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPSYSDATABASEHOSTS");
if (!envVar.isNull())
dtspSysDB = new CString(envVar);
envVar = os->getEnvironmentVariable("DTSPUSERDATABASEHOSTS");
if (!envVar.isNull())
dtspUserDB = new CString(envVar);
envVar = os->getEnvironmentVariable("DTMANPATH");
if (!envVar.isNull())
dtManPath = new CString(envVar);
envVar = os->getEnvironmentVariable("DTUSERSESSION");
if (!envVar.isNull())
userHostDir = envVar;
if (homedir == 0) {
envVar = os->getEnvironmentVariable("HOME");
theHome = envVar;
}
else
theHome = *homedir;
theHome += "/.dt";
defaultSearchPath = theHome + "," + sysAdmConfig + "," + factoryInstall;
}
CDEEnvironment::~CDEEnvironment()
{
delete dtspSysApp;
delete dtspUserApp;
delete dtspSysIcon;
delete dtspUserIcon;
delete dtspSysHelp;
delete dtspUserHelp;
delete dtspSysInfoLib;
delete dtspUserInfoLib;
delete dtspSysDB;
delete dtspUserDB;
delete dtManPath;
delete os;
}
void CDEEnvironment::setDTAPPSP
(
const CString & sp
)
{
delete dtspSysApp;
dtspSysApp = new CString(sp);
}
void CDEEnvironment::CreateHomeAppconfigDir()
{
if (!os->FileExists (HOME()))
os->MakeDirectory (HOME(), 0755);
if (!os->FileExists (HOME() + "/types"))
os->MakeDirectory (HOME() + "/types", 0775);
if (!os->FileExists (HOME() + "/icons"))
os->MakeDirectory (HOME() + "/icons", 0775);
if (!os->FileExists (HOME() + "/appmanager"))
os->MakeDirectory (HOME() + "/appmanager", 0775);
if (!os->FileExists (HOME() + "/help"))
os->MakeDirectory (HOME() + "/help", 0775);
}

View File

@@ -0,0 +1,214 @@
/* $TOG: Environ.h /main/8 1998/04/06 13:32:59 mgreess $ */
/*******************************************************************
** (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 _ENVIRON_H_
#define _ENVIRON_H_
#include "cstring.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
class Shell {
public:
// class constructor, destructor
Shell() {}
~Shell() {}
// pure virtual function
virtual void putToEnv( const CString &, const char * ) = 0;
};
class KShell : public Shell {
public:
KShell() {}
~KShell() {}
void putToEnv ( const CString & envvar,
const char * value )
{
CString toPut(envvar);
toPut += "=";
toPut += value;
#ifdef IOSTREAMSWORKS
cout << toPut << ";" << endl;
cout << "export " << envvar << ";" << endl;
#else
printf("%s;\n", toPut.data());
printf("export %s;\n", envvar.data());
#endif
}
};
class CShell : public Shell {
public:
CShell() {}
~CShell() {}
void putToEnv ( const CString & envvar,
const char * value )
{
CString toPut("setenv ");
toPut += envvar;
toPut += " ";
toPut += value;
#ifdef IOSTREAMSWORKS
cout << toPut << ";" << endl;
#else
printf("%s;\n", toPut.data());
#endif
}
};
class OSEnvironment {
public:
OSEnvironment();
virtual ~OSEnvironment() {}
virtual int FileExists (const CString &) const = 0;
virtual void MakeDirectory (const CString &, mode_t) = 0;
virtual CString getEnvironmentVariable (const char *) = 0;
virtual int isDirectory (const CString &) = 0;
virtual int isFile (const CString &) = 0;
virtual int isLink (const CString &) = 0;
virtual void changePermissions (const CString &, mode_t) = 0;
virtual void changeOwnerGroup (const CString &, const char *,
const char * = 0) = 0;
virtual void removeDirectory (const CString &) = 0;
virtual void removeFiles (const CString &, const CString &) = 0;
virtual void removeFile (const CString &) = 0;
virtual void removeDeadLinks (const CString &) = 0;
virtual void symbolicLink (const CString &, const CString &) = 0;
virtual void setUserId (const char * = 0) = 0;
CString MountPoint() const { return dtMountPoint; }
CString LocalHost() const { return localHost; }
CString LANG() const { return lang; }
CString MANPATH() const { return manpath; }
int NonDefaultLang() { return lang != "C"; }
Shell *shell () { return shell_ ; }
protected:
CString dtMountPoint;
CString localHost;
CString lang;
CString manpath;
Shell *shell_;
};
class UnixEnvironment : public OSEnvironment {
public:
UnixEnvironment();
virtual ~UnixEnvironment();
virtual int FileExists (const CString &) const;
virtual void MakeDirectory (const CString &, mode_t);
virtual CString getEnvironmentVariable (const char *);
virtual int isDirectory (const CString &);
virtual int isFile (const CString &);
virtual int isLink (const CString &);
virtual void changePermissions (const CString &, mode_t);
virtual void changeOwnerGroup (const CString &, const char *,
const char * = 0);
virtual void removeDirectory (const CString &);
virtual void removeFiles (const CString &, const CString &);
virtual void removeFile (const CString &);
virtual void removeDeadLinks (const CString &);
virtual void symbolicLink (const CString &, const CString &);
virtual void setUserId (const char * = 0);
int cshFormat;
static CString kshString() {
return CString("ksh");
}
static CString cshString() {
return CString("csh");
}
static int isCsh(const CString &shStr) {
CString cshStr(cshString());
return shStr.contains(cshStr);
}
static int isKsh(const CString &shStr) {
CString kshStr(kshString());
return shStr.contains(kshStr);
}
private:
uid_t uid_;
gid_t gid_;
};
class CDEEnvironment {
public:
CDEEnvironment () {}
CDEEnvironment (CString *, OSEnvironment *);
~CDEEnvironment();
void CreateHomeAppconfigDir();
CString * DTAPPSP() const { return dtspSysApp; }
CString * DTUSERAPPSP() const { return dtspUserApp; }
CString * DTICONSP() const { return dtspSysIcon; }
CString * DTUSERICONSP() const { return dtspUserIcon; }
CString * DTHELPSP() const { return dtspSysHelp; }
CString * DTUSERHELPSP() const { return dtspUserHelp; }
CString * DTINFOLIBSP() const { return dtspSysInfoLib; }
CString * DTUSERINFOLIBSP() const { return dtspUserInfoLib; }
CString * DTDBSP() const { return dtspSysDB; }
CString * DTUSERDBSP() const { return dtspUserDB; }
CString * DTMANPATH() const { return dtManPath; }
void setDTAPPSP (const CString & sp);
CString HOME() const { return theHome; }
CString SysAdmConfig() const { return sysAdmConfig; }
CString FactoryInstall() const { return factoryInstall; }
CString FactoryManPath() const { return factoryManPath; }
CString DefaultSearchPath() const { return defaultSearchPath; }
CString UserHostDir() const { return userHostDir; }
OSEnvironment * OS() const { return os; }
// These vars are public because their defaults will be
// changed for DTINFOLIBSEARCHPATH.
CString sysAdmConfig;
CString factoryInstall;
private:
CString theHome;
CString factoryManPath;
CString defaultSearchPath;
CString userHostDir;
CString * dtspUserApp;
CString * dtspSysApp;
CString * dtspSysIcon;
CString * dtspUserIcon;
CString * dtspSysHelp;
CString * dtspUserHelp;
CString * dtspSysInfoLib;
CString * dtspUserInfoLib;
CString * dtspSysDB;
CString * dtspUserDB;
CString * dtManPath;
OSEnvironment * os;
};
#endif

View File

@@ -0,0 +1,33 @@
XCOMM $TOG: Imakefile /main/5 1998/08/05 13:22:12 mgreess $
#define DoNormalLib YES
#define DoSharedLib NO
#define DoDebugLib NO
#define DoProfileLib NO
#define LibName CliSrv
#define LibHeaders NO
#define LibInstall NO
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
INCLUDES = -I.
#ifdef SunArchitecture
SYS_LIBRARIES = -ldl -lintl
LAST_LOAD_FLAGS = -Bstatic -lC -Bdynamic -lm -lc -ladm -Bstatic
EXTRA_DEFINES = -DIOSTREAMSWORKS
#endif
#ifdef RsArchitecture
EXTRA_DEFINES = -DIOSTREAMSWORKS
#endif
SRCS = DirIterator.C Environ.C TTFile.C \
UnixEnv.C cstring.C
OBJS = DirIterator.o Environ.o TTFile.o \
UnixEnv.o cstring.o
#include <Library.tmpl>
DependTarget()

View File

@@ -0,0 +1,87 @@
/* $XConsortium: TTFile.C /main/2 1995/07/17 14:10:04 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 "TTFile.h"
#include <Tt/tt_c.h>
#include <stdio.h>
TTFile::TTFile
(
const CString & host,
const CString & path
) : CString(), status(TT_OK)
{
char * temp = tt_host_file_netfile(host.data(), path.data());
if ((status = tt_ptr_error(temp)) != TT_OK)
Throw (TT_Exception(temp));
contents = tt_netfile_file(temp);
tt_free(temp);
if ((status = tt_ptr_error(contents)) != TT_OK)
Throw (TT_Exception(contents));
}
TTFile::TTFile
(
const TTFile & file
)
{
contents = new char [file.length() + 1];
strcpy(contents,file.data());
status = file.status;
}
TTFile::~TTFile()
{
if (contents)
tt_free(contents);
}
#ifndef HAS_EXCEPTIONS
void TTFile::TT_Exception
(
char * str
)
{
#ifdef IOSTREAMSWORKS
cerr << tt_status_message(tt_pointer_error(str)) << endl;
#else
fprintf(stderr, "%s\n", tt_status_message(tt_pointer_error(str)));
#endif
}
#endif
TTFile & TTFile::operator=
(
const TTFile & file
)
{
if (file != *this) {
delete [] contents;
contents = new char [file.length() + 1];
strcpy(contents,file.data());
status = file.status;
}
return *this;
}
ostream & operator<<
(
ostream & os,
TTFile & file
)
{
if (file.ttFileOpFailed())
return os << "Error in filename mapping; status = "
<< file.getStatus() << endl;
else
return os << file.data() << endl;
}

View File

@@ -0,0 +1,55 @@
/* $XConsortium: TTFile.h /main/3 1995/11/03 12:33:57 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 _TTFILE_H_
#define _TTFILE_H_
#include "cstring.h"
#include "Tt/tt_c.h"
#ifdef HAS_EXCEPTIONS
#define Throw(ex) throw ex
#define Try try
#define Catch(type,file) catch(type ex)
#else
#define Throw(ex) { ex; return; }
#define Try
#define Catch(type,file) if (file->ttFileOpFailed())
#endif
class TTFile : public CString {
public:
TTFile () : status(TT_OK) {}
TTFile (const CString &, const CString &);
TTFile (const TTFile &);
~TTFile();
TTFile & operator=(const TTFile &);
#ifdef HAS_EXCEPTIONS
class TT_Exception {
public:
TT_Exception (char * str)
{ cerr << tt_status_message(tt_pointer_error(str)); }
~TT_Exception() {}
friend ostream & operator<< (ostream &, TTFile &);
};
#else
void TT_Exception (char *);
friend ostream & operator<< (ostream &, TTFile &);
#endif
int ttFileOpFailed () { return status != TT_OK; }
Tt_status getStatus() { return status; }
private:
Tt_status status;
};
#endif

View File

@@ -0,0 +1,327 @@
/* $TOG: UnixEnv.C /main/11 1998/12/14 17:06:02 mgreess $ */
/*******************************************************************
** (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 "Environ.h"
#include "DirIterator.h"
#include <sys/stat.h>
#if defined(USL) || defined(__uxp__)
#define S_ISLNK(mode) ((mode & S_IFMT) == S_IFLNK)
#endif
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <stdio.h>
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#if defined(sun) || defined(USL) || defined(__uxp__)
#include <regexpr.h>
#else
#include <regex.h>
#endif
#include <errno.h>
#if defined(sun) || defined(_AIX) || defined(__osf__) || defined(USL) || defined(__uxp__) || (linux)
#define UID_NO_CHANGE ((uid_t) -1)
#define GID_NO_CHANGE ((gid_t) -1)
#endif
UnixEnvironment::UnixEnvironment()
{
dtMountPoint = getEnvironmentVariable("DTMOUNTPOINT");
if (dtMountPoint.isNull())
#if defined(sun) || defined(USL) || defined(__uxp__)
dtMountPoint = "/net/";
#else
dtMountPoint = "/nfs/";
#endif
CString temp = getEnvironmentVariable("MANPATH");
if (temp.isNull())
#if defined(sun) || defined(USL) || defined(__uxp__)
manpath = "/usr/share/man";
#elif defined(_AIX)
manpath = "/usr/share/man:/usr/lpp/info";
#elif defined(hpux)
manpath = "/usr/man:/usr/contrib/man:/usr/local/man";
#elif defined(__osf__)
manpath = "/usr/share/%L/man:/usr/share/man:/usr/local/man";
#elif defined(linux)
manpath = "/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man";
#endif
else
manpath = temp;
lang = getEnvironmentVariable("LANG");
if (lang.isNull())
lang = "C";
localHost = "localhost";
CString sh(getEnvironmentVariable("SHELL"));
cshFormat = 0;
if (isCsh(sh)) {
shell_ = new CShell();
cshFormat = 1;
}
else
shell_ = new KShell();
uid_ = getuid();
gid_ = getgid();
}
UnixEnvironment::~UnixEnvironment()
{
delete shell_;
}
int UnixEnvironment::FileExists
(
const CString & filename
) const
{
struct stat file;
if (stat((const char *)filename.data(),&file) == 0)
return 1;
return 0;
}
void UnixEnvironment::MakeDirectory
(
const CString & dirname,
mode_t permissions
)
{
if (mkdir (dirname.data(), permissions) == -1) {
CString errorStr("MakeDirectory: " + dirname);
perror(errorStr.data());
}
}
CString UnixEnvironment::getEnvironmentVariable
(
const char * envvar
)
{
char * value = getenv(envvar);
if (value == 0)
return CString("");
return CString(value);
}
int UnixEnvironment::isDirectory
(
const CString & directory
)
{
struct stat file;
if (stat((const char *)directory.data(),&file) == 0)
if (S_ISDIR(file.st_mode))
return 1;
return 0;
}
int UnixEnvironment::isFile
(
const CString & filespec
)
{
struct stat file;
if (stat((const char *)filespec.data(),&file) == 0)
if (S_ISREG(file.st_mode))
return 1;
return 0;
}
int UnixEnvironment::isLink
(
const CString & filespec
)
{
struct stat file;
if (lstat((const char *)filespec.data(),&file) == 0)
if (S_ISLNK(file.st_mode))
return 1;
return 0;
}
void UnixEnvironment::symbolicLink
(
const CString & linkto,
const CString & linkee
)
{
if (symlink (linkto.data(), linkee.data()) == -1) {
CString errorStr("symbolicLink: " + linkee + " -> " + linkto + "| ");
perror(errorStr.data());
}
}
void UnixEnvironment::setUserId
(
const char * name
)
{
uid_t uid = UID_NO_CHANGE;
if (name && name[0]) {
struct passwd * pwent = getpwnam(name);
uid = pwent->pw_uid;
}
else if (name == 0)
uid = uid_;
if (setuid(uid) == -1) {
CString errorStr("setUserId: ");
errorStr += name;
errorStr += "| ";
perror(errorStr.data());
}
}
void UnixEnvironment::changePermissions
(
const CString & filespec,
mode_t mode
)
{
if (chmod (filespec.data(), mode) == -1) {
CString errorStr("changePermissions: " + filespec + "| ");
perror(errorStr.data());
}
}
void UnixEnvironment::changeOwnerGroup
(
const CString & filespec,
const char * owner,
const char * group
)
{
uid_t uid = UID_NO_CHANGE;
gid_t gid = GID_NO_CHANGE;
if (owner) {
if (owner[0]) {
struct passwd * pwent = getpwnam(owner);
uid = pwent->pw_uid;
}
else
uid = getuid();
}
if (group) {
if (group[0]) {
struct group * grent = getgrnam(group);
gid = grent->gr_gid;
}
else
gid = getgid();
}
if (chown(filespec.data(),uid,gid) == -1) {
CString errorStr("changeOwnerGroup: " + filespec + "| ");
perror(errorStr.data());
}
}
void UnixEnvironment::removeDirectory
(
const CString & dirspec
)
{
#ifdef sun
removeFiles(dirspec, ".~*");
removeFiles(dirspec, "*");
#else
removeFiles(dirspec, "[.]~*");
removeFiles(dirspec, "[.]*");
#endif
if (rmdir (dirspec.data()) == -1) {
CString errorStr("removeDirectory: " + dirspec + "| ");
perror(errorStr.data());
}
}
void UnixEnvironment::removeFiles
(
const CString & dirspec,
const CString & filespec
)
{
#if defined(sun) || defined(__uxp__)
char buffer[100];
sprintf(buffer,"rm -f %s/%s", dirspec.data(),filespec.data());
system(buffer);
#else
DirectoryIterator dir(dirspec);
struct dirent * direntry;
while (direntry = dir()) {
/*# ifdef should_be_sun_but_this_dont_work*/
#if defined(USL)
char * re = NULL;
re = compile (filespec.data(), NULL, NULL);
if (step (direntry->d_name,re)) {
# else
regex_t re;
regcomp (&re, filespec.data(), 0);
if (regexec (&re, direntry->d_name, 0, NULL, 0) == 0) {
# endif
if (strcmp(direntry->d_name,".") == 0 ||
strcmp(direntry->d_name,"..") == 0)
continue;
removeFile(dirspec + "/" + direntry->d_name);
}
}
#endif
}
void UnixEnvironment::removeFile
(
const CString & filespec
)
{
if (isDirectory(filespec) && !isLink(filespec))
removeDirectory(filespec);
else {
if (unlink (filespec.data()) == -1) {
CString errorStr("removeFile(unlink): " + filespec + "| ");
perror(errorStr.data());
}
}
}
void UnixEnvironment::removeDeadLinks
(
const CString & dirspec
)
{
DIR * dir = opendir(dirspec.data());
struct dirent * direntry;
while (direntry = readdir(dir)) {
if (isLink(dirspec + "/" + direntry->d_name))
if (!isFile(dirspec + "/" + direntry->d_name) &&
!isDirectory(dirspec + "/" + direntry->d_name))
removeFile(dirspec + "/" + direntry->d_name);
}
closedir(dir);
}

View File

@@ -0,0 +1,555 @@
/* $XConsortium: cstring.C /main/2 1995/07/17 14:10:22 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 "cstring.h"
#include <ctype.h>
CString::CString()
{
contents = 0;
skipWhiteSpace = 1;
}
CString::CString
(
const char * s,
unsigned char ws
) : skipWhiteSpace(ws)
{
if (s != 0) {
contents = new char [strlen(s) + 1];
strcpy(contents,s);
}
else {
contents = new char [1];
strcpy(contents,"");
}
}
CString::CString
(
const char c,
unsigned char ws
) : skipWhiteSpace(ws)
{
contents = new char [2];
contents[0] = c;
contents[1] = 0;
}
CString::~CString()
{
delete [] contents;
}
CString::CString
(
const CString & s
)
{
contents = new char [s.length() + 1];
strcpy(contents,s.data());
skipWhiteSpace = s.skipWhiteSpace;
}
char & CString::operator[]
(
int index
) const
{
if (index < 0)
return contents[0];
if (index > strlen(contents))
return contents[strlen(contents)-1];
return contents[index];
}
int CString::operator!=
(
const CString & s
) const
{
return !(*this == s);
}
int CString::operator==
(
const CString & s
) const
{
if (isNull() && s.isNull())
return 1;
if (isNull() || s.isNull())
return 0;
if (strcmp(contents,s.data()) == 0)
return 1;
return 0;
}
CString & CString::operator=
(
const CString & s
)
{
if (s != *this) {
delete [] contents;
contents = new char [s.length() + 1];
strcpy(contents,s.data());
}
return *this;
}
CString & CString::operator=
(
const char * s
)
{
delete [] contents;
contents = new char [strlen(s) + 1];
strcpy(contents,s);
return *this;
}
CString & CString::operator+=
(
const char * cs
)
{
char * temp;
if (contents) {
if (cs)
temp = new char [strlen(contents) + strlen(cs) + 1];
else
return *this;
}
else {
if (cs)
temp = new char [strlen(cs) + 1];
else
return *this;
}
*temp = 0;
if (contents)
strcat(temp,contents);
if (cs)
strcat(temp,cs);
delete [] contents;
contents = temp;
return *this;
}
CString & CString::operator+=
(
const CString & s
)
{
char * temp;
if (contents) {
if (s.contents)
temp = new char [strlen(contents) + s.length() + 1];
else
return *this;
}
else {
if (s.contents)
temp = new char [s.length() + 1];
else
return *this;
}
*temp = 0;
if (contents)
strcat(temp,contents);
if (s.contents)
strcat(temp,s.data());
delete [] contents;
contents = temp;
return *this;
}
CString operator+
(
const CString & s1,
const CString & s2
)
{
CString result(s1);
result += s2;
return result;
}
CString operator+
(
const CString & s,
const char * cs
)
{
CString result(s);
result += cs;
return result;
}
CString operator+
(
const char * cs,
const CString & s
)
{
CString result(cs);
result += s;
return result;
}
CString CString::copy
(
unsigned int start,
const char * delim
)
{
if (isNull())
return *this;
for (int i = 0; i < strlen(delim); i++) {
char * q;
if (q = strchr(contents,delim[i])) {
char remember = *q;
*q = 0;
CString result(&contents[start]);
*q = remember;
return result;
}
}
return *this;
}
CString CString::copy
(
const char * delim1,
const char * delim2
)
{
if (isNull())
return *this;
for (int i = 0; i < strlen(delim1); i++) {
char * q;
if (q = strchr(contents,delim1[i])) {
for (int j = 0; j < strlen(delim2); j++) {
char * p;
if (p = strchr(q+1,delim2[j])) {
char remember = *p;
*p = 0;
CString result(q+1);
*p = remember;
return result;
}
}
return CString(q);
}
}
return *this;
}
CString CString::find
(
const char * cs
)
{
char * q;
if (isNull())
return *this;
if (q = strstr(contents,cs))
return CString(q);
return *this;
}
int CString::contains
(
const CString & s,
const char * leader,
const char * trailer
) const
{
return contains(s.data(), leader, trailer);
}
int CString::contains
(
const char * cs,
const char * leader,
const char * trailer
) const
{
// first see if there is anything in contents
if (isNull())
return 0;
// or if the strings are exactly the same
if (strcmp(cs,data()) == 0)
return 1;
// now check to see if it is embedded in the string
CString search(leader);
search += cs;
search += trailer;
if (strstr (contents, search.data()))
return 1;
// if skipWhiteSpace is on then check for spaces on one or
// both sides of the target in the source.
if (skipWhiteSpace) {
// first, a space in front, delimiter on the end
search = " ";
search += cs;
search += trailer;
if (strstr (contents, search.data()))
return 1;
// second, a delimiter on the front, space on the end
search = leader;
search += cs;
search += " ";
if (strstr (contents, search.data()))
return 1;
// third, spaces before and after
search = " ";
search += cs;
search += " ";
if (strstr (contents, search.data()))
return 1;
}
// now check to see if it is the start of the string
search = cs;
search += trailer;
if (strncmp (contents, search.data(), search.length()) == 0)
return 1;
// now check to see if it is the start of the string followed
// by a space
search = cs;
search += " ";
if (strncmp (contents, search.data(), search.length()) == 0)
return 1;
// last, check to see if it is on the end of the string using
// the delimiter and a space
search = leader;
while (1) {
search += cs;
char *q, *r = 0;
char *p = contents;
while (q = strstr(p, search.data())) {
r = q + strlen(leader);
p = q + 1;
}
if (r && strcmp(r,cs) == 0)
return 1;
if (search[0] == ' ')
break;
search = " ";
}
return 0;
}
void CString::replace
(
const CString & to_be_replaced,
const CString & replacee
)
{
char * q;
if (isNull())
return;
if (q = strstr(contents,to_be_replaced.data())) {
*q = 0;
char * prefix = new char [strlen(contents) + 1];
strcpy(prefix,contents);
q += to_be_replaced.length();
char * suffix = new char [strlen(q) + 1];
strcpy(suffix,q);
delete [] contents;
contents = new char [strlen(prefix) +
replacee.length() +
strlen(suffix) + 1];
strcpy(contents,prefix);
strcat(contents,replacee.data());
strcat(contents,suffix);
delete [] prefix;
delete [] suffix;
}
}
int CString::isNull() const
{
if (contents == 0)
return 1;
if (strlen(contents) == 0)
return 1;
return 0;
}
CTokenizedString::CTokenizedString()
: CString(""), finished(0), cursor(0), delimiter(0)
{}
CTokenizedString::CTokenizedString
(
const CTokenizedString & s
)
{
if (s != *this) {
cursor = new char [strlen(s.cursor) + 1];
strcpy(cursor,s.cursor);
delimiter = new char [strlen(s.delimiter) + 1];
strcpy(delimiter,s.delimiter);
finished = s.finished;
skipWhiteSpace = s.skipWhiteSpace;
contents = new char [strlen(s.contents) + 1];
strcpy(contents,s.contents);
}
}
CTokenizedString::CTokenizedString
(
const CString & s,
char * d,
unsigned char ws
) : CString(s), finished(0)
{
cursor = new char [s.length() + 1];
strcpy(cursor,s.data());
delimiter = new char [strlen(d) + 1];
strcpy(delimiter,d);
skipWhiteSpace = ws;
}
CTokenizedString::~CTokenizedString()
{
delete [] cursor;
delete [] delimiter;
}
CString CTokenizedString::next()
{
char * q = 0;
if (cursor) {
if (strlen(delimiter) == 1)
q = strchr(cursor,delimiter[0]);
else {
for (int i = 0; i < strlen(cursor); i++)
if (strchr(delimiter,cursor[i])) {
q = &cursor[i];
break;
}
}
}
if (q) {
// a delimiter has been found. Create the return token,
// adjust the cursor
*q = 0;
// eliminate trailing white space
if (skipWhiteSpace) {
for (char *p = q; isspace(*(p-1)); p--);
*p = 0;
}
CString result(cursor);
// eliminate leading white space
if (skipWhiteSpace)
for (; isspace(*(q+1)); q++);
char * temp = new char [strlen(q+1) + 1];
strcpy(temp,q+1);
delete [] cursor;
cursor = temp;
return result;
}
else if (cursor) {
// no delimiter found. Return what is left of the string
CString result(cursor);
delete [] cursor;
cursor = 0;
return result;
}
else {
finished = 1;
return CString("");
}
}
ostream & operator<<
(
ostream & os,
const CString & s
)
{
if (s.isNull())
return os << "(null)";
return os << s.data();
}

View File

@@ -0,0 +1,75 @@
/* $XConsortium: cstring.h /main/3 1995/11/03 12:34:22 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 _CSTRING_H_
#define _CSTRING_H_
#include <iostream.h>
#include <string.h>
class CString {
public:
CString();
CString(const char * s, unsigned char = 1);
CString(const char, unsigned char = 1);
CString(const CString &);
~CString();
int length() const { return strlen(contents); }
char * data() const { return contents; }
CString & operator= (const CString &);
CString & operator= (const char *);
CString & operator+= (const CString &);
CString & operator+= (const char *);
int operator!= (const CString &) const;
int operator== (const CString &) const;
char & operator[](int) const;
friend CString operator+ (const CString & s1, const CString & s2);
friend CString operator+ (const CString & s, const char * cs);
friend CString operator+ (const char * cs, const CString & s);
CString copy (unsigned int, const char *);
CString copy (const char *, const char *);
CString find (const char *);
int contains (const char *, const char * = "", const char * = "") const;
int contains (const CString &, const char * = "", const char * = "") const;
int isNull() const;
void replace (const CString &, const CString &);
friend ostream & operator<< (ostream &, const CString &);
protected:
char * contents;
unsigned char skipWhiteSpace;
};
class CTokenizedString : public CString {
public:
CTokenizedString();
CTokenizedString(const CTokenizedString &);
CTokenizedString(const CString &, char *, unsigned char = 1);
~CTokenizedString();
int Finished() { return finished == 1; }
CString next();
private:
char * cursor;
char * delimiter;
int finished;
};
#endif