From a33d9f4d7a1bf4bd4ab286f69af322b5b8d7c946 Mon Sep 17 00:00:00 2001 From: Eric Gillespie Date: Fri, 8 Aug 2008 23:45:24 +0000 Subject: [PATCH] * sbr/discard.c, sbr/m_getfld.c, uip/scansbr.c: Add support for DragonFlyBSD stdio (from NetBSD pkgsrc). --- ChangeLog | 5 +++++ sbr/discard.c | 2 +- sbr/m_getfld.c | 34 ++++++++++++++++++++++++++++++++++ uip/scansbr.c | 6 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7dc5491..0b0c883 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-08 Eric Gillespie + + * sbr/discard.c, sbr/m_getfld.c, uip/scansbr.c: Add support for + DragonFlyBSD stdio (from NetBSD pkgsrc). + 2008-08-05 Eric Gillespie * uip/folder.c: chdir(nmhdir) in main rather than in dodir, which diff --git a/sbr/discard.c b/sbr/discard.c index 7c132ce..55c160b 100644 --- a/sbr/discard.c +++ b/sbr/discard.c @@ -55,7 +55,7 @@ discard (FILE *io) # endif #endif -#ifdef _FSTDIO +#if defined(_FSTDIO) || defined(__DragonFly__) fpurge (io); #else # ifdef LINUX_STDIO diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 59b8682..c542d52 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -266,6 +266,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, bp = sp = (unsigned char *) iob->_IO_read_ptr - 1; j = (cnt = ((long) iob->_IO_read_end - (long) iob->_IO_read_ptr) + 1) < i ? cnt : i; +#elif defined(__DragonFly__) + bp = sp = (unsigned char *) ((struct __FILE_public *)iob)->_p - 1; + j = (cnt = ((struct __FILE_public *)iob)->_r+1) < i ? cnt : i; #else bp = sp = (unsigned char *) iob->_ptr - 1; j = (cnt = iob->_cnt+1) < i ? cnt : i; @@ -278,6 +281,8 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, #ifdef LINUX_STDIO iob->_IO_read_ptr = iob->_IO_read_end; if (__underflow(iob) == EOF) { +#elif defined(__DragonFly__) + if (__srget(iob) == EOF) { #else if (_filbuf(iob) == EOF) { #endif @@ -291,6 +296,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, } else { #ifdef LINUX_STDIO iob->_IO_read_ptr = bp + 1; +#elif defined(__DragonFly__) + ((struct __FILE_public *)iob)->_p = bp + 1; + ((struct __FILE_public *)iob)->_r = cnt - 1; #else iob->_ptr = bp + 1; iob->_cnt = cnt - 1; @@ -335,6 +343,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, #ifdef LINUX_STDIO cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr; bp = (unsigned char *) --iob->_IO_read_ptr; +#elif defined(__DragonFly__) + cnt = ((struct __FILE_public *)iob)->_r++; + bp = (unsigned char *) --((struct __FILE_public *)iob)->_p; #else cnt = iob->_cnt++; bp = (unsigned char *) --iob->_ptr; @@ -349,6 +360,11 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, j = ep - (unsigned char *) iob->_IO_read_ptr; memcpy (cp, iob->_IO_read_ptr, j); iob->_IO_read_ptr = ep; +#elif defined(__DragonFly__) + j = ep - (unsigned char *) ((struct __FILE_public *)iob)->_p; + memcpy (cp, ((struct __FILE_public *)iob)->_p, j); + ((struct __FILE_public *)iob)->_p = ep; + ((struct __FILE_public *)iob)->_r -= j; #else j = ep - (unsigned char *) iob->_ptr; memcpy (cp, iob->_ptr, j); @@ -368,6 +384,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, #ifdef LINUX_STDIO c += bp - (unsigned char *) iob->_IO_read_ptr; memcpy( cp, iob->_IO_read_ptr, c); +#elif defined(__DragonFly__) + c += bp - (unsigned char *) ((struct __FILE_public *)iob)->_p; + memcpy( cp, ((struct __FILE_public *)iob)->_p, c); #else c += bp - (unsigned char *) iob->_ptr; memcpy( cp, iob->_ptr, c); @@ -378,6 +397,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, /* the dest buffer is full */ #ifdef LINUX_STDIO iob->_IO_read_ptr += c; +#elif defined(__DragonFly__) + ((struct __FILE_public *)iob)->_r -= c; + ((struct __FILE_public *)iob)->_p += c; #else iob->_cnt -= c; iob->_ptr += c; @@ -397,6 +419,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, iob->_IO_read_ptr = iob->_IO_read_end; c = __underflow(iob); iob->_IO_read_ptr++; /* NOT automatic! */ +#elif defined(__DragonFly__) + *cp++ =j = *(((struct __FILE_public *)iob)->_p + c); + c = __srget(iob); #else *cp++ = j = *(iob->_ptr + c); c = _filbuf(iob); @@ -406,6 +431,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, if (c != EOF) { #ifdef LINUX_STDIO --iob->_IO_read_ptr; +#elif defined(__DragonFly__) + --((struct __FILE_public *)iob)->_p; + ++((struct __FILE_public *)iob)->_r; #else --iob->_ptr; ++iob->_cnt; @@ -429,6 +457,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, #ifdef LINUX_STDIO bp = (unsigned char *) --iob->_IO_read_ptr; cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr; +#elif defined(__DragonFly__) + bp = (unsigned char *) --((struct __FILE_public *)iob)->_p; + cnt = ++((struct __FILE_public *)iob)->_r; #else bp = (unsigned char *) --iob->_ptr; cnt = ++iob->_cnt; @@ -491,6 +522,9 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, memcpy( buf, bp, c ); #ifdef LINUX_STDIO iob->_IO_read_ptr += c; +#elif defined(__DragonFly__) + ((struct __FILE_public *)iob)->_r -= c; + ((struct __FILE_public *)iob)->_p += c; #else iob->_cnt -= c; iob->_ptr += c; diff --git a/uip/scansbr.c b/uip/scansbr.c index 6a9278b..df18258 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -256,6 +256,8 @@ body:; while (state == BODY) { #ifdef LINUX_STDIO if (scnout->_IO_write_ptr == scnout->_IO_write_end) { +#elif defined(__DragonFly__) + if (((struct __FILE_public *)scnout)->_w <= 0) { #else if (scnout->_cnt <= 0) { #endif @@ -266,6 +268,10 @@ body:; state = m_getfld(state, name, scnout->_IO_write_ptr, (long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end , inb); scnout->_IO_write_ptr += msg_count; +#elif defined(__DragonFly__) + state = m_getfld( state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb ); + ((struct __FILE_public *)scnout)->_w -= msg_count; + ((struct __FILE_public *)scnout)->_p += msg_count; #else state = m_getfld( state, name, scnout->_ptr, -(scnout->_cnt), inb ); scnout->_cnt -= msg_count; -- 1.7.10.4