1/* 2 * Copyright (c) 1985, 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 31 unchanged lines hidden (view full) --- 40 41%{ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; 46#endif 47static const char rcsid[] = |
48 "$FreeBSD: head/libexec/ftpd/ftpcmd.y 89935 2002-01-28 19:28:14Z yar $"; |
49#endif /* not lint */ 50 51#include <sys/param.h> 52#include <sys/socket.h> 53#include <sys/stat.h> 54 55#include <netinet/in.h> 56#include <arpa/ftp.h> 57 58#include <ctype.h> 59#include <errno.h> 60#include <glob.h> 61#include <netdb.h> 62#include <pwd.h> |
63#include <signal.h> 64#include <stdio.h> 65#include <stdlib.h> 66#include <string.h> 67#include <syslog.h> 68#include <time.h> 69#include <unistd.h> 70#include <libutil.h> --- 24 unchanged lines hidden (view full) --- 95extern int noretr; 96extern int noguestretr; 97 98off_t restart_point; 99 100static int cmd_type; 101static int cmd_form; 102static int cmd_bytesz; |
103static int state; |
104char cbuf[512]; 105char *fromname = (char *) 0; 106 107extern int epsvall; 108 109%} 110 111%union { --- 633 unchanged lines hidden (view full) --- 745 if ($4 != NULL) 746 free($4); 747 } 748 | QUIT CRLF 749 { 750 reply(221, "Goodbye."); 751 dologout(0); 752 } |
753 | error |
754 { |
755 yyclearin; /* discard lookahead data */ 756 yyerrok; /* clear error condition */ 757 state = 0; /* reset lexer state */ |
758 } 759 ; 760rcmd 761 : RNFR check_login_ro SP pathname CRLF 762 { 763 restart_point = (off_t) 0; 764 if ($2 && $4) { 765 if (fromname) --- 278 unchanged lines hidden (view full) --- 1044 } 1045 else 1046 $$ = check_login1(); 1047 } 1048 ; 1049 1050%% 1051 |
1052#define CMD 0 /* beginning of command */ 1053#define ARGS 1 /* expect miscellaneous arguments */ 1054#define STR1 2 /* expect SP followed by STRING */ 1055#define STR2 3 /* expect STRING */ 1056#define OSTR 4 /* optional SP then STRING */ 1057#define ZSTR1 5 /* optional SP then optional STRING */ 1058#define ZSTR2 6 /* optional STRING after SP */ 1059#define SITECMD 7 /* SITE command */ --- 188 unchanged lines hidden (view full) --- 1248 syslog(LOG_INFO, "User %s timed out after %d seconds", 1249 (pw ? pw -> pw_name : "unknown"), timeout); 1250 dologout(1); 1251} 1252 1253static int 1254yylex() 1255{ |
1256 static int cpos; |
1257 char *cp, *cp2; 1258 struct tab *p; 1259 int n; 1260 char c; 1261 1262 for (;;) { 1263 switch (state) { 1264 --- 20 unchanged lines hidden (view full) --- 1285 c = cbuf[cpos]; 1286 cbuf[cpos] = '\0'; 1287 upper(cbuf); 1288 p = lookup(cmdtab, cbuf); 1289 cbuf[cpos] = c; 1290 if (p != 0) { 1291 if (p->implemented == 0) { 1292 nack(p->name); |
1293 return (LEXERR); |
1294 } 1295 state = p->state; 1296 yylval.s = p->name; 1297 return (p->token); 1298 } 1299 break; 1300 1301 case SITECMD: --- 8 unchanged lines hidden (view full) --- 1310 cbuf[cpos] = '\0'; 1311 upper(cp); 1312 p = lookup(sitetab, cp); 1313 cbuf[cpos] = c; 1314 if (guest == 0 && p != 0) { 1315 if (p->implemented == 0) { 1316 state = CMD; 1317 nack(p->name); |
1318 return (LEXERR); |
1319 } 1320 state = p->state; 1321 yylval.s = p->name; 1322 return (p->token); 1323 } 1324 state = CMD; 1325 break; 1326 --- 133 unchanged lines hidden (view full) --- 1460 return (T); 1461 1462 } 1463 break; 1464 1465 default: 1466 fatalerror("Unknown state in scanner."); 1467 } |
1468 state = CMD; |
1469 return (LEXERR); |
1470 } 1471} 1472 1473void 1474upper(s) 1475 char *s; 1476{ 1477 while (*s != '\0') { --- 235 unchanged lines hidden --- |