Added pipe() syscall; Fixed some memleaks;
[ZeXOS.git] / kernel / include / pipe.h
blobb8815e3d7ce5de57f86043c21e6e103d7ce329db
1 /*
2 * ZeX/OS
3 * Copyright (C) 2009 Martin 'povik' Poviser (martin.povik@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
19 #ifndef _PIPE_H
20 #define _PIPE_H
22 #include <mytypes.h>
24 #define PIPE_BUFFER_PART_SIZE 128
26 #define FD_PIPE 0x200
28 typedef struct pipe_buffer {
29 BYTE buffer[PIPE_BUFFER_PART_SIZE];
30 struct pipe_buffer *next, *prev;
31 } pipe_buffer_t;
33 typedef struct pipe {
34 pipe_buffer_t *buffer_list_start;
35 pipe_buffer_t *buffer_list_end;
36 unsigned int buffer_start_pos;
37 unsigned int buffer_end_len;
38 int fd_a, fd_b;
39 struct pipe *next, *prev;
40 } pipe_t;
42 pipe_t *pipe_get (int fd);
43 void pipe_close (int fd);
44 bool pipe_write (pipe_t *p, BYTE *buffer, unsigned int buffer_len);
45 unsigned int pipe_read (pipe_t *p, BYTE *buffer, unsigned int buffer_max_len);
46 int pipe (int fds[2]);
48 #endif