ipa_timerules.c revision b9f94bc83f139df3e143cc020b98e6e652887049
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen IPA Provider Time Rules Parsing
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen Jakub Hrozek <jhrozek@redhat.com>
965ed6ea3fc8f7637bd0d159d2fdb283a191ce34Timo Sirainen Copyright (C) Red Hat, Inc 2009
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen This program is free software; you can redistribute it and/or modify
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen it under the terms of the GNU General Public License as published by
3b94ff5951db4d4eddb7a80ed4e3f61207202635Timo Sirainen the Free Software Foundation; either version 3 of the License, or
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainen (at your option) any later version.
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen This program is distributed in the hope that it will be useful,
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0373a24e97602b4c394e93a70b75f45e5869fa51Timo Sirainen GNU General Public License for more details.
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainen You should have received a copy of the GNU General Public License
22535a9e685e29214082878e37a267157044618eTimo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainen#define _XOPEN_SOURCE /* strptime() needs this */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen ptr = talloc_array(ctx, unsigned char, count); \
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen memset(ptr, 0, sizeof(unsigned char)*count); \
if (bitfield) { \
*resptr = false; \
return EOK; \
if (bitfield) { \
*resptr = false; \
return EOK; \
#define RGX_GENERALIZED "(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})(?P<hour>[0-9]{2})?(?P<minute>[0-9]{2})?(?P<second>[0-9]{2})?"
#define RGX_PERIODIC "^periodic (?P<perspec>daily|weekly|monthly|yearly) (?P<period>.*?)"RGX_TIMESPEC"$"
static const char *names_day_of_week[] =
static const char *names_months[] =
enum rangetypes {
struct absolute_range {
struct periodic_range {
unsigned char day_of_week;
unsigned char *day_of_month;
unsigned char *day_of_year;
unsigned char week_of_month;
unsigned char *week_of_year;
unsigned char *month;
unsigned char *hour;
unsigned char *minute;
struct range_ctx {
struct parse_ctx {
int matches;
int *ovec;
enum timelib_rgx {
static const char *lookup_table[] = {
NULL,
struct time_rules_ctx {
* in tarball of fcron, file bitstring.h
unsigned int stop)
int index = 0;
const char *one;
index++;
unsigned char *out,
const char *str,
const char **translate)
char *copy;
char *end_ptr;
int ret;
char *dash;
while (next) {
if (next) {
next++;
errno = 0;
goto done;
++dash;
errno = 0;
goto done;
errno = 0;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
const char *str,
const char *substr_name,
char **out)
int ret;
char *o = NULL;
return ENOENT;
if (o == NULL) {
return ENOMEM;
*out = o;
return EOK;
const char *str,
const char *substr_name,
int *out)
int ret;
int val;
char *err_ptr;
return ret;
errno = 0;
substr));
return EINVAL;
return EOK;
const char *str,
int ret;
if (ret <= 0) {
goto done;
return EOK;
done:
return ret;
if (fs <= 0) {
t->tm_mon--;
t->tm_mon++;
const char *str,
int ret;
done:
return ret;
const char *str)
int ret;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
struct tm t;
char *err;
return EINVAL;
return EOK;
const char *str)
int ret;
done:
return ret;
const char *str)
int ret;
done:
return ret;
const char *str)
int ret;
done:
return ret;
const char *str)
int ret;
int hour_from;
int hour_to;
int min_from;
int min_to;
done:
return ret;
const char *str)
int ret;
goto done;
done:
return ret;
int ret;
goto done;
done:
return ret;
bool *result)
*result = false;
return EOK;
*result = false;
return EOK;
*result = true;
return EOK;
bool *result)
int wnum;
int wom;
return EFAULT;
return EINVAL;
return EINVAL;
*result = true;
return EOK;
bool *result)
int ret;
case TYPE_ABSOLUTE:
case TYPE_PERIODIC:
return ret;
const char *str,
bool *result)
int ret;
goto done;
goto done;
done:
return EOK;
for (i = 0; i< LP_RGX_MAX; ++i) {
const char *errstr;
int errval;
int errpos;
int ret;
&errval,
&errstr,
&errpos,
NULL);
goto done;
return EOK;
done:
return ret;