FreeNOS
unistd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBPOSIX_UNISTD_H
19 #define __LIBPOSIX_UNISTD_H
20 
21 #include <Macros.h>
22 #include <stdio.h>
23 #include "sys/types.h"
24 
38 #define _POSIX_VERSION 200809L
39 
45 #define _POSIX2_VERSION 200809L
46 
55 extern C pid_t getpid();
56 
62 extern C pid_t getppid();
63 
79 extern C ssize_t read(int fildes, void *buf, size_t nbyte);
80 
97 extern C ssize_t write(int fildes, const void *buf, size_t nbyte);
98 
108 extern C int close(int fildes);
109 
129 extern C off_t lseek(int fildes, off_t offset, int whence);
130 
140 extern C int forkexec(const char *path, const char *argv[]);
141 
152 extern C int spawn(Address program, Size programSize, const char *argv[]);
153 
171 extern C int gethostname(char *name, size_t namelen);
172 
189 extern C char *getcwd(char *buf, size_t size);
190 
205 extern C int chdir(const char *path);
206 
212 extern C int unlink(const char *path);
213 
221 extern C unsigned int sleep(unsigned int seconds);
222 
228 #endif /* __LIBPOSIX_UNISTD_H */
gethostname
C int gethostname(char *name, size_t namelen)
Get name of current host.
Definition: gethostname.cpp:21
off_t
sint off_t
Used for file sizes.
Definition: types.h:59
Macros.h
write
C ssize_t write(int fildes, const void *buf, size_t nbyte)
Write on a file.
Definition: write.cpp:22
types.h
getcwd
C char * getcwd(char *buf, size_t size)
Get the pathname of the current working directory.
Definition: getcwd.cpp:24
getpid
C pid_t getpid()
Get the process ID.
Definition: getpid.cpp:21
Address
unsigned long Address
A memory address.
Definition: Types.h:131
read
C ssize_t read(int fildes, void *buf, size_t nbyte)
Read from a file.
Definition: read.cpp:22
C
#define C
Used to define external C functions.
Definition: Macros.h:134
close
C int close(int fildes)
Close a file descriptor.
Definition: close.cpp:22
getppid
C pid_t getppid()
Get parent process ID.
Definition: getppid.cpp:21
sleep
C unsigned int sleep(unsigned int seconds)
Sleep for the specified number of seconds.
Definition: sleep.cpp:23
stdio.h
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
unlink
C int unlink(const char *path)
Remove a file from the filesystem.
Definition: unlink.cpp:24
forkexec
C int forkexec(const char *path, const char *argv[])
Create a new process and execute program.
Definition: forkexec.cpp:27
lseek
C off_t lseek(int fildes, off_t offset, int whence)
Move the read/write file offset.
Definition: lseek.cpp:22
pid_t
ProcessID pid_t
Used for process IDs and process group IDs.
Definition: types.h:32
chdir
C int chdir(const char *path)
Change working directory.
Definition: chdir.cpp:27
spawn
C int spawn(Address program, Size programSize, const char *argv[])
Create a new process using in-memory image.
Definition: spawn.cpp:29
ssize_t
slong ssize_t
Used for a count of bytes or an error indication.
Definition: types.h:38