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
)
36 register char *cp1
, *cp2
;
37 int count
= 2, loopflg
= 0;
39 struct cmd
*getcmd(), *c
;
42 (void) strcat(line
, " ");
43 printf("(macro name) ");
44 (void) fflush(stdout
);
45 (void) gets(&line
[strlen(line
)]);
51 printf("Usage: %s macro_name.\n", argv
[0]);
52 (void) fflush(stdout
);
56 for (i
= 0; i
< macnum
; ++i
) {
57 if (!strncmp(argv
[1], macros
[i
].mac_name
, 9)) {
62 printf("'%s' macro not found.\n", argv
[1]);
63 (void) fflush(stdout
);
67 (void) strcpy(line2
, line
);
69 cp1
= macros
[i
].mac_start
;
70 while (cp1
!= macros
[i
].mac_end
) {
71 while (isspace(*cp1
)) {
75 while (*cp1
!= '\0') {
81 if (isdigit(*(cp1
+1))) {
83 while (isdigit(*++cp1
)) {
84 j
= 10*j
+ *cp1
- '0';
88 (void) strcpy(cp2
, argv
[j
+1]);
89 cp2
+= strlen(argv
[j
+1]);
93 if (*(cp1
+1) == 'i') {
97 (void) strcpy(cp2
, argv
[count
]);
98 cp2
+= strlen(argv
[count
]);
102 /* intentional drop through */
113 c
= getcmd(margv
[0]);
114 if (c
== (struct cmd
*)-1) {
115 printf("?Ambiguous command\n");
119 printf("?Invalid command\n");
122 else if (c
->c_conn
&& !connected
) {
123 printf("Not connected.\n");
130 (*c
->c_handler
)(margc
, margv
);
131 if (bell
&& c
->c_bell
) {
132 (void) putchar('\007');
134 (void) strcpy(line
, line2
);
139 if (cp1
!= macros
[i
].mac_end
) {
142 (void) fflush(stdout
);
144 if (loopflg
&& ++count
< argc
) {