RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
dfs_seq_file.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2023, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 */
9
10#ifndef __DFS_SEQ_FILE_H__
11#define __DFS_SEQ_FILE_H__
12
13#include <dfs.h>
14#include <dfs_fs.h>
15
16struct dfs_seq_ops;
17
19{
20 char *buf;
21 size_t size;
22 size_t from;
23 size_t count;
24 size_t pad_until;
25 off_t index;
26 off_t read_pos;
27 struct rt_mutex lock;
28 const struct dfs_seq_ops *ops;
29 const struct dfs_file *file;
30 void *data;
31};
32
34{
35 void *(*start)(struct dfs_seq_file *seq, off_t *index);
36 void (*stop)(struct dfs_seq_file *seq, void *data);
37 void *(*next)(struct dfs_seq_file *seq, void *data, off_t *index);
38 int (*show)(struct dfs_seq_file *seq, void *data);
39};
40
44static inline rt_bool_t dfs_seq_is_full(struct dfs_seq_file *seq)
45{
46 return seq->count == seq->size;
47}
48
52static inline void dfs_seq_setwidth(struct dfs_seq_file *seq, size_t size)
53{
54 seq->pad_until = seq->count + size;
55}
56
57int dfs_seq_open(struct dfs_file *file, const struct dfs_seq_ops *ops);
58ssize_t dfs_seq_read(struct dfs_file *file, void *buf, size_t size, off_t *pos);
59off_t dfs_seq_lseek(struct dfs_file *file, off_t offset, int whence);
60int dfs_seq_release(struct dfs_file *file);
61int dfs_seq_write(struct dfs_seq_file *seq, const void *data, size_t len);
62
63void dfs_seq_vprintf(struct dfs_seq_file *seq, const char *fmt, va_list args);
64void dfs_seq_printf(struct dfs_seq_file *seq, const char *fmt, ...);
65void dfs_seq_putc(struct dfs_seq_file *seq, char c);
66void dfs_seq_puts(struct dfs_seq_file *seq, const char *s);
67void dfs_seq_pad(struct dfs_seq_file *seq, char c);
68
69#endif
int dfs_seq_release(struct dfs_file *file)
off_t dfs_seq_lseek(struct dfs_file *file, off_t offset, int whence)
void dfs_seq_pad(struct dfs_seq_file *seq, char c)
void dfs_seq_putc(struct dfs_seq_file *seq, char c)
void dfs_seq_puts(struct dfs_seq_file *seq, const char *s)
void dfs_seq_printf(struct dfs_seq_file *seq, const char *fmt,...)
ssize_t dfs_seq_read(struct dfs_file *file, void *buf, size_t size, off_t *pos)
int dfs_seq_open(struct dfs_file *file, const struct dfs_seq_ops *ops)
int dfs_seq_write(struct dfs_seq_file *seq, const void *data, size_t len)
void dfs_seq_vprintf(struct dfs_seq_file *seq, const char *fmt, va_list args)
int rt_bool_t
struct rt_mutex lock
const struct dfs_file * file
const struct dfs_seq_ops * ops
int(* show)(struct dfs_seq_file *seq, void *data)
void(* stop)(struct dfs_seq_file *seq, void *data)