1.1 --- a/client/file.h Tue Apr 13 00:03:18 2021 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,114 +0,0 @@
1.4 -/*
1.5 - * File access convenience functions and types.
1.6 - *
1.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.8 - *
1.9 - * This program is free software; you can redistribute it and/or
1.10 - * modify it under the terms of the GNU General Public License as
1.11 - * published by the Free Software Foundation; either version 2 of
1.12 - * the License, or (at your option) any later version.
1.13 - *
1.14 - * This program is distributed in the hope that it will be useful,
1.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 - * GNU General Public License for more details.
1.18 - *
1.19 - * You should have received a copy of the GNU General Public License
1.20 - * along with this program; if not, write to the Free Software
1.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 - * Boston, MA 02110-1301, USA
1.23 - */
1.24 -
1.25 -#include <l4/sys/types.h>
1.26 -
1.27 -#include <systypes/base.h>
1.28 -
1.29 -
1.30 -
1.31 -EXTERN_C_BEGIN
1.32 -
1.33 -/* File access abstraction. */
1.34 -
1.35 -typedef struct
1.36 -{
1.37 - /* File object reference. */
1.38 -
1.39 - l4_cap_idx_t ref;
1.40 -
1.41 - /* Mapped memory accessing a file region. */
1.42 -
1.43 - char *memory;
1.44 -
1.45 - /* File region parameters. */
1.46 -
1.47 - offset_t start_pos, end_pos; /* start and end positions of region */
1.48 - offset_t data_end; /* amount/extent of data in the region */
1.49 - offset_t data_current; /* client access offset */
1.50 -
1.51 - /* Total size of file. */
1.52 -
1.53 - offset_t size;
1.54 -
1.55 - /* Arbitrary memory mapping support. */
1.56 -
1.57 - int can_mmap;
1.58 -
1.59 -} file_t;
1.60 -
1.61 -
1.62 -
1.63 -/* File operations. */
1.64 -
1.65 -void file_close(file_t *file);
1.66 -long file_open(file_t *file, const char *filename, flags_t flags, l4_cap_idx_t server);
1.67 -
1.68 -/* File lifecycle operations. */
1.69 -
1.70 -long file_context(file_t *file, l4_cap_idx_t server);
1.71 -long file_context_open(file_t *file, flags_t flags, file_t *context);
1.72 -void file_init(file_t *file);
1.73 -
1.74 -/* File and region operations. */
1.75 -
1.76 -long file_flush(file_t *file);
1.77 -long file_mmap(file_t *file, offset_t position, offset_t length);
1.78 -long file_resize(file_t *file, offset_t size);
1.79 -
1.80 -/* File and region properties. */
1.81 -
1.82 -offset_t file_populated_span(file_t *file);
1.83 -offset_t file_span(file_t *file);
1.84 -
1.85 -/* Convenience functions. */
1.86 -
1.87 -char *file_string_get(file_t *file, offset_t offset);
1.88 -int file_string_set(file_t *file, const char *data, offset_t offset, offset_t *written);
1.89 -
1.90 -/* Client data functions. */
1.91 -
1.92 -offset_t file_data_available(file_t *file);
1.93 -char *file_data_current(file_t *file);
1.94 -offset_t file_data_current_position(file_t *file);
1.95 -offset_t file_data_end_position(file_t *file);
1.96 -offset_t file_data_space(file_t *file);
1.97 -
1.98 -/* Client data transfer functions. */
1.99 -
1.100 -void file_data_read(file_t *file, char *buf, size_t to_transfer);
1.101 -void file_data_write(file_t *file, char *buf, size_t to_transfer);
1.102 -
1.103 -
1.104 -
1.105 -/* Pipe operations. */
1.106 -
1.107 -long pipe_open(offset_t size, file_t *reader, file_t *writer, l4_cap_idx_t server);
1.108 -
1.109 -/* Pipe region operations. */
1.110 -
1.111 -long pipe_current(file_t *pipe);
1.112 -long pipe_next(file_t *pipe);
1.113 -long pipe_written(file_t *pipe, offset_t size);
1.114 -
1.115 -EXTERN_C_END
1.116 -
1.117 -// vim: tabstop=2 expandtab shiftwidth=2