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

📄 oporttofile.cpp

📁 1、简介 此代码是IS0 13818-5 MPEG2系统层协议分析代码
💻 CPP
字号:
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved. * *   Usage Restrictions * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes only. * *   Disclaimer of Warranty * * These software programs are available to the user without any license * fee or royalty on an "as is" basis.  Tektronix Inc. disclaims any and * all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose.  In no event shall the copyright-holder be liable for any  * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and * user's customers, employees, agents, transferees, successors, and * assigns. * * The Tektronix Inc. does not represent or warrant that the programs * furnished hereunder are free of infringement of any third-party * patents.*//* OPortToFile implementation */#include "OPortToFile.H"#include "Utilities.H"/*extern "C"{int read (int, char*, int);int write (int, char*, int);int close (int);}*/
OPortToFile::OPortToFile (char* f, int tf) : OutputPort(tf){//  fd = open(f, O_CREAT | O_RDWR | O_TRUNC, 0666);
  fd = _open(f, O_CREAT | O_RDWR | O_TRUNC, 0666);  assert(fd);  next_out = 0;  bufpos = 0;}OPortToFile::~OPortToFile(){  write(fd, fbuf, bufpos);  close(fd);}void OPortToFile::output_bit (char b){  buf[next_out] = b;  next_out++;  if (next_out > 7)    {      output_byte();      next_out = 0;    }}void OPortToFile::output_byte (char b){  int result;  if (next_out != 0)    {      sys_error("not on byte boundary in output_byte");    }  fbuf[bufpos++] = b;  if (bufpos == CacheSize)  {    result = write(fd, fbuf, CacheSize);    bufpos = 0;  }}     void OPortToFile::output_flush (){  int result = write(fd, fbuf, bufpos);  bufpos = 0;}char inline bit (char c){  return (c == '0') ? ((char) 0) : ((char) 1);}void OPortToFile::output_byte (){  int result;  for (int i = 0; i < 8 - next_out; i++) write_bit('0');    if (textflag)	  result = write(fd, buf, 8);  else    {      char b =	bit(buf[0]) << 7 |	  bit(buf[1]) << 6 |	    bit(buf[2]) << 5 |	      bit(buf[3]) << 4 |		bit(buf[4]) << 3 |		  bit(buf[5]) << 2 |		    bit(buf[6]) << 1 |		      bit(buf[7]) << 0;      fbuf[bufpos++] = b;      if (bufpos == CacheSize)        {	  write(fd, fbuf, CacheSize);	  bufpos = 0;        }    }}

⌨️ 快捷键说明

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