http://www.aros.orgAROS-ExecTeam AROSAROS-Exec Archives

Strona główna

English

Česky

Deutsch

Ελληυικά

Français

Italiano

Nederlands

Polski

Português

Русский

Español

Suomi

Svenska


Newsy

Archiwum

Wprowadzenie

Status
Zrzuty ekranu
Porty
Licencja

Download


Dokumentacja

Użytkownicy
Instalacja
Użytkowanie
Komendy shella
Applications
FAQ
Programi¶ci
Współpraca
Roadmap
Bug Tracker
Praca z SVN
Kompilowanie
Podręcznik programisty
Zune - podręcznik programisty
System Development Manual
Debugging Manual
Reference
Specyfikacje
UI Style Guide
Documenting
Porting
Tłumaczenie
Summaries
Linki

Kontakt

Listy dyskusyjne
Kanały IRC

Credits

Acknowledgements


Obrazy

Programi¶ci
Developers en Masse

Sponsorzy

Linkowanie

Linki

SourceForge Logo

clib

Index


__get_default_file() __path_a2u() __path_u2a() __spawnv()
__vcformat() __vcscan() _exit() abort()
abs() access() asctime() asctime_r()
assert() atexit() atof() atoi()
atol() basename() bcmp() bsearch()
bzero() calloc() chdir() chmod()
chown() clearerr() clock() close()
closedir() creat() ctime() ctime_r()
difftime() dirfd() dirname() div()
dup() dup2() endgrent() endpwent()
execl() execlp() execv() execve()
execvp() exit() fchdir() fchmod()
fchown() fclose() fcntl() fdopen()
feof() ferror() fflush() fgetc()
fgetpos() fgets() fileno() flock()
fopen() fprintf() fputc() fputs()
fread() free() freopen() fscanf()
fseek() fsetpos() fstat() fsync()
ftell() ftime() ftruncate() fwrite()
gcvt() getc() getchar() getcwd()
getegid() getenv() geteuid() getfsstat()
getgid() getgrent() getgrgid() getgrnam()
getgroups() getloadavg() getlogin() getopt()
getpgrp() getpid() getppid() getpwent()
getpwnam() getpwuid() gets() gettimeofday()
getuid() getw() gmtime() gmtime_r()
ioctl() isalnum() isalpha() isascii()
isatty() isblank() iscntrl() isdigit()
isgraph() islower() isprint() ispunct()
isspace() isupper() isxdigit() jrand48()
kill() labs() lcong48() ldiv()
link() lldiv() localtime() localtime_r()
lrand48() lseek() malloc() mblen()
mbstowcs() mbtowc() memchr() memcmp()
memset() mkdir() mknod() mkstemp()
mktemp() mktime() mrand48() nrand48()
on_exit() open() opendir() pclose()
perror() pipe() popen() posix_memalign()
printf() putc() putchar() putenv()
puts() putw() qsort() raise()
rand() read() readdir() realloc()
realloc_nocopy() remove() rename() rewind()
rewinddir() rmdir() scanf() seed48()
seekdir() setbuf() setenv() setgid()
setgrent() setlinebuf() setpwent() setuid()
setvbuf() sigaction() sigaddset() sigdelset()
sigemptyset() sigfillset() sigismember() signal()
sigpending() sigprocmask() sigsuspend() sleep()
snprintf() spawnv() spawnvp() sprintf()
srand() srand48() sscanf() stat()
statfs() stccpy() stcd_l() stch_l()
stcl_d() stcl_h() stcl_o() stco_l()
stcu_d() stpblk() stpcpy() stpsym()
strcasecmp() strcasestr() strcat() strchr()
strcmp() strcoll() strcpy() strcspn()
strdup() strerror() strftime() strlcat()
strlcpy() strlen() strlwr() strncasecmp()
strncat() strncmp() strncpy() strpbrk()
strrchr() strrev() strsep() strspn()
strstr() strtod() strtoimax() strtok()
strtol() strtoll() strtoul() strtoull()
strtoumax() strupr() strxfrm() swab()
symlink() system() telldir() tempnam()
time() times() tmpfile() tmpnam()
truncate() ttyname() umask() uname()
ungetc() unlink() unsetenv() updatestdio()
usleep() utime() utimes() vfprintf()
vfscanf() vprintf() vscanf() vsnprintf()
vsprintf() vsscanf() wait() waitpid()
wcstombs() wctomb() write()  

__get_default_file()

Synopsis

int __get_default_file(
   int file_descriptor,
   long * file_handle)

Function

Gets dos.library file handle associated with a given file descriptor.

Inputs

file_descriptor - the File Descriptor you wish to obtain the associated
        file handle for.
file_handle - Pointer to store the associated file handle.

Result

!=0 on error, 0 on success.

Notes

This function is not a part of the ISO C standard, it comes from clib2
project and was implemented to make porting of abc-shell easier.

__path_a2u()

Synopsis

const char *__path_a2u(
   const char *apath)

Function

Translates an AmigaDOS-style path into an unix one.

Inputs

apath - AmigaDOS-style path to translate into an unix-style equivalent.

Result

A pointer to a string containing the unix-style path, or NULL in
case of error.

The pointer is valid only until next call to this function, so if
you need to call this function recursively, you must save the string
pointed to by the pointer before calling this function again.

Notes

This function is for private usage by system code. Do not use it
elsewhere.

__path_u2a()

Synopsis

const char *__path_u2a(
   const char *upath)

Function

Translates an unix-style path into an AmigaDOS one.

Inputs

upath - Unix-style path to translate into an AmigaDOS-style equivalent.

Result

A pointer to a string containing the AmigaDOS-style path, or NULL in
case of error.

The pointer is valid only until next call to this function, so if
you need to call this function recursively, you must save the string
pointed to by the pointer before calling this function again.

Notes

This function is for private usage by system code. Do not use it
elsewhere.

__spawnv()

Synopsis

int __spawnv(
    int         mode,
    BPTR        seg,
    char *const argv[])

Function

Spawn a child process, given a vector of arguments and an already LoadSeg()'d executable.

Inputs

mode - the way the child process has to be loaded, and how the parent has to behave
       after the child process is initiated. Specify one of the following values:

       P_WAIT    - the child program is loaded into memory, then it's executed while
                   the parent process waits for it to terminate, at which point the
                   patent process resumes execution.

       P_NOWAIT  - the parent program is executed concurrently with the new child process.

       P_OVERLAY - teplace the parent program with the child program in memory and then
                   execute the child. The parent program will never be resumed. This
                   mode is equivalent to calling one of the exec*() functions.

seg  - the LoadSeg()'s executable. The segment is UnloadSeg()'d by this function.

argv - a pointer to a NULL terminated array of strings representing arguments to pass
       to the child process. The first entry in the array is conventionally the name of
       the program to spawn, but in any case it must _never_ be NULL, and the argv
       pointer itself must never be NULL either.

Result

If P_WAIT is specified, then the return code of the child program is returned.
If instead P_NOWAIT is used, then the pid of the newly created process is returned.
Finally, if P_OVERLAY is used, the function doesn't return unless an error has occurred,
in which case -1 is returned also for the other modes and the global errno variable will
hold the proper error code.

Notes

The way the child process behaves regarding parent's file descriptors, signal handlers
and so on is the same way it would behave with one of the exec*(3) functions.
This, for one, means that all filedescriptors are inherited except the ones which have
the close-on-exec flag set.

__vcformat()

Synopsis

int __vcformat(
   void       * data,
   int       (* outc)(int, void *),
   const char * format,
   va_list      args)

Function

Format a list of arguments and call a function for each char
to print.

Inputs

data - This is passed to the usercallback outc
outc - Call this function for every character that should be
        emitted. The function should return EOF on error and
        > 0 otherwise.
format - A printf() format string.
args - A list of arguments for the format string.

Result

The number of characters written.

__vcscan()

Synopsis

int __vcscan(
   void       * data,
   int       (* getc)(void *),
   int       (* ungetc)(int,void *),
   const char * format,
   va_list      args)

Function

Scan an input stream as specified in format. The result of
the scan will be placed in args.

Inputs

data - This is passed to the usercallback getc and ungetc
getc - This function gets called when the routine wants to
        read the next character. It whould return EOF when
        no more characters are available.
ungetc - This function gets called when the routine wants to
        put a read character back into the stream. The next
        call to getc should return this character. It is possible
        that this function is called more than once before the
        next getc.
format - A scanf() format string.
args - A list of arguments in which the result of the scan should
        be placed.

Result

The number of arguments converted.

_exit()

Synopsis

void _exit(
   int code)

Function

Terminates the running program immediately. The code is returned to
the program which has called the running program. In contrast to
exit(), this function does not call user exit-handlers added with
atexit() or on_exit(). It does, however, close open filehandles.

Inputs

code - Exit code. 0 for success, other values for failure.

Result

None. This function does not return.

Notes

This function must not be used in a shared library or in a threaded
application.

EXAMPLE

Bugs

Currently, this function *does* trigger user exit-handlers to be
called.

abort()

Synopsis

void abort(
   void)

Function

Causes abnormal program termination. If there is a signal handler
for SIGABORT, then the handler will be called. If the handler
returns, then the program is continued.

Inputs

None.

Result

None. This function does not return.

Example

if (fatal_error)
    abort ();

Notes

This function must not be used in a shared library or
in a threaded application.

Bugs

Signal handling is not implemented yet.

abs()

Synopsis

int abs(
   int j)

Function

Compute the absolute value of j.

Inputs

j - A signed integer

Result

The absolute value of j.

Example

// returns 1
abs (1);

// returns 1
abs (-1);

access()

Synopsis

int access(
   const char *path,
   int         mode)

Function

Check access permissions of a file or pathname

Inputs

path - the path of the file being checked
mode - the bitwise inclusive OR of the access permissions
       to be checked:

       W_OK - for write permission
       R_OK - for readpermissions
       X_OK - for execute permission
       F_OK - Just to see whether the file exists

Result

If path cannot be found or if any of the desired access
modes would not be granted, then a -1 value is returned;
otherwise a 0 value is returned.

asctime()

Synopsis

char * asctime(
   const struct tm * tm)

Function

The asctime() function converts the broken-down time value tm
into a string.

See asctime_r() for details.

Inputs

tm - The broken down time

Result

A statically allocated buffer with the converted time. Note that
the contents of the buffer might get lost with the call of any of the
date and time functions.

Example

time_t      tt;
struct tm * tm;
char      * str;

// Get time
time (&tt);

// Break time up
tm = localtime (&tt);

// Convert to string
str = asctime (tm);

Notes

This function must not be used in a shared library or
in a threaded application. Use asctime_r() instead.

asctime_r()

Synopsis

char * asctime_r(
   const struct tm * tm,
   char * buf)

Function

The asctime_r() function converts the broken-down time value tm
into a string with this format:

    "Wed Jun 30 21:49:08 1993\n"

Inputs

tm - The broken down time
buf - Buffer of at least 26 characters to store the string in

Result

The pointer passed in buf, containing the converted time. Note that
there is a newline at the end of the buffer.

Example

time_t    tt;
struct tm tm;
char      str[26];

// Get time
time (&tt);

// Break time up
localtime (&tt, &tm);

// Convert to string
asctime (&tm, str);

assert()

Synopsis

void assert(
   expr)

Function

Evaluates the expression expr and if it's FALSE or NULL, then
printf a message and stops the program. The message will
contain the expression, the name of the file with the assert
in it and the line in the file.

Inputs

expr - The expression to evaluate. The type of the expression does
        not matter, only if its zero/NULL or not.

Result

The function doesn't return.

Example

// Make sure that x equals 1
assert (x==1);

atexit()

Synopsis

int atexit(
   void (*func)(void))

Function

Registers the given function to be called at normal
process termination.

Inputs

func - function to be called.

atof()

Synopsis

double atof(
   const char * str)

Function

Convert a string of digits into a double.

Inputs

str - The string which should be converted. Leading
        whitespace are ignored. The number may be prefixed
        by a '+' or '-'.

Result

The value of string str.

atoi()

Synopsis

int atoi(
   const char * str)

Function

Convert a string of digits into an integer.

Inputs

str - The string which should be converted. Leading
        whitespace are ignored. The number may be prefixed
        by a '+' or '-'.

Result

The value of string str.

Example

// returns 1
atoi ("  \t +1");

// returns 1
atoi ("1");

// returns -1
atoi ("  \n -1");

atol()

Synopsis

long atol(
   const char * str)

Function

Convert a string of digits into an long integer.

Inputs

str - The string which should be converted. Leading
        whitespace are ignored. The number may be prefixed
        by a '+' or '-'.

Result

The value of string str.

Example

// returns 1
atol ("  \t +1");

// returns 1
atol ("1");

// returns -1
atol ("  \n -1");

basename()

Synopsis

char *basename(
   char *filename)

Function

Returns the part after the latest '/' of a path.
Trailing '/' are not counted as part of the path.

Inputs

filename - Path which should be split.

Result

Rightmost part of the path.

bcmp()

Synopsis

int bcmp(
   const void * s1,
   const void * s2,
   size_t       n)

Function

Compare the first n bytes of s1 and s2.

Inputs

s1 - The first byte array to be compared
s2 - The second byte array to be compared
n  - How many bytes to compare

bsearch()

Synopsis

void * bsearch(
   const void * key,
   const void * base,
   size_t       count,
   size_t       size,
   int       (* comparefunction)(const void *, const void *))

Function

Search in a sorted array for an entry key.

Inputs

key - Look for this key.
base - This is the address of the first element in the array
        to be searched. Note that the array *must* be sorted.
count - The number of elements in the array
size - The size of one element
comparefunction - The function which is called when two elements
        must be compared. The function gets the addresses of two
        elements of the array and must return 0 is both are equal,
        < 0 if the first element is less than the second and > 0
        otherwise.

Result

A pointer to the element which equals key in the array or NULL if
no such element could be found.

bzero()

Synopsis

void bzero(
   void * ptr,
   size_t    len)

Function

Write len zero bytes to ptr. If len is zero, does nothing.

Inputs

ptr - The first byte of the area in memory to be cleared.
len - How many bytes to clear.

calloc()

Synopsis

void * calloc(
   size_t count,
   size_t size)

Function

Allocate size bytes of memory, clears the memory (sets all bytes to
0) and returns the address of the first byte.

Inputs

count - How many time size
size - How much memory to allocate.

Result

A pointer to the allocated memory or NULL. If you don't need the
memory anymore, you can pass this pointer to free(). If you don't,
the memory will be freed for you when the application exits.

Notes

This function must not be used in a shared library or
in a threaded application.

chdir()

Synopsis

int chdir(
   const char *path )

Function

Change the current working directory to the one specified by path.

Inputs

path - Path of the directory to change to.

Result

If the current directory was changed successfully, zero is returned.
Otherwise, -1 is returned and errno set apropriately.

Notes

At program exit, the current working directory will be changed back
to the one that was current when the program first started. If you
do not desire this behaviour, use dos.library/CurrentDir() instead.
The path given to chdir can be translated so that getcwd gives back
a string that is not the same but points to th same directory. For
example, assigns are replaced by the path where the assign points to
and device names (like DH0:) are replaced with the volume name
(e.g. Workbench:).

chmod()

Synopsis

int chmod(
   const char *path,
   mode_t mode)

Function

Change permission bits of a specified file.

Inputs

path - path to the file
mode - permission bits

Result

Permission bits of the file given by path are changed accordingly
to given mode.

chown()

Synopsis

int chown(
   const char *path,
   uid_t owner,
   gid_t group)

Notes

Not implemented.

clearerr()

Synopsis

void clearerr(
   FILE * stream)

Function

Clear EOF and error flag in a stream. You must call this for
example after you have read the file until EOF, then appended
something to it and want to continue reading.

Inputs

stream - The stream to be reset.

Result

None.

clock()

Synopsis

clock_t clock(
   void)

Function

clock() returns an approximation of the time passed since
the program was started

Result

The time passed in CLOCKS_PER_SEC units. To get the
number of seconds divide by CLOCKS_PER_SEC.

Notes

This function must not be used in a shared library or
in a threaded application.

close()

Synopsis

int close(
   int fd)

Function

Closes an open file. If this is the last file descriptor
associated with this file, then all allocated resources
are freed, too.

Inputs

fd - The result of a successful open()

Result

-1 for error or zero on success.

Notes

This function must not be used in a shared library or
in a threaded application.

closedir()

Synopsis

int closedir(
   DIR *dir)

Function

Closes a directory

Inputs

dir - the directory stream pointing to the directory being closed

Result

The  closedir()  function  returns  0  on success or -1 on
failure.

creat()

Synopsis

int creat(
   const char * pathname,
   int          mode)

Function

Creates a file with the specified mode and name.

Inputs

pathname - Path and filename of the file you want to open.
mode - The access flags.

Result

-1 for error or a file descriptor for use with write().

Notes

If the filesystem doesn't allow to specify different access modes
for users, groups and others, then the user modes are used.

This is the same as open (pathname, O_CREAT|O_WRONLY|O_TRUNC, mode);

This function must not be used in a shared library or
in a threaded application.

ctime()

Synopsis

char * ctime(
   const time_t * tt)

Function

The ctime() function converts the broken-down time value tt
into a string.

See ctime_r() for details.

Inputs

tt - Convert this time.

Result

A statically allocated buffer with the converted time. Note that
the contents of the buffer might get lost with the call of any of the
date and time functions.

Example

time_t tt;
char * str;

// Get time
time (&tt);

// Convert to string
str = ctime (&tt);

Notes

This function must not be used in a shared library or
in a threaded application. Use ctime_r() instead.

ctime_r()

Synopsis

char * ctime_r(
   const time_t * tt,
   char * buf)

Function

The ctime_r() function converts the time value tt into a string with
this format:

    "Wed Jun 30 21:49:08 1993\n"

Inputs

tt - Convert this time.
buf - Buffer of at least 26 characters to store the string in

Result

The pointer passed in buf, containing the converted time. Note that
there is a newline at the end of the buffer.

Example

time_t tt;
char str[26];

// Get time
time (&tt);

// Convert to string
ctime (&tt, str);

difftime()

Synopsis

double difftime(
   time_t time2,
   time_t time1)

Function

difftime() returns the number of seconds elapsed between
time time2 and time time1.

Inputs

time2 - time value from which time1 is subtracted
time1 - time value that is subtracted from time2

Result

The number of seconds elapsed in double precision.

Example

time_t tt1, tt2;
double secs;

time (&tt1);
...
time (&tt2);

secs = difftime(tt2, tt1);

dirfd()

Synopsis

int dirfd(
   DIR *dir)

Function

get directory stream file descriptor

Inputs

dir - directory stream dir.

Result

on error -1 is returned.

Notes

This descriptor is the one used internally by the directory stream.  As
a  result,  it  is  only useful for functions which do not depend on or
alter the file position, such as fstat(2) and fchdir(2).   It  will  be
automatically closed when closedir(3) is called.

dirname()

Synopsis

char *dirname(
   char *filename)

Function

Returns the string up to the latest '/'.

Inputs

filename - Path which should be split

Result

Directory part of the path.

div()

Synopsis

div_t div(
   int numer,
   int denom)

Function

Compute quotient en remainder of two int variables

Inputs

numer = the numerator
denom = the denominator

Result

a struct with two ints quot and rem with
quot = numer / denom and rem = numer % denom.

typedef struct div_t {
    int quot;
    int rem;
} div_t;

NOTES


dup()

Synopsis

int dup(
   int oldfd
   )

Function

Duplicates a file descriptor.

The object referenced by the descriptor does not distinguish between oldd
and newd in any way.  Thus if newd and oldd are duplicate references to
an open file, read(),  write() and lseek() calls all move a single
pointer into the file, and append mode, non-blocking I/O and asynchronous
I/O options are shared between the references.  If a separate pointer
into the file is desired, a different object reference to the file must be
obtained by issuing an additional open(2) call.  The close-on-exec flag
on the new file descriptor is unset.

Inputs

oldfd - The file descriptor to be duplicated

Result

-1 for error or the new descriptor.

The new descriptor returned by the call is the lowest numbered
descriptor currently not in use by the process.

Notes

This function must not be used in a shared library or
in a threaded application.

dup2()

Synopsis

int dup2(
   int oldfd,
   int newfd
   )

Function

Duplicates a file descriptor.

The object referenced by the descriptor does not distinguish between oldd
and newd in any way.  Thus if newd and oldd are duplicate references to
an open file, read(),  write() and lseek() calls all move a single
pointer into the file, and append mode, non-blocking I/O and asynchronous
I/O options are shared between the references.  If a separate pointer
into the file is desired, a different object reference to the file must be
obtained by issuing an additional open(2) call.  The close-on-exec flag
on the new file descriptor is unset.

Inputs

oldfd - The file descriptor to be duplicated
newfd - The value of the new descriptor we want the old one to be duplicated in

Result

-1 for error or newfd on success

Notes

This function must not be used in a shared library or
in a threaded application.

endgrent()

Synopsis

void endgrent(
   void)

Notes

Not implemented.

endpwent()

Synopsis

void endpwent(
   void)

Notes

Not implemented.

execl()

Synopsis

int execl(
   const char *path,
   const char *arg, ...)

Notes

Not implemented.

execlp()

Synopsis

int execlp(
   const char *file,
   const char *arg, ...)

execv()

Synopsis

int execv(
   const char *path,
   char *const argv[])

Function

Executes a file with specified arguments.

Inputs

file - Name of the file to execute.
argv - Array of arguments given to main() function of the executed
file.

Result

0 in case of success. In case of failure errno is set appropriately
and function returns -1.

Bugs

See execve documentation.

execve()

Synopsis

int execve(
   const char *filename,
   char *const argv[],
   char *const envp[])

Function

Executes a file with given name.

Inputs

filename - Name of the file to execute.
argv - Array of arguments provided to main() function of the executed
file.
envp - Array of environment variables passed as environment to the
executed program.

Result

Returns -1 and sets errno appropriately in case of error, otherwise
doesn't return.

execvp()

Synopsis

int execvp(
   const char *file,
   char *const argv[])

Function

Executes a file with specified arguments.

Inputs

file - Name of the file to execute.
argv - Array of arguments given to main() function of the executed
file.

Result

0 in case of success. In case of failure errno is set appropriately
and function returns -1.

Bugs

See execve documentation.

exit()

Synopsis

void exit(
   int code)

Function

Terminates the running program. The code is returned to the
program which has called the running program.

Inputs

code - Exit code. 0 for success, other values for failure.

Result

None. This function does not return.

Notes

This function must not be used in a shared library or
in a threaded application.
EXAMPLE
if (no_problems)
exit (0);
if (warning)
exit (5);
if (error)
exit (10);
if (fatal)
exit (20);

fchdir()

Synopsis

int fchdir(
   int fd )

Function

Change the current working directory to the directory given as an open
file descriptor.

Inputs

fd - File descriptor of the directory to change to.

Result

If the current directory was changed successfully, zero is returned.
Otherwise, -1 is returned and errno set apropriately.

Notes

At program exit, the current working directory will be changed back
to the one that was current when the program first started. If you
do not desire this behaviour, use dos.library/CurrentDir() instead.

fchmod()

Synopsis

int fchmod(
   int filedes,
   mode_t mode)

Notes

Not implemented.

fchown()

Synopsis

int fchown(
   int fd,
   uid_t owner,
   gid_t group)

Notes

Not implemented.

fclose()

Synopsis

int fclose(
   FILE * stream)

Function

Closes a stream.

Inputs

stream - Stream to close.

Result

Upon successful completion 0 is returned. Otherwise, EOF is
returned and the global variable errno is set to indicate the
error. In either case no further access to the stream is possible.

Notes

This function must not be used in a shared library or
in a threaded application.

fcntl()

Synopsis

int fcntl(
   int fd,
   int cmd,
   ...)

fdopen()

Synopsis

FILE *fdopen(
   int         filedes,
   const char *mode
   )

Function

function associates a stream with an existing file descriptor.

Inputs

filedes - The descriptor the stream has to be associated with
mode    - The mode of the stream  (same as with fopen()) must be com­
          patible with the mode of the file  descriptor.   The  file
          position  indicator  of  the  new  stream  is  set to that
          belonging to filedes, and the error and end-of-file indica­
          tors  are cleared.  Modes "w" or "w+" do not cause trunca­
          tion of the file.  The file descriptor is not dup'ed,  and
          will  be  closed  when  the  stream  created  by fdopen is
          closed.

Result

NULL on error or the new stream associated with the descriptor.

The new descriptor returned by the call is the lowest numbered
descriptor currently not in use by the process.

Notes

This function must not be used in a shared library or
in a threaded application.

feof()

Synopsis

int feof(
   FILE * stream)

Function

Test the EOF-Flag of a stream. This flag is set automatically by
any function which recognises EOF. To clear it, call clearerr().

Inputs

stream - The stream to be tested.

Result

!= 0, if the stream is at the end of the file, 0 otherwise.

Notes

This function must not be used in a shared library or
in a threaded application.

ferror()

Synopsis

int ferror(
   FILE * stream)

Function

Test the error flag of a stream. This flag is set automatically by
any function that detects an error. To clear it, call clearerr().

Inputs

stream - The stream to be tested.

Result

!= 0, if the stream had an error, 0 otherwise.

fflush()

Synopsis

int fflush(
   FILE * stream)

Function

Flush a stream. If the stream is an input stream, then the stream
is synchronised for unbuffered I/O. If the stream is an output
stream, then any buffered data is written.

Inputs

stream - Flush this stream. May be NULL. In this case, all
        output streams are flushed.

Result

0 on success or EOF on error.

fgetc()

Synopsis

int fgetc(
   FILE * stream)

Function

Read one character from the stream. If there is no character
available or an error occurred, the function returns EOF.

Inputs

stream - Read from this stream

Result

The character read or EOF on end of file or error.

fgetpos()

Synopsis

int fgetpos(
   FILE   * stream,
   fpos_t * pos)

Function

Get the current position in a stream. This function is eqivalent
to ftell(). However, on some systems fpos_t may be a complex
structure, so this routine may be the only way to portably
get the position of a stream.

Inputs

stream - The stream to get the position from.
pos - Pointer to the fpos_t position structure to fill.

Result

0 on success and -1 on error. If an error occurred, the global
variable errno is set.

fgets()

Synopsis

char * fgets(
   char * buffer,
   int    size,
   FILE * stream)

Function

Read one line of characters from the stream into the buffer.
Reading will stop, when a newline ('\n') is encountered, EOF
or when the buffer is full. If a newline is read, then it is
put into the buffer. The last character in the buffer is always
'\0' (Therefore at most size-1 characters can be read in one go).

Inputs

buffer - Write characters into this buffer
size - This is the size of the buffer in characters.
stream - Read from this stream

Result

buffer or NULL in case of an error or EOF.

Example

// Read a file line by line
char line[256];

// Read until EOF
while (fgets (line, sizeof (line), fh))
{
    // Evaluate the line
}

fileno()

Synopsis

int fileno(
   FILE *stream)

Function

Returns the descriptor associated with the stream

Inputs

strem - the stream to get the descriptor from

Result

The integer descriptor

flock()

Synopsis

int flock(
   int fd,
   int operation)

fopen()

Synopsis

FILE * fopen(
   const char * pathname,
   const char * mode)

Function

Opens a file with the specified name in the specified mode.

Inputs

pathname - Path and filename of the file you want to open.
mode - How to open the file:

        r: Open for reading. The stream is positioned at the
                beginning of the file.

        r+: Open for reading and writing. The stream is positioned
                at the beginning of the file.

        w: Open for writing. If the file doesn't exist, then
                it is created. If it does already exist, then
                it is truncated. The stream is positioned at the
                beginning of the file.

        w+: Open for reading and writing. If the file doesn't
                exist, then it is created. If it does already
                exist, then it is truncated. The stream is
                positioned at the beginning of the file.

        a: Open for writing. If the file doesn't exist, then
                it is created. The stream is positioned at the
                end of the file.

        a+: Open for reading and writing. If the file doesn't
                exist, then it is created. The stream is positioned
                at the end of the file.

        b: Open in binary more. This has no effect and is ignored.

Result

A pointer to a FILE handle or NULL in case of an error. When NULL
is returned, then errno is set to indicate the error.

Notes

This function must not be used in a shared library or
in a threaded application.

Bugs

Most modes are not supported right now.

fprintf()

Synopsis

int fprintf(
   FILE       * fh,
   const char * format,
   ...)

Function

Format a string with the specified arguments and write it to
the stream.

Inputs

fh - Write to this stream
format - How to format the arguments
... - The additional arguments

Result

The number of characters written to the stream or EOF on error.

fputc()

Synopsis

int fputc(
   int    c,
   FILE * stream)

Function

Write one character to the specified stream.

Inputs

c - The character to output
stream - The character is written to this stream

Result

The character written or EOF on error.

fputs()

Synopsis

int fputs(
   const char * str,
   FILE       * stream)

Function

Write a string to the specified stream.

Inputs

str - Output this string...
fh - ...to this stream

Result

> 0 on success and EOF on error.

fread()

Synopsis

size_t fread(
   void * buf,
   size_t size,
   size_t nblocks,
   FILE * stream)

Function

Read an amount of bytes from a stream.

Inputs

buf - The buffer to read the bytes into
size - Size of one block to read
nblocks - The number of blocks to read
stream - Read from this stream

Result

The number of blocks read. This may range from 0 when the stream
contains no more blocks up to nblocks. In case of an error, 0 is
returned.

free()

Synopsis

void free(
   void * memory)

Function

Return memory allocated with malloc() or a similar function to the
system.

Inputs

memory - The result of the previous call to malloc(), etc. or
        NULL.

Result

None.

Notes

This function must not be used in a shared library or in a threaded
application.

freopen()

Synopsis

FILE *freopen(
   const char *path,
   const char *mode,
   FILE       *stream
   )

Function

Opens the  file whose name is the string pointed to by path  and
associates  the  stream  pointed to by stream with it.

Inputs

path   - the file to open
mode   - The mode of the stream  (same as with fopen()) must be com­
         patible with the mode of the file  descriptor.   The  file
         position  indicator  of  the  new  stream  is  set to that
         belonging to fildes, and the error and end-of-file indica­
         tors  are cleared.  Modes "w" or "w+" do not cause trunca­
         tion of the file.  The file descriptor is not dup'ed,  and
         will  be  closed  when  the  stream  created  by fdopen is
         closed.
stream - the stream to wich the file will be associated.

Result

NULL on error or stream.

fscanf()

Synopsis

int fscanf(
   FILE       * fh,
   const char * format,
   ...)

Function

Scan a string with the specified arguments and write the results
in the specified parameters.

Inputs

fh - Read from this stream
format - How to convert the input into the arguments
... - Write the result in these arguments

Result

The number of converted arguments.

fseek()

Synopsis

int fseek(
   FILE * stream,
   long   offset,
   int    whence)

Function

Change the current position in a stream.

Inputs

stream - Modify this stream
offset, whence - How to modify the current position. whence
        can be SEEK_SET, then offset is the absolute position
        in the file (0 is the first byte), SEEK_CUR then the
        position will change by offset (ie. -5 means to move
        5 bytes to the beginning of the file) or SEEK_END.
        SEEK_END means that the offset is relative to the
        end of the file (-1 is the last byte and 0 is
        the EOF).

Result

0 on success and -1 on error. If an error occurred, the global
variable errno is set.

Bugs

Not fully compatible with iso fseek, especially in 'ab' and 'a+b'
modes

fsetpos()

Synopsis

int fsetpos(
   FILE            * stream,
   const fpos_t    * pos)

Function

Change the current position in a stream. This function is eqivalent
to fseek() with whence set to SEEK_SET. However, on some systems
fpos_t may be a complex structure, so this routine may be the only
way to portably reposition a stream.

Inputs

stream - Modify this stream
pos - The new position in the stream.

Result

0 on success and -1 on error. If an error occurred, the global
variable errno is set.

fstat()

Synopsis

int fstat(
   int fd,
   struct stat *sb)

fsync()

Synopsis

int fsync(
   int fd)

ftell()

Synopsis

long ftell(
   FILE * stream)

Function

Tell the current position in a stream.

Inputs

stream - Obtain position of this stream

Result

The position on success and -1 on error.
If an error occurred, the global variable errno is set.

ftime()

Synopsis

int ftime(
   struct timeb *tb)

ftruncate()

Synopsis

int ftruncate(
   int   fd,
   off_t length)

Function

Truncate a file to a specified length

Inputs

fd     - the descriptor of the file being truncated.
         The file must be open for writing
lenght - The file will have at most this size

Result

0 on success or -1 on errorr.

Notes

If the file previously was larger than this size, the extra  data
is  lost.   If  the  file  previously  was  shorter, it is
unspecified whether the  file  is  left  unchanged  or  is
extended.  In  the  latter case the extended part reads as
zero bytes.

fwrite()

Synopsis

size_t fwrite(
   const void * restrict   buf,
   size_t                  size,
   size_t                  nblocks,
   FILE * restrict         stream)

Function

Write an amount of bytes to a stream.

Inputs

buf - The buffer to write to the stream
size - Size of one block to write
nblocks - The number of blocks to write
stream - Write to this stream

Result

The number of blocks written. If no error occurred, this is
nblocks. Otherwise examine errno for the reason of the error.

gcvt()

Synopsis

char * gcvt(
   double    number,
   int       ndigit,
   char    * buf
   )

Function

Converts a number to a minimal length NULL terminated ASCII string.
It produces ndigit significant digits in either printf F format or
E format.

Inputs

number  - The number to convert.
ndigits - The number of significan digits that the string has to have.
buf     - The buffer that will contain the result string.

Result

The address of the string pointed to by buf.

getc()

Synopsis

int getc(
   FILE * stream)

Function

Read one character from the stream. If there is no character
available or an error occurred, the function returns EOF.

Inputs

stream - Read from this stream

Result

The character read or EOF on end of file or error.

getchar()

Synopsis

int getchar(

Function

Read one character from the standard input stream. If there
is no character available or an error occurred, the function
returns EOF.

Result

The character read or EOF on end of file or error.

getcwd()

Synopsis

char *getcwd(
   char *buf,
   size_t size)

Function

Get the current working directory.

Inputs

buf - Pointer of the buffer where the path is to be stored
size - The size of the above buffer

Result

Copies the absolute pathname of the current working directory
to the buffer. If the pathname is longer than the buffer
(with lenght "size") NULL is returned and errno set to ERANGE.
Otherwise the pointer to the buffer is returned.

Notes

If buf is NULL this function will allocate the buffer itself
using malloc() and the specified size "size". If size is
0, too, the buffer is allocated to hold the whole path.
It is possible and recommended to free() this buffer yourself!
The path returned does not have to be literally the same as the
one given to chdir. See NOTES from chdir for more explanation.

getegid()

Synopsis

gid_t getegid(
   void)

getenv()

Synopsis

char *getenv(
   const char *name)

Function

Get an environment variable.

Inputs

name - Name of the environment variable.

Result

Pointer to the variable's value, or NULL on failure.

Notes

This function must not be used in a shared library.

geteuid()

Synopsis

uid_t geteuid(
   void)

getfsstat()

Synopsis

 int getfsstat(
struct statfs *buf,
long bufsize,
int flags)

Function

Gets information about mounted filesystems.

Inputs

buf - pointer to statfs structures where information about filesystems
    will be stored or NULL
bufsize - size of buf in bytes
flags - not used