ReactOS 0.4.15-dev-5669-g09dde2c
domacro.c File Reference
#include "precomp.h"
Include dependency graph for domacro.c:

Go to the source code of this file.

Functions

void domacro (int argc, const char *argv[])
 

Variables

static char sccsid [] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89"
 

Function Documentation

◆ domacro()

void domacro ( int  argc,
const char argv[] 
)

Definition at line 26 of file domacro.c.

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) ");
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]);
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]);
58 code = -1;
59 return;
60 }
61 (void) strcpy(line2, line);
62TOP:
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}
static int argc
Definition: ServiceArgs.c:12
#define isspace(c)
Definition: acclib.h:69
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define isdigit(c)
Definition: acclib.h:68
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
struct cmd * getcmd(const char *name)
Definition: main.c:359
void makeargv(void)
Definition: main.c:393
int putchar(int c)
Definition: crtsupp.c:12
#define printf
Definition: freeldr.h:94
const char * margv[20]
Definition: main.c:102
int macnum
Definition: main.c:108
char line[200]
Definition: main.c:97
int bell
Definition: main.c:65
struct macel macros[16]
Definition: main.c:109
int connected
Definition: main.c:61
int margc
Definition: main.c:101
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
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
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
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define c
Definition: ke_i.h:80
#define argv
Definition: mplay32.c:18
#define verbose
Definition: rosglue.h:36
Definition: ftp_var.h:139
Definition: inflate.c:139
Definition: parser.c:49

Referenced by login().

Variable Documentation

◆ sccsid

char sccsid[] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89"
static

Definition at line 23 of file domacro.c.