~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/mod_gsoap/gsoap_win/isapi/gsoap/.svn/text-base/isapistream.cpp.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** Implementation of the isapistream class.
2
 
  * @file isapistream.cpp
3
 
  * @author Christian Aberger 
4
 
  * Copyright (C) 2001 WebWare (http://www.webware.at) 
5
 
  */
6
 
#include "isapistream.h"
7
 
#include <cassert>
8
 
using namespace std;
9
 
 
10
 
isapistreambuf::isapistreambuf(EXTENSION_CONTROL_BLOCK *pECB)
11
 
: _pECB(pECB) 
12
 
{
13
 
    static const int nMinBufSize = 1024;
14
 
    assert(NULL != pECB);
15
 
    setp(_obuf, _obuf + sizeof _obuf);
16
 
 
17
 
    _cbTotalBytes = pECB->cbTotalBytes;
18
 
    _ibuflen = pECB->cbAvailable > nMinBufSize ? pECB->cbAvailable : nMinBufSize;
19
 
    _ibuf = new char[_ibuflen + 1]; // we allocate it one byte more, adding a trailing '\0', then it is easier with strings
20
 
    memset(_ibuf, 0, _ibuflen + 1);
21
 
    memcpy(_ibuf, pECB->lpbData, pECB->cbAvailable);
22
 
    _cbRead = pECB->cbAvailable;
23
 
    setg(_ibuf, _ibuf, _ibuf + _cbRead);
24
 
}
25
 
isapistreambuf::~isapistreambuf() {
26
 
    delete _ibuf;
27
 
}
28
 
int isapistreambuf::sync() {
29
 
        BOOL bWrite = TRUE;
30
 
        if (NULL != _pECB) {
31
 
                DWORD dwBytesWritten = pptr() - pbase();
32
 
                if (dwBytesWritten) {
33
 
                        bWrite = _pECB->WriteClient(_pECB->ConnID, (PVOID)_obuf, &dwBytesWritten, 0);
34
 
                        setp(_obuf, _obuf + sizeof _obuf);
35
 
                }
36
 
        }
37
 
        return bWrite ? 0 : -1;
38
 
}
39
 
int isapistreambuf::overflow(int ch) {
40
 
    if (char_traits<char>::eof() == ch) {
41
 
        return streambuf::overflow(ch);
42
 
    }
43
 
    if (pptr() < epptr()) {
44
 
        return sputc(ch);
45
 
    }
46
 
    int ret = sync();
47
 
    if (0 == ret && char_traits<char>::eof() != ch) {
48
 
        sputc(ch);
49
 
    }
50
 
    return ret;
51
 
}
52
 
int isapistreambuf::underflow() {
53
 
    int retval = char_traits<char>::eof();
54
 
    if (gptr() < egptr()) {
55
 
        //retval = snextc();
56
 
                retval = sgetc();
57
 
    } else {
58
 
        if (_cbRead < _cbTotalBytes) {
59
 
            memset(_ibuf, 0, _ibuflen + 1);
60
 
            DWORD dwLen = _ibuflen;
61
 
            BOOL bRead = (*_pECB->ReadClient)(_pECB->ConnID, _ibuf, &dwLen);
62
 
            if (bRead && dwLen > 0) {
63
 
                _cbRead += dwLen;
64
 
                setg(_ibuf, _ibuf, _ibuf + dwLen);
65
 
                //retval = snextc();
66
 
                                retval = sgetc();
67
 
            }
68
 
        }
69
 
    }
70
 
    return retval;
71
 
}
72
 
isapistream::~isapistream() {
73
 
}
74
 
EXTENSION_CONTROL_BLOCK *isapistreambuf::ECB() {
75
 
    return _pECB;
76
 
}
77
 
EXTENSION_CONTROL_BLOCK *isapistream::ECB() {
78
 
    return _buf.ECB();
79
 
}
80