1
/* @(#)osrtest.c 19.1 (ES0-DMD) 02/25/03 13:56:14 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
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.
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.
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,
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
27
===========================================================================*/
32
.IDENTIFICATION TESTosr
33
.VERSION 1.0 06-Oct-1987: Creation
34
.AUTHOR Francois Ochsenbein [ESO-IPG]
35
.KEYWORDS Test of osr routines
39
-------------------------------------------------------------------------*/
46
#define NULL NULL_PTR(char)
49
extern char *oshenv();
52
static char buf[1000];
53
static struct remstat info;
55
static int timeout = 1;
61
puts("==== Testing OSR (Remote Access) routines ====");
62
puts(" Type ? for Help");
65
{ printf("Your choice: "); if (!gets(msg)) break;
68
{ default: puts("*** Uknown Command!");
69
case 'H': case '?': help(); continue;
71
case 'C': case 'c': /* Close */
72
s = osrclose(f); break;
74
case 'O': case 'o': /* Open */
75
if (msg[1] != ' ') { puts("Specify Destination!"); break;}
76
p = msg + 2, u = NULL;
78
{ p = oshenv(p, "PSI$DTE_TABLE");
79
if (p) oscopuc(buf, p, 100, EOS);
81
i = strlen(msg); msg[i++] = '_';
82
msg[i++] = 'U'; msg[i++] = EOS;
83
u = oshenv(msg+2, "PSI$DTE_TABLE");
84
if (u) oscopuc(buf+100, u, 100, EOS);
87
s = osropen(p, NULL, u, NULL);
91
case '@': /* Select File Number */
93
printf("Switching to Circuit %d\n", f);
96
case 'T': case 't': /* Modify timeout */
97
timeout = atoi(&msg[1]);
98
printf("Timeout is now %ds.\n", timeout);
101
case 'I': case 'i': /* Get status */
102
s = osrinfo(f, &info);
103
printf("Circuit %d: dte=%s, net=%s, device=%s, unit=%d\n",
104
f, info.dte, info.net, info.device, info.unit);
108
case 'G': case 'g': /* Gets n bytes */
109
s = osrgets(f, buf, atoi(msg+1), timeout);
112
for (p = buf; *p; p++)
113
{ if (iscntrl(*p)) printf("^%c", *p+'@');
114
else printf("%c",*p);
120
case 'P': case 'p': /* Write text */
121
if (msg[1] == EOS) { printf("Text: ") ; gets(&msg[2]);}
122
s = osrputs(f, &msg[2]);
125
printf("Status is %d", s);
126
if (s < 0) printf(": %s",osmsg());
135
printf("Current Circuit is %d, with timeout of %ds.\n", f, timeout);
136
puts("Possibilities are: ? Help");
137
puts(" @ f select Circuit f");
138
puts(" C Close Current Circuit");
139
puts(" G n Gets n bytes");
140
puts(" I Display status of Current Circuit");
141
puts(" O dte Open Circuit");
142
puts(" P text Puts text to Remote");
143
puts(" T seconds Modify Time-out");