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

Home

English

Deutsch

Ελληυικά

Français

Italiano

Nederlands

Polski

Português

Русский

Español

Suomi

Svenska

Česky


News

Archive

Introduction

Status
Screenshots
Ports
License

Download


Documentation

Users
Installation
Using
Shell commands
Applications
FAQ
Developers
Contribute
Roadmap
Bug Tracker
Working with Subversion
Compiling
Application Development Manual
Zune Application Development Manual
System Development Manual
Debugging Manual
Reference
Specifications
UI Style Guide
Documenting
Porting
Translating
Summaries
Links

Contact

Mailing lists
IRC channels

Credits

Acknowledgements


Pictures

Developers
Developers en Masse

Sponsors

Linking

Links

SourceForge Logo

dos

Index


AbortPkt AddBuffers AddDosEntry AddPart
AddSegment AllocDosObject AssignAdd AssignLate
AssignLock AssignPath AttemptLockDosList ChangeMode
CheckSignal Cli CliInitNewcli CliInitRun
Close CompareDates CreateDir CreateNewProc
CreateProc CurrentDir DateStamp DateToStr
Delay DeleteFile DeleteVar DeviceProc
DisplayError DoPkt DupLock EndNotify
Error ErrorReport ExAll ExAllEnd
ExNext Examine Execute Exit
FGetC FGets FPutC FPuts
FRead FWrite Fault FilePart
FindArg FindCliProc FindDosEntry FindSegment
FindVar Flush Format FreeArgs
FreeDeviceProc FreeDosEntry FreeDosObject GetArgStr
GetConsoleTask GetCurrentDirName GetDeviceProc GetFileSysTask
GetProgramDir GetProgramName GetPrompt GetVar
Info Inhibit Input InternalLoadSeg
InternalUnLoadSeg IoErr IsFileSystem IsInteractive
LoadSeg Lock LockDosList LockRecord
LockRecords MakeDosEntry MakeLink MatchEnd
MatchFirst MatchNext MatchPattern MatchPatternNoCase
MaxCli NameFromLock NewLoadSeg NextDosEntry
Open OpenFromLock Output ParentDir
ParentOfFH ParsePattern ParsePatternNoCase PathPart
Pipe PrintFault PutStr Read
ReadArgs ReadItem ReadLink Relabel
RemAssignList RemDosEntry RemSegment Rename
ReplyPkt RunCommand SameDevice SameLock
ScanVars Seek SelectError SelectInput
SelectOutput SendPkt SetArgStr SetComment
SetConsoleTask SetCurrentDirName SetFileDate SetFileSize
SetFileSysTask SetIoErr SetMode SetOwner
SetProgramDir SetProgramName SetPrompt SetProtection
SetVBuf SetVar SplitName StartNotify
StrToDate StrToLong SystemTagList UnGetC
UnLoadSeg UnLockDosList UnLockRecord UnLockRecords
VFPrintf VFWritef VPrintf WaitForChar
WaitPkt Write WriteChars  

AbortPkt

Synopsis

void AbortPkt(
         struct MsgPort   * port,
         struct DosPacket * pkt );

AddBuffers

Synopsis

LONG AddBuffers(
         CONST_STRPTR devicename,
         LONG numbuffers );

Function

Add or remove cache memory from a filesystem.

Inputs

devicename  --  NUL terminated dos device name.
numbuffers  --  Number of buffers to add. May be negative.

Result

!= 0 on success (IoErr() gives the actual number of buffers),
0 else (IoErr() gives the error code).

AddDosEntry

Synopsis

LONG AddDosEntry(
         struct DosList * dlist );

Function

Adds a given dos list entry to the dos list. Automatically
locks the list for writing. There may be not more than one device
or assign node of the same name. There are no restrictions on
volume nodes.

Inputs

dlist - pointer to dos list entry.

Result

!= 0 if all went well, 0 otherwise.

Notes

Since anybody who wants to use a device or volume node in the
dos list has to lock the list, filesystems may be called with
the dos list locked. So if you want to add a dos list entry
out of a filesystem don't just wait on the lock but serve all
incoming requests until the dos list is free instead.

AddPart

Synopsis

BOOL AddPart(
         STRPTR dirname,
         CONST_STRPTR filename,
         ULONG size );

Function

AddPart() will add a file, directory or other path name to a
directory path. It will take into account any pre-existing
separator characters (':','/').

If filename is a fully qualified path, then it will replace
the current value of dirname.

Inputs

dirname     -   the path to add the new path to
filename    -   the path you wish added
size        -   The size of the dirname buffer (must NOT be 0)

Result

Non-zero if everything succeeded, FALSE if the buffer would have
overflowed.

If the buffer would have overflowed, then dirname will not have
been changed.

Example

UBYTE buffer[80];
buffer[0]='\0';
AddPart(buffer, "Work:", 80);
AddPart(buffer, "Programming/Include/exec", 80);

FPuts(Output(), buffer);
--> Work:Programming/Include/exec

AddPart(buffer, "/graphics", 80);

FPuts(Output(), buffer);
--> Work:Programming/Include/graphics

AddPart(buffer, "gfxmacros.h", 80);
FPuts(Output(), buffer);
--> Work:Programming/Include/graphics/gfxmacros.h

See also

FilePart(), PathPart()

AddSegment

Synopsis

BOOL AddSegment(
         CONST_STRPTR name,
         BPTR seg,
         LONG type );

Function

Adds a program segment to the system resident list. You can later
use these segments to run programs.

The name field should refer to a NULL terminated strings, which
will be copied. The type field determines the type of resident
program. Normal programs should have type >= 0, system segments
should have type == CMD_SYSTEM.

Note that all other values of type are reserved.

Inputs

name            - Name of the segment. This is used by FindSegment().
seg             - Segment to add.
type            - What type of segment (initial use count).

Result

Segment will have been added to the DOS resident list.

!= 0    success
== 0    failure

Bugs

Uses Forbid() based locking.

See also

FindSegment(), RemSegment()

AllocDosObject

Synopsis

APTR AllocDosObject(
         ULONG type,
         const struct TagItem * tags );

Function

Creates a new dos object of a given type. This memory has to be
freed with FreeDosObject().

Inputs

type - Object type.
tags - Pointer to taglist array with additional information. See
       <dos/dostags.h> for a list of all supported tags.

Result

Pointer to new object or NULL, to indicate an error.

AssignAdd

Synopsis

BOOL AssignAdd(
         CONST_STRPTR name,
         BPTR lock );

Function

Create a multi-directory assign, or adds to it if it already was one.
Do not use or free the lock after calling this function - it becomes
the assign and will be freed by the system when the assign is removed.

Inputs

name - NULL terminated name of the assign.
lock - Lock on the assigned directory.

Result

!= 0 success, 0 on failure. IoErr() gives additional information
in that case. The lock is not freed on failure.

Notes

This will only work with an assign created with AssignLock() or
a resolved AssignLate() assign.

See also

Lock(), AssignLock(), AssignPath(), AssignLate(), DupLock(),
RemAssignList()

AssignLate

Synopsis

BOOL AssignLate(
         CONST_STRPTR name,
         CONST_STRPTR path );

Function

Create an assign for the given name, which will be resolved upon the
first reference to it. If this succeeds (i.e. the path exists and
can be locked) it will be turned into an AssignLock() type assign.
This way you can create assigns to unmounted volumes which will only
be requested when accessed.

Inputs

name  --  NULL terminated name of the assign.
path  --  NULL terminated path to be resolved on the first reference.

Result

!= 0 success, 0 on failure. IoErr() gives additional information
in that case.

See also

Lock(), AssignAdd(), AssignPath(), AssignLock()

AssignLock

Synopsis

BOOL AssignLock(
         CONST_STRPTR name,
         BPTR lock );

Function

Create an assign from a given name to a lock. Replaces any older
assignments from that name, 0 cancels the assign completely. Do not
use or free the lock after calling this function - it becomes
the assign and will be freed by the system if the assign is removed.

Inputs

name -- NUL terminated name of the assign.
lock -- Lock to assigned directory.

Result

!= 0 success, 0 on failure. IoErr() gives additional information
in that case. The lock is not freed on failure.

AssignPath

Synopsis

BOOL AssignPath(
         CONST_STRPTR name,
         CONST_STRPTR path );

Function

Create an assign for the given name, which will be resolved upon
each reference to it. There will be no permanent lock kept on the
specified path. This way you can create assigns to unmounted volumes
which will only be requested when accessed. Also, using AssignPath()
to assign C: to df0:c would make references go to to df0:c even if
you change the disk.

Inputs

name  -- NULL terminated name of the assign.
path  -- NULL terminated path to be resolved on each reference.

Result

!= 0 in case of success, 0 on failure. IoErr() gives additional
information in that case.

See also

AssignAdd(), AssignLock(), AssignLate(), Open()

AttemptLockDosList

Synopsis

struct DosList * AttemptLockDosList(
         ULONG flags );

Function

Tries to get a lock on some of the dos lists. If all went
well a handle is returned that can be used for FindDosEntry().
Don't try to busy wait until the lock can be granted - use
LockDosList() instead.

Inputs

flags  --  what lists to lock

Result

Handle to the dos list or NULL. This is not a direct pointer
to the first list element but to a pseudo element instead.

ChangeMode

Synopsis

BOOL ChangeMode(
         ULONG type,
         BPTR object,
         ULONG newmode );

Function

Try to change the mode used by a lock or filehandle.

Inputs

type    - CHANGE_FH or CHANGE_LOCK.
object  - Filehandle or lock.
newmode - New mode (see <dos/dos.h>).

Result

!= 0 if all went well, otherwise 0. IoErr() gives additional
information in the latter case.

Notes

Since filehandles and locks are identical under AROS the type
argument is ignored.

CheckSignal

Synopsis

LONG CheckSignal(
         LONG mask );

Function

Checks the current task to see if any of the signals specified in
the mask have been set. The mask of all signals which were set is
returned. The signals specified in the mask will be cleared.

Inputs

mask - The signal mask to check.

Result

The mask of all signals which were set.

Cli

Synopsis

struct CommandLineInterface * Cli();

Function

Returns a pointer to the CLI structure of the current process.

Result

Pointer to CLI structure.

Notes

Do not use this function to test if the process was started from
the shell. Check pr_CLI instead.

CliInitNewcli

Synopsis

IPTR CliInitNewcli(
         struct DosPacket * dp );

Function

Set up a process to be a shell using a startup packet.

Inputs

packet  --  startup arguments passed as a packet

Notes

This function is obsolete as AROS don't use packets. There is no need
for this function as functionality is added in other places to deal
with things taken care of by this function. Furthermore, the Amiga
startup packet interface was a pile of crap.

See also

CliInitRun()

CliInitRun

Synopsis

IPTR CliInitRun(
         struct DosPacket * dp );

Function

Set up a process to be a shell.

Inputs

dp  --  startup arguments specified as a packet

Notes

This function is obsolete for the same reasons as CliInitNewCli()
and should not be used.

See also

CliInitNewCli()

Close

Synopsis

BOOL Close(
         BPTR file );

Function

Close a filehandle opened with Open(). If the file was used
with buffered I/O the final write may fail and thus Close()
return an error. The file is closed in any case.

Inputs

file  --  filehandle

Result

0 if there was an error. != 0 on success.

Notes

This function is identical to UnLock().

CompareDates

Synopsis

LONG CompareDates(
         const struct DateStamp * date1,
         const struct DateStamp * date2 );

Function

Compares two dates.

Inputs

date1, date2 - The two dates to compare.

Result

< 0 if date1 is later than date2, == 0 if they are equal or > 0
if date2 is later than date1.

Notes

This is NOT the same ordering as strcmp() !

CreateDir

Synopsis

BPTR CreateDir(
         CONST_STRPTR name );

Function

Creates a new directory under the given name. If all went well, an
exclusive lock on the new diretory is returned.

Inputs

name  -- NUL terminated name.

Result

Exclusive lock to the new directory or 0 if it couldn't be created.
IoErr() gives additional information in that case.

CreateNewProc

Synopsis

struct Process * CreateNewProc(
         struct TagItem * tags );

Function

Create a new process using the tagitem array.

Inputs

tags - information on the new process.

Result

Pointer to the new process or NULL on error.

CreateProc

Synopsis

struct MsgPort * CreateProc(
         CONST_STRPTR name,
         LONG pri,
         BPTR segList,
         LONG stackSize );

Function

CreateProc() will create a new process (a process is a superset
of an exec Task), with the name 'name' and the priority 'pri'.

You should pass a segList as returned by LoadSeg() (or similar)
in the 'segList' parameter, and specify the stack size in
'stackSize'.

You should really use CreateNewProc() rather than this function
as it is much more flexible.

Inputs

name        --   Name of the new process.
pri         --   Starting priority.
segList     --   BCPL pointer to a seglist.
stackSize   --   The size of the initial process stack.

Result

Pointer to the pr_MsgPort in the Process structure. Will
return NULL on failure.

Notes

This will not free the seglist when the process finishes.

This does not return a pointer to the Process structure, but
rather the MsgPort structure contained within it. You can
get the real Process structure by:

struct Process *pr;
struct MsgPort *mp;

mp = CreateProc(...);
pr = (struct Process *)((struct Task *)mp - 1);

// Shouldn't use mp after this point

See also

CreateNewProc(), LoadSeg(), UnLoadSeg()

CurrentDir

Synopsis

BPTR CurrentDir(
         BPTR lock );

Function

Sets a new directory as the current directory. Returns the old one.
0 is valid in both cases and represents the boot filesystem.

Inputs

lock - Lock for the new current directory.

Result

Old current directory.

DateStamp

Synopsis

struct DateStamp * DateStamp(
         struct DateStamp * date );

Function

Fills the structure with the current time. Time is measured from
Jan 1, 1978.

Inputs

date - The structure to fill.

Result

date->ds_Days is filled with the days from Jan 1, 1978.
date->ds_Minute is filled with the number of minutes elapsed in the
day. date->ds_Tick is the number of ticks elapsed in the current
minute. A tick happens 50 times a second. DateStamp() ensures that
the day and minute are consistent. All three elements are zero if
the date is unset.

Notes

The original function could only return even multiples of 50 ticks.

DateToStr

Synopsis

BOOL DateToStr(
         struct DateTime * datetime );

Function

DateToStr converts an AmigaDOS DateStamp to a human
readable ASCII string as requested by your settings in the
DateTime structure.

Inputs

DateTime - a pointer to an initialized DateTime structure. The
           DateTime structure should be initialized as follows:

        dat_Stamp: The datestamp to convert to ascii

        dat_Format: How to convert the datestamp into
                dat_StrDate. Can be any of the following:

            FORMAT_DOS: AmigaDOS format (dd-mmm-yy). This
                is the default if you specify something other
                than any entry in this list.

            FORMAT_INT: International format (yy-mmm-dd).

            FORMAT_USA: American format (mm-dd-yy).

            FORMAT_CDN: Canadian format (dd-mm-yy).

            FORMAT_DEF default format for locale.


        dat_Flags: Modifies dat_Format. The only flag
                used by this function is DTF_SUBST. If set, then
                a string like "Today" or "Monday" is generated
                instead of the normal format if possible.

        dat_StrDay: Pointer to a buffer to receive the day of
                the week string. (Monday, Tuesday, etc.). If null,
                this string will not be generated.

        dat_StrDate: Pointer to a buffer to receive the date
                string, in the format requested by dat_Format,
                subject to possible modifications by DTF_SUBST. If
                null, this string will not be generated.

        dat_StrTime: Pointer to a buffer to receive the time
                of day string. If NULL, this will not be generated.

Result

A zero return indicates that the DateStamp was invalid, and could
not be converted.  Non-zero indicates that the call succeeded.

Example

See below.

See also

DateStamp(), StrtoDate()

Delay

Synopsis

void Delay(
         ULONG timeout );

Function

Waits for at least the time specified as timeout.

Inputs

timeout - the minimum time to wait in ticks (1/50 seconds)

DeleteFile

Synopsis

BOOL DeleteFile(
         CONST_STRPTR name );

Function

Tries to delete a file or directory by a given name.
May fail if the file is in use or protected from deletion.

Inputs

name       - NUL terminated name.

Result

!= 0 if the file is gone, 0 if is still there.
IoErr() gives additional information in that case.

DeleteVar

Synopsis

LONG DeleteVar(
         CONST_STRPTR name,
         ULONG flags );

Function

Deletes a local or environment variable.

The default is to delete a local variable if one was found,
or to delete a global environmental variable otherwise.

A global environmental variable will only be deleted for the
type LV_VAR.

Inputs

name    -   the name of the variable to delete. Note that variable
            names follow the same syntax and semantics as filesystem
            names.

flags   -   A combination of the type of variable (low 8 bits), and
            flags to control the behaviour of this routine.
            Currently defined flags:

            GVF_LOCAL_ONLY  - delete a local variable.
            GVF_GLOBAL_ONLY - delete a global environmental variable.

Result

If non-zero, the variable was deleted successfully,
DOSFALSE otherwise.

Notes

When the GVF_SAVE_VAR flag is set, and only one of the global
variable pair could be deleted (either the in memory or on disk
variable), DOSFALSE will be returned.

DeviceProc

Synopsis

struct MsgPort * DeviceProc(
         CONST_STRPTR name );

Function

DeviceProc() is an obsolete function that returns the Process
responsible for a DOS device. It has been updated to return a
new filesystem device.

DeviceProc() will fail if you ask for the Process of a device
created with AssignPath() as there is no process to return.
If the device requested is an assign, the IoErr() will contain
the Lock to the directory (the function will return the device
on which the lock is set).

Inputs

name - The name of the DOS device, without the ':'.

Result

Either a pointer to the Device structure, or NULL.

Notes

You should really use GetDeviceProc() as this function caters
for all possible device types.

Bugs

Does not support late- and non-bound assigns, or multiple
path assigns very well.

See also

GetDeviceProc(), FreeDeviceProc().

DisplayError

Synopsis

LONG DisplayError(
         CONST_STRPTR formatStr,
         ULONG flags,
         APTR args );

Function

Displays an error message to and gets response from a user.

Inputs

formatStr   --  printf-style formatted string
flags       --  arguments to EasyRequestArgs()
args        --  arguments to 'formatStr'

Result

Nothing

Notes

This is a PRIVATE dos function.

DoPkt

Synopsis

LONG DoPkt(
         struct MsgPort * port,
         LONG action,
         LONG arg1,
         LONG arg2,
         LONG arg3,
         LONG arg4,
         LONG arg5 );

Function

Send a dos packet to a filesystem and wait for the action to complete.

Notes

Callable from a task.

This function should NOT be used; it's only here for AmigaOS compatibility.

DupLock

Synopsis

BPTR DupLock(
         BPTR lock );

Function

Clone a lock on a file or directory. This will only work on shared
locks.

Inputs

lock - Old lock.

Result

The new lock or NULL in case of an error. IoErr() will give additional
information in that case.

Notes

This function is identical to DupLockFromFH().

EndNotify

Synopsis

void EndNotify(
         struct NotifyRequest * notify );

Function

End a notification (quit notifying for a request previously sent with
StartNotify()).

Inputs

notify  --  NotifyRequest used with StartNotify()

See also

StartNotify()

Error

Synopsis

BPTR Error();

Function

Returns the current error stream or 0 if there is no current
input stream.

Result

Error stream handle.

Notes

This function is AROS specific

ErrorReport

Synopsis

BOOL ErrorReport(
         LONG code,
         LONG type,
         IPTR arg1,
         struct MsgPort * device );

Inputs

code    --  The error to put up the requester for
type    --  Type of request

            REPORT_LOCK    --  arg1 is a lock (BPTR).
            REPORT_FH      --  arg1 is a filehandle (BPTR).
            REPORT_VOLUME  --  arg1 is a volumenode (C pointer).
            REPORT_INSERT  --  arg1 is the string for the volumename

arg1    --  Argument according to type (see above)
device  --  Optional handler task address (obsolete!)

Notes

Locks and filehandles are the same in AROS so there is redundancy in
the parameters. Furthermore, the 'device' argument is not cared about
as AROS doesn't build filesystems with handlers.

ExAll

Synopsis

BOOL ExAll(
         BPTR lock,
         struct ExAllData * buffer,
         LONG size,
         LONG data,
         struct ExAllControl * control );

Function

Examine an entire directory.

Inputs

lock     --  lock on the directory to be examined
buffer   --  buffer for the data that is returned (must be aligned)
             which is filled with (partial) ExAllData structures

Result

An indicator of if ExAll() is done. If FALSE is returned, either ExAll()
has completed in which case IoErr() is ERROR_NO_MORE_ENTRIES or an
error occurred. If a non-zero value is returned ExAll() must be called
again until it returns FALSE.

Notes

size     --  size of 'buffer' in bytes
type     --  type of the data to be returned
control  --  a control structure allocated by AllocDosObject()


The following information is essential information on the ExAllData
structure:

ead_type :

See also

Examine(), ExNext(), MatchPatternNoCase(), ParsePatternNoCase(),
AllocDosObject(), ExAllEnd()

ExAllEnd

Synopsis

void ExAllEnd(
         BPTR lock,
         struct ExAllData * buffer,
         LONG size,
         LONG data,
         struct ExAllControl * control );

Function

Stop an ExAll() operation before returning ERROR_NO_MORE_ENTRIES.

Inputs

The inputs should correspond to the inputs for the ExAll() function.

lock     --  lock on the directory that is being examined
buffer   --  buffer for data returned
size     --  size of 'buffer' in bytes
type     --  type of data to be returned
control  --  control data structure

Notes

The control data structure must have been allocated with AllocDosObject().

See also

ExAll(), AllocDosObject()

ExNext

Synopsis

BOOL ExNext(
         BPTR lock,
         struct FileInfoBlock * fileInfoBlock );

Function

Examine the next entry in a directory.

Inputs

lock  --  lock on the direcory the contents of which to examine
fib   --  a FileInfoBlock previously initialized by Examine()
          (or used before with ExNext())

Result

success  --  a boolean telling whether the operation was successful
             or not. A failure occurs also if there is no "next" entry in
             the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES.

Example

To examine a directory, do the following:

1.  Pass a lock on the directory and a FileInfoBlock (allocated by
    AllocDosObject()) to Examine().
2.  Pass the same parameters to ExNext().
3.  Do something with the FileInfoBlock returned.
4.  Call ExNext() repeatedly until it returns FALSE and use the
    information you are provided. When ExNext returns FALSE, check IoErr()
    to make sure that there was no real failure (ERROR_NO_MORE_ENTRIES).

Notes

If scanning a filesystem tree recursively, you'll need to allocated a
new FilInfoBlock for each directory level.

Bugs

At the moment it is necessary that the lock passed to this
function is a directory(!!) that has previously been
assigned (i.e. assign env: env).

See also

Examine(), IoErr(), AllocDosObject(), ExAll()

Examine

Synopsis

BOOL Examine(
         BPTR lock,
         struct FileInfoBlock * fib );

Function

Fill in a FileInfoBlock structure concerning a file or directory
associated with a particular lock.

Inputs

lock  --  lock to examine
fib   --  FileInfoBlock where the result of the examination is stored

Result

A boolean telling whether the operation was successful or not.

Notes

FileInfoBlocks should be allocated with AllocDosObject(). You may make
a copy of the FileInfoBlock but, however, this copy may NOT be passed
to ExNext()!

See also

Lock(), UnLock(), ExNext(), AllocDosObject(), ExAll(), <dos/dos.h>

Execute

Synopsis

LONG Execute(
         CONST_STRPTR string,
         BPTR input,
         BPTR output );

Function

Execute a CLI command specified in 'string'. This string may contain
features you may use on the shell commandline like redirection using >,
< or >>. Execute() doesn't return until the command(s) that should be
executed are finished.
    If 'input' is not NULL, more commands will be read from this stream
until end of file is reached. 'output' will be used as the output stream
of the commands (if output is not redirected). If 'output' is NULL the
current window is used for output -- note that programs run from the
Workbench doesn't normally have a current window.

Inputs

string  --  pointer to a NULL-terminated string with commands
            (may be NULL)
input   --  stream to use as input (may be NULL)
output  --  stream to use as output (may be NULL)

Result

Boolean telling whether Execute() could find and start the specified
command(s). (This is NOT the return code of the command(s).)

See also

SystemTagList()

Exit

Synopsis

void Exit(
         LONG returnCode );

Function

Obsolete function, the purpose of which was to exit from a BCPL program.

Notes

This function is obsolete and doens't do anything. Therefore, do not
call it!

FGetC

Synopsis

LONG FGetC(
         BPTR file );

Function

Get a character from a buffered file. Buffered I/O is more efficient
for small amounts of data but less for big chunks. You have to
use Flush() between buffered and non-buffered I/O or you'll
clutter your I/O stream.

Inputs

file   - filehandle

Result

The character read or EOF if the file ended or an error happened.
IoErr() gives additional information in that case.

See also

IoErr(), Flush()

FGets

Synopsis

STRPTR FGets(
         BPTR fh,
         STRPTR buf,
         ULONG buflen );

Function

Read until NEWLINE (\n), EOF is encountered or buflen-1
characters have been read. If a NEWLINE is read, it will
be the last character in the buffer. The buffer will always
be \0-terminated.

Inputs

fh - Read buffered from this filehandle
buf - Put read chars in this buffer
buflen - The size of the buffer

Result

buf or NULL if the first thing read is EOF.

FPutC

Synopsis

LONG FPutC(
         BPTR file,
         LONG character );

Inputs

file      - Filehandle to write to.
character - Character to write.

Result

The character written or EOF in case of an error.
IoErr() gives additional information in that case.

See also

FGetC(), IoErr()

FPuts

Synopsis

LONG FPuts(
         BPTR file,
         CONST_STRPTR string );

Function

This routine writes an unformatted string to the filehandle.  No
newline is appended to the string.  This routine is buffered.

Inputs

file   - Filehandle to write to.
string - String to write.

Result

0 if all went well or EOF in case of an error.
IoErr() gives additional information in that case.

See also

FGetC(), IoErr()

FRead

Synopsis

LONG FRead(
         BPTR fh,
         APTR block,
         ULONG blocklen,
         ULONG number );

Function

Read a number of blocks from a file.

Inputs

fh - Read from this file
block - The data is put here
blocklen - This is the size of a single block
number - The number of blocks

Result

The number of blocks read from the file or 0 on EOF.
This function may return less than the requested number of blocks
IoErr() gives additional information in case of an error.

See also

Open(), FWrite(), FPutc(), Close()

FWrite

Synopsis

LONG FWrite(
         BPTR fh,
         CONST_APTR block,
         ULONG blocklen,
         ULONG numblocks );

Function

Write a number of blocks to a file.

Inputs

    fh        - Write to this file
    block     - The data begins here
blocklen  - number of bytes per block.  Must be > 0.
numblocks - number of blocks to write.  Must be > 0.

Result

The number of blocks written to the file or EOF on error. IoErr()
gives additional information in case of an error.

See also

Open(), FRead(), FPutc(), Close()

Fault

Synopsis

BOOL Fault(
         LONG code,
         CONST_STRPTR header,
         STRPTR buffer,
         LONG len );

Function

Fault will obtain the error message string for the given error
code. First the header string is copied to the buffer, followed
by a ":" (colon), then the NULL terminated string for the error
message into the buffer.

By convention, error messages are ALWAYS less than 80 (plus 1 for
NULL termination), and ideally less than 60 characters.

If the error code is not know, then the string "Unknown error"
followed by the error number will be added to the string.

Inputs

code    -   The error code.
header  -   The string to prepend to the buffer before the error
            text. This may be NULL in which case nothing is prepended.
buffer  -   The destination buffer.
len     -   Length of the buffer.

Result

Number of characters placed in the buffer, may be 0.

FilePart

Synopsis

STRPTR FilePart(
         CONST_STRPTR path );

Function

Get a pointer to the last component of a path, which is normally the
filename.

Inputs

path - pointer AmigaDOS path string
    May be relative to the current directory or the current disk.

Result

A pointer to the first char of the filename!

Example

FilePart("xxx:yyy/zzz/qqq") returns a pointer to the first 'q'.
FilePart("xxx:yyy")         returns a pointer to the first 'y'.
FilePart("yyy")             returns a pointer to the first 'y'.

Bugs

None known.

See also

PathPart(), AddPart()

FindArg

Synopsis

LONG FindArg(
         CONST_STRPTR template,
         CONST_STRPTR keyword );

FindCliProc

Synopsis

struct Process * FindCliProc(
         ULONG num );

Function

Find a CLI process by its task number. The number must be greater
than 0.

Inputs

num - The task number of the CLI to find.

Result

Pointer to the process if found, NULL otherwise.

Notes

The process calling this function doesn't need to do any locking.

See also

Cli(), MaxCli()

FindDosEntry

Synopsis

struct DosList * FindDosEntry(
         struct DosList * dlist,
         CONST_STRPTR name,
         ULONG flags );

Function

Looks for the next dos list entry with the right name. The list
must be locked for this. There may be not more than one device
or assign node of the same name. There are no restrictions on
volume nodes.

Inputs

dlist - the value given by LockDosList() or the last call to
        FindDosEntry().
name  - logical device name without colon. Case insensitive.
flags - the same flags as given to LockDosList() or a subset
        of them.

Result

Pointer to dos list entry found or NULL if the are no more entries.

FindSegment

Synopsis

struct Segment * FindSegment(
         CONST_STRPTR name,
         struct Segment * seg,
         BOOL system );

Function

Search for a resident segment by name and type. FindSegment() will
return the first segment that exactly matches the name and type.

You can continue searching by specifying the last returned segment
as the seg argument.

Inputs

name            - Name of the segment to search for.
seg             - Start search from this point.
system          - Search for a system segment.

Result

Will return the segment structure if a match is found, otherwise
will return NULL.

Notes

FindSegment() does no locking of the segment list. You should
lock yourself. FindSegment() also does not increment the value
of the seg_UC field. If the value of seg_UC > 0, you MUST
perform user counting in order to prevent the segment from being
unloaded.

See also

AddSegment(), RemSegment()

FindVar

Synopsis

struct LocalVar * FindVar(
         CONST_STRPTR name,
         ULONG type );

Function

Finds a local variable structure.

Inputs

name   --   the name of the variable you wish to find. Note that
            variable names follow the same syntax and semantics
            as filesystem names.
type   --   The type of variable to be found (see <dos/var.h>).
            Actually, only the lower 8 bits of "type" are used
            by FindVar().

Result

A pointer to the LocalVar structure for that variable if it was
found. If the variable wasn't found, or was of the wrong type,
NULL will be returned.

See also

DeleteVar(), GetVar(), SetVar()

Flush

Synopsis

LONG Flush(
         BPTR file );

Function

Flushes any pending writes on the file. If the file was used
for input and there is still some data to read it tries to
seek back to the expected position.

Inputs

file - filehandle

Result

!= 0 on success, 0 on error. IoErr() gives additional information
in that case.

Format

Synopsis

BOOL Format(
         CONST_STRPTR devicename,
         CONST_STRPTR volumename,
         ULONG dostype );

Function

Initialise a filesystem for use by the system. This instructs
a filesystem to write out the data that it uses to describe the
device.

The device should already have been formatted.

Inputs

devicename      - Name of the device to format.
volumename      - The name you wish the volume to be called.
dostype         - The DOS type you wish on the disk.

Result

!= 0 if the format was successful, 0 otherwise.

FreeArgs

Synopsis

void FreeArgs(
         struct RDArgs * args );

Function

FreeArgs() will clean up after a call to ReadArgs(). If the
RDArgs structure was allocated by the system in a call to
ReadArgs(), then it will be freed. If however, you allocated
the RDArgs structure with AllocDosObject(), then you will
have to free it yourself with FreeDosObject().

Inputs

args            - The data used by ReadArgs(). May be NULL,
                  in which case, FreeArgs() does nothing.

Result

Some memory will have been returned to the system.

See also

ReadArgs()

FreeDeviceProc

Synopsis

void FreeDeviceProc(
         struct DevProc * dp );

Function

FreeDeviceProc() will clean up after a call to GetDeviceProc().

Inputs

dp              - DevProc structure as returned by GetDeviceProc().

Result

Some memory and other resources returned to the system.

See also

GetDeviceProc()

FreeDosEntry

Synopsis

void FreeDosEntry(
         struct DosList * dlist );

Function

Free a dos list entry created with MakeDosEntry().

Inputs

dlist  --  pointer to dos list entry. May be NULL.

FreeDosObject

Synopsis

void FreeDosObject(
         ULONG type,
         APTR ptr );

Function

Frees an object allocated with AllocDosObject.

Inputs

type - object type. The same parameter as given to AllocDosObject().
ptr  - Pointer to object.

GetArgStr

Synopsis

STRPTR GetArgStr();

Function

Returns a pointer to the argument string passed to the current
process at startup.

Result

Pointer to argument string.

GetConsoleTask

Synopsis

struct MsgPort * GetConsoleTask();

Function

Return the console handler for the current Process. The return
type depends upon whether AROS is running binary compatible.

Inputs

None.

Result

The address of the console handler, or NULL if none is set.

Notes

You will only get NULL from this call if you call it on a Task,
or when the Process is not attached to a console.

See also

SetConsoleTask()

GetCurrentDirName

Synopsis

BOOL GetCurrentDirName(
         STRPTR buf,
         LONG len );

Function

Copies the name of the current directory from the CLI structure
into the buffer. If the buffer is too small the name is truncated,
and a failure is returned. If the current process doesn't have
a CLI structure, a 0 length string is put into the buffer and a
failure is returned.

Inputs

buf - Buffer for the name.
len - Size of the buffer in bytes.

Result

!=0 on success, 0 on failure. IoErr() gives additional information
in that case.

See also

SetCurrentDirName()

GetDeviceProc

Synopsis

struct DevProc * GetDeviceProc(
         CONST_STRPTR name,
         struct DevProc * dp );

Function

GetDeviceProc() will search for the filesystem handler which
you should send a command to for a specific path.

By calling GetDeviceProc() multiple times, the caller will
be able to handle multi-assign paths.

The first call to GetDeviceProc() should have the |dp| parameter
as NULL.

Inputs

name            - Name of the object to find.
dp              - Previous result of GetDeviceProc() or NULL.

Result

A pointer to a DevProc structure containing the information
required to send a command to a filesystem.

Bugs

Currently doesn't return dvp_DevNode for locks which are
relative to "PROGDIR:", ":", or the current directory.

See also

FreeDeviceProc()

GetFileSysTask

Synopsis

struct MsgPort * GetFileSysTask();

Function

Return the default filesystem handler for this process.

Inputs

None.

Result

The default filesystem handler for this process.

See also

SetFileSysTask()

GetProgramDir

Synopsis

BPTR GetProgramDir();

Function

This function will return the shared lock on the directory that
the current process was loaded from. You can use this to help
you find data files which were supplied with your program.

A NULL return is possible, which means that you may be running
from the Resident list.

You should NOT under any circumstance UnLock() this lock.

Result

A shared lock on the directory the program was started from.

GetProgramName

Synopsis

BOOL GetProgramName(
         STRPTR buf,
         LONG len );

Function

Copies the name of the current program from the CLI structure
into the buffer. If the buffer is too small the name is truncated,
and a failure is returned. If the current process doesn't have
a CLI structure, a 0 length string is put into the buffer and a
failure is returned.

Inputs

buf - Buffer for the name.
len - Size of the buffer in bytes.

Result

!=0 on success, 0 on failure. IoErr() gives additional information
in that case.

See also

SetProgramName()

GetPrompt

Synopsis

BOOL GetPrompt(
         STRPTR buf,
         LONG len );

Function

Copies the prompt from the CLI structure into the buffer. If the
buffer is too small the name is truncated, and a failure is returned.
If the current process doesn't have a CLI structure, a 0 length string
is put into the buffer and a failure is returned.

Inputs

buf - Buffer for the prompt.
len - Size of the buffer in bytes.

Result

!=0 on success, 0 on failure. IoErr() gives additional information
in that case.

See also

SetPrompt()

GetVar

Synopsis

LONG GetVar(
         CONST_STRPTR name,
         STRPTR buffer,
         LONG size,
         LONG flags );

Function

This function will return the value of a local or environmental
variable in the supplied buffer.

It is advised to only use ASCII characters with a variable, but
this is not required.

If GVF_BINARY_VAR is not specified, this function will stop putting
characters into the destination buffer when a '\n' is hit, or the
end of the buffer is reached. Otherwise it will complete fill the
buffer.

Inputs

name    -   the name of the variable you want.
buffer  -   Space to store the returned variable.
size    -   Length of the buffer in bytes.
flags   -   A combination of the type of variable to get (lower
            8 bits) and flags that control the value of this
            function. Current flags are:

            GVF_GLOBAL_ONLY    - only tries to get a global variable.
            GVF_LOCAL_ONLY     - only tries to get a local variable.
            GVF_BINARY_VAR     - do not stop at a '\n' character.
            GVF_DONT_NULL_TERM - no NULL termination. This only
                                 applies to GVF_BINARY_VAR.

Result

Will return the number of characters put in the buffer, or -1
if the variable is not defined. The '\n' character if it exists
will not be placed in the buffer.

If the value would overflow the user buffer, then the number of
characters copied into the buffer will be returned and the buffer
truncated.The buffer will be NULL terminated unless
GVF_DONT_NULL_TERM is set.

IoErr() will contain either:
  ERROR_OBJECT_NOT_FOUND
      if the variable is not defined.
  ERROR_BAD_NUMBER
      if the size of the buffer is 0.
  the total length of the variable
      otherwise.

Bugs

LV_VAR is the only type that can be global.

See also

DeleteVar(), FindVar(), SetVar()

Info

Synopsis

BOOL Info(
         BPTR lock,
         struct InfoData * parameterBlock );

Function

Get information about a volume in the system.

Inputs

lock            --  a lock on any file on the volume for which information
                    should be supplied
parameterBlock  --  pointer to an InfoData structure

Result

Boolean indicating success or failure. If TRUE (success) the
'parameterBlock' is filled with information on the volume.

See also

<dos/dos.h>

Inhibit

Synopsis

LONG Inhibit(
         CONST_STRPTR name,
         LONG onoff );

Function

Stop a filesystem from being used.

Inputs

name   --  Name of the device to inhibit (including a ':')
onoff  --  Specify whether to inhinit (DOSTRUE) or uninhibit (DOSFALSE)
           the device

Result

A boolean telling whether the action was carried out.

Notes

After uninhibiting a device anything might have happened like the disk
in the drive was removed.

Input

Synopsis

BPTR Input();

Function

Returns the current input stream or 0 if there is no current
input stream.

Result

Input stream handle.

InternalLoadSeg

Synopsis

BPTR InternalLoadSeg(
         BPTR fh,
         BPTR table,
         LONG_FUNC functionarray,
         LONG * stack );

Function

Loads from fh.
Functionarray is a pointer to an array of functions. See below.

This function really only tries to load the different file
formats aos, elf and aout.

Inputs

fh            : Filehandle to load from
table         : ignored
functionarray : array of functions to be used for read, alloc and free
   FuncTable[0] -> bytes  = ReadFunc(readhandle, buffer, length), DOSBase
                   D0                D1          A0      D0       A6
   FuncTable[1] -> Memory = AllocFunc(size,flags), ExecBase
                   D0                 D0   D1      A6
   FuncTable[2] -> FreeFunc(memory, size), ExecBase
                            A1       D0    A6
stack         : pointer to storage (ULONG) for stacksize.
                (currently ignored)

Result

seglist  - pointer to loaded Seglist or NULL in case of failure.

Bugs

Use of table and stack are not implemented, yet!

See also

UnLoadSeg()

InternalUnLoadSeg

Synopsis

BOOL InternalUnLoadSeg(
         BPTR seglist,
         VOID_FUNC freefunc );

IoErr

Synopsis

LONG IoErr();

Function

Get the dos error code for the current process.

Result

Error code.

IsFileSystem

Synopsis

BOOL IsFileSystem(
         CONST_STRPTR devicename );

Function

Query the device whether it is a filesystem.

Inputs

devicename      - Name of the device to query.

Result

TRUE if the device is a filesystem, FALSE otherwise.

Notes

DF0:, HD0:, ... are filesystems.
CON:, PIPE:, AUX:, ... are not

In AmigaOS if devicename contains no ":" then result
is always TRUE. Also volume and assign names return
TRUE.

IsInteractive

Synopsis

BOOL IsInteractive(
         BPTR file );

Function

Check if file is bound to an interactive device such as a console
or shell window.

Inputs

file   - filehandle

Result

!= 0 if the file is interactive, 0 if it is not.

LoadSeg

Synopsis

BPTR LoadSeg(
         CONST_STRPTR name );

Function

Loads an executable file into memory. Each hunk of the loadfile
is loaded into its own memory section and a handle on all of them
is returned. The segments can be freed with UnLoadSeg().

Inputs

name - NUL terminated name of the file.

Result

Handle to the loaded executable or NULL if the load failed.
IoErr() gives additional information in that case.

Notes

This function is built on top of InternalLoadSeg()

See also

UnLoadSeg()

Lock

Synopsis

BPTR Lock(
         CONST_STRPTR name,
         LONG accessMode );

Function

Gets a lock on a file or directory. There may be more than one
shared lock on a file but only one if it is an exclusive one.
Locked files or directories may not be deleted.

Inputs

name       - NUL terminated name of the file or directory.
accessMode - One of SHARED_LOCK
                    EXCLUSIVE_LOCK

Result

Handle to the file or directory or 0 if the object couldn't be locked.
IoErr() gives additional information in that case.

Notes

The lock structure returned by this function is different
from that of AmigaOS (in fact it is identical to a filehandle).
Do not try to read any internal fields.

LockDosList

Synopsis

struct DosList * LockDosList(
         ULONG flags );

Function

Waits until the desired dos lists are free then gets a lock on them.
A handle is returned that can be used for FindDosEntry().
Calls to this function nest, i.e. you must call UnLockDosList()
as often as you called LockDosList(). Always lock all lists
at once - do not try to get a lock on one of them then on another.

Inputs

flags - what lists to lock

Result

Handle to the dos list. This is not a direct pointer
to the first list element but to a pseudo element instead.

LockRecord

Synopsis

BOOL LockRecord(
         BPTR fh,
         ULONG offset,
         ULONG length,
         ULONG mode,
         ULONG timeout );

Function

Lock a portion of a file for exclusive access. A timeout may be specified
which is the maximum amount of time to wait for the record to be available.

Inputs

fh       --  file handle for the file to lock a record of
offset   --  starting position of the lock
length   --  length of the record in bytes
mode     --  lock type
timeout  --  timeout interval measured in ticks (may be 0)

Result

Success/failure indicator.

Notes

Record locks are cooperative, meaning that they only affect other calls
to LockRecord().

See also

LockRecords(), UnLockRecord()

LockRecords

Synopsis

BOOL LockRecords(
         struct RecordLock * recArray,
         ULONG timeout );

Function

Lock several records at the same time. The timeout specified is applied
to each lock to attempt. The array of RecordLock:s is terminated with
an entry where rec_FH is equal to NULL.

Inputs

recArray  --  array of records to lock
timeout   --  maximum number of ticks to wait for a lock to be ready

Result

Success/failure indication. In case of a success, all the record locks
are locked. In case of failure, no record locks are locked.

Notes

A set of records should always be locked in the same order so as to
reduce possiblities of deadlock.

See also

UnLockRecords()

MakeDosEntry

Synopsis

struct DosList * MakeDosEntry(
         CONST_STRPTR name,
         LONG type );

Function

Create an entry for the dos list. Depending on the type this may
be a device, a volume or an assign node.

Inputs

name  --  pointer to name
type  --  type of list entry to create

Result

The new device entry, or NULL if it couldn't be created.

See also

AddDosEntry(), RemDosEntry(), FindDosEntry(), LockDosList(),
NextDosEntry(), FreeDosEntry()

MakeLink

Synopsis

LONG MakeLink(
         CONST_STRPTR name,
         APTR dest,
         LONG soft );

Function

MakeLink() will create a link between two files or directories.
A link is a filesystem object that refers to another file.

A soft link refers to another file by name, and is resolved by
the filesystem and the caller. Soft links are not restricted to
the same volume. The |dest| argument is a NUL terminated pathname
to the pre-existing object. Soft links can be used on directories.

A hard link refers to another file by the location on a disk, and
is resolved by the filesystem. Hard links are restricted to files
on the same volume. The |dest| argument is a lock on another file.

Inputs

name - The name of the link to create
dest - If 'soft' is TRUE this must be a filename, if it is FALSE a BPTR
       pointing to the file to be hard-linked must be provided
soft - TRUE, if a soft-link is to be created, FALSE for an hard-link

Result

boolean - DOSTRUE or DOSFALSE. On error, IoErr() will contain more
information.

Bugs

Soft links were not working in the ROM filesystem before version
37.

See also

ReadLink()

MatchEnd

Synopsis

void MatchEnd(
         struct AnchorPath * AP );

Function

Free the memory that was allocated by calls to MatchFirst() and
MatchNext()

Inputs

AP  - pointer to Anchor Path structure which had been passed to
      MatchFirst() before.

Result

Allocated memory is returned and filelocks are freed.

MatchFirst

Synopsis

LONG MatchFirst(
         CONST_STRPTR pat,
         struct AnchorPath * AP );

Function

Searches for the first file or directory that matches a given pattern.
MatchFirst() initializes the AnchorPath structure for you but you
must initilize the following fields: ap_Flags, ap_Strlen, ap_BreakBits
and ap_FoundBreak. The first call to MatchFirst() also passes you
the first matching file which you can examine in ap_Info and the directory
the files is in in ap_Current->an_Lock. After the first call to
MatchFirst(), call MatchNext().
The search begins wherever the current directory is set to. See
CurrentDir();
For more info on patterns see ParsePattern().

Inputs

pat  - pattern to search for
AP   - pointer to (initilized) AnchorPath structure

Result

0     = success
other = DOS error code

See also

MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir()
<dos/dosasl.h>

MatchNext

Synopsis

LONG MatchNext(
         struct AnchorPath * AP );

Function

Find next file or directory that matches a given pattern.
See <dos/dosasl.h> for more docs and how to control MatchNext().

Inputs

AP  - pointer to Anchor Path structure which had been passed to
      MatchFirst() before.

See also

MatchFirst() MatchEnd() CurrentDir() Examine() ExNext()
ParsePattern() <dos/dosasl.h>

MatchPattern

Synopsis

BOOL MatchPattern(
         CONST_STRPTR pat,
         CONST_STRPTR str );

Function

Check if a string matches a pattern. The pattern must be a pattern as
output by ParsePattern(). Note that this routine is case sensitive.

Inputs

pat   --   Pattern string (as returned by ParsePattern())
str   --   The string to match against the pattern 'pat'

Result

Boolean telling whether the string matched the pattern.

See also

ParsePattern(), MatchPatternNoCase(), MatchFirst(), MatchNext()

MatchPatternNoCase

Synopsis

BOOL MatchPatternNoCase(
         CONST_STRPTR pat,
         CONST_STRPTR str );

Function

Similar to MatchPattern(), only case insensitive (see there for
more information). For use with ParsePatternNoCase().

Inputs

pat  --  Pattern as returned by ParsePatternNoCase()
str  --  String to match against the pattern 'pat'

Result

Boolean telling whether the match was successful or not.

See also

MatchPattern(), ParsePatternNoCase().

MaxCli

Synopsis

ULONG MaxCli();

Function

Returns the highest Cli number currently in use. Since processes
may be added and removed at any time the returned value may already
be wrong.

Result

Maximum Cli number (_not_ the number of Clis).

NameFromLock

Synopsis

BOOL NameFromLock(
         BPTR lock,
         STRPTR buffer,
         LONG length );

Function

Get the full path name associated with a lock to a file or
directory into a user supplied buffer.

Inputs

lock   - Lock to file or directory.
buffer - Buffer to fill. Contains a NUL terminated string if
         all went well.
length - Size of the buffer in bytes.

Result

!=0 if all went well, 0 in case of an error. IoErr() will
give additional information in that case.

NewLoadSeg

Synopsis

BPTR NewLoadSeg(
         CONST_STRPTR file,
         struct TagItem * tags );

Function

Loads an executable file into memory via LoadSeg() and takes
additional actions based upon the supplied tags.

Inputs

file - NULL terminated name of the file
tags - pointer to the tagitems

Result

Handle to the loaded executable or 0 if the load failed.
IoErr() gives additional information in that case.

Bugs

As there are no tags currently defined, all this function does is
call LoadSeg()