Jspice3
vmsio.c
Go to the documentation of this file.
1 /**********
2 Copyright 1990 Regents of the University of California. All rights reserved.
3 **********/
4 /*
5  * vmsio.c
6  *
7  * Written by Giles Billingsley, UC Berkeley.
8  * sccsid "@(#)vmsio.c 1.9 9/3/83"
9  *
10  * MFB is a graphics package that was developed by the integrated
11  * circuits group of the Electronics Research Laboratory and the
12  * Department of Electrical Engineering and Computer Sciences at
13  * the University of California, Berkeley, California. The programs
14  * in MFB are available free of charge to any interested party.
15  * The sale, resale, or use of these program for profit without the
16  * express written consent of the Department of Electrical Engineering
17  * and Computer Sciences, University of California, Berkeley, California,
18  * is forbidden.
19  *
20  * Routines to replace stty on VMS.
21  *
22  * dev_init(buf,size) initialize this package
23  * dev_getchar() input a char (no-echo, 1 char buff)
24  * from stdin.
25  * dev_printf() output a string of n chars with no
26  * hacking of special characters to stdout
27  * dev_getc() input a char (no-echo, 1 char buff)
28  * dev_write() output a string of n chars with no
29  * hacking of special characters
30  */
31 
32 #ifdef vms
33 #include "spice.h"
34 
35 #include ssdef
36 #include descrip
37 #include iodef
38 #include rms
39 #include "mfb.h"
40 
41 static unsigned rfunc;
42 static unsigned wfunc;
43 static int dev_channel;
44 static int initialized = 0;
45 
46 /*
47  * Test routine for vmsio.c
48  *
49  * main(){
50  * int c;
51  * dev_init();
52  * c = dev_getchar();
53  * printf("character = %d\n",c);
54  * c = dev_getchar();
55  * printf("character = %d\n",c);
56  * c = dev_getchar();
57  * printf("character = %d\n",c);
58  * c = dev_getchar();
59  * printf("character = %d\n",c);
60  * c = dev_getchar();
61  * printf("character = %d\n",c);
62  * dev_printf("this is a test",14);
63  * }
64  */
65 
66 
67 /* */
68 /* DEV_INIT - initializes global variables in DISPLAY */
69 /* */
70 dev_init()
71 {
72  struct dsc$descriptor_s com_desc;
73  char *cp = "TT";
74  int status;
75 
76  if(initialized)
77  return;
78  initialized = 1;
79  com_desc.dsc$w_length = strlen( cp );
80  com_desc.dsc$a_pointer = cp;
81  com_desc.dsc$b_class = DSC$K_CLASS_S;
82  com_desc.dsc$b_dtype = DSC$K_DTYPE_T;
83  wfunc = IO$_WRITEVBLK | IO$M_NOFORMAT;
84  rfunc = IO$_READVBLK | IO$M_NOECHO;
85  status = sys$assign(&com_desc,&dev_channel,0,0);
86  if(status != SS$_NORMAL){
87  printf("SYS$ASSIGN failed. Status = %d\n",status);
88  exit(1);
89  }
90 }
91 
92 
93 /* */
94 /* DEV_OPEN - initializes global variables in DISPLAY. */
95 /* open and assign the 'channel' to device 'name' (stdio by */
96 /* default). */
97 /* */
98 dev_open(name,channel)
99 char *name;
100 int *channel;
101 {
102  struct dsc$descriptor_s com_desc;
103  char *cp = "TT";
104  int status;
105 
106  /* initialize stdio */
107  dev_init();
108  /* open the standard channel by default */
109  if(name == NULL || *name == NULL){
110  /* stdout by default */
111  com_desc.dsc$w_length = strlen( cp );
112  com_desc.dsc$a_pointer = cp;
113  }
114  else{
115  com_desc.dsc$w_length = strlen( name );
116  com_desc.dsc$a_pointer = name;
117  }
118  com_desc.dsc$b_class = DSC$K_CLASS_S;
119  com_desc.dsc$b_dtype = DSC$K_DTYPE_T;
120  wfunc = IO$_WRITEVBLK | IO$M_NOFORMAT;
121  rfunc = IO$_READVBLK | IO$M_NOECHO;
122  status = sys$assign(&com_desc,channel,0,0);
123  if(status != SS$_NORMAL){
124  printf("SYS$ASSIGN failed. Status = %d\n",status);
125  exit(1);
126  }
127 }
128 
129 
130 /* */
131 /* DEV_PRINTF - dumps buffer to standard terminal */
132 /* */
133 /* It is necessary to have the length argument because the */
134 /* character buffer may have embedded nulls. */
135 /* */
136 dev_printf(buffer,length)
137 char *buffer;
138 int length;
139 {
140  int status;
141  int f_status;
142 
143  status = sys$qiow(6,dev_channel,wfunc,&f_status,0,0,buffer,length,0,0,0,0);
144  if(status != SS$_NORMAL){
145  printf("SYS$QIOW failed. Status = %d\n",status);
146  }
147  return(status);
148 }
149 
150 
151 /* */
152 /* DEV_GETCHAR - get a character from the standard terminal */
153 /* */
154 dev_getchar(){
155 char buf[10];
156 int status;
157 int f_status;
158 
159  status = sys$qiow(7,dev_channel,rfunc,&f_status,0,0,buf,1,0,0,0,0);
160  return((int)buf[0]);
161 }
162 
163 
164 /* */
165 /* DEV_WRITE - dumps buffer to device channel */
166 /* */
167 /* It is necessary to have the length argument because the */
168 /* character buffer may have embedded nulls. */
169 /* */
170 dev_write(channel,buffer,length)
171 char *buffer;
172 int channel;
173 int length;
174 {
175  int status;
176  int f_status;
177 
178  status = sys$qiow(6,channel,wfunc,&f_status,0,0,buffer,length,0,0,0,0);
179  if(status != SS$_NORMAL){
180  printf("SYS$QIOW failed. Status = %d\n",status);
181  }
182  return(status);
183 }
184 
185 
186 /* */
187 /* DEV_GETC - get a character from the device channel */
188 /* */
189 dev_getc(channel)
190 int channel;
191 {
192  char buf[10];
193  int status;
194  int f_status;
195 
196  status = sys$qiow(7,channel,rfunc,&f_status,0,0,buf,1,0,0,0,0);
197  return((int)buf[0]);
198 }
199 
200 #else
201 int vms_dummy_int; /* define something to keep linker happy */
202 #endif
static char buf[MAXPROMPT]
Definition: arg.c:18
int vms_dummy_int
Definition: vmsio.c:201
#define NULL
Definition: spdefs.h:121