Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/coreutils/src/compat/compat.h
1067 views
1
/*
2
* compat.h
3
* Local prototype definitions for functions put together in this library.
4
* We don't have the full OpenBSD system headers, so use this header file
5
* to be a placeholder.
6
*/
7
8
/*
9
* Reference from Apple's archived OS X (now macOS documentation
10
* we need to import this else we are going to get a "declaration expected at
11
* line 29"
12
*
13
* including types.h allows us to fix erros in the mget declaration
14
*
15
*/
16
17
#ifndef COWASM_COMPAT_H
18
#define COWASM_COMPAT_H
19
20
#include "posix-wasm.h"
21
#include <unistd.h>
22
#include <string.h>
23
#include <stddef.h>
24
#include <sys/types.h>
25
#include <sys/stat.h>
26
27
/* setmode.c */
28
mode_t getmode(const void *, mode_t);
29
void *setmode(const char *);
30
31
/* strmode.c */
32
void strmode(int, char *);
33
34
/* pwcache.c */
35
/* Darwin (OSX/macOS) requires the nouser and nogroup
36
to be added */
37
38
#if defined __APPLE__
39
const char *user_from_uid(uid_t, int nouser);
40
const char *group_from_gid(gid_t, int nogroup);
41
int uid_from_user(const char *, uid_t *);
42
int gid_from_group(const char *, gid_t *);
43
#else
44
const char *user_from_uid(uid_t, int);
45
const char *group_from_gid(gid_t, int);
46
int uid_from_user(const char *, uid_t *);
47
int gid_from_group(const char *, gid_t *);
48
#endif
49
50
/* logwtmp.c */
51
void logwtmp(const char *, const char *, const char *);
52
53
/* fmt_scaled.c */
54
int scan_scaled(char *, long long *);
55
int fmt_scaled(long long, char *);
56
57
/* getbsize.c */
58
char *getbsize(int *, long *);
59
60
/* devname.c */
61
char *devname(dev_t, mode_t);
62
63
/* heapsort.c */
64
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
65
66
/* recallocarray.c */
67
void *recallocarray(void *, size_t, size_t, size_t);
68
69
/* reallocarray.c */
70
#if defined __APPLE__
71
void *reallocarray(void *ptr, size_t nmemb, size_t size);
72
#endif
73
74
/* strlcat.c */
75
#if defined __linux
76
size_t strlcat(char *, const char *, size_t);
77
#endif
78
79
/* strlcpy.c */
80
#if defined __linux__
81
size_t strlcpy(char *, const char *, size_t);
82
#endif
83
84
/*
85
* MAXBSIZE does not exist on Linux however, since Darwin is an OS
86
* that derives from FreesBD this does exist on Darwin, so we dont
87
* need to get oursevels, an extra warning for redefining a macro,
88
* however this is the explainaition for Linux because filesystem block size
89
* limits are per filesystem and not consistently enforced across
90
* the different filesystems. If you look at e2fsprogs and its
91
* header files, you'll see the max block size is defined as 65536
92
* via (1 << EXT2_MAX_BLOCK_LOG_SIZE) where EXT2_MAX_BLOCK_LOG_SIZE
93
* is 16. On OpenBSD, MAXBSIZE is simply (64 * 1024), which is
94
* 65536. So we'll just define that here so as to avoid having
95
* bsdutils depend on e2fsprogs to compile.
96
*/
97
#if !defined __APPLE__
98
#define MAXBSIZE (64 * 1024)
99
#endif
100
101
/*
102
* fmt_scaled(3) specific flags.
103
* This comes from lib/libutil/util.h in the OpenBSD source.
104
*/
105
#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
106
107
/* Buffer sizes */
108
#define _PW_BUF_LEN sysconf(_SC_GETPW_R_SIZE_MAX)
109
#define _GR_BUF_LEN sysconf(_SC_GETGR_R_SIZE_MAX)
110
111
/* Defined in progname.c */
112
extern void setprogname(const char *progname);
113
extern const char *__progname;
114
115
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
116
117
#define OFF_MAX LLONG_MAX /* max value for an off_t */
118
#define MAP_NOCORE 0x00020000
119
#define MAP_NOSYNC 0x0800
120
121
#define __FBSDID(x)
122
#define __DECONST(a, v) ((a)(v))
123
124
#endif // COWASM_COMPAT_H
125