finished the inital fio routines
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h 419 2008-10-13 11:32:58Z baconevi $
|
||||
* $Id: awk.h 455 2008-11-26 09:05:00Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -661,6 +661,10 @@ void* ase_awk_getextension (
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_ccls_t* ase_awk_getccls (
|
||||
ase_awk_t* awk
|
||||
);
|
||||
|
||||
/*
|
||||
* set the character classfier
|
||||
*/
|
||||
@ -671,6 +675,10 @@ void ase_awk_setccls (
|
||||
ase_ccls_t* ccls
|
||||
);
|
||||
|
||||
ase_awk_prmfns_t* ase_awk_getprmfns (
|
||||
ase_awk_t* awk
|
||||
);
|
||||
|
||||
/*
|
||||
* set primitive functions
|
||||
*/
|
||||
@ -1046,4 +1054,36 @@ void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct ase_ns_awk_t
|
||||
{
|
||||
ase_awk_t* (*open) (ase_mmgr_t*, ase_size_t ext);
|
||||
int (*close) (ase_awk_t*);
|
||||
|
||||
ase_mmgr_t* (*getmmgr) (ase_awk_t*);
|
||||
void (*setmmgr) (ase_awk_t*, ase_mmgr_t*);
|
||||
void* (*getextension) (ase_awk_t*);
|
||||
|
||||
ase_ccls_t* (*getccls) (ase_awk_t*);
|
||||
void (*setccls) (ase_awk_t*, ase_ccls_t*);
|
||||
|
||||
ase_awk_prmfns_t* (*getprmfns) (ase_awk_t*);
|
||||
void (*setprmfns) (ase_awk_t*, ase_awk_prmfns_t*);
|
||||
|
||||
int (*parse) (ase_awk_t*, ase_awk_srcios_t*);
|
||||
};
|
||||
|
||||
#define ase_ns_awk_d \
|
||||
{ \
|
||||
ase_awk_open, \
|
||||
ase_awk_close, \
|
||||
ase_awk_getmmgr, \
|
||||
ase_awk_setmmgr, \
|
||||
ase_awk_getextension, \
|
||||
ase_awk_getccls, \
|
||||
ase_awk_setccls, \
|
||||
ase_awk_getprmfns, \
|
||||
ase_awk_setprmfns, \
|
||||
ase_awk_parse \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
110
ase/include/ase/cmn/fio.h
Normal file
110
ase/include/ase/cmn/fio.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_FIO_H_
|
||||
#define _ASE_CMN_FIO_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
enum ase_fio_open_flag_t
|
||||
{
|
||||
/* treat the file name pointer as a handle pointer */
|
||||
ASE_FIO_HANDLE = (1 << 0),
|
||||
|
||||
ASE_FIO_READ = (1 << 1),
|
||||
ASE_FIO_WRITE = (1 << 2),
|
||||
ASE_FIO_CREATE = (1 << 3),
|
||||
ASE_FIO_TRUNCATE = (1 << 4),
|
||||
ASE_FIO_EXCLUSIVE = (1 << 5),
|
||||
ASE_FIO_APPEND = (1 << 6),
|
||||
ASE_FIO_SYNC = (1 << 7),
|
||||
|
||||
/* for ms windows only */
|
||||
ASE_FIO_NOSHRD = (1 << 16),
|
||||
ASE_FIO_NOSHWR = (1 << 17),
|
||||
};
|
||||
|
||||
/* seek origin */
|
||||
enum ase_fio_seek_origin_t
|
||||
{
|
||||
ASE_FIO_BEGIN = 0,
|
||||
ASE_FIO_CURRENT = 1,
|
||||
ASE_FIO_END = 2
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
/* <winnt.h> typedef PVOID HANDLE; */
|
||||
typedef void* aes_fio_hnd_t;
|
||||
#else
|
||||
typedef int ase_fio_hnd_t;
|
||||
#endif
|
||||
|
||||
/* file offset */
|
||||
typedef ase_int64_t ase_fio_off_t;
|
||||
typedef enum ase_fio_seek_origin_t ase_fio_ori_t;
|
||||
|
||||
typedef struct ase_fio_t ase_fio_t;
|
||||
|
||||
struct ase_fio_t
|
||||
{
|
||||
ase_mmgr_t* mmgr;
|
||||
ase_fio_hnd_t handle;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_fio_t* ase_fio_open (
|
||||
ase_mmgr_t* mmgr,
|
||||
ase_size_t ext,
|
||||
const ase_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
|
||||
void ase_fio_close (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
|
||||
ase_fio_t* ase_fio_init (
|
||||
ase_fio_t* fio,
|
||||
ase_mmgr_t* mmgr,
|
||||
const ase_char_t* path,
|
||||
int flags,
|
||||
int mode
|
||||
);
|
||||
|
||||
void ase_fio_fini (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
|
||||
ase_fio_hnd_t ase_fio_gethandle (
|
||||
ase_fio_t* fio
|
||||
);
|
||||
|
||||
ase_fio_off_t ase_fio_seek (
|
||||
ase_fio_t* fio,
|
||||
ase_fio_off_t offset,
|
||||
ase_fio_ori_t origin
|
||||
);
|
||||
|
||||
ase_ssize_t ase_fio_read (
|
||||
ase_fio_t* fio,
|
||||
void* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
ase_ssize_t ase_fio_write (
|
||||
ase_fio_t* fio,
|
||||
const void* buf,
|
||||
ase_size_t size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h tio.h
|
||||
|
||||
pkgincludedir= $(includedir)/ase/cmn
|
||||
|
||||
|
@ -178,7 +178,7 @@ sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h tio.h
|
||||
CLEANFILES = *dist
|
||||
all: all-am
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 430 2008-10-17 11:43:20Z baconevi $
|
||||
* $Id: str.h 455 2008-11-26 09:05:00Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -393,7 +393,7 @@ ase_size_t ase_mbstowcs (
|
||||
|
||||
/****f* ase.cmn.str/ase_mbsntowcsn
|
||||
* NAME
|
||||
* ase_mbsntowcsn - conver a multibyte string to a wide character string
|
||||
* ase_mbsntowcsn - convert a multibyte string to a wide character string
|
||||
*
|
||||
* RETURN
|
||||
* The ase_mbstowcs() function returns the number of bytes handled.
|
||||
@ -408,6 +408,24 @@ ase_size_t ase_mbsntowcsn (
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.str/ase_wcstombs
|
||||
* NAME
|
||||
* ase_wcstombs - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_wcstombs() function converts a null-terminated wide character
|
||||
* string to a multibyte string and stores it into the buffer pointed to
|
||||
* by mbs. The pointer to a variable holding the buffer length should be
|
||||
* passed to the function as the third parameter. After conversion, it holds
|
||||
* the length of the multibyte string excluding the terminating-null.
|
||||
* It may not null-terminate the resulting multibyte string if the buffer
|
||||
* is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wcstombs() function returns the number of wide characters handled.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_size_t ase_wcstombs (
|
||||
const ase_wchar_t* wcs,
|
||||
ase_mchar_t* mbs,
|
||||
@ -431,6 +449,26 @@ ase_size_t ase_wcsntombsn (
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.cmn.str/ase_wcstombs_strict
|
||||
* NAME
|
||||
* ase_wcstombs_strict - convert a wide character string to a multibyte string.
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_wcstombs_strict() function performs the same as the ase_wcsmbs()
|
||||
* function except that it returns an error if it can't fully convert the
|
||||
* input string and/or the buffer is not large enough.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_wcstombs_strict() function returns 0 on success and -1 on failure.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_wcstombs_strict (
|
||||
const ase_wchar_t* wcs,
|
||||
ase_mchar_t* mbs,
|
||||
ase_size_t mbslen
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -63,6 +63,9 @@
|
||||
/* sizeof(__int8) */
|
||||
#undef ASE_SIZEOF___INT8
|
||||
|
||||
/* use the syscall() function */
|
||||
#undef ASE_USE_SYSCALL
|
||||
|
||||
/* package version */
|
||||
#undef ASE_VERSION
|
||||
|
||||
@ -78,9 +81,18 @@
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `fstat64' function. */
|
||||
#undef HAVE_FSTAT64
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `lseek64' function. */
|
||||
#undef HAVE_LSEEK64
|
||||
|
||||
/* Define to 1 if you have the `lstat64' function. */
|
||||
#undef HAVE_LSTAT64
|
||||
|
||||
/* Define to 1 if you have the `mbrlen' function. */
|
||||
#undef HAVE_MBRLEN
|
||||
|
||||
@ -96,6 +108,12 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `open64' function. */
|
||||
#undef HAVE_OPEN64
|
||||
|
||||
/* Define to 1 if you have the `stat64' function. */
|
||||
#undef HAVE_STAT64
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
@ -114,6 +132,9 @@
|
||||
/* 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/syscall.h> header file. */
|
||||
#undef HAVE_SYS_SYSCALL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: macros.h 399 2008-09-29 10:26:26Z baconevi $
|
||||
* $Id: macros.h 455 2008-11-26 09:05:00Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -147,6 +147,20 @@
|
||||
(ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
||||
#endif
|
||||
|
||||
/****d* ase/ASE_FNS
|
||||
* NAME
|
||||
* ASE_FNS - define an ASE function name space
|
||||
* DESCRIPTION
|
||||
* The ASE_FNS macro enables you to simulate a function name space for the
|
||||
* types designed properly.
|
||||
* EXAMPLE
|
||||
* ASE_FNS (awk, AWK);
|
||||
* ase_awk_t* awk = AWK.open (....);
|
||||
* AWK.close (awk);
|
||||
******
|
||||
*/
|
||||
#define ASE_NS(type,name) struct ase_ns_##type##_t name = ase_ns_##type##_d
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define ASE_BEGIN_NAMESPACE(x) namespace x {
|
||||
#define ASE_END_NAMESPACE(x) }
|
||||
|
Reference in New Issue
Block a user