⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crlfthru.lex

📁 伯克利做的SFTP安全文件传输协议
💻 LEX
字号:
  // crlfthru.lex  // flex input to convert CRLF to CRLF, in the context of sftpc  // copyright Scott McPeak, 1999  Terms of use are as specified in license.txt.  // (this conversion is not trivial; to get the same behavior under  // windows and unix, given the same inputs, we will do the same  // picky translation)  // ------- Flex options ------------%option noyywrap%option nounput%option outfile="crlfthru.cpp"%option prefix="crlfthru"  // --------- C++ declarations ------------  #include "crlflex.h"     // common declarations with crlf*.lex  // say what the scanner's interface is  #define YY_DECL void inner_CRLF_to_CRLF(StreamOutputDest &dest,    \                                          int &bareCRs, int &bareLFs)  #define yyterminate() return  // ---------- rules ------------%%"\r\n" {  dest.write("\r\n", 2);}"\r" {  // a bare \r isn't supposed to appear in CRLF  // text.. I choose to eat it, but not silently  bareCRs++;}"\n" {  // a bare \n isn't supposed to appear either  bareLFs++;}[^\r\n]+ {  dest.write(yytext, yyleng);}%%// ---------------- additional C++ code ---------------#include "nonport.h"    // LOCKERvoid CRLF_to_CRLF(StreamInputSource &source,                  StreamOutputDest &dest,                  int &bareCRs, int &bareLFs){  LOCKER  streamSource = &source;  inner_CRLF_to_CRLF(dest, bareCRs, bareLFs);  streamSource = NULL;}#ifdef TEST_CRLFTHRU#include "filesrc.h"      // FileInputSource, FileOutputDest#include "test.h"         // USUAL_MAINint entry(int argc, char *argv[]){  if (argc <= 2) {    printf("usage: crlfthru input-crlf-file output-crlf-file\n");    return 0;  }  FILE *in = fopen(argv[1], "rb");  FILE *out = fopen(argv[2], "wb");  if (!in || !out) {    printf("error opening one of the input files\n");    return 2;  }  FileInputSource src(in);  FileOutputDest dest(out);  int bareCRs=0, bareLFs=0;  CRLF_to_CRLF(src, dest, bareCRs, bareLFs);  printf("bareCRs=%d, bareLFs=%d\n", bareCRs, bareLFs);  fclose(in);  fclose(out);  return 0;}ARGS_MAIN#endif // TEST_CRLFTHRU

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -