From 0ef93eb0e5defae95b0fe9fddb2acdf17e190dde Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 15 Aug 2012 10:27:28 +0200 Subject: [PATCH] msvcp90: Added strstreambuf seekpos and seekoff implementation. --- dlls/msvcp90/ios.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++---- dlls/msvcp90/msvcp90.h | 6 ++--- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 78dbd673d4c..6491278ffb4 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -12714,8 +12714,53 @@ int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c) DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20) fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode) { - FIXME("(%p %p %ld %d %d) stub\n", this, ret, off, way, mode); - return NULL; + char *eback = basic_streambuf_char_eback(&this->base); + char *pptr = basic_streambuf_char_pptr(&this->base); + char *gptr = basic_streambuf_char_gptr(&this->base); + + TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode); + + ret->off = 0; + ret->state = 0; + + if(pptr > this->seekhigh) + this->seekhigh = pptr; + + if((mode & OPENMODE_in) && gptr) { + if(way==SEEKDIR_cur && !(mode & OPENMODE_out)) + off += gptr-eback; + else if(way == SEEKDIR_end) + off += this->seekhigh-eback; + else if(way != SEEKDIR_beg) + off = -1; + + if(off<0 || off>this->seekhigh-eback) { + off = -1; + }else { + basic_streambuf_char_gbump(&this->base, eback-gptr+off); + if((mode & OPENMODE_out) && pptr) { + basic_streambuf_char_setp_next(&this->base, eback, + gptr, basic_streambuf_char_epptr(&this->base)); + } + } + }else if((mode & OPENMODE_out) && pptr) { + if(way == SEEKDIR_cur) + off += pptr-eback; + else if(way == SEEKDIR_end) + off += this->seekhigh-eback; + else if(way != SEEKDIR_beg) + off = -1; + + if(off<0 || off>this->seekhigh-eback) + off = -1; + else + basic_streambuf_char_pbump(&this->base, eback-pptr+off); + }else { + off = -1; + } + + ret->pos = off; + return ret; } /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */ @@ -12723,8 +12768,14 @@ fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, str DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36) fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode) { - FIXME("(%p %p %s %d) stub\n", this, ret, debugstr_fpos_int(&pos), mode); - return NULL; + TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode); + + if(pos.off==0 && pos.pos==-1 && pos.state==0) { + *ret = pos; + return ret; + } + + return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode); } /* ?underflow@strstreambuf@std@@MAEHXZ */ diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 9343d163e8d..b91faace922 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -246,9 +246,9 @@ typedef enum { } IOSB_openmode; typedef enum { - SEEKDIR_beg = 0x1, - SEEKDIR_cur = 0x2, - SEEKDIR_end = 0x3, + SEEKDIR_beg = 0x0, + SEEKDIR_cur = 0x1, + SEEKDIR_end = 0x2, SEEKDIR_mask = 0x3 } IOSB_seekdir; -- 2.11.4.GIT