add iob_free and man page for iob_reset.

check in some windoze compat crap (still does not compile through for
windoze)
This commit is contained in:
leitner
2005-03-08 14:56:36 +00:00
parent e73c3e85f1
commit 9eb09b5bfe
21 changed files with 184 additions and 14 deletions

View File

@@ -1,13 +1,22 @@
#include <buffer.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef __MINGW32__
#include <windows.h>
#else
#include <sys/mman.h>
#endif
void buffer_close(buffer* b) {
if (b->fd != -1) close(b->fd);
switch (b->todo) {
case FREE: free(b->x); break;
case MUNMAP: munmap(b->x,b->a); break;
case MUNMAP:
#ifdef __MINGW32__
UnmapViewOfFile(b->x);
#else
munmap(b->x,b->a); break;
#endif
default: ;
}
}

View File

@@ -1,6 +1,15 @@
#include <stdarg.h>
#include <sys/types.h>
#ifdef __MINGW32__
#include "windows.h"
struct iovec {
LPCVOID iov_base;
DWORD iov_len;
};
#else
#include <sys/uio.h>
#endif
#include "errmsg.h"
#include "str.h"

View File

@@ -1,6 +1,16 @@
#include <stdarg.h>
#include <sys/types.h>
#ifdef __MINGW32__
#include "windows.h"
#include <unistd.h>
struct iovec {
LPCVOID iov_base;
DWORD iov_len;
};
#else
#include <sys/uio.h>
#endif
#include "errmsg.h"
#include "str.h"
@@ -10,6 +20,15 @@ void errmsg_info(const char* message, ...) {
struct iovec x[23];
va_list a;
va_start(a,message);
#ifdef __MINGW32__
{
int i,j;
j=errmsg_cvt(x,message,a);
for (i=0; i<j; ++i)
write(1,x[i].iov_base,x[i].iov_len);
}
#else
writev(1,x,errmsg_cvt(x,message,a));
#endif
va_end(a);
}

View File

@@ -1,12 +1,10 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "errmsg.h"
#include "str.h"
#include <string.h>
#include <errno.h>
extern int errmsg_cvt(struct iovec* x,const char* message, va_list a);
extern void errmsg_writesys(int fd,const char* message,va_list list);
void errmsg_infosys(const char* message, ...) {

View File

@@ -1,6 +1,16 @@
#include <stdarg.h>
#include <sys/types.h>
#ifdef __MINGW32__
#include "windows.h"
#include <unistd.h>
struct iovec {
LPCVOID iov_base;
DWORD iov_len;
};
#else
#include <sys/uio.h>
#endif
#include "errmsg.h"
#include "str.h"
@@ -10,6 +20,15 @@ void errmsg_warn(const char* message, ...) {
struct iovec x[23];
va_list a;
va_start(a,message);
#ifdef __MINGW32__
{
int i,j;
j=errmsg_cvt(x,message,a);
for (i=0; i<j; ++i)
write(2,x[i].iov_base,x[i].iov_len);
}
#else
writev(2,x,errmsg_cvt(x,message,a));
#endif
va_end(a);
}

View File

@@ -1,12 +1,10 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "errmsg.h"
#include "str.h"
#include <string.h>
#include <errno.h>
extern int errmsg_cvt(struct iovec* x,const char* message, va_list a);
extern void errmsg_writesys(int fd,const char* message,va_list list);
void errmsg_warnsys(const char* message, ...) {

View File

@@ -1,6 +1,16 @@
#include <stdarg.h>
#include <sys/types.h>
#ifdef __MINGW32__
#include "windows.h"
#include <unistd.h>
struct iovec {
LPCVOID iov_base;
DWORD iov_len;
};
#else
#include <sys/uio.h>
#endif
#include "errmsg.h"
#include "str.h"
#include <string.h>
@@ -22,5 +32,13 @@ void errmsg_writesys(int fd,const char* message,va_list list) {
x[i+1].iov_base="\n";
x[i+1].iov_len=1;
#ifdef __MINGW32__
{
int j;
for (j=0; j<i+2; ++j)
write(2,x[j].iov_base,x[j].iov_len);
}
#else
writev(2,x,i+2);
#endif
}