2 * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifndef __PARSE_UNITS_H__
37 #define __PARSE_UNITS_H__
43 #ifndef ROKEN_LIB_FUNCTION
45 #define ROKEN_LIB_FUNCTION
46 #define ROKEN_LIB_CALL __cdecl
48 #define ROKEN_LIB_FUNCTION
49 #define ROKEN_LIB_CALL
58 ROKEN_LIB_FUNCTION
int64_t ROKEN_LIB_CALL
59 parse_units (const char *s
, const struct units
*units
,
60 const char *def_unit
);
62 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
63 print_units_table (const struct units
*units
, FILE *f
);
65 ROKEN_LIB_FUNCTION
uint64_t ROKEN_LIB_CALL
66 parse_flags (const char *s
, const struct units
*units
,
69 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
70 unparse_units(int64_t num
, const struct units
*units
, char *s
, size_t len
);
72 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
73 unparse_units_approx(int64_t num
, const struct units
*units
, char *s
,
76 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
77 unparse_flags(uint64_t num
, const struct units
*units
, char *s
, size_t len
);
79 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
80 print_flags_table (const struct units
*units
, FILE *f
);
82 /* And again, but renamed */
84 #define parse_units rk_parse_units
85 #define unparse_units rk_unparse_units
86 #define unparse_units_approx rk_unparse_units_approx
87 #define print_units_table rk_print_units_table
88 #define parse_flags rk_parse_flags
89 #define unparse_flags rk_unparse_flags
90 #define print_flags_table rk_print_flags_table
92 ROKEN_LIB_FUNCTION
int64_t ROKEN_LIB_CALL
93 parse_units (const char *s
, const struct units
*units
,
94 const char *def_unit
);
96 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
97 print_units_table (const struct units
*units
, FILE *f
);
99 ROKEN_LIB_FUNCTION
uint64_t ROKEN_LIB_CALL
100 parse_flags (const char *s
, const struct units
*units
,
103 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
104 unparse_units(int64_t num
, const struct units
*units
, char *s
, size_t len
);
106 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
107 unparse_units_approx(int64_t num
, const struct units
*units
, char *s
,
110 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
111 unparse_flags(uint64_t num
, const struct units
*units
, char *s
, size_t len
);
113 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
114 print_flags_table (const struct units
*units
, FILE *f
);
116 #endif /* __PARSE_UNITS_H__ */