summaryrefslogtreecommitdiff
path: root/cmd/srv9p/static9p.h
blob: 7a3d476d6fecbb61e9670089a3e73f2074c0d446 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* srv9p/static9p.h - Serve static files over 9P
 *
 * Copyright (C) 2024  Luke T. Shumaker <lukeshu@lukeshu.com>
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

#ifndef _SRV9P_STATIC9P_H_
#define _SRV9P_STATIC9P_H_

#include <lib9p/srv.h>

typedef struct {
	implements_lib9p_srv_file;

	char                    *u_name;
	uint32_t                 u_num;
	char                    *g_name;
	uint32_t                 g_num;
	char                    *m_name;
	uint32_t                 m_num;

	uint64_t                 pathnum;
	char                    *name;
	lib9p_dm_t               perm;
	uint32_t                 atime, mtime;
} _static_common;

struct static_dir {
	_static_common;

	/* NULL-terminated */
	implements_lib9p_srv_file       *members[];
};


struct static_file {
	_static_common;

	char                    *data_start; /* must not be NULL */
	char                    *data_end;   /* may be NULL, in which case data_size is used */
	size_t                   data_size;  /* only used if .data_end==NULL */
};

extern struct lib9p_srv_file_vtable static_dir_vtable;
extern struct lib9p_srv_file_vtable static_file_vtable;

#endif /* _SRV9P_STATIC9P_H_ */