blob: 25aeeaf7041ecb5d2db4e97a30b0edc7a6da47ad [file] [log] [blame]
Denis Vlasenko83ea6432006-11-16 02:27:24 +00001/*
2Copyright (c) 2001-2006, Gerrit Pape
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
Denis Vlasenko83ea6432006-11-16 02:27:24 +000028/*** byte.h ***/
29
30extern unsigned byte_chr(char *s,unsigned n,int c);
31
32
33/*** coe.h ***/
34
35extern int coe(int);
36
37
38/*** direntry.h ***/
39
40#define direntry struct dirent
41
42
Denis Vlasenko83ea6432006-11-16 02:27:24 +000043/*** tai.h ***/
44
45struct tai {
46 uint64_t x;
Denis Vlasenko8c783952007-01-27 22:21:52 +000047};
Denis Vlasenko83ea6432006-11-16 02:27:24 +000048
49#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64_t) (u)))
50
Denis Vlasenko83ea6432006-11-16 02:27:24 +000051#define TAI_PACK 8
Denis Vlasenko8c783952007-01-27 22:21:52 +000052//extern void tai_pack(char *,const struct tai *);
Denis Vlasenko83ea6432006-11-16 02:27:24 +000053extern void tai_unpack(const char *,struct tai *);
54
55extern void tai_uint(struct tai *,unsigned);
56
57
58/*** taia.h ***/
59
60struct taia {
61 struct tai sec;
62 unsigned long nano; /* 0...999999999 */
63 unsigned long atto; /* 0...999999999 */
Denis Vlasenko8c783952007-01-27 22:21:52 +000064};
Denis Vlasenko83ea6432006-11-16 02:27:24 +000065
Denis Vlasenko8c783952007-01-27 22:21:52 +000066//extern void taia_tai(const struct taia *,struct tai *);
Denis Vlasenko83ea6432006-11-16 02:27:24 +000067
68extern void taia_now(struct taia *);
69
Denis Vlasenko83ea6432006-11-16 02:27:24 +000070extern void taia_add(struct taia *,const struct taia *,const struct taia *);
71extern void taia_addsec(struct taia *,const struct taia *,int);
72extern void taia_sub(struct taia *,const struct taia *,const struct taia *);
73extern void taia_half(struct taia *,const struct taia *);
74extern int taia_less(const struct taia *,const struct taia *);
75
76#define TAIA_PACK 16
77extern void taia_pack(char *,const struct taia *);
Denis Vlasenko8c783952007-01-27 22:21:52 +000078//extern void taia_unpack(const char *,struct taia *);
Denis Vlasenko83ea6432006-11-16 02:27:24 +000079
Denis Vlasenko8c783952007-01-27 22:21:52 +000080//#define TAIA_FMTFRAC 19
81//extern unsigned taia_fmtfrac(char *,const struct taia *);
Denis Vlasenko83ea6432006-11-16 02:27:24 +000082
83extern void taia_uint(struct taia *,unsigned);
84
85
86/*** fmt_ptime.h ***/
87
88#define FMT_PTIME 30
89
Denis Vlasenko8c783952007-01-27 22:21:52 +000090/* NUL terminated */
91extern void fmt_ptime30nul(char *, struct taia *);
92/* NOT terminated! */
93extern unsigned fmt_taia25(char *, struct taia *);
Denis Vlasenko83ea6432006-11-16 02:27:24 +000094
95
Denis Vlasenko83ea6432006-11-16 02:27:24 +000096/*** iopause.h ***/
97
98typedef struct pollfd iopause_fd;
99#define IOPAUSE_READ POLLIN
100#define IOPAUSE_WRITE POLLOUT
101
102extern void iopause(iopause_fd *,unsigned,struct taia *,struct taia *);
103
104
105/*** lock.h ***/
106
107extern int lock_ex(int);
108extern int lock_un(int);
109extern int lock_exnb(int);
110
111
Denis Vlasenko83ea6432006-11-16 02:27:24 +0000112/*** open.h ***/
113
114extern int open_read(const char *);
115extern int open_excl(const char *);
116extern int open_append(const char *);
117extern int open_trunc(const char *);
118extern int open_write(const char *);
119
120
Denis Vlasenko83ea6432006-11-16 02:27:24 +0000121/*** pmatch.h ***/
122
123extern unsigned pmatch(const char *, const char *, unsigned);
124
125
Denis Vlasenko83ea6432006-11-16 02:27:24 +0000126/*** str.h ***/
127
128extern unsigned str_chr(const char *,int); /* never returns NULL */
129
Denis Vlasenkoe2473f82007-01-27 22:22:17 +0000130#define str_diff(s,t) strcmp((s), (t))
131#define str_equal(s,t) (!strcmp((s), (t)))