2 * Copyright (c) 1985 Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 static char sccsid
[] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89";
23 #include "prototypes.h"
29 //#include <sys/ttychars.h>
31 void domacro(argc
, argv
)
38 int count
= 2, loopflg
= 0;
40 struct cmd
*getcmd(), *c
;
43 (void) strcat(line
, " ");
44 printf("(macro name) ");
45 (void) fflush(stdout
);
46 (void) gets(&line
[strlen(line
)]);
52 printf("Usage: %s macro_name.\n", argv
[0]);
53 (void) fflush(stdout
);
57 for (i
= 0; i
< macnum
; ++i
) {
58 if (!strncmp(argv
[1], macros
[i
].mac_name
, 9)) {
63 printf("'%s' macro not found.\n", argv
[1]);
64 (void) fflush(stdout
);
68 (void) strcpy(line2
, line
);
70 cp1
= macros
[i
].mac_start
;
71 while (cp1
!= macros
[i
].mac_end
) {
72 while (isspace(*cp1
)) {
76 while (*cp1
!= '\0') {
82 if (isdigit(*(cp1
+1))) {
84 while (isdigit(*++cp1
)) {
85 j
= 10*j
+ *cp1
- '0';
89 (void) strcpy(cp2
, argv
[j
+1]);
90 cp2
+= strlen(argv
[j
+1]);
94 if (*(cp1
+1) == 'i') {
98 (void) strcpy(cp2
, argv
[count
]);
99 cp2
+= strlen(argv
[count
]);
103 /* intentional drop through */
114 c
= getcmd(margv
[0]);
115 if (c
== (struct cmd
*)-1) {
116 printf("?Ambiguous command\n");
120 printf("?Invalid command\n");
123 else if (c
->c_conn
&& !connected
) {
124 printf("Not connected.\n");
131 (*c
->c_handler
)(margc
, margv
);
132 if (bell
&& c
->c_bell
) {
133 (void) putchar('\007');
135 (void) strcpy(line
, line2
);
140 if (cp1
!= macros
[i
].mac_end
) {
143 (void) fflush(stdout
);
145 if (loopflg
&& ++count
< argc
) {