~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to test/os/oshtest.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)oshtest.c        19.1 (ES0-DMD) 02/25/03 14:33:05 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
5
  This program is free software; you can redistribute it and/or 
 
6
  modify it under the terms of the GNU General Public License as 
 
7
  published by the Free Software Foundation; either version 2 of 
 
8
  the License, or (at your option) any later version.
 
9
 
 
10
  This program is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU General Public 
 
16
  License along with this program; if not, write to the Free 
 
17
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
  MA 02139, USA.
 
19
 
 
20
  Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
        Internet e-mail: midas@eso.org
 
22
        Postal address: European Southern Observatory
 
23
                        Data Management Division 
 
24
                        Karl-Schwarzschild-Strasse 2
 
25
                        D 85748 Garching bei Muenchen 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/*+++++++++++   
 
30
.TYPE           Program
 
31
.LANGUAGE       C
 
32
.IDENTIFICATION TESTosf
 
33
.VERSION 1.0    23-Oct-1987: Creation
 
34
.VERSION 1.1    01-Aug-1990: Added oshproc services
 
35
.AUTHOR         Francois Ochsenbein [ESO-IPG]
 
36
.KEYWORDS       Test of osh routines
 
37
.ENVIRONMENT    
 
38
.COMMENTS       
 
39
 
 
40
-------------------------------------------------------------------------*/
 
41
 
 
42
#include   <osdefos.h>
 
43
 
 
44
/* char *osmsg(), *oshenv(), *oshuser(), *oshostname(); */
 
45
char *osmsg(), *oshenv();
 
46
long oshtime(), oshgmt();
 
47
 
 
48
static char msg[80];
 
49
static char c1[80], c2[80];
 
50
 
 
51
main()
 
52
{       int i, l, n, n1, n2;
 
53
        long int tim;
 
54
        char *p, *r;
 
55
 
 
56
  puts("Test of osh (Host Services) Routines");
 
57
 
 
58
  while (1)
 
59
  {     printf("Operation: ");
 
60
        if (gets(msg) == 0)     break;
 
61
        switch(msg[0])
 
62
        { case '?': help(); break;
 
63
          case 'l': case 'L':           /* Logical translation  */
 
64
                printf("Logical to translate: ");       gets(c1);
 
65
#               if VMS
 
66
                printf("Table to use: ");               gets(c2);
 
67
#               endif
 
68
                r = oshenv(c1, c2);
 
69
                if (r)  printf("Translation: %s\n", r);
 
70
                else    puts(osmsg());
 
71
                break;
 
72
 
 
73
/*        case 'n': case 'N':           /* NodeName     */
 
74
/*              printf("You should be on node `%s'\n", oshostname());
 
75
/*              break;
 
76
*/
 
77
 
 
78
/*
 
79
/*        case 'p': case 'P':           /* Put Logical  */
 
80
/*              printf("Logical to define: ");          gets(c1);
 
81
/*              printf("Equivalence: ");                gets(c2);
 
82
/*              l = oshset(c1, c2);
 
83
/*              if (l)  puts(osmsg());
 
84
/*              break;
 
85
*/
 
86
 
 
87
          case 't': case 'T':           /* Time         */
 
88
                printf("Time is now: %d\n", oshtime());
 
89
#if 0
 
90
                printf("UTime is now: %d\n", oshgmt());
 
91
#endif
 
92
                break;
 
93
 
 
94
/*
 
95
/*        case 'u': case 'U':           /* UserName     */
 
96
/*              printf("You should be user `%s'\n", oshuser());
 
97
/*              break;
 
98
*/
 
99
 
 
100
#if 0
 
101
          case 's': case 'S':           /* Set time     */
 
102
                switch(msg[1])
 
103
                { case 'c': case 'C':
 
104
                        tim = oshcpu(INIT_CLOCK, NULL_PTR(float)); break;
 
105
                  case 'e': case 'E':
 
106
                        tim = oshela(INIT_CLOCK, NULL_PTR(long)); break;
 
107
                  default: puts("***BAD***"); 
 
108
                }
 
109
                break;
 
110
 
 
111
          case 'g': case 'G':           /* Get time     */
 
112
                switch(msg[1])
 
113
                { case 'c': case 'C':
 
114
                        tim = oshcpu(GET_CLOCK, NULL_PTR(float)); break;
 
115
                  case 'e': case 'E':
 
116
                        tim = oshela(GET_CLOCK, NULL_PTR(long)); break;
 
117
                  default: 
 
118
                        tim = oshela(-1); break;
 
119
                }
 
120
                if (tim >= 0)   printf("Time: %d\n", tim);
 
121
                else    puts(osmsg());
 
122
                break;
 
123
#endif
 
124
 
 
125
          case 'e': case 'E':           /* Execute      */
 
126
                printf("Specify Command: ");    if (gets(msg) == 0) break;
 
127
#if 1
 
128
                printf("Specify stdin  : ");    if (gets(c1) == 0) break;
 
129
                printf("Specify stdout : ");    if (gets(c2) == 0) break;
 
130
                i = oshcmd(msg, c1 , c2, (char *)0);
 
131
#else
 
132
                i = oshexec(msg);
 
133
#endif
 
134
                puts(osmsg());
 
135
                break;
 
136
 
 
137
          default: puts("***BAD***"); 
 
138
                break;
 
139
        }
 
140
  }
 
141
}
 
142
help()
 
143
{
 
144
  puts("Possibilities are: ?           Help");
 
145
  puts("                   L           translate Logical");
 
146
  puts("                   SC|SE       Set time Cpu|Elapsed");
 
147
  puts("                   GC|GE       Get Time Cpu|Elapsed");
 
148
  puts("                   N           tell Node name");
 
149
  puts("                   P           Put Logical Name in Environment");
 
150
  puts("                   T           tell Time");
 
151
  puts("                   U           tell User name");
 
152
  puts("                   E           Execute a command");
 
153
  return(0);
 
154
}