VirtualBox

source: vbox/trunk/src/bldprogs/scmstream.h@ 40528

Last change on this file since 40528 was 40528, checked in by vboxsync, 13 years ago

scm: Splitting out the SCMSTREAM bits so it can be used by others.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: scmstream.h 40528 2012-03-19 11:04:34Z vboxsync $ */
2/** @file
3 * IPRT Testcase / Tool - Source Code Massager Stream Code.
4 */
5
6/*
7 * Copyright (C) 2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___scmstream_h___
19#define ___scmstream_h___
20
21#include <iprt/types.h>
22
23RT_C_DECLS_BEGIN
24
25/** End of line marker type. */
26typedef enum SCMEOL
27{
28 SCMEOL_NONE = 0,
29 SCMEOL_LF = 1,
30 SCMEOL_CRLF = 2
31} SCMEOL;
32/** Pointer to an end of line marker type. */
33typedef SCMEOL *PSCMEOL;
34
35/**
36 * Line record.
37 */
38typedef struct SCMSTREAMLINE
39{
40 /** The offset of the line. */
41 size_t off;
42 /** The line length, excluding the LF character.
43 * @todo This could be derived from the offset of the next line if that wasn't
44 * so tedious. */
45 size_t cch;
46 /** The end of line marker type. */
47 SCMEOL enmEol;
48} SCMSTREAMLINE;
49/** Pointer to a line record. */
50typedef SCMSTREAMLINE *PSCMSTREAMLINE;
51
52/**
53 * Source code massager stream.
54 */
55typedef struct SCMSTREAM
56{
57 /** Pointer to the file memory. */
58 char *pch;
59 /** The current stream position. */
60 size_t off;
61 /** The current stream size. */
62 size_t cb;
63 /** The size of the memory pb points to. */
64 size_t cbAllocated;
65
66 /** Line records. */
67 PSCMSTREAMLINE paLines;
68 /** The current line. */
69 size_t iLine;
70 /** The current stream size given in lines. */
71 size_t cLines;
72 /** The sizeof the the memory backing paLines. */
73 size_t cLinesAllocated;
74
75 /** Set if write-only, clear if read-only. */
76 bool fWriteOrRead;
77 /** Set if the memory pb points to is from RTFileReadAll. */
78 bool fFileMemory;
79 /** Set if fully broken into lines. */
80 bool fFullyLineated;
81
82 /** Stream status code (IPRT). */
83 int rc;
84} SCMSTREAM;
85/** Pointer to a SCM stream. */
86typedef SCMSTREAM *PSCMSTREAM;
87/** Pointer to a const SCM stream. */
88typedef SCMSTREAM const *PCSCMSTREAM;
89
90
91int ScmStreamInitForReading(PSCMSTREAM pStream, const char *pszFilename);
92int ScmStreamInitForWriting(PSCMSTREAM pStream, PCSCMSTREAM pRelatedStream);
93void ScmStreamDelete(PSCMSTREAM pStream);
94int ScmStreamGetStatus(PCSCMSTREAM pStream);
95void ScmStreamRewindForReading(PSCMSTREAM pStream);
96void ScmStreamRewindForWriting(PSCMSTREAM pStream);
97bool ScmStreamIsText(PSCMSTREAM pStream);
98int ScmStreamCheckItegrity(PSCMSTREAM pStream);
99int ScmStreamWriteToFile(PSCMSTREAM pStream, const char *pszFilenameFmt, ...);
100size_t ScmStreamTell(PSCMSTREAM pStream);
101size_t ScmStreamTellLine(PSCMSTREAM pStream);
102size_t ScmStreamSize(PSCMSTREAM pStream);
103size_t ScmStreamCountLines(PSCMSTREAM pStream);
104int ScmStreamSeekAbsolute(PSCMSTREAM pStream, size_t offAbsolute);
105int ScmStreamSeekRelative(PSCMSTREAM pStream, ssize_t offRelative);
106int ScmStreamSeekByLine(PSCMSTREAM pStream, size_t iLine);
107const char *ScmStreamGetLineByNo(PSCMSTREAM pStream, size_t iLine, size_t *pcchLine, PSCMEOL penmEol);
108const char *ScmStreamGetLine(PSCMSTREAM pStream, size_t *pcchLine, PSCMEOL penmEol);
109int ScmStreamRead(PSCMSTREAM pStream, void *pvBuf, size_t cbToRead);
110bool ScmStreamIsWhiteLine(PSCMSTREAM pStream, size_t iLine);
111SCMEOL ScmStreamGetEol(PSCMSTREAM pStream);
112SCMEOL ScmStreamGetEolByLine(PSCMSTREAM pStream, size_t iLine);
113int ScmStreamPutLine(PSCMSTREAM pStream, const char *pchLine, size_t cchLine, SCMEOL enmEol);
114int ScmStreamWrite(PSCMSTREAM pStream, const char *pchBuf, size_t cchBuf);
115int ScmStreamPutCh(PSCMSTREAM pStream, char ch);
116int ScmStreamCopyLines(PSCMSTREAM pDst, PSCMSTREAM pSrc, size_t cLines);
117
118RT_C_DECLS_END
119
120#endif
121
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette