Eneboo - Documentación para desarrolladores
|
#include "libexslt/libexslt.h"
#include "config.h"
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxslt/xsltconfig.h>
#include <libxslt/xsltutils.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/extensions.h>
#include "exslt.h"
#include <string.h>
Clases | |
struct | _exsltDateValDate |
struct | _exsltDateValDuration |
struct | _exsltDateVal |
'defines' | |
#define | IN_LIBEXSLT |
#define | IS_TZO_CHAR(c) ((c == 0) || (c == 'Z') || (c == '+') || (c == '-')) |
#define | VALID_ALWAYS(num) (num >= 0) |
#define | VALID_YEAR(yr) (yr != 0) |
#define | VALID_MONTH(mon) ((mon >= 1) && (mon <= 12)) |
#define | VALID_DAY(day) ((day >= 1) && (day <= 31)) |
#define | VALID_HOUR(hr) ((hr >= 0) && (hr <= 23)) |
#define | VALID_MIN(min) ((min >= 0) && (min <= 59)) |
#define | VALID_SEC(sec) ((sec >= 0) && (sec < 60)) |
#define | VALID_TZO(tzo) ((tzo > -1440) && (tzo < 1440)) |
#define | IS_LEAP(y) (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) |
#define | MAX_DAYINMONTH(yr, mon) (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1]) |
#define | VALID_MDAY(dt) |
#define | VALID_DATE(dt) (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) |
#define | VALID_TIME(dt) |
#define | VALID_DATETIME(dt) (VALID_DATE(dt) && VALID_TIME(dt)) |
#define | SECS_PER_MIN (60) |
#define | SECS_PER_HOUR (60 * SECS_PER_MIN) |
#define | SECS_PER_DAY (24 * SECS_PER_HOUR) |
#define | DAY_IN_YEAR(day, month, year) |
#define | FORMAT_GYEAR(yr, cur) |
#define | PARSE_2_DIGITS(num, cur, func, invalid) |
#define | FORMAT_2_DIGITS(num, cur) |
#define | PARSE_FLOAT(num, cur, invalid) |
#define | FORMAT_FLOAT(num, cur, pad) |
#define | FORMAT_GMONTH(mon, cur) FORMAT_2_DIGITS(mon, cur) |
#define | FORMAT_GDAY(dt, cur) FORMAT_2_DIGITS(dt->day, cur) |
#define | FORMAT_DATE(dt, cur) |
#define | FORMAT_TIME(dt, cur) |
#define | FORMAT_TZ(tzo, cur) |
#define | PARSE_DIGITS(num, cur, num_type) |
#define | PARSE_NUM(num, cur, num_type) |
#define | RETURN_TYPE_IF_VALID(t) |
#define | FORMAT_ITEM(num, cur, limit, item) |
#define | TIME_TO_NUMBER(dt) |
#define | FQUOTIENT(a, b) ((floor(((double)a/(double)b)))) |
#define | MODULO(a, b) ((a - FQUOTIENT(a,b) * b)) |
#define | FQUOTIENT_RANGE(a, low, high) (FQUOTIENT((a-low),(high-low))) |
#define | MODULO_RANGE(a, low, high) ((MODULO((a-low),(high-low)))+low) |
#define | X_IN_Y(x, y) |
'typedefs' | |
typedef struct _exsltDateValDate | exsltDateValDate |
typedef exsltDateValDate * | exsltDateValDatePtr |
typedef struct _exsltDateValDuration | exsltDateValDuration |
typedef exsltDateValDuration * | exsltDateValDurationPtr |
typedef struct _exsltDateVal | exsltDateVal |
typedef exsltDateVal * | exsltDateValPtr |
Enumeraciones | |
enum | exsltDateType { EXSLT_UNKNOWN = 0, XS_TIME = 1, XS_GDAY = (XS_TIME << 1), XS_GMONTH = (XS_GDAY << 1), XS_GMONTHDAY = (XS_GMONTH | XS_GDAY), XS_GYEAR = (XS_GMONTH << 1), XS_GYEARMONTH = (XS_GYEAR | XS_GMONTH), XS_DATE = (XS_GYEAR | XS_GMONTH | XS_GDAY), XS_DATETIME = (XS_DATE | XS_TIME), XS_DURATION = (XS_GYEAR << 1) } |
Funciones | |
void | exsltDateRegister (void) |
int | exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix) |
#define DAY_IN_YEAR | ( | day, | |
month, | |||
year | |||
) |
((IS_LEAP(year) ? \ dayInLeapYearByMonth[month - 1] : \ dayInYearByMonth[month - 1]) + day)
#define FORMAT_2_DIGITS | ( | num, | |
cur | |||
) |
#define FORMAT_DATE | ( | dt, | |
cur | |||
) |
FORMAT_GYEAR(dt->year, cur); \ *cur = '-'; \ cur++; \ FORMAT_GMONTH(dt->mon, cur); \ *cur = '-'; \ cur++; \ FORMAT_GDAY(dt, cur);
FORMAT_DATE: : the exsltDateValDate to format : a pointer to an allocated buffer
Formats in xsl:date format. Result is appended to and is updated to point after the xsl:date.
#define FORMAT_FLOAT | ( | num, | |
cur, | |||
pad | |||
) |
{ \ xmlChar *sav, *str; \ if ((pad) && (num < 10.0)) \ *cur++ = '0'; \ str = xmlXPathCastNumberToString(num); \ sav = str; \ while (*str != 0) \ *cur++ = *str++; \ xmlFree(sav); \ }
FORMAT_FLOAT: : the double to format : a pointer to an allocated buffer : a flag for padding to 2 integer digits
Formats a float. Result is appended to and is updated to point after the integer. If the flag is non-zero, then the float representation has a minimum 2-digits integer part. The fractional part is formatted if has a fractional value.
#define FORMAT_GDAY | ( | dt, | |
cur | |||
) | FORMAT_2_DIGITS(dt->day, cur) |
FORMAT_GDAY: : the exsltDateValDate to format : a pointer to an allocated buffer
Formats in xsl:gDay format. Result is appended to and is updated to point after the xsl:gDay.
#define FORMAT_GMONTH | ( | mon, | |
cur | |||
) | FORMAT_2_DIGITS(mon, cur) |
FORMAT_GMONTH: : the month to format : a pointer to an allocated buffer
Formats in xsl:gMonth format. Result is appended to and is updated to point after the xsl:gMonth.
#define FORMAT_GYEAR | ( | yr, | |
cur | |||
) |
if (yr < 0) { \ *cur = '-'; \ cur++; \ } \ { \ long year = (yr < 0) ? - yr : yr; \ xmlChar tmp_buf[100], *tmp = tmp_buf; \ /* result is in reverse-order */ \ while (year > 0) { \ *tmp = '0' + (xmlChar)(year % 10); \ year /= 10; \ tmp++; \ } \ /* virtually adds leading zeros */ \ while ((tmp - tmp_buf) < 4) \ *tmp++ = '0'; \ /* restore the correct order */ \ while (tmp > tmp_buf) { \ tmp--; \ *cur = *tmp; \ cur++; \ } \ }
FORMAT_GYEAR: : the year to format : a pointer to an allocated buffer
Formats in xsl:gYear format. Result is appended to and is updated to point after the xsl:gYear.
#define FORMAT_ITEM | ( | num, | |
cur, | |||
limit, | |||
item | |||
) |
if (num != 0) { \ long comp = (long)num / limit; \ if (comp != 0) { \ FORMAT_FLOAT((double)comp, cur, 0); \ *cur++ = item; \ num -= (double)(comp * limit); \ } \ }
FORMAT_ITEM: : number to format : current location to convert number : max value : char designator
#define FORMAT_TIME | ( | dt, | |
cur | |||
) |
FORMAT_2_DIGITS(dt->hour, cur); \ *cur = ':'; \ cur++; \ FORMAT_2_DIGITS(dt->min, cur); \ *cur = ':'; \ cur++; \ FORMAT_FLOAT(dt->sec, cur, 1);
FORMAT_TIME: : the exsltDateValDate to format : a pointer to an allocated buffer
Formats in xsl:time format. Result is appended to and is updated to point after the xsl:time.
#define FORMAT_TZ | ( | tzo, | |
cur | |||
) |
if (tzo == 0) { \ *cur = 'Z'; \ cur++; \ } else { \ int aTzo = (tzo < 0) ? - tzo : tzo; \ int tzHh = aTzo / 60, tzMm = aTzo % 60; \ *cur = (tzo < 0) ? '-' : '+' ; \ cur++; \ FORMAT_2_DIGITS(tzHh, cur); \ *cur = ':'; \ cur++; \ FORMAT_2_DIGITS(tzMm, cur); \ }
FORMAT_TZ: : the timezone offset to format : a pointer to an allocated buffer
Formats timezone. Result is appended to and is updated to point after the timezone.
#define IN_LIBEXSLT |
#define IS_LEAP | ( | y | ) | (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) |
#define MAX_DAYINMONTH | ( | yr, | |
mon | |||
) | (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1]) |
#define PARSE_2_DIGITS | ( | num, | |
cur, | |||
func, | |||
invalid | |||
) |
if ((cur[0] < '0') || (cur[0] > '9') || \ (cur[1] < '0') || (cur[1] > '9')) \ invalid = 1; \ else { \ int val; \ val = (cur[0] - '0') * 10 + (cur[1] - '0'); \ if (!func(val)) \ invalid = 2; \ else \ num = val; \ } \ cur += 2;
PARSE_2_DIGITS: : the integer to fill in : an xmlChar * : validation function for the number : an integer
Parses a 2-digits integer and updates with the value. is updated to point just after the integer. In case of error, is set to TRUE, values of and are undefined.
#define PARSE_DIGITS | ( | num, | |
cur, | |||
num_type | |||
) |
if ((*cur < '0') || (*cur > '9')) \ num_type = -1; \ else \ while ((*cur >= '0') && (*cur <= '9')) { \ num = num * 10 + (*cur - '0'); \ cur++; \ }
PARSE_DIGITS: : the integer to fill in : an xmlChar * : an integer flag
Parses a digits integer and updates with the value. is updated to point just after the integer. In case of error, is set to -1, values of and are undefined.
#define PARSE_FLOAT | ( | num, | |
cur, | |||
invalid | |||
) |
PARSE_2_DIGITS(num, cur, VALID_ALWAYS, invalid); \ if (!invalid && (*cur == '.')) { \ double mult = 1; \ cur++; \ if ((*cur < '0') || (*cur > '9')) \ invalid = 1; \ while ((*cur >= '0') && (*cur <= '9')) { \ mult /= 10; \ num += (*cur - '0') * mult; \ cur++; \ } \ }
PARSE_FLOAT: : the double to fill in : an xmlChar * : an integer
Parses a float and updates with the value. is updated to point just after the float. The float must have a 2-digits integer part and may or may not have a decimal part. In case of error, is set to TRUE, values of and are undefined.
#define PARSE_NUM | ( | num, | |
cur, | |||
num_type | |||
) |
num = 0; \ PARSE_DIGITS(num, cur, num_type); \ if (!num_type && (*cur == '.')) { \ double mult = 1; \ cur++; \ if ((*cur < '0') || (*cur > '9')) \ num_type = -1; \ else \ num_type = 1; \ while ((*cur >= '0') && (*cur <= '9')) { \ mult /= 10; \ num += (*cur - '0') * mult; \ cur++; \ } \ }
PARSE_NUM: : the double to fill in : an xmlChar * : an integer flag
Parses a float or integer and updates with the value. is updated to point just after the number. If the number is a float, then it must have an integer part and a decimal part; will be set to 1. If there is no decimal part, is set to zero. In case of error, is set to -1, values of and are undefined.
#define RETURN_TYPE_IF_VALID | ( | t | ) |
if (IS_TZO_CHAR(*cur)) { \ ret = _exsltDateParseTimeZone(&(dt->value.date), &cur); \ if (ret == 0) { \ if (*cur != 0) \ goto error; \ dt->type = t; \ return dt; \ } \ }
#define SECS_PER_DAY (24 * SECS_PER_HOUR) |
#define SECS_PER_HOUR (60 * SECS_PER_MIN) |
#define SECS_PER_MIN (60) |
#define TIME_TO_NUMBER | ( | dt | ) |
((double)((dt->value.date.hour * SECS_PER_HOUR) + \ (dt->value.date.min * SECS_PER_MIN)) + dt->value.date.sec)
TIME_TO_NUMBER: : an exsltDateValPtr
Calculates the number of seconds in the time portion of .
Returns seconds.
#define VALID_DATE | ( | dt | ) | (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) |
#define VALID_DATETIME | ( | dt | ) | (VALID_DATE(dt) && VALID_TIME(dt)) |
#define VALID_DAY | ( | day | ) | ((day >= 1) && (day <= 31)) |
#define VALID_HOUR | ( | hr | ) | ((hr >= 0) && (hr <= 23)) |
#define VALID_MDAY | ( | dt | ) |
(IS_LEAP(dt->year) ? \ (dt->day <= daysInMonthLeap[dt->mon - 1]) : \ (dt->day <= daysInMonth[dt->mon - 1]))
#define VALID_MIN | ( | min | ) | ((min >= 0) && (min <= 59)) |
#define VALID_MONTH | ( | mon | ) | ((mon >= 1) && (mon <= 12)) |
#define VALID_SEC | ( | sec | ) | ((sec >= 0) && (sec < 60)) |
#define VALID_TIME | ( | dt | ) |
#define VALID_TZO | ( | tzo | ) | ((tzo > -1440) && (tzo < 1440)) |
#define VALID_YEAR | ( | yr | ) | (yr != 0) |
#define X_IN_Y | ( | x, | |
y | |||
) |
static void \ exsltDate##x##In##y##Function (xmlXPathParserContextPtr ctxt, \ int nargs) { \ xmlChar *dt = NULL; \ double ret; \ \ if ((nargs < 0) || (nargs > 1)) { \ xmlXPathSetArityError(ctxt); \ return; \ } \ \ if (nargs == 1) { \ dt = xmlXPathPopString(ctxt); \ if (xmlXPathCheckError(ctxt)) { \ xmlXPathSetTypeError(ctxt); \ return; \ } \ } \ \ ret = exsltDate##x##In##y(dt); \ \ if (dt != NULL) \ xmlFree(dt); \ \ xmlXPathReturnNumber(ctxt, ret); \ }
typedef struct _exsltDateVal exsltDateVal |
typedef struct _exsltDateValDate exsltDateValDate |
typedef exsltDateValDate* exsltDateValDatePtr |
typedef struct _exsltDateValDuration exsltDateValDuration |
typedef exsltDateVal* exsltDateValPtr |
enum exsltDateType |
void exsltDateRegister | ( | void | ) |
exsltDateRegister:
Registers the EXSLT - Dates and Times module