This commit is contained in:
Mickaël Rémond 2015-02-11 16:05:03 +01:00
parent f41fb570d6
commit ab85f6a6e4
23 changed files with 0 additions and 4805 deletions

View File

@ -1,27 +0,0 @@
Copyright (c) 2006, Claes Wikstrom, klacke@hyber.org
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of "bfile" nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,23 +0,0 @@
all:
(cd config;$(MAKE))
(cd src;$(MAKE))
-(cd c_src;$(MAKE) -k)
$(MAKE) appfile
clean:
(cd src;$(MAKE) clean)
(cd c_src;$(MAKE) clean)
(cd config; $(MAKE) clean)
install: all
(cd c_src; $(MAKE) install)
conf_clean:
(cd config; $(MAKE) clean)
appfile:
(cd src;$(MAKE) ../ebin/bfile.app)

View File

@ -1,28 +0,0 @@
An interface to fast FILE I/O
It's based on an old and hacked version
of the BSD FILE*
To install, type make; make install
and it shuld install itself as an app in your
erlang dir.
See the source src/bfile.erl for API
Here's an example shell session:
2> bfile:load_driver().
ok
4> {ok, Fd} = bfile:fopen("Makefile", "r").
{ok,{bfile,#Port<0.98>}}
5> bfile:fgets(Fd).
{line,<<10>>}
6> bfile:fgets(Fd).
{line,<<10>>}
7> bfile:fgets(Fd).
{line,<<97,108,108,58,32,10>>}
14> bfile:fread(Fd, 10000).
{ok,<<10,10,105,110,115,116,97,108,108,58,32,97,108,108,10,9,40,99,100,32,99,95,115,114,99,59,32,...>>}
15> bfile:fread(Fd, 10000).
eof

View File

@ -1,490 +0,0 @@
/* Interface to stdio buffered FILE io */
/* author: klacke@kaja.klacke.net */
/* Created : 22 Nov 1999 by Claes Wikstrom <klacke@kaja.klacke.net> */
#include <string.h>
#define USE_STDIO
#ifdef WIN32
#define USE_STDIO
#include <windows.h>
#else
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#endif
#include "erl_driver.h"
#ifndef ERL_DRV_NIL
#include "erl_driver_compat.h"
#endif
#ifdef USE_STDIO
# include <stdio.h>
#else
# define malloc(s) driver_alloc(s)
# define realloc(p, s) driver_realloc(p, s)
# define free(p) driver_free(p)
# define BINTERFACE static
# include "bbio.c"
# define FILE bFILE
# define clearerr bclearerr
# define fclose bfclose
# define feof bfeof
# define ferror bferror
# define fflush bfflush
# define fgets bfgets
# define fileno bfileno
# define fopen bfopen
# define fread bfread
# define fseek bfseek
# define ftell bftell
# define fwrite bfwrite
# define getc bgetc
# define ungetc bungetc
#endif
#define get_int32(s) ((((unsigned char*) (s))[0] << 24) | \
(((unsigned char*) (s))[1] << 16) | \
(((unsigned char*) (s))[2] << 8) | \
(((unsigned char*) (s))[3]))
#define put_int32(i, s) {((char*)(s))[0] = (char)((i) >> 24) & 0xff; \
((char*)(s))[1] = (char)((i) >> 16) & 0xff; \
((char*)(s))[2] = (char)((i) >> 8) & 0xff; \
((char*)(s))[3] = (char)((i) & 0xff);}
/* op codes */
#define XX_OPEN 'o'
#define XX_CLOSE 'c'
#define XX_READ 'r'
#define XX_WRITE 'w'
#define XX_SEEK 's'
#define XX_TELL 't'
#define XX_TRUNCATE 'T'
#define XX_FLUSH 'f'
#define XX_OEOF 'e'
#define XX_ERROR 'E'
#define XX_GETC 'g'
#define XX_GETS 'G'
#define XX_GETS2 '2'
#define XX_SET_LINEBUF_SIZE 'S'
#define XX_UNGETC 'u'
/* return codes */
#define XX_VALUE 'v'
#define XX_FLINE 'L'
#define XX_OK 'o'
#define XX_I32 'O'
#define XX_NOLINE 'N'
#define XX_FERROR 'E'
#define XX_REOF 'x'
#ifdef WIN32
#define XX_EINVAL WSAEINVAL
#else
#define XX_EINVAL EINVAL
#endif
static ErlDrvData FILE_start(ErlDrvPort port, char *buf);
static void FILE_stop(ErlDrvData drv_data);
static ErlDrvEntry FILE_driver_entry;
typedef struct _desc {
ErlDrvPort port;
FILE *fp;
int linebuf_size;
} Desc;
static ErlDrvData FILE_start(ErlDrvPort port, char *buf)
{
Desc *d = (Desc*) driver_alloc(sizeof (Desc));
if (d == NULL)
return (ErlDrvData) -1;
d->fp = NULL;
d->port = port;
d->linebuf_size = 255; /* default line size */
set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY);
return (ErlDrvData) d;
}
static void FILE_stop(ErlDrvData drv_data)
{
Desc *d = (Desc*) drv_data;
if (d->fp)
fclose(d->fp);
driver_free(d);
}
static char *driver_error(ErlDrvPort port, int err)
{
char response[256]; /* Response buffer. */
char* s;
char* t;
ErlDrvBinary* bin;
bin = driver_alloc_binary(1);
bin->orig_bytes[0] = XX_FERROR;
response[0] = XX_FERROR;
for (s = erl_errno_id(err), t = bin->orig_bytes + 1; *s; s++, t++)
*t = tolower(*s);
return (char *)bin;
}
static char *driver_ret32(ErlDrvPort port, unsigned int r)
{
char ch = XX_I32;
ErlDrvBinary* bin;
bin = driver_alloc_binary(1);
bin->orig_bytes[0] = ch;
put_int32(r, bin->orig_bytes + 1);
return (char *)bin;
}
static char *driver_ok(ErlDrvPort port)
{
char ch = XX_OK;
ErlDrvBinary* bin;
bin = driver_alloc_binary(1);
bin->orig_bytes[0] = ch;
return (char *)bin;
}
static char *driver_eof(ErlDrvPort port)
{
char ch = XX_REOF;
ErlDrvBinary* bin;
bin = driver_alloc_binary(1);
bin->orig_bytes[0] = ch;
return (char *)bin;
}
static int FILE_control(ErlDrvData drv_data,
unsigned int command,
char *buf, int len,
char **rbuf, int rlen)
{
Desc *desc = (Desc*) drv_data;
ErlDrvBinary* bin;
switch (command) {
case XX_OPEN: {
char file[BUFSIZ]; /* should be FILENAME_MAX */
char flags[4]; /* at most someething like rb+ */
char* src;
char* dst;
char* src_end;
char* dst_end;
if (desc->fp != NULL) {
*rbuf = driver_error(desc->port, XX_EINVAL);
return 1;
}
/* play it safe ? */
src = buf;
src_end = buf + len;
/* get file name */
dst = file;
dst_end = dst + BUFSIZ; /* make room for a '\0' */
while((src < src_end) && (dst < dst_end) && (*src != '\0'))
*dst++ = *src++;
if ((src == src_end) || (dst == dst_end)) {
driver_error(desc->port, XX_EINVAL);
}
*dst = *src++;
/* get flags */
dst = flags;
dst_end = dst + 4;
while((src < src_end) && (dst < dst_end) && (*src != '\0'))
*dst++ = *src++;
if (dst == dst_end) {
*rbuf = driver_error(desc->port, XX_EINVAL);
return 1;
}
*dst = '\0';
if (src + 1 != src_end) {
*rbuf = driver_error(desc->port, XX_EINVAL);
return 1;
}
if ((desc->fp = fopen(file, flags))==NULL) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = driver_ok(desc->port);
return 1;
break;
}
case XX_WRITE: {
if (fwrite(buf, 1, len, desc->fp) != len) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = driver_ok(desc->port);
return 1;
break;
}
case XX_READ: {
char ch = XX_VALUE;
int rval;
int sz = get_int32(buf);
if ((bin = driver_alloc_binary(sz + 1)) == NULL) {
*rbuf = driver_error(desc->port, -1);
return 1;
}
bin->orig_bytes[0] = ch;
if ((rval = fread(bin->orig_bytes + 1, 1, sz, desc->fp)) != sz) {
if (feof(desc->fp)) {
if (rval == 0) {
driver_free_binary(bin);
*rbuf = driver_eof(desc->port);
return 1;
}
bin = driver_realloc_binary(bin, rval + 1);
*rbuf = (char *)bin;
return 1;
}
driver_free_binary(bin);
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = (char *)bin;
return 1;
}
case XX_SEEK: {
int offs = get_int32(buf);
int w = (int) buf[4];
int whence;
switch (w) {
case 1: whence = SEEK_SET; break;
case 2: whence = SEEK_CUR; break;
case 3: whence = SEEK_END; break;
}
if ((w = fseek(desc->fp, offs, whence)) != 0) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = driver_ok(desc->port);
return 1;
}
case XX_TELL: {
int offs;
if ((offs = ftell(desc->fp)) == -1) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = driver_ret32(desc->port, offs);
return 1;
break;
}
case XX_TRUNCATE: {
int fno;
int offs;
/* is this really safe? */
if (fflush(desc->fp) != 0) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
if ((offs = ftell(desc->fp)) == -1) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
fno = fileno(desc->fp);
#ifdef WIN32
if (SetEndOfFile((HANDLE)fno) != 0) {
*rbuf = driver_error(desc->port, GetLastError());
return 1;
}
#else
if (ftruncate(fno, offs) == -1) {
*rbuf = driver_error(desc->port, errno);
return 1;
}
#endif
*rbuf = driver_ok(desc->port);
return 1;
}
case XX_FLUSH:
if (fflush(desc->fp) != 0)
*rbuf = driver_error(desc->port, errno);
else
*rbuf = driver_ok(desc->port);
return 1;
break;
case XX_OEOF:
if (feof(desc->fp))
*rbuf = driver_ret32(desc->port, 1);
else
*rbuf = driver_ret32(desc->port, 0);
return 1;
break;
case XX_ERROR:
if (ferror(desc->fp))
*rbuf = driver_ret32(desc->port, 1);
else
*rbuf = driver_ret32(desc->port,0);
return 1;
break;
case XX_GETC: {
int ch;
if ((ch = getc(desc->fp)) == EOF) {
if (feof(desc->fp)) {
*rbuf = driver_eof(desc->port);
return 1;
}
*rbuf = driver_error(desc->port, errno);
return 1;
}
*rbuf = driver_ret32(desc->port, ch);
return 1;
break;
}
case XX_SET_LINEBUF_SIZE: {
int sz = get_int32(buf);
desc->linebuf_size = sz;
*rbuf = driver_ok(desc->port);
return 1;
break;
}
case XX_GETS:
case XX_GETS2: {
int rval;
long cpos1, cpos2;
char header;
if ((bin = driver_alloc_binary(desc->linebuf_size + 1)) == NULL) {
*rbuf = driver_error(desc->port, -1);
return 1;
}
if ((cpos1 = ftell(desc->fp)) == -1) {
driver_free_binary(bin);
*rbuf = driver_error(desc->port, errno);
return 1;
}
if ((fgets(bin->orig_bytes + 1, desc->linebuf_size,
desc->fp)) == NULL) {
driver_free_binary(bin);
if (feof(desc->fp)) {
*rbuf = driver_eof(desc->port);
return 1;
}
*rbuf = driver_error(desc->port, errno);
return 1;
}
if ((cpos2 = ftell(desc->fp)) == -1) {
driver_free_binary(bin);
*rbuf = driver_error(desc->port, errno);
return 1;
}
rval = cpos2 - cpos1;
if (bin->orig_bytes[rval] == '\n' &&
bin->orig_bytes[rval + 1] == 0) {
header = XX_FLINE;
/* GETS keep newline, GETS2 remove newline */
rval = rval - (command == XX_GETS ? 0 : 1);
}
else
header = XX_NOLINE;
bin->orig_bytes[0] = header;
bin = driver_realloc_binary(bin, rval + 1);
*rbuf = (char *)bin;
return 1;
}
case XX_UNGETC: {
int ch = buf[0];
if (ungetc(ch, desc->fp) == EOF)
*rbuf = driver_error(desc->port, errno);
else
*rbuf = driver_ok(desc->port);
return 1;
break;
}
default:
#ifdef DEBUG
fprintf(stderr, "Unknown opcode %c\n\r", command);
#endif
*rbuf = driver_error(desc->port, XX_EINVAL);
return 1;
break;
}
}
static void FILE_finish()
{
#ifndef USE_STDIO
/*
* Make sure any remaining buffers are flushed (this is done on exit() by
* the normal stdio).
*/
bbio_cleanup();
#endif
}
/*
* Initialize and return a driver entry struct
*/
DRIVER_INIT(FILE_drv)
{
FILE_driver_entry.init = NULL; /* Not used */
FILE_driver_entry.start = FILE_start;
FILE_driver_entry.stop = FILE_stop;
FILE_driver_entry.output = NULL;
FILE_driver_entry.ready_input = NULL;
FILE_driver_entry.ready_output = NULL;
FILE_driver_entry.driver_name = "FILE_drv";
FILE_driver_entry.finish = FILE_finish;
FILE_driver_entry.outputv = NULL;
FILE_driver_entry.control = FILE_control;
return &FILE_driver_entry;
}

View File

@ -1,42 +0,0 @@
include ../config/include.mk
## don't build this under win32 at all
ifdef WIN32
PRIV_FILES =
else
PRIV_FILES=../priv/FILE_drv.so
endif
CFLAGS += -I$(ERL_C_INCLUDE_DIR) -I../config -I.
#
# Targets
#
all: $(PRIV_FILES)
clean:
-rm -f $(PRIV_FILES) FILE_drv.o
install:
install -d $(ERLDIR)/lib/bfile
cp -r `pwd` $(ERLDIR)/lib/bfile
cp -r `pwd`/../ebin $(ERLDIR)/lib/bfile
cp -r `pwd`/../priv $(ERLDIR)/lib/bfile
../priv/FILE_drv.so: FILE_drv.o
$(LD_SHARED) -o $@ FILE_drv.o $(LIBS)
FILE_drv.o: FILE_drv.c
$(CC) -o $@ -c -fpic $(CFLAGS) -DDYNAMIC_DRIVER FILE_drv.c

View File

@ -1,21 +0,0 @@
MK_INCLUDE=include.mk
CONFIG_H=config.h
all: config.status $(MK_INCLUDE) $(CONFIG_H)
config.status: configure
./configure
$(CONFIG_H) $(MK_INCLUDE): config.status include.mk.in config.h.in
./config.status
configure: configure.in
autoheader
autoconf
clean:
-rm -f config.cache config.log config.status configure \
$(MK_INCLUDE) $(CONFIG_H)
-rm -rf autom4te.cache

View File

@ -1,269 +0,0 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
#ifndef WIN32
@TOP@
/*
* This file contains prototypes for config.h.in which autoheader
* could not figure by itself. I.e. if you write your own test which
* defines a macro you will probably have to put it here, but if you
* use any standard test AC_* it will be detected by autoheader.
*/
#undef WIN32
/* Define to a string defining your target. ($target in configure.in) */
#undef CPU_VENDOR_OS
/* Define to the full path of the ifconfig program */
#undef IFCONFIG
/* Define to the full path of the route program */
#undef ROUTE
/* Define to the full path of the arp program */
#undef ARP
/*
* These four below should definately be done away with!!
*/
/* Define if your target OS is a BSD derivative */
#undef BSD
/* Define if your target OS is Linux */
#undef LINUX
/* Define if your target OS is SunOS 5.x */
#undef SOLARIS
/* Define if your target OS is BSD/OS 4.x */
#undef BSDI
/*
* What are these???
*/
/* ? */
#undef USE_IFALIAS
/* Define if you wish to use the bpf interface */
#undef USE_BPF
/* Define if you wish to use the dlpi interface */
#undef USE_DLPI
/* ? */
#undef USE_SOCKET
/* Define if prototypes for malloc can be found in stdlib.h */
#undef STDLIB_MALLOC
/* Define if your include files defines a prototype for sys_errlist[] */
#undef HAVE_SYS_ERRLIST
/* This isn't used anywhere (that I could find) so I don't know what it means*/
#undef IFCONFIG_REQUIRES_DOWN_ADDRESS
/* Define if your OS have broken cmsg fields in the msghdr struct (Linux) */
#undef BROKEN_CMSG_FIELDS
/* Define if sockaddr structure has sa_len member */
#undef SA_LEN_IN_SOCKADDR
/*
* Provide a common way to refer to ints with specific size. (Is this
* used everywhere?) The names used are {u_,}int{8,16,32,64}_t unless
* they are defined in sys/types.h they are defined in ints.h using
* the BIT macros. e.g. if int8_t isn't defined in sys/types.h int8_t
* is typedef:ed to BIT8.
*
*/
/* Define to a basic signed type that is 8 bits in size */
#undef BIT8
/* Define to a basic signed type that is 16 bits in size */
#undef BIT16
/* Define to a basic signed type that is 32 bits in size */
#undef BIT32
/* Define to a basic signed type that is 64 bits in size */
#undef BIT64
/* Define if sys/types.h defines this type */
#undef HAVE_int8_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int8_t
/* Define if sys/types.h defines this type */
#undef HAVE_int16_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int16_t
/* Define if sys/types.h defines this type */
#undef HAVE_int32_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int32_t
/* Define if sys/types.h defines this type */
#undef HAVE_int64_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int64_t
/* */
#undef ETHER_HEADER_USES_ETHER_ADDR
/* */
#undef HAVE_DLIOCRAW
/* */
#undef HAVE_ETHERADDRL
/* */
#undef HAVE_ETHER_ADDR_LEN
/* */
#undef HAVE_MSGHDR_MSG_CONTROL
/* */
#undef HAVE_SIOCGARP
/* */
#undef HAVE_SIOCGIFCONF
/* */
#undef HAVE_SIOCGIFHWADDR
/* */
#undef HAVE_arpreq
/* */
#undef HAVE_caddr_t
/* */
#undef HAVE_ether_header
/* */
#undef HAVE_ethhdr
/* */
#undef HAVE_ifnet
/* */
#undef HAVE_in_addr
/* */
#undef HAVE_sockaddr
/* */
#undef HAVE_sockaddr_dl
/* */
#undef HAVE_sockaddr_in
/* */
#undef NEED_HAVE_sockaddr_dl
/*
* I have yet to figure out what all this need_* stuff is for, shouldn't
* it suffice with using have_* ???
*/
/* */
#undef NEED_LINUX_SOCKIOS_H
/* */
#undef NEED_NETINET_IF_ETHER_H
/* */
#undef NEED_NETINET_IN_H
/* */
#undef NEED_NET_ETHERNET_H
/* */
#undef NEED_NET_IF_ARP_H
/* */
#undef NEED_NET_IF_DL_H
/* */
#undef NEED_NET_IF_H
/* */
#undef NEED_SYS_BITYPES_H
/* */
#undef NEED_SYS_DLPI_H
/* */
#undef NEED_SYS_ETHERNET_H
/* */
#undef NEED_SYS_SOCKETIO_H
/* */
#undef NEED_SYS_SOCKET_H
/* */
#undef NEED_SYS_SOCKIO_H
/* */
#undef NEED_SYS_TYPES_H
/* if we have the openssl with engine support */
#undef HAVE_SSL_ENGINE
/* ... with Rainbow patches */
#undef HAVE_RAINBOW_PATCHES
/* ... with Rainbow's libswift */
#undef HAVE_SWIFT
/* ... with one of our HW checks */
#undef HAVE_LOCAL_ENGINE_SETUP
#undef HAVE_SSL_HW_CHECK
/* ... with patch to get cfg password from card */
#undef HAVE_ENGINE_GET_PASSWORD
/* ... with our buffer patches */
#undef HAVE_SSL_BUFFER_CB
/* */
#undef ISD_SYSTEM_VSN
/* eventpoll */
#undef HAVE_KPOLL
/* Have/use netfilter (a.k.a. iptables) */
#undef HAVE_NETFILTER
/* Non-standard support for "non-local connect()" in Linux 2.4 */
#undef HAVE_NONLOCAL_CONNECT
/* atomic asmebler op in asm/atomic.h ? */
#undef HAVE_ATOMIC_OPS
@BOTTOM@
#endif /* WIN32 */
#endif /* _CONFIG_H_ */

View File

@ -1,32 +0,0 @@
dnl ----------------------------------------------------------------------
dnl
dnl BT_MSG_CONTROL checks for msg_control member in msghdr and that
dnl the cmsg fields aren't broken...
dnl
AC_DEFUN(BT_MSG_CONTROL,
[
AC_CACHE_CHECK([for msg_control member in msghdr],
bt_cv_have_msghdr_msg_control,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[struct msghdr msg;
msg.msg_control;],
bt_cv_have_msghdr_msg_control=yes, bt_cv_have_msghdr_msg_control=no)])
if test $bt_cv_have_msghdr_msg_control = yes; then
AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)
fi
if test $bt_cv_have_msghdr_msg_control = yes; then
AC_MSG_CHECKING(for broken CMSG_FIELDS)
case "$target_os" in
linux*)
AC_DEFINE(BROKEN_CMSG_FIELDS)
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac
fi
])

File diff suppressed because it is too large Load Diff

View File

@ -1,319 +0,0 @@
/* config.h.in. Generated from configure.in by autoheader. */
#ifndef _CONFIG_H_
#define _CONFIG_H_
#ifndef WIN32
/*
* This file contains prototypes for config.h.in which autoheader
* could not figure by itself. I.e. if you write your own test which
* defines a macro you will probably have to put it here, but if you
* use any standard test AC_* it will be detected by autoheader.
*/
#undef WIN32
/* Define to a string defining your target. ($target in configure.in) */
#undef CPU_VENDOR_OS
/* Define to the full path of the ifconfig program */
#undef IFCONFIG
/* Define to the full path of the route program */
#undef ROUTE
/* Define to the full path of the arp program */
#undef ARP
/*
* These four below should definately be done away with!!
*/
/* Define if your target OS is a BSD derivative */
#undef BSD
/* Define if your target OS is Linux */
#undef LINUX
/* Define if your target OS is SunOS 5.x */
#undef SOLARIS
/* Define if your target OS is BSD/OS 4.x */
#undef BSDI
/*
* What are these???
*/
/* ? */
#undef USE_IFALIAS
/* Define if you wish to use the bpf interface */
#undef USE_BPF
/* Define if you wish to use the dlpi interface */
#undef USE_DLPI
/* ? */
#undef USE_SOCKET
/* Define if prototypes for malloc can be found in stdlib.h */
#undef STDLIB_MALLOC
/* Define if your include files defines a prototype for sys_errlist[] */
#undef HAVE_SYS_ERRLIST
/* This isn't used anywhere (that I could find) so I don't know what it means*/
#undef IFCONFIG_REQUIRES_DOWN_ADDRESS
/* Define if your OS have broken cmsg fields in the msghdr struct (Linux) */
#undef BROKEN_CMSG_FIELDS
/* Define if sockaddr structure has sa_len member */
#undef SA_LEN_IN_SOCKADDR
/*
* Provide a common way to refer to ints with specific size. (Is this
* used everywhere?) The names used are {u_,}int{8,16,32,64}_t unless
* they are defined in sys/types.h they are defined in ints.h using
* the BIT macros. e.g. if int8_t isn't defined in sys/types.h int8_t
* is typedef:ed to BIT8.
*
*/
/* Define to a basic signed type that is 8 bits in size */
#undef BIT8
/* Define to a basic signed type that is 16 bits in size */
#undef BIT16
/* Define to a basic signed type that is 32 bits in size */
#undef BIT32
/* Define to a basic signed type that is 64 bits in size */
#undef BIT64
/* Define if sys/types.h defines this type */
#undef HAVE_int8_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int8_t
/* Define if sys/types.h defines this type */
#undef HAVE_int16_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int16_t
/* Define if sys/types.h defines this type */
#undef HAVE_int32_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int32_t
/* Define if sys/types.h defines this type */
#undef HAVE_int64_t
/* Define if sys/types.h defines this type */
#undef HAVE_u_int64_t
/* */
#undef ETHER_HEADER_USES_ETHER_ADDR
/* */
#undef HAVE_DLIOCRAW
/* */
#undef HAVE_ETHERADDRL
/* */
#undef HAVE_ETHER_ADDR_LEN
/* */
#undef HAVE_MSGHDR_MSG_CONTROL
/* */
#undef HAVE_SIOCGARP
/* */
#undef HAVE_SIOCGIFCONF
/* */
#undef HAVE_SIOCGIFHWADDR
/* */
#undef HAVE_arpreq
/* */
#undef HAVE_caddr_t
/* */
#undef HAVE_ether_header
/* */
#undef HAVE_ethhdr
/* */
#undef HAVE_ifnet
/* */
#undef HAVE_in_addr
/* */
#undef HAVE_sockaddr
/* */
#undef HAVE_sockaddr_dl
/* */
#undef HAVE_sockaddr_in
/* */
#undef NEED_HAVE_sockaddr_dl
/*
* I have yet to figure out what all this need_* stuff is for, shouldn't
* it suffice with using have_* ???
*/
/* */
#undef NEED_LINUX_SOCKIOS_H
/* */
#undef NEED_NETINET_IF_ETHER_H
/* */
#undef NEED_NETINET_IN_H
/* */
#undef NEED_NET_ETHERNET_H
/* */
#undef NEED_NET_IF_ARP_H
/* */
#undef NEED_NET_IF_DL_H
/* */
#undef NEED_NET_IF_H
/* */
#undef NEED_SYS_BITYPES_H
/* */
#undef NEED_SYS_DLPI_H
/* */
#undef NEED_SYS_ETHERNET_H
/* */
#undef NEED_SYS_SOCKETIO_H
/* */
#undef NEED_SYS_SOCKET_H
/* */
#undef NEED_SYS_SOCKIO_H
/* */
#undef NEED_SYS_TYPES_H
/* if we have the openssl with engine support */
#undef HAVE_SSL_ENGINE
/* ... with Rainbow patches */
#undef HAVE_RAINBOW_PATCHES
/* ... with Rainbow's libswift */
#undef HAVE_SWIFT
/* ... with one of our HW checks */
#undef HAVE_LOCAL_ENGINE_SETUP
#undef HAVE_SSL_HW_CHECK
/* ... with patch to get cfg password from card */
#undef HAVE_ENGINE_GET_PASSWORD
/* ... with our buffer patches */
#undef HAVE_SSL_BUFFER_CB
/* */
#undef ISD_SYSTEM_VSN
/* eventpoll */
#undef HAVE_KPOLL
/* Have/use netfilter (a.k.a. iptables) */
#undef HAVE_NETFILTER
/* Non-standard support for "non-local connect()" in Linux 2.4 */
#undef HAVE_NONLOCAL_CONNECT
/* atomic asmebler op in asm/atomic.h ? */
#undef HAVE_ATOMIC_OPS
/* Description */
#undef DARWIN
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
#endif /* WIN32 */
#endif /* _CONFIG_H_ */

1460
bfile/config/config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +0,0 @@
AC_INIT
dnl work out who the cpu, vendor and OS are
AC_CANONICAL_SYSTEM
AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$target")
dnl Programs
AC_PROG_CC
AC_PATH_PROG(ERL, erl)
AC_PATH_PROG(ERLC, erlc)
ERLBINDIR=`dirname $ERL` ; ERLBINDIR=`dirname $ERLBINDIR`/lib/erlang/bin
ERLDIR=`awk -F= '/ROOTDIR=/ { print [$]2; exit; }' $ERL`
AC_SUBST(ERL)
AC_SUBST(ERLC)
AC_SUBST(ERLBINDIR)
AC_SUBST(ERLDIR)
if test ! -d "$ERLDIR" ; then
AC_MSG_ERROR([Broken Erlang installation, $ERLDIR does not exist!])
fi
dnl C header files
AC_CONFIG_HEADER(config.h:config.h.in)
AC_CHECK_HEADERS(malloc.h)
BT_MSG_CONTROL
case "$target_os" in
*cygwin*)
:
dnl fix this later
;;
linux*)
AC_DEFINE(LINUX)
LD_SHARED="ld -shared"
;;
*bsd*)
AC_DEFINE(BSD)
LD_SHARED="ld -Bshareable"
;;
*solaris*)
AC_DEFINE(SOLARIS)
LD_SHARED="ld -G"
;;
*darwin*)
AC_DEFINE([DARWIN], [], [Description])
LD_SHARED="cc -bundle -flat_namespace -undefined suppress"
;;
*)
LD_SHARED="ld -shared"
;;
esac
AC_SUBST(LD_SHARED)
dnl libnsl and libsocket tests borrowed from ethereal's autoconf scheme.
dnl # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
dnl # to get the SysV transport functions.
dnl # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4)
dnl # needs -lnsl.
dnl # The nsl library prevents programs from opening the X display
dnl # on Irix 5.2, according to dickey@clark.net.
AC_CHECK_FUNC(gethostbyname, ,
AC_CHECK_LIB(nsl, gethostbyname, NSL_LIBS="-lnsl"))
AC_SUBST(NSL_LIBS)
dnl # lieder@skyler.mavd.honeywell.com says without -lsocket,
dnl # socket/setsockopt and other routines are undefined under SCO ODT
dnl # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
dnl # on later versions), says simon@lia.di.epfl.ch: it contains
dnl # gethostby* variants that don't use the nameserver (or something).
dnl # -lsocket must be given before -lnsl if both are needed.
dnl # We assume that if connect needs -lnsl, so does gethostbyname.
AC_CHECK_FUNC(connect, ,
AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket",
AC_MSG_ERROR(Function 'socket' not found.), $NSL_LIBS))
AC_SUBST(SOCKET_LIBS)
dnl
dnl End.
AC_OUTPUT(include.mk)

View File

@ -1,75 +0,0 @@
## -*- makefile -*-
######################################################################
## C
CC := @CC@
CFLAGS := @CFLAGS@ @DEFS@
LD_SHARED := @LD_SHARED@
######################################################################
## Erlang
ERL = @ERL@
ERLC = @ERLC@
ERLDIR = @ERLDIR@
ERL_C_INCLUDE_DIR := $(ERLDIR)/usr/include
ERLC_FLAGS := -W
ifndef no_debug_info
ERLC_FLAGS += +debug_info
endif
ifdef debug
ERLC_FLAGS += -Ddebug
endif
EBIN_DIR := ../ebin
DOC_DIR := ../doc
EMULATOR := beam
ERL_SOURCES := $(wildcard *.erl)
ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.$(EMULATOR))
ERL_DOCUMENTS := $(ERL_SOURCES:%.erl=$(DOC_DIR)/%.html)
# Hmm, don't know if you are supposed to like this better... ;-)
APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
../ebin/%.app: %.app.src ../vsn.mk Makefile
perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@
../ebin/%.appup: %.appup
cp $< $@
$(EBIN_DIR)/%.$(EMULATOR): %.erl
$(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<
# generate documentation with edoc:
# this is still not the proper way to do it, but it works
# (see the wumpus application for an example)
$(DOC_DIR)/%.html: %.erl
${ERL} -noshell \
-pa ../../syntax_tools/ebin \
-pa ../../edoc/ebin \
-pa ../../xmerl/ebin \
-pa ../../ucs/ebin \
-run edoc file $< -run init stop
mv *.html $(DOC_DIR)
# C linking items
NSL_LIBS = @NSL_LIBS@
SOCKET_LIBS = @SOCKET_LIBS@
# Miscellaneous
GROFF = @GROFF@
PS2PDF = @PS2PDF@

View File

@ -1,250 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

View File

View File

@ -1,25 +0,0 @@
include ../config/include.mk
include ../vsn.mk
VSN=$(FD_SERVER_VSN)
ifeq ($(TYPE),debug)
DEBUG_FLAGS = -Ddebug
else
DEBUG_FLAGS =
endif
MODULES=bfile
EBIN = ../ebin
EBIN_FILES = $(MODULES:%=$(EBIN)/%.$(EMULATOR)) $(EBIN)/bfile.app
all: $(EBIN_FILES)
debug:
$(MAKE) DEBUG=-DDEBUG
clean:
rm -rf $(EBIN_FILES)

View File

@ -1,7 +0,0 @@
{application,bfile,
[{description,"Fast FILE interface"},
{vsn,"%VSN%"},
{modules,[%MODULES%]},
{applications,[kernel,stdlib]},
{env, []},
{mod,{bfile,[]}}]}.

View File

@ -1,224 +0,0 @@
%%%
%%% File : bfile.erl
%%% Author : Claes Wikstrom <klacke@kaja.klacke.net>
%%% Purpose : Interface to stdio buffered FILE io
%%% Created : 22 Nov 1999 by Claes Wikstrom <klacke@kaja.klacke.net>
%%%----------------------------------------------------------------------
-module(bfile).
-vsn("$Revision: 1.1 $ ").
-author('klacke@kaja.klacke.net').
-export([
load_driver/0,
fopen/2,
fclose/1,
fread/2,
fwrite/2,
feof/1,
ferror/1,
set_linebuf_size/2,
fseek/3,
ftell/1,
ftruncate/1,
fflush/1,
frewind/1,
fgetc/1,
fungetc/2,
fgets/1,
gets/1,
pwrite/3,
pread/3
]).
%% Opcodes
-define(OPEN, $o).
-define(CLOSE, $c).
-define(READ, $r).
-define(WRITE, $w).
-define(SEEK, $s).
-define(TELL, $t).
-define(TRUNCATE, $T).
-define(FLUSH, $f).
-define(OEOF, $e).
-define(ERROR, $E).
-define(GETC, $g).
-define(GETS, $G).
-define(GETS2, $2).
-define(SET_LINEBUF_SIZE, $S).
-define(UNGETC, $u).
%% ret codes
-define(VALUE, $v).
-define(FLINE, $L).
-define(OK, $o).
-define(I32, $O).
-define(NOLINE,$N).
-define(FERROR, $E).
-define(REOF, $x).
-define(int32(X),
[((X) bsr 24) band 16#ff, ((X) bsr 16) band 16#ff,
((X) bsr 8) band 16#ff, (X) band 16#ff]).
%% Bytes to unsigned
-define(u32(X3,X2,X1,X0),
(((X3) bsl 24) bor ((X2) bsl 16) bor ((X1) bsl 8) bor (X0))).
%% Bytes to signed
-define(i32(X3,X2,X1,X0),
(?u32(X3,X2,X1,X0) -
(if (X3) > 127 -> 16#100000000; true -> 0 end))).
load_driver() ->
Dir = filename:join([filename:dirname(code:which(bfile)),"..", "priv"]),
erl_ddll:load_driver(Dir, "FILE_drv").
%% Flags = "r" | "w" | ... etc, see fopen(3)
%% Ret: {ok, Fd} | {error, Reason}
fopen(Fname, Flags) ->
P = open_port({spawn, 'FILE_drv'}, [binary]),
Res = erlang_port_control(P, ?OPEN, [Fname, 0, Flags, 0]),
case decode(Res) of
ok ->
{ok, {bfile, P}};
Err ->
unlink(P),
exit(P, die),
Err
end.
%% void()
fclose({bfile, Fd}) ->
unlink(Fd),
catch erlang:port_close(Fd).
%% {ok, #Bin} | {error, Reason} | eof
fread({bfile, Fd}, Sz) ->
Res = erlang_port_control(Fd, ?READ, ?int32(Sz)),
decode(Res).
%% ok | {error, Reason}
fwrite({bfile, Fd}, IoList) ->
Res = erlang_port_control(Fd, ?WRITE, IoList),
decode(Res).
%% ok | {error, Reason}
pwrite(BFd, Pos, IoList) ->
case fseek(BFd, Pos, seek_set) of
ok ->
fwrite(BFd, IoList);
Error ->
Error
end.
%% {ok, #Bin} | {error, Reason} | eof
pread(BFd, Pos, Sz) ->
case fseek(BFd, Pos, seek_set) of
ok ->
fread(BFd, Sz);
Error ->
Error
end.
%% bool
feof({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?OEOF, []),
bool(decode(Res)).
%% bool
ferror({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?ERROR, []),
bool(decode(Res)).
%% void()
set_linebuf_size({bfile, Fd}, Sz) ->
Res = erlang_port_control(Fd, ?SET_LINEBUF_SIZE, ?int32(Sz)),
decode(Res).
%% Whence == seek_set | seek_cur || seek_end
%% ok | {error, Reason}
fseek({bfile, Fd}, Offs, Whence) ->
Res = erlang_port_control(Fd, ?SEEK, [?int32(Offs), whence_enc(Whence)]),
decode(Res).
%% {ok, Int} | {error, Reason}
ftell({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?TELL, []),
decode(Res).
%% ok | {error, Reason}
ftruncate({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?TRUNCATE, []),
decode(Res).
%% ok | {error, Reason}
fflush({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?FLUSH, []),
decode(Res).
%% ok | {error, Reason}
frewind(BFd) ->
fseek(BFd, 0, seek_set).
%% {ok, Char} | {error, Reason} | eof
fgetc({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?GETC, []),
decode(Res).
%% ok | {error, Reason}
fungetc({bfile, Fd}, Char) ->
Res = erlang_port_control(Fd, ?UNGETC, [Char]),
decode(Res).
%% {line, #Bin} | {noline, #Bin} | {error, Reason} | eof
%% including newline
fgets({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?GETS, []),
decode(Res).
%% {line, #Bin} | {noline, #Bin} | {error, Reason} | eof
%% not including newline
gets({bfile, Fd}) ->
Res = erlang_port_control(Fd, ?GETS2, []),
decode(Res).
whence_enc(seek_set) ->
1;
whence_enc(seek_cur) ->
2;
whence_enc(seek_end) ->
3.
bool({ok, 1}) ->
true;
bool({ok, 0}) ->
false.
decode(Res) ->
case Res of
<<?VALUE, Bin/binary>> ->
{ok, Bin};
<<?FLINE, Bin/binary>> ->
{line, Bin};
<<?OK>> ->
ok;
<<?I32, X1, X2, X3, X4>> ->
{ok, ?i32(X1, X2, X3, X4)};
<<?NOLINE, Bin/binary>> ->
{noline, Bin};
<<?FERROR, Err/binary>> ->
{error, list_to_atom(binary_to_list(Err))};
<<?REOF>> ->
eof
end.
erlang_port_control(P, C, Data) ->
erlang:port_control(P, C, Data).

View File

@ -1,19 +0,0 @@
-module(read).
-export([start/1, start/2]).
scan_file(F, Readsize, Total) ->
Rd = bfile:fread(F, Readsize),
case Rd of
{ok, Bin} -> scan_file(F, Readsize, size(Bin)+Total);
eof -> Total
end.
scan_file(F, Readsize) -> scan_file(F, Readsize, 0).
start(File, Readsize) ->
bfile:load_driver(),
{ok, F} = bfile:fopen(File, "r"),
T = scan_file(F, Readsize),
io:format("read ~p bytes~n", [T]),
bfile:fclose(F).
start(File) ->
start(File, 512*1024).

View File

@ -1,18 +0,0 @@
-module(readold).
-export([start/1, start/2]).
scan_file(F, Readsize, Total) ->
Rd = file:read(F, Readsize),
case Rd of
{ok, Bin} -> scan_file(F, Readsize, size(Bin)+Total);
eof -> Total
end.
scan_file(F, Readsize) -> scan_file(F, Readsize, 0).
start(File, Readsize) ->
{ok, F} = file:open(File, [raw, binary, read]),
T = scan_file(F, Readsize),
io:format("read ~p bytes~n", [T]),
file:close(F).
start(File) ->
start(File, 512*1024).

View File

@ -1,17 +0,0 @@
-module(write).
-export([start/2, start/3]).
dump_file(F, Data, 0) ->
ok;
dump_file(F, Data, N) ->
bfile:fwrite(F, Data),
dump_file(F, Data, N - 1).
start(File, Data, N) ->
bfile:load_driver(),
{ok, F} = bfile:fopen(File, "w"),
dump_file(F, Data, N),
bfile:fclose(F).
start(File, N) ->
Data = list_to_binary(lists:duplicate(1000000, 10)),
start(File, Data, N).

View File

@ -1,16 +0,0 @@
-module(writeold).
-export([start/2, start/3]).
dump_file(F, Data, 0) ->
ok;
dump_file(F, Data, N) ->
file:write(F, Data),
dump_file(F, Data, N - 1).
start(File, Data, N) ->
{ok, F} = file:open(File, [raw, binary, write]),
dump_file(F, Data, N),
file:close(F).
start(File, N) ->
Data = list_to_binary(lists:duplicate(1000000, 10)),
start(File, Data, N).

View File

@ -1 +0,0 @@
BFILE_VSN=1.0