Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
26
cde/programs/dtsearchpath/dtappg/Imakefile
Normal file
26
cde/programs/dtsearchpath/dtappg/Imakefile
Normal 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)
|
||||
48
cde/programs/dtsearchpath/dtappg/Options.C
Normal file
48
cde/programs/dtsearchpath/dtappg/Options.C
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
cde/programs/dtsearchpath/dtappg/Options.h
Normal file
27
cde/programs/dtsearchpath/dtappg/Options.h
Normal 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
|
||||
298
cde/programs/dtsearchpath/dtappg/dtappgather.C
Normal file
298
cde/programs/dtsearchpath/dtappg/dtappgather.C
Normal 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;
|
||||
}
|
||||
42
cde/programs/dtsearchpath/dtappg/dtappgather.h
Normal file
42
cde/programs/dtsearchpath/dtappg/dtappgather.h
Normal 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;
|
||||
};
|
||||
|
||||
|
||||
10
cde/programs/dtsearchpath/dtappg/howto-customize
Normal file
10
cde/programs/dtsearchpath/dtappg/howto-customize
Normal 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
|
||||
Reference in New Issue
Block a user