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

📄 memsrc.cpp

📁 伯克利做的SFTP安全文件传输协议
💻 CPP
字号:
// memsrc.cc// code for memsrc.h// copyright SafeTP Development Group, Inc., 2000  Terms of use are as specified in license.txt#include "memsrc.h"      // this module#include <string.h>      // memcpy#include "xassert.h"     // xassert#include "typ.h"         // SELFCHECK, min//#define min(a,b) ((a)<(b)?(a):(b))MemoryInputSource::MemoryInputSource(char const *D, int L)  : data(D),    dataLen(L),    next(D){  selfCheck();    // check ctor arguments}// check invariantsvoid MemoryInputSource::selfCheck() const{  xassert(data != NULL &&          dataLen >= 0 &&          0 <= (next-data) &&               (next-data) <= dataLen);}int MemoryInputSource::read(char *buffer, int bufLen){  SELFCHECK();  // compute # of bytes to copy  int rem = remaining();  int supply = mymin(rem, bufLen);  // copy bytes  if (supply > 0) {    memcpy(buffer, next, supply);    // consume bytes    next += supply;  }  SELFCHECK();  return supply;}int MemoryInputSource::remaining() const{  return dataLen - (next-data);}

⌨️ 快捷键说明

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