blob: 36ddca985491bcd05f3ea7f30a014587fabad293 [file] [log] [blame]
Elliott Hughes3f6b63e2014-02-28 17:25:17 -08001/*
2 * Copyright (C) 2014, The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
Elliott Hughesfd4c6b02014-07-22 17:20:15 -070029#include <stdbool.h>
Elliott Hughes3f6b63e2014-02-28 17:25:17 -080030#include <sys/types.h>
31
32/* We want chown to support user.group as well as user:group. */
33#define SUPPORT_DOT
34
Elliott Hughes04650ef2014-07-10 19:38:01 -070035/* We don't localize /system/bin! */
36#define WITHOUT_NLS
37
Elliott Hughesfd4c6b02014-07-22 17:20:15 -070038// NetBSD uses _DIAGASSERT to null-check arguments and the like.
39#include <assert.h>
40#define _DIAGASSERT(e) ((e) ? (void) 0 : __assert2(__FILE__, __LINE__, __func__, #e))
41
42// TODO: update our <sys/cdefs.h> to support this properly.
43#define __type_fit(t, a) (0 == 0)
44
45// TODO: should this be in our <sys/cdefs.h>?
46#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
47
48// This at least matches GNU dd(1) behavior.
49#define SIGINFO SIGUSR1
50
51#define S_ISWHT(x) false
52
Elliott Hughes3f6b63e2014-02-28 17:25:17 -080053__BEGIN_DECLS
54
Elliott Hughesfd4c6b02014-07-22 17:20:15 -070055/* From NetBSD <grp.h> and <pwd.h>. */
56char* group_from_gid(gid_t gid, int noname);
57int uid_from_user(const char* name, uid_t* uid);
58char* user_from_uid(uid_t uid, int noname);
59
60/* From NetBSD <stdlib.h>. */
61#define HN_DECIMAL 0x01
62#define HN_NOSPACE 0x02
63#define HN_B 0x04
64#define HN_DIVISOR_1000 0x08
65#define HN_GETSCALE 0x10
66#define HN_AUTOSCALE 0x20
67int humanize_number(char *, size_t, int64_t, const char *, int, int);
68int dehumanize_number(const char *, int64_t *);
69char *getbsize(int *, long *);
70long long strsuftoll(const char *, const char *, long long, long long);
71long long strsuftollx(const char *, const char *, long long, long long,
72 char *, size_t);
73
74/* From NetBSD <string.h>. */
75void strmode(mode_t, char*);
76
77/* From NetBSD <sys/param.h>. */
78#define MAXBSIZE 65536
79
80/* From NetBSD <sys/stat.h>. */
81#define DEFFILEMODE (S_IRUSR | S_IWUSR)
82
83/* From NetBSD <unistd.h>. */
84void swab(const void * __restrict, void * __restrict, ssize_t);
85
86/* From NetBSD <util.h>. */
87int raise_default_signal(int);
Elliott Hughes3f6b63e2014-02-28 17:25:17 -080088
89__END_DECLS