ReactOS  0.4.12-dev-18-gf469aca
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.

Referenced by login().

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 }
static int argc
Definition: ServiceArgs.c:12
#define isspace(c)
Definition: acclib.h:69
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
GLuint GLuint GLsizei count
Definition: gl.h:1545
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int putchar(int c)
Definition: crtsupp.c:12
Definition: parser.c:48
#define isdigit(c)
Definition: acclib.h:68
void makeargv(void)
Definition: main.c:384
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
char line[200]
Definition: main.c:97
int connected
Definition: main.c:61
char c_conn
Definition: ftp_var.h:143
int bell
Definition: main.c:65
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
struct macel macros[16]
Definition: main.c:109
int macnum
Definition: main.c:108
char c_bell
Definition: ftp_var.h:142
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
struct cmd * getcmd(const char *name)
Definition: main.c:350
void(* c_handler)(int argc, const char *argv[])
Definition: ftp_var.h:145
#define printf
Definition: config.h:203

Variable Documentation

◆ sccsid

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

Definition at line 23 of file domacro.c.