Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
chxavnextline.cpp
Package: helix.src.0812.rar [view]
Upload User: zhongxx05
Upload Date: 2007-06-06
Package Size: 33641k
Code Size: 2k
Category:
Symbian
Development Platform:
C/C++
- /*============================================================================*
- *
- * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *============================================================================*/
- #include "chxavbuffer.h"
- #include "chxavnextline.h"
- static const int InitialLineBufSize = 320;
- CHXAvNextLine::CHXAvNextLine(const CHXString& name)
- : m_name(name),
- m_pFile(0),
- m_buf(InitialLineBufSize),
- m_lineNum(0)
- {
- }
- CHXAvNextLine::~CHXAvNextLine()
- {
- Close();
- }
- bool CHXAvNextLine::Open()
- {
- m_pFile = (m_name == "") ? stdin : fopen(m_name, "r");
- return m_pFile != 0;
- }
- void CHXAvNextLine::Close()
- {
- if (m_name != "" && m_pFile)
- fclose(m_pFile);
- m_pFile = 0;
- }
- bool CHXAvNextLine::IsOpen() const
- {
- return m_pFile != 0;
- }
- bool CHXAvNextLine::Reset()
- {
- bool ret = m_pFile && fseek(m_pFile, (long) 0, SEEK_SET) != -1;
- if (ret)
- m_lineNum = 0;
- return ret;
- }
- bool CHXAvNextLine::GetLine(CHXString& line)
- {
- int len = 0;
- if (m_pFile)
- {
- if (FGetS(m_buf, m_pFile))
- {
- line = (char *)m_buf;
- len = line.GetLength();
- m_lineNum++;
- }
- }
- return len > 0;
- }
- bool CHXAvNextLine::End() const
- {
- return m_pFile == 0 || feof(m_pFile);
- }
- // replacement for system fgets that
- // looks for r or rn in addtion to n
- char* CHXAvNextLine::FGetS(CHXAvBuffer& buf, FILE* fp)
- {
- bool eol = false;
- int i = 0;
- for (i = 0; !eol; ++i)
- {
- int c = fgetc(fp);
- if (c == EOF)
- break;
- // Make sure the buffer is large enough
- buf.Resize(i + 2);
- ((char*)buf)[i] = c;
- if (c == 'n')
- eol = true;
- else if (c == 'r')
- {
- eol = true;
- // check for n and eat it
- if ((c = fgetc(fp)) == 'n')
- ((char*)buf)[++i] = c;
- else if (c != EOF)
- ungetc(c, fp);
- else
- break;
- }
- }
- if (buf.MaxLength() > 0)
- ((char*)buf)[i] = '';
- return (i == 0 ? 0 : (char*)buf);
- }