MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / _tmrec_parse

Function _tmrec_parse

time_rec.c:1555–1648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1553
1554
1555static inline int _tmrec_parse(const char *tr, tmrec_t *time_rec)
1556{
1557 char *p, *s;
1558 osips_free_t free_f = (time_rec->flags & PKG_ALLOC ?
1559 osips_pkg_free : osips_shm_free);
1560
1561 /* empty definition? */
1562 if (!tr || *tr == '\0')
1563 return 0;
1564
1565 p = (char *)tr;
1566
1567 load_TR_value(p, s, time_rec, tr_parse_tz, parse_error, done);
1568
1569 /* Important: make sure to set the tz NOW, before more parsing... */
1570 if (time_rec->tz)
1571 _tz_set(time_rec->tz);
1572
1573 load_TR_value(p, s, time_rec, tr_parse_dtstart, parse_error, done);
1574 load_TR_value(p, s, time_rec, tr_parse_dtend, parse_error, done);
1575 load_TR_value(p, s, time_rec, tr_parse_duration, parse_error, done);
1576 load_TR_value(p, s, time_rec, tr_parse_freq, parse_error, done);
1577 load_TR_value(p, s, time_rec, tr_parse_until, parse_error, done);
1578 load_TR_value(p, s, time_rec, tr_parse_interval, parse_error, done);
1579 load_TR_value(p, s, time_rec, tr_parse_byday, parse_error, done);
1580 load_TR_value(p, s, time_rec, tr_parse_bymday, parse_error, done);
1581 load_TR_value(p, s, time_rec, tr_parse_byyday, parse_error, done);
1582 load_TR_value(p, s, time_rec, tr_parse_byweekno, parse_error, done);
1583 load_TR_value(p, s, time_rec, tr_parse_bymonth, parse_error, done);
1584
1585done:
1586 if (time_rec->tz)
1587 tz_reset();
1588
1589 if (!_IS_SET(time_rec->dtstart))
1590 time_rec->dtstart = 0; /* invalid; auto-fix to 19700101T000000 */
1591
1592 if (!_IS_SET(time_rec->duration)) {
1593 if (!_IS_SET(time_rec->dtend)) {
1594 /* invalid; since we don't support mementos, we need a duration */
1595 switch (get_min_interval(time_rec)) {
1596 case FREQ_DAILY:
1597 time_rec->dtend = time_rec->dtstart + SEC_DAILY -
1598 (time_rec->ts.tm_hour * 3600 + time_rec->ts.tm_min * 60
1599 + time_rec->ts.tm_sec); /* until the end of the day */
1600 break;
1601 case FREQ_WEEKLY:
1602 time_rec->dtend = time_rec->dtstart + SEC_WEEKLY -
1603 (time_rec->ts.tm_wday * SEC_DAILY
1604 + time_rec->ts.tm_hour * 3600 + time_rec->ts.tm_min * 60
1605 + time_rec->ts.tm_sec); /* until the end of the week */
1606 break;
1607 case FREQ_MONTHLY:
1608 time_rec->dtend = time_rec->dtstart + SEC_MONTHLY_MAX -
1609 (time_rec->ts.tm_mday * SEC_DAILY
1610 + time_rec->ts.tm_hour * 3600 + time_rec->ts.tm_min * 60
1611 + time_rec->ts.tm_sec); /* until the end of the month */
1612 break;

Callers 3

tmrec_parseFunction · 0.85
_tmrec_check_strFunction · 0.85
tmrec_expr_parseFunction · 0.85

Calls 3

_tz_setFunction · 0.85
tz_resetFunction · 0.85
get_min_intervalFunction · 0.85

Tested by

no test coverage detected