ReactOS
0.4.16-dev-2104-gb84fa49
domacro.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 1985 Regents of the University of California.
3
* All rights reserved.
4
*
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.
16
*/
17
18
19
20
#include "
precomp.h
"
21
22
#ifndef lint
23
static
char
sccsid
[] =
"@(#)domacro.c 1.6 (Berkeley) 2/28/89"
;
24
#endif
/* not lint */
25
26
void
domacro
(
int
argc
,
const
char
*
argv
[])
27
{
28
int
i
,
j
;
29
const
char
*cp1;
30
char
*cp2;
31
int
count
= 2, loopflg = 0;
32
char
line2[200];
33
struct
cmd
*
getcmd
(), *
c
;
34
35
if
(
argc
< 2) {
36
(
void
)
strcat
(
line
,
" "
);
37
printf
(
"(macro name) "
);
38
(
void
)
fflush
(
stdout
);
39
(
void
)
gets
(&
line
[
strlen
(
line
)]);
40
makeargv
();
41
argc
=
margc
;
42
argv
=
margv
;
43
}
44
if
(
argc
< 2) {
45
printf
(
"Usage: %s macro_name.\n"
,
argv
[0]);
46
(
void
)
fflush
(
stdout
);
47
code
= -1;
48
return
;
49
}
50
for
(
i
= 0;
i
<
macnum
; ++
i
) {
51
if
(!
strncmp
(
argv
[1],
macros
[
i
].mac_name, 9)) {
52
break
;
53
}
54
}
55
if
(
i
==
macnum
) {
56
printf
(
"'%s' macro not found.\n"
,
argv
[1]);
57
(
void
)
fflush
(
stdout
);
58
code
= -1;
59
return
;
60
}
61
(
void
)
strcpy
(line2,
line
);
62
TOP:
63
cp1 =
macros
[
i
].mac_start;
64
while
(cp1 !=
macros
[
i
].mac_end) {
65
while
(
isspace
(*cp1)) {
66
cp1++;
67
}
68
cp2 =
line
;
69
while
(*cp1 !=
'\0'
) {
70
switch
(*cp1) {
71
case
'\\'
:
72
*cp2++ = *++cp1;
73
break
;
74
case
'$'
:
75
if
(
isdigit
(*(cp1+1))) {
76
j
= 0;
77
while
(
isdigit
(*++cp1)) {
78
j
= 10*
j
+ *cp1 -
'0'
;
79
}
80
cp1--;
81
if
(
argc
- 2 >=
j
) {
82
(
void
)
strcpy
(cp2,
argv
[
j
+1]);
83
cp2 +=
strlen
(
argv
[
j
+1]);
84
}
85
break
;
86
}
87
if
(*(cp1+1) ==
'i'
) {
88
loopflg = 1;
89
cp1++;
90
if
(
count
<
argc
) {
91
(
void
)
strcpy
(cp2,
argv
[
count
]);
92
cp2 +=
strlen
(
argv
[
count
]);
93
}
94
break
;
95
}
96
/* intentional drop through */
97
default
:
98
*cp2++ = *cp1;
99
break
;
100
}
101
if
(*cp1 !=
'\0'
) {
102
cp1++;
103
}
104
}
105
*cp2 =
'\0'
;
106
makeargv
();
107
c
=
getcmd
(
margv
[0]);
108
if
(
c
== (
struct
cmd
*)-1) {
109
printf
(
"?Ambiguous command\n"
);
110
code
= -1;
111
}
112
else
if
(
c
== 0) {
113
printf
(
"?Invalid command\n"
);
114
code
= -1;
115
}
116
else
if
(
c
->c_conn && !
connected
) {
117
printf
(
"Not connected.\n"
);
118
code
= -1;
119
}
120
else
{
121
if
(
verbose
) {
122
printf
(
"%s\n"
,
line
);
123
}
124
(*
c
->c_handler)(
margc
,
margv
);
125
if
(
bell
&&
c
->c_bell) {
126
(
void
)
putchar
(
'\007'
);
127
}
128
(
void
)
strcpy
(
line
, line2);
129
makeargv
();
130
argc
=
margc
;
131
argv
=
margv
;
132
}
133
if
(cp1 !=
macros
[
i
].mac_end) {
134
cp1++;
135
}
136
(
void
)
fflush
(
stdout
);
137
}
138
if
(loopflg && ++
count
<
argc
) {
139
goto
TOP;
140
}
141
}
argc
static int argc
Definition:
ServiceArgs.c:12
isspace
#define isspace(c)
Definition:
acclib.h:69
isdigit
#define isdigit(c)
Definition:
acclib.h:68
getcmd
struct cmd * getcmd(const char *name)
Definition:
main.c:359
makeargv
void makeargv(void)
Definition:
main.c:393
putchar
int putchar(int c)
Definition:
crtsupp.c:12
gets
char *CDECL gets(char *buf)
Definition:
file.c:4871
fflush
int CDECL fflush(FILE *file)
Definition:
file.c:1182
stdout
#define stdout
Definition:
corecrt_wstdio.h:51
strlen
_ACRTIMP size_t __cdecl strlen(const char *)
Definition:
string.c:1592
strncmp
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition:
string.c:3330
sccsid
static char sccsid[]
Definition:
domacro.c:23
domacro
void domacro(int argc, const char *argv[])
Definition:
domacro.c:26
printf
#define printf
Definition:
freeldr.h:97
margv
const char * margv[20]
Definition:
main.c:102
macnum
int macnum
Definition:
main.c:108
line
char line[200]
Definition:
main.c:97
bell
int bell
Definition:
main.c:65
macros
struct macel macros[16]
Definition:
main.c:109
connected
int connected
Definition:
main.c:61
margc
int margc
Definition:
main.c:101
count
GLuint GLuint GLsizei count
Definition:
gl.h:1545
c
const GLubyte * c
Definition:
glext.h:8905
i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition:
glfuncs.h:248
j
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition:
glfuncs.h:250
void
Definition:
nsiface.idl:2307
c
#define c
Definition:
ke_i.h:80
argv
#define argv
Definition:
mplay32.c:18
verbose
#define verbose
Definition:
rosglue.h:36
strcat
strcat
Definition:
string.h:92
strcpy
strcpy
Definition:
string.h:131
cmd
Definition:
ftp_var.h:139
code
Definition:
inflate.c:139
line
Definition:
parser.c:49
precomp.h
base
applications
network
ftp
domacro.c
Generated on Tue Jan 6 2026 06:06:16 for ReactOS by
1.9.6