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(int argc
, const char *argv
[])
36 int count
= 2, loopflg
= 0;
38 struct cmd
*getcmd(), *c
;
41 (void) strcat(line
, " ");
42 printf("(macro name) ");
43 (void) fflush(stdout
);
44 (void) gets(&line
[strlen(line
)]);
50 printf("Usage: %s macro_name.\n", argv
[0]);
51 (void) fflush(stdout
);
55 for (i
= 0; i
< macnum
; ++i
) {
56 if (!strncmp(argv
[1], macros
[i
].mac_name
, 9)) {
61 printf("'%s' macro not found.\n", argv
[1]);
62 (void) fflush(stdout
);
66 (void) strcpy(line2
, line
);
68 cp1
= macros
[i
].mac_start
;
69 while (cp1
!= macros
[i
].mac_end
) {
70 while (isspace(*cp1
)) {
74 while (*cp1
!= '\0') {
80 if (isdigit(*(cp1
+1))) {
82 while (isdigit(*++cp1
)) {
83 j
= 10*j
+ *cp1
- '0';
87 (void) strcpy(cp2
, argv
[j
+1]);
88 cp2
+= strlen(argv
[j
+1]);
92 if (*(cp1
+1) == 'i') {
96 (void) strcpy(cp2
, argv
[count
]);
97 cp2
+= strlen(argv
[count
]);
101 /* intentional drop through */
112 c
= getcmd(margv
[0]);
113 if (c
== (struct cmd
*)-1) {
114 printf("?Ambiguous command\n");
118 printf("?Invalid command\n");
121 else if (c
->c_conn
&& !connected
) {
122 printf("Not connected.\n");
129 (*c
->c_handler
)(margc
, margv
);
130 if (bell
&& c
->c_bell
) {
131 (void) putchar('\007');
133 (void) strcpy(line
, line2
);
138 if (cp1
!= macros
[i
].mac_end
) {
141 (void) fflush(stdout
);
143 if (loopflg
&& ++count
< argc
) {