| 1 |
/* @(#)oshtest.c 19.1 (ES0-DMD) 02/25/03 13:56:12 */ |
| 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: [email protected] |
| 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 |
.AUTHOR Francois Ochsenbein [ESO-IPG] |
| 34 |
.KEYWORDS Test of osh routines |
| 35 |
.ENVIRONMENT |
| 36 |
.COMMENTS |
| 37 |
.VERSION 1.0 23-Oct-1987: Creation |
| 38 |
.VERSION 1.1 01-Aug-1990: Added oshproc services |
| 39 |
.VERSION 1.2 09-Feb-1993: Removed GNU-nonunderstandable code.(oshostname)CG. |
| 40 |
|
| 41 |
-------------------------------------------------------------------------*/ |
| 42 |
|
| 43 |
#include <osdefos.h> |
| 44 |
|
| 45 |
char *osmsg(), *oshenv(), *oshuser(); |
| 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 'p': case 'P': /* Put Logical */ |
| 74 |
printf("Logical to define: "); gets(c1); |
| 75 |
printf("Equivalence: "); gets(c2); |
| 76 |
l = oshset(c1, c2); |
| 77 |
if (l) puts(osmsg()); |
| 78 |
break; |
| 79 |
|
| 80 |
case 't': case 'T': /* Time */ |
| 81 |
printf("Time is now: %d\n", oshtime()); |
| 82 |
#if 0 |
| 83 |
printf("UTime is now: %d\n", oshgmt()); |
| 84 |
#endif |
| 85 |
break; |
| 86 |
|
| 87 |
case 'u': case 'U': /* UserName */ |
| 88 |
printf("You should be user `%s'\n", oshuser()); |
| 89 |
break; |
| 90 |
|
| 91 |
#if 0 |
| 92 |
case 's': case 'S': /* Set time */ |
| 93 |
switch(msg[1]) |
| 94 |
{ case 'c': case 'C': |
| 95 |
tim = oshcpu(INIT_CLOCK, NULL_PTR(float)); break; |
| 96 |
case 'e': case 'E': |
| 97 |
tim = oshela(INIT_CLOCK, NULL_PTR(long)); break; |
| 98 |
default: puts("***BAD***"); |
| 99 |
} |
| 100 |
break; |
| 101 |
|
| 102 |
case 'g': case 'G': /* Get time */ |
| 103 |
switch(msg[1]) |
| 104 |
{ case 'c': case 'C': |
| 105 |
tim = oshcpu(GET_CLOCK, NULL_PTR(float)); break; |
| 106 |
case 'e': case 'E': |
| 107 |
tim = oshela(GET_CLOCK, NULL_PTR(long)); break; |
| 108 |
default: |
| 109 |
tim = oshela(-1); break; |
| 110 |
} |
| 111 |
if (tim >= 0) printf("Time: %d\n", tim); |
| 112 |
else puts(osmsg()); |
| 113 |
break; |
| 114 |
#endif |
| 115 |
|
| 116 |
case 'e': case 'E': /* Execute */ |
| 117 |
printf("Specify Command: "); if (gets(msg) == 0) break; |
| 118 |
#if 1 |
| 119 |
printf("Specify stdin : "); if (gets(c1) == 0) break; |
| 120 |
printf("Specify stdout : "); if (gets(c2) == 0) break; |
| 121 |
i = oshcmd(msg, c1 , c2, (char *)0); |
| 122 |
#else |
| 123 |
i = oshexec(msg); |
| 124 |
#endif |
| 125 |
puts(osmsg()); |
| 126 |
break; |
| 127 |
|
| 128 |
default: puts("***BAD***"); |
| 129 |
break; |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
help() |
| 134 |
{ |
| 135 |
puts("Possibilities are: ? Help"); |
| 136 |
puts(" L translate Logical"); |
| 137 |
puts(" SC|SE Set time Cpu|Elapsed"); |
| 138 |
puts(" GC|GE Get Time Cpu|Elapsed"); |
| 139 |
puts(" N tell Node name"); |
| 140 |
puts(" P Put Logical Name in Environment"); |
| 141 |
puts(" T tell Time"); |
| 142 |
puts(" U tell User name"); |
| 143 |
puts(" E Execute a command"); |
| 144 |
return(0); |
| 145 |
} |