*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-19 04:29:09 +00:00
parent f46aa21f07
commit 738900e74a
2 changed files with 62 additions and 41 deletions

View File

@ -26,12 +26,12 @@ The following code fragment illustrates the basic steps of embedding the process
}}}
(((
* Most of the functions and data types needed are defined in the header file ##ase/awk/awk.h##.
* ##ase_awk_t## represents the processor. However, the internal representation is not exposed.
* ##ase_awk_open## creates the processor instance.
* ##ase_awk_parse## parses an AWK script.
* ##ase_awk_run## executes the script parsed.
* ##ase_awk_close## destroys the processor instance.
* Most of the functions and data types needed are defined in the header file [[ase/awk/awk.h]].
* [[ase_awk_t]] represents the processor. However, the internal representation is not exposed.
* [[ase_awk_open]] creates the processor instance.
* [[ase_awk_parse]] parses an AWK script.
* [[ase_awk_run]] executes the script parsed.
* [[ase_awk_close]] destroys the processor instance.
)))
More detailed description is available {here,awk-mini-en.html}. You may refer to other sample files such as [[ase/test/awk/awk.c]] and [[ase/awk/jni.c]].
@ -57,7 +57,7 @@ struct ase_awk_prmfns_t
};
}}}
A caller of ##ase_awk_open## should fill in most of the fields of a ##ase_awk_prmfns_t## structure and pass the structure to it. The function pointers in the miscellaneous group labeled [misc] is defined as follows:
A caller of [[ase_awk_open]] should fill in most of the fields of a [[ase_awk_prmfns_t]] structure and pass the structure to it. The function pointers in the miscellaneous group labeled [misc] is defined as follows:
{{{
/* returns the value of x raised to the power of y */
@ -71,7 +71,7 @@ typedef int (*ase_awk_sprintf_t) (void* custom, ase_char_t* buf, ase_size_t size
typedef void (*ase_awk_dprintf_t) (void* custom, const ase_char_t* fmt, ...);
}}}
The fourth field of the group is passed to its member functions as the first argument on invocation. The function pointed by the ##sprintf## field should ensure that the resuliting string is null-terminated and ##%s## and ##%c## are accepted for the ##ase_char_t*## and ##ase_char_t## type respectively regardless the character mode.
The fourth field of the group is passed to its member functions as the first argument on invocation. The function pointed by the [[sprintf]] field should ensure that the resuliting string is null-terminated and [[%s]] and [[%c]] are accepted for the [[ase_char_t*]] and [[ase_char_t]] type respectively regardless the character mode.
The memory manager group labeled [mmgr] and the character class group labled [ccls] are defined as follows:
@ -110,7 +110,7 @@ struct ase_ccls_t
};
}}}
The functions in these groups perform the memory operations and character class related operations respectively. They follow the style of the memory allocation functions and character class handling functions of the standard C library except that they accept a pointer to the user-defined data as the first argument, thus providing more flexibility. The pointer to the user-defined data is specified into the ##custom_data## field of each group. The ##realloc## field, however, can be ##ASE_NULL##, in which case the functions pointed by the free and the malloc field replace the role of the function pointed by the ##realloc## field.
The functions in these groups perform the memory operations and character class related operations respectively. They follow the style of the memory allocation functions and character class handling functions of the standard C library except that they accept a pointer to the user-defined data as the first argument, thus providing more flexibility. The pointer to the user-defined data is specified into the [[custom_data]] field of each group. The [[realloc]] field, however, can be [[ASE_NULL]], in which case the functions pointed by the free and the malloc field replace the role of the function pointed by the [[realloc]] field.
=== Source IO Handler ===
@ -131,11 +131,11 @@ struct ase_awk_srcios_t
};
}}}
The ##in## field of the ase_awk_srcios_t is mandatory and should be filled in. The ##out## field can be set to ##ASE_NULL## or can point to a source output handling function. The ##custom_data## field is passed to the source handlers as the second argument. The first parameter ##cmd## of the source input handler is one of ##ASE_AWK_IO_OPEN##, ##ASE_AWK_IO_CLOSE##, ##ASE_AWK_IO_READ##. The first parameter ##cmd## of the source output handler is one of ##ASE_AWK_IO_OPEN##, ##ASE_AWK_IO_CLOSE##, ##ASE_AWK_IO_WRITE##. The third parameter ##data## and the fourth parameter ##count## are the pointer to the buffer to read data into and its size if the first parameter ##cmd## is ##ASE_AWK_IO_READ## while they are the pointer to the data and its size if ##cmd## is ##ASE_AWK_IO_WRITE##.
The [[in]] field of the ase_awk_srcios_t is mandatory and should be filled in. The [[out]] field can be set to [[ASE_NULL]] or can point to a source output handling function. The [[custom_data]] field is passed to the source handlers as the second argument. The first parameter [[cmd]] of the source input handler is one of [[ASE_AWK_IO_OPEN]], [[ASE_AWK_IO_CLOSE]], [[ASE_AWK_IO_READ]]. The first parameter [[cmd]] of the source output handler is one of [[ASE_AWK_IO_OPEN]], [[ASE_AWK_IO_CLOSE]], [[ASE_AWK_IO_WRITE]]. The third parameter [[data]] and the fourth parameter [[count]] are the pointer to the buffer to read data into and its size if the first parameter [[cmd]] is [[ASE_AWK_IO_READ]] while they are the pointer to the data and its size if [[cmd]] is [[ASE_AWK_IO_WRITE]].
The source handler should return a negative value for an error and zero or a positive value otherwise. However, there is a subtle difference in the meaning of the return value depending on the value of the first parameter ##cmd##.
The source handler should return a negative value for an error and zero or a positive value otherwise. However, there is a subtle difference in the meaning of the return value depending on the value of the first parameter [[cmd]].
When ##cmd## is ##ASE_AWK_IO_OPEN##, the return value of -1 and 1 indicates the failure and the success respectively. In addition, the return value of 0 indicates that the operation is successful but has reached the end of the stream. The library calls the handler with ##ASE_AWK_IO_CLOSE## for deinitialization if the return value is 0 or 1. When ##cmd## is ##ASE_AWK_IO_CLOSE##, the return value of -1 and 0 indicate the failure and the success respectively. When ##cmd## is ##ASE_AWK_IO_READ## or ##ASE_AWK_IO_WRITE##, the return value of -1 indicates the failure, 0 the end of the stream, and other positive values the number of characters read or written.
When [[cmd]] is [[ASE_AWK_IO_OPEN]], the return value of -1 and 1 indicates the failure and the success respectively. In addition, the return value of 0 indicates that the operation is successful but has reached the end of the stream. The library calls the handler with [[ASE_AWK_IO_CLOSE]] for deinitialization if the return value is 0 or 1. When [[cmd]] is [[ASE_AWK_IO_CLOSE]], the return value of -1 and 0 indicate the failure and the success respectively. When [[cmd]] is [[ASE_AWK_IO_READ]] or [[ASE_AWK_IO_WRITE]], the return value of -1 indicates the failure, 0 the end of the stream, and other positive values the number of characters read or written.
The typical source handler will look as follows:
{{{
@ -182,7 +182,7 @@ ase_ssize_t awk_srcio_out (int cmd, void* arg, ase_char_t* data, ase_size_t size
}
}}}
Once you have the source handler ready, you can fill in the fields of a ##ase_awk_srcios_t## structure and pass it to the call of ##ase_awk_parse##.
Once you have the source handler ready, you can fill in the fields of a [[ase_awk_srcios_t]] structure and pass it to the call of [[ase_awk_parse]].
{{{
ase_awk_srcios_t srcios;

View File

@ -2,54 +2,75 @@
== ASE Quck Start Guide ==
The first step in using this library is to build it as the pre-compiled binary is not available at this moment.
The first step in using this library is to build it as the pre-compiled binary is not available at this moment. This document shows how to build the core library on various operating systems.
=== Unix/Linux ===
== Unix/Linux ==
You may run the [[configure]] script on most of the Unix-like operation systems to set up the build environment and then run the [[make]] utility.
You may run the [[configure]] script on most of the Unix-like operation systems to set up the build environment and then run the [[make]] utility at the top-level directory.
{{{
$ ./configure
$ make
}}}
However, if you have preference for a particular compiler and the flags, you may explicitly specify them when you run the [[configure]] script.
The [[make]] utility visits each core module directory and build the library there. The [[test]] directory and its subdirectories are not built by default.
Here are presented a few such examples.
If you have preference for a particular compiler and the flags, you may explicitly specify them when you run the [[configure]] script. Here are presented a few such examples.
{{{
HP ANSI C
HP-UX B.11.23 9000/800
HP-UX B.11.23 ia64
for 64bit
CC=cc CFLAGS="-O2 +DD64" LDFLAGS="+DD64" ./configure
for 32bit
CC=cc CFLAGS="-O2 +DD32" LDFLAGS="+DD32" ./configure
SCO OpenServer Release 5.0.7 (SCO_SV 3.2 5.0.7)
# HP-UX B.11.23 with HP ANSI C
CC=cc CFLAGS="-O2 +DD64" LDFLAGS="+DD64" ./configure # 64-bit
CC=cc CFLAGS="-O2 +DD32" LDFLAGS="+DD32" ./configure # 32-bit
# SCO OpenServer Release 5.0.7 (SCO_SV 3.2 5.0.7) with SCO OpenServer Development System
CC=cc CFLAGS="-Xc -a ansi -O2" ./configure
Solaris
64 bit gcc
CC=gcc CFLAGS="-Wall -O2 -m64" LDFLAGS="-m64" ./configure
32 bit gcc
CC=gcc CFLAGS="-Wall -O2" ./configure
# Solaris 10 with GCC
CC=gcc CFLAGS="-Wall -O2 -m64" LDFLAGS="-m64" ./configure # 64-bit
CC=gcc CFLAGS="-Wall -O2" ./configure # 32-bit
}}}
=== OpenVMS ===
== OpenVMS ==
You may use the [[mms] command or the [[mmk]] command to build the library. No counterpart for the [[configure]] script is provided. As not top-level build script is provided, you have to run the command in each directory that you want to build the library in.
set default [.ase.awk]
Let's build the AWK library and its test program, for instance.
{{{
set default [.ase.cmn]
mms
set default [-.-.test.awk]
set default [-.awk]
mms
set default [-.utl]
mms
set default [-.test.awk]
mms
}}}
For those who are not familar with OpenVMS, here is one of the ways how to run the test program.
{{{
; define the foreign command.
aseawk :== $DISK$GEIN_SYS:[USERS.BACON.ASE.TEST.AWK]aseawk.exe
; run the command.
aseawk -f hello.awk
}}}
=== MS-Windows ===
You may use the Visual Studio 6 or later to use the provided project file. Otherwise open the command-line build environment and use the [[make]] utility.
A set of make scripts is provided to support the Microsoft build environement and the Borland build environment. The script for the Miscrosoft build environment is named [[makefile.msw.cl]] while it is [[makefile.msw.bcc]] for the Borland counterpart.
If you are building the AWK library and the test program, this might be what you have to do.
{{{
cd ase\cmn
nmake /f makefile.msw.cl
cd ..\awk
nmake /f makefile.msw.cl
cd ..\utl
nmake /f makefile.msw.cl
cd ..\test\awk
nmake /f makefile.msw.cl
}}}