* Copyright (c) 1985 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)domacro.c 1.6 (Berkeley) %G%";
#include <sys/ttychars.h>
register char *cp1
, *cp2
;
int count
= 2, loopflg
= 0;
extern char **glob(), *globerr
;
struct cmd
*getcmd(), *c
;
extern struct cmd cmdtab
[];
(void) strcat(line
, " ");
(void) gets(&line
[strlen(line
)]);
printf("Usage: %s macro_name.\n", argv
[0]);
for (i
= 0; i
< macnum
; ++i
) {
if (!strncmp(argv
[1], macros
[i
].mac_name
, 9)) {
printf("'%s' macro not found.\n", argv
[1]);
(void) strcpy(line2
, line
);
cp1
= macros
[i
].mac_start
;
while (cp1
!= macros
[i
].mac_end
) {
while (isdigit(*++cp1
)) {
(void) strcpy(cp2
, argv
[j
+1]);
cp2
+= strlen(argv
[j
+1]);
(void) strcpy(cp2
, argv
[count
]);
cp2
+= strlen(argv
[count
]);
/* intentional drop through */
if (c
== (struct cmd
*)-1) {
printf("?Ambiguous command\n");
printf("?Invalid command\n");
else if (c
->c_conn
&& !connected
) {
printf("Not connected.\n");
(*c
->c_handler
)(margc
, margv
);
(void) strcpy(line
, line2
);
if (cp1
!= macros
[i
].mac_end
) {
if (loopflg
&& ++count
< argc
) {