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:
parent
e73c3e85f1
commit
9eb09b5bfe
1
CHANGES
1
CHANGES
@ -6,6 +6,7 @@
|
|||||||
' '; needed for web servers, so they can serve libstdc++.tar.gz)
|
' '; needed for web servers, so they can serve libstdc++.tar.gz)
|
||||||
fix iob_write to handle failure properly
|
fix iob_write to handle failure properly
|
||||||
document that the iob_write callback should limit itself
|
document that the iob_write callback should limit itself
|
||||||
|
add iob_free, add man pages for iob_free and iob_reset
|
||||||
|
|
||||||
0.21:
|
0.21:
|
||||||
errno cleanup and man page updates (Rolf Eike Beer)
|
errno cleanup and man page updates (Rolf Eike Beer)
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
#include <buffer.h>
|
#include <buffer.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void buffer_close(buffer* b) {
|
void buffer_close(buffer* b) {
|
||||||
if (b->fd != -1) close(b->fd);
|
if (b->fd != -1) close(b->fd);
|
||||||
switch (b->todo) {
|
switch (b->todo) {
|
||||||
case FREE: free(b->x); break;
|
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: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
struct iovec {
|
||||||
|
LPCVOID iov_base;
|
||||||
|
DWORD iov_len;
|
||||||
|
};
|
||||||
|
#else
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.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>
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
@ -10,6 +20,15 @@ void errmsg_info(const char* message, ...) {
|
|||||||
struct iovec x[23];
|
struct iovec x[23];
|
||||||
va_list a;
|
va_list a;
|
||||||
va_start(a,message);
|
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));
|
writev(1,x,errmsg_cvt(x,message,a));
|
||||||
|
#endif
|
||||||
va_end(a);
|
va_end(a);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/uio.h>
|
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.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);
|
extern void errmsg_writesys(int fd,const char* message,va_list list);
|
||||||
|
|
||||||
void errmsg_infosys(const char* message, ...) {
|
void errmsg_infosys(const char* message, ...) {
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.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>
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
@ -10,6 +20,15 @@ void errmsg_warn(const char* message, ...) {
|
|||||||
struct iovec x[23];
|
struct iovec x[23];
|
||||||
va_list a;
|
va_list a;
|
||||||
va_start(a,message);
|
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));
|
writev(2,x,errmsg_cvt(x,message,a));
|
||||||
|
#endif
|
||||||
va_end(a);
|
va_end(a);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/uio.h>
|
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.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);
|
extern void errmsg_writesys(int fd,const char* message,va_list list);
|
||||||
|
|
||||||
void errmsg_warnsys(const char* message, ...) {
|
void errmsg_warnsys(const char* message, ...) {
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.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>
|
#include <sys/uio.h>
|
||||||
|
#endif
|
||||||
#include "errmsg.h"
|
#include "errmsg.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include <string.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_base="\n";
|
||||||
x[i+1].iov_len=1;
|
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);
|
writev(2,x,i+2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include "io_internal.h"
|
#include "io_internal.h"
|
||||||
|
|
||||||
void io_close(int64 d) {
|
void io_close(int64 d) {
|
||||||
@ -10,7 +14,12 @@ void io_close(int64 d) {
|
|||||||
io_dontwantread(d);
|
io_dontwantread(d);
|
||||||
io_dontwantwrite(d);
|
io_dontwantwrite(d);
|
||||||
if (e->mmapped) {
|
if (e->mmapped) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
UnmapViewOfFile(e->mmapped);
|
||||||
|
CloseHandle(e->mh);
|
||||||
|
#else
|
||||||
munmap(e->mmapped,e->maplen);
|
munmap(e->mmapped,e->maplen);
|
||||||
|
#endif
|
||||||
e->mmapped=0;
|
e->mmapped=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,9 @@ int io_fd(int64 d) {
|
|||||||
if (!(e=array_allocate(&io_fds,sizeof(io_entry),d))) return 0;
|
if (!(e=array_allocate(&io_fds,sizeof(io_entry),d))) return 0;
|
||||||
byte_zero(e,sizeof(io_entry));
|
byte_zero(e,sizeof(io_entry));
|
||||||
e->inuse=1;
|
e->inuse=1;
|
||||||
#ifndef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
e->mh=0;
|
||||||
|
#else
|
||||||
if (r&O_NDELAY) e->nonblock=1;
|
if (r&O_NDELAY) e->nonblock=1;
|
||||||
#endif
|
#endif
|
||||||
e->next_read=e->next_write=-1;
|
e->next_read=e->next_write=-1;
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
#include <iob.h>
|
#include <iob.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BUFSIZE 16384
|
#define BUFSIZE 16384
|
||||||
|
|
||||||
@ -14,19 +18,33 @@ int64 io_mmapwritefile(int64 out,int64 in,uint64 off,uint64 bytes,io_write_callb
|
|||||||
if (e) {
|
if (e) {
|
||||||
const char* c;
|
const char* c;
|
||||||
long left;
|
long left;
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (!e->mh) e->mh=CreateFileMapping(out,0,PAGE_READONLY,0,0,NULL);
|
||||||
|
if (!e->mh) goto readwrite;
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
if (e->mmapped) {
|
if (e->mmapped) {
|
||||||
/* did we already map the right chunk? */
|
/* did we already map the right chunk? */
|
||||||
if (off>=e->mapofs && off<e->mapofs+e->maplen)
|
if (off>=e->mapofs && off<e->mapofs+e->maplen)
|
||||||
goto mapok; /* ok; mmapped the right chunk*/
|
goto mapok; /* ok; mmapped the right chunk*/
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
UnmapViewOfFile(e->mmapped);
|
||||||
|
#else
|
||||||
munmap(e->mmapped,e->maplen);
|
munmap(e->mmapped,e->maplen);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
e->mapofs=off&0xffffffffffff0000ull;
|
e->mapofs=off&0xffffffffffff0000ull;
|
||||||
if (e->mapofs+0x10000>off+bytes)
|
if (e->mapofs+0x10000>off+bytes)
|
||||||
e->maplen=off+bytes-e->mapofs;
|
e->maplen=off+bytes-e->mapofs;
|
||||||
else
|
else
|
||||||
e->maplen=0x10000;
|
e->maplen=0x10000;
|
||||||
if ((e->mmapped=mmap(0,e->maplen,PROT_READ,MAP_SHARED,in,e->mapofs))==MAP_FAILED) {
|
#ifdef __MINGW32__
|
||||||
|
if ((e->mmapped=MapViewOfFile(e->mh,FILE_MAP_READ,(DWORD)(e->mapofs>>32),
|
||||||
|
(DWORD)e->mapofs,e->maplen))==0)
|
||||||
|
#else
|
||||||
|
if ((e->mmapped=mmap(0,e->maplen,PROT_READ,MAP_SHARED,in,e->mapofs))==MAP_FAILED)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
e->mmapped=0;
|
e->mmapped=0;
|
||||||
goto readwrite;
|
goto readwrite;
|
||||||
}
|
}
|
||||||
@ -40,7 +58,11 @@ int64 io_mmapwritefile(int64 out,int64 in,uint64 off,uint64 bytes,io_write_callb
|
|||||||
e->canwrite=0;
|
e->canwrite=0;
|
||||||
e->next_write=-1;
|
e->next_write=-1;
|
||||||
if (errno!=EAGAIN) {
|
if (errno!=EAGAIN) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
UnmapViewOfFile(e->mmapped);
|
||||||
|
#else
|
||||||
munmap(e->mmapped,e->maplen);
|
munmap(e->mmapped,e->maplen);
|
||||||
|
#endif
|
||||||
e->mmapped=0;
|
e->mmapped=0;
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -55,7 +77,11 @@ int64 io_mmapwritefile(int64 out,int64 in,uint64 off,uint64 bytes,io_write_callb
|
|||||||
}
|
}
|
||||||
} while (bytes);
|
} while (bytes);
|
||||||
if (e->mmapped) {
|
if (e->mmapped) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
UnmapViewOfFile(e->mmapped);
|
||||||
|
#else
|
||||||
munmap(e->mmapped,e->maplen);
|
munmap(e->mmapped,e->maplen);
|
||||||
|
#endif
|
||||||
e->mmapped=0;
|
e->mmapped=0;
|
||||||
}
|
}
|
||||||
return sent;
|
return sent;
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
#ifdef __MINGW32__
|
||||||
|
#include "io_internal.h"
|
||||||
|
#include <errno.h>
|
||||||
|
int io_passfd(int64 sock,int64 fd) {
|
||||||
|
errno=EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -40,3 +49,4 @@ int io_passfd(int64 sock,int64 fd) {
|
|||||||
#endif
|
#endif
|
||||||
return sendmsg(sock,&msg,0)>=0?0:-1;
|
return sendmsg(sock,&msg,0)>=0?0:-1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <errno.h>
|
||||||
|
#include "io_internal.h"
|
||||||
|
int64 io_receivefd(int64 sock) {
|
||||||
|
errno=EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -60,3 +69,4 @@ int64 io_receivefd(int64 sock) {
|
|||||||
return fd;
|
return fd;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
/* this is an internal function, called by io_trywrite and io_waitwrite */
|
/* this is an internal function, called by io_trywrite and io_waitwrite */
|
||||||
|
|
||||||
void io_sigpipe(void) {
|
void io_sigpipe(void) {
|
||||||
|
#ifndef __MINGW32__
|
||||||
static int isitdone;
|
static int isitdone;
|
||||||
if (!isitdone) {
|
if (!isitdone) {
|
||||||
signal(SIGPIPE,SIG_IGN);
|
signal(SIGPIPE,SIG_IGN);
|
||||||
isitdone=1;
|
isitdone=1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifndef __MINGW32__
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#include "windoze.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "io_internal.h"
|
#include "io_internal.h"
|
||||||
|
|
||||||
int io_socketpair(int64* d) {
|
int io_socketpair(int64* d) {
|
||||||
int fds[2];
|
int fds[2];
|
||||||
|
__winsock_init();
|
||||||
if (socketpair(AF_UNIX,SOCK_STREAM,0,fds)==-1)
|
if (socketpair(AF_UNIX,SOCK_STREAM,0,fds)==-1)
|
||||||
if (socketpair(AF_INET6,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
if (socketpair(AF_INET6,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
||||||
if (socketpair(AF_INET,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
if (socketpair(AF_INET,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
||||||
|
13
io/iob_free.3
Normal file
13
io/iob_free.3
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.TH iob_free 3
|
||||||
|
.SH NAME
|
||||||
|
iob_free \- free an I/O batch
|
||||||
|
.SH SYNTAX
|
||||||
|
.B #include <iob.h>
|
||||||
|
|
||||||
|
void \fBiob_free\fP(io_batch* b);
|
||||||
|
.SH DESCRIPTION
|
||||||
|
iob_free frees all resources associated with \fIb\fR. Calling iob_free
|
||||||
|
is equivalent to calling iob_reset and free.
|
||||||
|
avoiding unnecessary copying (using writev).
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
iob_new(3), iob_reset(3)
|
7
io/iob_free.c
Normal file
7
io/iob_free.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include "iob_internal.h"
|
||||||
|
|
||||||
|
void iob_free(io_batch* b) {
|
||||||
|
iob_reset(b);
|
||||||
|
free(b);
|
||||||
|
}
|
16
io/iob_reset.3
Normal file
16
io/iob_reset.3
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.TH iob_reset 3
|
||||||
|
.SH NAME
|
||||||
|
iob_reset \- reset an I/O batch
|
||||||
|
.SH SYNTAX
|
||||||
|
.B #include <iob.h>
|
||||||
|
|
||||||
|
void \fBiob_reset\fP(io_batch* b);
|
||||||
|
.SH DESCRIPTION
|
||||||
|
iob_free empties the list of transactions in an I/O batch. Files added
|
||||||
|
with iob_addfile_close are closed, and buffer added with iob_addbuf_free
|
||||||
|
of iob_adds_free are freed.
|
||||||
|
|
||||||
|
The I/O batch itself is not freed. You can start adding transactions to
|
||||||
|
it again.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
iob_new(3), iob_reset(3)
|
@ -30,7 +30,7 @@ typedef struct {
|
|||||||
uint64 mapofs;
|
uint64 mapofs;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
OVERLAPPED o;
|
OVERLAPPED o;
|
||||||
HANDLE fd;
|
HANDLE /* fd, */ mh;
|
||||||
#endif
|
#endif
|
||||||
} io_entry;
|
} io_entry;
|
||||||
|
|
||||||
|
1
iob.h
1
iob.h
@ -31,6 +31,7 @@ int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n);
|
|||||||
int64 iob_send(int64 s,io_batch* b);
|
int64 iob_send(int64 s,io_batch* b);
|
||||||
int64 iob_write(int64 s,io_batch* b,io_write_callback cb);
|
int64 iob_write(int64 s,io_batch* b,io_write_callback cb);
|
||||||
void iob_reset(io_batch* b);
|
void iob_reset(io_batch* b);
|
||||||
|
void iob_free(io_batch* b);
|
||||||
void iob_prefetch(io_batch* b,uint64 bytes);
|
void iob_prefetch(io_batch* b,uint64 bytes);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include "textcode.h"
|
#include "textcode.h"
|
||||||
#include "havealloca.h"
|
#include "havealloca.h"
|
||||||
|
|
||||||
void b64encode(const char* c) {
|
void b64encode(const char* c,long len) {
|
||||||
char* buf=alloca(strlen(c)*2+4);
|
char* buf=alloca(len*2+4);
|
||||||
buffer_put(buffer_1,buf,fmt_base64(buf,c,strlen(c)));
|
buffer_put(buffer_1,buf,fmt_base64(buf,c,len));
|
||||||
if (isatty(1))
|
if (isatty(1))
|
||||||
buffer_putnlflush(buffer_1);
|
buffer_putnlflush(buffer_1);
|
||||||
else
|
else
|
||||||
@ -16,15 +16,14 @@ void b64encode(const char* c) {
|
|||||||
int main(int argc,char* argv[]) {
|
int main(int argc,char* argv[]) {
|
||||||
int i;
|
int i;
|
||||||
for (i=1; i<argc; ++i) {
|
for (i=1; i<argc; ++i) {
|
||||||
b64encode(argv[i]);
|
b64encode(argv[i],strlen(argv[i]));
|
||||||
}
|
}
|
||||||
if (argc<2) {
|
if (argc<2) {
|
||||||
char src[1024];
|
char src[1024];
|
||||||
int len;
|
int len;
|
||||||
while ((len=read(0,src,sizeof(src)-1))>0) {
|
while ((len=read(0,src,sizeof(src)-1))>0) {
|
||||||
if (len==-1) return(1);
|
if (len==-1) return(1);
|
||||||
src[len]=0;
|
b64encode(src,len);
|
||||||
b64encode(src);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user