1*d19ef5a2SAaron LI /*- 2*d19ef5a2SAaron LI * SPDX-License-Identifier: BSD-3-Clause 3*d19ef5a2SAaron LI * 4*d19ef5a2SAaron LI * Copyright (c) 2020 The DragonFly Project. All rights reserved. 5*d19ef5a2SAaron LI * 6*d19ef5a2SAaron LI * This code is derived from software contributed to The DragonFly Project 7*d19ef5a2SAaron LI * by Aaron LI <aly@aaronly.me> 8*d19ef5a2SAaron LI * 9*d19ef5a2SAaron LI * Redistribution and use in source and binary forms, with or without 10*d19ef5a2SAaron LI * modification, are permitted provided that the following conditions 11*d19ef5a2SAaron LI * are met: 12*d19ef5a2SAaron LI * 13*d19ef5a2SAaron LI * 1. Redistributions of source code must retain the above copyright 14*d19ef5a2SAaron LI * notice, this list of conditions and the following disclaimer. 15*d19ef5a2SAaron LI * 2. Redistributions in binary form must reproduce the above copyright 16*d19ef5a2SAaron LI * notice, this list of conditions and the following disclaimer in 17*d19ef5a2SAaron LI * the documentation and/or other materials provided with the 18*d19ef5a2SAaron LI * distribution. 19*d19ef5a2SAaron LI * 3. Neither the name of The DragonFly Project nor the names of its 20*d19ef5a2SAaron LI * contributors may be used to endorse or promote products derived 21*d19ef5a2SAaron LI * from this software without specific, prior written permission. 22*d19ef5a2SAaron LI * 23*d19ef5a2SAaron LI * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24*d19ef5a2SAaron LI * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25*d19ef5a2SAaron LI * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26*d19ef5a2SAaron LI * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27*d19ef5a2SAaron LI * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28*d19ef5a2SAaron LI * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 29*d19ef5a2SAaron LI * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30*d19ef5a2SAaron LI * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 31*d19ef5a2SAaron LI * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32*d19ef5a2SAaron LI * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 33*d19ef5a2SAaron LI * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34*d19ef5a2SAaron LI * SUCH DAMAGE. 35*d19ef5a2SAaron LI */ 36*d19ef5a2SAaron LI 37*d19ef5a2SAaron LI #ifndef PARSEDATA_H_ 38*d19ef5a2SAaron LI #define PARSEDATA_H_ 39*d19ef5a2SAaron LI 40*d19ef5a2SAaron LI #include <stdbool.h> 41*d19ef5a2SAaron LI 42*d19ef5a2SAaron LI #define F_NONE 0x00000 43*d19ef5a2SAaron LI #define F_MONTH 0x00001 44*d19ef5a2SAaron LI #define F_DAYOFWEEK 0x00002 45*d19ef5a2SAaron LI #define F_DAYOFMONTH 0x00004 46*d19ef5a2SAaron LI #define F_INDEX 0x00008 47*d19ef5a2SAaron LI #define F_OFFSET 0x00010 48*d19ef5a2SAaron LI #define F_SPECIALDAY 0x00020 49*d19ef5a2SAaron LI #define F_ALLMONTH 0x00040 50*d19ef5a2SAaron LI #define F_ALLDAY 0x00080 51*d19ef5a2SAaron LI #define F_VARIABLE 0x00100 52*d19ef5a2SAaron LI #define F_YEAR 0x00200 53*d19ef5a2SAaron LI 54*d19ef5a2SAaron LI struct cal_day; 55*d19ef5a2SAaron LI 56*d19ef5a2SAaron LI int parse_cal_date(const char *date, int *flags, struct cal_day **dayp, 57*d19ef5a2SAaron LI char **edp); 58*d19ef5a2SAaron LI 59*d19ef5a2SAaron LI bool parse_timezone(const char *s, int *result); 60*d19ef5a2SAaron LI bool parse_location(const char *s, double *latitude, double *longitude, 61*d19ef5a2SAaron LI double *elevation); 62*d19ef5a2SAaron LI bool parse_date(const char *date, int *rd_out); 63*d19ef5a2SAaron LI bool parse_time(const char *time, double *t_out); 64*d19ef5a2SAaron LI 65*d19ef5a2SAaron LI #endif 66