/* imapd/scan_imap_command.i */ /* This file is part of Decimail; see http://decimail.org */ /* (C) 2004-2017 Philip Endecott */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */ /* USA. */ %{ #include "ScannerExtra.hh" #include #include "commands.hh" #include "Configuration.hh" #include "parse_imap_command.tab.h" #include #define YY_INPUT(buf,result,max_size) \ { \ /*assert(max_size<=SSIZE_MAX);*/ \ int n = yyextra->session.get_in_fd().read(buf,max_size-1); \ if (n>=0) { \ result=n; \ buf[n]='\0'; \ if (Configuration::singleton().get_bool("imapd_log_imap",false)) { \ syslog(LOG_MAIL|LOG_DEBUG,"{%d} C: %s",yyextra->session.num,buf); \ } \ } else { \ throw pbe::ErrnoException("read(in_fd)"); \ } \ } %} %option reentrant %option case-insensitive %option bison-bridge %option prefix="scan_imap_command_" %option header-file="scan_imap_command.h" %option outfile="scan_imap_command.c" %option nodefault %option noyywrap %option always-interactive %option debug %option nounput %x QS %x ATM %% if(yyextra->start_atom) { BEGIN(ATM); yyextra->start_atom=0; } \r\n BEGIN(INITIAL); return CRLF; \n BEGIN(INITIAL); return CRLF; /* Not per protocol, but we'll excuse it */ <> return END_OF_FILE; \" BEGIN(QS); yylval->str = new std::string; [^\\"\r\n]* yylval->str->append(yytext); \\\\ yylval->str->append(1,'\\'); \\\" yylval->str->append(1,'"'); \" BEGIN(INITIAL); return QUOTED; <> BEGIN(INITIAL); return UNTERMINATED_STRING; [\\\n] BEGIN(INITIAL); return ILLEGAL; \% BEGIN(INITIAL); return PERCENT; \* BEGIN(INITIAL); return STAR; INBOX BEGIN(INITIAL); return KW_INBOX; [^(){ \0-\x1f\x7f%*"\\]+ yylval->str = new std::string(yytext); BEGIN(INITIAL); return ATOM; . BEGIN(INITIAL); return ILLEGAL; \+ return PLUS; \- return MINUS; \( return LPAREN; \) return RPAREN; \< return LANGLE; \> return RANGLE; \[ return LBRACKET; \] return RBRACKET; \. return DOT; \: return COLON; \, return COMMA; \\ return BACKSLASH; \ return SPACE; [0-9] yylval->chr = yytext[0]; return DIGIT; \{[0-9]+\}\r?\n { yyextra->send_continuation_request(); int n = atoi(yytext+1); std::string* s = new std::string; for(int i=0; istr = s; BEGIN(INITIAL); return LITERAL; } ALL return KW_ALL; ANSWERED return KW_ANSWERED; APPEND return KW_APPEND; AUTHENTICATE return KW_AUTHENTICATE; BCC return KW_BCC; BEFORE return KW_BEFORE; BODY return KW_BODY; CAPABILITY return KW_CAPABILITY; CC return KW_CC; CHARSET return KW_CHARSET; CHECK return KW_CHECK; CLOSE return KW_CLOSE; COPY return KW_COPY; CREATE return KW_CREATE; DELETE return KW_DELETE; DELETED return KW_DELETED; DRAFT return KW_DRAFT; ENVELOPE return KW_ENVELOPE; EXAMINE return KW_EXAMINE; EXPUNGE return KW_EXPUNGE; FAST return KW_FAST; FETCH return KW_FETCH; FIELDS return KW_FIELDS; FLAGGED return KW_FLAGGED; FLAGS return KW_FLAGS; FULL return KW_FULL; FROM return KW_FROM; HEADER return KW_HEADER; IDLE return KW_IDLE; INTERNALDATE return KW_INTERNALDATE; KEYWORD return KW_KEYWORD; LARGER return KW_LARGER; LIST return KW_LIST; LOGIN return KW_LOGIN; LOGOUT return KW_LOGOUT; LSUB return KW_LSUB; MESSAGES return KW_MESSAGES; MIME return KW_MIME; NEW return KW_NEW; NOOP return KW_NOOP; NOT return KW_NOT; OLD return KW_OLD; ON return KW_ON; OR return KW_OR; PEEK return KW_PEEK; RECENT return KW_RECENT; RENAME return KW_RENAME; RFC822 return KW_RFC822; SEARCH return KW_SEARCH; SEEN return KW_SEEN; SELECT return KW_SELECT; SENTBEFORE return KW_SENTBEFORE; SENTON return KW_SENTON; SENTSINCE return KW_SENTSINCE; SILENT return KW_SILENT; SINCE return KW_SINCE; SIZE return KW_SIZE; SMALLER return KW_SMALLER; STATUS return KW_STATUS; STORE return KW_STORE; STRUCTURE return KW_STRUCTURE; SUBSCRIBE return KW_SUBSCRIBE; SUBJECT return KW_SUBJECT; TEXT return KW_TEXT; TO return KW_TO; UID return KW_UID; UIDNEXT return KW_UIDNEXT; UIDVALIDITY return KW_UIDVALIDITY; UNANSWERED return KW_UNANSWERED; UNDELETED return KW_UNDELETED; UNDRAFT return KW_UNDRAFT; UNFLAGGED return KW_UNFLAGGED; UNKEYWORD return KW_UNKEYWORD; UNSEEN return KW_UNSEEN; UNSUBSCRIBE return KW_UNSUBSCRIBE; XCOMPLETE return KW_XCOMPLETE; JAN return KW_JAN; FEB return KW_FEB; MAR return KW_MAR; APR return KW_APR; MAY return KW_MAY; JUN return KW_JUN; JUL return KW_JUL; AUG return KW_AUG; SEP return KW_SEP; OCT return KW_OCT; NOV return KW_NOV; DEC return KW_DEC; <*>. return ILLEGAL; %%