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,49 @@
XCOMM $XConsortium: Imakefile /main/10 1996/05/08 09:27:50 drk $
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
#include <Threads.tmpl>
#include "../../tooltalk.tmpl"
DEFINES =
INCLUDES = -I. -I../../lib
DEPLIBS = TtClientDepLibs
LOCAL_LIBRARIES = TtClientLibs
SYS_LIBRARIES =
#ifdef TtClientExtraLibs
EXTRA_LIBRARIES = TtClientExtraLibs
#endif
PROG1 = ttmv
SRCS1 = ttmv.C mover.C
OBJS1 = ttmv.o mover.o
PROG2 = ttrm
SRCS2 = ttrm.C remover.C
OBJS2 = ttrm.o remover.o
PROG3 = ttcp
SRCS3 = ttcp.C copier.C
OBJS3 = ttcp.o copier.o
PROG4 = ttrmdir
SRCS4 = $(SRCS2)
OBJS4 = $(OBJS2)
PROGRAMS = $(PROG1) $(PROG2) $(PROG3) $(PROG4)
NormalCplusplusObjectRule()
ComplexCplusplusProgramTarget_1($(PROG1),$(LOCAL_LIBRARIES),/**/)
ComplexCplusplusProgramTarget_2($(PROG2),$(LOCAL_LIBRARIES),/**/)
ComplexCplusplusProgramTarget_3($(PROG3),$(LOCAL_LIBRARIES),/**/)
ComplexCplusplusProgramTarget_4($(PROG4),$(LOCAL_LIBRARIES),/**/)
SpecialCplusplusObjectRule(remover,remover,$(TT_VERSION_DEFINE))
SpecialCplusplusObjectRule(mover,mover,$(TT_VERSION_DEFINE))
SpecialCplusplusObjectRule(copier,copier,$(TT_VERSION_DEFINE))

View File

@@ -0,0 +1,11 @@
XCOMM $XConsortium: admindefines /main/2 1996/05/07 19:16:10 drk $
#ifdef sun
/*
* Some tooltalk header files contain inline references to internal
* functions. Attempting to compile with -g fails because these
* inline references expand into unresolved symbols. Until tooltalk
* is fixed force use of -g0. See CDExc20311 for details.
*/
# define DebuggableCplusplusDebugFlags -g0
#endif

View File

@@ -0,0 +1,452 @@
//%% (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.
//%% $XConsortium: copier.C /main/3 1995/10/20 16:35:57 rswiston $
/*
* copier.cc - Link Service/ToolTalk wrapper for cp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include "tt_options.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <errno.h>
#include "api/c/tt_c.h"
#include "util/tt_path.h"
#include "util/tt_gettext.h"
#include "util/copyright.h"
#include "copier.h"
/*
* External variables
*/
extern char *_tt_get_realpath(char *, char *);
/*
* copier::copier()
*/
copier::
copier( char *arg0 )
{
if (arg0 != NULL) {
char *base = strrchr( arg0, '/' );
if (base == NULL) {
base = arg0;
} else {
base++; /* Don't want the '/' */
}
_prog_name = base;
_process_name = _prog_name;
}
_args = new _Tt_string_list();
_from_paths = new _Tt_string_list();
_should_cp = TRUE;
_recurse = FALSE;
_preserve = FALSE;
_clonedir_mode = FALSE;
_tt_opened = FALSE;
}
copier::
~copier()
{
}
/*
* copier::do_cp() - Use system() to invoke cp(1), and return its exit status.
* We can just use _args, since we never get here when our one
* cp-incompatible option (-L) has been given.
*/
int copier::
do_cp()
{
_Tt_string cmd( "cp" );
_Tt_string_list_cursor arg_cursor( _args );
while (arg_cursor.next()) {
cmd = cmd.cat( " " ).cat( *arg_cursor );
}
//printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
if (WIFEXITED(sys_status)) {
return WEXITSTATUS(sys_status);
} else {
fprintf( stderr,
"%s: system(\"%s\"): %d\n",
(char *)_process_name, (char *)cmd, sys_status );
return 1;
}
}
/*
* copier::do_ttcp() - Use tttar(1) to copy the objects of the _from_paths.
*
* Algorithm:
*
* if (_clonedir_mode) {
* cd _from_path; tttar cfhL - . | (cd ../_to_path; tttar xfLp? -)
* } else {
* if (_to_path_is_dir) {
* tttar cfhL - _from_paths | (cd _to_path ; tttar xfLp? - )
* } else {
* tttar cfhL - _from_path | tttar xfLp? - -rename from to
* }
* }
*/
Tt_status copier::
do_ttcp()
{
_Tt_string cmd;
_Tt_string_list_cursor from_path_cursor( _from_paths );
Tt_status err;
if (_clonedir_mode) {
#ifdef DO_TTTAR_AFTER_CP
if (mkdir( (char *)_to_path, S_IRWXU ) != 0) {
return TT_ERR_PATH;
}
#endif
cmd = cmd.cat( "cd " ).cat( _from_paths->top()).cat( " ; ");
}
cmd = cmd.cat( "tttar cfhL -" );
while (from_path_cursor.next()) {
_Tt_string from_path = *from_path_cursor;
if (! this->can_cp( from_path )) {
/*
* Don't tttar any paths we know that cp(1) will
* reject. We do this for clonedir mode, too, so
* we can return if the cloning shouldn't be done.
*/
from_path_cursor.remove();
} else {
/*
* tt_file_destroy() any path that cp(1) will delete
*/
_Tt_string path2zap = _to_path;
if (_to_path_is_dir) {
/*
* cp(1) will overwrite any entry in _to_path
* that has the same name as a _from_path.
*/
_Tt_string dir, base;
base = from_path.rsplit( '/', dir );
path2zap = _to_path.cat( "/" ).cat( base );
}
err = tt_file_destroy( (char *)path2zap );
if (err > TT_WRN_LAST) {
fprintf( stderr,
catgets(_ttcatd, 8, 12,
"%s: Could not remove "
"ToolTalk objects of %s "
"because %s\n"),
(char *)_process_name,
(char *)path2zap,
tt_status_message(err) );
}
}
}
if (_from_paths->count() <= 0) {
return TT_OK;
}
if (_clonedir_mode) {
/*
* In clonedir mode, we just tttar up everything in
* the directory we're cloning.
*/
cmd = cmd.cat( " ." );
} else {
from_path_cursor.reset();
while (from_path_cursor.next()) {
cmd = cmd.cat( " " ).cat( *from_path_cursor );
}
}
cmd = cmd.cat( " |" );
if (_to_path_is_dir) {
cmd = cmd.cat( " ( cd " );
if (_clonedir_mode) {
char realpath_buf[ MAXPATHLEN ];
/*
* If we're in _clonedir_mode, then we'll be
* cd'ing down into _from_path, and so we want
* a realpath of _to_path to cd over to,
* because if _from_path is a symlink then
* in _from_path "../_to_path" is _not_ _to_path.
*/
char *real_to_path = _tt_get_realpath( (char *)_to_path,
realpath_buf );
if (real_to_path == NULL) {
fprintf( stderr, "%s: %s: %s\n",
(char *)_process_name,
(char *)_to_path, strerror(errno) );
return TT_ERR_PATH;
}
cmd = cmd.cat( real_to_path );
} else {
cmd = cmd.cat( _to_path );
}
cmd = cmd.cat( " ;" );
}
cmd = cmd.cat( " tttar xfL" );
if (_preserve) {
cmd = cmd.cat( "p" );
}
cmd = cmd.cat( " -" );
/*
* Use the hack we built into tttar(1) to rename paths
* as they're extracted. Rename each _from_path to _to_path.
*/
from_path_cursor.reset();
while (from_path_cursor.next()) {
_Tt_string from_path = *from_path_cursor;
cmd = cmd.cat( " -rename " ).cat( from_path )
.cat( " " ).cat( _to_path );
/*
* If the copy is to be made in a subdirectory of _to_path,
* make tttar maps _from_path to the appropriate
* subdirectory of _to_path as it extracts.
*/
if ((_to_path_is_dir) && (! _clonedir_mode)) {
_Tt_string dir_name;
cmd = cmd.cat( "/" )
.cat( from_path.rsplit( '/', dir_name ));
}
}
if (_to_path_is_dir) {
cmd = cmd.cat( " )" );
}
//printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
#ifdef DO_TTTAR_AFTER_CP
if (_clonedir_mode) {
/*
* remove the target directory, so that cp(1) won't
* see it and make _from_path a subdirectory of it.
*/
if (rmdir( (char *)_to_path ) != 0) {
fprintf( stderr, "%s: rmdir(\"%s\"): %s\n",
(char *)_process_name, (char *)_to_path,
strerror(errno) );
return TT_ERR_PATH;
}
}
#endif
if (WIFEXITED(sys_status)) {
if (WEXITSTATUS(sys_status) == 0) {
return TT_OK;
} else {
return TT_ERR_INTERNAL;
}
} else {
fprintf( stderr,
"%s: system(\"%s\"): %d\n",
(char *)_process_name, sys_status );
return TT_ERR_INTERNAL;
}
} /* do_ttcp() */
/*
* copier::can_cp() - Can we copy this path to _to_path?
*
* TO_DO: can_cp() can be as tricky as you like.
*/
bool_t copier::
can_cp( _Tt_string from_path )
{
struct stat stat_buf;
if (stat( (char *)from_path, &stat_buf) != 0) {
return FALSE;
}
if (S_ISDIR(stat_buf.st_mode) && (! _recurse)) {
return FALSE;
}
return TRUE;
}
/*
* copier::open_tt()
*/
Tt_status copier::
open_tt()
{
char *process_id = tt_open();
Tt_status err = tt_ptr_error( process_id );
if (err == TT_OK) {
_process_id = process_id;
_tt_opened = TRUE;
} else if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_open(): %s\n",
(char *)_process_name, tt_status_message( err ) );
}
return err;
}
/*
* copier::close_tt()
*/
Tt_status copier::
close_tt()
{
if (! _tt_opened) {
return TT_OK;
}
Tt_status err = tt_close();
if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_close(): %s\n",
(char *)_process_name, tt_status_message( err ) );
}
return err;
}
/*
* copier::parse_args()
*/
void copier::
parse_args( int argc, char **argv )
{
for ( int arg_num = 1; arg_num < argc; arg_num++ ) {
_Tt_string arg( argv[arg_num] );
_args->append( arg );
if (arg[0] == '-') {
this->_parse_arg( (char *)arg );
} else {
if (arg_num == argc - 1) {
_to_path = arg;
} else {
_from_paths->append( arg );
}
}
}
if ((_to_path.len() <= 0) || (_from_paths->count() <= 0)) {
this->usage();
exit(1);
}
if (_from_paths->count() > 1) {
/*
* If multiple things to move, the place we're moving them to
* must be a directory.
*/
struct stat stat_buf;
if (stat( (char *)_to_path, &stat_buf) != 0) {
fprintf( stderr, "%s: %s: ", (char *)_process_name,
(char *)_to_path );
perror(NULL);
exit(2);
}
if (! S_ISDIR(stat_buf.st_mode)) {
fprintf( stderr, "%s: %s: %s\n",
(char *)_process_name, (char *)_to_path,
strerror(ENOTDIR) );
this->usage();
exit(2);
}
_to_path_is_dir = TRUE;
} else {
struct stat stat_buf;
_to_path_is_dir = FALSE;
if (stat( (char *)_to_path, &stat_buf) == 0) {
_to_path_is_dir = S_ISDIR(stat_buf.st_mode);
} else {
/*
* If you "cp -r dir1 dir2" and dir2 doesn't
* exist, cp(1) creates it and copies dir1's
* contents into it. What we need to do in this
* case is to
* 1. mkdir( dir2 ), [so we can cd there]
* 2. (cd dir1; tttar cf - .) | (cd dir2; tttar xf -)
* 3. rmdir( dir2 ) [so cp(1) will do right thing]
*/
_Tt_string from_path = _from_paths->top();
if ( (_from_paths->count() == 1)
&& (stat( (char *)from_path, &stat_buf) == 0)
&& S_ISDIR(stat_buf.st_mode))
{
_clonedir_mode = TRUE;
_to_path_is_dir = TRUE;
}
}
}
} /* parse_args() */
/*
* copier::_parse_arg() - Parse an option
*
* If you add any options not supported by cp(1) and still expect
* it to be system()'d, fix ::do_cp() to pass cp(1) the right args.
*/
void copier::
_parse_arg( char *arg )
{
if (arg == NULL) {
return;
}
int n = -1;
while (arg[++n] != '\0') {
switch (arg[n]) {
case '-':
if (n != 0) {
this->usage();
exit(1);
}
break;
case 'i':
this->usage();
exit(1);
break;
case 'L':
_should_cp = FALSE;
break;
case 'p':
_preserve = TRUE;
break;
case 'r':
case 'R':
_recurse = TRUE;
break;
case 'v':
_TT_PRINT_VERSIONS((char *)_prog_name)
exit(0);
break;
case 'h':
default:
this->usage();
exit(1);
}
}
} /* _parse_arg() */
/*
* copier::usage()
*/
void copier::
usage(FILE *fs) const
{
fprintf( fs,
catgets(_ttcatd, 8, 13,
"Usage: %s [-pL] file1 file2\n"
" %s [-prRL] path1 [path2 ...] dir\n"
" %s -v\n"
" %s -h\n"),
(char *)_prog_name, (char *)_prog_name, (char *)_prog_name,
(char *)_prog_name );
fprintf( fs,
catgets(_ttcatd, 8, 14,
"\t-L do not perform a cp(1)\n"
"\t-v print the version number and quit\n"
"\t-h print this message\n" ));
}

View File

@@ -0,0 +1,51 @@
/*%% (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. */
/*%% $XConsortium: copier.h /main/3 1995/10/20 16:36:05 rswiston $ */
/*
* copier.h - Interface to copier, an LS/TT-aware cp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#ifndef _COPIER_H
#define _COPIER_H
#include <api/c/tt_c.h>
#include <util/tt_string.h>
class copier : public _Tt_object {
public:
copier( char *arg0 );
virtual ~copier();
int do_cp();
Tt_status do_ttcp();
bool_t can_cp( _Tt_string from_path );
Tt_status open_tt();
Tt_status close_tt();
void parse_args( int argc, char **argv );
void usage( FILE *fs = stderr ) const;
bool_t should_cp() { return _should_cp; }
bool_t tt_opened() { return _tt_opened; }
private:
void _parse_arg( char *arg );
_Tt_string _process_name;
_Tt_string _prog_name;
_Tt_string _process_id;
_Tt_string_list_ptr _args;
bool_t _should_cp;
bool_t _recurse;
bool_t _preserve;
bool_t _tt_opened;
_Tt_string_list_ptr _from_paths;
_Tt_string _to_path;
bool_t _to_path_is_dir;
bool_t _clonedir_mode; /* see parse_args() */
};
#endif /* _COPIER_H */

View File

@@ -0,0 +1,368 @@
//%% (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.
//%% $XConsortium: mover.C /main/4 1995/10/20 16:36:15 rswiston $
/*
* mover.cc - Link Service/ToolTalk wrapper for mv(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include "tt_options.h"
#include <errno.h>
#include <string.h>
#ifdef __osf__
#include <unistd.h>
#else
#if !defined(USL) && !defined(__uxp__)
#include <osfcn.h>
#endif
#endif
#include <stdlib.h>
#include <errno.h>
#if defined(ultrix)
#include <sys/inode.h>
#define S_ISLNK(m) (((m)&IFMT) == IFLNK)
#endif
#include <sys/stat.h>
#if defined(OPT_BUG_USL) || defined(OPT_BUG_UXP)
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#endif
#include <sys/wait.h>
#include "api/c/tt_c.h"
#include "util/tt_gettext.h"
#include "util/copyright.h"
#include "mover.h"
/*
* External variables
*/
/*
* mover::mover()
*/
mover::
mover( char *arg0 )
{
if (arg0 != NULL) {
char *base = strrchr( arg0, '/' );
if (base == NULL) {
base = arg0;
} else {
base++; // Don't want the '/'
}
_prog_name = base;
_process_name = _prog_name;
}
_args = new _Tt_string_list();
_from_paths = new _Tt_string_list();
_should_mv = TRUE;
_force = FALSE;
_tt_opened = FALSE;
}
mover::
~mover()
{
}
/*
* mover::do_mv() - Use system() to invoke mv(1), and return its exit status.
* We can just use _args, since we never get here when our one
* mv-incompatible option (-L) has been given.
*/
int mover::
do_mv()
{
_Tt_string cmd( "mv" );
_Tt_string_list_cursor arg_cursor( _args );
while (arg_cursor.next()) {
cmd = cmd.cat( " " ).cat( *arg_cursor );
}
//printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
if (WIFEXITED(sys_status)) {
return WEXITSTATUS(sys_status);
} else {
if (! _force) {
fprintf(stderr, "%s: system(\"%s\"): %d\n",
(char *)_process_name, (char *)cmd, sys_status);
}
return 1;
}
}
/*
* mover::do_ttmv() - Use tt_file_move() on the things to move.
*/
Tt_status mover::
do_ttmv()
{
Tt_status worst_err = TT_OK;
Tt_status err;
_Tt_string full_to_path;
bool_t abort = FALSE;
bool_t are_more;
full_to_path = _to_path;
_Tt_string_list_cursor from_path_cursor( _from_paths );
/*
* call to next() must be first, so that are_more will be valid
* if we abort. Why does the next() method wrap around?
*/
while ((are_more = from_path_cursor.next()) && (! abort)) {
if (! this->can_mv( *from_path_cursor )) {
continue;
}
/*
* tt_file_destroy() any path that mv(1) will delete
*/
if (_to_path_is_dir) {
full_to_path = _to_path.cat("/").
cat(*from_path_cursor);
}
/*
* mv(1) will overwrite any entry in _to_path that
* has the same name as a _from_path.
*/
err = tt_file_destroy( (char *)full_to_path );
if ((err > TT_WRN_LAST) && (! _force)) {
fprintf( stderr,
catgets(_ttcatd, 8, 2,
"%s: Could not remove "
"ToolTalk objects of %s "
"because %s\n"),
(char *)_process_name,
(char *)full_to_path,
tt_status_message(err) );
}
err = tt_file_move( (char *)*from_path_cursor,
(char *)full_to_path );
if (err > TT_WRN_LAST) {
worst_err = err;
if (! _force) {
fprintf( stderr,
catgets(_ttcatd, 8, 3,
"%s: Could not move ToolTalk "
"objects of \"%s\" to \"%s\" "
"because %s\n"),
(char *)_process_name,
(char *)*from_path_cursor,
(char *)full_to_path,
tt_status_message( err ));
}
switch (err) {
case TT_ERR_DBAVAIL:
case TT_ERR_PATH:
break;
case TT_ERR_NOMP:
case TT_ERR_DBEXIST:
default:
abort = TRUE;
break;
}
}
}
if (are_more && (! _force)) {
from_path_cursor.prev();
fprintf( stderr,
catgets(_ttcatd, 8, 4,
"%s: Will not attempt to move the ToolTalk "
"objects of:\n"),
(char *)_process_name );
while (from_path_cursor.next()) {
fprintf( stderr, "\t%s\n", (char *)*from_path_cursor );
}
}
/*
* TO_DO: This should be uncommented if you think that warning them
* about hygiene is more important than obeying the -f flag.
*
if ((worst_err > TT_WRN_LAST) && _should_mv && _force) {
fprintf( stderr, "%s: The ToolTalk objects of some files were "
"not moved.\nSince you've told us to move the files "
"anyway, you will need to\nuse %s -L to move "
"the ToolTalk objects of the problem files.\n",
(char *)_process_name, (char *)_prog_name );
}
*/
return worst_err;
} /* do_ttmv() */
/*
* mover::can_mv() - Can we move this path to _to_path?
*
* TO_DO: Judging by mv.c, can_mv() can be as tricky as you like.
* I'll count on tt_file_move() to Do The Right Thing.
*/
bool_t mover::
can_mv( _Tt_string from_path )
{
struct stat lstat_buf;
if (lstat( (char *)from_path, &lstat_buf) == 0) {
if (S_ISLNK(lstat_buf.st_mode)) {
/*
* Don't tt_file_move() a symlink, or TT will
* tt_file_move() the linked file.
*/
return FALSE;
} else {
return TRUE;
}
} else {
/*
* If we're trying to mv a file that doesn't exist,
* let's not tt_file_move() the associated pathname.
* But if we're trying to ttmv -L a file that doesn't
* exist, we should probably tt_file_move() it anyway.
*/
if (_should_mv) {
return FALSE;
} else {
return TRUE;
}
}
}
/*
* mover::open_tt()
*/
Tt_status mover::
open_tt()
{
char *process_id = tt_open();
Tt_status err = tt_ptr_error( process_id );
if (err == TT_OK) {
_process_id = process_id;
_tt_opened = TRUE;
} else if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_open(): %s\n",
(char *)_process_name, tt_status_message(err) );
}
return err;
}
/*
* mover::close_tt()
*/
Tt_status mover::
close_tt()
{
if (! _tt_opened) {
return TT_OK;
}
Tt_status err = tt_close();
if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_close(): %s\n",
(char *)_process_name, tt_status_message(err) );
}
return err;
}
/*
* mover::parse_args()
*/
void mover::
parse_args( int argc, char **argv )
{
bool_t no_more_options = FALSE;
for ( int arg_num = 1; arg_num < argc; arg_num++ ) {
_Tt_string arg( argv[arg_num] );
_args->append( arg );
if ((arg[0] == '-') && (! no_more_options)) {
if (arg[1] == '\0') {
/*
* The bare option "-" means take the
* subsequent arguments to be pathnames.
*/
no_more_options = TRUE;
} else {
for (int n = 1; n < arg.len(); n++) {
switch (arg[n]) {
case 'f':
_force = TRUE;
break;
case 'L':
_should_mv = FALSE;
break;
case 'v':
_TT_PRINT_VERSIONS((char *)_prog_name)
exit(0);
break;
case 'h':
default:
this->usage();
exit(1);
}
}
}
} else {
if (arg_num == argc - 1) {
_to_path = arg;
} else {
_from_paths->append( arg );
}
}
}
if ((_to_path.len() <= 0) || (_from_paths->count() <= 0)) {
this->usage();
exit(1);
}
if (_from_paths->count() > 1) {
/*
* If multiple things to move, the place we're moving them to
* must be a directory.
*/
struct stat stat_buf;
if (stat( (char *)_to_path, &stat_buf) != 0) {
fprintf( stderr, "%s: \"%s\": ", (char *)_process_name,
(char *)_to_path );
perror(NULL);
exit(2);
}
if (! S_ISDIR(stat_buf.st_mode)) {
fprintf( stderr, "%s: \"%s\": %s\n",
(char *)_process_name, (char *)_to_path,
strerror(ENOTDIR) );
this->usage();
exit(2);
}
_to_path_is_dir = TRUE;
} else {
struct stat stat_buf;
_to_path_is_dir = FALSE;
if (stat( (char *)_to_path, &stat_buf) == 0) {
_to_path_is_dir = S_ISDIR(stat_buf.st_mode);
}
}
}
/*
* mover::usage()
*/
void mover::
usage(FILE *fs) const
{
fprintf( fs,
catgets(_ttcatd, 8, 5,
"Usage: %s [-] [-fL] path1 path2\n"
" %s [-] [-fL] path1 [path2 ...] dir\n"
" %s -v\n"
" %s -h\n"),
(char *)_prog_name, (char *)_prog_name, (char *)_prog_name,
(char *)_prog_name );
fprintf( fs,
catgets(_ttcatd, 8, 6,
"\t-L do not perform a mv(1)\n"
"\t-v print the version number and quit\n"
"\t-h print this message\n" ));
}

View File

@@ -0,0 +1,48 @@
/*%% (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. */
/*%% $XConsortium: mover.h /main/3 1995/10/20 16:36:24 rswiston $ */
/*
* mover.h - Interface to mover, an LS/TT-aware mv(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#ifndef _MOVER_H
#define _MOVER_H
#include <api/c/tt_c.h>
#include <util/tt_string.h>
class mover : public _Tt_object {
public:
mover( char *arg0 );
virtual ~mover();
int do_mv();
Tt_status do_ttmv();
bool_t can_mv( _Tt_string from_path );
Tt_status open_tt();
Tt_status close_tt();
void parse_args( int argc, char **argv );
void usage( FILE *fs = stderr ) const;
bool_t should_mv() { return _should_mv; }
bool_t force() { return _force; }
bool_t tt_opened() { return _tt_opened; }
private:
_Tt_string _process_name;
_Tt_string _prog_name;
_Tt_string _process_id;
_Tt_string_list_ptr _args;
bool_t _should_mv;
bool_t _force;
bool_t _tt_opened;
_Tt_string_list_ptr _from_paths;
_Tt_string _to_path;
bool_t _to_path_is_dir;
};
#endif /* _MOVER_H */

View File

@@ -0,0 +1,371 @@
//%% (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.
//%% $XConsortium: rcopier.C /main/3 1995/10/20 16:36:32 rswiston $
/*
* rcopier.cc - Link Service/ToolTalk wrapper for rcp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include "tt_options.h"
#include <string.h>
#ifdef __osf__
#include <unistd.h>
#else
#ifndef USL
#include <osfcn.h>
#endif
#endif
#if defined(OPT_BUG_SUNOS_4)
# include <stdlib.h>
#endif
#include <api/c/tt_c.h>
#include <util/tt_path.h>
#include <util/tt_enumname.h>
#include <util/copyright.h>
#include "rcopier.h"
/*
* External variables
*/
implement_list_of(rpath)
/*
* rpath::rpath()
*/
rpath::
rpath()
{
}
/*
* rpath::~rpath()
*/
rpath::
~rpath()
{
}
/*
* rpath::rpath()
*/
rpath::
rpath( _Tt_string)
{
/*
* host:path
* user@host:path
*/
}
/*
* rcopier::rcopier()
*/
rcopier::
rcopier( char *arg0 )
{
if (arg0 != NULL) {
char *base = strrchr( arg0, '/' );
if (base == NULL) {
base = arg0;
} else {
base++; /* Don't want the '/' */
}
_prog_name = base;
_process_name = _prog_name;
}
_args = new _Tt_string_list();
_from_paths = new rpath_list();
_should_rcp = TRUE;
_recurse = FALSE;
_preserve = FALSE;
_tt_opened = FALSE;
}
rcopier::
~rcopier()
{
}
/*
* rcopier::do_rcp() - Use system() to invoke rcp(1), and return its exit status.
* We can just use _args, since we never get here when our one
* rcp-incompatible option (-L) has been given.
*/
int rcopier::
do_rcp()
{
_Tt_string cmd( "rcp" );
_Tt_string_list_cursor arg_cursor( _args );
while (arg_cursor.next()) {
cmd = cmd.cat( " " ).cat( *arg_cursor );
}
printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
if (WIFEXITED(sys_status)) {
return WEXITSTATUS(sys_status);
} else {
fprintf( stderr,
"%s: I invoked rcp(1), but system() returned "
"%d, which is not an exit status!\n",
(char *)_process_name, sys_status );
return 1;
}
}
/*
* rcopier::do_ttrcp() - Use tttar(1) to copy the objects of the _from_paths.
*
* Algorithm:
*
* [rsh fromhost -l user] tttar cfhL - frompath |
* [rsh tohost -l user] tttar xfL - -rename frompath topath
*
* TO_DO: this won't work if topath is a directory. If it's a
* remote directory, how do we find this out?
* }
*/
Tt_status rcopier::
do_ttrcp()
{
rpath_list_cursor from_path_cursor( _from_paths );
/*
* TO_DO: tt_file_destroy() any paths that rcp(1) will delete
*/
while (from_path_cursor.next()) {
_Tt_string cmd;
rpath_ptr rp = *from_path_cursor;
if (rp->host().len() >= 0) {
cmd = cmd.cat( "rsh ").cat( rp->host()).cat( " -l ")
.cat( _username ).cat( " " );
}
cmd = cmd.cat( "tttar cfhL - " ).cat( rp->path()).cat(" | ");
if (_to_path->host().len() >= 0) {
cmd = cmd.cat( "rsh ").cat( _to_path->host())
.cat( " -l ").cat( _username ).cat( " " );
}
cmd = cmd.cat( "tttar xfL" );
if (_preserve) {
cmd = cmd.cat( "p" );
}
cmd = cmd.cat( " - -rename " ).cat( rp->path())
.cat( _to_path->path());
printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
if (WIFEXITED(sys_status)) {
if (WEXITSTATUS(sys_status) != 0) {
return TT_ERR_INTERNAL;
}
} else {
fprintf( stderr,
"%s: invoked tttar(1), but system() returned "
"%d, which is not an exit status!\n",
(char *)_process_name, sys_status );
return TT_ERR_INTERNAL;
}
}
return TT_OK;
} /* do_ttrcp() */
/*
* rcopier::open_tt()
*/
Tt_status rcopier::
open_tt()
{
char *process_id = tt_open();
Tt_status err = tt_ptr_error( process_id );
if (err == TT_OK) {
_process_id = process_id;
_tt_opened = TRUE;
} else if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: Could not initialize ToolTalk because %s\n",
(char *)_process_name,
#ifndef TT_STATUS_MSG_TO_DO
_tt_enumname( (Tt_status)err )
#else
tt_status_message( err )
#endif
);
}
return err;
}
/*
* rcopier::close_tt()
*/
Tt_status rcopier::
close_tt()
{
if (! _tt_opened) {
return TT_OK;
}
Tt_status err = tt_close();
if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: Could not close ToolTalk because %s\n",
(char *)_process_name,
#ifndef TT_STATUS_MSG_TO_DO
_tt_enumname( (Tt_status)err )
#else
tt_status_message( err )
#endif
);
}
return err;
}
/*
* rcopier::parse_args()
*/
void rcopier::
parse_args( int argc, char **argv )
{
for ( int arg_num = 1; arg_num < argc; arg_num++ ) {
_Tt_string arg( argv[arg_num] );
_args->append( arg );
if (arg[0] == '-') {
this->_parse_arg( (char *)arg );
} else {
if (arg_num == argc - 1) {
_to_path = new rpath( arg );
} else {
rpath_ptr rp = new rpath( arg );
_from_paths->append( rp );
}
}
}
if (_to_path->path().len() <= 0) {
this->usage();
exit(1);
}
if (_from_paths->count() <= 0) {
this->usage();
exit(1);
}
if (_from_paths->count() > 1) {
/*
* If multiple things to move, the place we're
* moving them to must be a directory.
*/
if (_to_path->host().len() <= 0) {
/*
* to_path is local. Yay!
*/
struct stat stat_buf;
if (stat( (char *)_to_path->path(), &stat_buf) != 0) {
fprintf( stderr, "%s: %s: ",
(char *)_process_name,
(char *)_to_path->path() );
perror(NULL);
exit(2);
}
if (! S_ISDIR(stat_buf.st_mode)) {
fprintf( stderr, "%s: %s is not a directory\n",
(char *)_process_name,
(char *)_to_path->path() );
this->usage();
exit(2);
}
_to_path_is_dir = TRUE;
} else {
/*
* TO_DO: figure out if remote path is dir or not
*/
}
} else {
if (_to_path->host().len() <= 0) {
struct stat stat_buf;
_to_path_is_dir = FALSE;
if (stat( (char *)_to_path->path(), &stat_buf) == 0) {
_to_path_is_dir = S_ISDIR(stat_buf.st_mode);
}
/*
* I don't think rcp has a clonedir mode. (see ttcp)
else {
_Tt_string from_path = _from_paths->top();
if ( (_from_paths->count() == 1)
&& (stat( (char *)from_path, &stat_buf) == 0)
&& S_ISDIR(stat_buf.st_mode))
{
_clonedir_mode = TRUE;
_to_path_is_dir = TRUE;
}
}
*/
} else {
/*
* TO_DO: figure out if remote path is dir or not
*/
}
}
} /* parse_args() */
/*
* rcopier::_parse_arg() - Parse an option
*/
void rcopier::
_parse_arg( char *arg )
{
if (arg == NULL) {
return;
}
int n = -1;
while (arg[++n] != '\0') {
switch (arg[n]) {
case '-':
if (n != 0) {
this->usage();
exit(1);
}
break;
case 'L':
_should_rcp = FALSE;
break;
case 'p':
_preserve = TRUE;
break;
case 'r':
_recurse = TRUE;
break;
case 'v':
_TT_PRINT_VERSIONS((char *)_prog_name)
exit(0);
break;
case 'h':
default:
this->usage();
exit(1);
}
}
} /* _parse_arg() */
/*
* rcopier::usage()
*/
void rcopier::
usage(FILE *fs) const
{
fprintf( fs,
"Usage: %s [-pL] file1 file2\n"
" %s [-prL] path1 [path2 ...] dir\n"
" %s -v\n"
" %s -h\n",
(char *)_prog_name, (char *)_prog_name, (char *)_prog_name,
(char *)_prog_name );
fprintf( fs, "\t-L do not perform a rcp(1)\n" );
fprintf( fs, "\t-v print the version number and quit\n" );
fprintf( fs, "\t-h[elp] print this message\n" );
}

View File

@@ -0,0 +1,65 @@
/*%% (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. */
/*%% $XConsortium: rcopier.h /main/3 1995/10/20 16:36:39 rswiston $ */
/*
* rcopier.h - Interface to rcopier, an LS/TT-aware rcp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#ifndef _RCOPIER_H
#define _RCOPIER_H
#include <api/c/tt_c.h>
#include <util/tt_string.h>
class rpath : public _Tt_object {
public:
rpath();
rpath( _Tt_string r_path );
virtual ~rpath();
_Tt_string host() { return _host; }
_Tt_string path() { return _path; }
private:
_Tt_string _host;
_Tt_string _path;
};
declare_list_of(rpath)
class rcopier : public _Tt_object {
public:
rcopier( char *arg0 );
virtual ~rcopier();
int do_rcp();
Tt_status do_ttrcp();
Tt_status open_tt();
Tt_status close_tt();
void parse_args( int argc, char **argv );
void usage( FILE *fs = stderr ) const;
bool_t should_rcp() { return _should_rcp; }
bool_t tt_opened() { return _tt_opened; }
private:
void _parse_arg( char *arg );
_Tt_string _process_name;
_Tt_string _prog_name;
_Tt_string _process_id;
_Tt_string_list_ptr _args;
bool_t _should_rcp;
bool_t _tt_opened;
_Tt_string _username;
bool_t _preserve;
bool_t _recurse;
rpath_list_ptr _from_paths;
rpath_ptr _to_path;
bool_t _to_path_is_dir;
};
#endif /* _RCOPIER_H */

View File

@@ -0,0 +1,376 @@
//%% (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.
//%% $TOG: remover.C /main/5 1999/10/14 18:37:42 mgreess $
/*
* remover.cc - ToolTalk wrapper for rm(1) and rmdir(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include "tt_options.h"
#include <errno.h>
#include <string.h>
#ifdef __osf__
#include <unistd.h>
#else
#if !defined(USL) && !defined(__uxp__)
#include <osfcn.h>
#endif
#endif
#include <stdlib.h>
#include <errno.h>
#if defined(ultrix)
#include <sys/inode.h>
#define S_ISLNK(m) (((m)&IFMT) == IFLNK)
#endif
#include <sys/stat.h>
#if defined(OPT_BUG_USL) || defined(OPT_BUG_UXP)
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#endif
#include <sys/wait.h>
#include "api/c/tt_c.h"
#include "util/tt_path.h"
#include "util/tt_gettext.h"
#include "util/copyright.h"
#include "remover.h"
/*
* External variables
*/
/*
* remover::remover()
*/
remover::
remover( char *arg0 )
{
if (arg0 != NULL) {
char *base = strrchr( arg0, '/' );
if (base == NULL) {
base = arg0;
} else {
base++;
}
_prog_name = base;
_process_name = _prog_name;
}
_am_rmdir = (_prog_name == "ttrmdir");
_args = new _Tt_string_list();
_paths = new _Tt_string_list();
_should_rm = TRUE;
_force = FALSE;
_recurse = FALSE;
_tt_opened = FALSE;
}
remover::
~remover()
{
}
/*
* remover::do_rm() - Invoke rm[dir](1), and return its exit status.
* We can just use _args, since we never get here when our one
* incompatible option (-L) has been given.
*/
int remover::
do_rm()
{
_Tt_string cmd;
_Tt_string_list_cursor arg_cursor( _args );
if (_am_rmdir) {
cmd = "rmdir";
} else {
cmd = "rm";
}
while (arg_cursor.next()) {
cmd = cmd.cat( " " ).cat( *arg_cursor );
}
//printf( "Invoking: %s\n", (char *)cmd );
int sys_status = system( (char *)cmd );
if (WIFEXITED(sys_status)) {
return WEXITSTATUS(sys_status);
} else {
fprintf( stderr,
"%s: system(\"%s\"): %d\n",
(char *)_process_name, (char *)cmd, sys_status );
return 1;
}
}
/*
* remover::do_ttrm() - Use tt_file_destroy() on the paths to destroy.
*/
Tt_status remover::
do_ttrm()
{
return this->_ttrm_paths( _paths );
}
/*
* remover::ttrm_path() - tt_file_destroy() this path.
*/
Tt_status remover::
_ttrm_paths( _Tt_string_list_ptr paths )
{
Tt_status worst_err = TT_OK;
Tt_status err;
bool_t abort = FALSE;
while ((! paths->is_empty()) && (! abort)) {
_Tt_string path = paths->top();
_Tt_string_list_ptr children;
paths->pop();
if (! this->can_rm( path )) {
continue;
}
if (_recurse) {
_Tt_string_list_ptr children = _tt_dir_entries(path,
FALSE);
err = this->_ttrm_paths( children );
if (err > TT_WRN_LAST) {
switch (err) {
case TT_ERR_DBAVAIL:
case TT_ERR_PATH:
break;
case TT_ERR_NOMP:
case TT_ERR_DBEXIST:
default:
abort = TRUE;
break;
}
}
}
if (! abort) {
err = tt_file_destroy( (char *)path );
if (err > TT_WRN_LAST) {
worst_err = err;
if (! _force) {
fprintf( stderr,
catgets(_ttcatd, 8, 7,
"%s: Could not remove "
"ToolTalk objects of "
"%s because %s\n"),
(char *)_process_name,
(char *)path,
tt_status_message(err) );
}
switch (err) {
case TT_ERR_DBAVAIL:
case TT_ERR_PATH:
break;
case TT_ERR_NOMP:
case TT_ERR_DBEXIST:
default:
abort = TRUE;
break;
}
}
}
}
return worst_err;
} /* ttrm_paths() */
/*
* remover::can_rm() - Can we remove this path?
*
* TO_DO: For now I'll count on tt_file_destroy() not to let me
* destroy the specs in files I can't remove.
*/
bool_t remover::
can_rm( _Tt_string path )
{
if (_am_rmdir) {
} else {
if (! _recurse) {
struct stat lstat_buf;
if (lstat( (char *)path, &lstat_buf) == 0) {
if (S_ISDIR(lstat_buf.st_mode)) {
/*
* rm(1) without the -r flag
* won't remove directories,
* but tt_file_destroy() will,
* so we make sure not to ask
* it to.
*/
if (! _force) {
fprintf( stderr, "%s: %s: %s\n",
(char *)_prog_name,
(char *)path,
strerror(EISDIR) );
}
return FALSE;
} else if (S_ISLNK(lstat_buf.st_mode)) {
/*
* Don't tt_file_destroy() a symlink,
* or TT will tt_file_destroy() the
* linked file.
*/
return FALSE;
} else {
return TRUE;
}
} else {
return FALSE;
}
}
}
return FALSE;
}
/*
* remover::open_tt()
*/
Tt_status remover::
open_tt()
{
char *process_id = tt_open();
Tt_status err = tt_ptr_error( process_id );
if (err == TT_OK) {
_process_id = process_id;
_tt_opened = TRUE;
} else if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_open(): %s\n",
(char *)_process_name, tt_status_message(err) );
}
return err;
}
/*
* remover::close_tt()
*/
Tt_status remover::
close_tt()
{
if (! _tt_opened) {
return TT_OK;
}
Tt_status err = tt_close();
if (err > TT_WRN_LAST) {
fprintf( stderr,
"%s: tt_close(): %s\n",
(char *)_process_name, tt_status_message(err) );
}
return err;
}
/*
* remover::parse_args()
*/
void remover::
parse_args( int argc, char **argv )
{
bool_t no_more_options = FALSE;
for ( int arg_num = 1; arg_num < argc; arg_num++ ) {
_Tt_string arg( argv[arg_num] );
_args->append( arg );
if (_am_rmdir) {
if (arg[0] == '-') {
this->_parse_arg( (char *)arg );
} else {
_paths->append( arg );
}
} else {
if ((arg[0] != '-') || no_more_options) {
_paths->append( arg );
} else {
if (arg[1] == '\0') {
/*
* The bare option "-" means take the
* subsequent arguments to be paths.
*/
no_more_options = TRUE;
} else {
this->_parse_arg( (char *)arg );
}
}
}
}
if (_paths->count() <= 0) {
this->usage();
exit(1);
}
}
/*
* remover::_parse_arg() - Parse an option
*/
void remover::
_parse_arg( char *arg )
{
if (arg == NULL) {
return;
}
int n = -1;
while (arg[++n] != '\0') {
switch (arg[n]) {
case '-':
if (n != 0) {
this->usage();
exit(1);
}
break;
case 'f':
if (_am_rmdir) {
this->usage();
exit(1);
} else {
_force = TRUE;
}
break;
case 'r':
case 'R':
if (_am_rmdir) {
this->usage();
exit(1);
} else {
_recurse = TRUE;
}
break;
case 'L':
_should_rm = FALSE;
break;
case 'v':
_TT_PRINT_VERSIONS((char *)_prog_name)
exit(0);
break;
case 'h':
default:
this->usage();
exit(1);
}
}
}
/*
* remover::usage()
*/
void remover::
usage(FILE *fs) const
{
fprintf( fs,
catgets(_ttcatd, 8, 8,
"Usage: %s [-] [-%s] %s ...\n"
" %s -v\n"
" %s -h\n"),
(char *)_prog_name,
(_am_rmdir ? "L" : "fLrR"),
(_am_rmdir ? catgets(_ttcatd, 8, 9, "file")
: catgets(_ttcatd, 8, 10, "dir") ),
(char *)_prog_name, (char *)_prog_name );
fprintf( fs,
catgets(_ttcatd, 8, 11,
"\t-L do not perform a %s(1)\n"
"\t-v print the version number and quit\n"
"\t-h[elp] print this message\n" ),
(_am_rmdir ? "rmdir" : "rm"));
}

View File

@@ -0,0 +1,51 @@
/*%% (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. */
/*%% $XConsortium: remover.h /main/3 1995/10/20 16:36:57 rswiston $ */
/*
* remover.h - Interface to remover, an LS/TT-aware rm(1) and rmdir(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#ifndef _REMOVER_H
#define _REMOVER_H
#include <api/c/tt_c.h>
#include <util/tt_string.h>
class remover : public _Tt_object {
public:
remover( char *arg0 );
virtual ~remover();
int do_rm();
Tt_status do_ttrm();
bool_t can_rm( _Tt_string path );
Tt_status open_tt();
Tt_status close_tt();
void parse_args( int argc, char **argv );
void usage( FILE *fs = stderr ) const;
bool_t should_rm() { return _should_rm; }
bool_t force() { return _force; }
bool_t tt_opened() { return _tt_opened; }
private:
Tt_status _ttrm_paths( _Tt_string_list_ptr paths );
void _parse_arg( char *arg );
_Tt_string _process_name;
_Tt_string _prog_name;
_Tt_string _process_id;
_Tt_string_list_ptr _args;
bool_t _should_rm;
bool_t _force;
bool_t _recurse;
bool_t _am_rmdir;
bool_t _tt_opened;
_Tt_string_list_ptr _paths;
};
#endif /* _REMOVER_H */

View File

@@ -0,0 +1,56 @@
//%% (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.
//%% $XConsortium: ttcp.C /main/3 1995/10/20 16:37:11 rswiston $
/* @(#)ttcp.C 1.12 93/07/30
* ttcp.cc - Link Service/ToolTalk wrapper for cp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include <stdlib.h>
#include <locale.h>
#include <util/copyright.h>
#include <tt_options.h>
#include "copier.h"
TT_INSERT_COPYRIGHT
#ifdef OPT_PATCH
static char PatchID[] = "Patch Id: 100626_03.";
static int Patch_ID100626_03;
#endif
/*
* main()
*/
int
main(int argc, char **argv)
{
Tt_status tterr = TT_OK;
copier *ttcp = new copier( argv[0] );
setlocale( LC_ALL, "" );
ttcp->parse_args( argc, argv );
if (ttcp->should_cp()) {
int err = ttcp->do_cp();
if (err != 0) {
exit( err );
}
}
tterr = ttcp->open_tt();
if (ttcp->tt_opened()) {
tterr = ttcp->do_ttcp();
}
(void)ttcp->close_tt();
if (tterr > TT_WRN_LAST) {
exit(1);
} else {
exit(0);
}
}

View File

@@ -0,0 +1,62 @@
//%% (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.
//%% $XConsortium: ttmv.C /main/3 1995/10/20 16:37:18 rswiston $
/* @(#)ttmv.C 1.13 93/07/30
* ttmv.cc - Link Service/ToolTalk wrapper for mv(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include <stdlib.h>
#include <locale.h>
#include <util/copyright.h>
#include "mover.h"
TT_INSERT_COPYRIGHT
#ifdef OPT_PATCH
static char PatchID[] = "Patch Id: 100626_03.";
static int Patch_ID100626_03;
#endif
/*
* main()
*/
int
main(int argc, char **argv)
{
Tt_status tterr = TT_OK;
mover *ttmv = new mover( argv[0] );
setlocale( LC_ALL , "" );
ttmv->parse_args( argc, argv );
tterr = ttmv->open_tt();
if (ttmv->tt_opened()) {
tterr = ttmv->do_ttmv();
}
if ( ttmv->should_mv()
/*
* I take the -f option pretty seriously, so I'll move
* the actual files even though the ttmv failed.
*/
&& ((tterr <= TT_WRN_LAST) || ttmv->force()))
{
int err = ttmv->do_mv();
if (err != 0) {
(void)ttmv->close_tt();
exit( err );
}
}
(void)ttmv->close_tt();
if ((tterr > TT_WRN_LAST) && (! ttmv->force())) {
exit(1);
}
return(0);
}

View File

@@ -0,0 +1,50 @@
//%% (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.
//%% $XConsortium: ttrcp.C /main/3 1995/10/20 16:37:27 rswiston $
/*
* ttrcp.cc - Link Service/ToolTalk wrapper for rcp(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include <stdlib.h>
#include <locale.h>
#include <util/copyright.h>
#include "rcopier.h"
TT_INSERT_COPYRIGHT
/*
* main()
*/
void
main(int argc, char **argv)
{
Tt_status tterr = TT_OK;
rcopier *ttrcp = new rcopier( argv[0] );
setlocale( LC_ALL, "" );
ttrcp->parse_args( argc, argv );
if (ttrcp->should_rcp()) {
int err = ttrcp->do_rcp();
if (err != 0) {
exit( err );
}
}
tterr = ttrcp->open_tt();
if (ttrcp->tt_opened()) {
tterr = ttrcp->do_ttrcp();
}
(void)ttrcp->close_tt();
if (tterr > TT_WRN_LAST) {
exit(1);
} else {
exit(0);
}
}

View File

@@ -0,0 +1,63 @@
//%% (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.
//%% $XConsortium: ttrm.C /main/3 1995/10/20 16:37:34 rswiston $
/* @(#)ttrm.C 1.12 93/07/30
* ttrm.cc - Link Service/ToolTalk wrapper for rm(1).
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
*/
#include <stdlib.h>
#include <locale.h>
#include <util/copyright.h>
#include <tt_options.h>
#include "remover.h"
/*
* External variables
*/
TT_INSERT_COPYRIGHT
#ifdef OPT_PATCH
static char PatchID[] = "Patch Id: 100626_03.";
static int Patch_ID100626_03;
#endif
/*
* main()
*/
int
main(int argc, char **argv)
{
Tt_status tterr = TT_OK;
remover *ttrm = new remover( argv[0] );
setlocale( LC_ALL, "" );
ttrm->parse_args( argc, argv );
tterr = ttrm->open_tt();
if (ttrm->tt_opened()) {
tterr = ttrm->do_ttrm();
}
if ( ttrm->should_rm()
&& ((tterr <= TT_WRN_LAST) || ttrm->force()))
{
int err = ttrm->do_rm();
if (err != 0) {
(void)ttrm->close_tt();
exit( err );
}
}
(void)ttrm->close_tt();
if ((tterr > TT_WRN_LAST) && (! ttrm->force())) {
exit(1);
} else {
exit(0);
}
}