Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / tt / bin / shell / ttrm.C
1 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                  
2 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.    
3 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                   
4 //%%  (c) Copyright 1993, 1994 Novell, Inc.                             
5 //%%  $XConsortium: ttrm.C /main/3 1995/10/20 16:37:34 rswiston $                                                       
6 /* @(#)ttrm.C   1.12 93/07/30
7  * ttrm.cc - Link Service/ToolTalk wrapper for rm(1).
8  *
9  * Copyright (c) 1990 by Sun Microsystems, Inc.
10  *
11  */
12
13 #include <stdlib.h>
14 #include <locale.h>
15 #include <util/copyright.h>
16 #include <tt_options.h>
17 #include "remover.h"
18
19 /*
20  * External variables
21  */
22
23 TT_INSERT_COPYRIGHT
24
25 #ifdef OPT_PATCH
26 static char PatchID[] = "Patch Id: 100626_03.";
27 static int Patch_ID100626_03;
28 #endif
29
30 /*
31  * main()
32  */
33 int
34 main(int argc, char **argv)
35 {
36         Tt_status       tterr = TT_OK;
37         remover        *ttrm = new remover( argv[0] );
38
39         setlocale( LC_ALL, "" );
40         ttrm->parse_args( argc, argv );
41         tterr = ttrm->open_tt();
42
43         if (ttrm->tt_opened()) {
44                 tterr = ttrm->do_ttrm();
45         }
46         if (    ttrm->should_rm()
47              && ((tterr <= TT_WRN_LAST) || ttrm->force()))
48         {
49                 int err = ttrm->do_rm();
50                 if (err != 0) {
51                         (void)ttrm->close_tt();
52                         exit( err );
53                 }
54         }
55
56         (void)ttrm->close_tt();
57
58         if ((tterr > TT_WRN_LAST) && (! ttrm->force())) {
59                 exit(1);
60         } else {
61                 exit(0);
62         }
63 }