xref: /freebsd/usr.sbin/newsyslog/extern.h (revision b326fec486bf8f8c81b7c01cbdc439cee21ad4e1)
12f8d7c56SGarance A Drosehn /*-
22f8d7c56SGarance A Drosehn  * ------+---------+---------+---------+---------+---------+---------+---------*
32f8d7c56SGarance A Drosehn  * Copyright (c) 2003  - Garance Alistair Drosehn <gad@FreeBSD.org>.
42f8d7c56SGarance A Drosehn  * All rights reserved.
52f8d7c56SGarance A Drosehn  *
62f8d7c56SGarance A Drosehn  * Redistribution and use in source and binary forms, with or without
72f8d7c56SGarance A Drosehn  * modification, are permitted provided that the following conditions
82f8d7c56SGarance A Drosehn  * are met:
92f8d7c56SGarance A Drosehn  *   1. Redistributions of source code must retain the above copyright
102f8d7c56SGarance A Drosehn  *      notice, this list of conditions and the following disclaimer.
112f8d7c56SGarance A Drosehn  *   2. Redistributions in binary form must reproduce the above copyright
122f8d7c56SGarance A Drosehn  *      notice, this list of conditions and the following disclaimer in the
132f8d7c56SGarance A Drosehn  *      documentation and/or other materials provided with the distribution.
142f8d7c56SGarance A Drosehn  *
152f8d7c56SGarance A Drosehn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
162f8d7c56SGarance A Drosehn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172f8d7c56SGarance A Drosehn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182f8d7c56SGarance A Drosehn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192f8d7c56SGarance A Drosehn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202f8d7c56SGarance A Drosehn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212f8d7c56SGarance A Drosehn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222f8d7c56SGarance A Drosehn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232f8d7c56SGarance A Drosehn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242f8d7c56SGarance A Drosehn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252f8d7c56SGarance A Drosehn  * SUCH DAMAGE.
262f8d7c56SGarance A Drosehn  *
272f8d7c56SGarance A Drosehn  * The views and conclusions contained in the software and documentation
282f8d7c56SGarance A Drosehn  * are those of the authors and should not be interpreted as representing
292f8d7c56SGarance A Drosehn  * official policies, either expressed or implied, of the FreeBSD Project.
302f8d7c56SGarance A Drosehn  *
312f8d7c56SGarance A Drosehn  * ------+---------+---------+---------+---------+---------+---------+---------*
322f8d7c56SGarance A Drosehn  * $FreeBSD$
332f8d7c56SGarance A Drosehn  * ------+---------+---------+---------+---------+---------+---------+---------*
342f8d7c56SGarance A Drosehn  */
352f8d7c56SGarance A Drosehn 
362f8d7c56SGarance A Drosehn #include <sys/cdefs.h>
372f8d7c56SGarance A Drosehn #include <time.h>
382f8d7c56SGarance A Drosehn 
396a1485e2SGarance A Drosehn #define	PTM_PARSE_ISO8601	0x0001	/* Parse ISO-standard format */
406a1485e2SGarance A Drosehn #define	PTM_PARSE_DWM		0x0002	/* Parse Day-Week-Month format */
416a1485e2SGarance A Drosehn #define	PTM_PARSE_MATCHDOM	0x0004	/* If the user specifies a day-of-month,
426a1485e2SGarance A Drosehn 					 * then the result should be a month
436a1485e2SGarance A Drosehn 					 * which actually has that day.  Eg:
446a1485e2SGarance A Drosehn 					 * the user requests "day 31" when
456a1485e2SGarance A Drosehn 					 * the present month is February. */
466a1485e2SGarance A Drosehn 
476a1485e2SGarance A Drosehn struct ptime_data;
486a1485e2SGarance A Drosehn 
496a1485e2SGarance A Drosehn /* Some global variables from newsyslog.c which might be of interest */
506a1485e2SGarance A Drosehn extern int	 dbg_at_times;		/* cmdline debugging option */
512f8d7c56SGarance A Drosehn extern int	 noaction;		/* command-line option */
522f8d7c56SGarance A Drosehn extern int	 verbose;		/* command-line option */
536a1485e2SGarance A Drosehn extern struct ptime_data *dbg_timenow;
542f8d7c56SGarance A Drosehn 
552f8d7c56SGarance A Drosehn __BEGIN_DECLS
566a1485e2SGarance A Drosehn struct ptime_data *ptime_init(const struct ptime_data *_optsrc);
576a1485e2SGarance A Drosehn int		 ptime_adjust4dst(struct ptime_data *_ptime, const struct
586a1485e2SGarance A Drosehn 		    ptime_data *_dstsrc);
596a1485e2SGarance A Drosehn int		 ptime_free(struct ptime_data *_ptime);
606a1485e2SGarance A Drosehn int		 ptime_relparse(struct ptime_data *_ptime, int _parseopts,
616a1485e2SGarance A Drosehn 		    time_t _basetime, const char *_str);
626a1485e2SGarance A Drosehn const char	*ptimeget_ctime(const struct ptime_data *_ptime);
63*b326fec4SDavid Bright char		*ptimeget_ctime_rfc5424(const struct ptime_data *_ptime,
64*b326fec4SDavid Bright 		    char *timebuf, size_t bufsize);
656a1485e2SGarance A Drosehn double		 ptimeget_diff(const struct ptime_data *_minuend,
666a1485e2SGarance A Drosehn 		    const struct ptime_data *_subtrahend);
676a1485e2SGarance A Drosehn time_t		 ptimeget_secs(const struct ptime_data *_ptime);
686a1485e2SGarance A Drosehn int		 ptimeset_nxtime(struct ptime_data *_ptime);
696a1485e2SGarance A Drosehn int		 ptimeset_time(struct ptime_data *_ptime, time_t _secs);
702f8d7c56SGarance A Drosehn __END_DECLS
71