documented the source code a little bit

This commit is contained in:
2009-02-17 21:27:03 +00:00
parent fed0a952ab
commit 80dfcd497c
8 changed files with 83 additions and 57 deletions

View File

@ -1,3 +1,9 @@
/****S* AWK/Basic Loop
* DESCRIPTION
* This program demonstrates how to use qse_awk_rtx_loop().
* SOURCE
*/
#include <qse/awk/awk.h>
#include <qse/utl/stdio.h>
@ -61,3 +67,5 @@ oops:
if (awk != QSE_NULL) qse_awk_close (awk);
return -1;
}
/******/

View File

@ -1,4 +1,4 @@
/****S* Sample/AWK
/****S* AWK/Calling Functions
* DESCRIPTION
* This program demonstrates how to use qse_awk_rtx_call().
* SOURCE
@ -7,13 +7,13 @@
#include <qse/awk/awk.h>
#include <qse/utl/stdio.h>
const qse_char_t* src = QSE_T(
static const qse_char_t* src = QSE_T(
"function init() { a = 20; }"
"function main() { a++; }"
"function fini() { print a; }"
);
const qse_char_t* f[] =
static const qse_char_t* f[] =
{
QSE_T("init"),
QSE_T("main"),
@ -29,6 +29,7 @@ int main ()
qse_awk_rtx_t* rtx = QSE_NULL;
int ret, i;
/* create a main processor */
awk = qse_awk_opensimple ();
if (awk == QSE_NULL)
{
@ -51,6 +52,7 @@ int main ()
goto oops;
}
/* create a runtime context */
rtx = qse_awk_rtx_opensimple (
awk,
QSE_NULL /* no console files */
@ -62,19 +64,22 @@ int main ()
ret = -1; goto oops;
}
/* invoke functions as indicated in the array f */
for (i = 0; i < QSE_COUNTOF(f); i++)
{
ret = qse_awk_rtx_call (rtx, f[i], QSE_NULL, 0);
if (ret == -1)
{
qse_fprintf (QSE_STDERR, QSE_T("%d error: %s\n"),
i, qse_awk_rtx_geterrmsg(rtx));
qse_fprintf (QSE_STDERR, QSE_T("error: %s\n"),
qse_awk_rtx_geterrmsg(rtx));
goto oops;
}
}
oops:
/* destroy a runtime context */
if (rtx != QSE_NULL) qse_awk_rtx_close (rtx);
/* destroy the processor */
if (awk != QSE_NULL) qse_awk_close (awk);
return ret;
}