summaryrefslogtreecommitdiff
path: root/anthy/src/shim/pwd.h
blob: 529df98fe4d674336a7b4fec9e14f5a4f8c9f1cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * shim/pwd.h — the passwd database WASI does not have.
 *
 * anthy's src-diclib/conf.c includes <pwd.h> and calls getpwuid(getuid()) to find
 * the user's home directory (used later for the private dictionary and user
 * history). WASI has neither pwd.h nor getpwuid, and its <unistd.h> does not even
 * declare getuid. Rather than patch anthy's source, this header sits earlier in
 * the include path (-isystem) and the implementations live in shim_posix.c.
 *
 * The embedder passes HOME through the WASI environment, so pw_dir follows it.
 */
#ifndef ANTHY_WASM_SHIM_PWD_H
#define ANTHY_WASM_SHIM_PWD_H

#include <sys/types.h>

struct passwd {
    char *pw_name;
    char *pw_passwd;
    uid_t pw_uid;
    gid_t pw_gid;
    char *pw_gecos;
    char *pw_dir;
    char *pw_shell;
};

struct passwd *getpwuid(uid_t uid);
struct passwd *getpwnam(const char *name);
uid_t getuid(void);
uid_t geteuid(void);

#endif /* ANTHY_WASM_SHIM_PWD_H */