added ase_gettime() and ase_settime(), also added many builtin functions to ase_awk_opensimple()
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.hpp 468 2008-12-10 10:19:59Z baconevi $
|
||||
* $Id: StdAwk.hpp 499 2008-12-16 09:42:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -23,6 +23,7 @@ class StdAwk: public Awk
|
||||
public:
|
||||
StdAwk ();
|
||||
int open ();
|
||||
int run (const char_t* main, const char_t** args, size_t nargs);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h 496 2008-12-15 09:56:48Z baconevi $
|
||||
* $Id: awk.h 499 2008-12-16 09:42:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1142,17 +1142,68 @@ void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val);
|
||||
void ase_awk_freevalchunk (ase_awk_run_t* run, ase_awk_val_chunk_t* chunk);
|
||||
|
||||
ase_bool_t ase_awk_valtobool (
|
||||
ase_awk_run_t* run, ase_awk_val_t* val);
|
||||
ase_awk_run_t* run,
|
||||
ase_awk_val_t* val
|
||||
);
|
||||
|
||||
ase_char_t* ase_awk_valtostr (
|
||||
ase_awk_run_t* run, ase_awk_val_t* val,
|
||||
int opt, ase_str_t* buf, ase_size_t* len);
|
||||
ase_awk_run_t* run,
|
||||
ase_awk_val_t* val,
|
||||
int opt,
|
||||
ase_str_t* buf,
|
||||
ase_size_t* len
|
||||
);
|
||||
|
||||
/****f* ase.awk/ase_awk_valtonum
|
||||
* NAME
|
||||
* ase_awk_valtonum - convert a value to a number
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_awk_valtonum() function converts a value to a number.
|
||||
* The converted value is stored into the variable pointed to by
|
||||
* either l or r depending on the type of the number. If the value
|
||||
* is converted to a long number, the function returns 0 and l is
|
||||
* set with the converted number. If the value is converted to a real number,
|
||||
* the function returns 1 and r is set with a real number.
|
||||
*
|
||||
* RETURN
|
||||
* The ase_awk_valtonum() function returns -1 on error, 0 if the converted
|
||||
* value is a long number and 1 if it is a real number.
|
||||
*
|
||||
* EXAMPLES
|
||||
* ase_long_t l;
|
||||
* ase_real_t r;
|
||||
* int n;
|
||||
*
|
||||
* n = ase_awk_valtonum (v, &l, &r);
|
||||
* if (n == -1) error ();
|
||||
* else if (n == 0) do_long (l);
|
||||
* else if (n == 1) do_real (r);
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_awk_valtonum (
|
||||
ase_awk_run_t* run, ase_awk_val_t* v, ase_long_t* l, ase_real_t* r);
|
||||
ase_awk_run_t* run,
|
||||
ase_awk_val_t* v /* the value to convert to a number */,
|
||||
ase_long_t* l /* a pointer to a long number */,
|
||||
ase_real_t* r /* a pointer to a ase_real_t */
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* ase.awk/ase_awk_strtonum
|
||||
* NAME
|
||||
* ase_awk_strtonum - convert a string to a number
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int ase_awk_strtonum (
|
||||
ase_awk_run_t* run, const ase_char_t* ptr, ase_size_t len,
|
||||
ase_long_t* l, ase_real_t* r);
|
||||
ase_awk_run_t* run,
|
||||
const ase_char_t* ptr,
|
||||
ase_size_t len,
|
||||
ase_long_t* l,
|
||||
ase_real_t* r
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h tio.h sio.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 sio.h time.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 fio.h tio.h sio.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 sio.h time.h
|
||||
CLEANFILES = *dist
|
||||
all: all-am
|
||||
|
||||
|
47
ase/include/ase/cmn/time.h
Normal file
47
ase/include/ase/cmn/time.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ASE_CMN_TIME_H_
|
||||
#define _ASE_CMN_TIME_H_
|
||||
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
#define ASE_EPOCH_YEAR ((ase_time_t)1970)
|
||||
#define ASE_EPOCH_MON ((ase_time_t)1)
|
||||
#define ASE_EPOCH_DAY ((ase_time_t)1)
|
||||
#define ASE_EPOCH_WDAY ((ase_time_t)4)
|
||||
|
||||
#define ASE_DAY_IN_WEEK ((ase_time_t)7)
|
||||
#define ASE_MON_IN_YEAR ((ase_time_t)12)
|
||||
#define ASE_HOUR_IN_DAY ((ase_time_t)24)
|
||||
#define ASE_MIN_IN_HOUR ((ase_time_t)60)
|
||||
#define ASE_MIN_IN_DAY (ASE_MIN_IN_HOUR * ASE_HOUR_IN_DAY)
|
||||
#define ASE_SEC_IN_MIN ((ase_time_t)60)
|
||||
#define ASE_SEC_IN_HOUR (ASE_SEC_IN_MIN * ASE_MIN_IN_HOUR)
|
||||
#define ASE_SEC_IN_DAY (ASE_SEC_IN_MIN * ASE_MIN_IN_DAY)
|
||||
#define ASE_MSEC_IN_SEC ((ase_time_t)1000)
|
||||
#define ASE_MSEC_IN_MIN (ASE_MSEC_IN_SEC * ASE_SEC_IN_MIN)
|
||||
#define ASE_MSEC_IN_HOUR (ASE_MSEC_IN_SEC * ASE_SEC_IN_HOUR)
|
||||
#define ASE_MSEC_IN_DAY (ASE_MSEC_IN_SEC * ASE_SEC_IN_DAY)
|
||||
|
||||
#define ASE_USEC_IN_MSEC ((ase_time_t)1000)
|
||||
#define ASE_NSEC_IN_USEC ((ase_time_t)1000)
|
||||
#define ASE_USEC_IN_SEC ((ase_time_t)ASE_USEC_IN_MSEC * ASE_MSEC_IN_SEC)
|
||||
|
||||
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
|
||||
typedef ase_long_t ase_time_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ase_gettime (ase_time_t* t);
|
||||
int ase_settime (ase_time_t t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -78,9 +78,45 @@
|
||||
/* patch level */
|
||||
#undef ASE_VERSION_PATCH
|
||||
|
||||
/* Define to 1 if you have the `atan' function. */
|
||||
#undef HAVE_ATAN
|
||||
|
||||
/* Define to 1 if you have the `atan2' function. */
|
||||
#undef HAVE_ATAN2
|
||||
|
||||
/* Define to 1 if you have the `atan2f' function. */
|
||||
#undef HAVE_ATAN2F
|
||||
|
||||
/* Define to 1 if you have the `atan2l' function. */
|
||||
#undef HAVE_ATAN2L
|
||||
|
||||
/* Define to 1 if you have the `atanf' function. */
|
||||
#undef HAVE_ATANF
|
||||
|
||||
/* Define to 1 if you have the `atanl' function. */
|
||||
#undef HAVE_ATANL
|
||||
|
||||
/* Define to 1 if you have the `cos' function. */
|
||||
#undef HAVE_COS
|
||||
|
||||
/* Define to 1 if you have the `cosf' function. */
|
||||
#undef HAVE_COSF
|
||||
|
||||
/* Define to 1 if you have the `cosl' function. */
|
||||
#undef HAVE_COSL
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `exp' function. */
|
||||
#undef HAVE_EXP
|
||||
|
||||
/* Define to 1 if you have the `expf' function. */
|
||||
#undef HAVE_EXPF
|
||||
|
||||
/* Define to 1 if you have the `expl' function. */
|
||||
#undef HAVE_EXPL
|
||||
|
||||
/* Define to 1 if you have the `fstat64' function. */
|
||||
#undef HAVE_FSTAT64
|
||||
|
||||
@ -90,6 +126,15 @@
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `log' function. */
|
||||
#undef HAVE_LOG
|
||||
|
||||
/* Define to 1 if you have the `logf' function. */
|
||||
#undef HAVE_LOGF
|
||||
|
||||
/* Define to 1 if you have the `logl' function. */
|
||||
#undef HAVE_LOGL
|
||||
|
||||
/* Define to 1 if you have the `lseek64' function. */
|
||||
#undef HAVE_LSEEK64
|
||||
|
||||
@ -108,6 +153,33 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
/* Define to 1 if you have the `powf' function. */
|
||||
#undef HAVE_POWF
|
||||
|
||||
/* Define to 1 if you have the `powl' function. */
|
||||
#undef HAVE_POWL
|
||||
|
||||
/* Define to 1 if you have the `sin' function. */
|
||||
#undef HAVE_SIN
|
||||
|
||||
/* Define to 1 if you have the `sinf' function. */
|
||||
#undef HAVE_SINF
|
||||
|
||||
/* Define to 1 if you have the `sinl' function. */
|
||||
#undef HAVE_SINL
|
||||
|
||||
/* Define to 1 if you have the `sqrt' function. */
|
||||
#undef HAVE_SQRT
|
||||
|
||||
/* Define to 1 if you have the `sqrtf' function. */
|
||||
#undef HAVE_SQRTF
|
||||
|
||||
/* Define to 1 if you have the `sqrtl' function. */
|
||||
#undef HAVE_SQRTL
|
||||
|
||||
/* Define to 1 if you have the `stat64' function. */
|
||||
#undef HAVE_STAT64
|
||||
|
||||
@ -135,6 +207,15 @@
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the `tan' function. */
|
||||
#undef HAVE_TAN
|
||||
|
||||
/* Define to 1 if you have the `tanf' function. */
|
||||
#undef HAVE_TANF
|
||||
|
||||
/* Define to 1 if you have the `tanl' function. */
|
||||
#undef HAVE_TANL
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
|
Reference in New Issue
Block a user