BSD 4_3 development
[unix-history] / usr / contrib / kermit / ckuus2.c
CommitLineData
ee2abe03
C
1/* C K U U S 2 -- "User Interface" STRINGS module for Unix Kermit */
2
3/*
4 Author: Frank da Cruz (SY.FDC@CU20B),
5 Columbia University Center for Computing Activities, January 1985.
6 Copyright (C) 1985, Trustees of Columbia University in the City of New York.
7 Permission is granted to any individual or institution to use, copy, or
8 redistribute this software so long as it is not sold for profit, provided this
9 copyright notice is retained.
10*/
11
12/* This module separates long strings from the body of the ckuser module. */
13
14#include "ckcdeb.h"
15#include <stdio.h>
16#include <ctype.h>
17#include "ckcker.h"
18#include "ckucmd.h"
19#include "ckuusr.h"
20
21extern char cmdbuf[];
22extern int nrmt, nprm, dfloc;
23extern char *dftty;
24extern struct keytab prmtab[];
25extern struct keytab remcmd[];
26
27static
28char *hlp1[] = {
29"\n",
30" Usage: kermit [-x arg [-x arg]...[-yyy]..]]\n",
31" x is an option that requires an argument, y an option with no argument:\n",
32" actions (* options also require -l and -b) --\n",
33" -s file(s) send (use '-s -' to send from stdin)\n",
34" -r receive\n",
35" -k receive to stdout\n",
36" * -g file(s) get remote file(s) from server (quote wildcards)\n",
37" -a name alternate name, used with -s, -r, -g\n",
38" -x enter server mode\n",
39" * -f finish remote server\n",
40" * -c connect before transaction\n",
41" * -n connect after transaction\n",
42" -h help - print this message\n",
43" settings --\n",
44" -l line communication line device\n",
45" -b baud line speed, e.g. 1200\n",
46" -i binary file or Unix-to-Unix\n",
47" -p x parity, x is one of e,o,m,s,n\n",
48" -t line turnaround handshake = xon, half duplex\n",
49" -w don't write over preexisting files\n",
50" -q be quiet during file transfer\n",
51" -d log debugging info to debug.log\n",
52" If no action command is included, enter interactive dialog.\n",
53""
54};
55
56/* U S A G E */
57
58usage() {
59 conola(hlp1);
60}
61\f
62
63/* Help string definitions */
64
65static char *tophlp[] = { "\n\
66Type ? for a list of commands, type 'help x' for any command x.\n\
67While typing commands, use the following special characters:\n\n\
68 DEL, RUBOUT, BACKSPACE, CTRL-H: Delete the most recent character typed.\n\
69 CTRL-W: Delete the most recent word typed.\n",
70
71"\
72 CTRL-U: Delete the current line.\n\
73 CTRL-R: Redisplay the current line.\n\
74 ? (question mark) display help on the current command or field.\n\
75 ESC (Escape or Altmode) Attempt to complete the current field.\n",
76
77"\
78 \\ (backslash) include the following character literally.\n\n\
79From system level, type 'kermit -h' to get help about command line args.\
80\n",
81"" };
82
83static char *hmxxbye = "\
84Shut down and log out a remote Kermit server";
85
86static char *hmxxclo = "\
87Close one of the following logs:\n\
88 session, transaction, packet, debugging -- 'help log' for further info.";
89
90static char *hmxxcon = "\
91Connect to a remote system via the tty device given in the\n\
92most recent 'set line' command";
93
94static char *hmxxget = "\
95Format: 'get filespec'. Tell the remote Kermit server to send the named\n\
96files. If filespec is omitted, then you are prompted for the remote and\n\
97local filenames separately.";
98
99static char *hmxxlg[] = { "\
100Record information in a log file:\n\n\
101 debugging Debugging information, to help track down\n\
102 (default debug.log) bugs in the C-Kermit program.\n\n\
103 packets Kermit packets, to help track down protocol problems.\n\
104 (packet.log)\n\n",
105
106" session Terminal session, during CONNECT command.\n\
107 (session.log)\n\n\
108 transactions Names and statistics about files transferred.\n\
109 (transact.log)\n",
110"" } ;
111\f
112
113static char *hmxxlogi[] = { "\
114Syntax: script text\n\n",
115"Login to a remote system using the text provided. The login script\n",
116"is intended to operate similarly to uucp \"L.sys\" entries.\n",
117"A login script is a sequence of the form:\n\n",
118" expect send [expect send] . . .\n\n",
119"where 'expect' is a prompt or message to be issued by the remote site, and\n",
120"'send' is the names, numbers, etc, to return. The send may also be the\n",
121"keyword EOT, to send control-d, or BREAK, to send a break. Letters in\n",
122"send may be prefixed by ~ to send special characters. These are:\n",
123"~b backspace, ~s space, ~q '?', ~n linefeed, ~r return, ~c don\'t\n",
124"append a return, and ~o[o[o]] for octal of a character. As with some \n",
125"uucp systems, sent strings are followed by ~r unless they end with ~c.\n\n",
126"Only the last 7 characters in each expect are matched. A null expect,\n",
127"e.g. ~0 or two adjacent dashes, causes a short delay. If you expect\n",
128"that a sequence might not arrive, as with uucp, conditional sequences\n",
129"may be expressed in the form:\n\n",
130" -send-expect[-send-expect[...]]\n\n",
131"where dashed sequences are followed as long as previous expects fail.\n",
132"" };
133
134static char *hmxxrc[] = { "\
135Format: 'receive [filespec]'. Wait for a file to arrive from the other\n\
136Kermit, which must be given a 'send' command. If the optional filespec is\n",
137
138"given, the (first) incoming file will be stored under that name, otherwise\n\
139it will be stored under the name it arrives with.",
140"" } ;
141
142static char *hmxxsen = "\
143Format: 'send file1 [file2]'. File1 may contain wildcard characters '*' or\n\
144'?'. If no wildcards, then file2 may be used to specify the name file1 is\n\
145sent under; if file2 is omitted, file1 is sent under its own name.";
146
147static char *hmxxser = "\
148Enter server mode on the currently selected line. All further commands\n\
149will be taken in packet form from the other Kermit program.";
150
151static char *hmhset[] = { "\
152The 'set' command is used to establish various communication or file\n",
153"parameters. The 'show' command can be used to display the values of\n",
154"'set' parameters. Help is available for each individual parameter;\n",
155"type 'help set ?' to see what's available.\n",
156"" } ;
157
158static char *hmxychkt[] = { "\
159Type of packet block check to be used for error detection, 1, 2, or 3.\n",
160"Type 1 is standard, and catches most errors. Types 2 and 3 specify more\n",
161"rigorous checking at the cost of higher overhead. Not all Kermit programs\n",
162"support types 2 and 3.\n",
163"" } ;
164\f
165
166static char *hmxyf[] = { "\set file: names, type, warning, display.\n\n",
167"'names' are normally 'converted', which means file names are converted\n",
168"to 'common form' during transmission; 'literal' means use filenames\n",
169"literally (useful between like systems).\n\n",
170"'type' is normally 'text', in which conversion is done between Unix\n",
171"newlines and CRLF line delimiters; 'binary' means to do no conversion.\n",
172"Use 'binary' for executable programs or binary data.\n\n",
173"'warning' is 'on' or 'off', normally off. When off, incoming files will\n",
174"overwrite existing files of the same name. When on, new names will be\n",
175"given to incoming files whose names are the same as existing files.\n",
176"\n\
177'display' is normally 'on', causing file transfer progress to be displayed\n",
178"on your screen when in local mode. 'set display off' is useful for\n",
179"allowing file transfers to proceed in the background.\n\n",
180"" } ;
181
182static char *hmhrmt[] = { "\
183The 'remote' command is used to send file management instructions to a\n",
184"remote Kermit server. There should already be a Kermit running in server\n",
185"mode on the other end of the currently selected line. Type 'remote ?' to\n",
186"see a list of available remote commands. Type 'help remote x' to get\n",
187"further information about a particular remote command 'x'.\n",
188"" } ;
189\f
190
191/* D O H L P -- Give a help message */
192
193dohlp(xx) int xx; {
194 int x,y;
195
196 if (xx < 0) return(xx);
197 switch (xx) {
198
199case XXBYE:
200 return(hmsg(hmxxbye));
201
202case XXCLO:
203 return(hmsg(hmxxclo));
204
205case XXCON:
206 return(hmsg(hmxxcon));
207
208case XXCWD:
209#ifdef vms
210 return(hmsg("\
211Change Working Directory, equivalent to VMS SET DEFAULT command"));
212#else
213 return(hmsg("Change Working Directory, equivalent to Unix 'cd' command"));
214#endif
215
216case XXDEL:
217 return(hmsg("Delete a local file or files"));
218
219case XXDIAL:
220 return(hmsg("Dial a number using modem autodialer"));
221
222case XXDIR:
223 return(hmsg("Display a directory of local files"));
224
225case XXECH:
226 return(hmsg("Display the rest of the command on the terminal,\n\
227useful in command files."));
228
229case XXEXI:
230case XXQUI:
231 return(hmsg("Exit from the Kermit program, closing any open logs."));
232
233case XXFIN:
234 return(hmsg("\
235Tell the remote Kermit server to shut down without logging out."));
236
237case XXGET:
238 return(hmsg(hmxxget));
239
240case XXHLP:
241 return(hmsga(tophlp));
242
243case XXLOG:
244 return(hmsga(hmxxlg));
245
246case XXLOGI:
247 return(hmsga(hmxxlogi));
248
249case XXREC:
250 return(hmsga(hmxxrc));
251\f
252
253case XXREM:
254 if ((y = cmkey(remcmd,nrmt,"Remote command","")) == -2) return(y);
255 if (y == -1) return(y);
256 if (x = (cmcfm()) < 0) return(x);
257 return(dohrmt(y));
258
259case XXSEN:
260 return(hmsg(hmxxsen));
261
262case XXSER:
263 return(hmsg(hmxxser));
264
265case XXSET:
266 if ((y = cmkey(prmtab,nprm,"Parameter","")) == -2) return(y);
267 if (y == -2) return(y);
268 if (x = (cmcfm()) < 0) return(x);
269 return(dohset(y));
270
271case XXSHE:
272#ifdef vms
273 return(hmsg("\
274Issue a command to VMS (space required after '!')"));
275#else
276 return(hmsg("\
277Issue a command to the Unix shell (space required after '!')"));
278#endif
279
280case XXSHO:
281 return(hmsg("\
282Display current values of 'set' parameters; 'show version' will display\n\
283program version information for each of the C-Kermit modules."));
284
285case XXSPA:
286 return(hmsg("Display disk usage in current device, directory"));
287
288case XXSTA:
289 return(hmsg("Display statistics about most recent file transfer"));
290
291case XXTAK:
292 return(hmsg("\
293Take Kermit commands from the named file. Kermit command files may\n\
294themselves contain 'take' commands, up to a reasonable depth of nesting."));
295
296default:
297 if (x = (cmcfm()) < 0) return(x);
298 printf("Not available yet - %s\n",cmdbuf);
299 break;
300 }
301 return(0);
302}
303\f
304
305/* H M S G -- Get confirmation, then print the given message */
306
307hmsg(s) char *s; {
308 int x;
309 if (x = (cmcfm()) < 0) return(x);
310 puts(s);
311 return(0);
312}
313
314hmsga(s) char *s[]; { /* Same function, but for arrays */
315 int x, i;
316 if ( x = (cmcfm()) < 0) return(x);
317 for ( i = 0; *s[i] ; i++ ) fputs(s[i], stdout);
318 fputc( '\n', stdout);
319 return(0);
320}
321\f
322
323/* D O H S E T -- Give help for SET command */
324
325dohset(xx) int xx; {
326
327 if (xx == -3) return(hmsga(hmhset));
328 if (xx < 0) return(xx);
329 switch (xx) {
330
331case XYCHKT:
332 return(hmsga(hmxychkt));
333
334case XYDELA:
335 puts("\
336Number of seconds to wait before sending first packet after 'send' command.");
337 return(0);
338
339case XYDUPL:
340 puts("\
341During 'connect': 'full' means remote host echoes, 'half' means this program");
342 puts("does its own echoing.");
343 return(0);
344
345case XYESC:
346 printf("%s","\
347Decimal ASCII value for escape character during 'connect', normally 28\n\
348(Control-\\)\n");
349 return(0);
350
351case XYFILE:
352 return(hmsga(hmxyf));
353
354case XYFLOW:
355 puts("\
356Type of flow control to be used. Choices are 'xon/xoff' and 'none'.");
357 puts("normally xon/xoff.");
358 return(0);
359
360case XYHAND:
361 puts("\
362Decimal ASCII value for character to use for half duplex line turnaround");
363 puts("handshake. Normally, handshaking is not done.");
364 return(0);
365
366case XYIFD:
367 puts("\
368Incomplete file disposition: discard or keep. Normally discard.");
369 return(0);
370\f
371case XYLINE:
372 printf("\
373Device name of communication line to use. Normally %s.\n",dftty);
374 if (!dfloc) {
375 printf("\
376If you set the line to other than %s, then Kermit\n",dftty);
377 printf("\
378will be in 'local' mode; 'set line' will reset Kermit to its default mode.\n");
379#ifndef vms
380 printf("\
381'set line /dev/tty' will always put Kermit in remote mode.\n");
382#endif
383 }
384 puts("\
385If the line has a modem, and if the modem-dialer is set to direct, this");
386 puts("\
387command causes waiting for a carrier detect (e.g. on a hayes type modem).");
388 puts("\
389This can be used to wait for incoming calls.");
390 puts("\
391To use the modem to dial out, first set modem-dialer (e.g., to hayes), then");
392 puts("set line, next issue the dial command, and finally connect.");
393
394 return(0);
395
396case XYMODM:
397 puts("\
398Type of modem for dialing remote connections. Needed to indicate modem can");
399 puts("\
400be commanded to dial without 'carrier detect' from modem. Many recently");
401 puts("\
402manufactured modems use 'hayes' protocol. Type 'set modem ?' to see what");
403 puts("\
404types of modems are supported by this program.");
405 return(0);
406
407
408case XYPARI:
409 puts("Parity to use during terminal connection and file transfer:");
410 puts("even, odd, mark, space, or none. Normally none.");
411 return(0);
412
413case XYPROM:
414 puts("Prompt string for this program, normally 'C-Kermit>'.");
415 return(0);
416
417case XYSPEE:
418 puts("\
419Communication line speed for external tty line specified in most recent");
420 puts("\
421'set line' command. Any of the common baud rates:");
422 puts(" 0, 110, 150, 300, 600, 1200, 1800, 2400, 4800, 9600.");
423 return(0);
424\f
425case XYRECV:
426 puts("\
427Specify parameters for inbound packets:");
428 puts("\
429End-Of-Packet (ASCII value), Packet-Length (94 or less),");
430 puts("\
431Padding (amount, 94 or less), Pad-Character (ASCII value),");
432 puts("\
433Start-Of-Packet (ASCII value), and Timeout (94 seconds or less),");
434 puts("\
435all specified as decimal numbers.");
436 return(0);
437
438case XYSEND:
439 puts("\
440Specify parameters for outbound packets:");
441 puts("\
442End-Of-Packet (ASCII value), Packet-Length (94 or less),");
443 puts("\
444Padding (amount, 94 or less), Pad-Character (ASCII value),");
445 puts("\
446Start-Of-Packet (ASCII value), and Timeout (94 seconds or less),");
447 puts("\
448all specified as decimal numbers.");
449 return(0);
450
451default:
452 printf("%s","Not available yet - %s\n",cmdbuf);
453 return(0);
454 }
455}
456\f
457
458/* D O H R M T -- Give help about REMOTE command */
459
460dohrmt(xx) int xx; {
461 int x;
462 if (xx == -3) return(hmsga(hmhrmt));
463 if (xx < 0) return(xx);
464 switch (xx) {
465
466case XZCWD:
467 return(hmsg("\
468Ask remote Kermit server to change its working directory."));
469
470case XZDEL:
471 return(hmsg("\
472Ask remote Kermit server to delete the named file(s)."));
473
474case XZDIR:
475 return(hmsg("\
476Ask remote Kermit server to provide directory listing of the named file(s)."));
477
478case XZHLP:
479 return(hmsg("\
480Ask remote Kermit server to tell you what services it provides."));
481
482case XZHOS:
483 return(hmsg("\
484Send a command to the remote system in its own command language\n\
485through the remote Kermit server."));
486
487case XZSPA:
488 return(hmsg("\
489Ask the remote Kermit server to tell you about its disk space."));
490
491case XZTYP:
492 return(hmsg("\
493Ask the remote Kermit server to type the named file(s) on your screen."));
494
495case XZWHO:
496 return(hmsg("\
497Ask the remote Kermit server to list who's logged in, or to give information\n\
498about the specified user."));
499
500default:
501 if (x = (cmcfm()) < 0) return(x);
502 printf("%s","not working yet - %s\n",cmdbuf);
503 return(-2);
504 }
505}