From 38d7bd9a33bea17137bbd0a4a9e80800100b39d3 Mon Sep 17 00:00:00 2001 From: mazze Date: Wed, 21 Nov 2012 19:47:17 +0000 Subject: [PATCH] Detabbed git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@46059 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/dos/abortpkt.c | 18 +- rom/dos/addbuffers.c | 18 +- rom/dos/adddosentry.c | 238 +++--- rom/dos/addpart.c | 592 ++++++------- rom/dos/addsegment.c | 42 +- rom/dos/allocdosobject.c | 346 ++++---- rom/dos/assignadd.c | 44 +- rom/dos/assignlate.c | 88 +- rom/dos/assignlock.c | 96 +-- rom/dos/assignpath.c | 90 +- rom/dos/attemptlockdoslist.c | 76 +- rom/dos/boot.c | 22 +- rom/dos/bstr_helper.c | 10 +- rom/dos/changemode.c | 30 +- rom/dos/checksignal.c | 16 +- rom/dos/cli.c | 12 +- rom/dos/cliinit.c | 104 +-- rom/dos/cliinitnewcli.c | 6 +- rom/dos/cliinitrun.c | 6 +- rom/dos/close.c | 22 +- rom/dos/comparedates.c | 24 +- rom/dos/createdir.c | 20 +- rom/dos/createnewproc.c | 424 ++++----- rom/dos/createproc.c | 248 +++--- rom/dos/currentdir.c | 14 +- rom/dos/datestamp.c | 34 +- rom/dos/delay.c | 20 +- rom/dos/deletefile.c | 20 +- rom/dos/deviceproc.c | 44 +- rom/dos/displayerror.c | 56 +- rom/dos/dopkt.c | 62 +- rom/dos/dos_init.c | 334 ++++---- rom/dos/dos_intern.h | 112 +-- rom/dos/dosgetstring.c | 46 +- rom/dos/duplock.c | 18 +- rom/dos/duplockfromfh.c | 16 +- rom/dos/endnotify.c | 34 +- rom/dos/errorreport.c | 38 +- rom/dos/exall.c | 356 ++++---- rom/dos/exallend.c | 16 +- rom/dos/examine.c | 12 +- rom/dos/examinefh.c | 12 +- rom/dos/execute.c | 22 +- rom/dos/exit.c | 46 +- rom/dos/exnext.c | 18 +- rom/dos/fault.c | 284 +++---- rom/dos/fgetc.c | 30 +- rom/dos/fgets.c | 44 +- rom/dos/filepart.c | 60 +- rom/dos/findarg.c | 202 ++--- rom/dos/findcliproc.c | 26 +- rom/dos/finddosentry.c | 70 +- rom/dos/findsegment.c | 64 +- rom/dos/findvar.c | 104 +-- rom/dos/flush.c | 42 +- rom/dos/format.c | 28 +- rom/dos/fputc.c | 22 +- rom/dos/fputs.c | 20 +- rom/dos/fread.c | 44 +- rom/dos/freeargs.c | 58 +- rom/dos/freedeviceproc.c | 20 +- rom/dos/freedosentry.c | 18 +- rom/dos/freedosobject.c | 124 +-- rom/dos/fs_driver.c | 24 +- rom/dos/fwrite.c | 24 +- rom/dos/getargstr.c | 10 +- rom/dos/getconsoletask.c | 22 +- rom/dos/getcurrentdirname.c | 40 +- rom/dos/getdeviceproc.c | 156 ++-- rom/dos/getfilesystask.c | 14 +- rom/dos/getprogramdir.c | 20 +- rom/dos/getprogramname.c | 40 +- rom/dos/getprompt.c | 40 +- rom/dos/getvar.c | 284 +++---- rom/dos/include/loadseg.h | 14 +- rom/dos/info.c | 8 +- rom/dos/inhibit.c | 10 +- rom/dos/input.c | 10 +- rom/dos/internalflush.c | 18 +- rom/dos/internalloadseg.c | 44 +- rom/dos/internalloadseg.h | 2 +- rom/dos/internalloadseg_aos.c | 50 +- rom/dos/internalloadseg_elf.c | 14 +- rom/dos/internalseek.c | 6 +- rom/dos/internalunloadseg.c | 46 +- rom/dos/ioerr.c | 8 +- rom/dos/isbootable.c | 42 +- rom/dos/isfilesystem.c | 34 +- rom/dos/isinteractive.c | 14 +- rom/dos/loadseg.c | 52 +- rom/dos/lock.c | 86 +- rom/dos/lockdoslist.c | 58 +- rom/dos/lockrecord.c | 16 +- rom/dos/lockrecords.c | 28 +- rom/dos/makedosentry.c | 64 +- rom/dos/makelink.c | 28 +- rom/dos/match_misc.c | 416 ++++----- rom/dos/match_old.c | 1890 ++++++++++++++++++++--------------------- rom/dos/matchend.c | 64 +- rom/dos/matchfirst.c | 46 +- rom/dos/matchnext.c | 894 +++++++++---------- rom/dos/matchpattern.c | 10 +- rom/dos/matchpatternnocase.c | 8 +- rom/dos/maxcli.c | 12 +- rom/dos/namefrom.c | 112 +-- rom/dos/namefromfh.c | 54 +- rom/dos/namefromlock.c | 30 +- rom/dos/newloadseg.c | 2 +- rom/dos/nextdosentry.c | 22 +- rom/dos/open.c | 152 ++-- rom/dos/openfromlock.c | 18 +- rom/dos/output.c | 10 +- rom/dos/packethelper.c | 12 +- rom/dos/parentdir.c | 18 +- rom/dos/parentoffh.c | 22 +- rom/dos/parsepattern.c | 152 ++-- rom/dos/parsepatternnocase.c | 16 +- rom/dos/pathpart.c | 46 +- rom/dos/patternmatching.c | 1276 ++++++++++++++-------------- rom/dos/printfault.c | 58 +- rom/dos/putstr.c | 6 +- rom/dos/read.c | 40 +- rom/dos/readitem.c | 82 +- rom/dos/readlink.c | 40 +- rom/dos/relabel.c | 10 +- rom/dos/remassignlist.c | 272 +++--- rom/dos/remdosentry.c | 36 +- rom/dos/remsegment.c | 72 +- rom/dos/rename.c | 158 ++-- rom/dos/replypkt.c | 10 +- rom/dos/rootnode.c | 8 +- rom/dos/runcommand.c | 42 +- rom/dos/runhandler.c | 166 ++-- rom/dos/samedevice.c | 20 +- rom/dos/samelock.c | 34 +- rom/dos/scanvars.c | 204 ++--- rom/dos/seek.c | 54 +- rom/dos/selectinput.c | 14 +- rom/dos/selectoutput.c | 14 +- rom/dos/sendpkt.c | 10 +- rom/dos/setargstr.c | 16 +- rom/dos/setcomment.c | 40 +- rom/dos/setconsoletask.c | 20 +- rom/dos/setcurrentdirname.c | 28 +- rom/dos/setfiledate.c | 22 +- rom/dos/setfilesize.c | 22 +- rom/dos/setfilesystask.c | 16 +- rom/dos/setioerr.c | 12 +- rom/dos/setmode.c | 26 +- rom/dos/setowner.c | 20 +- rom/dos/setprogramdir.c | 26 +- rom/dos/setprogramname.c | 28 +- rom/dos/setprompt.c | 20 +- rom/dos/setprotection.c | 20 +- rom/dos/setvar.c | 544 ++++++------ rom/dos/setvbuf.c | 54 +- rom/dos/splitname.c | 56 +- rom/dos/startnotify.c | 8 +- rom/dos/strtodate.c | 880 +++++++++---------- rom/dos/strtolong.c | 34 +- rom/dos/systemtaglist.c | 228 ++--- rom/dos/ungetc.c | 40 +- rom/dos/unloadseg.c | 4 +- rom/dos/unlock.c | 12 +- rom/dos/unlockdoslist.c | 24 +- rom/dos/unlockrecord.c | 12 +- rom/dos/unlockrecords.c | 22 +- rom/dos/vfprintf.c | 42 +- rom/dos/vfwritef.c | 624 +++++++------- rom/dos/vprintf.c | 22 +- rom/dos/waitforchar.c | 30 +- rom/dos/waitpkt.c | 34 +- rom/dos/write.c | 40 +- rom/dos/writechars.c | 26 +- 174 files changed, 8096 insertions(+), 8096 deletions(-) rewrite rom/dos/adddosentry.c (60%) rewrite rom/dos/addpart.c (75%) rewrite rom/dos/allocdosobject.c (64%) rewrite rom/dos/createproc.c (72%) rewrite rom/dos/fault.c (62%) rewrite rom/dos/findarg.c (63%) rewrite rom/dos/match_old.c (63%) rewrite rom/dos/matchnext.c (83%) rewrite rom/dos/parsepattern.c (66%) rewrite rom/dos/patternmatching.c (69%) rewrite rom/dos/remassignlist.c (63%) rewrite rom/dos/scanvars.c (73%) rewrite rom/dos/setvar.c (61%) rewrite rom/dos/strtodate.c (73%) rewrite rom/dos/vfwritef.c (60%) diff --git a/rom/dos/abortpkt.c b/rom/dos/abortpkt.c index a36437644c..f7ea037973 100644 --- a/rom/dos/abortpkt.c +++ b/rom/dos/abortpkt.c @@ -16,23 +16,23 @@ #include #include - AROS_LH2(void, AbortPkt, + AROS_LH2(void, AbortPkt, /* SYNOPSIS */ - AROS_LHA(struct MsgPort *, port, D1), - AROS_LHA(struct DosPacket *, pkt, D2), + AROS_LHA(struct MsgPort *, port, D1), + AROS_LHA(struct DosPacket *, pkt, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 44, Dos) + struct DosLibrary *, DOSBase, 44, Dos) /* FUNCTION - Tries to abort an asynchronous packet. There is no guarantee - that this succeeds. You must wait for the packet to return - before you can reuse or deallocate it. + Tries to abort an asynchronous packet. There is no guarantee + that this succeeds. You must wait for the packet to return + before you can reuse or deallocate it. INPUTS - port - the message port to where the packet was sent - pkt - the packet to be aborted + port - the message port to where the packet was sent + pkt - the packet to be aborted RESULT diff --git a/rom/dos/addbuffers.c b/rom/dos/addbuffers.c index 15838eb00c..0d3bf20646 100644 --- a/rom/dos/addbuffers.c +++ b/rom/dos/addbuffers.c @@ -14,25 +14,25 @@ NAME */ #include - AROS_LH2(LONG, AddBuffers, + AROS_LH2(LONG, AddBuffers, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, devicename, D1), - AROS_LHA(LONG, numbuffers, D2), + AROS_LHA(CONST_STRPTR, devicename, D1), + AROS_LHA(LONG, numbuffers, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 122, Dos) + struct DosLibrary *, DOSBase, 122, Dos) /* FUNCTION - Add or remove cache memory from a filesystem. + Add or remove cache memory from a filesystem. INPUTS - devicename -- NUL terminated dos device name. - numbuffers -- Number of buffers to add. May be negative. + 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). + != 0 on success (IoErr() gives the actual number of buffers), + 0 else (IoErr() gives the error code). NOTES diff --git a/rom/dos/adddosentry.c b/rom/dos/adddosentry.c dissimilarity index 60% index a13c98b64c..53e880a866 100644 --- a/rom/dos/adddosentry.c +++ b/rom/dos/adddosentry.c @@ -1,119 +1,119 @@ -/* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ - -#include -#include -#include -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include - - AROS_LH1(LONG, AddDosEntry, - -/* SYNOPSIS */ - AROS_LHA(struct DosList *, dlist, D1), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 113, Dos) - -/* 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. - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - Behaviour of this function is slightly different from AmigaOS 3.x - and MorphOS. Instead of LDF_WRITE it locks DosList with LDF_READ - flag. This is done because in AROS handlers are run with DosList - locked with LDF_READ flag and this could cause a lockup if we use - LDF_WRITE here. - - Due to nature of the DosList it is safe to read the list while - someone is adding a node, adding operation is atomic to other - readers. The only problem here would happen if more than one - process attempts to add a DosNode at the same time. In order to - avoid this race condition we make this call single-threaded - using an LDF_ENTRY lock in LDF_WRITE mode. - - LDF_ENTRY is NOT touched when a handler is started up in this - dos.library implementation. LDF_DELETE is not used at all. - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - LONG success = DOSTRUE; - struct DosList *dl; - - if (dlist == NULL) - return success; - - D(bug("[AddDosEntry] Adding '%b' type %d from addr %x Task '%s'\n", - dlist->dol_Name, dlist->dol_Type, dlist, - FindTask(NULL)->tc_Node.ln_Name)); - - dl = LockDosList(LDF_ALL | LDF_READ); - - LockDosList(LDF_ENTRY|LDF_WRITE); - if(dlist->dol_Type != DLT_VOLUME) - { - while(TRUE) - { - dl = BADDR(dl->dol_Next); - - if(dl == NULL) - break; - - if(dl->dol_Type != DLT_VOLUME && !CMPBSTR(dl->dol_Name, dlist->dol_Name)) - { - D(bug("[AddDosEntry] Name clash for %08lx->dol_Name: %b and %08lx->dol_Name %b\n", dl, dl->dol_Name, dlist, dlist->dol_Name)); - success = DOSFALSE; - break; - } - } - } - - if(success) - { - struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info); - - dlist->dol_Next = dinf->di_DevInfo; - dinf->di_DevInfo = MKBADDR(dlist); - } - - UnLockDosList(LDF_ENTRY|LDF_WRITE); - UnLockDosList(LDF_ALL | LDF_READ); - - return success; - - AROS_LIBFUNC_EXIT -} /* AddDosEntry */ +/* + Copyright © 1995-2011, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ + +#include +#include +#include +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include + + AROS_LH1(LONG, AddDosEntry, + +/* SYNOPSIS */ + AROS_LHA(struct DosList *, dlist, D1), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 113, Dos) + +/* 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. + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + Behaviour of this function is slightly different from AmigaOS 3.x + and MorphOS. Instead of LDF_WRITE it locks DosList with LDF_READ + flag. This is done because in AROS handlers are run with DosList + locked with LDF_READ flag and this could cause a lockup if we use + LDF_WRITE here. + + Due to nature of the DosList it is safe to read the list while + someone is adding a node, adding operation is atomic to other + readers. The only problem here would happen if more than one + process attempts to add a DosNode at the same time. In order to + avoid this race condition we make this call single-threaded + using an LDF_ENTRY lock in LDF_WRITE mode. + + LDF_ENTRY is NOT touched when a handler is started up in this + dos.library implementation. LDF_DELETE is not used at all. + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + LONG success = DOSTRUE; + struct DosList *dl; + + if (dlist == NULL) + return success; + + D(bug("[AddDosEntry] Adding '%b' type %d from addr %x Task '%s'\n", + dlist->dol_Name, dlist->dol_Type, dlist, + FindTask(NULL)->tc_Node.ln_Name)); + + dl = LockDosList(LDF_ALL | LDF_READ); + + LockDosList(LDF_ENTRY|LDF_WRITE); + if(dlist->dol_Type != DLT_VOLUME) + { + while(TRUE) + { + dl = BADDR(dl->dol_Next); + + if(dl == NULL) + break; + + if(dl->dol_Type != DLT_VOLUME && !CMPBSTR(dl->dol_Name, dlist->dol_Name)) + { + D(bug("[AddDosEntry] Name clash for %08lx->dol_Name: %b and %08lx->dol_Name %b\n", dl, dl->dol_Name, dlist, dlist->dol_Name)); + success = DOSFALSE; + break; + } + } + } + + if(success) + { + struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info); + + dlist->dol_Next = dinf->di_DevInfo; + dinf->di_DevInfo = MKBADDR(dlist); + } + + UnLockDosList(LDF_ENTRY|LDF_WRITE); + UnLockDosList(LDF_ALL | LDF_READ); + + return success; + + AROS_LIBFUNC_EXIT +} /* AddDosEntry */ diff --git a/rom/dos/addpart.c b/rom/dos/addpart.c dissimilarity index 75% index 9f76bb090c..9fb5272ebe 100644 --- a/rom/dos/addpart.c +++ b/rom/dos/addpart.c @@ -1,296 +1,296 @@ -/* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include "dos_intern.h" - -#include - -/***************************************************************************** - - NAME */ -#include - - AROS_LH3(BOOL, AddPart, - -/* SYNOPSIS */ - AROS_LHA(STRPTR, dirname, D1), - AROS_LHA(CONST_STRPTR, filename, D2), - AROS_LHA(ULONG, size, D3), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 147, Dos) - -/* 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. - - NOTES - - 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 - - BUGS - - SEE ALSO - FilePart(), PathPart() - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - -#if 1 - /* stegerg: a bit simple, but since the other code does not - work correctly. And then even AmigaOS AddPart() - does not seem to do things like eliminating - "dead" path components like: - - "test/test2//test3" --> "test/test3" - - It just makes sure that the path is correct - */ - - char *stringpos; - LONG stringlen; - WORD mustaddslash = 0; - - stringpos = strchr(filename, ':'); - if (stringpos) - { - if (stringpos == (char *)filename) - { - /* The first char of filename is a ':' */ - - /* Find dirname position to where we copy filename later */ - - stringpos = strchr(dirname, ':'); - if (!stringpos) stringpos = dirname; - } - else - { - /* Filename is a fully qualified path including - volume/device name -> replace dirname with filename */ - - stringpos = dirname; - } - } - else - { - /* filename did not contain ':' */ - - stringlen = strlen(dirname); - stringpos = dirname + stringlen; - - /* Check if we must add a slash */ - - if (stringlen > 0) - { - if ((stringpos[-1] != ':') && (stringpos[-1] != '/')) - mustaddslash = 1; - } - } - - /* Check if dirname buffer is big enough */ - - stringlen = ((LONG)(stringpos - (char *)dirname)) + strlen(filename) + 1 + mustaddslash; - if (stringlen <= size) - { - if (mustaddslash) *stringpos++ = '/'; - strcpy(stringpos, filename); - return DOSTRUE; - } - else - { - SetIoErr(ERROR_LINE_TOO_LONG); - return DOSFALSE; - } - -#else - - /* stegerg: this is buggy, because in some places it accesses - chars in dirname behind the (initial) string in - there (after the 0 char). For example: - - char buffer[256]; - - strcpy(buffer, "LOCALE:Catalogs"); - AddPart(buffer, "deutsch", 256); - - gives correct "LOCALE:Catalogs/deutsch" - - but: exactly the same, but buffer before was used for - something else: - - char buffer[256]; - - strcpy(buffer, "PROGDIR:Catalogs"); - AddPart(buffer, "deutsch", 256); - - gives correct "PROGDIR:Catalogs/deutsch" - - strcpy(buffer, "LOCALE:Catalogs"); - AddPart(buffer, "deutsch", 256); - - gives wrong "LOCALE:Catalogs//deutsch" - ^^ - - */ - - LONG didx, fidx; - BOOL gotfull = FALSE; - - /* - Make sure the buffer wouldn't overflow, also finds the ends - of the strings... - */ - - didx = fidx = 0; - - while(dirname[didx]) didx++; - while(filename[fidx]) - { - /* - If this has a colon, and its not the first char, - then this is probably a FQ path. - */ - if((filename[fidx] == ':') && (fidx != 0)) - gotfull = TRUE; - - fidx++; - } - - /* If we got a fully qualified path, then just do a copy. */ - if(gotfull == TRUE) - { - /* +1 for NULL byte */ - if( fidx + 1 > size ) { - SetIoErr(ERROR_LINE_TOO_LONG); - return DOSFALSE; - - while(*filename) - { - *dirname++ = *filename++; - } - *dirname = '\0'; - return DOSTRUE; - } - - /* Otherwise correctly add the subpath on to the end */ - else - { - /* +1 for NULL byte, +1 for '/' */ - if((didx + fidx + 2) > size) { - SetIoErr(ERROR_LINE_TOO_LONG); - return DOSFALSE; - } - - /* - Add a '/' onto the end of the current path, unless of course - the new path has a ':' or '/' on it already or current path - is emtpy (stegerg) ... - */ - if( (*filename != '/') - && (didx != 0 ) - && (dirname[didx - 1] != ':') - && (dirname[didx - 1] != '/') - ) - { - dirname[didx++] = '/'; - } - - /* - Handle leading '/'s - */ - while (*filename == '/') - { - filename ++; - while ((dirname[didx] != '/') && (dirname[didx] != ':') && didx) - didx --; - - /* - if we are at start of dirname buf then break even - if there are more leading '/'s - */ - if (!didx) - break; - - /* - Another leading '/' ?. - Only move up a dir if we are not at the root - */ - if ((*filename== '/') && (dirname[didx] != ':')) - didx --; - - } - /* If at root, don't overwrite the ':' */ - if (dirname[didx] == ':') - didx ++; - /* - if filename not only was a number of '/'s but also contained - a subpath, then be sure to skip the found '/' of dirname. - */ - else if ((dirname[didx] == '/') && *filename) - didx ++; - - /* Now add the parts, making sure to do any backtracking... */ - while(*filename) - { - if(*filename == ':') - { - /* - Search back for a ':' or the start of the buffer - do the ':' test first, so we test for didx = 0 after... - */ - while( (dirname[didx] != ':') && didx) - { - didx--; - } - dirname[didx++] = *filename++; - } - else - dirname[didx++] = *filename++; - } /* while(*filename) */ - - dirname[didx] = '\0'; - } - return DOSTRUE; -#endif - - AROS_LIBFUNC_EXIT -} /* AddPart */ +/* + Copyright © 1995-2008, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include "dos_intern.h" + +#include + +/***************************************************************************** + + NAME */ +#include + + AROS_LH3(BOOL, AddPart, + +/* SYNOPSIS */ + AROS_LHA(STRPTR, dirname, D1), + AROS_LHA(CONST_STRPTR, filename, D2), + AROS_LHA(ULONG, size, D3), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 147, Dos) + +/* 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. + + NOTES + + 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 + + BUGS + + SEE ALSO + FilePart(), PathPart() + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + +#if 1 + /* stegerg: a bit simple, but since the other code does not + work correctly. And then even AmigaOS AddPart() + does not seem to do things like eliminating + "dead" path components like: + + "test/test2//test3" --> "test/test3" + + It just makes sure that the path is correct + */ + + char *stringpos; + LONG stringlen; + WORD mustaddslash = 0; + + stringpos = strchr(filename, ':'); + if (stringpos) + { + if (stringpos == (char *)filename) + { + /* The first char of filename is a ':' */ + + /* Find dirname position to where we copy filename later */ + + stringpos = strchr(dirname, ':'); + if (!stringpos) stringpos = dirname; + } + else + { + /* Filename is a fully qualified path including + volume/device name -> replace dirname with filename */ + + stringpos = dirname; + } + } + else + { + /* filename did not contain ':' */ + + stringlen = strlen(dirname); + stringpos = dirname + stringlen; + + /* Check if we must add a slash */ + + if (stringlen > 0) + { + if ((stringpos[-1] != ':') && (stringpos[-1] != '/')) + mustaddslash = 1; + } + } + + /* Check if dirname buffer is big enough */ + + stringlen = ((LONG)(stringpos - (char *)dirname)) + strlen(filename) + 1 + mustaddslash; + if (stringlen <= size) + { + if (mustaddslash) *stringpos++ = '/'; + strcpy(stringpos, filename); + return DOSTRUE; + } + else + { + SetIoErr(ERROR_LINE_TOO_LONG); + return DOSFALSE; + } + +#else + + /* stegerg: this is buggy, because in some places it accesses + chars in dirname behind the (initial) string in + there (after the 0 char). For example: + + char buffer[256]; + + strcpy(buffer, "LOCALE:Catalogs"); + AddPart(buffer, "deutsch", 256); + + gives correct "LOCALE:Catalogs/deutsch" + + but: exactly the same, but buffer before was used for + something else: + + char buffer[256]; + + strcpy(buffer, "PROGDIR:Catalogs"); + AddPart(buffer, "deutsch", 256); + + gives correct "PROGDIR:Catalogs/deutsch" + + strcpy(buffer, "LOCALE:Catalogs"); + AddPart(buffer, "deutsch", 256); + + gives wrong "LOCALE:Catalogs//deutsch" + ^^ + + */ + + LONG didx, fidx; + BOOL gotfull = FALSE; + + /* + Make sure the buffer wouldn't overflow, also finds the ends + of the strings... + */ + + didx = fidx = 0; + + while(dirname[didx]) didx++; + while(filename[fidx]) + { + /* + If this has a colon, and its not the first char, + then this is probably a FQ path. + */ + if((filename[fidx] == ':') && (fidx != 0)) + gotfull = TRUE; + + fidx++; + } + + /* If we got a fully qualified path, then just do a copy. */ + if(gotfull == TRUE) + { + /* +1 for NULL byte */ + if( fidx + 1 > size ) { + SetIoErr(ERROR_LINE_TOO_LONG); + return DOSFALSE; + + while(*filename) + { + *dirname++ = *filename++; + } + *dirname = '\0'; + return DOSTRUE; + } + + /* Otherwise correctly add the subpath on to the end */ + else + { + /* +1 for NULL byte, +1 for '/' */ + if((didx + fidx + 2) > size) { + SetIoErr(ERROR_LINE_TOO_LONG); + return DOSFALSE; + } + + /* + Add a '/' onto the end of the current path, unless of course + the new path has a ':' or '/' on it already or current path + is emtpy (stegerg) ... + */ + if( (*filename != '/') + && (didx != 0 ) + && (dirname[didx - 1] != ':') + && (dirname[didx - 1] != '/') + ) + { + dirname[didx++] = '/'; + } + + /* + Handle leading '/'s + */ + while (*filename == '/') + { + filename ++; + while ((dirname[didx] != '/') && (dirname[didx] != ':') && didx) + didx --; + + /* + if we are at start of dirname buf then break even + if there are more leading '/'s + */ + if (!didx) + break; + + /* + Another leading '/' ?. + Only move up a dir if we are not at the root + */ + if ((*filename== '/') && (dirname[didx] != ':')) + didx --; + + } + /* If at root, don't overwrite the ':' */ + if (dirname[didx] == ':') + didx ++; + /* + if filename not only was a number of '/'s but also contained + a subpath, then be sure to skip the found '/' of dirname. + */ + else if ((dirname[didx] == '/') && *filename) + didx ++; + + /* Now add the parts, making sure to do any backtracking... */ + while(*filename) + { + if(*filename == ':') + { + /* + Search back for a ':' or the start of the buffer + do the ':' test first, so we test for didx = 0 after... + */ + while( (dirname[didx] != ':') && didx) + { + didx--; + } + dirname[didx++] = *filename++; + } + else + dirname[didx++] = *filename++; + } /* while(*filename) */ + + dirname[didx] = '\0'; + } + return DOSTRUE; +#endif + + AROS_LIBFUNC_EXIT +} /* AddPart */ diff --git a/rom/dos/addsegment.c b/rom/dos/addsegment.c index 9c12961e96..c93cbd32d8 100644 --- a/rom/dos/addsegment.c +++ b/rom/dos/addsegment.c @@ -15,47 +15,47 @@ #include #include - AROS_LH3(BOOL, AddSegment, + AROS_LH3(BOOL, AddSegment, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(BPTR , seg, D2), - AROS_LHA(LONG , type, D3), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(BPTR , seg, D2), + AROS_LHA(LONG , type, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 129, Dos) + struct DosLibrary *, DOSBase, 129, Dos) /* FUNCTION - Adds a program segment to the system resident list. You can later - use these segments to run programs. + 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. + 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. + 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). + 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. + Segment will have been added to the DOS resident list. - != 0 success - == 0 failure + != 0 success + == 0 failure NOTES EXAMPLE BUGS - Uses Forbid() based locking. + Uses Forbid() based locking. SEE ALSO - FindSegment(), RemSegment() + FindSegment(), RemSegment() INTERNALS @@ -75,7 +75,7 @@ } sptr = AllocVec(sizeof(struct Segment) + namelen - 4 + 1, - MEMF_CLEAR | MEMF_PUBLIC); + MEMF_CLEAR | MEMF_PUBLIC); if( sptr == NULL ) { Permit(); diff --git a/rom/dos/allocdosobject.c b/rom/dos/allocdosobject.c dissimilarity index 64% index 8afe5f18c3..fab282dc92 100644 --- a/rom/dos/allocdosobject.c +++ b/rom/dos/allocdosobject.c @@ -1,173 +1,173 @@ -/* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English -*/ -#include -#include -#include -#include -#include -#include -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include - - AROS_LH2(APTR, AllocDosObject, - -/* SYNOPSIS */ - AROS_LHA(ULONG , type, D1), - AROS_LHA(const struct TagItem *, tags, D2), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 38, Dos) - -/* 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 - for a list of all supported tags. - - RESULT - Pointer to new object or NULL, to indicate an error. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - APTR mem; - - switch(type) - { - case DOS_FILEHANDLE: - mem = AllocVec(sizeof(struct FileHandle), MEMF_CLEAR); - - if (mem != NULL) - { - struct FileHandle *fh = (struct FileHandle *)mem; - - fh->fh_Pos = -1; - fh->fh_End = -1; - } - return mem; - - case DOS_FIB: - return AllocVec(sizeof(struct FileInfoBlock), MEMF_CLEAR); - - case DOS_STDPKT: - return allocdospacket(); - - case DOS_EXALLCONTROL: - return AllocVec(sizeof(struct InternalExAllControl), MEMF_CLEAR); - - case DOS_CLI: - { - struct CommandLineInterface *cli = NULL; - struct TagItem defaults[] = - { - /* 0 */ { ADO_DirLen, 255 }, - /* 1 */ { ADO_CommNameLen, 255 }, - /* 2 */ { ADO_CommFileLen, 255 }, - /* 3 */ { ADO_PromptLen, 255 }, - { TAG_END, 0 } - }; - - STRPTR dir = NULL; - STRPTR command = NULL; - STRPTR file = NULL; - STRPTR prompt = NULL; - - /* C has no exceptions. This is a simple replacement. */ -#define ENOMEM_IF(a) if(a) goto enomem /* Throw out of memory. */ - - cli = AllocVec(sizeof(struct CommandLineInterface), MEMF_CLEAR); - ENOMEM_IF(cli == NULL); - - cli->cli_FailLevel = RETURN_ERROR; - cli->cli_Background = DOSTRUE; - ApplyTagChanges(defaults, (struct TagItem *)tags); - - dir = AllocVec(defaults[0].ti_Data + 1, MEMF_PUBLIC | MEMF_CLEAR); - ENOMEM_IF(dir == NULL); - - AROS_BSTR_setstrlen(MKBADDR(dir), 0); - cli->cli_SetName = MKBADDR(dir); - - command = AllocVec(defaults[1].ti_Data + 1, - MEMF_PUBLIC | MEMF_CLEAR); - ENOMEM_IF(command == NULL); - - AROS_BSTR_setstrlen(MKBADDR(command), 0); - cli->cli_CommandName = MKBADDR(command); - - file = AllocVec(defaults[2].ti_Data + 1, MEMF_PUBLIC | MEMF_CLEAR); - ENOMEM_IF(file == NULL); - - AROS_BSTR_setstrlen(MKBADDR(file), 0); - cli->cli_CommandFile = MKBADDR(file); - - prompt = AllocVec(defaults[3].ti_Data + 1, - MEMF_PUBLIC | MEMF_CLEAR); - ENOMEM_IF(prompt == NULL); - - AROS_BSTR_setstrlen(MKBADDR(prompt), 0); - cli->cli_Prompt = MKBADDR(prompt); - - return cli; - -enomem: - if(cli != NULL) - FreeVec(cli); - - FreeVec(dir); - FreeVec(command); - FreeVec(file); - FreeVec(prompt); - - SetIoErr(ERROR_NO_FREE_STORE); - - return NULL; - } - - case DOS_RDARGS: - return AllocVec(sizeof(struct RDArgs), MEMF_CLEAR); - } - - SetIoErr(ERROR_BAD_NUMBER); - - return NULL; - - AROS_LIBFUNC_EXIT -} /* AllocDosObject */ - -/* Internal routines for packet allocation. Does not require DOSBase. */ -struct DosPacket *allocdospacket(void) -{ - struct StandardPacket *sp = AllocVec(sizeof(struct StandardPacket), MEMF_CLEAR); - - if (sp == NULL) - return NULL; - - sp->sp_Pkt.dp_Link = &sp->sp_Msg; - sp->sp_Msg.mn_Node.ln_Name = (char *)&sp->sp_Pkt; - - return &sp->sp_Pkt; -} +/* + Copyright © 1995-2011, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ +#include +#include +#include +#include +#include +#include +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include + + AROS_LH2(APTR, AllocDosObject, + +/* SYNOPSIS */ + AROS_LHA(ULONG , type, D1), + AROS_LHA(const struct TagItem *, tags, D2), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 38, Dos) + +/* 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 + for a list of all supported tags. + + RESULT + Pointer to new object or NULL, to indicate an error. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + APTR mem; + + switch(type) + { + case DOS_FILEHANDLE: + mem = AllocVec(sizeof(struct FileHandle), MEMF_CLEAR); + + if (mem != NULL) + { + struct FileHandle *fh = (struct FileHandle *)mem; + + fh->fh_Pos = -1; + fh->fh_End = -1; + } + return mem; + + case DOS_FIB: + return AllocVec(sizeof(struct FileInfoBlock), MEMF_CLEAR); + + case DOS_STDPKT: + return allocdospacket(); + + case DOS_EXALLCONTROL: + return AllocVec(sizeof(struct InternalExAllControl), MEMF_CLEAR); + + case DOS_CLI: + { + struct CommandLineInterface *cli = NULL; + struct TagItem defaults[] = + { + /* 0 */ { ADO_DirLen, 255 }, + /* 1 */ { ADO_CommNameLen, 255 }, + /* 2 */ { ADO_CommFileLen, 255 }, + /* 3 */ { ADO_PromptLen, 255 }, + { TAG_END, 0 } + }; + + STRPTR dir = NULL; + STRPTR command = NULL; + STRPTR file = NULL; + STRPTR prompt = NULL; + + /* C has no exceptions. This is a simple replacement. */ +#define ENOMEM_IF(a) if(a) goto enomem /* Throw out of memory. */ + + cli = AllocVec(sizeof(struct CommandLineInterface), MEMF_CLEAR); + ENOMEM_IF(cli == NULL); + + cli->cli_FailLevel = RETURN_ERROR; + cli->cli_Background = DOSTRUE; + ApplyTagChanges(defaults, (struct TagItem *)tags); + + dir = AllocVec(defaults[0].ti_Data + 1, MEMF_PUBLIC | MEMF_CLEAR); + ENOMEM_IF(dir == NULL); + + AROS_BSTR_setstrlen(MKBADDR(dir), 0); + cli->cli_SetName = MKBADDR(dir); + + command = AllocVec(defaults[1].ti_Data + 1, + MEMF_PUBLIC | MEMF_CLEAR); + ENOMEM_IF(command == NULL); + + AROS_BSTR_setstrlen(MKBADDR(command), 0); + cli->cli_CommandName = MKBADDR(command); + + file = AllocVec(defaults[2].ti_Data + 1, MEMF_PUBLIC | MEMF_CLEAR); + ENOMEM_IF(file == NULL); + + AROS_BSTR_setstrlen(MKBADDR(file), 0); + cli->cli_CommandFile = MKBADDR(file); + + prompt = AllocVec(defaults[3].ti_Data + 1, + MEMF_PUBLIC | MEMF_CLEAR); + ENOMEM_IF(prompt == NULL); + + AROS_BSTR_setstrlen(MKBADDR(prompt), 0); + cli->cli_Prompt = MKBADDR(prompt); + + return cli; + +enomem: + if(cli != NULL) + FreeVec(cli); + + FreeVec(dir); + FreeVec(command); + FreeVec(file); + FreeVec(prompt); + + SetIoErr(ERROR_NO_FREE_STORE); + + return NULL; + } + + case DOS_RDARGS: + return AllocVec(sizeof(struct RDArgs), MEMF_CLEAR); + } + + SetIoErr(ERROR_BAD_NUMBER); + + return NULL; + + AROS_LIBFUNC_EXIT +} /* AllocDosObject */ + +/* Internal routines for packet allocation. Does not require DOSBase. */ +struct DosPacket *allocdospacket(void) +{ + struct StandardPacket *sp = AllocVec(sizeof(struct StandardPacket), MEMF_CLEAR); + + if (sp == NULL) + return NULL; + + sp->sp_Pkt.dp_Link = &sp->sp_Msg; + sp->sp_Msg.mn_Node.ln_Name = (char *)&sp->sp_Pkt; + + return &sp->sp_Pkt; +} diff --git a/rom/dos/assignadd.c b/rom/dos/assignadd.c index 92a06071e0..3fe15b2f42 100644 --- a/rom/dos/assignadd.c +++ b/rom/dos/assignadd.c @@ -16,39 +16,39 @@ NAME */ #include - AROS_LH2(BOOL, AssignAdd, + AROS_LH2(BOOL, AssignAdd, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(BPTR , lock, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(BPTR , lock, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 105, Dos) + struct DosLibrary *, DOSBase, 105, Dos) /* 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. + 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. + 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. + != 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. + This will only work with an assign created with AssignLock() or + a resolved AssignLate() assign. EXAMPLE BUGS SEE ALSO - Lock(), AssignLock(), AssignPath(), AssignLate(), DupLock(), - RemAssignList() + Lock(), AssignLock(), AssignPath(), AssignLate(), DupLock(), + RemAssignList() INTERNALS @@ -59,27 +59,27 @@ struct AssignList **al, *newal; if(lock == BNULL) - return DOSFALSE; + return DOSFALSE; dl = LockDosList(LDF_ASSIGNS | LDF_WRITE); dl = FindDosEntry(dl, name, LDF_ASSIGNS); if((dl == NULL) || (dl->dol_Type != DLT_DIRECTORY)) { - UnLockDosList(LDF_ASSIGNS | LDF_WRITE); - SetIoErr(ERROR_OBJECT_WRONG_TYPE); + UnLockDosList(LDF_ASSIGNS | LDF_WRITE); + SetIoErr(ERROR_OBJECT_WRONG_TYPE); - return DOSFALSE; + return DOSFALSE; } newal = AllocVec(sizeof(struct AssignList), MEMF_PUBLIC | MEMF_CLEAR); if(newal == NULL) { - UnLockDosList(LDF_ASSIGNS | LDF_WRITE); - SetIoErr(ERROR_NO_FREE_STORE); + UnLockDosList(LDF_ASSIGNS | LDF_WRITE); + SetIoErr(ERROR_NO_FREE_STORE); - return DOSFALSE; + return DOSFALSE; } newal->al_Lock = lock; diff --git a/rom/dos/assignlate.c b/rom/dos/assignlate.c index e4e2e15577..f1b5221375 100644 --- a/rom/dos/assignlate.c +++ b/rom/dos/assignlate.c @@ -16,29 +16,29 @@ NAME */ #include - AROS_LH2(BOOL, AssignLate, + AROS_LH2(BOOL, AssignLate, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(CONST_STRPTR, path, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, path, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 103, Dos) + struct DosLibrary *, DOSBase, 103, Dos) /* 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. + 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. + 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. + != 0 success, 0 on failure. IoErr() gives additional information + in that case. NOTES @@ -47,7 +47,7 @@ BUGS SEE ALSO - Lock(), AssignAdd(), AssignPath(), AssignLock() + Lock(), AssignAdd(), AssignPath(), AssignLock() INTERNALS @@ -65,22 +65,22 @@ newdl = MakeDosEntry(name, DLT_LATE); if (newdl == NULL) - return DOSFALSE; + return DOSFALSE; s2 = path; while(*s2++) - ; + ; namelen = s2 - path + 1; pathcopy = AllocVec(namelen, MEMF_PUBLIC | MEMF_CLEAR); if(pathcopy == NULL) { - FreeDosEntry(newdl); - SetIoErr(ERROR_NO_FREE_STORE); + FreeDosEntry(newdl); + SetIoErr(ERROR_NO_FREE_STORE); - return DOSFALSE; + return DOSFALSE; } CopyMem(path, pathcopy, namelen); @@ -91,41 +91,41 @@ if(dl == NULL) { - AddDosEntry(newdl); + AddDosEntry(newdl); } else if(dl->dol_Type == DLT_VOLUME || dl->dol_Type == DLT_DEVICE) { - dl = NULL; - FreeVec(newdl->dol_misc.dol_assign.dol_AssignName); - FreeDosEntry(newdl); - SetIoErr(ERROR_OBJECT_EXISTS); - result = DOSFALSE; + dl = NULL; + FreeVec(newdl->dol_misc.dol_assign.dol_AssignName); + FreeDosEntry(newdl); + SetIoErr(ERROR_OBJECT_EXISTS); + result = DOSFALSE; } else { - RemDosEntry(dl); - AddDosEntry(newdl); + RemDosEntry(dl); + AddDosEntry(newdl); } if(dl != NULL) { - UnLock(dl->dol_Lock); - - if(dl->dol_misc.dol_assign.dol_List != NULL) - { - struct AssignList *al, *oal; - - for(al = dl->dol_misc.dol_assign.dol_List; al; ) - { - UnLock(al->al_Lock); - oal = al; - al = al->al_Next; - FreeVec(oal); - } - } - - FreeVec(dl->dol_misc.dol_assign.dol_AssignName); - FreeDosEntry(dl); + UnLock(dl->dol_Lock); + + if(dl->dol_misc.dol_assign.dol_List != NULL) + { + struct AssignList *al, *oal; + + for(al = dl->dol_misc.dol_assign.dol_List; al; ) + { + UnLock(al->al_Lock); + oal = al; + al = al->al_Next; + FreeVec(oal); + } + } + + FreeVec(dl->dol_misc.dol_assign.dol_AssignName); + FreeDosEntry(dl); } UnLockDosList(LDF_ALL | LDF_WRITE); diff --git a/rom/dos/assignlock.c b/rom/dos/assignlock.c index 1c156e5685..624a68a9a0 100644 --- a/rom/dos/assignlock.c +++ b/rom/dos/assignlock.c @@ -15,28 +15,28 @@ NAME */ #include - AROS_LH2(LONG, AssignLock, + AROS_LH2(LONG, AssignLock, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(BPTR, lock, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(BPTR, lock, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 102, Dos) + struct DosLibrary *, DOSBase, 102, Dos) /* 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. + 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. + 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. + != 0 success, 0 on failure. IoErr() gives additional information + in that case. The lock is not freed on failure. NOTES @@ -58,17 +58,17 @@ if (lock != BNULL) { - newdl = MakeDosEntry(name, DLT_DIRECTORY); + newdl = MakeDosEntry(name, DLT_DIRECTORY); - if (newdl == NULL) - return DOSFALSE; - else - { - struct FileLock *fl = BADDR(lock); + if (newdl == NULL) + return DOSFALSE; + else + { + struct FileLock *fl = BADDR(lock); - newdl->dol_Task = fl->fl_Task; - newdl->dol_Lock = lock; - } + newdl->dol_Task = fl->fl_Task; + newdl->dol_Lock = lock; + } } dl = LockDosList(LDF_ALL | LDF_WRITE); @@ -76,44 +76,44 @@ if (dl == NULL) { - AddDosEntry(newdl); + AddDosEntry(newdl); } else if (dl->dol_Type == DLT_DEVICE || dl->dol_Type == DLT_VOLUME) { - dl = NULL; - FreeDosEntry(newdl); - SetIoErr(ERROR_OBJECT_EXISTS); - success = DOSFALSE; + dl = NULL; + FreeDosEntry(newdl); + SetIoErr(ERROR_OBJECT_EXISTS); + success = DOSFALSE; } else { - RemDosEntry(dl); + RemDosEntry(dl); - AddDosEntry(newdl); + AddDosEntry(newdl); } if (dl != NULL) { - if (dl->dol_Lock) - { - UnLock(dl->dol_Lock); - } - - if (dl->dol_misc.dol_assign.dol_List != NULL) - { - struct AssignList *al, *oal; - - for (al = dl->dol_misc.dol_assign.dol_List; al; ) - { - UnLock(al->al_Lock); - oal = al; - al = al->al_Next; - FreeVec(oal); - } - } - - FreeVec(dl->dol_misc.dol_assign.dol_AssignName); - FreeDosEntry(dl); + if (dl->dol_Lock) + { + UnLock(dl->dol_Lock); + } + + if (dl->dol_misc.dol_assign.dol_List != NULL) + { + struct AssignList *al, *oal; + + for (al = dl->dol_misc.dol_assign.dol_List; al; ) + { + UnLock(al->al_Lock); + oal = al; + al = al->al_Next; + FreeVec(oal); + } + } + + FreeVec(dl->dol_misc.dol_assign.dol_AssignName); + FreeDosEntry(dl); } UnLockDosList(LDF_ALL | LDF_WRITE); diff --git a/rom/dos/assignpath.c b/rom/dos/assignpath.c index f17f9c0130..bb79f1b9ae 100644 --- a/rom/dos/assignpath.c +++ b/rom/dos/assignpath.c @@ -16,30 +16,30 @@ NAME */ #include - AROS_LH2(BOOL, AssignPath, + AROS_LH2(BOOL, AssignPath, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(CONST_STRPTR, path, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, path, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 104, Dos) + struct DosLibrary *, DOSBase, 104, Dos) /* 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. + 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. + 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. + != 0 in case of success, 0 on failure. IoErr() gives additional + information in that case. NOTES @@ -48,7 +48,7 @@ BUGS SEE ALSO - AssignAdd(), AssignLock(), AssignLate(), Open() + AssignAdd(), AssignLock(), AssignLate(), Open() INTERNALS @@ -66,22 +66,22 @@ newdl = MakeDosEntry(name, DLT_NONBINDING); if(newdl == NULL) - return DOSFALSE; + return DOSFALSE; s2 = path; while(*s2++) - ; + ; namelen = s2 - path + 1; pathcopy = AllocVec(namelen, MEMF_PUBLIC | MEMF_CLEAR); if(pathcopy == NULL) { - FreeDosEntry(newdl); - SetIoErr(ERROR_NO_FREE_STORE); + FreeDosEntry(newdl); + SetIoErr(ERROR_NO_FREE_STORE); - return DOSFALSE; + return DOSFALSE; } CopyMem(path, pathcopy, namelen); @@ -92,42 +92,42 @@ if(dl == NULL) { - AddDosEntry(newdl); + AddDosEntry(newdl); } else if(dl->dol_Type == DLT_VOLUME || dl->dol_Type == DLT_DEVICE) { - dl = NULL; - FreeVec(newdl->dol_misc.dol_assign.dol_AssignName); - FreeDosEntry(newdl); - SetIoErr(ERROR_OBJECT_EXISTS); + dl = NULL; + FreeVec(newdl->dol_misc.dol_assign.dol_AssignName); + FreeDosEntry(newdl); + SetIoErr(ERROR_OBJECT_EXISTS); - result = DOSFALSE; + result = DOSFALSE; } else { - RemDosEntry(dl); - AddDosEntry(newdl); + RemDosEntry(dl); + AddDosEntry(newdl); } if(dl != NULL) { - UnLock(dl->dol_Lock); - - if(dl->dol_misc.dol_assign.dol_List != NULL) - { - struct AssignList *al, *oal; - - for(al = dl->dol_misc.dol_assign.dol_List; al; ) - { - UnLock(al->al_Lock); - oal = al; - al = al->al_Next; - FreeVec(oal); - } - } - - FreeVec(dl->dol_misc.dol_assign.dol_AssignName); - FreeDosEntry(dl); + UnLock(dl->dol_Lock); + + if(dl->dol_misc.dol_assign.dol_List != NULL) + { + struct AssignList *al, *oal; + + for(al = dl->dol_misc.dol_assign.dol_List; al; ) + { + UnLock(al->al_Lock); + oal = al; + al = al->al_Next; + FreeVec(oal); + } + } + + FreeVec(dl->dol_misc.dol_assign.dol_AssignName); + FreeDosEntry(dl); } UnLockDosList(LDF_ALL | LDF_WRITE); diff --git a/rom/dos/attemptlockdoslist.c b/rom/dos/attemptlockdoslist.c index 1bbfffca23..f3e7badd5e 100644 --- a/rom/dos/attemptlockdoslist.c +++ b/rom/dos/attemptlockdoslist.c @@ -14,26 +14,26 @@ NAME */ #include - AROS_LH1(struct DosList *, AttemptLockDosList, + AROS_LH1(struct DosList *, AttemptLockDosList, /* SYNOPSIS */ - AROS_LHA(ULONG, flags, D1), + AROS_LHA(ULONG, flags, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 111, Dos) + struct DosLibrary *, DOSBase, 111, Dos) /* 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. + 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 + 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. + Handle to the dos list or NULL. This is not a direct pointer + to the first list element but to a pseudo element instead. NOTES @@ -56,51 +56,51 @@ D(bug("AttemptLockDosList: flags = $%lx\n", flags)); if (((flags & (LDF_READ|LDF_WRITE)) != LDF_READ && - (flags & (LDF_READ|LDF_WRITE)) != LDF_WRITE) || - (flags & ~(LDF_READ|LDF_WRITE|LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS|LDF_ENTRY|LDF_DELETE))) - return NULL; + (flags & (LDF_READ|LDF_WRITE)) != LDF_WRITE) || + (flags & ~(LDF_READ|LDF_WRITE|LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS|LDF_ENTRY|LDF_DELETE))) + return NULL; if (flags & LDF_ALL) { - if (flags & LDF_WRITE) - DevSem = AttemptSemaphore(&di->di_DevLock); - else - DevSem = AttemptSemaphoreShared(&di->di_DevLock); - if (!DevSem) - dl = NULL; + if (flags & LDF_WRITE) + DevSem = AttemptSemaphore(&di->di_DevLock); + else + DevSem = AttemptSemaphoreShared(&di->di_DevLock); + if (!DevSem) + dl = NULL; } if (flags & LDF_ENTRY) { - if (flags & LDF_WRITE) - EntrySem = AttemptSemaphore(&di->di_EntryLock); - else - EntrySem = AttemptSemaphoreShared(&di->di_EntryLock); - if (!EntrySem) - dl = NULL; + if (flags & LDF_WRITE) + EntrySem = AttemptSemaphore(&di->di_EntryLock); + else + EntrySem = AttemptSemaphoreShared(&di->di_EntryLock); + if (!EntrySem) + dl = NULL; } if (flags & LDF_DELETE) { - if (flags & LDF_WRITE) - DelSem = AttemptSemaphore(&di->di_DeleteLock); - else - DelSem = AttemptSemaphoreShared(&di->di_DeleteLock); - if (!DelSem) - dl = NULL; + if (flags & LDF_WRITE) + DelSem = AttemptSemaphore(&di->di_DeleteLock); + else + DelSem = AttemptSemaphoreShared(&di->di_DeleteLock); + if (!DelSem) + dl = NULL; } /* This came from MorphOS source code, however looks strange. Commented out but left for reference. if (dl) - Forbid(); */ + Forbid(); */ if (!dl) { - if (DevSem) - ReleaseSemaphore(&di->di_DevLock); - if (EntrySem) - ReleaseSemaphore(&di->di_EntryLock); - if (DelSem) - ReleaseSemaphore(&di->di_DeleteLock); + if (DevSem) + ReleaseSemaphore(&di->di_DevLock); + if (EntrySem) + ReleaseSemaphore(&di->di_EntryLock); + if (DelSem) + ReleaseSemaphore(&di->di_DeleteLock); } D(bug("AttemptLockDosList: result = $%lx\n", dl)); diff --git a/rom/dos/boot.c b/rom/dos/boot.c index 0bcd1bab75..62b9c843e2 100644 --- a/rom/dos/boot.c +++ b/rom/dos/boot.c @@ -45,14 +45,14 @@ static void load_system_configuration(struct DosLibrary *DOSBase) fh = Open("DEVS:system-configuration", MODE_OLDFILE); if (!fh) - return; + return; len = Read(fh, &prefs, sizeof prefs); Close(fh); if (len != sizeof prefs) - return; + return; IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION); if (IntuitionBase) - SetPrefs(&prefs, len, FALSE); + SetPrefs(&prefs, len, FALSE); CloseLibrary(IntuitionBase); } @@ -69,7 +69,7 @@ void __dos_Boot(struct DosLibrary *DOSBase, ULONG BootFlags, UBYTE Flags) BPTR cis = BNULL; /* We have been created as a process by DOS, we should now - try and boot the system. */ + try and boot the system. */ D(bug("[__dos_Boot] generic boot sequence, BootFlags 0x%08X Flags 0x%02X\n", BootFlags, Flags)); @@ -94,16 +94,16 @@ void __dos_Boot(struct DosLibrary *DOSBase, ULONG BootFlags, UBYTE Flags) STRPTR args = ""; BPTR oldin, oldout; - /* - * Argument strings MUST contain terminating LF because of ReadItem() bugs. - * Their absence causes ReadArgs() crash. - */ + /* + * Argument strings MUST contain terminating LF because of ReadItem() bugs. + * Their absence causes ReadArgs() crash. + */ if (BootFlags & BF_NO_COMPOSITION) - args = "NOCOMPOSITION\n"; + args = "NOCOMPOSITION\n"; else if (BootFlags & BF_NO_DISPLAY_DRIVERS) - args = "ONLYCOMPOSITION\n"; + args = "ONLYCOMPOSITION\n"; - D(bug("[__dos_Boot] Running AROSMonDrvs %s\n", args)); + D(bug("[__dos_Boot] Running AROSMonDrvs %s\n", args)); /* RunCommand needs a valid Input() handle * for passing in its arguments. diff --git a/rom/dos/bstr_helper.c b/rom/dos/bstr_helper.c index a699cf669b..a366bd00bc 100644 --- a/rom/dos/bstr_helper.c +++ b/rom/dos/bstr_helper.c @@ -11,13 +11,13 @@ static void BSTR2CINLINE(char *s) { - UBYTE len = s[0]; - memmove(s, s + 1, len); - s[len] = 0; + UBYTE len = s[0]; + memmove(s, s + 1, len); + s[len] = 0; } void fixfib(struct FileInfoBlock *fib) { - BSTR2CINLINE(fib->fib_FileName); - BSTR2CINLINE(fib->fib_Comment); + BSTR2CINLINE(fib->fib_FileName); + BSTR2CINLINE(fib->fib_Comment); } diff --git a/rom/dos/changemode.c b/rom/dos/changemode.c index 81439c202d..68958faff2 100644 --- a/rom/dos/changemode.c +++ b/rom/dos/changemode.c @@ -16,27 +16,27 @@ NAME */ #include - AROS_LH3(BOOL, ChangeMode, + AROS_LH3(BOOL, ChangeMode, /* SYNOPSIS */ - AROS_LHA(ULONG, type, D1), - AROS_LHA(BPTR, object, D2), - AROS_LHA(ULONG, newmode, D3), + AROS_LHA(ULONG, type, D1), + AROS_LHA(BPTR, object, D2), + AROS_LHA(ULONG, newmode, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 75, Dos) + struct DosLibrary *, DOSBase, 75, Dos) /* FUNCTION - Try to change the access mode of a lock or filehandle. + Try to change the access mode of a lock or filehandle. INPUTS - type - CHANGE_FH or CHANGE_LOCK. - object - Filehandle or lock. - newmode - New mode, either SHARED_LOCK or EXCLUSIVE_LOCK. + type - CHANGE_FH or CHANGE_LOCK. + object - Filehandle or lock. + newmode - New mode, either SHARED_LOCK or EXCLUSIVE_LOCK. RESULT - != 0 if all went well, otherwise 0. IoErr() gives additional - information in the latter case. + != 0 if all went well, otherwise 0. IoErr() gives additional + information in the latter case. NOTES @@ -47,8 +47,8 @@ SEE ALSO INTERNALS - Since filehandles and locks are identical under AROS the type - argument is ignored. + Since filehandles and locks are identical under AROS the type + argument is ignored. *****************************************************************************/ { @@ -60,8 +60,8 @@ LONG ret; if (type != CHANGE_LOCK && type != CHANGE_FH) { - SetIoErr(ERROR_BAD_NUMBER); - return FALSE; + SetIoErr(ERROR_BAD_NUMBER); + return FALSE; } D(bug("[ChangeMode] %d %x %d\n", type, fh, newmode)); ret = dopacket3(DOSBase, NULL, type == CHANGE_LOCK ? fl->fl_Task : fh->fh_Type, ACTION_CHANGE_MODE, type, object, newmode); diff --git a/rom/dos/checksignal.c b/rom/dos/checksignal.c index fde1cef907..1ba573c85f 100644 --- a/rom/dos/checksignal.c +++ b/rom/dos/checksignal.c @@ -14,24 +14,24 @@ NAME */ #include - AROS_LH1(LONG, CheckSignal, + AROS_LH1(LONG, CheckSignal, /* SYNOPSIS */ - AROS_LHA(LONG, mask, D1), + AROS_LHA(LONG, mask, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 132, Dos) + struct DosLibrary *, DOSBase, 132, Dos) /* 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. + 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. + mask - The signal mask to check. RESULT - The mask of all signals which were set. + The mask of all signals which were set. NOTES diff --git a/rom/dos/cli.c b/rom/dos/cli.c index 486e767961..434db83df2 100644 --- a/rom/dos/cli.c +++ b/rom/dos/cli.c @@ -16,24 +16,24 @@ NAME */ #include - AROS_LH0(struct CommandLineInterface *, Cli, + AROS_LH0(struct CommandLineInterface *, Cli, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 82, Dos) + struct DosLibrary *, DOSBase, 82, Dos) /* FUNCTION - Returns a pointer to the CLI structure of the current process. + Returns a pointer to the CLI structure of the current process. INPUTS RESULT - Pointer to CLI structure. + Pointer to CLI structure. NOTES - Do not use this function to test if the process was started from - the shell. Check pr_CLI instead. + Do not use this function to test if the process was started from + the shell. Check pr_CLI instead. EXAMPLE diff --git a/rom/dos/cliinit.c b/rom/dos/cliinit.c index 650e70aa56..e22a08eaf9 100644 --- a/rom/dos/cliinit.c +++ b/rom/dos/cliinit.c @@ -28,12 +28,12 @@ static void PRINT_DOSTYPE(ULONG dt) for (i = 0; i < 4; i++) { - unsigned char c = dt >> (24 - i * 8); + unsigned char c = dt >> (24 - i * 8); - if (isprint(c)) - RawPutChar(c); - else - bug("\\%02X", c); + if (isprint(c)) + RawPutChar(c); + else + bug("\\%02X", c); } RawPutChar('\n'); @@ -53,13 +53,13 @@ static long internalBootCliHandler(void); #include #include - AROS_LH1(IPTR, CliInit, + AROS_LH1(IPTR, CliInit, /* SYNOPSIS */ - AROS_LHA(struct DosPacket *, dp, A0), + AROS_LHA(struct DosPacket *, dp, A0), /* LOCATION */ - struct DosLibrary *, DOSBase, 154, Dos) + struct DosLibrary *, DOSBase, 154, Dos) /* FUNCTION @@ -169,7 +169,7 @@ static long internalBootCliHandler(void); return RETURN_OK; /* Make sure we return non-zero error code, 0 == RETURN_OK */ if (Res2 == 0) - Res2 = ERROR_UNKNOWN; + Res2 = ERROR_UNKNOWN; return Res2; @@ -233,7 +233,7 @@ static void internalPatchBootNode(struct FileSysResource *fsr, struct DeviceNode /* If the DosType is 0 and dn_Handler == BNULL, use the default handler */ if (de->de_DosType == 0 && dn->dn_Handler == BNULL) { - D(bug("Dos/CliInit: Neither DosType nor Handler specified, using default filesystem\n")); + D(bug("Dos/CliInit: Neither DosType nor Handler specified, using default filesystem\n")); dn->dn_SegList = defseg; dn->dn_GlobalVec = (BPTR)-1; return; @@ -279,7 +279,7 @@ static struct MsgPort *mountBootNode(struct DeviceNode *dn, struct FileSysResour struct DosList *dl; if ((dn == NULL) || (dn->dn_Name == BNULL)) - return NULL; + return NULL; D(bug("Dos/CliInit: Mounting 0x%p (%b)...\n", dn, dn->dn_Name)); @@ -288,8 +288,8 @@ static struct MsgPort *mountBootNode(struct DeviceNode *dn, struct FileSysResour while ((dl = NextDosEntry(dl, LDF_DEVICES))) { - if (dl == (struct DosList *)dn) - break; + if (dl == (struct DosList *)dn) + break; } UnLockDosList(LDF_DEVICES | LDF_READ); @@ -297,7 +297,7 @@ static struct MsgPort *mountBootNode(struct DeviceNode *dn, struct FileSysResour /* Found in DOS list? Do nothing. */ if (dl) { - return dl->dol_Task; + return dl->dol_Task; } /* Patch it up, if needed */ @@ -305,8 +305,8 @@ static struct MsgPort *mountBootNode(struct DeviceNode *dn, struct FileSysResour if (!dn->dn_Handler && !dn->dn_SegList) { - /* Don't know how to mount? Error... */ - return NULL; + /* Don't know how to mount? Error... */ + return NULL; } if (AddDosEntry((struct DosList *)dn) != DOSFALSE) @@ -314,7 +314,7 @@ static struct MsgPort *mountBootNode(struct DeviceNode *dn, struct FileSysResour /* * Do not check for ANDF_STARTPROC because: * a) On the Amiga ADNF_STARTPROC was not present in KS 1.3 and earlier, there was no deferred mount. - * b) In fact if we have something in ExpansionBase, we for sure want it to be mounted. + * b) In fact if we have something in ExpansionBase, we for sure want it to be mounted. */ D(bug("Dos/CliInit: Added to DOS list, starting up handler... ")); @@ -374,7 +374,7 @@ static BPTR internalBootLock(struct DosLibrary *DOSBase, struct ExpansionBase *E name = AllocVec(name_len + 2, MEMF_ANY); if (name != NULL) { - SIPTR err = 0; + SIPTR err = 0; /* Make the volume name a volume: name */ CopyMem(AROS_BSTR_ADDR(dn->dn_Name), name, name_len); @@ -389,10 +389,10 @@ static BPTR internalBootLock(struct DosLibrary *DOSBase, struct ExpansionBase *E { /* If we have a lock, check the per-platform conditional boot code. */ if (!__dos_IsBootable(DOSBase, lock)) - { - UnLock(lock); - lock = BNULL; - err = ERROR_OBJECT_WRONG_TYPE; /* Something to more or less reflect "This disk is not bootable" */ + { + UnLock(lock); + lock = BNULL; + err = ERROR_OBJECT_WRONG_TYPE; /* Something to more or less reflect "This disk is not bootable" */ } } else @@ -402,7 +402,7 @@ static BPTR internalBootLock(struct DosLibrary *DOSBase, struct ExpansionBase *E if (!lock) { - SIPTR dead; + SIPTR dead; /* Darn. Not bootable. Try to unmount it. */ D(bug("Dos/CliInit: Does not have a bootable filesystem, unmounting...\n")); @@ -411,18 +411,18 @@ static BPTR internalBootLock(struct DosLibrary *DOSBase, struct ExpansionBase *E dead = DoPkt(mp, ACTION_DIE, 0, 0, 0, 0, 0); D(bug("Dos/CliInit: ACTION_DIE returned %ld\n", dead)); - if (dead) - { - /* - * Handlers usually won't remove their DeviceNoces themselves. - * And even if they do (ACTION_DIE is poorly documented), RemDosEntry() - * on an already removed entry is safe due to nature of DOS list. - * What is really prohibited, it's unloading own seglist. Well, resident - * handlers will never do it, they know... - */ - RemDosEntry((struct DosList *)dn); - dn->dn_Task = NULL; - } + if (dead) + { + /* + * Handlers usually won't remove their DeviceNoces themselves. + * And even if they do (ACTION_DIE is poorly documented), RemDosEntry() + * on an already removed entry is safe due to nature of DOS list. + * What is really prohibited, it's unloading own seglist. Well, resident + * handlers will never do it, they know... + */ + RemDosEntry((struct DosList *)dn); + dn->dn_Task = NULL; + } /* DoPkt() clobbered IoErr() */ SetIoErr(err); } @@ -437,7 +437,7 @@ static void AddBootAssign(CONST_STRPTR path, CONST_STRPTR assign, APTR DOSBase) { BPTR lock; if (!(lock = Lock(path, SHARED_LOCK))) - lock = Lock("SYS:", SHARED_LOCK); + lock = Lock("SYS:", SHARED_LOCK); if (lock) AssignLock(assign, lock); } @@ -472,7 +472,7 @@ static long internalBootCliHandler(void) ExpansionBase = (APTR)OpenLibrary("expansion.library", 0); if (!ExpansionBase) - return ERROR_INVALID_RESIDENT_LIBRARY; + return ERROR_INVALID_RESIDENT_LIBRARY; /* It's perfectly fine if this fails. */ fsr = OpenResource("FileSystem.resource"); @@ -483,20 +483,20 @@ static long internalBootCliHandler(void) if (lock == BNULL) { - /* - * We've failed. Inform our parent and exit. - * Immediately after we reply the packet, the parent (Boot Task) can expunge DOSBase. - * This is why we first cleanup, then use internal_ReplyPkt (DOSBase is considered - * invalid). - * Alternatively we could Forbid() before ReplyPkt(), but... Forbid() is so unpolite... - */ - IPTR err = IoErr(); - - CloseLibrary(&ExpansionBase->LibNode); - CloseLibrary(&DOSBase->dl_lib); - - /* Immediately after ReplyPkt() DOSBase can be freed. So Forbid() until we really quit. */ - internal_ReplyPkt(dp, mp, DOSFALSE, err); + /* + * We've failed. Inform our parent and exit. + * Immediately after we reply the packet, the parent (Boot Task) can expunge DOSBase. + * This is why we first cleanup, then use internal_ReplyPkt (DOSBase is considered + * invalid). + * Alternatively we could Forbid() before ReplyPkt(), but... Forbid() is so unpolite... + */ + IPTR err = IoErr(); + + CloseLibrary(&ExpansionBase->LibNode); + CloseLibrary(&DOSBase->dl_lib); + + /* Immediately after ReplyPkt() DOSBase can be freed. So Forbid() until we really quit. */ + internal_ReplyPkt(dp, mp, DOSFALSE, err); return err; } @@ -562,7 +562,7 @@ static long internalBootCliHandler(void) * read mappings for disk-based handlers from file. * This way we could automount e. g. FAT, NTFS, EXT3/2, whatever else, partitions. */ - mountBootNode(bn->bn_DeviceNode, fsr, DOSBase); + mountBootNode(bn->bn_DeviceNode, fsr, DOSBase); } CloseLibrary((APTR)ExpansionBase); diff --git a/rom/dos/cliinitnewcli.c b/rom/dos/cliinitnewcli.c index bb78978a5c..c7966e8a18 100644 --- a/rom/dos/cliinitnewcli.c +++ b/rom/dos/cliinitnewcli.c @@ -15,13 +15,13 @@ #include #include - AROS_LH1(IPTR, CliInitNewcli, + AROS_LH1(IPTR, CliInitNewcli, /* SYNOPSIS */ - AROS_LHA(struct DosPacket *, dp, A0), + AROS_LHA(struct DosPacket *, dp, A0), /* LOCATION */ - struct DosLibrary *, DOSBase, 155, Dos) + struct DosLibrary *, DOSBase, 155, Dos) /* FUNCTION diff --git a/rom/dos/cliinitrun.c b/rom/dos/cliinitrun.c index baf0b93e27..c61d4d51b9 100644 --- a/rom/dos/cliinitrun.c +++ b/rom/dos/cliinitrun.c @@ -14,13 +14,13 @@ #include #include - AROS_LH1(IPTR, CliInitRun, + AROS_LH1(IPTR, CliInitRun, /* SYNOPSIS */ - AROS_LHA(struct DosPacket *, dp, A0), + AROS_LHA(struct DosPacket *, dp, A0), /* LOCATION */ - struct DosLibrary *, DOSBase, 156, Dos) + struct DosLibrary *, DOSBase, 156, Dos) /* FUNCTION diff --git a/rom/dos/close.c b/rom/dos/close.c index 2a4926a2ed..a1b9bd0d8c 100644 --- a/rom/dos/close.c +++ b/rom/dos/close.c @@ -18,24 +18,24 @@ NAME */ #include - AROS_LH1(BOOL, Close, + AROS_LH1(BOOL, Close, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), + AROS_LHA(BPTR, file, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 6, Dos) + struct DosLibrary *, DOSBase, 6, Dos) /* 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. + 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 + file -- filehandle RESULT - 0 if there was an error. != 0 on success. + 0 if there was an error. != 0 on success. NOTES @@ -61,15 +61,15 @@ /* 0 handles are OK */ if(file == BNULL) - return ret; + return ret; /* Func3 == -1: file was already closed. */ if (fh->fh_Func3 == -1) - Alert(AN_FileReclosed); + Alert(AN_FileReclosed); /* If the filehandle has a pending write on it Flush() the buffer. */ if(fh->fh_Flags & FHF_WRITE) - ret = Flush(file); + ret = Flush(file); ret = dopacket1(DOSBase, NULL, fh->fh_Type, ACTION_END, fh->fh_Arg1); diff --git a/rom/dos/comparedates.c b/rom/dos/comparedates.c index fe2c5b7a74..953a8e5fac 100644 --- a/rom/dos/comparedates.c +++ b/rom/dos/comparedates.c @@ -12,27 +12,27 @@ NAME */ #include - AROS_LH2(LONG, CompareDates, + AROS_LH2(LONG, CompareDates, /* SYNOPSIS */ - AROS_LHA(const struct DateStamp *, date1, D1), - AROS_LHA(const struct DateStamp *, date2, D2), + AROS_LHA(const struct DateStamp *, date1, D1), + AROS_LHA(const struct DateStamp *, date2, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 123, Dos) + struct DosLibrary *, DOSBase, 123, Dos) /* FUNCTION - Compares two dates. + Compares two dates. INPUTS - date1, date2 - The two dates to compare. + 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. + < 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() ! + This is NOT the same ordering as strcmp() ! EXAMPLE @@ -51,10 +51,10 @@ if (diff == 0) { - diff = date2->ds_Minute - date1->ds_Minute; + diff = date2->ds_Minute - date1->ds_Minute; - if (diff == 0) - diff = date2->ds_Tick - date1->ds_Tick; + if (diff == 0) + diff = date2->ds_Tick - date1->ds_Tick; } return diff; diff --git a/rom/dos/createdir.c b/rom/dos/createdir.c index 5ac0527a1b..c112e1c929 100644 --- a/rom/dos/createdir.c +++ b/rom/dos/createdir.c @@ -20,24 +20,24 @@ NAME */ #include - AROS_LH1(BPTR, CreateDir, + AROS_LH1(BPTR, CreateDir, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 20, Dos) + struct DosLibrary *, DOSBase, 20, Dos) /* FUNCTION - Creates a new directory under the given name. If all went well, an - exclusive lock on the new diretory is returned. + 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. + 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. + Exclusive lock to the new directory or 0 if it couldn't be created. + IoErr() gives additional information in that case. NOTES @@ -59,8 +59,8 @@ D(bug("[CreateDir] '%s'\n", name)); if (getpacketinfo(DOSBase, name, &phs)) { - lock = (BPTR)dopacket2(DOSBase, NULL, phs.port, ACTION_CREATE_DIR, phs.lock, phs.name); - freepacketinfo(DOSBase, &phs); + lock = (BPTR)dopacket2(DOSBase, NULL, phs.port, ACTION_CREATE_DIR, phs.lock, phs.name); + freepacketinfo(DOSBase, &phs); } return lock; diff --git a/rom/dos/createnewproc.c b/rom/dos/createnewproc.c index 4f89eb161a..5f0a6bd429 100644 --- a/rom/dos/createnewproc.c +++ b/rom/dos/createnewproc.c @@ -41,29 +41,29 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); NAME */ #include - AROS_LH1(struct Process *, CreateNewProc, + AROS_LH1(struct Process *, CreateNewProc, /* SYNOPSIS */ - AROS_LHA(const struct TagItem *, tags, D1), + AROS_LHA(const struct TagItem *, tags, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 83, Dos) + struct DosLibrary *, DOSBase, 83, Dos) /* FUNCTION - Create a new process using the tagitem array. + Create a new process using the tagitem array. INPUTS - tags - information on the new process. + tags - information on the new process. RESULT - Pointer to the new process or NULL on error. + Pointer to the new process or NULL on error. NOTES - It is possible to supply NP_Input, NP_Output and NP_Error tags - with BNULL values. This is equal to NIL: handle, however if NP_Input - is set to BNULL, NP_Arguments tag will not work. Arguments are - passed to the process via input stream, and the stream needs - to be a valid handle for this. This is original AmigaOS(tm) feature. + It is possible to supply NP_Input, NP_Output and NP_Error tags + with BNULL values. This is equal to NIL: handle, however if NP_Input + is set to BNULL, NP_Arguments tag will not work. Arguments are + passed to the process via input stream, and the stream needs + to be a valid handle for this. This is original AmigaOS(tm) feature. EXAMPLE @@ -78,13 +78,13 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); AROS_LIBFUNC_INIT /* Allocated resources */ - struct Process *process = NULL; - BPTR input = 0, output = 0, ces = 0, curdir = 0, homedir = 0, segList, *segArray; - STRPTR stack = NULL, name = NULL, argptr = NULL; - ULONG namesize = 0, argsize = 0; - struct MemList *memlist = NULL; + struct Process *process = NULL; + BPTR input = 0, output = 0, ces = 0, curdir = 0, homedir = 0, segList, *segArray; + STRPTR stack = NULL, name = NULL, argptr = NULL; + ULONG namesize = 0, argsize = 0; + struct MemList *memlist = NULL; struct CommandLineInterface *cli = NULL; - struct Process *me = (struct Process *)FindTask(NULL); + struct Process *me = (struct Process *)FindTask(NULL); ULONG old_sig = 0; APTR entry; @@ -94,32 +94,32 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); struct TagItem defaults[]= { - /* 0 */ { NP_Seglist , 0 }, - /* 1 */ { NP_Entry , (IPTR)NULL }, - /* 2 */ { NP_Input , TAGDATA_NOT_SPECIFIED }, - /* 3 */ { NP_CloseInput , 1 }, - /* 4 */ { NP_Output , TAGDATA_NOT_SPECIFIED }, - /* 5 */ { NP_CloseOutput , 1 }, - /* 6 */ { NP_Error , TAGDATA_NOT_SPECIFIED }, - /* 7 */ { NP_CloseError , 1 }, - /* 8 */ { NP_CurrentDir , TAGDATA_NOT_SPECIFIED }, - /* 9 */ { NP_StackSize , AROS_STACKSIZE }, - /*10 */ { NP_Name , (IPTR)"New Process" }, - /*11 */ { NP_Priority , me->pr_Task.tc_Node.ln_Pri }, - /*12 */ { NP_Arguments , TAGDATA_NOT_SPECIFIED }, - /*13 */ { NP_Cli , 0 }, - /*14 */ { NP_UserData , (IPTR)NULL }, - /*15 */ { NP_ExitCode , (IPTR)NULL }, - /*16 */ { NP_ExitData , (IPTR)NULL }, - /*17 */ { NP_WindowPtr , (IPTR)NULL }, /* Default: default public screen */ - /*18 */ { NP_CopyVars , (IPTR)TRUE }, - /*19 */ { NP_Synchronous , (IPTR)FALSE }, - /*20 */ { NP_FreeSeglist , (IPTR)TRUE }, - /*21 */ { NP_HomeDir , TAGDATA_NOT_SPECIFIED }, + /* 0 */ { NP_Seglist , 0 }, + /* 1 */ { NP_Entry , (IPTR)NULL }, + /* 2 */ { NP_Input , TAGDATA_NOT_SPECIFIED }, + /* 3 */ { NP_CloseInput , 1 }, + /* 4 */ { NP_Output , TAGDATA_NOT_SPECIFIED }, + /* 5 */ { NP_CloseOutput , 1 }, + /* 6 */ { NP_Error , TAGDATA_NOT_SPECIFIED }, + /* 7 */ { NP_CloseError , 1 }, + /* 8 */ { NP_CurrentDir , TAGDATA_NOT_SPECIFIED }, + /* 9 */ { NP_StackSize , AROS_STACKSIZE }, + /*10 */ { NP_Name , (IPTR)"New Process" }, + /*11 */ { NP_Priority , me->pr_Task.tc_Node.ln_Pri }, + /*12 */ { NP_Arguments , TAGDATA_NOT_SPECIFIED }, + /*13 */ { NP_Cli , 0 }, + /*14 */ { NP_UserData , (IPTR)NULL }, + /*15 */ { NP_ExitCode , (IPTR)NULL }, + /*16 */ { NP_ExitData , (IPTR)NULL }, + /*17 */ { NP_WindowPtr , (IPTR)NULL }, /* Default: default public screen */ + /*18 */ { NP_CopyVars , (IPTR)TRUE }, + /*19 */ { NP_Synchronous , (IPTR)FALSE }, + /*20 */ { NP_FreeSeglist , (IPTR)TRUE }, + /*21 */ { NP_HomeDir , TAGDATA_NOT_SPECIFIED }, /*22 */ { NP_Path , TAGDATA_NOT_SPECIFIED }, /* Default: copy path from parent */ /*23 */ { NP_NotifyOnDeath , (IPTR)FALSE }, /*24 */ { NP_ConsoleTask , TAGDATA_NOT_SPECIFIED }, - { TAG_END , 0 } + { TAG_END , 0 } }; /* C has no exceptions. This is a simple replacement. */ @@ -131,18 +131,18 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); /* Inherit the parent process' stacksize if possible */ if (__is_process(me)) { - struct CommandLineInterface *cli = Cli(); + struct CommandLineInterface *cli = Cli(); - if (cli) - { - LONG parentstack = cli->cli_DefaultStack * CLI_DEFAULTSTACK_UNIT; + if (cli) + { + LONG parentstack = cli->cli_DefaultStack * CLI_DEFAULTSTACK_UNIT; - D(bug("[createnewproc] Parent stack: %u (0x%08X)\n", parentstack, parentstack)); - if (parentstack > AROS_STACKSIZE) - { - defaults[9].ti_Data = parentstack; - } - } + D(bug("[createnewproc] Parent stack: %u (0x%08X)\n", parentstack, parentstack)); + if (parentstack > AROS_STACKSIZE) + { + defaults[9].ti_Data = parentstack; + } + } } ApplyTagChanges(defaults, (struct TagItem *)tags); @@ -215,7 +215,7 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); /* We need a minimum stack to handle interrupt contexts */ if (process->pr_StackSize < AROS_STACKSIZE) { - process->pr_StackSize = AROS_STACKSIZE; + process->pr_StackSize = AROS_STACKSIZE; } stack = AllocMem(process->pr_StackSize, MEMF_PUBLIC); @@ -228,26 +228,26 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); /* NP_Arguments */ if (defaults[12].ti_Data != TAGDATA_NOT_SPECIFIED) { - CONST_STRPTR args = (CONST_STRPTR)defaults[12].ti_Data; + CONST_STRPTR args = (CONST_STRPTR)defaults[12].ti_Data; - /* If NULL, then it was provided by the user, - * so use the empty "" arg list - */ - if (args == NULL) - { - args = ""; - } + /* If NULL, then it was provided by the user, + * so use the empty "" arg list + */ + if (args == NULL) + { + args = ""; + } argsize = strlen(args); argptr = (STRPTR)AllocVec(argsize+1, MEMF_PUBLIC); ENOMEM_IF(argptr == NULL); CopyMem(args, argptr, argsize+1); - D(bug("[createnewproc] Arguments \"%s\"\n", argptr)); + D(bug("[createnewproc] Arguments \"%s\"\n", argptr)); } memlist = AllocMem(sizeof(struct MemList) + 2*sizeof(struct MemEntry), - MEMF_ANY); + MEMF_ANY); ENOMEM_IF(memlist == NULL); /* NP_Cli */ @@ -255,32 +255,32 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); { BPTR oldpath = BNULL; - /* Don't forget to pass tags to AllocDosObject() */ - cli = (struct CommandLineInterface *)AllocDosObject(DOS_CLI, (struct TagItem *)tags); - ENOMEM_IF(cli == NULL); + /* Don't forget to pass tags to AllocDosObject() */ + cli = (struct CommandLineInterface *)AllocDosObject(DOS_CLI, (struct TagItem *)tags); + ENOMEM_IF(cli == NULL); - cli->cli_DefaultStack = (process->pr_StackSize + CLI_DEFAULTSTACK_UNIT - 1) / CLI_DEFAULTSTACK_UNIT; + cli->cli_DefaultStack = (process->pr_StackSize + CLI_DEFAULTSTACK_UNIT - 1) / CLI_DEFAULTSTACK_UNIT; - if (__is_process(me)) - { - struct CommandLineInterface *oldcli = Cli(); + if (__is_process(me)) + { + struct CommandLineInterface *oldcli = Cli(); - if (oldcli != NULL) - { - LONG oldlen = AROS_BSTR_strlen(oldcli->cli_Prompt); - LONG newlen = GetTagData(ADO_PromptLen, 255, tags); + if (oldcli != NULL) + { + LONG oldlen = AROS_BSTR_strlen(oldcli->cli_Prompt); + LONG newlen = GetTagData(ADO_PromptLen, 255, tags); - oldpath = oldcli->cli_CommandDir; + oldpath = oldcli->cli_CommandDir; - CopyMem(BADDR(oldcli->cli_Prompt), BADDR(cli->cli_Prompt), (newlencli_Prompt), BADDR(cli->cli_Prompt), (newlenpr_CLI = MKBADDR(cli); - addprocesstoroot(process, DOSBase); - } + process->pr_CLI = MKBADDR(cli); + addprocesstoroot(process, DOSBase); + } - if (defaults[22].ti_Data != TAGDATA_NOT_SPECIFIED) + if (defaults[22].ti_Data != TAGDATA_NOT_SPECIFIED) { cli->cli_CommandDir = (BPTR) defaults[22].ti_Data; } @@ -294,65 +294,65 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); if (defaults[2].ti_Data == TAGDATA_NOT_SPECIFIED) { - input = OpenNIL(DOSBase); - ERROR_IF(!input); + input = OpenNIL(DOSBase); + ERROR_IF(!input); - defaults[2].ti_Data = (IPTR)input; + defaults[2].ti_Data = (IPTR)input; } /* NP_Output */ if (defaults[4].ti_Data == TAGDATA_NOT_SPECIFIED) { - output = OpenNIL(DOSBase); - ERROR_IF(!output); + output = OpenNIL(DOSBase); + ERROR_IF(!output); - defaults[4].ti_Data = (IPTR)output; + defaults[4].ti_Data = (IPTR)output; } /* NP_Error */ if (defaults[6].ti_Data == TAGDATA_NOT_SPECIFIED) { - ces = OpenNIL(DOSBase); - ERROR_IF(!ces); + ces = OpenNIL(DOSBase); + ERROR_IF(!ces); - defaults[6].ti_Data = (IPTR)ces; + defaults[6].ti_Data = (IPTR)ces; } /* NP_CurrentDir */ if (defaults[8].ti_Data == TAGDATA_NOT_SPECIFIED) { - if (__is_process(me) && me->pr_CurrentDir) - { - curdir = Lock("", SHARED_LOCK); - ERROR_IF(!curdir); + if (__is_process(me) && me->pr_CurrentDir) + { + curdir = Lock("", SHARED_LOCK); + ERROR_IF(!curdir); - defaults[8].ti_Data = (IPTR)curdir; - } - else - { - defaults[8].ti_Data = 0; - } + defaults[8].ti_Data = (IPTR)curdir; + } + else + { + defaults[8].ti_Data = 0; + } } /* NP_HomeDir */ if (defaults[21].ti_Data == TAGDATA_NOT_SPECIFIED) { - defaults[21].ti_Data = 0; + defaults[21].ti_Data = 0; - if (__is_process(me)) - { - if (me->pr_HomeDir) - { - homedir = DupLock(me->pr_HomeDir); - ERROR_IF(!homedir); + if (__is_process(me)) + { + if (me->pr_HomeDir) + { + homedir = DupLock(me->pr_HomeDir); + ERROR_IF(!homedir); - defaults[21].ti_Data = (IPTR)homedir; - } - } + defaults[21].ti_Data = (IPTR)homedir; + } + } } CopyMem((APTR)defaults[10].ti_Data, name, namesize); @@ -398,13 +398,13 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); /* Inherit pr_ConsoleTask and pr_FileSystemTask from parent */ if (defaults[24].ti_Data != TAGDATA_NOT_SPECIFIED) - process->pr_ConsoleTask = (struct MsgPort*)defaults[24].ti_Data; + process->pr_ConsoleTask = (struct MsgPort*)defaults[24].ti_Data; else if (__is_process(me)) - process->pr_ConsoleTask = me->pr_ConsoleTask; + process->pr_ConsoleTask = me->pr_ConsoleTask; if (__is_process(me)) - process->pr_FileSystemTask = me->pr_FileSystemTask; + process->pr_FileSystemTask = me->pr_FileSystemTask; else - process->pr_FileSystemTask = DOSBase->dl_Root->rn_BootProc; + process->pr_FileSystemTask = DOSBase->dl_Root->rn_BootProc; D(bug("[createnewproc] pr_ConsoleTask = %p\n", process->pr_ConsoleTask)); D(bug("[createnewproc] pr_FileSystemTask = %p\n", process->pr_FileSystemTask)); @@ -417,23 +417,23 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); process->pr_WindowPtr = (struct Window *)defaults[17].ti_Data; process->pr_HomeDir = (BPTR)defaults[21].ti_Data; process->pr_Flags = (defaults[3].ti_Data ? PRF_CLOSEINPUT : 0) | - (defaults[5].ti_Data ? PRF_CLOSEOUTPUT : 0) | - (defaults[7].ti_Data ? PRF_CLOSEERROR : 0) | - (defaults[8].ti_Data ? PRF_FREECURRDIR : 0) | - (defaults[13].ti_Data ? PRF_FREECLI : 0) | - (defaults[19].ti_Data ? PRF_SYNCHRONOUS : 0) | - (defaults[20].ti_Data ? PRF_FREESEGLIST : 0) | - (defaults[23].ti_Data ? PRF_NOTIFYONDEATH : 0) | - (argptr ? PRF_FREEARGS : 0); + (defaults[5].ti_Data ? PRF_CLOSEOUTPUT : 0) | + (defaults[7].ti_Data ? PRF_CLOSEERROR : 0) | + (defaults[8].ti_Data ? PRF_FREECURRDIR : 0) | + (defaults[13].ti_Data ? PRF_FREECLI : 0) | + (defaults[19].ti_Data ? PRF_SYNCHRONOUS : 0) | + (defaults[20].ti_Data ? PRF_FREESEGLIST : 0) | + (defaults[23].ti_Data ? PRF_NOTIFYONDEATH : 0) | + (argptr ? PRF_FREEARGS : 0); process->pr_ExitCode = (APTR)defaults[15].ti_Data; process->pr_ExitData = defaults[16].ti_Data; process->pr_Arguments = argptr; if ((BOOL)defaults[18].ti_Data) /* NP_CopyVars */ { - BOOL res = copyVars(me, process, DOSBase); + BOOL res = copyVars(me, process, DOSBase); - ENOMEM_IF(res == FALSE); + ENOMEM_IF(res == FALSE); } process->pr_ShellPrivate = 0; @@ -442,7 +442,7 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); if (defaults[19].ti_Data) { me->pr_Flags |= PRF_WAITINGFORCHILD; - + old_sig = SetSignal(0L, SIGF_SINGLE) & SIGF_SINGLE; } @@ -466,9 +466,9 @@ void internal_ChildFree(APTR tid, struct DosLibrary * DOSBase); D(bug("[createnewproc] Creating SegArray %p, segList=%p\n", segArray, BADDR(segList))); segArray[0] = (BPTR)SEGARRAY_LENGTH; - segArray[1] = (BPTR)-1; /* 'system' segment */ - segArray[2] = (BPTR)-2; /* 'dosbase' segment */ - segArray[3] = segList; /* Program segment */ + segArray[1] = (BPTR)-1; /* 'system' segment */ + segArray[2] = (BPTR)-2; /* 'dosbase' segment */ + segArray[3] = segList; /* Program segment */ process->pr_SegList = MKBADDR(segArray); @@ -536,7 +536,7 @@ enomem: if (__is_process(me)) { - SetIoErr(ERROR_NO_FREE_STORE); + SetIoErr(ERROR_NO_FREE_STORE); } freeLocalVars(process, DOSBase); @@ -547,59 +547,59 @@ error: if (cli != NULL) { - FreeDosObject(DOS_CLI, cli); + FreeDosObject(DOS_CLI, cli); } if (homedir != BNULL) { - UnLock(homedir); + UnLock(homedir); } if (curdir != BNULL) { - UnLock(curdir); + UnLock(curdir); } if (output != BNULL) { - Close(output); + Close(output); } if (input != BNULL) { - Close(input); + Close(input); } if (ces != BNULL) { - Close(ces); + Close(ces); } if (argptr != NULL) { - FreeVec(argptr); + FreeVec(argptr); } if (memlist != NULL) { - FreeMem(memlist, sizeof(struct MemList) + 2*sizeof(struct MemEntry)); + FreeMem(memlist, sizeof(struct MemList) + 2*sizeof(struct MemEntry)); } if (name != NULL) { - FreeMem(name, namesize); + FreeMem(name, namesize); } if (stack != NULL) { - FreeMem(stack, process->pr_StackSize); + FreeMem(stack, process->pr_StackSize); } if (process != NULL) { - FreeMem(process, sizeof(struct Process)); + FreeMem(process, sizeof(struct Process)); - process = NULL; + process = NULL; } end: @@ -618,13 +618,13 @@ static void freeLocalVars(struct Process *process, struct DosLibrary *DOSBase) struct Node *tempNode; ForeachNodeSafe(&process->pr_LocalVars, - varNode, tempNode) + varNode, tempNode) { - D(bug("Freeing variable %s with value %s at %p\n", - varNode->lv_Node.ln_Name, varNode->lv_Value, varNode)); - FreeMem(varNode->lv_Value, varNode->lv_Len); - Remove((struct Node *)varNode); - FreeVec(varNode); + D(bug("Freeing variable %s with value %s at %p\n", + varNode->lv_Node.ln_Name, varNode->lv_Value, varNode)); + FreeMem(varNode->lv_Value, varNode->lv_Len); + Remove((struct Node *)varNode); + FreeVec(varNode); } } @@ -677,44 +677,44 @@ BOOL copyVars(struct Process *fromProcess, struct Process *toProcess, struct Dos /* We must have variables to copy... */ if (__is_process(fromProcess)) { - struct LocalVar *varNode; - struct LocalVar *newVar; - - /* We use the same strategy as in the ***Var() functions */ - ForeachNode(&fromProcess->pr_LocalVars, varNode) - { - LONG copyLength = strlen(varNode->lv_Node.ln_Name) + 1 + - sizeof(struct LocalVar); - - newVar = (struct LocalVar *)AllocVec(copyLength, - MEMF_PUBLIC | MEMF_CLEAR); - if (newVar == NULL) - return FALSE; - - CopyMem(varNode, newVar, copyLength); - newVar->lv_Node.ln_Name = (char *)newVar + - sizeof(struct LocalVar); - D(bug("Variable with name %s copied.\n", - newVar->lv_Node.ln_Name)); - + struct LocalVar *varNode; + struct LocalVar *newVar; + + /* We use the same strategy as in the ***Var() functions */ + ForeachNode(&fromProcess->pr_LocalVars, varNode) + { + LONG copyLength = strlen(varNode->lv_Node.ln_Name) + 1 + + sizeof(struct LocalVar); + + newVar = (struct LocalVar *)AllocVec(copyLength, + MEMF_PUBLIC | MEMF_CLEAR); + if (newVar == NULL) + return FALSE; + + CopyMem(varNode, newVar, copyLength); + newVar->lv_Node.ln_Name = (char *)newVar + + sizeof(struct LocalVar); + D(bug("Variable with name %s copied.\n", + newVar->lv_Node.ln_Name)); + if (varNode->lv_Len) { - newVar->lv_Value = AllocMem(varNode->lv_Len, MEMF_PUBLIC); - - if (newVar->lv_Value == NULL) - { - /* Free variable node before shutting down */ - FreeVec(newVar); - - return FALSE; - } - + newVar->lv_Value = AllocMem(varNode->lv_Len, MEMF_PUBLIC); + + if (newVar->lv_Value == NULL) + { + /* Free variable node before shutting down */ + FreeVec(newVar); + + return FALSE; + } + CopyMem(varNode->lv_Value, newVar->lv_Value, varNode->lv_Len); - } + } - AddTail((struct List *)&toProcess->pr_LocalVars, - (struct Node *)newVar); - } + AddTail((struct List *)&toProcess->pr_LocalVars, + (struct Node *)newVar); + } } return TRUE; @@ -755,31 +755,31 @@ static void DosEntry(void) if (me->pr_ExitCode != NULL) { /* - The Ralph Babel's guru book says that pr_ExitCode - is passed the process return code in D0 and pr_ExitData in D1, - but the Matt Dillon's DICE C implementation of vfork shows that - those parameters are passed also on the stack. - */ + The Ralph Babel's guru book says that pr_ExitCode + is passed the process return code in D0 and pr_ExitData in D1, + but the Matt Dillon's DICE C implementation of vfork shows that + those parameters are passed also on the stack. + */ #ifdef __mc68000 - asm volatile ( - "move.l %0, %%d0\n" - "move.l %1, %%d1\n" - "move.l %2, %%a0\n" - "move.l %%d0, %%sp@-\n" - "move.l %%d1, %%sp@-\n" - "jsr (%%a0)\n" - "addq.l #8, %%sp\n" - : /* No return values */ - : "g" (result), "g" (me->pr_ExitData), "g" (me->pr_ExitCode) - : "d0", "d1", "a0", "a1" - ); + asm volatile ( + "move.l %0, %%d0\n" + "move.l %1, %%d1\n" + "move.l %2, %%a0\n" + "move.l %%d0, %%sp@-\n" + "move.l %%d1, %%sp@-\n" + "jsr (%%a0)\n" + "addq.l #8, %%sp\n" + : /* No return values */ + : "g" (result), "g" (me->pr_ExitData), "g" (me->pr_ExitCode) + : "d0", "d1", "a0", "a1" + ); #else - /* - The AROS macros for functions with register parameters don't - support both register and stack parameters at once, so we use - the stack only on non-m68k. This oughta be fixed somehow. + /* + The AROS macros for functions with register parameters don't + support both register and stack parameters at once, so we use + the stack only on non-m68k. This oughta be fixed somehow. */ - me->pr_ExitCode(result, me->pr_ExitData); + me->pr_ExitCode(result, me->pr_ExitData); #endif } @@ -809,38 +809,38 @@ static void DosEntry(void) if (me->pr_Flags & PRF_CLOSEINPUT) { - Close(cis); + Close(cis); } D(bug("Closing output stream\n")); if (me->pr_Flags & PRF_CLOSEOUTPUT) { - Close(cos); + Close(cos); } D(bug("Closing error stream\n")); if (me->pr_Flags & PRF_CLOSEERROR) { - Close(ces); + Close(ces); } D(bug("Freeing arguments\n")); if (me->pr_Flags & PRF_FREEARGS) { - FreeVec(me->pr_Arguments); + FreeVec(me->pr_Arguments); } D(bug("Unloading segment\n")); if (me->pr_Flags & PRF_FREESEGLIST) { - BPTR *segarray = BADDR(me->pr_SegList); + BPTR *segarray = BADDR(me->pr_SegList); - if (segarray && segarray[3]) - UnLoadSeg(segarray[3]); + if (segarray && segarray[3]) + UnLoadSeg(segarray[3]); } if (me->pr_SegList) @@ -855,7 +855,7 @@ static void DosEntry(void) if (me->pr_Flags & PRF_FREECURRDIR) { - UnLock(me->pr_CurrentDir); + UnLock(me->pr_CurrentDir); } D(bug("Unlocking home dir\n")); @@ -865,9 +865,9 @@ static void DosEntry(void) if (me->pr_Flags & PRF_FREECLI) { - FreeDosObject(DOS_CLI, BADDR(me->pr_CLI)); - removefromrootnode(me, DOSBase); - me->pr_CLI = BNULL; + FreeDosObject(DOS_CLI, BADDR(me->pr_CLI)); + removefromrootnode(me, DOSBase); + me->pr_CLI = BNULL; } /* Synchronous completion must be before diff --git a/rom/dos/createproc.c b/rom/dos/createproc.c dissimilarity index 72% index 3511125157..ddb1ed075b 100644 --- a/rom/dos/createproc.c +++ b/rom/dos/createproc.c @@ -1,124 +1,124 @@ -/* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Create a new process (in an old way). - Lang: English -*/ - -#include "dos_intern.h" -#include -#include - -/***************************************************************************** - - NAME */ -#include - - AROS_LH4(struct MsgPort *, CreateProc, - -/* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(LONG, pri, D2), - AROS_LHA(BPTR, segList, D3), - AROS_LHA(LONG, stackSize, D4), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 23, Dos) - -/* 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 - - EXAMPLE - - BUGS - - SEE ALSO - CreateNewProc(), LoadSeg(), UnLoadSeg() - - INTERNALS - Basically passes this call to CreateNewProc(). - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - struct Process *pr; /* The process to create */ - struct Process *parent = (struct Process *)FindTask(NULL); - APTR windowPtr = NULL; - - /* If the caller is a process, inherit its window pointer */ - if (__is_process(parent)) - { - windowPtr = parent->pr_WindowPtr; - } - - { - /* Don't forget to find out some extra defaults here */ - struct TagItem procTags[] = - { - { NP_Seglist , (IPTR)segList }, - { NP_FreeSeglist , FALSE }, - { NP_StackSize , stackSize }, - { NP_Name , (IPTR)name }, - { NP_Priority , pri }, - { NP_WindowPtr , (IPTR)windowPtr }, - /* These arguments are necessary, for - * AOS 3.x compatability. Specifically, - * CreateProc() must *not* break Forbid() - * locking. - */ - { NP_CurrentDir , 0 }, - { NP_HomeDir , 0 }, - { NP_Input , 0 }, - { NP_Output , 0 }, - { NP_CloseInput , FALSE }, - { NP_CloseOutput , FALSE }, - { TAG_DONE , 0 } - }; - - if ((pr = CreateNewProc(procTags))) - { - return (struct MsgPort *)&pr->pr_MsgPort; - } - else - { - return NULL; - } - } - - AROS_LIBFUNC_EXIT -} /* CreateProc */ +/* + Copyright © 1995-2011, The AROS Development Team. All rights reserved. + $Id$ + + Desc: Create a new process (in an old way). + Lang: English +*/ + +#include "dos_intern.h" +#include +#include + +/***************************************************************************** + + NAME */ +#include + + AROS_LH4(struct MsgPort *, CreateProc, + +/* SYNOPSIS */ + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(LONG, pri, D2), + AROS_LHA(BPTR, segList, D3), + AROS_LHA(LONG, stackSize, D4), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 23, Dos) + +/* 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 + + EXAMPLE + + BUGS + + SEE ALSO + CreateNewProc(), LoadSeg(), UnLoadSeg() + + INTERNALS + Basically passes this call to CreateNewProc(). + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + struct Process *pr; /* The process to create */ + struct Process *parent = (struct Process *)FindTask(NULL); + APTR windowPtr = NULL; + + /* If the caller is a process, inherit its window pointer */ + if (__is_process(parent)) + { + windowPtr = parent->pr_WindowPtr; + } + + { + /* Don't forget to find out some extra defaults here */ + struct TagItem procTags[] = + { + { NP_Seglist , (IPTR)segList }, + { NP_FreeSeglist , FALSE }, + { NP_StackSize , stackSize }, + { NP_Name , (IPTR)name }, + { NP_Priority , pri }, + { NP_WindowPtr , (IPTR)windowPtr }, + /* These arguments are necessary, for + * AOS 3.x compatability. Specifically, + * CreateProc() must *not* break Forbid() + * locking. + */ + { NP_CurrentDir , 0 }, + { NP_HomeDir , 0 }, + { NP_Input , 0 }, + { NP_Output , 0 }, + { NP_CloseInput , FALSE }, + { NP_CloseOutput , FALSE }, + { TAG_DONE , 0 } + }; + + if ((pr = CreateNewProc(procTags))) + { + return (struct MsgPort *)&pr->pr_MsgPort; + } + else + { + return NULL; + } + } + + AROS_LIBFUNC_EXIT +} /* CreateProc */ diff --git a/rom/dos/currentdir.c b/rom/dos/currentdir.c index d2d93749ec..285dc10276 100644 --- a/rom/dos/currentdir.c +++ b/rom/dos/currentdir.c @@ -14,23 +14,23 @@ NAME */ #include - AROS_LH1(BPTR, CurrentDir, + AROS_LH1(BPTR, CurrentDir, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 21, Dos) + struct DosLibrary *, DOSBase, 21, Dos) /* FUNCTION - Sets a new directory as the current directory. Returns the old one. - 0 is valid in both cases and represents the boot filesystem. + 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. + lock - Lock for the new current directory. RESULT - Old current directory. + Old current directory. NOTES diff --git a/rom/dos/datestamp.c b/rom/dos/datestamp.c index 6b045133f9..ea46c54951 100644 --- a/rom/dos/datestamp.c +++ b/rom/dos/datestamp.c @@ -11,40 +11,40 @@ #define SECONDS_PER_DAY (60UL * 60 * 24) #define SECONDS_PER_MINUTE (60UL) -#define uSEC_PER_SEC (1000000UL) -#define TICKS_PER_SEC (50UL) -#define uSEC_PER_TICK (uSEC_PER_SEC / TICKS_PER_SEC) +#define uSEC_PER_SEC (1000000UL) +#define TICKS_PER_SEC (50UL) +#define uSEC_PER_TICK (uSEC_PER_SEC / TICKS_PER_SEC) /***************************************************************************** NAME */ #include - AROS_LH1(struct DateStamp *, DateStamp, + AROS_LH1(struct DateStamp *, DateStamp, /* SYNOPSIS */ - AROS_LHA(struct DateStamp *, date, D1), + AROS_LHA(struct DateStamp *, date, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 32, Dos) + struct DosLibrary *, DOSBase, 32, Dos) /* FUNCTION - Fills the structure with the current time. Time is measured from - Jan 1, 1978. + Fills the structure with the current time. Time is measured from + Jan 1, 1978. INPUTS - date - The structure to fill. + 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. + 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. + The original function could only return even multiples of 50 ticks. EXAMPLE @@ -67,7 +67,7 @@ date->ds_Minute = tv.tv_secs / SECONDS_PER_MINUTE; tv.tv_secs %= SECONDS_PER_MINUTE; date->ds_Tick = (tv.tv_micro + tv.tv_secs * uSEC_PER_SEC) / - uSEC_PER_TICK; + uSEC_PER_TICK; return date; AROS_LIBFUNC_EXIT diff --git a/rom/dos/delay.c b/rom/dos/delay.c index a55a97621e..4233d0dc9b 100644 --- a/rom/dos/delay.c +++ b/rom/dos/delay.c @@ -18,13 +18,13 @@ NAME */ #include - AROS_LH1(void, Delay, + AROS_LH1(void, Delay, /* SYNOPSIS */ - AROS_LHA(ULONG, timeout, D1), + AROS_LHA(ULONG, timeout, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 33, Dos) + struct DosLibrary *, DOSBase, 33, Dos) /* FUNCTION Waits for at least the time specified as timeout. @@ -49,14 +49,14 @@ AROS_LIBFUNC_INIT struct timerequest timerio; - struct MsgPort timermp; + struct MsgPort timermp; memset(&timermp, 0, sizeof(timermp)); timermp.mp_Node.ln_Type = NT_MSGPORT; - timermp.mp_Flags = PA_SIGNAL; - timermp.mp_SigBit = SIGB_SINGLE; - timermp.mp_SigTask = FindTask(NULL); + timermp.mp_Flags = PA_SIGNAL; + timermp.mp_SigBit = SIGB_SINGLE; + timermp.mp_SigTask = FindTask(NULL); NEWLIST(&timermp.mp_MsgList); /* clone timerequest in DOSBase */ @@ -64,12 +64,12 @@ timerio.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG; timerio.tr_node.io_Message.mn_ReplyPort = &timermp; - timerio.tr_node.io_Command = TR_ADDREQUEST; + timerio.tr_node.io_Command = TR_ADDREQUEST; timerio.tr_time.tv_secs = timeout / TICKS_PER_SECOND; - timerio.tr_time.tv_micro = 1000000UL / TICKS_PER_SECOND * (timeout % TICKS_PER_SECOND); + timerio.tr_time.tv_micro = 1000000UL / TICKS_PER_SECOND * (timeout % TICKS_PER_SECOND); SetSignal(0, SIGF_SINGLE); - + DoIO(&timerio.tr_node); AROS_LIBFUNC_EXIT diff --git a/rom/dos/deletefile.c b/rom/dos/deletefile.c index eee211fd3c..889a364ec4 100644 --- a/rom/dos/deletefile.c +++ b/rom/dos/deletefile.c @@ -19,24 +19,24 @@ NAME */ #include - AROS_LH1(BOOL, DeleteFile, + AROS_LH1(BOOL, DeleteFile, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 12, Dos) + struct DosLibrary *, DOSBase, 12, Dos) /* FUNCTION - Tries to delete a file or directory by a given name. - May fail if the file is in use or protected from deletion. + 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. + name - NUL terminated name. RESULT - != 0 if the file is gone, 0 if is still there. - IoErr() gives additional information in that case. + != 0 if the file is gone, 0 if is still there. + IoErr() gives additional information in that case. NOTES @@ -58,8 +58,8 @@ D(bug("[DeleteFile] '%s'\n", name)); if (getpacketinfo(DOSBase, name, &phs)) { - status = dopacket2(DOSBase, NULL, phs.port, ACTION_DELETE_OBJECT, phs.lock, phs.name); - freepacketinfo(DOSBase, &phs); + status = dopacket2(DOSBase, NULL, phs.port, ACTION_DELETE_OBJECT, phs.lock, phs.name); + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/deviceproc.c b/rom/dos/deviceproc.c index 29609cdcc5..f61eaa1e65 100644 --- a/rom/dos/deviceproc.c +++ b/rom/dos/deviceproc.c @@ -12,43 +12,43 @@ NAME */ #include - AROS_LH1(struct MsgPort *, DeviceProc, + AROS_LH1(struct MsgPort *, DeviceProc, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 29, Dos) + struct DosLibrary *, DOSBase, 29, Dos) /* FUNCTION - DeviceProc() is an obsolete function that returns the - MsgPort responsible for a DOS device. + DeviceProc() is an obsolete function that returns the + MsgPort responsible for a DOS device. - DeviceProc() will fail if you ask for the MsgPort 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). + DeviceProc() will fail if you ask for the MsgPort 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, INCLUDING the ':'. + name - The name of the DOS device, INCLUDING the ':'. RESULT - Either a pointer to the MsgPort, or NULL. + Either a pointer to the MsgPort, or NULL. NOTES - You should really use GetDeviceProc(), as that function - returns a more useful structure (DevProc), that will - persist until FreeDeviceProc() is called on it. + You should really use GetDeviceProc(), as that function + returns a more useful structure (DevProc), that will + persist until FreeDeviceProc() is called on it. EXAMPLE BUGS - Does not support late- and non-bound assigns, or multiple - path assigns very well. + Does not support late- and non-bound assigns, or multiple + path assigns very well. SEE ALSO - GetDeviceProc(), FreeDeviceProc() + GetDeviceProc(), FreeDeviceProc() INTERNALS @@ -68,14 +68,14 @@ * can't return it as there's no cleanup function, so we have to error */ if (dvp->dvp_Flags & DVPF_UNLOCK) { - res = NULL; - err = ERROR_DEVICE_NOT_MOUNTED; + res = NULL; + err = ERROR_DEVICE_NOT_MOUNTED; } else { /* all good. get the lock and device */ - res = dvp->dvp_Port; - err = (SIPTR)dvp->dvp_Lock; + res = dvp->dvp_Port; + err = (SIPTR)dvp->dvp_Lock; } FreeDeviceProc(dvp); diff --git a/rom/dos/displayerror.c b/rom/dos/displayerror.c index 56bd85d232..c0b9448dbd 100644 --- a/rom/dos/displayerror.c +++ b/rom/dos/displayerror.c @@ -21,29 +21,29 @@ NAME */ #include - AROS_LH3(LONG, DisplayError, + AROS_LH3(LONG, DisplayError, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, formatStr, A0), - AROS_LHA(ULONG , flags , D0), - AROS_LHA(APTR , args , A1), + AROS_LHA(CONST_STRPTR, formatStr, A0), + AROS_LHA(ULONG , flags , D0), + AROS_LHA(APTR , args , A1), /* LOCATION */ - struct DosLibrary *, DOSBase, 81, Dos) + struct DosLibrary *, DOSBase, 81, Dos) /* FUNCTION - Displays an error message to and gets response from a user. + 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' + formatStr -- printf-style formatted string + flags -- arguments to EasyRequestArgs() + args -- arguments to 'formatStr' RESULT - Nothing + Nothing NOTES - This is a PRIVATE dos function. + This is a PRIVATE dos function. EXAMPLE @@ -52,8 +52,8 @@ SEE ALSO INTERNALS - The purpose of this function is to put up a requester when an error - has occurred that is connected to the filesystem. + The purpose of this function is to put up a requester when an error + has occurred that is connected to the filesystem. *****************************************************************************/ { @@ -61,19 +61,19 @@ struct IntuitionBase *IntuitionBase = NULL; struct Process *me = (struct Process *)FindTask(NULL); - struct Window *window; /* The window to put the requester in */ - char gadTexts[128]; + struct Window *window; /* The window to put the requester in */ + char gadTexts[128]; char *gtPtr = (char *)gadTexts; - ULONG idcmp = flags; - ULONG res; + ULONG idcmp = flags; + ULONG res; struct EasyStruct es = { - sizeof(struct EasyStruct), - 0, /* flags */ - DosGetString(MSG_STRING_REQUESTTITLE), /* "System Requester" */ - (STRPTR)formatStr, - gadTexts /* "Retry|Cancel" */ + sizeof(struct EasyStruct), + 0, /* flags */ + DosGetString(MSG_STRING_REQUESTTITLE), /* "System Requester" */ + (STRPTR)formatStr, + gadTexts /* "Retry|Cancel" */ }; ASSERT_VALID_PROCESS(me); @@ -82,21 +82,21 @@ /* Supress requesters? */ if ((IPTR)window == (IPTR)-1L) { - return 1; + return 1; } if (DOSBase->dl_IntuitionBase == NULL) { - DOSBase->dl_IntuitionBase = OpenLibrary("intuition.library", 37L); + DOSBase->dl_IntuitionBase = OpenLibrary("intuition.library", 37L); } if (DOSBase->dl_IntuitionBase == NULL) { - return 1; + return 1; } else { - IntuitionBase = (struct IntuitionBase *)DOSBase->dl_IntuitionBase; + IntuitionBase = (struct IntuitionBase *)DOSBase->dl_IntuitionBase; } /* Create localised gadget texts */ @@ -108,11 +108,11 @@ if (res == 0) { - return 1; + return 1; } else { - return 0; + return 0; } AROS_LIBFUNC_EXIT diff --git a/rom/dos/dopkt.c b/rom/dos/dopkt.c index e95457cf23..2b99d55f74 100644 --- a/rom/dos/dopkt.c +++ b/rom/dos/dopkt.c @@ -15,19 +15,19 @@ NAME */ #include - AROS_LH7I(SIPTR, DoPkt, + AROS_LH7I(SIPTR, DoPkt, /* SYNOPSIS */ - AROS_LHA(struct MsgPort *, port, D1), - AROS_LHA(LONG , action, D2), - AROS_LHA(SIPTR , arg1, D3), - AROS_LHA(SIPTR , arg2, D4), - AROS_LHA(SIPTR , arg3, D5), - AROS_LHA(SIPTR , arg4, D6), - AROS_LHA(SIPTR , arg5, D7), + AROS_LHA(struct MsgPort *, port, D1), + AROS_LHA(LONG , action, D2), + AROS_LHA(SIPTR , arg1, D3), + AROS_LHA(SIPTR , arg2, D4), + AROS_LHA(SIPTR , arg3, D5), + AROS_LHA(SIPTR , arg4, D6), + AROS_LHA(SIPTR , arg5, D7), /* LOCATION */ - struct DosLibrary *, DOSBase, 40, Dos) + struct DosLibrary *, DOSBase, 40, Dos) /* FUNCTION @@ -75,36 +75,36 @@ SIPTR dopacket(SIPTR *res2, struct MsgPort *port, LONG action, SIPTR arg1, SIPTR if (port == NULL) { - /* NIL: */ - D(bug("null port\n")); - return TRUE; + /* NIL: */ + D(bug("null port\n")); + return TRUE; } /* First I create a regular dos packet */ dp = allocdospacket(); if (NULL == dp) - return FALSE; + return FALSE; if (__is_process(me)) - replyPort = &me->pr_MsgPort; + replyPort = &me->pr_MsgPort; else { - /* - * Make sure that tasks can use DoPkt(). - * This is needed, for example, by Dos/Init() - * when creating the initial Shell. - */ - replyPort = CreateMsgPort(); - - if (NULL == replyPort) - { - freedospacket(dp); - return FALSE; - } + /* + * Make sure that tasks can use DoPkt(). + * This is needed, for example, by Dos/Init() + * when creating the initial Shell. + */ + replyPort = CreateMsgPort(); + + if (NULL == replyPort) + { + freedospacket(dp); + return FALSE; + } } D(bug("dp=0x%p act=%d port=0x%p reply=0x%p proc=%d 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx '%s'\n", - dp, action, port, replyPort, __is_process(me), arg1, arg2, arg3, arg4, arg5, arg6, arg7, me->pr_Task.tc_Node.ln_Name)); + dp, action, port, replyPort, __is_process(me), arg1, arg2, arg3, arg4, arg5, arg6, arg7, me->pr_Task.tc_Node.ln_Name)); dp->dp_Type = action; dp->dp_Arg1 = arg1; dp->dp_Arg2 = arg2; @@ -120,18 +120,18 @@ SIPTR dopacket(SIPTR *res2, struct MsgPort *port, LONG action, SIPTR arg1, SIPTR /* Did we get different packet back? System is in unstable state. */ if (internal_WaitPkt(replyPort) != dp) - Alert(AN_AsyncPkt); + Alert(AN_AsyncPkt); D(bug("res1=%x res2=%x\n", dp->dp_Res1, dp->dp_Res2)); res = dp->dp_Res1; if (res2) - *res2 = dp->dp_Res2; + *res2 = dp->dp_Res2; if (__is_process(me)) - me->pr_Result2 = dp->dp_Res2; + me->pr_Result2 = dp->dp_Res2; else - DeleteMsgPort(replyPort); + DeleteMsgPort(replyPort); freedospacket(dp); return res; diff --git a/rom/dos/dos_init.c b/rom/dos/dos_init.c index a2479e07b4..0185a60944 100644 --- a/rom/dos/dos_init.c +++ b/rom/dos/dos_init.c @@ -39,7 +39,7 @@ const struct Resident Dos_resident = RTC_MATCHWORD, (struct Resident *)&Dos_resident, (APTR)&LIBEND, - 0, /* We don't autoinit */ + 0, /* We don't autoinit */ VERSION_NUMBER, NT_LIBRARY, RESIDENTPRI, @@ -77,45 +77,45 @@ static void init_fs(struct DosLibrary *DOSBase) CloseLibrary(PartitionBase); } - /* - * Set dl_Root->rn_FileHandlerSegment to the AFS handler, - * if it's been loaded. Otherwise, use the first handler - * on the FileSystemResource list that has fse_PatchFlags - * set to mark it with a valid SegList - */ - if ((fsr = OpenResource("FileSystem.resource"))) - { + /* + * Set dl_Root->rn_FileHandlerSegment to the AFS handler, + * if it's been loaded. Otherwise, use the first handler + * on the FileSystemResource list that has fse_PatchFlags + * set to mark it with a valid SegList + */ + if ((fsr = OpenResource("FileSystem.resource"))) + { struct FileSysEntry *fse; - BPTR defseg = BNULL; - const ULONG DosMagic = 0x444f5301; /* DOS\001 */ - - ForeachNode(&fsr->fsr_FileSysEntries, fse) - { - if ((fse->fse_PatchFlags & FSEF_SEGLIST) && fse->fse_SegList) - { - /* We prefer DOS\001 */ + BPTR defseg = BNULL; + const ULONG DosMagic = 0x444f5301; /* DOS\001 */ + + ForeachNode(&fsr->fsr_FileSysEntries, fse) + { + if ((fse->fse_PatchFlags & FSEF_SEGLIST) && fse->fse_SegList) + { + /* We prefer DOS\001 */ if (fse->fse_DosType == DosMagic) - { - defseg = fse->fse_SegList; - break; - } - /* This will remember the first defined seglist */ - if (!defseg) - defseg = fse->fse_SegList; - } - } + { + defseg = fse->fse_SegList; + break; + } + /* This will remember the first defined seglist */ + if (!defseg) + defseg = fse->fse_SegList; + } + } DOSBase->dl_Root->rn_FileHandlerSegment = defseg; /* Add all that have both Handler and SegList defined to the Resident list */ ForeachNode(&fsr->fsr_FileSysEntries, fse) { - if ((fse->fse_PatchFlags & FSEF_HANDLER) && - (fse->fse_PatchFlags & FSEF_SEGLIST) && - (fse->fse_Handler != BNULL) && - (fse->fse_SegList != BNULL)) - { - D(bug("[DosInit] Adding \"%b\" (%p) at %p to the resident list\n", - fse->fse_Handler, BADDR(fse->fse_Handler), BADDR(fse->fse_SegList))); - AddSegment(AROS_BSTR_ADDR(fse->fse_Handler), fse->fse_SegList, CMD_SYSTEM); + if ((fse->fse_PatchFlags & FSEF_HANDLER) && + (fse->fse_PatchFlags & FSEF_SEGLIST) && + (fse->fse_Handler != BNULL) && + (fse->fse_SegList != BNULL)) + { + D(bug("[DosInit] Adding \"%b\" (%p) at %p to the resident list\n", + fse->fse_Handler, BADDR(fse->fse_Handler), BADDR(fse->fse_SegList))); + AddSegment(AROS_BSTR_ADDR(fse->fse_Handler), fse->fse_SegList, CMD_SYSTEM); } } } @@ -150,113 +150,113 @@ AROS_UFH3S(struct DosLibrary *, DosInit, if (!DOSBase) { - IPTR *taskarray; - struct DosInfo *dosinfo; - - D(bug("[DosInit] Creating dos.library...\n")); - - DOSBase = (struct DosLibrary *)MakeLibrary(GM_UNIQUENAME(FuncTable), NULL, NULL, sizeof(struct IntDosBase), BNULL); - if (!DOSBase) - return NULL; - - /* Initialize our header */ - DOSBase->dl_lib.lib_Node.ln_Name = MOD_NAME_STRING; - DOSBase->dl_lib.lib_Node.ln_Type = NT_LIBRARY; - DOSBase->dl_lib.lib_Node.ln_Pri = RESIDENTPRI; - DOSBase->dl_lib.lib_Version = VERSION_NUMBER; - DOSBase->dl_lib.lib_Revision = REVISION_NUMBER; - DOSBase->dl_lib.lib_IdString = (char *)&version[6]; - DOSBase->dl_lib.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED; - - /* - * These two are allocated together with DOSBase, for reduced fragmentation. - * Structure pointed to by dl_Errors is intentionally read-write - who knows... - */ - DOSBase->dl_Root = &((struct IntDosBase *)DOSBase)->rootNode; - DOSBase->dl_Errors = &((struct IntDosBase *)DOSBase)->errors; - - DOSBase->dl_Errors->estr_Nums = (LONG *)err_Numbers; - DOSBase->dl_Errors->estr_Strings = (STRPTR)err_Strings; - - /* Init the RootNode structure */ - dosinfo = AllocMem(sizeof(struct DosInfo), MEMF_PUBLIC|MEMF_CLEAR); - if (!dosinfo) - { - DosExpunge(DOSBase); - return NULL; - } - - DOSBase->dl_Root->rn_Info = MKBADDR(dosinfo); - - taskarray = AllocMem(sizeof(IPTR) + sizeof(APTR) * 20, MEMF_CLEAR); - if (!taskarray) - { - DosExpunge(DOSBase); - return NULL; - } - - taskarray[0] = 20; - DOSBase->dl_Root->rn_TaskArray = MKBADDR(taskarray); - - NEWLIST((struct List *)&DOSBase->dl_Root->rn_CliList); - InitSemaphore(&DOSBase->dl_Root->rn_RootLock); - - InitSemaphore(&dosinfo->di_DevLock); - InitSemaphore(&dosinfo->di_EntryLock); - InitSemaphore(&dosinfo->di_DeleteLock); - - /* Initialize for Stricmp */ - DOSBase->dl_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY); - if (!DOSBase->dl_UtilityBase) - { - DosExpunge(DOSBase); - return NULL; - } - - /* Initialize for the fools that illegally used this field */ - DOSBase->dl_IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION); - - /* - * iaint: - * I know this is bad, but I also know that the timer.device - * will never go away during the life of dos.library. I also - * don't intend to make any I/O calls using this. - * - * I also know that timer.device does exist in the device list - * at this point in time. - * - * I can't allocate a timerequest/MsgPort pair here anyway, - * because I need a separate one for each caller to Delay(). - * However, CreateIORequest() will fail if MsgPort == NULL, so we - * supply some dummy value. - */ - DOSBase->dl_TimeReq = CreateIORequest((APTR)0xC0DEBAD0, sizeof(struct timerequest)); - if (!DOSBase->dl_TimeReq) - { - DosExpunge(DOSBase); - return NULL; - } - - if (OpenDevice("timer.device", UNIT_VBLANK, &DOSBase->dl_TimeReq->tr_node, 0)) - { - DeleteIORequest(DOSBase->dl_TimeReq); - DOSBase->dl_TimeReq = NULL; - DosExpunge(DOSBase); - return NULL; - } - - /* Call platform-specific init code (if any) */ - if (!set_call_libfuncs(SETNAME(INITLIB), 1, 1, DOSBase)) - { - DosExpunge(DOSBase); - return NULL; - } - - /* debug.library is optional, so don't check result */ - DebugBase = OpenLibrary("debug.library", 0); - - /* Initialization finished */ - AddLibrary(&DOSBase->dl_lib); + IPTR *taskarray; + struct DosInfo *dosinfo; + + D(bug("[DosInit] Creating dos.library...\n")); + + DOSBase = (struct DosLibrary *)MakeLibrary(GM_UNIQUENAME(FuncTable), NULL, NULL, sizeof(struct IntDosBase), BNULL); + if (!DOSBase) + return NULL; + + /* Initialize our header */ + DOSBase->dl_lib.lib_Node.ln_Name = MOD_NAME_STRING; + DOSBase->dl_lib.lib_Node.ln_Type = NT_LIBRARY; + DOSBase->dl_lib.lib_Node.ln_Pri = RESIDENTPRI; + DOSBase->dl_lib.lib_Version = VERSION_NUMBER; + DOSBase->dl_lib.lib_Revision = REVISION_NUMBER; + DOSBase->dl_lib.lib_IdString = (char *)&version[6]; + DOSBase->dl_lib.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED; + + /* + * These two are allocated together with DOSBase, for reduced fragmentation. + * Structure pointed to by dl_Errors is intentionally read-write - who knows... + */ + DOSBase->dl_Root = &((struct IntDosBase *)DOSBase)->rootNode; + DOSBase->dl_Errors = &((struct IntDosBase *)DOSBase)->errors; + + DOSBase->dl_Errors->estr_Nums = (LONG *)err_Numbers; + DOSBase->dl_Errors->estr_Strings = (STRPTR)err_Strings; + + /* Init the RootNode structure */ + dosinfo = AllocMem(sizeof(struct DosInfo), MEMF_PUBLIC|MEMF_CLEAR); + if (!dosinfo) + { + DosExpunge(DOSBase); + return NULL; + } + + DOSBase->dl_Root->rn_Info = MKBADDR(dosinfo); + + taskarray = AllocMem(sizeof(IPTR) + sizeof(APTR) * 20, MEMF_CLEAR); + if (!taskarray) + { + DosExpunge(DOSBase); + return NULL; + } + + taskarray[0] = 20; + DOSBase->dl_Root->rn_TaskArray = MKBADDR(taskarray); + + NEWLIST((struct List *)&DOSBase->dl_Root->rn_CliList); + InitSemaphore(&DOSBase->dl_Root->rn_RootLock); + + InitSemaphore(&dosinfo->di_DevLock); + InitSemaphore(&dosinfo->di_EntryLock); + InitSemaphore(&dosinfo->di_DeleteLock); + + /* Initialize for Stricmp */ + DOSBase->dl_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY); + if (!DOSBase->dl_UtilityBase) + { + DosExpunge(DOSBase); + return NULL; + } + + /* Initialize for the fools that illegally used this field */ + DOSBase->dl_IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION); + + /* + * iaint: + * I know this is bad, but I also know that the timer.device + * will never go away during the life of dos.library. I also + * don't intend to make any I/O calls using this. + * + * I also know that timer.device does exist in the device list + * at this point in time. + * + * I can't allocate a timerequest/MsgPort pair here anyway, + * because I need a separate one for each caller to Delay(). + * However, CreateIORequest() will fail if MsgPort == NULL, so we + * supply some dummy value. + */ + DOSBase->dl_TimeReq = CreateIORequest((APTR)0xC0DEBAD0, sizeof(struct timerequest)); + if (!DOSBase->dl_TimeReq) + { + DosExpunge(DOSBase); + return NULL; + } + + if (OpenDevice("timer.device", UNIT_VBLANK, &DOSBase->dl_TimeReq->tr_node, 0)) + { + DeleteIORequest(DOSBase->dl_TimeReq); + DOSBase->dl_TimeReq = NULL; + DosExpunge(DOSBase); + return NULL; + } + + /* Call platform-specific init code (if any) */ + if (!set_call_libfuncs(SETNAME(INITLIB), 1, 1, DOSBase)) + { + DosExpunge(DOSBase); + return NULL; + } + + /* debug.library is optional, so don't check result */ + DebugBase = OpenLibrary("debug.library", 0); + + /* Initialization finished */ + AddLibrary(&DOSBase->dl_lib); init_fs(DOSBase); } @@ -264,13 +264,13 @@ AROS_UFH3S(struct DosLibrary *, DosInit, /* Try to boot */ if (CliInit(NULL) == RETURN_OK) { - /* - * We now restart the multitasking - this is done - * automatically by RemTask() when it switches. - */ - RemTask(NULL); + /* + * We now restart the multitasking - this is done + * automatically by RemTask() when it switches. + */ + RemTask(NULL); - /* We really really shouldn't ever get to this line. */ + /* We really really shouldn't ever get to this line. */ } DosExpunge(DOSBase); @@ -305,19 +305,19 @@ static void DosExpunge(struct DosLibrary *DOSBase) if (DOSBase->dl_lib.lib_OpenCnt) { - /* - * Someone is holding us... Perhaps some handler started subprocess - * which didn't quit. Who knows... - */ - D(bug("[DosInit] Open count is %d, can't expunge\n")); - return; + /* + * Someone is holding us... Perhaps some handler started subprocess + * which didn't quit. Who knows... + */ + D(bug("[DosInit] Open count is %d, can't expunge\n")); + return; } /* Call platform-specific expunge code (if any) */ if (!set_call_libfuncs(SETNAME(EXPUNGELIB), -1, 1, DOSBase)) { - D(bug("[DosInit] Platform-dependent code failed to expunge\n")); - return; + D(bug("[DosInit] Platform-dependent code failed to expunge\n")); + return; } /* Close some libraries */ @@ -328,19 +328,19 @@ static void DosExpunge(struct DosLibrary *DOSBase) /* Free the timer device */ if (DOSBase->dl_TimeReq) { - CloseDevice(&DOSBase->dl_TimeReq->tr_node); - DeleteIORequest(DOSBase->dl_TimeReq); + CloseDevice(&DOSBase->dl_TimeReq->tr_node); + DeleteIORequest(DOSBase->dl_TimeReq); } if (dinfo) { - /* Remove all segments */ - for (seg = BADDR(dinfo->di_ResList); seg != NULL; seg = stmp) - { + /* Remove all segments */ + for (seg = BADDR(dinfo->di_ResList); seg != NULL; seg = stmp) + { stmp = BADDR(seg->seg_Next); FreeVec(seg); - } - FreeMem(dinfo, sizeof(*dinfo)); + } + FreeMem(dinfo, sizeof(*dinfo)); } /* Free memory */ @@ -348,11 +348,11 @@ static void DosExpunge(struct DosLibrary *DOSBase) if (DOSBase->dl_lib.lib_Node.ln_Succ) { - /* - * A fresh DOSBase after creation is filled with NULLs. - * ln_Succ will be set to something only after AddLibrary(). - */ - Remove(&DOSBase->dl_lib.lib_Node); + /* + * A fresh DOSBase after creation is filled with NULLs. + * ln_Succ will be set to something only after AddLibrary(). + */ + Remove(&DOSBase->dl_lib.lib_Node); } FreeMem((char *)DOSBase - DOSBase->dl_lib.lib_NegSize, DOSBase->dl_lib.lib_NegSize + DOSBase->dl_lib.lib_PosSize); diff --git a/rom/dos/dos_intern.h b/rom/dos/dos_intern.h index 4c56fa9ac2..9bd280cff8 100644 --- a/rom/dos/dos_intern.h +++ b/rom/dos/dos_intern.h @@ -103,10 +103,10 @@ void internal_ReplyPkt(struct DosPacket *dp, struct MsgPort *replyPort, SIPTR re #define dopacket5(base, res2, port, action, arg1, arg2, arg3, arg4, arg5) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), (SIPTR)(arg4), (SIPTR)(arg5), 0, 0) #define dopacket4(base, res2, port, action, arg1, arg2, arg3, arg4) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), (SIPTR)(arg4), 0, 0, 0) -#define dopacket3(base, res2, port, action, arg1, arg2, arg3) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), 0, 0, 0, 0) -#define dopacket2(base, res2, port, action, arg1, arg2) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), 0, 0, 0, 0, 0) -#define dopacket1(base, res2, port, action, arg1) dopacket(res2, port, action, (SIPTR)(arg1), 0, 0, 0, 0, 0, 0) -#define dopacket0(base, res2, port, action) dopacket(res2, port, action, 0, 0, 0, 0, 0, 0, 0) +#define dopacket3(base, res2, port, action, arg1, arg2, arg3) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), 0, 0, 0, 0) +#define dopacket2(base, res2, port, action, arg1, arg2) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), 0, 0, 0, 0, 0) +#define dopacket1(base, res2, port, action, arg1) dopacket(res2, port, action, (SIPTR)(arg1), 0, 0, 0, 0, 0, 0) +#define dopacket0(base, res2, port, action) dopacket(res2, port, action, 0, 0, 0, 0, 0, 0, 0) #ifdef __mc68000 extern void BCPL_Fixup(struct Process *me); @@ -132,7 +132,7 @@ BPTR internal_CopyPath(BPTR boldpath, struct DosLibrary * DOSBase); /* Pattern matching function used by MatchPattern() and MatchPatternNoCase() */ BOOL patternMatch(CONST_STRPTR pat, CONST_STRPTR str, BOOL useCase, - struct DosLibrary *DOSBase); + struct DosLibrary *DOSBase); /* Pattern parsing function used by ParsePattern() and ParsePatternNoCase() */ LONG patternParse(CONST_STRPTR Source, STRPTR Dest, LONG DestLength, @@ -154,7 +154,7 @@ LONG InternalFlush( struct FileHandle *fh, struct DosLibrary *DOSBase ); struct AChain *Match_AllocAChain(LONG extrasize, struct DosLibrary *DOSBase); void Match_FreeAChain(struct AChain *ac, struct DosLibrary *DOSBase); LONG Match_BuildAChainList(CONST_STRPTR pattern, struct AnchorPath *ap, - struct AChain **retac, struct DosLibrary *DOSBase); + struct AChain **retac, struct DosLibrary *DOSBase); LONG Match_MakeResult(struct AnchorPath *ap, struct DosLibrary *DOSBase); void addprocesstoroot(struct Process * , struct DosLibrary *); @@ -175,60 +175,60 @@ struct markerarray }; #define PUSH(t,p,s) \ -{ \ +{ \ if(macnt==128) \ - { \ - if(macur->next==NULL) \ - { \ - macur->next=AllocMem(sizeof(struct markerarray),MEMF_ANY); \ - if(macur->next==NULL) \ - ERROR(ERROR_NO_FREE_STORE); \ - macur->next->prev=macur; \ - } \ - macur=macur->next; \ - macnt=0; \ - } \ + { \ + if(macur->next==NULL) \ + { \ + macur->next=AllocMem(sizeof(struct markerarray),MEMF_ANY); \ + if(macur->next==NULL) \ + ERROR(ERROR_NO_FREE_STORE); \ + macur->next->prev=macur; \ + } \ + macur=macur->next; \ + macnt=0; \ + } \ macur->marker[macnt].type=(t); \ macur->marker[macnt].pat=(p); \ macur->marker[macnt].str=(s); \ - macnt++; \ + macnt++; \ } #define POP(t,p,s) \ -{ \ - macnt--; \ +{ \ + macnt--; \ if(macnt<0) \ - { \ - macnt=127; \ - macur=macur->prev; \ - if(macur==NULL) \ - ERROR(0); \ - } \ + { \ + macnt=127; \ + macur=macur->prev; \ + if(macur==NULL) \ + ERROR(0); \ + } \ (t)=macur->marker[macnt].type; \ (p)=macur->marker[macnt].pat; \ (s)=macur->marker[macnt].str; \ } -#define MP_ESCAPE 0x81 /* Before characters in [0x81;0x8a] */ -#define MP_MULT 0x82 /* _#(_a) */ -#define MP_MULT_END 0x83 /* #(a_)_ */ -#define MP_NOT 0x84 /* _~(_a) */ -#define MP_NOT_END 0x85 /* ~(a_)_ */ -#define MP_OR 0x86 /* _(_a|b) */ -#define MP_OR_NEXT 0x87 /* (a_|_b) */ -#define MP_OR_END 0x88 /* (a|b_)_ */ -#define MP_SINGLE 0x89 /* ? */ -#define MP_ALL 0x8a /* #? or * */ -#define MP_SET 0x8b /* _[_ad-g] */ -#define MP_NOT_SET 0x8c /* _[~_ad-g] */ -#define MP_DASH 0x8d /* [ad_-g_] */ -#define MP_SET_END 0x8e /* [ad-g_]_ */ +#define MP_ESCAPE 0x81 /* Before characters in [0x81;0x8a] */ +#define MP_MULT 0x82 /* _#(_a) */ +#define MP_MULT_END 0x83 /* #(a_)_ */ +#define MP_NOT 0x84 /* _~(_a) */ +#define MP_NOT_END 0x85 /* ~(a_)_ */ +#define MP_OR 0x86 /* _(_a|b) */ +#define MP_OR_NEXT 0x87 /* (a_|_b) */ +#define MP_OR_END 0x88 /* (a|b_)_ */ +#define MP_SINGLE 0x89 /* ? */ +#define MP_ALL 0x8a /* #? or * */ +#define MP_SET 0x8b /* _[_ad-g] */ +#define MP_NOT_SET 0x8c /* _[~_ad-g] */ +#define MP_DASH 0x8d /* [ad_-g_] */ +#define MP_SET_END 0x8e /* [ad-g_]_ */ /* Whether MatchFirst/MatchNext/MatchEnd in case of the base AChain should just take the currentdir lock pointer, or make a real duplicate with DupLock() */ -#define MATCHFUNCS_NO_DUPLOCK 0 +#define MATCHFUNCS_NO_DUPLOCK 0 #define __is_task(task) (((struct Task *)task)->tc_Node.ln_Type == NT_TASK) #define __is_process(task) (((struct Task *)task)->tc_Node.ln_Type == NT_PROCESS) @@ -245,7 +245,7 @@ struct debug_segnode struct MinNode node; UBYTE name[200]; BPTR seglist; - IPTR start_address; // start address of loaded executable segment + IPTR start_address; // start address of loaded executable segment struct MinList seginfos; }; @@ -271,7 +271,7 @@ LONG FWriteChars(BPTR file, CONST UBYTE* buffer, ULONG length, struct DosLibrary #define CMPBSTR(x, y) Stricmp(BADDR(x), BADDR(y)) #define CMPNICBSTR(x, y, n) Strnicmp(x, BADDR(y), n) -#define BSTR2C(s) ((STRPTR)BADDR(s)) +#define BSTR2C(s) ((STRPTR)BADDR(s)) #define FreeCSTR(s) #else @@ -285,10 +285,10 @@ char *BSTR2C(BSTR); #endif #ifdef AROS_FAST_BSTR -#define C2BSTR(x) ((char *)(x)) -#define FREEC2BSTR(x) do { } while (0) -#define CMPCBSTR(a,b) strcmp(a,b) -#define CMPICBSTR(a,b) Stricmp(a,b) +#define C2BSTR(x) ((char *)(x)) +#define FREEC2BSTR(x) do { } while (0) +#define CMPCBSTR(a,b) strcmp(a,b) +#define CMPICBSTR(a,b) Stricmp(a,b) #else BSTR C2BSTR(CONST_STRPTR); #define FREEC2BSTR(bstr) FreeVec(BADDR(bstr)) @@ -300,10 +300,10 @@ void fixfib(struct FileInfoBlock*); struct PacketHelperStruct { - BSTR name; - struct MsgPort *port; - BPTR lock; - struct DevProc *dp; + BSTR name; + struct MsgPort *port; + BPTR lock; + struct DevProc *dp; }; BOOL getpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR, struct PacketHelperStruct*); @@ -311,10 +311,10 @@ BOOL getdevpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR devname, CONST_ST void freepacketinfo(struct DosLibrary *DOSBase, struct PacketHelperStruct*); #define ASSERT_VALID_FILELOCK(lock) do { \ - struct FileLock *fl = BADDR(lock); \ - if (fl && fl->fl_Access != SHARED_LOCK && fl->fl_Access != EXCLUSIVE_LOCK) { \ - bug("%s() called with a bogus FileLock! Lock=%x FL=%x Access %d %s/%s/%d\n", __FUNCTION__, lock, fl, fl->fl_Access, __FILE__,__FUNCTION__,__LINE__); \ - } \ + struct FileLock *fl = BADDR(lock); \ + if (fl && fl->fl_Access != SHARED_LOCK && fl->fl_Access != EXCLUSIVE_LOCK) { \ + bug("%s() called with a bogus FileLock! Lock=%x FL=%x Access %d %s/%s/%d\n", __FUNCTION__, lock, fl, fl->fl_Access, __FILE__,__FUNCTION__,__LINE__); \ + } \ } while (0); /* Shell utilities */ diff --git a/rom/dos/dosgetstring.c b/rom/dos/dosgetstring.c index bef8ce1b0d..9d13c288f6 100644 --- a/rom/dos/dosgetstring.c +++ b/rom/dos/dosgetstring.c @@ -13,31 +13,31 @@ NAME */ #include - AROS_LH1(STRPTR, DosGetString, + AROS_LH1(STRPTR, DosGetString, /* SYNOPSIS */ - AROS_LHA(LONG, stringNum, D1), + AROS_LHA(LONG, stringNum, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 163, Dos) + struct DosLibrary *, DOSBase, 163, Dos) /* FUNCTION - Internal DOS function, will return the string corresponding to - the number stringNum. + Internal DOS function, will return the string corresponding to + the number stringNum. INPUTS - stringNum - The number of the string you want. + stringNum - The number of the string you want. RESULT - A pointer to a string, or NULL if no string could be found with - a matching number. + A pointer to a string, or NULL if no string could be found with + a matching number. NOTES - Error strings will ALWAYS be less than 80 characters, and should - ideally be less than 60 characters. + Error strings will ALWAYS be less than 80 characters, and should + ideally be less than 60 characters. - This is a private function, whose the only purpose is to be patched - by locale.library. + This is a private function, whose the only purpose is to be patched + by locale.library. EXAMPLE @@ -46,7 +46,7 @@ SEE ALSO INTERNALS - This is dosPrivate5() + This is dosPrivate5() ******************************************************************************/ { @@ -57,19 +57,19 @@ do { - LONG n = p[0]; - LONG m = p[1]; + LONG n = p[0]; + LONG m = p[1]; - while (n <= m) - { - if (n == stringNum) - return q + 1; + while (n <= m) + { + if (n == stringNum) + return q + 1; - q += q[0] + 1; - ++n; - } + q += q[0] + 1; + ++n; + } - p += 2; + p += 2; } while (p[0] != 0); diff --git a/rom/dos/duplock.c b/rom/dos/duplock.c index 6ed952522b..576c36c386 100644 --- a/rom/dos/duplock.c +++ b/rom/dos/duplock.c @@ -15,24 +15,24 @@ NAME */ #include - AROS_LH1(BPTR, DupLock, + AROS_LH1(BPTR, DupLock, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 16, Dos) + struct DosLibrary *, DOSBase, 16, Dos) /* FUNCTION - Clone a lock on a file or directory. This will only work on shared - locks. + Clone a lock on a file or directory. This will only work on shared + locks. INPUTS - lock - Old lock. + lock - Old lock. RESULT - The new lock or NULL in case of an error. IoErr() will give additional - information in that case. + The new lock or NULL in case of an error. IoErr() will give additional + information in that case. NOTES @@ -52,7 +52,7 @@ BPTR ret; if (lock == BNULL) - return BNULL; + return BNULL; ret = (BPTR)dopacket1(DOSBase, NULL, fl->fl_Task, ACTION_COPY_DIR, lock); D(bug("[DupLock] %x -> %x\n", fl, BADDR(ret))); return ret; diff --git a/rom/dos/duplockfromfh.c b/rom/dos/duplockfromfh.c index e68abe8a89..544d4db569 100644 --- a/rom/dos/duplockfromfh.c +++ b/rom/dos/duplockfromfh.c @@ -15,24 +15,24 @@ NAME */ #include - AROS_LH1(BPTR, DupLockFromFH, + AROS_LH1(BPTR, DupLockFromFH, /* SYNOPSIS */ - AROS_LHA(BPTR, handle, D1), + AROS_LHA(BPTR, handle, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 62, Dos) + struct DosLibrary *, DOSBase, 62, Dos) /* FUNCTION - Clone a lock on a file or directory. This will only work on shared - locks. + Clone a lock on a file or directory. This will only work on shared + locks. INPUTS - lock - Old lock. + lock - Old lock. RESULT - The new lock or NULL in case of an error. IoErr() will give additional - information in that case. + The new lock or NULL in case of an error. IoErr() will give additional + information in that case. NOTES diff --git a/rom/dos/endnotify.c b/rom/dos/endnotify.c index ac5a46ed7e..057b313cf0 100644 --- a/rom/dos/endnotify.c +++ b/rom/dos/endnotify.c @@ -21,13 +21,13 @@ #include - AROS_LH1(void, EndNotify, + AROS_LH1(void, EndNotify, /* SYNOPSIS */ - AROS_LHA(struct NotifyRequest *, notify, D1), + AROS_LHA(struct NotifyRequest *, notify, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 149, Dos) + struct DosLibrary *, DOSBase, 149, Dos) /* FUNCTION @@ -74,36 +74,36 @@ /* if the filesystem has outstanding messages, they need to be replied */ if ((notify->nr_Flags & NRF_SEND_MESSAGE) && - ((notify->nr_Flags & NRF_WAIT_REPLY) || notify->nr_MsgCount > 0)) + ((notify->nr_Flags & NRF_WAIT_REPLY) || notify->nr_MsgCount > 0)) { - struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port; - struct NotifyMessage *nm, *tmp; + struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port; + struct NotifyMessage *nm, *tmp; - notify->nr_Flags &= ~NRF_MAGIC; + notify->nr_Flags &= ~NRF_MAGIC; /* protect access to the message list */ - Disable(); + Disable(); /* loop over the messages */ - ForeachNodeSafe(&port->mp_MsgList, nm, tmp) { + ForeachNodeSafe(&port->mp_MsgList, nm, tmp) { /* if its one of our notify messages */ - if (nm->nm_Class == NOTIFY_CLASS && - nm->nm_Code == NOTIFY_CODE && - nm->nm_NReq == notify) { + if (nm->nm_Class == NOTIFY_CLASS && + nm->nm_Code == NOTIFY_CODE && + nm->nm_NReq == notify) { /* remove and reply */ - Remove((struct Node *) nm); - ReplyMsg((struct Message *) nm); + Remove((struct Node *) nm); + ReplyMsg((struct Message *) nm); /* decrement the count. bail early if we've done them all */ notify->nr_MsgCount--; if (notify->nr_MsgCount == 0) break; - } - } + } + } /* unlock the list */ - Enable(); + Enable(); } AROS_LIBFUNC_EXIT diff --git a/rom/dos/errorreport.c b/rom/dos/errorreport.c index 47bff1c389..1d2d71ec8b 100644 --- a/rom/dos/errorreport.c +++ b/rom/dos/errorreport.c @@ -22,21 +22,21 @@ NAME */ #include - AROS_LH4(BOOL, ErrorReport, + AROS_LH4(BOOL, ErrorReport, /* SYNOPSIS */ - AROS_LHA(LONG , code , D1), - AROS_LHA(LONG , type , D2), - AROS_LHA(IPTR , arg1 , D3), - AROS_LHA(struct MsgPort *, device, D4), + AROS_LHA(LONG , code , D1), + AROS_LHA(LONG , type , D2), + AROS_LHA(IPTR , arg1 , D3), + AROS_LHA(struct MsgPort *, device, D4), /* LOCATION */ - struct DosLibrary *, DOSBase, 80, Dos) + struct DosLibrary *, DOSBase, 80, Dos) /* FUNCTION Displays a requester with Retry/Cancel buttons for an error. IoErr() is set to "code". - + INPUTS code -- The error to put up the requester for @@ -44,8 +44,8 @@ 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 + 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!) @@ -53,7 +53,7 @@ RESULT DOSFALSE - user has selected "Retry" DOSTRUE - user has selected "Cancel" or code wasn't understood or - pr_WindowPtr is -1 or if an attempt to open the requester fails. + pr_WindowPtr is -1 or if an attempt to open the requester fails. NOTES @@ -174,7 +174,7 @@ msgport = ((struct FileHandle *) BADDR(arg1))->fh_Type; dl = (struct DeviceList*)BADDR(dopacket1(DOSBase, NULL, msgport, ACTION_CURRENT_VOLUME, ((struct FileHandle *) BADDR(arg1))->fh_Arg1)); if (dl) - volname = (char*)BADDR(dl->dl_Name) + 1; + volname = (char*)BADDR(dl->dl_Name) + 1; break; case REPORT_TASK: @@ -186,21 +186,21 @@ { struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, 0); if (!fib) - return DOSTRUE; + return DOSTRUE; /* if they provided a lock, just use it */ if (arg1 != (IPTR)NULL) { - msgport = ((struct FileLock *) BADDR(arg1))->fl_Task; + msgport = ((struct FileLock *) BADDR(arg1))->fl_Task; } else { - msgport = device; + msgport = device; } if (dopacket2(DOSBase, NULL, msgport, ACTION_EXAMINE_OBJECT, arg1, (SIPTR)MKBADDR(fib))) { - fixfib(fib); - strncpy(buf, fib->fib_FileName, sizeof (buf) - 1); - buf[sizeof(buf) - 1] = 0; + fixfib(fib); + strncpy(buf, fib->fib_FileName, sizeof (buf) - 1); + buf[sizeof(buf) - 1] = 0; } FreeDosObject(DOS_FIB, fib); if (buf[0] == 0) - return DOSTRUE; + return DOSTRUE; volname = buf; } break; @@ -220,7 +220,7 @@ if (arg1 == (IPTR)NULL) return DOSTRUE; if (!getpacketinfo(DOSBase, (STRPTR)arg1, &phs)) - return DOSTRUE; + return DOSTRUE; msgport = phs.port; volname = (STRPTR) arg1; /* rip off any trailing stuff, if its there */ diff --git a/rom/dos/exall.c b/rom/dos/exall.c index d6e0f5204c..bfef36de8d 100644 --- a/rom/dos/exall.c +++ b/rom/dos/exall.c @@ -18,17 +18,17 @@ NAME */ #include - AROS_LH5(BOOL, ExAll, + AROS_LH5(BOOL, ExAll, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), - AROS_LHA(struct ExAllData *, buffer, D2), - AROS_LHA(LONG, size, D3), - AROS_LHA(LONG, data, D4), - AROS_LHA(struct ExAllControl *, control, D5), + AROS_LHA(BPTR, lock, D1), + AROS_LHA(struct ExAllData *, buffer, D2), + AROS_LHA(LONG, size, D3), + AROS_LHA(LONG, data, D4), + AROS_LHA(struct ExAllControl *, control, D5), /* LOCATION */ - struct DosLibrary *, DOSBase, 72, Dos) + struct DosLibrary *, DOSBase, 72, Dos) /* FUNCTION @@ -39,7 +39,7 @@ 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 - (see NOTES) + (see NOTES) size -- size of 'buffer' in bytes data -- type of the data to be returned control -- a control structure allocated by AllocDosObject() @@ -90,15 +90,15 @@ eac_MatchString : if NULL then information on all files will be returned. If non-NULL it's interpreted as a pointer to a string used for pattern matching which files to return - information on. This string must have been parsed by - ParsePatternNoCase()! + information on. This string must have been parsed by + ParsePatternNoCase()! eac_MatchFunc : pointer to a hook that will be called to decide if an entry should be included in the buffer. If NULL, no - matching function will be called. The hook is called as - follows + matching function will be called. The hook is called as + follows - BOOL = MatchFunc(hook, data, typeptr) + BOOL = MatchFunc(hook, data, typeptr) EXAMPLE @@ -125,186 +125,186 @@ handler. */ if (((struct InternalExAllControl *)control)->fib != NULL) { - err = ERROR_ACTION_NOT_KNOWN; + err = ERROR_ACTION_NOT_KNOWN; } else { - status = dopacket5(DOSBase, &err, fl->fl_Task, ACTION_EXAMINE_ALL, (SIPTR)lock, (IPTR)buffer, (IPTR)size, (IPTR)data, (IPTR)control); - if (status != DOSFALSE) - err = RETURN_OK; + status = dopacket5(DOSBase, &err, fl->fl_Task, ACTION_EXAMINE_ALL, (SIPTR)lock, (IPTR)buffer, (IPTR)size, (IPTR)data, (IPTR)control); + if (status != DOSFALSE) + err = RETURN_OK; } if ( err == ERROR_NOT_IMPLEMENTED || - err == ERROR_ACTION_NOT_KNOWN + err == ERROR_ACTION_NOT_KNOWN ) { - /* Try to emulate it */ - STRPTR end = (STRPTR)buffer + size; - STRPTR next; - - struct ExAllData *last = buffer, *curr = buffer; - - struct InternalExAllControl *icontrol = (struct InternalExAllControl *)control; - - static const ULONG sizes[]= - { - 0, - offsetof(struct ExAllData,ed_Type), - offsetof(struct ExAllData,ed_Size), - offsetof(struct ExAllData,ed_Prot), - offsetof(struct ExAllData,ed_Days), - offsetof(struct ExAllData,ed_Comment), - offsetof(struct ExAllData,ed_OwnerUID), - sizeof(struct ExAllData) - }; - - /* Reset the 'fake' error */ - err = 0; - - /* Allocate the FIB structure, if not allocated yet. It will be deallocated - by DeleteDosObject(). */ - if (!icontrol->fib) - { - icontrol->fib = AllocDosObject(DOS_FIB, NULL); - if (!icontrol->fib) - { - err = IoErr(); - goto end; - } - } + /* Try to emulate it */ + STRPTR end = (STRPTR)buffer + size; + STRPTR next; + + struct ExAllData *last = buffer, *curr = buffer; + + struct InternalExAllControl *icontrol = (struct InternalExAllControl *)control; + + static const ULONG sizes[]= + { + 0, + offsetof(struct ExAllData,ed_Type), + offsetof(struct ExAllData,ed_Size), + offsetof(struct ExAllData,ed_Prot), + offsetof(struct ExAllData,ed_Days), + offsetof(struct ExAllData,ed_Comment), + offsetof(struct ExAllData,ed_OwnerUID), + sizeof(struct ExAllData) + }; + + /* Reset the 'fake' error */ + err = 0; + + /* Allocate the FIB structure, if not allocated yet. It will be deallocated + by DeleteDosObject(). */ + if (!icontrol->fib) + { + icontrol->fib = AllocDosObject(DOS_FIB, NULL); + if (!icontrol->fib) + { + err = IoErr(); + goto end; + } + } /* No entries found as of now yet. */ control->eac_Entries = 0; - - /* If LastKey == 0 it means this is the first time we're getting called, - in which case we need to initialize the FIB structure and a few other things. - A "nice" side effect of this, is that if one wants to restart the scanning, - he/she just has to set LastKey to 0. */ - if (control->eac_LastKey == 0) - { - if (!Examine(lock, icontrol->fib)) - { - err = IoErr(); - goto end; - } - if (icontrol->fib->fib_DirEntryType <= 0) - { - err = ERROR_OBJECT_WRONG_TYPE; - goto end; - } - } - - /* Macro used when the data doesn't fit in the provided buffer. - In case not even one element fit in the buffer, return a buffer - overflow error, so that the user knows he/she has to increase the - buffer. */ - #define ReturnOverflow() \ - do { \ - if (last == curr) \ - err = ERROR_BUFFER_OVERFLOW; \ - \ - icontrol->fib->fib_DiskKey = control->eac_LastKey; \ - goto end; \ - } while (0) - - /* Copy a string pointer by _source into the buffer provided - to the ExAll function. This macro gracefully handles buffer - overflows. */ - #define CopyStringSafe(_source) \ - do { \ - STRPTR source = _source; \ - \ - for (;;) \ - { \ - if (next >= end) \ - ReturnOverflow(); \ - if (!(*next++ = *source++)) \ - break; \ - } \ - } while (0) - - - if (data > ED_OWNER) - /* We don't have that many fields to fill in... */ - err = ERROR_BAD_NUMBER; - else - { - for - ( ; - ExNext(lock, icontrol->fib); - /* Record the latest DiskKey into LastKey so that we can roll back to it - in case of a buffer overflow and when getting called again. */ - control->eac_LastKey = icontrol->fib->fib_DiskKey - ) - { - /* Try to match the filename, if required. */ - if (control->eac_MatchString && - !MatchPatternNoCase(control->eac_MatchString, - icontrol->fib->fib_FileName)) - continue; - - next = (STRPTR)curr + sizes[data]; - - /* Oops, the buffer is full. */ - if (next > end) - ReturnOverflow(); - - /* Switch over the requested fields and fill them as appropriate. */ - switch(data) - { - case ED_OWNER: - curr->ed_OwnerUID = icontrol->fib->fib_OwnerUID; - curr->ed_OwnerGID = icontrol->fib->fib_OwnerGID; - - /* Fall through */ - case ED_COMMENT: - curr->ed_Comment = next; - CopyStringSafe(icontrol->fib->fib_Comment); - - /* Fall through */ - case ED_DATE: - curr->ed_Days = icontrol->fib->fib_Date.ds_Days; - curr->ed_Mins = icontrol->fib->fib_Date.ds_Minute; - curr->ed_Ticks = icontrol->fib->fib_Date.ds_Tick; - - /* Fall through */ - case ED_PROTECTION: - curr->ed_Prot = icontrol->fib->fib_Protection; - - /* Fall through */ - case ED_SIZE: - curr->ed_Size = icontrol->fib->fib_Size; - - /* Fall through */ - case ED_TYPE: - curr->ed_Type = icontrol->fib->fib_DirEntryType; - - /* Fall through */ - case ED_NAME: - curr->ed_Name = next; - CopyStringSafe(icontrol->fib->fib_FileName); - - /* Fall through */ - case 0: - curr->ed_Next = (struct ExAllData *)(((IPTR)next + AROS_PTRALIGN - 1) & ~(AROS_PTRALIGN - 1)); - } - - /* Do some more matching... */ - if (control->eac_MatchFunc && !CALLHOOKPKT(control->eac_MatchFunc, curr, &data)) - continue; - - /* Finally go to the next entry in the buffer. */ - last = curr; - curr = curr->ed_Next; - control->eac_Entries++; - } - err = IoErr(); - } + + /* If LastKey == 0 it means this is the first time we're getting called, + in which case we need to initialize the FIB structure and a few other things. + A "nice" side effect of this, is that if one wants to restart the scanning, + he/she just has to set LastKey to 0. */ + if (control->eac_LastKey == 0) + { + if (!Examine(lock, icontrol->fib)) + { + err = IoErr(); + goto end; + } + if (icontrol->fib->fib_DirEntryType <= 0) + { + err = ERROR_OBJECT_WRONG_TYPE; + goto end; + } + } + + /* Macro used when the data doesn't fit in the provided buffer. + In case not even one element fit in the buffer, return a buffer + overflow error, so that the user knows he/she has to increase the + buffer. */ + #define ReturnOverflow() \ + do { \ + if (last == curr) \ + err = ERROR_BUFFER_OVERFLOW; \ + \ + icontrol->fib->fib_DiskKey = control->eac_LastKey; \ + goto end; \ + } while (0) + + /* Copy a string pointer by _source into the buffer provided + to the ExAll function. This macro gracefully handles buffer + overflows. */ + #define CopyStringSafe(_source) \ + do { \ + STRPTR source = _source; \ + \ + for (;;) \ + { \ + if (next >= end) \ + ReturnOverflow(); \ + if (!(*next++ = *source++)) \ + break; \ + } \ + } while (0) + + + if (data > ED_OWNER) + /* We don't have that many fields to fill in... */ + err = ERROR_BAD_NUMBER; + else + { + for + ( ; + ExNext(lock, icontrol->fib); + /* Record the latest DiskKey into LastKey so that we can roll back to it + in case of a buffer overflow and when getting called again. */ + control->eac_LastKey = icontrol->fib->fib_DiskKey + ) + { + /* Try to match the filename, if required. */ + if (control->eac_MatchString && + !MatchPatternNoCase(control->eac_MatchString, + icontrol->fib->fib_FileName)) + continue; + + next = (STRPTR)curr + sizes[data]; + + /* Oops, the buffer is full. */ + if (next > end) + ReturnOverflow(); + + /* Switch over the requested fields and fill them as appropriate. */ + switch(data) + { + case ED_OWNER: + curr->ed_OwnerUID = icontrol->fib->fib_OwnerUID; + curr->ed_OwnerGID = icontrol->fib->fib_OwnerGID; + + /* Fall through */ + case ED_COMMENT: + curr->ed_Comment = next; + CopyStringSafe(icontrol->fib->fib_Comment); + + /* Fall through */ + case ED_DATE: + curr->ed_Days = icontrol->fib->fib_Date.ds_Days; + curr->ed_Mins = icontrol->fib->fib_Date.ds_Minute; + curr->ed_Ticks = icontrol->fib->fib_Date.ds_Tick; + + /* Fall through */ + case ED_PROTECTION: + curr->ed_Prot = icontrol->fib->fib_Protection; + + /* Fall through */ + case ED_SIZE: + curr->ed_Size = icontrol->fib->fib_Size; + + /* Fall through */ + case ED_TYPE: + curr->ed_Type = icontrol->fib->fib_DirEntryType; + + /* Fall through */ + case ED_NAME: + curr->ed_Name = next; + CopyStringSafe(icontrol->fib->fib_FileName); + + /* Fall through */ + case 0: + curr->ed_Next = (struct ExAllData *)(((IPTR)next + AROS_PTRALIGN - 1) & ~(AROS_PTRALIGN - 1)); + } + + /* Do some more matching... */ + if (control->eac_MatchFunc && !CALLHOOKPKT(control->eac_MatchFunc, curr, &data)) + continue; + + /* Finally go to the next entry in the buffer. */ + last = curr; + curr = curr->ed_Next; + control->eac_Entries++; + } + err = IoErr(); + } end: /* This is the last one, after it there's nothing. */ - last->ed_Next = NULL; + last->ed_Next = NULL; } /* Set error code and return */ diff --git a/rom/dos/exallend.c b/rom/dos/exallend.c index 7ac533d8f1..3b72a3a6ea 100644 --- a/rom/dos/exallend.c +++ b/rom/dos/exallend.c @@ -16,17 +16,17 @@ NAME */ #include - AROS_LH5(void, ExAllEnd, + AROS_LH5(void, ExAllEnd, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), - AROS_LHA(struct ExAllData *, buffer, D2), - AROS_LHA(LONG, size, D3), - AROS_LHA(LONG, data, D4), - AROS_LHA(struct ExAllControl *, control, D5), + AROS_LHA(BPTR, lock, D1), + AROS_LHA(struct ExAllData *, buffer, D2), + AROS_LHA(LONG, size, D3), + AROS_LHA(LONG, data, D4), + AROS_LHA(struct ExAllControl *, control, D5), /* LOCATION */ - struct DosLibrary *, DOSBase, 165, Dos) + struct DosLibrary *, DOSBase, 165, Dos) /* FUNCTION @@ -66,7 +66,7 @@ { /* Get pointer to filehandle */ struct FileLock *fl = (struct FileLock *)BADDR(lock); - dopacket5(DOSBase, NULL, fl->fl_Task, ACTION_EXAMINE_ALL_END, (SIPTR)lock, (IPTR)buffer, (IPTR)size, (IPTR)data, (IPTR)control); + dopacket5(DOSBase, NULL, fl->fl_Task, ACTION_EXAMINE_ALL_END, (SIPTR)lock, (IPTR)buffer, (IPTR)size, (IPTR)data, (IPTR)control); } else { diff --git a/rom/dos/examine.c b/rom/dos/examine.c index 0da26a944a..62641a51f4 100644 --- a/rom/dos/examine.c +++ b/rom/dos/examine.c @@ -16,14 +16,14 @@ NAME */ #include - AROS_LH2(LONG, Examine, + AROS_LH2(LONG, Examine, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), - AROS_LHA(struct FileInfoBlock *, fib, D2), + AROS_LHA(BPTR, lock, D1), + AROS_LHA(struct FileInfoBlock *, fib, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 17, Dos) + struct DosLibrary *, DOSBase, 17, Dos) /* FUNCTION @@ -69,8 +69,8 @@ D(bug("[Examine] lock=%x fib=%x\n", fl, fib)); ret = dopacket2(DOSBase, NULL, fl->fl_Task, ACTION_EXAMINE_OBJECT, lock, MKBADDR(fib)); if (ret) { - fixfib(fib); - D(bug("[Examine] '%s'\n", fib->fib_FileName)); + fixfib(fib); + D(bug("[Examine] '%s'\n", fib->fib_FileName)); } return ret; diff --git a/rom/dos/examinefh.c b/rom/dos/examinefh.c index 08f1cabb0e..4702b1a78e 100644 --- a/rom/dos/examinefh.c +++ b/rom/dos/examinefh.c @@ -17,14 +17,14 @@ NAME */ #include - AROS_LH2(BOOL, ExamineFH, + AROS_LH2(BOOL, ExamineFH, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), - AROS_LHA(struct FileInfoBlock *, fib, D2), + AROS_LHA(BPTR, lock, D1), + AROS_LHA(struct FileInfoBlock *, fib, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 65, Dos) + struct DosLibrary *, DOSBase, 65, Dos) /* FUNCTION @@ -52,8 +52,8 @@ D(bug("[ExamineFH] fh=%x fib=%x\n", fh, fib)); ret = dopacket2(DOSBase, NULL, fh->fh_Type, ACTION_EXAMINE_FH, fh->fh_Arg1, MKBADDR(fib)); if (ret) { - fixfib(fib); - D(bug("[ExamineFH] '%s'\n", fib->fib_FileName)); + fixfib(fib); + D(bug("[ExamineFH] '%s'\n", fib->fib_FileName)); } return ret; diff --git a/rom/dos/execute.c b/rom/dos/execute.c index 105df518fc..a62a9c8005 100644 --- a/rom/dos/execute.c +++ b/rom/dos/execute.c @@ -17,15 +17,15 @@ NAME */ #include - AROS_LH3(BOOL, Execute, + AROS_LH3(BOOL, Execute, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, string, D1), - AROS_LHA(BPTR , input , D2), - AROS_LHA(BPTR , output, D3), + AROS_LHA(CONST_STRPTR, string, D1), + AROS_LHA(BPTR , input , D2), + AROS_LHA(BPTR , output, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 37, Dos) + struct DosLibrary *, DOSBase, 37, Dos) /* FUNCTION @@ -77,10 +77,10 @@ { { SYS_Background, TRUE }, { SYS_Asynch, FALSE }, - { SYS_Input, (IPTR)input }, - { SYS_Output, (IPTR)output }, - { SYS_Error, (IPTR)NULL }, - { TAG_DONE, 0 } + { SYS_Input, (IPTR)input }, + { SYS_Output, (IPTR)output }, + { SYS_Error, (IPTR)NULL }, + { TAG_DONE, 0 } }; D(bug("[Execute] input = %p, output = %p, cmd = \"%s\"\n", input, output, string)); @@ -97,9 +97,9 @@ result = SystemTagList(string, tags); if(result == 0) - return DOSTRUE; + return DOSTRUE; else - return DOSFALSE; + return DOSFALSE; AROS_LIBFUNC_EXIT } /* Execute */ diff --git a/rom/dos/exit.c b/rom/dos/exit.c index 2e6a536e90..3891b76f42 100644 --- a/rom/dos/exit.c +++ b/rom/dos/exit.c @@ -41,28 +41,28 @@ struct StackState NAME */ #include - AROS_LH1(void, Exit, + AROS_LH1(void, Exit, /* SYNOPSIS */ - AROS_LHA(LONG, returnCode, D1), + AROS_LHA(LONG, returnCode, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 24, Dos) + struct DosLibrary *, DOSBase, 24, Dos) /* FUNCTION - Instantly terminate the program. + Instantly terminate the program. INPUTS - returnCode - Process' return code. + returnCode - Process' return code. RESULT - None. + None. NOTES - Calling this function bypasses normal termination sequence of your program. - Automatically opened libraries will not be closed, destructors will not be - called, etc. Do this only if you really know what are you doing. It's not - adviced to use this function at all. + Calling this function bypasses normal termination sequence of your program. + Automatically opened libraries will not be closed, destructors will not be + called, etc. Do this only if you really know what are you doing. It's not + adviced to use this function at all. EXAMPLE @@ -113,21 +113,21 @@ ULONG CallEntry(STRPTR argptr, ULONG argsize, LONG_FUNC entry, struct Process *m if (setjmp(ss.state)) { - /* - * We came here from Exit(). - * Restore stack limits because the program might have swapped stack. - * We are clever enough to recover from this. - */ - me->pr_Task.tc_SPLower = ss.stackLower; - me->pr_Task.tc_SPUpper = ss.stackUpper; + /* + * We came here from Exit(). + * Restore stack limits because the program might have swapped stack. + * We are clever enough to recover from this. + */ + me->pr_Task.tc_SPLower = ss.stackLower; + me->pr_Task.tc_SPUpper = ss.stackUpper; - Enable(); /* We Disable()d in Exit() */ + Enable(); /* We Disable()d in Exit() */ - return ss.retval; + return ss.retval; } else - return AROS_UFC3(ULONG, entry, - AROS_UFCA(STRPTR, argptr, A0), - AROS_UFCA(ULONG, argsize, D0), - AROS_UFCA(struct ExecBase *, SysBase, A6)); + return AROS_UFC3(ULONG, entry, + AROS_UFCA(STRPTR, argptr, A0), + AROS_UFCA(ULONG, argsize, D0), + AROS_UFCA(struct ExecBase *, SysBase, A6)); } diff --git a/rom/dos/exnext.c b/rom/dos/exnext.c index a2b884f1d8..e97c971973 100644 --- a/rom/dos/exnext.c +++ b/rom/dos/exnext.c @@ -16,14 +16,14 @@ NAME */ #include - AROS_LH2(LONG, ExNext, + AROS_LH2(LONG, ExNext, /* SYNOPSIS */ - AROS_LHA(BPTR , lock, D1), - AROS_LHA(struct FileInfoBlock *, fileInfoBlock, D2), + AROS_LHA(BPTR , lock, D1), + AROS_LHA(struct FileInfoBlock *, fileInfoBlock, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 18, Dos) + struct DosLibrary *, DOSBase, 18, Dos) /* FUNCTION @@ -39,7 +39,7 @@ 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. + the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES. NOTES @@ -56,7 +56,7 @@ 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). + to make sure that there was no real failure (ERROR_NO_MORE_ENTRIES). BUGS @@ -80,10 +80,10 @@ D(bug("[ExNext] lock=%x fib=%x\n", fl, fileInfoBlock)); ret = dopacket2(DOSBase, NULL, fl->fl_Task, ACTION_EXAMINE_NEXT, lock, MKBADDR(fileInfoBlock)); if (ret) { - fixfib(fileInfoBlock); - D(bug("[ExNext] '%s'\n", fileInfoBlock->fib_FileName)); + fixfib(fileInfoBlock); + D(bug("[ExNext] '%s'\n", fileInfoBlock->fib_FileName)); } else { - D(bug("[ExNext] ret=%d err=%d\n", ret, IoErr())); + D(bug("[ExNext] ret=%d err=%d\n", ret, IoErr())); } return ret; diff --git a/rom/dos/fault.c b/rom/dos/fault.c dissimilarity index 62% index d35cce0427..0927c79984 100644 --- a/rom/dos/fault.c +++ b/rom/dos/fault.c @@ -1,142 +1,142 @@ -/* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. - $Id$ - - Desc: dos.library function Fault() - Lang: english -*/ -#include -#include "dos_intern.h" -#if PassThroughErrnos -# include -#endif -#include - -/***************************************************************************** - - NAME */ -#include - - AROS_LH4(BOOL, Fault, - -/* SYNOPSIS */ - AROS_LHA(LONG, code, D1), - AROS_LHA(CONST_STRPTR, header, D2), - AROS_LHA(STRPTR, buffer, D3), - AROS_LHA(LONG, len, D4), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 78, Dos) - -/* 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. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - LONG index = 0; - STRPTR theString; - - if (code == 0) - { - *buffer = '\0'; - return 0; - } - - /* Do this to make sure there is room for a NULL terminator */ - len--; - - if (header) - { - while((index < len) && *header) - { - buffer[index++] = *header++; - } - - buffer[index++] = ':'; - buffer[index++] = ' '; - } - - theString = DosGetString(code); -#if PassThroughErrnos - if ((!theString) && (code & PassThroughErrnos)) - { - theString = strerror (code ^ PassThroughErrnos); - } -#endif - if(theString) - { - while((index < len) && *theString) - { - buffer[index++] = *theString++; - } - } - else - { - /* String buffer/index for long 2 string */ - UBYTE l2str[12], l2idx = 11; - - theString = "Error"; - while((index < len) && *theString) - { - buffer[index++] = *theString++; - } - - /* If the number is negative, whack in a - sign. */ - if(code < 0) - { - code = -code; - buffer[index++] = '-'; - } - - /* Convert the number to a string, I work backwards, its easier */ - l2str[l2idx--] = '\0'; - while(code != 0) - { - l2str[l2idx--] = (code % 10) + '0'; - code /= 10; - } - - l2str[l2idx] = ' '; - - /* Copy the number onto the fault string */ - while((index < len) && l2str[l2idx]) - { - buffer[index++] = l2str[l2idx++]; - } - } - buffer[index] = '\0'; - return (len - index + 1); - - AROS_LIBFUNC_EXIT -} /* Fault */ +/* + Copyright © 1995-2008, The AROS Development Team. All rights reserved. + $Id$ + + Desc: dos.library function Fault() + Lang: english +*/ +#include +#include "dos_intern.h" +#if PassThroughErrnos +# include +#endif +#include + +/***************************************************************************** + + NAME */ +#include + + AROS_LH4(BOOL, Fault, + +/* SYNOPSIS */ + AROS_LHA(LONG, code, D1), + AROS_LHA(CONST_STRPTR, header, D2), + AROS_LHA(STRPTR, buffer, D3), + AROS_LHA(LONG, len, D4), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 78, Dos) + +/* 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. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + LONG index = 0; + STRPTR theString; + + if (code == 0) + { + *buffer = '\0'; + return 0; + } + + /* Do this to make sure there is room for a NULL terminator */ + len--; + + if (header) + { + while((index < len) && *header) + { + buffer[index++] = *header++; + } + + buffer[index++] = ':'; + buffer[index++] = ' '; + } + + theString = DosGetString(code); +#if PassThroughErrnos + if ((!theString) && (code & PassThroughErrnos)) + { + theString = strerror (code ^ PassThroughErrnos); + } +#endif + if(theString) + { + while((index < len) && *theString) + { + buffer[index++] = *theString++; + } + } + else + { + /* String buffer/index for long 2 string */ + UBYTE l2str[12], l2idx = 11; + + theString = "Error"; + while((index < len) && *theString) + { + buffer[index++] = *theString++; + } + + /* If the number is negative, whack in a - sign. */ + if(code < 0) + { + code = -code; + buffer[index++] = '-'; + } + + /* Convert the number to a string, I work backwards, its easier */ + l2str[l2idx--] = '\0'; + while(code != 0) + { + l2str[l2idx--] = (code % 10) + '0'; + code /= 10; + } + + l2str[l2idx] = ' '; + + /* Copy the number onto the fault string */ + while((index < len) && l2str[l2idx]) + { + buffer[index++] = l2str[l2idx++]; + } + } + buffer[index] = '\0'; + return (len - index + 1); + + AROS_LIBFUNC_EXIT +} /* Fault */ diff --git a/rom/dos/fgetc.c b/rom/dos/fgetc.c index 6465799f31..b6ca1b1586 100644 --- a/rom/dos/fgetc.c +++ b/rom/dos/fgetc.c @@ -21,26 +21,26 @@ NAME */ #include - AROS_LH1(LONG, FGetC, + AROS_LH1(LONG, FGetC, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), + AROS_LHA(BPTR, file, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 51, Dos) + struct DosLibrary *, DOSBase, 51, Dos) /* 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. + 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 + file - filehandle RESULT - The character read or EOF if the file ended or an error happened. - IoErr() gives additional information in that case. + The character read or EOF if the file ended or an error happened. + IoErr() gives additional information in that case. NOTES @@ -49,7 +49,7 @@ BUGS SEE ALSO - IoErr(), Flush() + IoErr(), Flush() INTERNALS @@ -65,7 +65,7 @@ if (fh == NULL) { - return EOF; + return EOF; } /* If the file is in write mode... */ @@ -80,7 +80,7 @@ /* An error happened? Return it. */ if(size < 0) - { + { return EOF; } @@ -131,10 +131,10 @@ /* No data read? Return EOF. */ if(size == 0) - { + { D(bug("FGetC: Tried to Read() to a %d byte buffer, got 0)\n", bufsize)); return EOF; - } + } } /* If fh_End == 0, simulate an EOF */ diff --git a/rom/dos/fgets.c b/rom/dos/fgets.c index afba1fbe8b..3ab87a7644 100644 --- a/rom/dos/fgets.c +++ b/rom/dos/fgets.c @@ -13,29 +13,29 @@ NAME */ #include - AROS_LH3(STRPTR, FGets, + AROS_LH3(STRPTR, FGets, /* SYNOPSIS */ - AROS_LHA(BPTR , fh, D1), - AROS_LHA(STRPTR, buf, D2), - AROS_LHA(ULONG , buflen, D3), + AROS_LHA(BPTR , fh, D1), + AROS_LHA(STRPTR, buf, D2), + AROS_LHA(ULONG , buflen, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 56, Dos) + struct DosLibrary *, DOSBase, 56, Dos) /* 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. + 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 + 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. + buf or NULL if the first thing read is EOF. NOTES @@ -58,17 +58,17 @@ do { - c = FGetC (fh); + c = FGetC (fh); - if (c == EOF) - { - if (len == 0) - return NULL; - else - break; - } + if (c == EOF) + { + if (len == 0) + return NULL; + else + break; + } - buf[len++] = c; + buf[len++] = c; } while ((len - AROS_LH1(STRPTR, FilePart, + AROS_LH1(STRPTR, FilePart, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, path, D1), + AROS_LHA(CONST_STRPTR, path, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 145, Dos) + struct DosLibrary *, DOSBase, 145, Dos) /* FUNCTION - Get a pointer to the last component of a path, which is normally the - filename. + 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. + 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! + A pointer to the first char of the filename! NOTES 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'. + 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. + None known. SEE ALSO - PathPart(), AddPart() + PathPart(), AddPart() INTERNALS - Goes from the last char of the pathname back until it finds a ':', - a '/' or until the first char reached. + Goes from the last char of the pathname back until it finds a ':', + a '/' or until the first char reached. *****************************************************************************/ { @@ -64,24 +64,24 @@ if(path) { - CONST_STRPTR i; + CONST_STRPTR i; - /* set i to last char of path */ + /* set i to last char of path */ - if (!*path) /* path == "" ? */ - return (STRPTR)path; + if (!*path) /* path == "" ? */ + return (STRPTR)path; - i = path + strlen (path) -1; /* set i to the \0-byte */ + i = path + strlen (path) -1; /* set i to the \0-byte */ - /* decrease pointer as long as there is no ':', no '/' or till - the first char anyway. hope this works in all situations */ - while ((*i != ':') && (*i != '/') && (i != path)) - i--; + /* decrease pointer as long as there is no ':', no '/' or till + the first char anyway. hope this works in all situations */ + while ((*i != ':') && (*i != '/') && (i != path)) + i--; - if ((*i == ':')) i++; - if ((*i == '/')) i++; + if ((*i == ':')) i++; + if ((*i == '/')) i++; - return (STRPTR)i; + return (STRPTR)i; } /* path */ return NULL; /* if no path is given, return NULL pointer (shouldn't happen) */ @@ -100,10 +100,10 @@ int main (int argc, char ** argv) while (--argc) { - s = *++argv; - fileptr = FilePart(s); + s = *++argv; + fileptr = FilePart(s); - printf("Pfad: %s\nDatei: %s\n", s, fileptr); + printf("Pfad: %s\nDatei: %s\n", s, fileptr); } } diff --git a/rom/dos/findarg.c b/rom/dos/findarg.c dissimilarity index 63% index b3485a5f8c..23f945ec49 100644 --- a/rom/dos/findarg.c +++ b/rom/dos/findarg.c @@ -1,101 +1,101 @@ -/* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include - - AROS_LH2(LONG, FindArg, - -/* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, template, D1), - AROS_LHA(CONST_STRPTR, keyword, D2), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 134, Dos) - -/* FUNCTION - Search for keyword in the template string. - Abbreviations are handled. - - INPUTS - template - template string to be searched - keyword - keyword to search for - - RESULT - Index of the keyword or -1 if not found. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - LONG count=0; - CONST_STRPTR key; - - /* Loop over template */ - for(;;) - { - /* Compare key to template */ - key=keyword; - for(;;) - { - UBYTE lkey; - - /* If the keyword has ended check the template */ - if(!*key) - { - if(!*template||*template=='='||*template=='/'||*template==',') - /* The template has ended, too. Return count. */ - return count; - /* The template isn't finished. Stop comparison. */ - break; - } - /* If the two differ stop comparison. */ - lkey=ToLower(*key); - if(lkey!=ToLower(*template)) - break; - /* Go to next character */ - key++; - template++; - } - /* Find next keyword in template */ - for(;;) - { - if(!*template) - return -1; - if(*template=='=') - { - /* Alias found */ - template++; - break; - } - if(*template==',') - { - /* Next item found */ - template++; - count++; - break; - } - template++; - } - } - AROS_LIBFUNC_EXIT -} /* FindArg */ +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include + + AROS_LH2(LONG, FindArg, + +/* SYNOPSIS */ + AROS_LHA(CONST_STRPTR, template, D1), + AROS_LHA(CONST_STRPTR, keyword, D2), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 134, Dos) + +/* FUNCTION + Search for keyword in the template string. + Abbreviations are handled. + + INPUTS + template - template string to be searched + keyword - keyword to search for + + RESULT + Index of the keyword or -1 if not found. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + LONG count=0; + CONST_STRPTR key; + + /* Loop over template */ + for(;;) + { + /* Compare key to template */ + key=keyword; + for(;;) + { + UBYTE lkey; + + /* If the keyword has ended check the template */ + if(!*key) + { + if(!*template||*template=='='||*template=='/'||*template==',') + /* The template has ended, too. Return count. */ + return count; + /* The template isn't finished. Stop comparison. */ + break; + } + /* If the two differ stop comparison. */ + lkey=ToLower(*key); + if(lkey!=ToLower(*template)) + break; + /* Go to next character */ + key++; + template++; + } + /* Find next keyword in template */ + for(;;) + { + if(!*template) + return -1; + if(*template=='=') + { + /* Alias found */ + template++; + break; + } + if(*template==',') + { + /* Next item found */ + template++; + count++; + break; + } + template++; + } + } + AROS_LIBFUNC_EXIT +} /* FindArg */ diff --git a/rom/dos/findcliproc.c b/rom/dos/findcliproc.c index 6cac474fbb..5ad4574daa 100644 --- a/rom/dos/findcliproc.c +++ b/rom/dos/findcliproc.c @@ -17,23 +17,23 @@ NAME */ #include - AROS_LH1(struct Process *, FindCliProc, + AROS_LH1(struct Process *, FindCliProc, /* SYNOPSIS */ - AROS_LHA(ULONG, num, D1), + AROS_LHA(ULONG, num, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 91, Dos) + struct DosLibrary *, DOSBase, 91, Dos) /* FUNCTION - Find a CLI process by its task number. The number must be greater - than 0. + 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. + num - The task number of the CLI to find. RESULT - Pointer to the process if found, NULL otherwise. + Pointer to the process if found, NULL otherwise. NOTES @@ -44,7 +44,7 @@ BUGS SEE ALSO - Cli(), MaxCli() + Cli(), MaxCli() INTERNALS @@ -60,11 +60,11 @@ ForeachNode(&root->rn_CliList, node) { - if (node->ci_Process->pr_TaskNum == num) - { - cliProc = node->ci_Process; - break; - } + if (node->ci_Process->pr_TaskNum == num) + { + cliProc = node->ci_Process; + break; + } } ReleaseSemaphore(&root->rn_RootLock); diff --git a/rom/dos/finddosentry.c b/rom/dos/finddosentry.c index 3dfbcf96bb..510ba1ae08 100644 --- a/rom/dos/finddosentry.c +++ b/rom/dos/finddosentry.c @@ -17,31 +17,31 @@ NAME */ #include - AROS_LH3(struct DosList *, FindDosEntry, + AROS_LH3(struct DosList *, FindDosEntry, /* SYNOPSIS */ - AROS_LHA(struct DosList *, dlist, D1), - AROS_LHA(CONST_STRPTR, name, D2), - AROS_LHA(ULONG, flags, D3), + AROS_LHA(struct DosList *, dlist, D1), + AROS_LHA(CONST_STRPTR, name, D2), + AROS_LHA(ULONG, flags, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 114, Dos) + struct DosLibrary *, DOSBase, 114, Dos) /* 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 such restrictions - on volume nodes. + 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 such 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. + 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. + Pointer to dos list entry found or NULL if the are no more entries. NOTES @@ -65,38 +65,38 @@ ULONG size; if (!dlist) - return NULL; + return NULL; while (*end++) - ; + ; size = ~(name-end); if (size && end[-2] == ':') { - size--; + size--; } /* Follow the list */ for (;;) { - /* Get next entry. Return NULL if there is none. */ - dlist = BADDR(dlist->dol_Next); - - if (dlist == NULL) - { - return NULL; - } - - D(bug("[FindDosEntry] Found list entry 0x%p, '%b' type %d\n", dlist, dlist->dol_Name, dlist->dol_Type)); - - /* Check type and name */ - if (flags & flagarray[dlist->dol_Type + 1] && - !CMPNICBSTR(name, dlist->dol_Name, size) && - !AROS_BSTR_ADDR(dlist->dol_Name)[size]) - { - return dlist; - } + /* Get next entry. Return NULL if there is none. */ + dlist = BADDR(dlist->dol_Next); + + if (dlist == NULL) + { + return NULL; + } + + D(bug("[FindDosEntry] Found list entry 0x%p, '%b' type %d\n", dlist, dlist->dol_Name, dlist->dol_Type)); + + /* Check type and name */ + if (flags & flagarray[dlist->dol_Type + 1] && + !CMPNICBSTR(name, dlist->dol_Name, size) && + !AROS_BSTR_ADDR(dlist->dol_Name)[size]) + { + return dlist; + } } AROS_LIBFUNC_EXIT } /* FindDosEntry */ diff --git a/rom/dos/findsegment.c b/rom/dos/findsegment.c index e3184f440f..23351aad5c 100644 --- a/rom/dos/findsegment.c +++ b/rom/dos/findsegment.c @@ -16,45 +16,45 @@ #include #include - AROS_LH3(struct Segment *, FindSegment, + AROS_LH3(struct Segment *, FindSegment, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR , name, D1), - AROS_LHA(struct Segment *, seg, D2), - AROS_LHA(BOOL , system, D3), + AROS_LHA(CONST_STRPTR , name, D1), + AROS_LHA(struct Segment *, seg, D2), + AROS_LHA(BOOL , system, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 130, Dos) + struct DosLibrary *, DOSBase, 130, Dos) /* FUNCTION - Search for a resident segment by name and type. FindSegment() will - return the first segment that exactly matches the name and type. + 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. + 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. + 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. + 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. + 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. EXAMPLE BUGS SEE ALSO - AddSegment(), RemSegment() + AddSegment(), RemSegment() INTERNALS @@ -66,24 +66,24 @@ /* Segment seg was the last match, let's start from the next one */ if( seg != NULL ) - seg = BADDR(seg->seg_Next); + seg = BADDR(seg->seg_Next); else - seg = BADDR(dinf->di_ResList); + seg = BADDR(dinf->di_ResList); while( seg != NULL ) { D(bug("[FindSegment] Checking segment '%s'\n", AROS_BSTR_ADDR(MKBADDR(&seg->seg_Name[0])))); - if - ( - (system || (system == FALSE && (seg->seg_UC >=0))) && - (Stricmp( name, AROS_BSTR_ADDR(MKBADDR(&seg->seg_Name[0]))) == 0) - ) - { - /* We have a matching segment */ - return seg; - } - seg = BADDR(seg->seg_Next); + if + ( + (system || (system == FALSE && (seg->seg_UC >=0))) && + (Stricmp( name, AROS_BSTR_ADDR(MKBADDR(&seg->seg_Name[0]))) == 0) + ) + { + /* We have a matching segment */ + return seg; + } + seg = BADDR(seg->seg_Next); } return NULL; diff --git a/rom/dos/findvar.c b/rom/dos/findvar.c index e22d80bb9b..78521df67a 100644 --- a/rom/dos/findvar.c +++ b/rom/dos/findvar.c @@ -36,8 +36,8 @@ variable names follow the same syntax and semantics as filesystem names. type -- The type of variable to be found (see ). - Actually, only the lower 8 bits of "type" are used - by FindVar(). + 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 @@ -54,31 +54,31 @@ DeleteVar(), GetVar(), SetVar() INTERNALS - For every local variable, a structure of type LocalVar exists: - struct LocalVar { - struct Node lv_Node; - UWORD lv_Flags; - UBYTE *lv_Value; - ULONG lv_Len; - }; + For every local variable, a structure of type LocalVar exists: + struct LocalVar { + struct Node lv_Node; + UWORD lv_Flags; + UBYTE *lv_Value; + ULONG lv_Len; + }; - lv_Node.ln_Type - holds the variable type, either LV_VAR for regular local environment - variables or LV_ALIAS for shell aliases. dos/var.h also defines - LVF_IGNORE (for private usage by the shell) + lv_Node.ln_Type + holds the variable type, either LV_VAR for regular local environment + variables or LV_ALIAS for shell aliases. dos/var.h also defines + LVF_IGNORE (for private usage by the shell) - lv_Node.ln_Name - holds the variable name (NUL terminated string) + lv_Node.ln_Name + holds the variable name (NUL terminated string) - lv_Flags - stores GVF_BINARY_VAR and GVF_DONT_NULL_TERM if given as flags to - SetVar(). It is only used by GetVar(). + lv_Flags + stores GVF_BINARY_VAR and GVF_DONT_NULL_TERM if given as flags to + SetVar(). It is only used by GetVar(). - lv_Value - holds the variable's value + lv_Value + holds the variable's value - lv_Len - is the length of lv_Value + lv_Len + is the length of lv_Value *****************************************************************************/ { @@ -89,36 +89,36 @@ if (name != NULL) { - /* We scan through the process->pr_LocalVars list */ - struct Process *pr; - struct LocalVar *var; - - pr = (struct Process *)FindTask(NULL); - ASSERT_VALID_PROCESS(pr); - var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; - - ForeachNode(&pr->pr_LocalVars, var) - { - LONG res; - - if (var->lv_Node.ln_Type == type) - { - /* The list is alphabetically sorted. */ - res = Stricmp(name, var->lv_Node.ln_Name); - - /* Found it */ - if (res == 0) - { - return var; - } - - /* We have gone too far through the sorted list. */ - else if (res < 0) - { - break; - } - } - } + /* We scan through the process->pr_LocalVars list */ + struct Process *pr; + struct LocalVar *var; + + pr = (struct Process *)FindTask(NULL); + ASSERT_VALID_PROCESS(pr); + var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; + + ForeachNode(&pr->pr_LocalVars, var) + { + LONG res; + + if (var->lv_Node.ln_Type == type) + { + /* The list is alphabetically sorted. */ + res = Stricmp(name, var->lv_Node.ln_Name); + + /* Found it */ + if (res == 0) + { + return var; + } + + /* We have gone too far through the sorted list. */ + else if (res < 0) + { + break; + } + } + } } return NULL; diff --git a/rom/dos/flush.c b/rom/dos/flush.c index 9b88ca4db3..07cbc7bb40 100644 --- a/rom/dos/flush.c +++ b/rom/dos/flush.c @@ -14,25 +14,25 @@ NAME */ #include - AROS_LH1(LONG, Flush, + AROS_LH1(LONG, Flush, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), + AROS_LHA(BPTR, file, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 60, Dos) + struct DosLibrary *, DOSBase, 60, Dos) /* 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. + 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 + file - filehandle RESULT - != 0 on success, 0 on error. IoErr() gives additional information - in that case. + != 0 on success, 0 on error. IoErr() gives additional information + in that case. NOTES @@ -52,25 +52,25 @@ struct FileHandle *fh = (struct FileHandle *)BADDR(file); if (!fh) - return DOSTRUE; + return DOSTRUE; /* The file must be in write mode. */ if( fh->fh_Flags & FHF_WRITE ) { - /* Handle append mode. */ - if( fh->fh_Flags & FHF_APPEND ) - { - InternalSeek( fh, 0, OFFSET_END, DOSBase ); - } - - return InternalFlush( fh, DOSBase ); + /* Handle append mode. */ + if( fh->fh_Flags & FHF_APPEND ) + { + InternalSeek( fh, 0, OFFSET_END, DOSBase ); + } + + return InternalFlush( fh, DOSBase ); } else if( fh->fh_Pos < fh->fh_End ) { - int offset = fh->fh_Pos - fh->fh_End; - - fh->fh_Pos = fh->fh_End = 0; - + int offset = fh->fh_Pos - fh->fh_End; + + fh->fh_Pos = fh->fh_End = 0; + /* Read mode. Try to seek back to the current position. */ if( InternalSeek( fh, offset, OFFSET_CURRENT, DOSBase ) < 0 ) { diff --git a/rom/dos/format.c b/rom/dos/format.c index 6b39776608..d13c7cbda2 100644 --- a/rom/dos/format.c +++ b/rom/dos/format.c @@ -13,30 +13,30 @@ NAME */ #include - AROS_LH3(BOOL, Format, + AROS_LH3(BOOL, Format, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, devicename, D1), - AROS_LHA(CONST_STRPTR, volumename, D2), - AROS_LHA(ULONG, dostype, D3), + AROS_LHA(CONST_STRPTR, devicename, D1), + AROS_LHA(CONST_STRPTR, volumename, D2), + AROS_LHA(ULONG, dostype, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 119, Dos) + struct DosLibrary *, DOSBase, 119, Dos) /* 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. + 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. + 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. + 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. + != 0 if the format was successful, 0 otherwise. NOTES @@ -56,7 +56,7 @@ LONG status = DOSFALSE; if (!getdevpacketinfo(DOSBase, devicename, volumename, &phs)) - return DOSFALSE; + return DOSFALSE; status = dopacket2(DOSBase, NULL, phs.port, ACTION_FORMAT, phs.name, (IPTR)dostype); diff --git a/rom/dos/fputc.c b/rom/dos/fputc.c index 7b23667e7c..52ae4aabea 100644 --- a/rom/dos/fputc.c +++ b/rom/dos/fputc.c @@ -20,25 +20,25 @@ NAME */ #include - AROS_LH2(LONG, FPutC, + AROS_LH2(LONG, FPutC, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(LONG, character, D2), + AROS_LHA(BPTR, file, D1), + AROS_LHA(LONG, character, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 52, Dos) + struct DosLibrary *, DOSBase, 52, Dos) /* FUNCTION - Write a character to a file. - + Write a character to a file. + INPUTS - file - Filehandle to write to. - character - Character to write. + 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. + The character written or EOF in case of an error. + IoErr() gives additional information in that case. NOTES @@ -47,7 +47,7 @@ BUGS SEE ALSO - FGetC(), IoErr() + FGetC(), IoErr() INTERNALS diff --git a/rom/dos/fputs.c b/rom/dos/fputs.c index c1685c4261..1b40b674b9 100644 --- a/rom/dos/fputs.c +++ b/rom/dos/fputs.c @@ -17,31 +17,31 @@ NAME */ #include - AROS_LH2(LONG, FPuts, -/* FPuts -- Writes a string the the specified output (buffered) */ + AROS_LH2(LONG, FPuts, +/* FPuts -- Writes a string the the specified output (buffered) */ /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(CONST_STRPTR, string, D2), + AROS_LHA(BPTR, file, D1), + AROS_LHA(CONST_STRPTR, string, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 57, Dos) + struct DosLibrary *, DOSBase, 57, Dos) /* 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. + 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. + 0 if all went well or EOF in case of an error. + IoErr() gives additional information in that case. SEE ALSO - FGetC(), IoErr() + FGetC(), IoErr() *****************************************************************************/ { diff --git a/rom/dos/fread.c b/rom/dos/fread.c index 2514cb9549..b5438e6bfb 100644 --- a/rom/dos/fread.c +++ b/rom/dos/fread.c @@ -12,30 +12,30 @@ NAME */ #include - AROS_LH4(LONG, FRead, + AROS_LH4(LONG, FRead, /* SYNOPSIS */ - AROS_LHA(BPTR , fh, D1), - AROS_LHA(APTR , block, D2), - AROS_LHA(ULONG, blocklen, D3), - AROS_LHA(ULONG, number, D4), + AROS_LHA(BPTR , fh, D1), + AROS_LHA(APTR , block, D2), + AROS_LHA(ULONG, blocklen, D3), + AROS_LHA(ULONG, number, D4), /* LOCATION */ - struct DosLibrary *, DOSBase, 54, Dos) + struct DosLibrary *, DOSBase, 54, Dos) /* FUNCTION - Read a number of blocks from a file. + 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 + 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 fewer than the requested number of blocks. - IoErr() gives additional information in case of an error. + The number of blocks read from the file or 0 on EOF. + This function may return fewer than the requested number of blocks. + IoErr() gives additional information in case of an error. NOTES @@ -44,7 +44,7 @@ BUGS SEE ALSO - Open(), FWrite(), FPutc(), Close() + Open(), FWrite(), FPutc(), Close() INTERNALS @@ -64,15 +64,15 @@ for(read = 0; read < number; read++) { - for(len = blocklen; len--; ) - { - c = FGetC(fh); + for(len = blocklen; len--; ) + { + c = FGetC(fh); - if(c < 0) - goto finish; + if(c < 0) + goto finish; - *ptr ++ = c; - } + *ptr ++ = c; + } } finish: if(read == 0 && len == blocklen) diff --git a/rom/dos/freeargs.c b/rom/dos/freeargs.c index f427ab4b31..b4e85b499a 100644 --- a/rom/dos/freeargs.c +++ b/rom/dos/freeargs.c @@ -14,27 +14,27 @@ NAME */ #include - AROS_NTLH1(void, FreeArgs, + AROS_NTLH1(void, FreeArgs, /* SYNOPSIS */ - AROS_LHA(struct RDArgs *, args, D1), + AROS_LHA(struct RDArgs *, args, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 143, Dos) + struct DosLibrary *, DOSBase, 143, Dos) /* 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(). + 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. + 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. + Some memory will have been returned to the system. NOTES @@ -43,7 +43,7 @@ BUGS SEE ALSO - ReadArgs() + ReadArgs() INTERNALS @@ -52,35 +52,35 @@ AROS_LIBFUNC_INIT if(!args) - return; + return; /* ReadArgs() failed. Clean everything up. */ if (args->RDA_DAList) { - FreeVec(((struct DAList *)args->RDA_DAList)->ArgBuf); - FreeVec(((struct DAList *)args->RDA_DAList)->StrBuf); - FreeVec(((struct DAList *)args->RDA_DAList)->MultVec); - FreeVec((struct DAList *)args->RDA_DAList); + FreeVec(((struct DAList *)args->RDA_DAList)->ArgBuf); + FreeVec(((struct DAList *)args->RDA_DAList)->StrBuf); + FreeVec(((struct DAList *)args->RDA_DAList)->MultVec); + FreeVec((struct DAList *)args->RDA_DAList); - args->RDA_DAList = 0; - + args->RDA_DAList = 0; + #if 0 - /* - Why do I put this here. Unless the user has been bad and - set RDA_DAList to something other than NULL, then this - RDArgs structure was allocated by ReadArgs(), so we can - free it. Otherwise the RDArgs was allocated by - AllocDosObject(), so we are not allowed to free it. + /* + Why do I put this here. Unless the user has been bad and + set RDA_DAList to something other than NULL, then this + RDArgs structure was allocated by ReadArgs(), so we can + free it. Otherwise the RDArgs was allocated by + AllocDosObject(), so we are not allowed to free it. - See the original AmigaOS autodoc if you don't believe me - */ + See the original AmigaOS autodoc if you don't believe me + */ - FreeVec(args); + FreeVec(args); #endif } if (args->RDA_Flags & RDAF_ALLOCATED_BY_READARGS) - FreeVec(args); + FreeVec(args); AROS_LIBFUNC_EXIT diff --git a/rom/dos/freedeviceproc.c b/rom/dos/freedeviceproc.c index 4c8225429e..c3cb521e9d 100644 --- a/rom/dos/freedeviceproc.c +++ b/rom/dos/freedeviceproc.c @@ -14,22 +14,22 @@ #include #include - AROS_LH1(void, FreeDeviceProc, + AROS_LH1(void, FreeDeviceProc, /* SYNOPSIS */ - AROS_LHA(struct DevProc *, dp, D1), + AROS_LHA(struct DevProc *, dp, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 108, Dos) + struct DosLibrary *, DOSBase, 108, Dos) /* FUNCTION - FreeDeviceProc() will clean up after a call to GetDeviceProc(). + FreeDeviceProc() will clean up after a call to GetDeviceProc(). INPUTS - dp - DevProc structure as returned by GetDeviceProc(). + dp - DevProc structure as returned by GetDeviceProc(). RESULT - Some memory and other resources returned to the system. + Some memory and other resources returned to the system. NOTES @@ -38,7 +38,7 @@ BUGS SEE ALSO - GetDeviceProc() + GetDeviceProc() INTERNALS @@ -48,9 +48,9 @@ if( dp ) { - if( dp->dvp_Flags & DVPF_UNLOCK ) - UnLock( dp->dvp_Lock ); - FreeMem( dp, sizeof(struct DevProc) ); + if( dp->dvp_Flags & DVPF_UNLOCK ) + UnLock( dp->dvp_Lock ); + FreeMem( dp, sizeof(struct DevProc) ); } AROS_LIBFUNC_EXIT diff --git a/rom/dos/freedosentry.c b/rom/dos/freedosentry.c index eb99771bb0..1890da9438 100644 --- a/rom/dos/freedosentry.c +++ b/rom/dos/freedosentry.c @@ -13,19 +13,19 @@ NAME */ #include - AROS_LH1(void, FreeDosEntry, + AROS_LH1(void, FreeDosEntry, /* SYNOPSIS */ - AROS_LHA(struct DosList *, dlist, D1), + AROS_LHA(struct DosList *, dlist, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 117, Dos) + struct DosLibrary *, DOSBase, 117, Dos) /* FUNCTION - Free a dos list entry created with MakeDosEntry(). + Free a dos list entry created with MakeDosEntry(). INPUTS - dlist -- pointer to dos list entry. May be NULL. + dlist -- pointer to dos list entry. May be NULL. RESULT @@ -45,10 +45,10 @@ if (dlist != NULL) { - /* It's important to free dol_Name here due to BSTR compatibility. - See MakeDosEntry() */ - FreeVec(BADDR(dlist->dol_Name)); - FreeVec(dlist); + /* It's important to free dol_Name here due to BSTR compatibility. + See MakeDosEntry() */ + FreeVec(BADDR(dlist->dol_Name)); + FreeVec(dlist); } AROS_LIBFUNC_EXIT diff --git a/rom/dos/freedosobject.c b/rom/dos/freedosobject.c index 3e4bb94624..cce966e028 100644 --- a/rom/dos/freedosobject.c +++ b/rom/dos/freedosobject.c @@ -16,21 +16,21 @@ NAME */ #include - AROS_LH2(void, FreeDosObject, + AROS_LH2(void, FreeDosObject, /* SYNOPSIS */ - AROS_LHA(ULONG, type, D1), - AROS_LHA(APTR, ptr, D2), + AROS_LHA(ULONG, type, D1), + AROS_LHA(APTR, ptr, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 39, Dos) + struct DosLibrary *, DOSBase, 39, Dos) /* FUNCTION - Frees an object allocated with AllocDosObject. + Frees an object allocated with AllocDosObject. INPUTS - type - object type. The same parameter as given to AllocDosObject(). - ptr - Pointer to object. + type - object type. The same parameter as given to AllocDosObject(). + ptr - Pointer to object. RESULT @@ -49,64 +49,64 @@ AROS_LIBFUNC_INIT if (ptr == NULL) - return; + return; switch(type) { - case DOS_FILEHANDLE: - { - struct FileHandle *fh=(struct FileHandle *)ptr; - if (fh->fh_Flags & FHF_OWNBUF) - FreeMem(BADDR(fh->fh_OrigBuf),fh->fh_BufSize); - FreeVec(fh); - break; - } - case DOS_FIB: - FreeVec(ptr); - break; - - case DOS_STDPKT: - freedospacket(ptr); - break; - - case DOS_EXALLCONTROL: - if (((struct InternalExAllControl *)ptr)->fib) - FreeDosObject(DOS_FIB, ((struct InternalExAllControl *)ptr)->fib); - - FreeVec(ptr); - break; - - case DOS_CLI: - { - struct CommandLineInterface *cli=(struct CommandLineInterface *)ptr; - BPTR *cur, *next; - cur=(BPTR *)BADDR(cli->cli_CommandDir); - FreeVec(BADDR(cli->cli_SetName)); - FreeVec(BADDR(cli->cli_CommandName)); - FreeVec(BADDR(cli->cli_CommandFile)); - FreeVec(BADDR(cli->cli_Prompt)); - FreeVec(ptr); - while(cur!=NULL) - { - next=(BPTR *)BADDR(cur[0]); - UnLock(cur[1]); - FreeVec(cur); - cur=next; - } - break; - - /* - FreeArgs() will not free a RDArgs without a RDA_DAList, - see that function for more information as to why... - */ - case DOS_RDARGS: - if(((struct RDArgs *)ptr)->RDA_DAList != 0) - FreeArgs(ptr); - else - FreeVec(ptr); - - break; - } + case DOS_FILEHANDLE: + { + struct FileHandle *fh=(struct FileHandle *)ptr; + if (fh->fh_Flags & FHF_OWNBUF) + FreeMem(BADDR(fh->fh_OrigBuf),fh->fh_BufSize); + FreeVec(fh); + break; + } + case DOS_FIB: + FreeVec(ptr); + break; + + case DOS_STDPKT: + freedospacket(ptr); + break; + + case DOS_EXALLCONTROL: + if (((struct InternalExAllControl *)ptr)->fib) + FreeDosObject(DOS_FIB, ((struct InternalExAllControl *)ptr)->fib); + + FreeVec(ptr); + break; + + case DOS_CLI: + { + struct CommandLineInterface *cli=(struct CommandLineInterface *)ptr; + BPTR *cur, *next; + cur=(BPTR *)BADDR(cli->cli_CommandDir); + FreeVec(BADDR(cli->cli_SetName)); + FreeVec(BADDR(cli->cli_CommandName)); + FreeVec(BADDR(cli->cli_CommandFile)); + FreeVec(BADDR(cli->cli_Prompt)); + FreeVec(ptr); + while(cur!=NULL) + { + next=(BPTR *)BADDR(cur[0]); + UnLock(cur[1]); + FreeVec(cur); + cur=next; + } + break; + + /* + FreeArgs() will not free a RDArgs without a RDA_DAList, + see that function for more information as to why... + */ + case DOS_RDARGS: + if(((struct RDArgs *)ptr)->RDA_DAList != 0) + FreeArgs(ptr); + else + FreeVec(ptr); + + break; + } } AROS_LIBFUNC_EXIT } /* FreeDosObject */ diff --git a/rom/dos/fs_driver.c b/rom/dos/fs_driver.c index 9462d032e0..0e39d29ada 100644 --- a/rom/dos/fs_driver.c +++ b/rom/dos/fs_driver.c @@ -20,7 +20,7 @@ LONG fs_LocateObject(BPTR *ret, struct MsgPort *port, BPTR parent, CONST_STRPTR BSTR bstrname = C2BSTR(name); if (!bstrname) - return ERROR_NO_FREE_STORE; + return ERROR_NO_FREE_STORE; *ret = (BPTR)dopacket3(DOSBase, &error, port, ACTION_LOCATE_OBJECT, parent, bstrname, accessMode); FREEC2BSTR(bstrname); @@ -54,17 +54,17 @@ LONG fs_Open(struct FileHandle *handle, struct MsgPort *port, BPTR lock, LONG mo if (!port) { - /* handler pointer not set, return NIL: handle */ - SetIoErr(0); - handle->fh_Type = BNULL; - /* NIL: is not considered interactive */ - handle->fh_Interactive = DOSFALSE; - return 0; + /* handler pointer not set, return NIL: handle */ + SetIoErr(0); + handle->fh_Type = BNULL; + /* NIL: is not considered interactive */ + handle->fh_Interactive = DOSFALSE; + return 0; } bstrname = C2BSTR(name); if (!bstrname) - return ERROR_NO_FREE_STORE; + return ERROR_NO_FREE_STORE; status = dopacket3(DOSBase, &error, port, action, MKBADDR(handle), lock, bstrname); FREEC2BSTR(bstrname); @@ -79,14 +79,14 @@ LONG fs_ReadLink(BPTR parent, struct DevProc *dvp, CONST_STRPTR path, STRPTR buf if (parent) { - struct FileLock *fl = BADDR(parent); + struct FileLock *fl = BADDR(parent); - port = fl->fl_Task; + port = fl->fl_Task; } else { - port = dvp->dvp_Port; - parent = dvp->dvp_Lock; + port = dvp->dvp_Port; + parent = dvp->dvp_Lock; } return ReadLink(port, parent, path, buffer, size); diff --git a/rom/dos/fwrite.c b/rom/dos/fwrite.c index 5bc93fb0cf..e27120984b 100644 --- a/rom/dos/fwrite.c +++ b/rom/dos/fwrite.c @@ -14,33 +14,33 @@ NAME */ #include - AROS_LH4(LONG, FWrite, + AROS_LH4(LONG, FWrite, /* FWrite -- Writes a number of blocks to an output (buffered) */ /* SYNOPSIS */ - AROS_LHA(BPTR , fh, D1), - AROS_LHA(CONST_APTR , block, D2), - AROS_LHA(ULONG, blocklen, D3), - AROS_LHA(ULONG, numblocks, D4), + AROS_LHA(BPTR , fh, D1), + AROS_LHA(CONST_APTR , block, D2), + AROS_LHA(ULONG, blocklen, D3), + AROS_LHA(ULONG, numblocks, D4), /* LOCATION */ - struct DosLibrary *, DOSBase, 55, Dos) + struct DosLibrary *, DOSBase, 55, Dos) /* FUNCTION - Write a number of blocks to a file. + Write a number of blocks to a file. INPUTS - fh - Write to this file - block - The data begins here + 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. + 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() + Open(), FRead(), FPutc(), Close() *****************************************************************************/ { diff --git a/rom/dos/getargstr.c b/rom/dos/getargstr.c index bb64298ca4..98fc42b97d 100644 --- a/rom/dos/getargstr.c +++ b/rom/dos/getargstr.c @@ -15,21 +15,21 @@ NAME */ #include - AROS_LH0(STRPTR, GetArgStr, + AROS_LH0(STRPTR, GetArgStr, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 89, Dos) + struct DosLibrary *, DOSBase, 89, Dos) /* FUNCTION - Returns a pointer to the argument string passed to the current - process at startup. + Returns a pointer to the argument string passed to the current + process at startup. INPUTS RESULT - Pointer to argument string. + Pointer to argument string. NOTES diff --git a/rom/dos/getconsoletask.c b/rom/dos/getconsoletask.c index 1e06f7f691..76bcf945dd 100644 --- a/rom/dos/getconsoletask.c +++ b/rom/dos/getconsoletask.c @@ -16,34 +16,34 @@ #include #include - AROS_LH0(struct MsgPort *, GetConsoleTask, + AROS_LH0(struct MsgPort *, GetConsoleTask, /* SYNOPSIS */ - /* void */ + /* void */ /* LOCATION */ - struct DosLibrary *, DOSBase, 85, Dos) + struct DosLibrary *, DOSBase, 85, Dos) /* FUNCTION - Return the console handler for the current Process. The return - type depends upon whether AROS is running binary compatible. + Return the console handler for the current Process. The return + type depends upon whether AROS is running binary compatible. INPUTS - None. + None. RESULT - The address of the console handler, or NULL if none is set. + 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. + 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. EXAMPLE BUGS SEE ALSO - SetConsoleTask() + SetConsoleTask() INTERNALS @@ -55,7 +55,7 @@ if (__is_task(me)) { - return NULL; + return NULL; } return (struct MsgPort *)me->pr_ConsoleTask; diff --git a/rom/dos/getcurrentdirname.c b/rom/dos/getcurrentdirname.c index 9eac3ce886..7134e5c7be 100644 --- a/rom/dos/getcurrentdirname.c +++ b/rom/dos/getcurrentdirname.c @@ -17,40 +17,40 @@ NAME */ #include - AROS_LH2(BOOL, GetCurrentDirName, + AROS_LH2(BOOL, GetCurrentDirName, /* SYNOPSIS */ - AROS_LHA(STRPTR, buf, D1), - AROS_LHA(LONG , len, D2), + AROS_LHA(STRPTR, buf, D1), + AROS_LHA(LONG , len, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 94, Dos) + struct DosLibrary *, DOSBase, 94, Dos) /* 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. + 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. + 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. + !=0 on success, 0 on failure. IoErr() gives additional information + in that case. NOTES - Documented as returning ERROR_OBJECT_WRONG_TYPE if CLI structure - is not present but actually it fallbacks to NameFromLock(). + Documented as returning ERROR_OBJECT_WRONG_TYPE if CLI structure + is not present but actually it fallbacks to NameFromLock(). EXAMPLE BUGS SEE ALSO - SetCurrentDirName() + SetCurrentDirName() INTERNALS @@ -68,15 +68,15 @@ cli = BADDR(me->pr_CLI); if (cli == NULL) - return NameFromLock(me->pr_CurrentDir, buf, len); + return NameFromLock(me->pr_CurrentDir, buf, len); cname = AROS_BSTR_ADDR(cli->cli_SetName); clen = (ULONG)AROS_BSTR_strlen(cli->cli_SetName); if (clen >= (len-1)) { - clen = len-1; - me->pr_Result2 = ERROR_LINE_TOO_LONG; - ret = DOSFALSE; + clen = len-1; + me->pr_Result2 = ERROR_LINE_TOO_LONG; + ret = DOSFALSE; } CopyMem(cname, buf, clen); buf[clen] = '\0'; diff --git a/rom/dos/getdeviceproc.c b/rom/dos/getdeviceproc.c index b00ac249f4..9b59f30da8 100644 --- a/rom/dos/getdeviceproc.c +++ b/rom/dos/getdeviceproc.c @@ -21,43 +21,43 @@ static struct DevProc *deviceproc_internal(struct DosLibrary *DOSBase, CONST_STR NAME */ #include - AROS_LH2(struct DevProc *, GetDeviceProc, + AROS_LH2(struct DevProc *, GetDeviceProc, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(struct DevProc *, dp, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(struct DevProc *, dp, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 107, Dos) + struct DosLibrary *, DOSBase, 107, Dos) /* FUNCTION - GetDeviceProc() will search for the filesystem handler which - you should send a command to for a specific path. + 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. + 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. + 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. + 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. + A pointer to a DevProc structure containing the information + required to send a command to a filesystem. NOTES EXAMPLE BUGS - Currently doesn't return dvp_DevNode for locks which are - relative to "PROGDIR:", ":", or the current directory. + Currently doesn't return dvp_DevNode for locks which are + relative to "PROGDIR:", ":", or the current directory. SEE ALSO - FreeDeviceProc() + FreeDeviceProc() INTERNALS @@ -118,7 +118,7 @@ static struct DevProc *deviceproc_internal(struct DosLibrary *DOSBase, CONST_STR dl = dp->dvp_DevNode; /* lock the dos list here, to match the result of the next block */ - LockDosList(LDF_ALL | LDF_READ); + LockDosList(LDF_ALL | LDF_READ); } /* otherwise we need to find a place to start in the doslist based on the @@ -131,25 +131,25 @@ static struct DevProc *deviceproc_internal(struct DosLibrary *DOSBase, CONST_STR } /* something real, work out what it's relative to */ - if (Strnicmp(name, "PROGDIR:", 8) == 0) { - lock = pr->pr_HomeDir; - /* I am not sure if these are correct but AOS does return - * non-NULL PROGDIR: handle even if pr_HomeDir is cleared */ - if (!lock) - lock = pr->pr_CurrentDir; - if (lock) { + if (Strnicmp(name, "PROGDIR:", 8) == 0) { + lock = pr->pr_HomeDir; + /* I am not sure if these are correct but AOS does return + * non-NULL PROGDIR: handle even if pr_HomeDir is cleared */ + if (!lock) + lock = pr->pr_CurrentDir; + if (lock) { fl = BADDR(lock); dp->dvp_Port = fl->fl_Task; dp->dvp_Lock = lock; dp->dvp_DevNode = BADDR(fl->fl_Volume); } else { - dp->dvp_Port = DOSBase->dl_Root->rn_BootProc; - dp->dvp_Lock = BNULL; + dp->dvp_Port = DOSBase->dl_Root->rn_BootProc; + dp->dvp_Lock = BNULL; dp->dvp_DevNode = NULL; } dp->dvp_Flags = 0; return dp; - } + } /* extract the volume name */ len = SplitName(name, ':', vol, 0, sizeof(vol) - 1); @@ -164,8 +164,8 @@ static struct DevProc *deviceproc_internal(struct DosLibrary *DOSBase, CONST_STR dp->dvp_Lock = lock; dp->dvp_DevNode = BADDR(fl->fl_Volume); } else { - dp->dvp_Port = DOSBase->dl_Root->rn_BootProc; - dp->dvp_Lock = BNULL; + dp->dvp_Port = DOSBase->dl_Root->rn_BootProc; + dp->dvp_Lock = BNULL; dp->dvp_DevNode = NULL; } @@ -251,56 +251,56 @@ static struct DevProc *deviceproc_internal(struct DosLibrary *DOSBase, CONST_STR /* devices and volumes are easy */ if (dl->dol_Type == DLT_DEVICE || dl->dol_Type == DLT_VOLUME) { - struct MsgPort *newhandler = NULL; - - if (dl->dol_Type == DLT_DEVICE) - { - /* Check if the handler is not started */ - newhandler = dl->dol_Task; - if (!newhandler) - { - D(bug("[GetDeviceProc] Accessing device '%b', path='%s'\n", dl->dol_Name, origname)); - - /* - * Unlock before starting handler, handler may internally - * require dos list locks, for example to add volume node. - */ - UnLockDosList(LDF_ALL | LDF_READ); - - newhandler = RunHandler((struct DeviceNode *)dl, origname, DOSBase); - if (!newhandler) - { - FreeMem(dp, sizeof(struct DevProc)); - SetIoErr(ERROR_DEVICE_NOT_MOUNTED); - return NULL; - } - - LockDosList(LDF_ALL | LDF_READ); - } - } - else - { - res = TRUE; - - while (res && !dl->dol_Task) - { - D(bug("[GetDeviceProc] Accessing offline volume '%b'\n", dl->dol_Name)); - res = !ErrorReport(ERROR_DEVICE_NOT_MOUNTED, REPORT_VOLUME, (IPTR)dl, NULL); - } - - if (!res) - { - UnLockDosList(LDF_ALL | LDF_READ); - FreeMem(dp, sizeof(struct DevProc)); - SetIoErr(ERROR_DEVICE_NOT_MOUNTED); - return NULL; + struct MsgPort *newhandler = NULL; + + if (dl->dol_Type == DLT_DEVICE) + { + /* Check if the handler is not started */ + newhandler = dl->dol_Task; + if (!newhandler) + { + D(bug("[GetDeviceProc] Accessing device '%b', path='%s'\n", dl->dol_Name, origname)); + + /* + * Unlock before starting handler, handler may internally + * require dos list locks, for example to add volume node. + */ + UnLockDosList(LDF_ALL | LDF_READ); + + newhandler = RunHandler((struct DeviceNode *)dl, origname, DOSBase); + if (!newhandler) + { + FreeMem(dp, sizeof(struct DevProc)); + SetIoErr(ERROR_DEVICE_NOT_MOUNTED); + return NULL; + } + + LockDosList(LDF_ALL | LDF_READ); + } + } + else + { + res = TRUE; + + while (res && !dl->dol_Task) + { + D(bug("[GetDeviceProc] Accessing offline volume '%b'\n", dl->dol_Name)); + res = !ErrorReport(ERROR_DEVICE_NOT_MOUNTED, REPORT_VOLUME, (IPTR)dl, NULL); } - } - /* - * A handler theoretically may choose to use custom MsgPort for communications. - * Pick up its preference if specified. - */ + if (!res) + { + UnLockDosList(LDF_ALL | LDF_READ); + FreeMem(dp, sizeof(struct DevProc)); + SetIoErr(ERROR_DEVICE_NOT_MOUNTED); + return NULL; + } + } + + /* + * A handler theoretically may choose to use custom MsgPort for communications. + * Pick up its preference if specified. + */ dp->dvp_Port = dl->dol_Task ? dl->dol_Task : newhandler; dp->dvp_Lock = BNULL; dp->dvp_Flags = 0; diff --git a/rom/dos/getfilesystask.c b/rom/dos/getfilesystask.c index bddc129543..c525286052 100644 --- a/rom/dos/getfilesystask.c +++ b/rom/dos/getfilesystask.c @@ -16,22 +16,22 @@ #include #include - AROS_LH0(struct MsgPort *, GetFileSysTask, + AROS_LH0(struct MsgPort *, GetFileSysTask, /* SYNOPSIS */ - /* void */ + /* void */ /* LOCATION */ - struct DosLibrary *, DOSBase, 87, Dos) + struct DosLibrary *, DOSBase, 87, Dos) /* FUNCTION - Return the default filesystem handler for this process. + Return the default filesystem handler for this process. INPUTS - None. + None. RESULT - The default filesystem handler for this process. + The default filesystem handler for this process. NOTES @@ -40,7 +40,7 @@ BUGS SEE ALSO - SetFileSysTask() + SetFileSysTask() INTERNALS diff --git a/rom/dos/getprogramdir.c b/rom/dos/getprogramdir.c index 3123d43c82..2f057cf3f9 100644 --- a/rom/dos/getprogramdir.c +++ b/rom/dos/getprogramdir.c @@ -15,28 +15,28 @@ NAME */ #include - AROS_LH0(BPTR, GetProgramDir, + AROS_LH0(BPTR, GetProgramDir, /* SYNOPSIS */ - /* void */ + /* void */ /* LOCATION */ - struct DosLibrary *, DOSBase, 100, Dos) + struct DosLibrary *, DOSBase, 100, Dos) /* 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. + 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. + 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. + You should NOT under any circumstance UnLock() this lock. INPUTS RESULT - A shared lock on the directory the program was started from. + A shared lock on the directory the program was started from. NOTES diff --git a/rom/dos/getprogramname.c b/rom/dos/getprogramname.c index afeb404f5d..58a2151fec 100644 --- a/rom/dos/getprogramname.c +++ b/rom/dos/getprogramname.c @@ -17,29 +17,29 @@ NAME */ #include - AROS_LH2(BOOL, GetProgramName, + AROS_LH2(BOOL, GetProgramName, /* SYNOPSIS */ - AROS_LHA(STRPTR, buf, D1), - AROS_LHA(LONG , len, D2), + AROS_LHA(STRPTR, buf, D1), + AROS_LHA(LONG , len, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 96, Dos) + struct DosLibrary *, DOSBase, 96, Dos) /* 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. + 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. + 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. + !=0 on success, 0 on failure. IoErr() gives additional information + in that case. NOTES @@ -48,7 +48,7 @@ BUGS SEE ALSO - SetProgramName() + SetProgramName() INTERNALS @@ -67,18 +67,18 @@ cli = BADDR(me->pr_CLI); if (cli == NULL) { - *buf = '\0'; - me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE; - return DOSFALSE; + *buf = '\0'; + me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE; + return DOSFALSE; } cname = AROS_BSTR_ADDR(cli->cli_CommandName); clen = (ULONG)AROS_BSTR_strlen(cli->cli_CommandName); if (clen >= (len-1)) { - clen = len-1; - me->pr_Result2 = ERROR_LINE_TOO_LONG; - ret = DOSFALSE; + clen = len-1; + me->pr_Result2 = ERROR_LINE_TOO_LONG; + ret = DOSFALSE; } CopyMem(cname, buf, clen); buf[clen] = '\0'; diff --git a/rom/dos/getprompt.c b/rom/dos/getprompt.c index 2774cd3d61..7c0ab522af 100644 --- a/rom/dos/getprompt.c +++ b/rom/dos/getprompt.c @@ -17,28 +17,28 @@ NAME */ #include - AROS_LH2(BOOL, GetPrompt, + AROS_LH2(BOOL, GetPrompt, /* SYNOPSIS */ - AROS_LHA(STRPTR, buf, D1), - AROS_LHA(LONG , len, D2), + AROS_LHA(STRPTR, buf, D1), + AROS_LHA(LONG , len, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 98, Dos) + struct DosLibrary *, DOSBase, 98, Dos) /* 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. + 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. + 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. + !=0 on success, 0 on failure. IoErr() gives additional information + in that case. NOTES @@ -47,7 +47,7 @@ BUGS SEE ALSO - SetPrompt() + SetPrompt() INTERNALS @@ -65,19 +65,19 @@ if (cli == NULL) { - if (len >= 1) - buf[0] = '\0'; - me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE; - return DOSFALSE; + if (len >= 1) + buf[0] = '\0'; + me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE; + return DOSFALSE; } cname = AROS_BSTR_ADDR(cli->cli_Prompt); clen = (ULONG)AROS_BSTR_strlen(cli->cli_Prompt); if (clen >= (len-1)) { - clen = len-1; - me->pr_Result2 = ERROR_LINE_TOO_LONG; - ret = DOSFALSE; + clen = len-1; + me->pr_Result2 = ERROR_LINE_TOO_LONG; + ret = DOSFALSE; } CopyMem(cname, buf, clen); buf[clen] = '\0'; diff --git a/rom/dos/getvar.c b/rom/dos/getvar.c index e467a24e67..f213b4b22b 100644 --- a/rom/dos/getvar.c +++ b/rom/dos/getvar.c @@ -92,100 +92,100 @@ static LONG getvar_from(const char *name, const char *volume, STRPTR buffer, LON AROS_LIBFUNC_INIT D(bug("GetVar: name = \"%s\", buffer = $%lx, size = %ld, flags = $%lx\n", - name, buffer, size, flags)); + name, buffer, size, flags)); if (0 == size) { - D(bug("GetVar: bad size\n")); + D(bug("GetVar: bad size\n")); - SetIoErr(ERROR_BAD_NUMBER); + SetIoErr(ERROR_BAD_NUMBER); - return 0; + return 0; } if (name && buffer) { - /* not global only? */ - if(0 == (flags & GVF_GLOBAL_ONLY)) - { - /* look for a local variable */ - struct LocalVar *lv; - - D(bug("GetVar: Local variable\n")); - /* look for a variable of the given name */ - lv = FindVar(name, flags); - - if (lv) - { - int i; - /* which size is shorter: the buffer or the size of - the value? */ - i = (size < lv->lv_Len) ? size : lv->lv_Len; - CopyMem(lv->lv_Value, buffer, i); - - /* were we supposed to stop after the first "\n"? - = No GVF_BINARY_VAR and no GVF_DONT_NULL_TERM - */ - if (0 == (flags & GVF_BINARY_VAR)) - { - int j = 0; - - while ((buffer[j] != '\n') && (j < i)) - { - j++; - } - - if (j == size) - { - j = size - 1; - } - - buffer[j]= 0x0; /* mark end of string */ - size = j; - } - else if (0 == (flags & GVF_DONT_NULL_TERM)) - { - if (i == size) - { - i = size - 1; - } - - buffer[i] = 0x0; /* mark end of string */ - size = i; - } - else - { - size = i; - } - - SetIoErr(lv->lv_Len); - D(bug("GetVar: return %d\n", size)); - - return size; - } /* Got lv */ - } /* !global only */ - - /****** GLOBAL VARIABLE TREATMENT ******/ - - if ((flags & 0xff) == LV_VAR && !(flags & GVF_LOCAL_ONLY)) - { - LONG ret; - - /* as standard: look for the file in ENV: if no path is - * given in the variable - */ - ret = getvar_from(name, "ENV:", buffer, size, flags, DOSBase); - - if (ret >= 0) - return ret; - - /* If not found in ENV:, look in ENVARC: */ - ret = getvar_from(name, "ENVARC:", buffer, size, flags, DOSBase); - - if (ret >= 0) - return ret; - - } /* ! local file only */ + /* not global only? */ + if(0 == (flags & GVF_GLOBAL_ONLY)) + { + /* look for a local variable */ + struct LocalVar *lv; + + D(bug("GetVar: Local variable\n")); + /* look for a variable of the given name */ + lv = FindVar(name, flags); + + if (lv) + { + int i; + /* which size is shorter: the buffer or the size of + the value? */ + i = (size < lv->lv_Len) ? size : lv->lv_Len; + CopyMem(lv->lv_Value, buffer, i); + + /* were we supposed to stop after the first "\n"? + = No GVF_BINARY_VAR and no GVF_DONT_NULL_TERM + */ + if (0 == (flags & GVF_BINARY_VAR)) + { + int j = 0; + + while ((buffer[j] != '\n') && (j < i)) + { + j++; + } + + if (j == size) + { + j = size - 1; + } + + buffer[j]= 0x0; /* mark end of string */ + size = j; + } + else if (0 == (flags & GVF_DONT_NULL_TERM)) + { + if (i == size) + { + i = size - 1; + } + + buffer[i] = 0x0; /* mark end of string */ + size = i; + } + else + { + size = i; + } + + SetIoErr(lv->lv_Len); + D(bug("GetVar: return %d\n", size)); + + return size; + } /* Got lv */ + } /* !global only */ + + /****** GLOBAL VARIABLE TREATMENT ******/ + + if ((flags & 0xff) == LV_VAR && !(flags & GVF_LOCAL_ONLY)) + { + LONG ret; + + /* as standard: look for the file in ENV: if no path is + * given in the variable + */ + ret = getvar_from(name, "ENV:", buffer, size, flags, DOSBase); + + if (ret >= 0) + return ret; + + /* If not found in ENV:, look in ENVARC: */ + ret = getvar_from(name, "ENVARC:", buffer, size, flags, DOSBase); + + if (ret >= 0) + return ret; + + } /* ! local file only */ } /* name and buffer */ D(bug("GetVar: not found\n")); @@ -215,64 +215,64 @@ static LONG getvar_from(const char *name, const char *volume, STRPTR buffer, LON if (file) /* file could be opened */ { - ULONG fSize; - struct FileInfoBlock fib; - - if (ExamineFH(file, &fib)) - { - /* fSize now contains the size of variable. */ - fSize = fib.fib_Size; - } - else - { - D(bug("GetVar: can't find size\n")); - - return -1; - } - - /* We return the number of bytes actually read. */ - i = Read(file, buffer, size); - Close(file); - - /* were we supposed to stop after the first "\n"? - = No GVF_BINARY_VAR and no GVF_DONT_NULL_TERM */ - if (0 == (flags & GVF_BINARY_VAR)) - { - int j = 0; - /* lets search for the first '\n' (if any) in the - * string and replace it by '\0'. */ - while ((buffer[j] != '\n') && (j < i)) - { - j++; - } + ULONG fSize; + struct FileInfoBlock fib; + + if (ExamineFH(file, &fib)) + { + /* fSize now contains the size of variable. */ + fSize = fib.fib_Size; + } + else + { + D(bug("GetVar: can't find size\n")); + + return -1; + } + + /* We return the number of bytes actually read. */ + i = Read(file, buffer, size); + Close(file); + + /* were we supposed to stop after the first "\n"? + = No GVF_BINARY_VAR and no GVF_DONT_NULL_TERM */ + if (0 == (flags & GVF_BINARY_VAR)) + { + int j = 0; + /* lets search for the first '\n' (if any) in the + * string and replace it by '\0'. */ + while ((buffer[j] != '\n') && (j < i)) + { + j++; + } - if (j == size) - { - j = size - 1; - } - - buffer[j]= '\0'; /* mark end of string */ - size = j; - } - else if (0 == (flags & GVF_DONT_NULL_TERM)) - { - if (i == size) - { - i = size - 1; - } - - buffer[i] = 0x0; /* mark end of string */ - size = i; - } - else - { - size = i; - } - - SetIoErr(fSize); - D(bug("GetVar: return %d\n", size)); - - return size; + if (j == size) + { + j = size - 1; + } + + buffer[j]= '\0'; /* mark end of string */ + size = j; + } + else if (0 == (flags & GVF_DONT_NULL_TERM)) + { + if (i == size) + { + i = size - 1; + } + + buffer[i] = 0x0; /* mark end of string */ + size = i; + } + else + { + size = i; + } + + SetIoErr(fSize); + D(bug("GetVar: return %d\n", size)); + + return size; } /* open(file) */ return -1; diff --git a/rom/dos/include/loadseg.h b/rom/dos/include/loadseg.h index 698464b34d..c261e319c2 100644 --- a/rom/dos/include/loadseg.h +++ b/rom/dos/include/loadseg.h @@ -26,12 +26,12 @@ AROS_LD4(BPTR, InternalLoadSeg, * There's no counterpart since the loaded seglist can be freed by * conventional IntrernalUnloadSeg(), even on old AmigaOS. */ -#define LoadSegment(fh, table, funcarray, stack) \ - AROS_CALL4(BPTR, AROS_SLIB_ENTRY(InternalLoadSeg, Dos, 126), \ - AROS_LCA(BPTR , fh , D0), \ - AROS_LDA(BPTR , table , A0), \ - AROS_LDA(LONG_FUNC *, funcarray , A1), \ - AROS_LDA(LONG * , stack , A2), \ - struct DosLibrary *, DOSBase) +#define LoadSegment(fh, table, funcarray, stack) \ + AROS_CALL4(BPTR, AROS_SLIB_ENTRY(InternalLoadSeg, Dos, 126), \ + AROS_LCA(BPTR , fh , D0), \ + AROS_LDA(BPTR , table , A0), \ + AROS_LDA(LONG_FUNC *, funcarray , A1), \ + AROS_LDA(LONG * , stack , A2), \ + struct DosLibrary *, DOSBase) #endif /* LOADSEG_LOADSEG_H */ diff --git a/rom/dos/info.c b/rom/dos/info.c index 0c3d93b947..fc456586f8 100644 --- a/rom/dos/info.c +++ b/rom/dos/info.c @@ -15,14 +15,14 @@ #include - AROS_LH2(LONG, Info, + AROS_LH2(LONG, Info, /* SYNOPSIS */ - AROS_LHA(BPTR , lock, D1), - AROS_LHA(struct InfoData *, parameterBlock, D2), + AROS_LHA(BPTR , lock, D1), + AROS_LHA(struct InfoData *, parameterBlock, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 19, Dos) + struct DosLibrary *, DOSBase, 19, Dos) /* FUNCTION diff --git a/rom/dos/inhibit.c b/rom/dos/inhibit.c index b77e2cf99a..2d553d1c39 100644 --- a/rom/dos/inhibit.c +++ b/rom/dos/inhibit.c @@ -11,14 +11,14 @@ NAME */ #include - AROS_LH2(LONG, Inhibit, + AROS_LH2(LONG, Inhibit, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(LONG, onoff, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(LONG, onoff, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 121, Dos) + struct DosLibrary *, DOSBase, 121, Dos) /* FUNCTION @@ -55,7 +55,7 @@ LONG status = DOSFALSE; if (!getdevpacketinfo(DOSBase, name, NULL, &phs)) - return DOSFALSE; + return DOSFALSE; status = dopacket1(DOSBase, NULL, phs.port, ACTION_INHIBIT, onoff); diff --git a/rom/dos/input.c b/rom/dos/input.c index 634e529ee7..4617733c39 100644 --- a/rom/dos/input.c +++ b/rom/dos/input.c @@ -15,21 +15,21 @@ NAME */ #include - AROS_LH0(BPTR, Input, + AROS_LH0(BPTR, Input, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 9, Dos) + struct DosLibrary *, DOSBase, 9, Dos) /* FUNCTION - Returns the current input stream or 0 if there is no current - input stream. + Returns the current input stream or 0 if there is no current + input stream. INPUTS RESULT - Input stream handle. + Input stream handle. NOTES diff --git a/rom/dos/internalflush.c b/rom/dos/internalflush.c index ee3992e9eb..39d5a72019 100644 --- a/rom/dos/internalflush.c +++ b/rom/dos/internalflush.c @@ -26,19 +26,19 @@ LONG InternalFlush( struct FileHandle *fh, struct DosLibrary *DOSBase ) while( position < fh->fh_Pos ) { - LONG size; + LONG size; - size = Write( MKBADDR(fh), BADDR(fh->fh_Buf) + position, fh->fh_Pos - position ); + size = Write( MKBADDR(fh), BADDR(fh->fh_Buf) + position, fh->fh_Pos - position ); - /* An error happened? No success. */ - if( size < 0 ) - { - fh->fh_Flags &= ~FHF_WRITE; + /* An error happened? No success. */ + if( size < 0 ) + { + fh->fh_Flags &= ~FHF_WRITE; - return FALSE; - } + return FALSE; + } - position += size; + position += size; } /* Reset the buffer. */ diff --git a/rom/dos/internalloadseg.c b/rom/dos/internalloadseg.c index 5e65477b18..36380ae4ee 100644 --- a/rom/dos/internalloadseg.c +++ b/rom/dos/internalloadseg.c @@ -74,7 +74,7 @@ typedef struct _segfunc_t { - ULONG id; + ULONG id; BPTR (*func)(BPTR, BPTR, SIPTR *, LONG *, struct DosLibrary *); D(CONST_STRPTR format;) } segfunc_t; @@ -92,23 +92,23 @@ if (fh) { UBYTE i; - const UBYTE num_funcs = sizeof(funcs) / sizeof(funcs[0]); - ULONG id; - LONG len; - - len = ilsRead(fh, &id, sizeof(id)); - if (len == sizeof(id)) { - id = AROS_BE2LONG(id); - for (i = 0; i < num_funcs; i++) { - if (funcs[i].id == id) { - segs = (*funcs[i].func)(fh, BNULL, (SIPTR *)funcarray, - stack, DOSBase); - D(bug("[InternalLoadSeg] %s loading %p as an %s object.\n", - segs ? "Succeeded" : "FAILED", fh, funcs[i].format)); - return segs; - } - } - } + const UBYTE num_funcs = sizeof(funcs) / sizeof(funcs[0]); + ULONG id; + LONG len; + + len = ilsRead(fh, &id, sizeof(id)); + if (len == sizeof(id)) { + id = AROS_BE2LONG(id); + for (i = 0; i < num_funcs; i++) { + if (funcs[i].id == id) { + segs = (*funcs[i].func)(fh, BNULL, (SIPTR *)funcarray, + stack, DOSBase); + D(bug("[InternalLoadSeg] %s loading %p as an %s object.\n", + segs ? "Succeeded" : "FAILED", fh, funcs[i].format)); + return segs; + } + } + } } /* This routine can be called from partition.library, when @@ -158,8 +158,8 @@ APTR _ilsAllocVec(SIPTR *funcarray, ULONG size, ULONG req) D(bug("allocmem %p %d\n", p, size)); if (!p) - return NULL; - + return NULL; + /* Note that the result is ULONG-aligned even on 64 bits! */ *((ULONG*)p) = (ULONG)size; return p + sizeof(ULONG); @@ -170,12 +170,12 @@ void _ilsFreeVec(SIPTR *funcarray, void *buf) UBYTE *p = (UBYTE*)buf; ULONG size; if (!buf) - return; + return; p -= sizeof(ULONG); size = ((ULONG*)p)[0]; D(bug("freemem %p %d\n", p, size)); if (!size) - return; + return; ilsFreeMem(p, size); } diff --git a/rom/dos/internalloadseg.h b/rom/dos/internalloadseg.h index d3a35f1113..af45ef9305 100644 --- a/rom/dos/internalloadseg.h +++ b/rom/dos/internalloadseg.h @@ -39,7 +39,7 @@ void _ilsFreeVec(SIPTR *funcarray, void *buf); AROS_UFCA(ULONG, size, D0), \ AROS_UFCA(ULONG, flags, D1), \ AROS_UFCA(struct ExecBase *, SysBase, A6) \ - ) + ) #define ilsFreeMem(addr, size) \ AROS_UFC3NR \ diff --git a/rom/dos/internalloadseg_aos.c b/rom/dos/internalloadseg_aos.c index cfafa8646c..42d81781f5 100644 --- a/rom/dos/internalloadseg_aos.c +++ b/rom/dos/internalloadseg_aos.c @@ -43,7 +43,7 @@ static int seek_forward(BPTR fd, ULONG count, SIPTR *funcarray, struct DosLibrar * read ahead. */ while (count && !(err = read_block(fd, &tmp, sizeof(tmp), funcarray, DOSBase))) - count--; + count--; return err; } @@ -239,11 +239,11 @@ BPTR InternalLoadSeg_AOS(BPTR fh, segtypes[(hunktype & 0xFFFFFF)-HUNK_CODE], curhunk, count*4)); if ((hunktype & 0xFFFFFF) != HUNK_BSS && count) - { + { if (read_block(fh, GETHUNKPTR(curhunk), count*4, funcarray, DOSBase)) goto end; - } + } lasthunk = curhunk; ++curhunk; @@ -303,10 +303,10 @@ BPTR InternalLoadSeg_AOS(BPTR fh, while (1) { ULONG *addr; - UWORD word; - - Wordcount++; - + UWORD word; + + Wordcount++; + if (read_block(fh, &word, sizeof(word), funcarray, DOSBase)) goto end; if (word == 0L) @@ -315,13 +315,13 @@ BPTR InternalLoadSeg_AOS(BPTR fh, word = AROS_BE2LONG(word); i = word; - Wordcount++; + Wordcount++; if (read_block(fh, &word, sizeof(word), funcarray, DOSBase)) goto end; word = AROS_BE2WORD(word); - count = word; + count = word; D(bug("\tHunk #%ld @%p: %ld relocations\n", count, GETHUNKPTR(lasthunk), i)); while (i > 0) { @@ -448,13 +448,13 @@ done: */ if (SysBase->LibNode.lib_Version >= 36) { - /* Clear caches */ - for (t = first; t < numhunks && t <= last; t++) - { - hunksize = *((ULONG*)BADDR(hunktab[t]) - 1); - if (hunksize) - CacheClearE(BADDR(hunktab[t]), hunksize, CACRF_ClearI | CACRF_ClearD); - } + /* Clear caches */ + for (t = first; t < numhunks && t <= last; t++) + { + hunksize = *((ULONG*)BADDR(hunktab[t]) - 1); + if (hunksize) + CacheClearE(BADDR(hunktab[t]), hunksize, CACRF_ClearI | CACRF_ClearD); + } } #endif @@ -506,9 +506,9 @@ end: #ifdef __mc68000 static AROS_UFH4(LONG, ReadFunc, - AROS_UFHA(BPTR, file, D1), - AROS_UFHA(APTR, buffer, D2), - AROS_UFHA(LONG, length, D3), + AROS_UFHA(BPTR, file, D1), + AROS_UFHA(APTR, buffer, D2), + AROS_UFHA(LONG, length, D3), AROS_UFHA(struct DosLibrary *, DOSBase, A6) ) { @@ -520,8 +520,8 @@ static AROS_UFH4(LONG, ReadFunc, } static AROS_UFH3(APTR, AllocFunc, - AROS_UFHA(ULONG, length, D0), - AROS_UFHA(ULONG, flags, D1), + AROS_UFHA(ULONG, length, D0), + AROS_UFHA(ULONG, flags, D1), AROS_UFHA(struct ExecBase *, SysBase, A6) ) { @@ -533,8 +533,8 @@ static AROS_UFH3(APTR, AllocFunc, } static AROS_UFH3(void, FreeFunc, - AROS_UFHA(APTR, buffer, A1), - AROS_UFHA(ULONG, length, D0), + AROS_UFHA(APTR, buffer, A1), + AROS_UFHA(ULONG, length, D0), AROS_UFHA(struct ExecBase *, SysBase, A6) ) { @@ -562,10 +562,10 @@ AROS_UFH4(BPTR, LoadSeg_Overlay, D(bug("LoadSeg_Overlay. table=%x fh=%x\n", hunktable, fh)); if (read_block(fh, &hunktype, sizeof(hunktype), (SIPTR*)FunctionArray, DosBase)) - return BNULL; + return BNULL; hunktype = AROS_BE2LONG(hunktype); if (hunktype != HUNK_HEADER) - return BNULL; + return BNULL; return InternalLoadSeg_AOS(fh, hunktable, (SIPTR*)FunctionArray, NULL, DosBase); AROS_USERFUNC_EXIT diff --git a/rom/dos/internalloadseg_elf.c b/rom/dos/internalloadseg_elf.c index 01868dbeb1..07069b0e31 100644 --- a/rom/dos/internalloadseg_elf.c +++ b/rom/dos/internalloadseg_elf.c @@ -611,13 +611,13 @@ static inline ULONG readlong_unaligned(ULONG *src) ULONG res, tmp; asm volatile( - "ldrb %0, [%2, #0]\n\t" - "ldrb %1, [%2, #1]\n\t" - "orr %0, %0, %1, lsl #8\n\t" - "ldrb %1, [%2, #2]\n\t" - "orr %0, %0, %1, lsl #16\n\t" - "ldrb %1, [%2, #3]\n\t" - "orr %0, %0, %1, lsl #24" + "ldrb %0, [%2, #0]\n\t" + "ldrb %1, [%2, #1]\n\t" + "orr %0, %0, %1, lsl #8\n\t" + "ldrb %1, [%2, #2]\n\t" + "orr %0, %0, %1, lsl #16\n\t" + "ldrb %1, [%2, #3]\n\t" + "orr %0, %0, %1, lsl #24" :"=&r"(res), "=&r"(tmp) : "r"(src) ); diff --git a/rom/dos/internalseek.c b/rom/dos/internalseek.c index 5968acc5ef..ec066e04ec 100644 --- a/rom/dos/internalseek.c +++ b/rom/dos/internalseek.c @@ -23,9 +23,9 @@ LONG InternalSeek ASSERT_VALID_PTR( fh ); ASSERT ( - mode == OFFSET_BEGINNING - || mode == OFFSET_END - || mode == OFFSET_CURRENT + mode == OFFSET_BEGINNING + || mode == OFFSET_END + || mode == OFFSET_CURRENT ); D(bug("[seek] %x:%d:%d\n", fh, position, mode)); do { diff --git a/rom/dos/internalunloadseg.c b/rom/dos/internalunloadseg.c index d49a1e548b..5cbb367a3b 100644 --- a/rom/dos/internalunloadseg.c +++ b/rom/dos/internalunloadseg.c @@ -30,14 +30,14 @@ struct DosLibrary *, DOSBase, 127, Dos) /* FUNCTION - Unloads a seglist loaded with InternalLoadSeg(). + Unloads a seglist loaded with InternalLoadSeg(). INPUTS - seglist - Seglist - freefunc - Function to be called to free memory + seglist - Seglist + freefunc - Function to be called to free memory RESULT - DOSTRUE if everything wents O.K. + DOSTRUE if everything wents O.K. NOTES @@ -58,32 +58,32 @@ if (seglist) { - if (DebugBase) - UnregisterModule(seglist); + if (DebugBase) + UnregisterModule(seglist); #ifdef __mc68000 - { - /* free overlay structures */ - ULONG *seg = BADDR(seglist); - if (seg[2] == 0x0000abcd && seg[6] == (ULONG)DOSBase->dl_GV) { - Close((BPTR)seg[3]); /* file handle */ - ilsFreeVec((void*)seg[4]); /* overlay table, APTR */ - ilsFreeVec(BADDR(seg[5])); /* hunk table, BPTR */ - } - } + { + /* free overlay structures */ + ULONG *seg = BADDR(seglist); + if (seg[2] == 0x0000abcd && seg[6] == (ULONG)DOSBase->dl_GV) { + Close((BPTR)seg[3]); /* file handle */ + ilsFreeVec((void*)seg[4]); /* overlay table, APTR */ + ilsFreeVec(BADDR(seg[5])); /* hunk table, BPTR */ + } + } #endif - while (seglist) - { - next = *(BPTR *)BADDR(seglist); - ilsFreeVec(BADDR(seglist)); - seglist = next; - } + while (seglist) + { + next = *(BPTR *)BADDR(seglist); + ilsFreeVec(BADDR(seglist)); + seglist = next; + } - return DOSTRUE; + return DOSTRUE; } else - return DOSFALSE; + return DOSFALSE; AROS_LIBFUNC_EXIT } /* InternalUnLoadSeg */ diff --git a/rom/dos/ioerr.c b/rom/dos/ioerr.c index 821d8ad200..9dcb042d68 100644 --- a/rom/dos/ioerr.c +++ b/rom/dos/ioerr.c @@ -15,20 +15,20 @@ NAME */ #include - AROS_LH0(SIPTR, IoErr, + AROS_LH0(SIPTR, IoErr, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 22, Dos) + struct DosLibrary *, DOSBase, 22, Dos) /* FUNCTION - Get the dos error code for the current process. + Get the dos error code for the current process. INPUTS RESULT - Error code. + Error code. NOTES diff --git a/rom/dos/isbootable.c b/rom/dos/isbootable.c index 290dc063c4..acbdec6a0c 100644 --- a/rom/dos/isbootable.c +++ b/rom/dos/isbootable.c @@ -34,14 +34,14 @@ BOOL __dos_IsBootable(struct DosLibrary * DOSBase, BPTR lock) if (!fh) { #ifdef __mc68000 - /* - * Original Amiga disks don't contain this signature. They are obviously bootable on m68k. - * However if the disk DOES contain a signature, we should check it. This can happen to be - * a disk for another architecture. Attempting to boot from it will cause crash. - */ - return TRUE; + /* + * Original Amiga disks don't contain this signature. They are obviously bootable on m68k. + * However if the disk DOES contain a signature, we should check it. This can happen to be + * a disk for another architecture. Attempting to boot from it will cause crash. + */ + return TRUE; #else - return FALSE; + return FALSE; #endif } @@ -50,30 +50,30 @@ BOOL __dos_IsBootable(struct DosLibrary * DOSBase, BPTR lock) abfile_fib = AllocDosObject(DOS_FIB, NULL); if (abfile_fib) { - if (ExamineFH(fh, abfile_fib)) - { - LONG readsize; + if (ExamineFH(fh, abfile_fib)) + { + LONG readsize; bufferLength = abfile_fib->fib_Size + 1; buffer = AllocMem(bufferLength, MEMF_ANY); D(bug("[__dos_IsBootable] Allocated %d bytes for Buffer @ %p\n", bufferLength, buffer)); - if (!buffer) + if (!buffer) { - Alert(AT_DeadEnd | AG_NoMemory | AN_DOSLib); + Alert(AT_DeadEnd | AG_NoMemory | AN_DOSLib); } - readsize = Read(fh, buffer, bufferLength - 1); - if (readsize > 0) + readsize = Read(fh, buffer, bufferLength - 1); + if (readsize > 0) { - char *sigptr = NULL; + char *sigptr = NULL; buffer[readsize] = '\0'; - D(bug("[__dos_IsBootable] Buffer contains '%s'\n", buffer)); + D(bug("[__dos_IsBootable] Buffer contains '%s'\n", buffer)); - if ((sigptr = strstr(buffer, AROS_CPU)) != 0) - { + if ((sigptr = strstr(buffer, AROS_CPU)) != 0) + { D(bug("[__dos_IsBootable] Signature '%s' found\n", AROS_CPU)); result = TRUE; } @@ -100,10 +100,10 @@ BOOL __dos_IsBootable(struct DosLibrary * DOSBase, BPTR lock) CurrentDir(lock); if ((seg = LoadSeg(AROS_BOOT_CHECKEXEC))) { - UnLoadSeg(seg); + UnLoadSeg(seg); - D(bug("[__dos_IsBootable] Success!\n")); - return TRUE; + D(bug("[__dos_IsBootable] Success!\n")); + return TRUE; } #else diff --git a/rom/dos/isfilesystem.c b/rom/dos/isfilesystem.c index 8723285832..9306d19784 100644 --- a/rom/dos/isfilesystem.c +++ b/rom/dos/isfilesystem.c @@ -18,31 +18,31 @@ NAME */ #include - AROS_LH1(BOOL, IsFileSystem, + AROS_LH1(BOOL, IsFileSystem, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, devicename, D1), + AROS_LHA(CONST_STRPTR, devicename, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 118, Dos) + struct DosLibrary *, DOSBase, 118, Dos) /* FUNCTION - Query the device whether it is a filesystem. + Query the device whether it is a filesystem. INPUTS - devicename - Name of the device to query. + devicename - Name of the device to query. RESULT - TRUE if the device is a filesystem, FALSE otherwise. + TRUE if the device is a filesystem, FALSE otherwise. NOTES - DF0:, HD0:, ... are filesystems. - CON:, PIPE:, AUX:, ... are not + 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. - + is always TRUE. Also volume and assign names return + TRUE. + EXAMPLE BUGS @@ -61,17 +61,17 @@ /* console is never a filesystem */ if (Stricmp(devicename, "CONSOLE:") == 0 || Stricmp(devicename, "*") == 0 || - Stricmp(devicename, "CON:") == 0 || Stricmp(devicename, "RAW:") == 0) { - SetIoErr(err); + Stricmp(devicename, "CON:") == 0 || Stricmp(devicename, "RAW:") == 0) { + SetIoErr(err); return code; } if ((dvp = GetDeviceProc(devicename, dvp))) { - if (dvp->dvp_Port != NULL) // NIL: isn't a filesystem - code = dopacket0(DOSBase, NULL, dvp->dvp_Port, ACTION_IS_FILESYSTEM); - FreeDeviceProc(dvp); + if (dvp->dvp_Port != NULL) // NIL: isn't a filesystem + code = dopacket0(DOSBase, NULL, dvp->dvp_Port, ACTION_IS_FILESYSTEM); + FreeDeviceProc(dvp); } else { - SetIoErr(err); + SetIoErr(err); } return code; diff --git a/rom/dos/isinteractive.c b/rom/dos/isinteractive.c index 7ae626d245..3c013aaa15 100644 --- a/rom/dos/isinteractive.c +++ b/rom/dos/isinteractive.c @@ -13,23 +13,23 @@ NAME */ #include - AROS_LH1(LONG, IsInteractive, + AROS_LH1(LONG, IsInteractive, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), + AROS_LHA(BPTR, file, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 36, Dos) + struct DosLibrary *, DOSBase, 36, Dos) /* FUNCTION - Check if file is bound to an interactive device such as a console - or shell window. + Check if file is bound to an interactive device such as a console + or shell window. INPUTS - file - filehandle + file - filehandle RESULT - != 0 if the file is interactive, 0 if it is not. + != 0 if the file is interactive, 0 if it is not. NOTES diff --git a/rom/dos/loadseg.c b/rom/dos/loadseg.c index b9a39b6476..5d75e7af3c 100644 --- a/rom/dos/loadseg.c +++ b/rom/dos/loadseg.c @@ -15,9 +15,9 @@ #include "dos_intern.h" static AROS_UFH4(LONG, ReadFunc, - AROS_UFHA(BPTR, file, D1), - AROS_UFHA(APTR, buffer, D2), - AROS_UFHA(LONG, length, D3), + AROS_UFHA(BPTR, file, D1), + AROS_UFHA(APTR, buffer, D2), + AROS_UFHA(LONG, length, D3), AROS_UFHA(struct DosLibrary *, DOSBase, A6) ) { @@ -29,9 +29,9 @@ static AROS_UFH4(LONG, ReadFunc, } static AROS_UFH4(LONG, SeekFunc, - AROS_UFHA(BPTR, file, D1), - AROS_UFHA(LONG, pos, D2), - AROS_UFHA(LONG, mode, D3), + AROS_UFHA(BPTR, file, D1), + AROS_UFHA(LONG, pos, D2), + AROS_UFHA(LONG, mode, D3), AROS_UFHA(struct DosLibrary *, DOSBase, A6) ) { @@ -44,8 +44,8 @@ static AROS_UFH4(LONG, SeekFunc, static AROS_UFH3(APTR, AllocFunc, - AROS_UFHA(ULONG, length, D0), - AROS_UFHA(ULONG, flags, D1), + AROS_UFHA(ULONG, length, D0), + AROS_UFHA(ULONG, flags, D1), AROS_UFHA(struct ExecBase *, SysBase, A6) ) { @@ -57,8 +57,8 @@ static AROS_UFH3(APTR, AllocFunc, } static AROS_UFH3(void, FreeFunc, - AROS_UFHA(APTR, buffer, A1), - AROS_UFHA(ULONG, length, D0), + AROS_UFHA(APTR, buffer, A1), + AROS_UFHA(ULONG, length, D0), AROS_UFHA(struct ExecBase *, SysBase, A6) ) { @@ -113,10 +113,10 @@ static AROS_UFH3(void, FreeFunc, BPTR file, segs=0; SIPTR err; LONG_FUNC FunctionArray[] = { - (LONG_FUNC)ReadFunc, - (LONG_FUNC)AllocFunc, - (LONG_FUNC)FreeFunc, - (LONG_FUNC)SeekFunc, /* Only needed for ELF */ + (LONG_FUNC)ReadFunc, + (LONG_FUNC)AllocFunc, + (LONG_FUNC)FreeFunc, + (LONG_FUNC)SeekFunc, /* Only needed for ELF */ }; /* Open the file */ @@ -125,21 +125,21 @@ static AROS_UFH3(void, FreeFunc, if (file) { - D(bug("[LoadSeg] Loading '%s'...\n", name)); + D(bug("[LoadSeg] Loading '%s'...\n", name)); - SetVBuf(file, NULL, BUF_FULL, 4096); - segs = InternalLoadSeg(file, BNULL, FunctionArray, NULL); - /* We cache the IoErr(), since Close() will alter it */ - err = IoErr(); + SetVBuf(file, NULL, BUF_FULL, 4096); + segs = InternalLoadSeg(file, BNULL, FunctionArray, NULL); + /* We cache the IoErr(), since Close() will alter it */ + err = IoErr(); - D(if (segs == BNULL) - bug("[LoadSeg] Failed to load '%s'\n", name)); + D(if (segs == BNULL) + bug("[LoadSeg] Failed to load '%s'\n", name)); #if (AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT) - /* overlayed executables return -segs and handle must not be closed */ - if ((LONG)segs > 0) - Close(file); - else - segs = (BPTR)-((LONG)segs); + /* overlayed executables return -segs and handle must not be closed */ + if ((LONG)segs > 0) + Close(file); + else + segs = (BPTR)-((LONG)segs); #else Close(file); #endif diff --git a/rom/dos/lock.c b/rom/dos/lock.c index 4a8cd2ed85..5a7937d9b8 100644 --- a/rom/dos/lock.c +++ b/rom/dos/lock.c @@ -28,33 +28,33 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, NAME */ #include - AROS_LH2(BPTR, Lock, + AROS_LH2(BPTR, Lock, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(LONG, accessMode, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(LONG, accessMode, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 14, Dos) + struct DosLibrary *, DOSBase, 14, Dos) /* 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. + 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 + 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. + 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. + 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. *****************************************************************************/ @@ -73,7 +73,7 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, if (InternalLock(name, accessMode, &fl, MAX_SOFT_LINK_NESTING, DOSBase)) { - D(bug("[Lock] returned 0x%p\n", fl)); + D(bug("[Lock] returned 0x%p\n", fl)); return fl; } @@ -165,8 +165,8 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, if(soft_nesting == 0) { - SetIoErr(ERROR_TOO_MANY_LEVELS); - return DOSFALSE; + SetIoErr(ERROR_TOO_MANY_LEVELS); + return DOSFALSE; } /* Check for a pseudo-file lock @@ -181,11 +181,11 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, struct MsgPort *port; BPTR lock; - /* No ':' in the pathname, path is relative to current directory */ - cur = me->pr_CurrentDir; - if (cur && cur != (BPTR)-1) { - port = ((struct FileLock *)BADDR(cur))->fl_Task; - lock = cur; + /* No ':' in the pathname, path is relative to current directory */ + cur = me->pr_CurrentDir; + if (cur && cur != (BPTR)-1) { + port = ((struct FileLock *)BADDR(cur))->fl_Task; + lock = cur; } else { port = DOSBase->dl_Root->rn_BootProc; lock = BNULL; @@ -196,7 +196,7 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, } else { - filename++; + filename++; do { if ((dvp = GetDeviceProc(name, dvp)) == NULL) @@ -205,12 +205,12 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, break; } - error = fs_LocateObject(handle, dvp->dvp_Port, dvp->dvp_Lock, filename, accessMode, DOSBase); + error = fs_LocateObject(handle, dvp->dvp_Port, dvp->dvp_Lock, filename, accessMode, DOSBase); } while (error == ERROR_OBJECT_NOT_FOUND); - /* FIXME: On Linux hosted we sometimes get ERROR_IS_SOFTLINK with dvp == NULL, - * which causes segfaults below if we don't change "error". Adding !dvp below + /* FIXME: On Linux hosted we sometimes get ERROR_IS_SOFTLINK with dvp == NULL, + * which causes segfaults below if we don't change "error". Adding !dvp below * is probably a hack */ if (error == ERROR_NO_MORE_ENTRIES || !dvp) @@ -234,22 +234,22 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, if (dvp) { olddir = me->pr_CurrentDir; - error = RootDir(dvp, DOSBase); + error = RootDir(dvp, DOSBase); } else - error = 0; + error = 0; if (!error) { - ret = InternalLock(softname, accessMode, handle, soft_nesting - 1, DOSBase); - error = ret ? 0 : IoErr(); - D(bug("[Lock] Resolve error %d\n", error)); + ret = InternalLock(softname, accessMode, handle, soft_nesting - 1, DOSBase); + error = ret ? 0 : IoErr(); + D(bug("[Lock] Resolve error %d\n", error)); - if (olddir) - UnLock(CurrentDir(olddir)); + if (olddir) + UnLock(CurrentDir(olddir)); } - FreeVec(softname); + FreeVec(softname); } else error = IoErr(); @@ -259,11 +259,11 @@ static LONG InternalLock(CONST_STRPTR name, LONG accessMode, if (error) { - SetIoErr(error); - ret = DOSFALSE; + SetIoErr(error); + ret = DOSFALSE; } else - ret = DOSTRUE; + ret = DOSTRUE; return ret; } @@ -293,9 +293,9 @@ STRPTR ResolveSoftlink(BPTR cur, struct DevProc *dvp, CONST_STRPTR name, struct written = fs_ReadLink(cur, dvp, name, softname, buffer_size, DOSBase); - switch (written) - { - case -1: + switch (written) + { + case -1: /* An error occured */ DLINK(bug("[Softlink] Error %d reading softlink\n", IoErr())); break; @@ -308,7 +308,7 @@ STRPTR ResolveSoftlink(BPTR cur, struct DevProc *dvp, CONST_STRPTR name, struct DLINK(bug("[Softlink] Increased buffer size up to %u\n", buffer_size)); break; - default: + default: /* All OK */ DLINK(bug("[Softlink] Resolved path: %s\n", softname)); return softname; @@ -331,7 +331,7 @@ LONG RootDir(struct DevProc *dvp, struct DosLibrary *DOSBase) error = fs_LocateObject(&lock, dvp->dvp_Port, dvp->dvp_Lock, "", SHARED_LOCK, DOSBase); if (!error) - CurrentDir(lock); + CurrentDir(lock); return error; } diff --git a/rom/dos/lockdoslist.c b/rom/dos/lockdoslist.c index eed55d3dd8..d763ac3a9e 100644 --- a/rom/dos/lockdoslist.c +++ b/rom/dos/lockdoslist.c @@ -14,27 +14,27 @@ NAME */ #include - AROS_LH1(struct DosList *, LockDosList, + AROS_LH1(struct DosList *, LockDosList, /* SYNOPSIS */ - AROS_LHA(ULONG, flags, D1), + AROS_LHA(ULONG, flags, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 109, Dos) + struct DosLibrary *, DOSBase, 109, Dos) /* 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. + 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 + 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. + Handle to the dos list. This is not a direct pointer + to the first list element but to a pseudo element instead. NOTES @@ -47,9 +47,9 @@ INTERNALS HISTORY - 04-06-07 sonic merged back from MorphOS source code - 29-10-95 digulla automatically created from - dos_lib.fd and clib/dos_protos.h + 04-06-07 sonic merged back from MorphOS source code + 29-10-95 digulla automatically created from + dos_lib.fd and clib/dos_protos.h *****************************************************************************/ { @@ -60,32 +60,32 @@ D(bug("LockDosList: flags = $%lx\n", flags)); if (((flags & (LDF_READ|LDF_WRITE)) != LDF_READ && - (flags & (LDF_READ|LDF_WRITE)) != LDF_WRITE) || - (flags & ~(LDF_READ|LDF_WRITE|LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS|LDF_ENTRY|LDF_DELETE))) - return NULL; + (flags & (LDF_READ|LDF_WRITE)) != LDF_WRITE) || + (flags & ~(LDF_READ|LDF_WRITE|LDF_DEVICES|LDF_VOLUMES|LDF_ASSIGNS|LDF_ENTRY|LDF_DELETE))) + return NULL; if (flags & LDF_ALL) { - if (flags & LDF_WRITE) - ObtainSemaphore(&di->di_DevLock); - else - ObtainSemaphoreShared(&di->di_DevLock); + if (flags & LDF_WRITE) + ObtainSemaphore(&di->di_DevLock); + else + ObtainSemaphoreShared(&di->di_DevLock); } if (flags & LDF_ENTRY) { - if (flags & LDF_WRITE) - ObtainSemaphore(&di->di_EntryLock); - else - ObtainSemaphoreShared(&di->di_EntryLock); + if (flags & LDF_WRITE) + ObtainSemaphore(&di->di_EntryLock); + else + ObtainSemaphoreShared(&di->di_EntryLock); } if (flags & LDF_DELETE) { - if (flags & LDF_WRITE) - ObtainSemaphore(&di->di_DeleteLock); - else - ObtainSemaphoreShared(&di->di_DeleteLock); + if (flags & LDF_WRITE) + ObtainSemaphore(&di->di_DeleteLock); + else + ObtainSemaphoreShared(&di->di_DeleteLock); } /* This strange thing came from MorphOS. diff --git a/rom/dos/lockrecord.c b/rom/dos/lockrecord.c index af22649580..c99cb19f98 100644 --- a/rom/dos/lockrecord.c +++ b/rom/dos/lockrecord.c @@ -14,17 +14,17 @@ NAME */ #include - AROS_LH5(BOOL, LockRecord, + AROS_LH5(BOOL, LockRecord, /* SYNOPSIS */ - AROS_LHA(BPTR , fh, D1), - AROS_LHA(ULONG, offset, D2), - AROS_LHA(ULONG, length, D3), - AROS_LHA(ULONG, mode, D4), - AROS_LHA(ULONG, timeout, D5), + AROS_LHA(BPTR , fh, D1), + AROS_LHA(ULONG, offset, D2), + AROS_LHA(ULONG, length, D3), + AROS_LHA(ULONG, mode, D4), + AROS_LHA(ULONG, timeout, D5), /* LOCATION */ - struct DosLibrary *, DOSBase, 45, Dos) + struct DosLibrary *, DOSBase, 45, Dos) /* FUNCTION @@ -67,7 +67,7 @@ if (fh == BNULL) { - return DOSFALSE; + return DOSFALSE; } status = dopacket5(DOSBase, NULL, fileH->fh_Type, ACTION_LOCK_RECORD, fileH->fh_Arg1, offset, length, mode, timeout); diff --git a/rom/dos/lockrecords.c b/rom/dos/lockrecords.c index 54a48e054f..ba679b3f80 100644 --- a/rom/dos/lockrecords.c +++ b/rom/dos/lockrecords.c @@ -13,14 +13,14 @@ #include #include - AROS_LH2(BOOL, LockRecords, + AROS_LH2(BOOL, LockRecords, /* SYNOPSIS */ - AROS_LHA(struct RecordLock *, recArray, D1), - AROS_LHA(ULONG , timeout, D2), + AROS_LHA(struct RecordLock *, recArray, D1), + AROS_LHA(ULONG , timeout, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 46, Dos) + struct DosLibrary *, DOSBase, 46, Dos) /* FUNCTION @@ -61,19 +61,19 @@ while (BADDR(recArray->rec_FH) != NULL) { - BPTR temp; + BPTR temp; - if (!LockRecord(recArray->rec_FH, recArray->rec_Offset, - recArray->rec_Length, recArray->rec_Mode, timeout)) - { - temp = recArray->rec_FH; - UnLockRecords(rLock); - recArray->rec_FH = temp; + if (!LockRecord(recArray->rec_FH, recArray->rec_Offset, + recArray->rec_Length, recArray->rec_Mode, timeout)) + { + temp = recArray->rec_FH; + UnLockRecords(rLock); + recArray->rec_FH = temp; - return DOSFALSE; - } + return DOSFALSE; + } - recArray++; + recArray++; } return DOSTRUE; diff --git a/rom/dos/makedosentry.c b/rom/dos/makedosentry.c index 19f9fe0634..84a8111c15 100644 --- a/rom/dos/makedosentry.c +++ b/rom/dos/makedosentry.c @@ -17,22 +17,22 @@ NAME */ #include - AROS_LH2(struct DosList *, MakeDosEntry, + AROS_LH2(struct DosList *, MakeDosEntry, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(LONG, type, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(LONG, type, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 116, Dos) + struct DosLibrary *, DOSBase, 116, Dos) /* FUNCTION - Create an entry for the dos list. Depending on the type this may - be a device, a volume or an assign node. + 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 + name -- pointer to name + type -- type of list entry to create RESULT @@ -62,36 +62,36 @@ struct DosList *dl; dl = (struct DosList *)AllocVec(sizeof(struct DosList), - MEMF_PUBLIC | MEMF_CLEAR); + MEMF_PUBLIC | MEMF_CLEAR); if (dl != NULL) { #ifdef AROS_FAST_BPTR - s2 = (STRPTR)AllocVec(len+1, MEMF_PUBLIC | MEMF_CLEAR); - dl->dol_Name = MKBADDR(s2); + s2 = (STRPTR)AllocVec(len+1, MEMF_PUBLIC | MEMF_CLEAR); + dl->dol_Name = MKBADDR(s2); #else - /* Binary compatibility for BCPL string. - * First byte is the length then comes the string. - * For ease of use a zero is put at the end so it can be used as a - * C string - */ - s2 = (STRPTR)AllocVec(len+2, MEMF_PUBLIC | MEMF_CLEAR); - dl->dol_Name = MKBADDR(s2); - if (s2 != NULL) - *s2++ = (UBYTE)(len > 255 ? 255 : len); + /* Binary compatibility for BCPL string. + * First byte is the length then comes the string. + * For ease of use a zero is put at the end so it can be used as a + * C string + */ + s2 = (STRPTR)AllocVec(len+2, MEMF_PUBLIC | MEMF_CLEAR); + dl->dol_Name = MKBADDR(s2); + if (s2 != NULL) + *s2++ = (UBYTE)(len > 255 ? 255 : len); #endif - if (s2 != NULL) - { - strcpy(s2, name); - dl->dol_Type = type; - return dl; - } - else - { - SetIoErr(ERROR_NO_FREE_STORE); - } - - FreeVec(dl); + if (s2 != NULL) + { + strcpy(s2, name); + dl->dol_Type = type; + return dl; + } + else + { + SetIoErr(ERROR_NO_FREE_STORE); + } + + FreeVec(dl); } else { diff --git a/rom/dos/makelink.c b/rom/dos/makelink.c index 0847c5c8cd..b691bf1dd3 100644 --- a/rom/dos/makelink.c +++ b/rom/dos/makelink.c @@ -15,15 +15,15 @@ #include #include - AROS_LH3(LONG, MakeLink, + AROS_LH3(LONG, MakeLink, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(APTR, dest, D2), - AROS_LHA(LONG , soft, D3), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(APTR, dest, D2), + AROS_LHA(LONG , soft, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 74, Dos) + struct DosLibrary *, DOSBase, 74, Dos) /* FUNCTION MakeLink() will create a link between two files or directories. @@ -38,14 +38,14 @@ or directories on the same volume. INPUTS - name - The name of the link to create - dest - If 'soft' is TRUE this must be a filename; if it is FALSE a lock - pointing to the file to be hard-linked must be provided - soft - TRUE, if a soft link is to be created, FALSE for a hard link + name - The name of the link to create + dest - If 'soft' is TRUE this must be a filename; if it is FALSE a lock + pointing to the file to be hard-linked must be provided + soft - TRUE, if a soft link is to be created, FALSE for a hard link RESULT - boolean - DOSTRUE or DOSFALSE. On error, IoErr() will contain more - information. + boolean - DOSTRUE or DOSFALSE. On error, IoErr() will contain more + information. NOTES @@ -59,8 +59,8 @@ ReadLink() INTERNALS - This function calls either FSA_CREATE_HARDLINK or FSA_CREATE_SOFTLINK - on the filesystem of `name`. + This function calls either FSA_CREATE_HARDLINK or FSA_CREATE_SOFTLINK + on the filesystem of `name`. *****************************************************************************/ { @@ -72,7 +72,7 @@ status = DOSFALSE; if (getpacketinfo(DOSBase, name, &phs)) { status = dopacket4(DOSBase, NULL, phs.port, ACTION_MAKE_LINK, phs.lock, phs.name, (SIPTR)name, (IPTR)soft); - freepacketinfo(DOSBase, &phs); + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/match_misc.c b/rom/dos/match_misc.c index 4a0fd260bc..12c04ab635 100644 --- a/rom/dos/match_misc.c +++ b/rom/dos/match_misc.c @@ -48,11 +48,11 @@ static void RemoveTrailingSlash(STRPTR s) if (len >= 2) { - if ((s[len - 1] == '/') && - ((s[len - 2] != '/') && (s[len - 2] != ':'))) - { - s[len - 1] = '\0'; - } + if ((s[len - 1] == '/') && + ((s[len - 2] != '/') && (s[len - 2] != ':'))) + { + s[len - 1] = '\0'; + } } } @@ -84,16 +84,16 @@ Examples: [] is one AChain **************************************************************************/ LONG Match_BuildAChainList(CONST_STRPTR pattern, struct AnchorPath *ap, - struct AChain **retac, struct DosLibrary *DOSBase) + struct AChain **retac, struct DosLibrary *DOSBase) { - struct AChain *baseac = 0, *prevac = 0, *ac; - STRPTR patterncopy = 0; - STRPTR patternstart, patternend, patternpos; - LONG len, error = 0; - WORD comptype = COMPTYPE_UNKNOWN; - WORD compcount = 0; - WORD i; - UBYTE c; + struct AChain *baseac = 0, *prevac = 0, *ac; + STRPTR patterncopy = 0; + STRPTR patternstart, patternend, patternpos; + LONG len, error = 0; + WORD comptype = COMPTYPE_UNKNOWN; + WORD compcount = 0; + WORD i; + UBYTE c; *retac = 0; @@ -103,7 +103,7 @@ LONG Match_BuildAChainList(CONST_STRPTR pattern, struct AnchorPath *ap, if (!patterncopy) { error = ERROR_NO_FREE_STORE; - goto done; + goto done; } strcpy(patterncopy, pattern); @@ -115,162 +115,162 @@ LONG Match_BuildAChainList(CONST_STRPTR pattern, struct AnchorPath *ap, patternpos = strchr(patterncopy, ':'); if (!patternpos) { - comptype = COMPTYPE_UNKNOWN; - patternpos = patternstart; - patternend = patternstart; + comptype = COMPTYPE_UNKNOWN; + patternpos = patternstart; + patternend = patternstart; } else { - comptype = COMPTYPE_NORMAL; - patternend = patternpos++; - compcount = 1; + comptype = COMPTYPE_NORMAL; + patternend = patternpos++; + compcount = 1; } do { - for(;;) - { - c = *patternpos; - if (c == '/') - { - if (comptype == COMPTYPE_UNKNOWN) - { - comptype = COMPTYPE_NORMAL; - patternend = patternpos; - } - else if (comptype == COMPTYPE_NORMAL) - { - patternend = patternpos; - compcount++; - } - if (comptype == COMPTYPE_PATTERN) - { - patternend = patternpos; - break; - } - } - else if (c == '\0') - { - if (comptype == COMPTYPE_UNKNOWN) - { - comptype = COMPTYPE_NORMAL; - patternend = patternpos; - break; - } - if (comptype == COMPTYPE_NORMAL) - { - compcount++; - break; - } - patternend = patternpos; - break; - } - else if ((c == '#') || - (c == '~') || - (c == '[') || - (c == ']') || - (c == '?') || - (c == '*') || - (c == '(') || - (c == ')') || - (c == '|') || - (c == '%')) - { - if (comptype == COMPTYPE_NORMAL) - { - break; - } - comptype = COMPTYPE_PATTERN; - } - - patternpos++; - - } /* for(;;) */ - - len = (LONG)(patternend - patternstart + 2); - if (comptype == COMPTYPE_PATTERN) len = len * 2 + 2; - - ac = Match_AllocAChain(len, DOSBase); - if (!ac) - { - error = ERROR_NO_FREE_STORE; - goto done; - } - - if (comptype == COMPTYPE_NORMAL) - { - if (*patternend == '\0') - { - strcpy(ac->an_String, patternstart); - } else { - c = patternend[1]; - patternend[1] = '\0'; - strcpy(ac->an_String, patternstart); - patternend[1] = c; - } - - } /* if (comptype == COMPTYPE_NORMAL) */ - else - { - if (*patternend == '\0') - { - i = ParsePatternNoCase(patternstart, ac->an_String, len); - if (i == 0) - { - /* It is not a pattern, although we guessed it was one. - Do the strcpy, otherwise we have uppercase stuff in - ac->an_String because of ParsePatternNOCASE() */ - strcpy(ac->an_String, patternstart); - } - } - else - { - c = patternend[1]; - patternend[1] = '\0'; - i = ParsePatternNoCase(patternstart, ac->an_String, len); - if (i == 0) - { - /* It is not a pattern, although we guessed it was one. - Do the strcpy, otherwise we have uppercase stuff in - ac->an_String because of ParsePatternNOCASE() */ - strcpy(ac->an_String, patternstart); - } - patternend[1] = c; - } - - if (i == -1) - { - error = ERROR_BAD_TEMPLATE; - Match_FreeAChain(ac, DOSBase);ac = 0; - goto done; - } - - if (i) - { - ac->an_Flags |= DDF_PatternBit; - ap->ap_Flags |= APF_ITSWILD; - } - - } /* if (comptype == COMPTYPE_NORMAL) else ... */ - - RemoveTrailingSlash(ac->an_String); - - if (!prevac) - { - baseac = ac; - } - else - { - prevac->an_Child = ac; - ac->an_Parent = prevac; - } - - prevac = ac; - - patternpos = patternend; - comptype = COMPTYPE_UNKNOWN; - patternstart = patternend = patternpos + 1; - compcount = 0; + for(;;) + { + c = *patternpos; + if (c == '/') + { + if (comptype == COMPTYPE_UNKNOWN) + { + comptype = COMPTYPE_NORMAL; + patternend = patternpos; + } + else if (comptype == COMPTYPE_NORMAL) + { + patternend = patternpos; + compcount++; + } + if (comptype == COMPTYPE_PATTERN) + { + patternend = patternpos; + break; + } + } + else if (c == '\0') + { + if (comptype == COMPTYPE_UNKNOWN) + { + comptype = COMPTYPE_NORMAL; + patternend = patternpos; + break; + } + if (comptype == COMPTYPE_NORMAL) + { + compcount++; + break; + } + patternend = patternpos; + break; + } + else if ((c == '#') || + (c == '~') || + (c == '[') || + (c == ']') || + (c == '?') || + (c == '*') || + (c == '(') || + (c == ')') || + (c == '|') || + (c == '%')) + { + if (comptype == COMPTYPE_NORMAL) + { + break; + } + comptype = COMPTYPE_PATTERN; + } + + patternpos++; + + } /* for(;;) */ + + len = (LONG)(patternend - patternstart + 2); + if (comptype == COMPTYPE_PATTERN) len = len * 2 + 2; + + ac = Match_AllocAChain(len, DOSBase); + if (!ac) + { + error = ERROR_NO_FREE_STORE; + goto done; + } + + if (comptype == COMPTYPE_NORMAL) + { + if (*patternend == '\0') + { + strcpy(ac->an_String, patternstart); + } else { + c = patternend[1]; + patternend[1] = '\0'; + strcpy(ac->an_String, patternstart); + patternend[1] = c; + } + + } /* if (comptype == COMPTYPE_NORMAL) */ + else + { + if (*patternend == '\0') + { + i = ParsePatternNoCase(patternstart, ac->an_String, len); + if (i == 0) + { + /* It is not a pattern, although we guessed it was one. + Do the strcpy, otherwise we have uppercase stuff in + ac->an_String because of ParsePatternNOCASE() */ + strcpy(ac->an_String, patternstart); + } + } + else + { + c = patternend[1]; + patternend[1] = '\0'; + i = ParsePatternNoCase(patternstart, ac->an_String, len); + if (i == 0) + { + /* It is not a pattern, although we guessed it was one. + Do the strcpy, otherwise we have uppercase stuff in + ac->an_String because of ParsePatternNOCASE() */ + strcpy(ac->an_String, patternstart); + } + patternend[1] = c; + } + + if (i == -1) + { + error = ERROR_BAD_TEMPLATE; + Match_FreeAChain(ac, DOSBase);ac = 0; + goto done; + } + + if (i) + { + ac->an_Flags |= DDF_PatternBit; + ap->ap_Flags |= APF_ITSWILD; + } + + } /* if (comptype == COMPTYPE_NORMAL) else ... */ + + RemoveTrailingSlash(ac->an_String); + + if (!prevac) + { + baseac = ac; + } + else + { + prevac->an_Child = ac; + ac->an_Parent = prevac; + } + + prevac = ac; + + patternpos = patternend; + comptype = COMPTYPE_UNKNOWN; + patternstart = patternend = patternpos + 1; + compcount = 0; } while (*patternpos++ != '\0'); @@ -281,34 +281,34 @@ done: { #if MATCHFUNCS_NO_DUPLOCK /* - * No DupLock() here, because then we would have to UnLock it in - * MatchEnd and we would not know any valid lock to which we could - * CurrentDir after, because we must make sure there is a valid - * CurrentDir after MatchEnd. - */ - + * No DupLock() here, because then we would have to UnLock it in + * MatchEnd and we would not know any valid lock to which we could + * CurrentDir after, because we must make sure there is a valid + * CurrentDir after MatchEnd. + */ + baseac->an_Lock = CurrentDir(0); - CurrentDir(baseac->an_Lock); + CurrentDir(baseac->an_Lock); #endif - - *retac = baseac; + + *retac = baseac; } else { ap->ap_Flags |= APF_NOMEMERR; - - if (baseac) - { - #define nextac prevac /* to not have to add another variable */ - - ac = baseac; - while(ac) - { - nextac = ac->an_Child; - Match_FreeAChain(ac, DOSBase); - ac = nextac; - } - } + + if (baseac) + { + #define nextac prevac /* to not have to add another variable */ + + ac = baseac; + while(ac) + { + nextac = ac->an_Child; + Match_FreeAChain(ac, DOSBase); + ac = nextac; + } + } } return error;} @@ -325,18 +325,18 @@ LONG Match_MakeResult(struct AnchorPath *ap, struct DosLibrary *DOSBase) { struct AChain *ac; - ap->ap_Buf[0] = 0; - - for(ac = ap->ap_Base; (ac && !error); ac = ac->an_Child) - { - if (!AddPart(ap->ap_Buf, - ((ac->an_Flags & DDF_PatternBit) ? ac->an_Info.fib_FileName : ac->an_String), - ap->ap_Strlen)) - { - error = IoErr(); - } - } - + ap->ap_Buf[0] = 0; + + for(ac = ap->ap_Base; (ac && !error); ac = ac->an_Child) + { + if (!AddPart(ap->ap_Buf, + ((ac->an_Flags & DDF_PatternBit) ? ac->an_Info.fib_FileName : ac->an_String), + ap->ap_Strlen)) + { + error = IoErr(); + } + } + } #else LONG error = 0; @@ -344,16 +344,16 @@ LONG Match_MakeResult(struct AnchorPath *ap, struct DosLibrary *DOSBase) ap->ap_Info = ap->ap_Current->an_Info; if (ap->ap_Strlen) { - ap->ap_Buf[0] = 0; - if (NameFromLock(ap->ap_Current->an_Lock, ap->ap_Buf, ap->ap_Strlen)) - { - if (!AddPart(ap->ap_Buf, ap->ap_Current->an_Info.fib_FileName, ap->ap_Strlen)) - { - error = IoErr(); - } - } else { - error = IoErr(); - } + ap->ap_Buf[0] = 0; + if (NameFromLock(ap->ap_Current->an_Lock, ap->ap_Buf, ap->ap_Strlen)) + { + if (!AddPart(ap->ap_Buf, ap->ap_Current->an_Info.fib_FileName, ap->ap_Strlen)) + { + error = IoErr(); + } + } else { + error = IoErr(); + } } #endif diff --git a/rom/dos/match_old.c b/rom/dos/match_old.c dissimilarity index 63% index 9f164c5f2f..4b31f17ad7 100644 --- a/rom/dos/match_old.c +++ b/rom/dos/match_old.c @@ -1,945 +1,945 @@ -matchfirst.c: - - - -/* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include "dos_intern.h" -#include -#include -#include -#include - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH2(LONG, MatchFirst, - -/* SYNOPSIS */ - AROS_LHA(STRPTR , pat, D1), - AROS_LHA(struct AnchorPath *, AP , D2), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 137, Dos) - -/* 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 whereever 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 - - NOTES - - EXAMPLE - - BUGS - Copying of the relative path to ap_Buf is not implemented yet - - SEE ALSO - MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir() - - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - struct AChain * AC; - struct AChain * AC_Prev = NULL; - LONG PatLength; - STRPTR ParsedPattern; - BPTR firstlock; - - bug("matchfirst\n"); - - if (!pat) - return FALSE; - - AP->ap_Base = NULL; - AP->ap_Current = NULL; - - PatLength = 2*strlen(pat)+2; - ParsedPattern = AllocMem(PatLength, MEMF_ANY); - - - if (NULL != ParsedPattern) - { - LONG PatStart = 0; - LONG PatEnd = 0; - BOOL AllDone = FALSE; - LONG index; - LONG success = FALSE; - BPTR origdir; - - bug("matchfirst: ParsedPattern mem okay. Calling ParsePatternNoCase\n"); - - /* - ** Put the preparsed string to some memory - ** If there are any wildcards then leave info - */ - if (1 == ParsePatternNoCase(pat, ParsedPattern, PatLength)) - AP->ap_Flags |= (BYTE)APF_ITSWILD; - - //bug("matchfirst: ParsePatternNoCase returned: pattern = \"%s\"\n", ParsedPattern); - - /* - ** First I search for the very first ':'. If a '/' comes along - ** before that I quit. The string before and including the ':' - ** is assumed to be an assigned directory, for example 'libs:'. - ** So I will start looking for the pattern in that directory. - */ - while (TRUE) - { - if (ParsedPattern[PatEnd] == ':') - { - success = TRUE; - break; - } - else - { - if ( ParsedPattern[PatEnd] == '/' || - ParsedPattern[PatEnd] == '\0' || - (ParsedPattern[PatEnd] & 0x80) != 0 - /* a token or nonprintable letter */) - { - PatEnd = 0; - break; - } - } - PatEnd++; - } - - /* - ** Only if success == TRUE an assigned dir was found. - */ - if (TRUE == success) - { - /* - ** try to create a lock to that assigned dir. - */ - char Remember = ParsedPattern[PatEnd+1]; - PatEnd++; - ParsedPattern[PatEnd] = '\0'; - firstlock = Lock(ParsedPattern, ACCESS_READ); - origdir = CurrentDir(firstlock); - - /* - ** check whether an error occurred - */ - if (NULL == firstlock) - { - FreeMem(ParsedPattern, PatLength); - return IoErr(); // ERROR_DIR_NOT_FOUND; /* !!! hope that's the right error code... */ - } - - /* - ** I have the correct lock. - */ - ParsedPattern[PatEnd] = Remember; - PatStart=PatEnd; - - } /* if (TRUE == success) */ - else - { - /* - ** Create a lock to the current dir. - */ - origdir = CurrentDir(NULL); - firstlock = DupLock(origdir); - if (!firstlock) - { - FreeMem(ParsedPattern, PatLength); - return IoErr(); - } - - (void)CurrentDir(firstlock); - } - - bug("MatchFirst: origdir = %x\n", origdir); - bug("MatchFirst: firstlock = %x\n", firstlock); - - /* - ** Allocate an AChain structure for the original directory. - */ - AC = (struct AChain *)AllocVec(sizeof(struct AChain), MEMF_CLEAR); - if (NULL == AC) - { - /* - ** No more memory - */ - FreeMem(ParsedPattern, PatLength); - UnLock(firstlock); - CurrentDir(origdir); - - return ERROR_NO_FREE_STORE; - } - - AC->an_Lock = origdir; - AC->an_Flags = DDF_Completed|DDF_Single; - AC_Prev = AC; - - - AP->ap_Base = AC; - - /* - ** Build the Anchor Chain. For every subdirectory I allocate - ** an AChain structure and link them all together - */ - while (FALSE == AllDone) - { - /* - ** Search for the next '/' in the pattern and everything behind - ** the previous '/' and before this '/' will go to an_String - */ - while (TRUE) - { - if (ParsedPattern[PatEnd] == '\0') - { - AllDone = TRUE; - PatEnd--; - break; - } - if (ParsedPattern[PatEnd] == '/') - { - PatEnd--; - break; - } - PatEnd++; - - } /* while(TRUE) */ - - AC = AllocVec(sizeof(struct AChain)+(PatEnd-PatStart+2), MEMF_CLEAR); - if (NULL == AC) - { - /* not so bad if this was not the very first AC. */ - if (NULL == AP->ap_Base) - { - /* - ** oops, it was the very first one. I really cannot do anything for - ** you. - sorry - */ - FreeMem(ParsedPattern, PatLength); - - UnLock(AP->ap_Base->an_Lock); - CurrentDir(origdir); /* stegerg */ - FreeMem(AP->ap_Base, sizeof(struct AChain)); - - return ERROR_NO_FREE_STORE; - } - - /* - ** let me out of here. I will at least try to do something for you. - ** I can check the first few subdirs but that's gonna be it. - */ - AP->ap_Flags |= APF_NOMEMERR; - break; - - } /* if (NULL == AC) */ - - if (NULL == AP->ap_Base) - AP->ap_Base = AC; - - if (NULL == AP->ap_Current) - AP->ap_Current = AC; - - - if (NULL != AC_Prev) - AC_Prev->an_Child = AC; - - AC->an_Parent = AC_Prev; - AC_Prev = AC; - - /* - ** copy the part of the pattern to the end of the AChain. - */ - index = 0; - while (PatStart <= PatEnd) - { - AC->an_String[index] = ParsedPattern[PatStart]; - index++; - PatStart++; - } - - /* - ** Put PatStart and PetEnd behind the '/' that was found. - */ - PatStart = PatEnd + 2; - PatEnd += 2; - - /* - ** the trailing '\0' is there automatically as I allocated enough store - ** with MEMF_CLEAR - */ - - } /* while (FALSE == AllDone) */ - - /* - ** Free the pattern since it has been distributed now - */ - FreeMem(ParsedPattern, PatLength); - - /* - ** The AnchorChain to work with is the second one. - */ - AP->ap_Base = AP->ap_Base->an_Child; - AC = AP->ap_Base; - - AC->an_Lock = firstlock; - - (void)Examine(AC->an_Lock, &AC->an_Info); - - return followpattern(AP, AC, DOSBase); - - } /* if (NULL != ParsedPattern) */ - else - { - return ERROR_NO_FREE_STORE; - } - - return 0; - - AROS_LIBFUNC_EXIT - -} /* MatchFirst */ - - - - - - -matchnext.c: - - - - - - - -/* - Copyright © 1995-96, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include -#include -#include -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH1(LONG, MatchNext, - -/* SYNOPSIS */ - AROS_LHA(struct AnchorPath *, AP, D1), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 138, Dos) - -/* FUNCTION - Find next file or directory that matches a given pattern. - See for more docs and how to control MatchNext(). - - - INPUTS - AP - pointer to Anchor Path structure which had been passed to - MatchFirst() before. - - RESULT - - NOTES - - EXAMPLE - - BUGS - Copying of the relative path to ap_Buf is not implemented yet - - - SEE ALSO - MatchFirst() MatchEnd() CurrentDir() Examine() ExNext() - ParsePattern() - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - /* - ** If the user says I am supposed to enter the directory then I first check - ** whether it is a directory... - */ - - struct AChain * AC = AP->ap_Current; - BOOL success; - struct Task * task = FindTask(NULL); - - bug("matchnext\n"); - - AP->ap_BreakBits &= (SIGBREAKF_CTRL_C| - SIGBREAKF_CTRL_D| - SIGBREAKF_CTRL_E| - SIGBREAKF_CTRL_F); - - if (0 != (AP->ap_Flags & APF_DODIR )) - { - bug("matchnext: APF_DODIR is set\n"); - if (AC->an_Info.fib_DirEntryType >= 0 /* && - AC->an_Info.fib_DirEntryType != ST_SOFTLINK */) - { - bug("matchnext: APF_DODIR is set. Is a directory.\n"); - - /* Ok, it seems to be a directory so I will enter it. */ - /* See whether there's a AnchorChain for that dir... */ - if (NULL == AC->an_Child) - { - bug("matchnext: APF_DODIR is set. Is a directory. Has no child. Creating temp AChain\n"); - AC->an_Child = (struct AChain *) - AllocVec(sizeof(struct AChain)+1, MEMF_CLEAR); - - if (AC->an_Child) - { - AC->an_Child->an_Parent = AC; - - AC->an_Child->an_String[0] = P_ANY; - AC->an_Child->an_Flags = DDF_PatternBit; - } - - bug("matchnext: Created temporary AChain structure: %x!\n", AC->an_Child); - } - - if (NULL != AC->an_Child) - { - BPTR newdir; - - bug("matchnext: APF_DODIR is set. Is a directory. Has child.\n"); - - /* Ok, we're all set. */ - /* Lock the director by it's name. */ - AP->ap_Current = AC->an_Child; - - bug("matchnext: APF_DODIR is set. Is a directory. Has child. Locking \"%s\"\n", AC->an_Info.fib_FileName); - - newdir = Lock(AC->an_Info.fib_FileName, ACCESS_READ); - bug("matchnext: APF_DODIR is set. Is a directory. Has child. Lock = %x\n", newdir); - - if (!newdir) /* stegerg */ - { - AC = AC->an_Child; - return IoErr(); - } /* end stegerg */ - - //kprintf("CurrentDir()ing %x\n",AC->an_Info.fib_FileName); - (void)CurrentDir(newdir); - bug("matchnext: APF_DODIR is set. Is a directory. Has child. CurrentDir()ed to lock\n"); - - AC = AC->an_Child; - AC->an_Lock = newdir; - bug("matchnext: APF_DODIR is set. Is a directory. Has child. Calling Examine\n"); - Examine(AC->an_Lock, &AC->an_Info); - bug("matchnext: APF_DODIR is set. Is a directory. Has child. Called Examine\n"); - } - else - { - bug("matchnext: APF_DODIR is set. Could not alloc temp AChain. Returnin ERROR_NO_FREE_STORE\n"); - return ERROR_NO_FREE_STORE; - } - - } /* if (AC->an_Info.fib_DirEntryType >= 0 ... */ - - } /* if (0 != (AP->ap_Flags & APF_DODIR )) */ - - AP->ap_Flags &= ~(BYTE)(APF_DODIR|APF_DIDDIR); - - bug("matchnext 2\n"); - - /* - ** AC points to the current AnchorChain - */ - while (TRUE) - { - do - { - ULONG breakbits; - /* - ** Check for a break signal CTRL C/D/E/F - */ - breakbits = (AP->ap_BreakBits & SetSignal(0, 0)); /* task->tc_SigRecvd */ - - if (0 != breakbits) - { - /* - ** Finish right here... there might be a problem when/if the - ** algorithm is resumed the next time... Gotta test that. - */ - AP->ap_FoundBreak = breakbits; - bug("matchnext 2: break bits were set. Returning ERROR_BREAK\n"); - - return ERROR_BREAK; - } - - success = ExNext (AC->an_Lock, &AC->an_Info); - } - - while (DOSTRUE == success && - DOSFALSE == MatchPatternNoCase(AC->an_String, - AC->an_Info.fib_FileName)); - - - if (DOSFALSE == success) - { - bug("matchnext 2: success == DOSFALSE (no matching file)\n"); - /* - ** No more entries in this dir that match. So I might have to - ** step back one directory. Unlock the current dir first. - */ - - //kprintf("Couldn't find a matching file.!\n"); - - if (AP->ap_Base == AC) - { - bug("matchnext 2: success == DOSFALSE (no matching file). Unlocking %x\n", AC->an_Lock); - UnLock(AC->an_Lock); - AP->ap_Current = AC->an_Parent; - bug("matchnext 2: success == DOSFALSE (no matching file). AP->ap_Current = %x\n", AP->ap_Current); - bug("matchnext 2: currentdiring to %x\n", AP->ap_Current->an_Lock); - CurrentDir(AP->ap_Current->an_Lock); /* stegerg */ - bug("matchnext 2: Cannot step back dir. Returning ERROR_NO_MORE_ENTRIES\n"); - return ERROR_NO_MORE_ENTRIES; - } - - /* - ** Are there any previous directories??? - */ - if (NULL != AC && NULL != AC->an_Parent) - { - LONG retval = 0; - - bug("matchnext 2: success == DOSFALSE. There is a Parent and AC is *not* NULL. Unlocking %x\n", AC->an_Lock); - - UnLock(AC->an_Lock); - AC->an_Lock = NULL; - - AC = AC->an_Parent; - AP->ap_Current = AC; - - bug("matchnext 2: success == DOSFALSE. There is a Parent and AC is *not* NULL. CurrentDir()ing %x\n", AC->an_Lock); - - CurrentDir(AC->an_Lock); - - if (AC->an_Child->an_Flags & DDF_PatternBit) - { - FreeVec(AC->an_Child); - AC->an_Child = NULL; - } - else - if (0 == (AC->an_Flags & DDF_PatternBit)) - { - /* - ** In this case I must silently follow the pattern again... - */ - bug("matchnext 2: success == DOSFALSE. DDF_PatternBit is *not* set. Leaving matchnext with result from followpattern()\n"); - return followpattern(AP, AC, DOSBase); - } - - AP->ap_Flags |= APF_DIDDIR; - /* - ** I show this dir again as I come back from searching it - */ - - retval = createresult(AP, AC, DOSBase); - - /* - ** Step back to this directory and go on searching here - */ - - CurrentDir(AC->an_Lock); - - if (NULL == AC->an_Parent) - retval = ERROR_NO_MORE_ENTRIES; - - bug("matchnext 2: returning retval\n", retval); - - return retval; - - } /* if (NULL != AC->an_Parent && NULL != AC) */ - - bug("matchnext 2: success == DOSFALSE. There is no Parent and/or AC is NULL. Returning ERROR_NO_MORE_ENTRIES\n"); - - /* - ** No previous directory, so I am done here... - */ - return ERROR_NO_MORE_ENTRIES; - - } /* if (DOSFALSE == success) */ - else - { - bug("matchnext 2: success == DOSTRUE (found a match). Leaving matchnext wth result from createresult()\n"); - /* Alright, I found a match... */ - return createresult(AP, AC, DOSBase); - } - - } /* while (TRUE) */ - - bug("matchnext 2: returning 0.\n"); - - return 0; - - AROS_LIBFUNC_EXIT - -} /* MatchNext */ - - - - - -matchend.c: - - - - - - -/* - Copyright © 1995-96, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH1(void, MatchEnd, - -/* SYNOPSIS */ - AROS_LHA(struct AnchorPath *, AP, D1), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 139, Dos) - -/* 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. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - /* Free the AChain and unlock all locks that are still there */ - struct AChain * AC = AP->ap_Current; - struct AChain * AC_tmp; - - /* Unlock everything */ - if (NULL == AC) - return; - - while (NULL != AC->an_Parent) - { - bug("MatchEnd: unlocking %x\n", AC->an_Lock); - UnLock(AC->an_Lock); - AC = AC->an_Parent; - } - - bug("MatchEnd: CurrentDir(%x)\n", AC->an_Lock); - - CurrentDir(AC->an_Lock); - - /* AC points to the very first AChain obj. in the list */ - /* Free the AChain List */ - while (NULL != AC) - { - AC_tmp = AC->an_Child; - FreeVec(AC); - AC = AC_tmp; - } - - /* Cleanup AP */ - AP->ap_Base = NULL; - AP->ap_Current = NULL; - - AROS_LIBFUNC_EXIT - -} /* MatchEnd */ - - - - - - - - - -match_misc.c: - -#include -#include -#include -#include -#include "dos_intern.h" -#include - -LONG followpattern(struct AnchorPath * AP, - struct AChain * AC, - struct DosLibrary * DOSBase) -{ - LONG success; - - bug("followpattern start\n"); - - /* - ** If the user specified the pattern libs:#?/s#/ - ** then I must enter that pattern before I return to the user. - */ - while (TRUE) - { - do - { - success = ExNext (AC->an_Lock, &AC->an_Info); - } - while (DOSTRUE == success && - DOSFALSE == MatchPatternNoCase(AC->an_String, - AC->an_Info.fib_FileName)); - - /* - ** If no matching entry could be found here then I - ** step back one directory, unless this is the very - ** first directory already. - */ - if (DOSFALSE == success) - { - bug("followpattern: success is DOSFALSE. Unlocking AC->an_Lock %x\n", AC->an_Lock); - UnLock(AC->an_Lock); - AC->an_Lock = NULL; - - AC = AC->an_Parent; - bug("followpattern: success is DOSFALSE. AC now %x\n", AC); - - AP->ap_Current = AC; - - bug("followpattern: success is DOSFALSE. CurrentDir()ing to %x\n", AC->an_Lock); - - CurrentDir(AC->an_Lock); - - bug("followpattern: success is DOSFALSE. AC has parent = %s\n", AC->an_Parent ? "yes" : "no"); - - if (NULL == AC->an_Parent) - { - bug("followpattern: success is DOSFALSE. Has no parent. --> returning ERROR_NO_MORE_ENTRIES\n"); - return ERROR_NO_MORE_ENTRIES; - } - } - else - { - bug("followpattern: success *not* DOSFALSE.\n"); - if (AC->an_Info.fib_DirEntryType >= 0 /* && - AC->an_Info.fib_DirEntryType != ST_SOFTLINK */) - { - bug("followpattern: success *not* DOSFALSE. Is a directory.\n"); - /* - ** I must silently enter this directory if there - ** are further patterns left, otherwise I return to the - ** user. - */ - if (NULL != AC->an_Child) - { - /* - ** Silently entering this dir according to the - ** pattern. - */ - BPTR newdir; - - bug("followpattern: success *not* DOSFALSE. Is a directory. Has a child. Entering\n"); - - AP->ap_Current = AC->an_Child; - - bug("followpattern: success *not* DOSFALSE. Is a directory. Locking + CurrentDir()ing to %s\n", AC->an_Info.fib_FileName); - - newdir = Lock(AC->an_Info.fib_FileName, ACCESS_READ); - bug("followpattern: success *not* DOSFALSE. Is a directory. Locking done. Lock = %x\n", newdir); - (void)CurrentDir(newdir); - - bug("followpattern: success *not* DOSFALSE. Is a directory. CurrentDir()ing done\n"); - - AC = AC->an_Child; - AC->an_Lock = newdir; - - bug("followpattern: success *not* DOSFALSE. Is a directory. Examining lock %x\n", newdir); - - Examine(AC->an_Lock, &AC->an_Info); - bug("followpattern: success *not* DOSFALSE. Is a directory. Examining lock done\n"); - } - else - { - bug("followpattern: success *not* DOSFALSE. Is a directory. Has now child. Leaving followpattern with result from createresult\n"); - /* - ** Ask the user whether to enter this dir or not - */ - return createresult(AP, AC, DOSBase); - } - - } /* is a directory */ - else - { - /* - ** This is a file. If there is pattern left to match then - ** I must not show this file because I must fulfill the pattern - ** first. - */ - if (NULL == AC->an_Child) - { - bug("followpattern: is a file and has no child: leaving followpattern with result from createresult \n"); - - /* - ** There's no pattern left! - */ - return createresult(AP, AC, DOSBase); - } - else - bug("followpattern: Silently skipping file %s!\n",AC->an_Info.fib_FileName); - - } /* is a file */ - - } /* if (DOSFALSE == success) */ - - } /* while (TRUE) */ - -#if 0 - /* - ** Hooray! A matching file was found. Also show the data in AP - */ - createresult(AP, AC, DOSBase); -#endif - -} - - -/* -** A file/directory has been found and now it must be written -** into the relevant structures. -*/ -LONG createresult(struct AnchorPath * AP, - struct AChain * AC, - struct DosLibrary * DOSBase) -{ - bug("createresult\n"); - - CopyMem(&AC->an_Info, &AP->ap_Info, sizeof(struct FileInfoBlock)); - if (0 != AP->ap_Strlen) - { - if (FALSE == writeFullPath(AP)) - { - bug("createresult: returning ERROR_BUFFER_OVERFLOW\n"); - return ERROR_BUFFER_OVERFLOW; - } - } - - bug("createresult: done\n"); - - return 0; -} - - -/* Function needed by MatchFirst/Next */ - -BOOL writeFullPath(struct AnchorPath * AP) -{ - struct AChain * AC = AP->ap_Base; - BOOL end = FALSE; - char * LastPos = (char *)&AP->ap_Buf; - int copied = 0; - - bug("writefullpath\n"); - while (FALSE == end) - { - int len = strlen(AC->an_Info.fib_FileName); - if (copied+len > AP->ap_Strlen) - { - bug("writefullpath: not enough space\n"); - return FALSE; - } - strcpy(&LastPos[copied], AC->an_Info.fib_FileName); - copied += len; - - if (AC != AP->ap_Current) - { - /* also add a '/' */ - if (copied+1 > AP->ap_Strlen) - { - bug("writefullpath: not enough space 2\n"); - return FALSE; - } - LastPos[copied]='/'; - copied++; - } - else - { - if (copied+1 > AP->ap_Strlen) - { - bug("writefullpath: not enough space 3\n"); - return FALSE; - } - LastPos[copied]='\0'; - end = TRUE; - } - - AC = AC->an_Child; - } - - bug("writefullpath: done\n"); - - return TRUE; -} +matchfirst.c: + + + +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include "dos_intern.h" +#include +#include +#include +#include + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH2(LONG, MatchFirst, + +/* SYNOPSIS */ + AROS_LHA(STRPTR , pat, D1), + AROS_LHA(struct AnchorPath *, AP , D2), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 137, Dos) + +/* 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 whereever 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 + + NOTES + + EXAMPLE + + BUGS + Copying of the relative path to ap_Buf is not implemented yet + + SEE ALSO + MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir() + + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + struct AChain * AC; + struct AChain * AC_Prev = NULL; + LONG PatLength; + STRPTR ParsedPattern; + BPTR firstlock; + + bug("matchfirst\n"); + + if (!pat) + return FALSE; + + AP->ap_Base = NULL; + AP->ap_Current = NULL; + + PatLength = 2*strlen(pat)+2; + ParsedPattern = AllocMem(PatLength, MEMF_ANY); + + + if (NULL != ParsedPattern) + { + LONG PatStart = 0; + LONG PatEnd = 0; + BOOL AllDone = FALSE; + LONG index; + LONG success = FALSE; + BPTR origdir; + + bug("matchfirst: ParsedPattern mem okay. Calling ParsePatternNoCase\n"); + + /* + ** Put the preparsed string to some memory + ** If there are any wildcards then leave info + */ + if (1 == ParsePatternNoCase(pat, ParsedPattern, PatLength)) + AP->ap_Flags |= (BYTE)APF_ITSWILD; + + //bug("matchfirst: ParsePatternNoCase returned: pattern = \"%s\"\n", ParsedPattern); + + /* + ** First I search for the very first ':'. If a '/' comes along + ** before that I quit. The string before and including the ':' + ** is assumed to be an assigned directory, for example 'libs:'. + ** So I will start looking for the pattern in that directory. + */ + while (TRUE) + { + if (ParsedPattern[PatEnd] == ':') + { + success = TRUE; + break; + } + else + { + if ( ParsedPattern[PatEnd] == '/' || + ParsedPattern[PatEnd] == '\0' || + (ParsedPattern[PatEnd] & 0x80) != 0 + /* a token or nonprintable letter */) + { + PatEnd = 0; + break; + } + } + PatEnd++; + } + + /* + ** Only if success == TRUE an assigned dir was found. + */ + if (TRUE == success) + { + /* + ** try to create a lock to that assigned dir. + */ + char Remember = ParsedPattern[PatEnd+1]; + PatEnd++; + ParsedPattern[PatEnd] = '\0'; + firstlock = Lock(ParsedPattern, ACCESS_READ); + origdir = CurrentDir(firstlock); + + /* + ** check whether an error occurred + */ + if (NULL == firstlock) + { + FreeMem(ParsedPattern, PatLength); + return IoErr(); // ERROR_DIR_NOT_FOUND; /* !!! hope that's the right error code... */ + } + + /* + ** I have the correct lock. + */ + ParsedPattern[PatEnd] = Remember; + PatStart=PatEnd; + + } /* if (TRUE == success) */ + else + { + /* + ** Create a lock to the current dir. + */ + origdir = CurrentDir(NULL); + firstlock = DupLock(origdir); + if (!firstlock) + { + FreeMem(ParsedPattern, PatLength); + return IoErr(); + } + + (void)CurrentDir(firstlock); + } + + bug("MatchFirst: origdir = %x\n", origdir); + bug("MatchFirst: firstlock = %x\n", firstlock); + + /* + ** Allocate an AChain structure for the original directory. + */ + AC = (struct AChain *)AllocVec(sizeof(struct AChain), MEMF_CLEAR); + if (NULL == AC) + { + /* + ** No more memory + */ + FreeMem(ParsedPattern, PatLength); + UnLock(firstlock); + CurrentDir(origdir); + + return ERROR_NO_FREE_STORE; + } + + AC->an_Lock = origdir; + AC->an_Flags = DDF_Completed|DDF_Single; + AC_Prev = AC; + + + AP->ap_Base = AC; + + /* + ** Build the Anchor Chain. For every subdirectory I allocate + ** an AChain structure and link them all together + */ + while (FALSE == AllDone) + { + /* + ** Search for the next '/' in the pattern and everything behind + ** the previous '/' and before this '/' will go to an_String + */ + while (TRUE) + { + if (ParsedPattern[PatEnd] == '\0') + { + AllDone = TRUE; + PatEnd--; + break; + } + if (ParsedPattern[PatEnd] == '/') + { + PatEnd--; + break; + } + PatEnd++; + + } /* while(TRUE) */ + + AC = AllocVec(sizeof(struct AChain)+(PatEnd-PatStart+2), MEMF_CLEAR); + if (NULL == AC) + { + /* not so bad if this was not the very first AC. */ + if (NULL == AP->ap_Base) + { + /* + ** oops, it was the very first one. I really cannot do anything for + ** you. - sorry + */ + FreeMem(ParsedPattern, PatLength); + + UnLock(AP->ap_Base->an_Lock); + CurrentDir(origdir); /* stegerg */ + FreeMem(AP->ap_Base, sizeof(struct AChain)); + + return ERROR_NO_FREE_STORE; + } + + /* + ** let me out of here. I will at least try to do something for you. + ** I can check the first few subdirs but that's gonna be it. + */ + AP->ap_Flags |= APF_NOMEMERR; + break; + + } /* if (NULL == AC) */ + + if (NULL == AP->ap_Base) + AP->ap_Base = AC; + + if (NULL == AP->ap_Current) + AP->ap_Current = AC; + + + if (NULL != AC_Prev) + AC_Prev->an_Child = AC; + + AC->an_Parent = AC_Prev; + AC_Prev = AC; + + /* + ** copy the part of the pattern to the end of the AChain. + */ + index = 0; + while (PatStart <= PatEnd) + { + AC->an_String[index] = ParsedPattern[PatStart]; + index++; + PatStart++; + } + + /* + ** Put PatStart and PetEnd behind the '/' that was found. + */ + PatStart = PatEnd + 2; + PatEnd += 2; + + /* + ** the trailing '\0' is there automatically as I allocated enough store + ** with MEMF_CLEAR + */ + + } /* while (FALSE == AllDone) */ + + /* + ** Free the pattern since it has been distributed now + */ + FreeMem(ParsedPattern, PatLength); + + /* + ** The AnchorChain to work with is the second one. + */ + AP->ap_Base = AP->ap_Base->an_Child; + AC = AP->ap_Base; + + AC->an_Lock = firstlock; + + (void)Examine(AC->an_Lock, &AC->an_Info); + + return followpattern(AP, AC, DOSBase); + + } /* if (NULL != ParsedPattern) */ + else + { + return ERROR_NO_FREE_STORE; + } + + return 0; + + AROS_LIBFUNC_EXIT + +} /* MatchFirst */ + + + + + + +matchnext.c: + + + + + + + +/* + Copyright © 1995-96, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include +#include +#include +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH1(LONG, MatchNext, + +/* SYNOPSIS */ + AROS_LHA(struct AnchorPath *, AP, D1), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 138, Dos) + +/* FUNCTION + Find next file or directory that matches a given pattern. + See for more docs and how to control MatchNext(). + + + INPUTS + AP - pointer to Anchor Path structure which had been passed to + MatchFirst() before. + + RESULT + + NOTES + + EXAMPLE + + BUGS + Copying of the relative path to ap_Buf is not implemented yet + + + SEE ALSO + MatchFirst() MatchEnd() CurrentDir() Examine() ExNext() + ParsePattern() + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + /* + ** If the user says I am supposed to enter the directory then I first check + ** whether it is a directory... + */ + + struct AChain * AC = AP->ap_Current; + BOOL success; + struct Task * task = FindTask(NULL); + + bug("matchnext\n"); + + AP->ap_BreakBits &= (SIGBREAKF_CTRL_C| + SIGBREAKF_CTRL_D| + SIGBREAKF_CTRL_E| + SIGBREAKF_CTRL_F); + + if (0 != (AP->ap_Flags & APF_DODIR )) + { + bug("matchnext: APF_DODIR is set\n"); + if (AC->an_Info.fib_DirEntryType >= 0 /* && + AC->an_Info.fib_DirEntryType != ST_SOFTLINK */) + { + bug("matchnext: APF_DODIR is set. Is a directory.\n"); + + /* Ok, it seems to be a directory so I will enter it. */ + /* See whether there's a AnchorChain for that dir... */ + if (NULL == AC->an_Child) + { + bug("matchnext: APF_DODIR is set. Is a directory. Has no child. Creating temp AChain\n"); + AC->an_Child = (struct AChain *) + AllocVec(sizeof(struct AChain)+1, MEMF_CLEAR); + + if (AC->an_Child) + { + AC->an_Child->an_Parent = AC; + + AC->an_Child->an_String[0] = P_ANY; + AC->an_Child->an_Flags = DDF_PatternBit; + } + + bug("matchnext: Created temporary AChain structure: %x!\n", AC->an_Child); + } + + if (NULL != AC->an_Child) + { + BPTR newdir; + + bug("matchnext: APF_DODIR is set. Is a directory. Has child.\n"); + + /* Ok, we're all set. */ + /* Lock the director by it's name. */ + AP->ap_Current = AC->an_Child; + + bug("matchnext: APF_DODIR is set. Is a directory. Has child. Locking \"%s\"\n", AC->an_Info.fib_FileName); + + newdir = Lock(AC->an_Info.fib_FileName, ACCESS_READ); + bug("matchnext: APF_DODIR is set. Is a directory. Has child. Lock = %x\n", newdir); + + if (!newdir) /* stegerg */ + { + AC = AC->an_Child; + return IoErr(); + } /* end stegerg */ + + //kprintf("CurrentDir()ing %x\n",AC->an_Info.fib_FileName); + (void)CurrentDir(newdir); + bug("matchnext: APF_DODIR is set. Is a directory. Has child. CurrentDir()ed to lock\n"); + + AC = AC->an_Child; + AC->an_Lock = newdir; + bug("matchnext: APF_DODIR is set. Is a directory. Has child. Calling Examine\n"); + Examine(AC->an_Lock, &AC->an_Info); + bug("matchnext: APF_DODIR is set. Is a directory. Has child. Called Examine\n"); + } + else + { + bug("matchnext: APF_DODIR is set. Could not alloc temp AChain. Returnin ERROR_NO_FREE_STORE\n"); + return ERROR_NO_FREE_STORE; + } + + } /* if (AC->an_Info.fib_DirEntryType >= 0 ... */ + + } /* if (0 != (AP->ap_Flags & APF_DODIR )) */ + + AP->ap_Flags &= ~(BYTE)(APF_DODIR|APF_DIDDIR); + + bug("matchnext 2\n"); + + /* + ** AC points to the current AnchorChain + */ + while (TRUE) + { + do + { + ULONG breakbits; + /* + ** Check for a break signal CTRL C/D/E/F + */ + breakbits = (AP->ap_BreakBits & SetSignal(0, 0)); /* task->tc_SigRecvd */ + + if (0 != breakbits) + { + /* + ** Finish right here... there might be a problem when/if the + ** algorithm is resumed the next time... Gotta test that. + */ + AP->ap_FoundBreak = breakbits; + bug("matchnext 2: break bits were set. Returning ERROR_BREAK\n"); + + return ERROR_BREAK; + } + + success = ExNext (AC->an_Lock, &AC->an_Info); + } + + while (DOSTRUE == success && + DOSFALSE == MatchPatternNoCase(AC->an_String, + AC->an_Info.fib_FileName)); + + + if (DOSFALSE == success) + { + bug("matchnext 2: success == DOSFALSE (no matching file)\n"); + /* + ** No more entries in this dir that match. So I might have to + ** step back one directory. Unlock the current dir first. + */ + + //kprintf("Couldn't find a matching file.!\n"); + + if (AP->ap_Base == AC) + { + bug("matchnext 2: success == DOSFALSE (no matching file). Unlocking %x\n", AC->an_Lock); + UnLock(AC->an_Lock); + AP->ap_Current = AC->an_Parent; + bug("matchnext 2: success == DOSFALSE (no matching file). AP->ap_Current = %x\n", AP->ap_Current); + bug("matchnext 2: currentdiring to %x\n", AP->ap_Current->an_Lock); + CurrentDir(AP->ap_Current->an_Lock); /* stegerg */ + bug("matchnext 2: Cannot step back dir. Returning ERROR_NO_MORE_ENTRIES\n"); + return ERROR_NO_MORE_ENTRIES; + } + + /* + ** Are there any previous directories??? + */ + if (NULL != AC && NULL != AC->an_Parent) + { + LONG retval = 0; + + bug("matchnext 2: success == DOSFALSE. There is a Parent and AC is *not* NULL. Unlocking %x\n", AC->an_Lock); + + UnLock(AC->an_Lock); + AC->an_Lock = NULL; + + AC = AC->an_Parent; + AP->ap_Current = AC; + + bug("matchnext 2: success == DOSFALSE. There is a Parent and AC is *not* NULL. CurrentDir()ing %x\n", AC->an_Lock); + + CurrentDir(AC->an_Lock); + + if (AC->an_Child->an_Flags & DDF_PatternBit) + { + FreeVec(AC->an_Child); + AC->an_Child = NULL; + } + else + if (0 == (AC->an_Flags & DDF_PatternBit)) + { + /* + ** In this case I must silently follow the pattern again... + */ + bug("matchnext 2: success == DOSFALSE. DDF_PatternBit is *not* set. Leaving matchnext with result from followpattern()\n"); + return followpattern(AP, AC, DOSBase); + } + + AP->ap_Flags |= APF_DIDDIR; + /* + ** I show this dir again as I come back from searching it + */ + + retval = createresult(AP, AC, DOSBase); + + /* + ** Step back to this directory and go on searching here + */ + + CurrentDir(AC->an_Lock); + + if (NULL == AC->an_Parent) + retval = ERROR_NO_MORE_ENTRIES; + + bug("matchnext 2: returning retval\n", retval); + + return retval; + + } /* if (NULL != AC->an_Parent && NULL != AC) */ + + bug("matchnext 2: success == DOSFALSE. There is no Parent and/or AC is NULL. Returning ERROR_NO_MORE_ENTRIES\n"); + + /* + ** No previous directory, so I am done here... + */ + return ERROR_NO_MORE_ENTRIES; + + } /* if (DOSFALSE == success) */ + else + { + bug("matchnext 2: success == DOSTRUE (found a match). Leaving matchnext wth result from createresult()\n"); + /* Alright, I found a match... */ + return createresult(AP, AC, DOSBase); + } + + } /* while (TRUE) */ + + bug("matchnext 2: returning 0.\n"); + + return 0; + + AROS_LIBFUNC_EXIT + +} /* MatchNext */ + + + + + +matchend.c: + + + + + + +/* + Copyright © 1995-96, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH1(void, MatchEnd, + +/* SYNOPSIS */ + AROS_LHA(struct AnchorPath *, AP, D1), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 139, Dos) + +/* 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. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + /* Free the AChain and unlock all locks that are still there */ + struct AChain * AC = AP->ap_Current; + struct AChain * AC_tmp; + + /* Unlock everything */ + if (NULL == AC) + return; + + while (NULL != AC->an_Parent) + { + bug("MatchEnd: unlocking %x\n", AC->an_Lock); + UnLock(AC->an_Lock); + AC = AC->an_Parent; + } + + bug("MatchEnd: CurrentDir(%x)\n", AC->an_Lock); + + CurrentDir(AC->an_Lock); + + /* AC points to the very first AChain obj. in the list */ + /* Free the AChain List */ + while (NULL != AC) + { + AC_tmp = AC->an_Child; + FreeVec(AC); + AC = AC_tmp; + } + + /* Cleanup AP */ + AP->ap_Base = NULL; + AP->ap_Current = NULL; + + AROS_LIBFUNC_EXIT + +} /* MatchEnd */ + + + + + + + + + +match_misc.c: + +#include +#include +#include +#include +#include "dos_intern.h" +#include + +LONG followpattern(struct AnchorPath * AP, + struct AChain * AC, + struct DosLibrary * DOSBase) +{ + LONG success; + + bug("followpattern start\n"); + + /* + ** If the user specified the pattern libs:#?/s#/ + ** then I must enter that pattern before I return to the user. + */ + while (TRUE) + { + do + { + success = ExNext (AC->an_Lock, &AC->an_Info); + } + while (DOSTRUE == success && + DOSFALSE == MatchPatternNoCase(AC->an_String, + AC->an_Info.fib_FileName)); + + /* + ** If no matching entry could be found here then I + ** step back one directory, unless this is the very + ** first directory already. + */ + if (DOSFALSE == success) + { + bug("followpattern: success is DOSFALSE. Unlocking AC->an_Lock %x\n", AC->an_Lock); + UnLock(AC->an_Lock); + AC->an_Lock = NULL; + + AC = AC->an_Parent; + bug("followpattern: success is DOSFALSE. AC now %x\n", AC); + + AP->ap_Current = AC; + + bug("followpattern: success is DOSFALSE. CurrentDir()ing to %x\n", AC->an_Lock); + + CurrentDir(AC->an_Lock); + + bug("followpattern: success is DOSFALSE. AC has parent = %s\n", AC->an_Parent ? "yes" : "no"); + + if (NULL == AC->an_Parent) + { + bug("followpattern: success is DOSFALSE. Has no parent. --> returning ERROR_NO_MORE_ENTRIES\n"); + return ERROR_NO_MORE_ENTRIES; + } + } + else + { + bug("followpattern: success *not* DOSFALSE.\n"); + if (AC->an_Info.fib_DirEntryType >= 0 /* && + AC->an_Info.fib_DirEntryType != ST_SOFTLINK */) + { + bug("followpattern: success *not* DOSFALSE. Is a directory.\n"); + /* + ** I must silently enter this directory if there + ** are further patterns left, otherwise I return to the + ** user. + */ + if (NULL != AC->an_Child) + { + /* + ** Silently entering this dir according to the + ** pattern. + */ + BPTR newdir; + + bug("followpattern: success *not* DOSFALSE. Is a directory. Has a child. Entering\n"); + + AP->ap_Current = AC->an_Child; + + bug("followpattern: success *not* DOSFALSE. Is a directory. Locking + CurrentDir()ing to %s\n", AC->an_Info.fib_FileName); + + newdir = Lock(AC->an_Info.fib_FileName, ACCESS_READ); + bug("followpattern: success *not* DOSFALSE. Is a directory. Locking done. Lock = %x\n", newdir); + (void)CurrentDir(newdir); + + bug("followpattern: success *not* DOSFALSE. Is a directory. CurrentDir()ing done\n"); + + AC = AC->an_Child; + AC->an_Lock = newdir; + + bug("followpattern: success *not* DOSFALSE. Is a directory. Examining lock %x\n", newdir); + + Examine(AC->an_Lock, &AC->an_Info); + bug("followpattern: success *not* DOSFALSE. Is a directory. Examining lock done\n"); + } + else + { + bug("followpattern: success *not* DOSFALSE. Is a directory. Has now child. Leaving followpattern with result from createresult\n"); + /* + ** Ask the user whether to enter this dir or not + */ + return createresult(AP, AC, DOSBase); + } + + } /* is a directory */ + else + { + /* + ** This is a file. If there is pattern left to match then + ** I must not show this file because I must fulfill the pattern + ** first. + */ + if (NULL == AC->an_Child) + { + bug("followpattern: is a file and has no child: leaving followpattern with result from createresult \n"); + + /* + ** There's no pattern left! + */ + return createresult(AP, AC, DOSBase); + } + else + bug("followpattern: Silently skipping file %s!\n",AC->an_Info.fib_FileName); + + } /* is a file */ + + } /* if (DOSFALSE == success) */ + + } /* while (TRUE) */ + +#if 0 + /* + ** Hooray! A matching file was found. Also show the data in AP + */ + createresult(AP, AC, DOSBase); +#endif + +} + + +/* +** A file/directory has been found and now it must be written +** into the relevant structures. +*/ +LONG createresult(struct AnchorPath * AP, + struct AChain * AC, + struct DosLibrary * DOSBase) +{ + bug("createresult\n"); + + CopyMem(&AC->an_Info, &AP->ap_Info, sizeof(struct FileInfoBlock)); + if (0 != AP->ap_Strlen) + { + if (FALSE == writeFullPath(AP)) + { + bug("createresult: returning ERROR_BUFFER_OVERFLOW\n"); + return ERROR_BUFFER_OVERFLOW; + } + } + + bug("createresult: done\n"); + + return 0; +} + + +/* Function needed by MatchFirst/Next */ + +BOOL writeFullPath(struct AnchorPath * AP) +{ + struct AChain * AC = AP->ap_Base; + BOOL end = FALSE; + char * LastPos = (char *)&AP->ap_Buf; + int copied = 0; + + bug("writefullpath\n"); + while (FALSE == end) + { + int len = strlen(AC->an_Info.fib_FileName); + if (copied+len > AP->ap_Strlen) + { + bug("writefullpath: not enough space\n"); + return FALSE; + } + strcpy(&LastPos[copied], AC->an_Info.fib_FileName); + copied += len; + + if (AC != AP->ap_Current) + { + /* also add a '/' */ + if (copied+1 > AP->ap_Strlen) + { + bug("writefullpath: not enough space 2\n"); + return FALSE; + } + LastPos[copied]='/'; + copied++; + } + else + { + if (copied+1 > AP->ap_Strlen) + { + bug("writefullpath: not enough space 3\n"); + return FALSE; + } + LastPos[copied]='\0'; + end = TRUE; + } + + AC = AC->an_Child; + } + + bug("writefullpath: done\n"); + + return TRUE; +} diff --git a/rom/dos/matchend.c b/rom/dos/matchend.c index 72078dcc15..d936a31044 100644 --- a/rom/dos/matchend.c +++ b/rom/dos/matchend.c @@ -14,24 +14,24 @@ #include #include - AROS_LH1(void, MatchEnd, + AROS_LH1(void, MatchEnd, /* SYNOPSIS */ - AROS_LHA(struct AnchorPath *, AP, D1), + AROS_LHA(struct AnchorPath *, AP, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 139, Dos) + struct DosLibrary *, DOSBase, 139, Dos) /* FUNCTION - Free the memory and file locks that were allocated by calls to - MatchFirst() and MatchNext(). + Free the memory and file locks that were allocated by calls to + MatchFirst() and MatchNext(). INPUTS - AP - pointer to Anchor Path structure which had been passed to + AP - pointer to Anchor Path structure which had been passed to MatchFirst() before. RESULT - None. + None. NOTES @@ -53,35 +53,35 @@ { #if MATCHFUNCS_NO_DUPLOCK /* - ** CurrentDir to a valid lock, ie. one that will not be - ** killed further below - */ - + ** CurrentDir to a valid lock, ie. one that will not be + ** killed further below + */ + CurrentDir(ac->an_Lock); #endif - - while(ac) - { - acnext = ac->an_Child; - - /* - ** Dont unlock lock in first AChain because it is the same - ** as the current directory when MatchFirst was called. And - ** this lock was not DupLock()ed (except MATCHFUNCS_NO_DUPLOCK == 0)!!! - */ - - if (ac->an_Lock + + while(ac) + { + acnext = ac->an_Child; + + /* + ** Dont unlock lock in first AChain because it is the same + ** as the current directory when MatchFirst was called. And + ** this lock was not DupLock()ed (except MATCHFUNCS_NO_DUPLOCK == 0)!!! + */ + + if (ac->an_Lock #if MATCHFUNCS_NO_DUPLOCK - && (ac != AP->ap_Base) + && (ac != AP->ap_Base) #endif - ) - { - UnLock(ac->an_Lock); - } - Match_FreeAChain(ac, DOSBase); - - ac = acnext; - } + ) + { + UnLock(ac->an_Lock); + } + Match_FreeAChain(ac, DOSBase); + + ac = acnext; + } } AP->ap_Current = NULL; diff --git a/rom/dos/matchfirst.c b/rom/dos/matchfirst.c index 7b6f4eae49..e7a58ab1dd 100644 --- a/rom/dos/matchfirst.c +++ b/rom/dos/matchfirst.c @@ -17,34 +17,34 @@ #include #include - AROS_LH2(LONG, MatchFirst, + AROS_LH2(LONG, MatchFirst, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR , pat, D1), - AROS_LHA(struct AnchorPath *, AP , D2), + AROS_LHA(CONST_STRPTR , pat, D1), + AROS_LHA(struct AnchorPath *, AP , D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 137, Dos) + struct DosLibrary *, DOSBase, 137, Dos) /* 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 file 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(). + 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 file 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 - + AP - pointer to (initilized) AnchorPath structure + RESULT - 0 = success - other = DOS error code + 0 = success + other = DOS error code NOTES @@ -53,8 +53,8 @@ BUGS SEE ALSO - MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir() - + MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir() + INTERNALS @@ -62,8 +62,8 @@ { AROS_LIBFUNC_INIT - struct AChain *ac; - LONG error; + struct AChain *ac; + LONG error; AP->ap_Flags = 0; AP->ap_Base = 0; @@ -72,9 +72,9 @@ error = Match_BuildAChainList(pat, AP, &ac, DOSBase); if (error == 0) { - AP->ap_Base = AP->ap_Current = ac; + AP->ap_Base = AP->ap_Current = ac; - error = MatchNext(AP); + error = MatchNext(AP); } /* if (error == 0) */ diff --git a/rom/dos/matchnext.c b/rom/dos/matchnext.c dissimilarity index 83% index 05a408b9a7..527a1ebd98 100644 --- a/rom/dos/matchnext.c +++ b/rom/dos/matchnext.c @@ -1,447 +1,447 @@ -/* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: english -*/ -#include -#include -#include -#include -#include "dos_intern.h" -#include -#include - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH1(LONG, MatchNext, - -/* SYNOPSIS */ - AROS_LHA(struct AnchorPath *, AP, D1), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 138, Dos) - -/* FUNCTION - Find next file or directory that matches a given pattern. - See for more docs and how to control MatchNext(). - - INPUTS - AP - pointer to Anchor Path structure which had been passed to - MatchFirst() before. - - RESULT - Zero on success, or error code on failure. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - MatchFirst() MatchEnd() CurrentDir() Examine() ExNext() - ParsePattern() - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - struct AChain *ac = AP->ap_Current; - BPTR origdir; - LONG error = 0; - BOOL dir_changed = FALSE; - - origdir = CurrentDir(0); - CurrentDir(origdir); - - AP->ap_Flags &= ~APF_DIDDIR; - - /* - ** Check if we are asked to enter a directory, but only do this - ** if it is really possible - */ - - if ((AP->ap_Flags & APF_DODIR) && - (ac->an_Flags & DDF_ExaminedBit) && - (ac->an_Info.fib_DirEntryType > 0) && - (ac->an_Child == NULL)) - { - /* - ** Alloc a new AChain. Make it the active one. Set its string to - ** "#?" and mark it with DDF_AllBit Flag to indicate that this is a - ** "APF_DODIR-AChain". This is important for "back steppings", - ** because "APF_DODIR-AChains" must be removed and freed then and - ** the user must be notified about the leaving of a APF_DODIR-AChain - ** with APF_DIDDIR. - */ - - if ((ac->an_Child = Match_AllocAChain(1, DOSBase))) - { - ac->an_Child->an_Parent = ac; - ac = ac->an_Child; - AP->ap_Current = ac; - - ac->an_String[0] = P_ANY; - ac->an_String[1] = 0; - ac->an_Flags = DDF_PatternBit | DDF_AllBit; - - dir_changed = TRUE; - } - - /* - ** If the allocation did not work, we simple ignore APF_DODIR. Just - ** like if the user did not set this flag. Good idea or bad idea? - */ - } - - - /* Main loop for AChain traversing */ - - for(;;) - { - BOOL must_go_back = FALSE; - - /* Check for user breaks (CTRL_C, ...) */ - - if (AP->ap_BreakBits) - { - AP->ap_FoundBreak = CheckSignal(AP->ap_BreakBits); - if (AP->ap_FoundBreak) - { - error = ERROR_BREAK; - goto done; - } - } - - /* Check if AChain must be "setup" */ - - if (!(ac->an_Flags & DDF_ExaminedBit)) - { - /* - ** This AChain must be "setup". First AChain->an_Lock must point - ** to the parent directory, that is the directory where this - ** AChain is "in". ! - */ - - dir_changed = TRUE; - - if (ac->an_Parent) - { - CurrentDir(ac->an_Parent->an_Lock); - if (ac->an_Parent->an_Flags & DDF_PatternBit) - { - ac->an_Lock = Lock(ac->an_Parent->an_Info.fib_FileName, SHARED_LOCK); - } - else - { - ac->an_Lock = Lock(ac->an_Parent->an_String, SHARED_LOCK); - } - - if (!ac->an_Lock) - { - error = IoErr(); - goto done; - } - } -#if !MATCHFUNCS_NO_DUPLOCK - else - { - ac->an_Lock = DupLock(origdir); - - if (!ac->an_Lock) - { - error = IoErr(); - goto done; - } - - } -#else - /* - ** If there was no ac->an_Parent then we are dealing with the - ** first AChain whose lock was already setup in - ** Match_BuildAChainList - */ -#endif - - CurrentDir(ac->an_Lock); - - if (ac->an_Flags & DDF_PatternBit) - { - /* - ** If this is a pattern AChain we first Examine here our - ** parent directory, so that it then can be traversed with - ** ExNext - */ - if (!Examine(ac->an_Lock, &ac->an_Info)) - { - error = IoErr(); - goto done; - } - ac->an_Flags |= DDF_ExaminedBit; - - } /* if (ac->an_Flags & DDF_PatternBit) */ - else - { - BPTR lock; - LONG success; - - /* - ** This is a normal AChain (no pattern). Try to lock it - ** to see if it exists. - */ - - if (!(lock = Lock(ac->an_String, SHARED_LOCK))) - { - /* It does not exist, so if possible go back one step */ - - if ((AP->ap_Flags & APF_ITSWILD) && (ac->an_Parent)) - { - /* [2] */ - - must_go_back = TRUE; - } - else - { - /* if going back is not possible get error code and exit */ - error = IoErr(); - goto done; - } - - } /* if (!(lock = Lock(ac->an_String, SHARED_LOCK))) */ - else - { - /* The File/Direcory ac->an_String exists */ - - success = Examine(lock, &ac->an_Info); - UnLock(lock); - - if (!success) - { - /* - ** Examine()ing the file/directory did not - ** work, although the lock was successful!?. - ** Get error code and exit - */ - - error = IoErr(); - goto done; - } - - /* - ** This strcpy is necessary, because in case - ** of empty ac->an_String("") fib_FileName would - ** get parent directory name which it must not! - */ - - if (*ac->an_String == '\0') - { - strcpy(ac->an_Info.fib_FileName, ac->an_String); - } - - ac->an_Flags |= DDF_ExaminedBit; - - /* - ** If this is a file, but there are still more path - ** components to follow then we have to go back one step - ** (AChain) - */ - - if (ac->an_Child && (ac->an_Info.fib_DirEntryType < 0)) - { - /* [1] */ - - must_go_back = TRUE; - } - - /* - ** Here we either have found a matching file/directory - ** (result) or, if ac->an_Child != NULL we have still to - ** continue walking through the AChains until we are in - ** the last one. This all happens further below - */ - - } /* if (!(lock = Lock(ac->an_String, SHARED_LOCK))) else ... */ - - } /* if (ac->an_Flags & DDF_PatternBit) else ... */ - - } /* if (!(ac->an_Flags & DDF_ExaminedBit)) */ - else - { - /* - ** This AChain was already setup. - ** - ** When an AChain which is *not* a pattern already had - ** DDF_PatternBit set, then this means ERROR_NO_MORE_ENTRIES, so - ** we try to go back one step - */ - - if (!(ac->an_Flags & DDF_PatternBit)) - { - /* [4] */ - - must_go_back = TRUE; - } - } - - /* - ** Here we can be sure that the actual AChain is setup, ie: it will - ** have ac->an_Lock set correctly and to indicate this - ** DDF_ExaminedBit was set - */ - - CurrentDir(ac->an_Lock); - - if (ac->an_Flags & DDF_PatternBit) - { - if(ExNext(ac->an_Lock, &ac->an_Info)) - { - if (MatchPatternNoCase(ac->an_String, ac->an_Info.fib_FileName)) - { - /* - ** This file matches the pattern in ac->an_String. If - ** there are no more AChains to follow then we have - ** found a matching file/directory (a result) --> - ** break. - */ - - if (!ac->an_Child) - { - break; - } - else - { - if (ac->an_Info.fib_DirEntryType < 0) - { - /* This is a file, no chance to follow child - AChain. Go to top of "for(;;)" loop */ - continue; - } - } - - } else { - /* Did not match. Go to top of "for(;;)" loop */ - continue; - } - } - else - { - error = IoErr(); - if (error != ERROR_NO_MORE_ENTRIES) goto done; - - /* [3] */ - - must_go_back = TRUE; - } - - } /* if (ac->an_Flags & DDF_PatternBit) */ - - /* - ** Handle the cases where we must (try to) go back to the previous - ** AChain. This can happen if the actual AChain turned out to be a - ** file although there are still more AChains to follow [1]. Or if - ** the actual AChain did not exist at all [2]. Or if in a pattern - ** AChain ExNext() told us that there are no more entries [3]. Or if - ** we were getting to a normal (no pattern) AChain which was already - ** setup (DDF_ExaminedBit) [4]. - */ - - if (must_go_back) - { - /* Check if going back is possible at all */ - - if (!ac->an_Parent) - { - error = ERROR_NO_MORE_ENTRIES; - goto done; - } - - dir_changed = TRUE; - - /* Yep. It is possible. So let's cleanup the AChain. */ - - CurrentDir(ac->an_Parent->an_Lock); - - UnLock(ac->an_Lock); - - ac->an_Lock = BNULL; - ac->an_Flags &= ~DDF_ExaminedBit; - - /* Make ac and AP->ap_Current point to the previous AChain */ - - AP->ap_Current = ac->an_Parent; - - /* - ** If this was an APF_DODIR Achain (indicated by DDF_AllBit) - ** then the AChain must be unlinked and freed. And the user - ** must be informed about the leaving with APF_DIDDIR and - ** a "result" in AnchorPath which points to the directory which - ** was leaved. - */ - - if (ac->an_Flags & DDF_AllBit) - { - AP->ap_Current->an_Child = NULL; - Match_FreeAChain(ac, DOSBase); - AP->ap_Flags |= APF_DIDDIR; - - /* go out of for(;;) loop --> MakeResult */ - - break; - } - - ac = AP->ap_Current; - - } /* if (must_go_back) */ - else - { - if (!ac->an_Child) - { - /* - ** We have reached the last AChain. And this means that - ** we have found a matching file/directory :-)). Go out of - ** for(;;) loop --> MakeResult - */ - - break; - } - - ac = ac->an_Child; - AP->ap_Current = ac; - - dir_changed = TRUE; /* CHECKME!!! Really? */ - } - - } /* for(;;) */ - - error = Match_MakeResult(AP, DOSBase); - -done: - CurrentDir(origdir); - - AP->ap_Flags &= ~APF_DODIR; - - if (dir_changed) - { - AP->ap_Flags |= APF_DirChanged; - } - else - { - AP->ap_Flags &= ~APF_DirChanged; - } - - SetIoErr(error); - - return error; - - AROS_LIBFUNC_EXIT - -} /* MatchNext */ - +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: english +*/ +#include +#include +#include +#include +#include "dos_intern.h" +#include +#include + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH1(LONG, MatchNext, + +/* SYNOPSIS */ + AROS_LHA(struct AnchorPath *, AP, D1), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 138, Dos) + +/* FUNCTION + Find next file or directory that matches a given pattern. + See for more docs and how to control MatchNext(). + + INPUTS + AP - pointer to Anchor Path structure which had been passed to + MatchFirst() before. + + RESULT + Zero on success, or error code on failure. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + MatchFirst() MatchEnd() CurrentDir() Examine() ExNext() + ParsePattern() + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + struct AChain *ac = AP->ap_Current; + BPTR origdir; + LONG error = 0; + BOOL dir_changed = FALSE; + + origdir = CurrentDir(0); + CurrentDir(origdir); + + AP->ap_Flags &= ~APF_DIDDIR; + + /* + ** Check if we are asked to enter a directory, but only do this + ** if it is really possible + */ + + if ((AP->ap_Flags & APF_DODIR) && + (ac->an_Flags & DDF_ExaminedBit) && + (ac->an_Info.fib_DirEntryType > 0) && + (ac->an_Child == NULL)) + { + /* + ** Alloc a new AChain. Make it the active one. Set its string to + ** "#?" and mark it with DDF_AllBit Flag to indicate that this is a + ** "APF_DODIR-AChain". This is important for "back steppings", + ** because "APF_DODIR-AChains" must be removed and freed then and + ** the user must be notified about the leaving of a APF_DODIR-AChain + ** with APF_DIDDIR. + */ + + if ((ac->an_Child = Match_AllocAChain(1, DOSBase))) + { + ac->an_Child->an_Parent = ac; + ac = ac->an_Child; + AP->ap_Current = ac; + + ac->an_String[0] = P_ANY; + ac->an_String[1] = 0; + ac->an_Flags = DDF_PatternBit | DDF_AllBit; + + dir_changed = TRUE; + } + + /* + ** If the allocation did not work, we simple ignore APF_DODIR. Just + ** like if the user did not set this flag. Good idea or bad idea? + */ + } + + + /* Main loop for AChain traversing */ + + for(;;) + { + BOOL must_go_back = FALSE; + + /* Check for user breaks (CTRL_C, ...) */ + + if (AP->ap_BreakBits) + { + AP->ap_FoundBreak = CheckSignal(AP->ap_BreakBits); + if (AP->ap_FoundBreak) + { + error = ERROR_BREAK; + goto done; + } + } + + /* Check if AChain must be "setup" */ + + if (!(ac->an_Flags & DDF_ExaminedBit)) + { + /* + ** This AChain must be "setup". First AChain->an_Lock must point + ** to the parent directory, that is the directory where this + ** AChain is "in". ! + */ + + dir_changed = TRUE; + + if (ac->an_Parent) + { + CurrentDir(ac->an_Parent->an_Lock); + if (ac->an_Parent->an_Flags & DDF_PatternBit) + { + ac->an_Lock = Lock(ac->an_Parent->an_Info.fib_FileName, SHARED_LOCK); + } + else + { + ac->an_Lock = Lock(ac->an_Parent->an_String, SHARED_LOCK); + } + + if (!ac->an_Lock) + { + error = IoErr(); + goto done; + } + } +#if !MATCHFUNCS_NO_DUPLOCK + else + { + ac->an_Lock = DupLock(origdir); + + if (!ac->an_Lock) + { + error = IoErr(); + goto done; + } + + } +#else + /* + ** If there was no ac->an_Parent then we are dealing with the + ** first AChain whose lock was already setup in + ** Match_BuildAChainList + */ +#endif + + CurrentDir(ac->an_Lock); + + if (ac->an_Flags & DDF_PatternBit) + { + /* + ** If this is a pattern AChain we first Examine here our + ** parent directory, so that it then can be traversed with + ** ExNext + */ + if (!Examine(ac->an_Lock, &ac->an_Info)) + { + error = IoErr(); + goto done; + } + ac->an_Flags |= DDF_ExaminedBit; + + } /* if (ac->an_Flags & DDF_PatternBit) */ + else + { + BPTR lock; + LONG success; + + /* + ** This is a normal AChain (no pattern). Try to lock it + ** to see if it exists. + */ + + if (!(lock = Lock(ac->an_String, SHARED_LOCK))) + { + /* It does not exist, so if possible go back one step */ + + if ((AP->ap_Flags & APF_ITSWILD) && (ac->an_Parent)) + { + /* [2] */ + + must_go_back = TRUE; + } + else + { + /* if going back is not possible get error code and exit */ + error = IoErr(); + goto done; + } + + } /* if (!(lock = Lock(ac->an_String, SHARED_LOCK))) */ + else + { + /* The File/Direcory ac->an_String exists */ + + success = Examine(lock, &ac->an_Info); + UnLock(lock); + + if (!success) + { + /* + ** Examine()ing the file/directory did not + ** work, although the lock was successful!?. + ** Get error code and exit + */ + + error = IoErr(); + goto done; + } + + /* + ** This strcpy is necessary, because in case + ** of empty ac->an_String("") fib_FileName would + ** get parent directory name which it must not! + */ + + if (*ac->an_String == '\0') + { + strcpy(ac->an_Info.fib_FileName, ac->an_String); + } + + ac->an_Flags |= DDF_ExaminedBit; + + /* + ** If this is a file, but there are still more path + ** components to follow then we have to go back one step + ** (AChain) + */ + + if (ac->an_Child && (ac->an_Info.fib_DirEntryType < 0)) + { + /* [1] */ + + must_go_back = TRUE; + } + + /* + ** Here we either have found a matching file/directory + ** (result) or, if ac->an_Child != NULL we have still to + ** continue walking through the AChains until we are in + ** the last one. This all happens further below + */ + + } /* if (!(lock = Lock(ac->an_String, SHARED_LOCK))) else ... */ + + } /* if (ac->an_Flags & DDF_PatternBit) else ... */ + + } /* if (!(ac->an_Flags & DDF_ExaminedBit)) */ + else + { + /* + ** This AChain was already setup. + ** + ** When an AChain which is *not* a pattern already had + ** DDF_PatternBit set, then this means ERROR_NO_MORE_ENTRIES, so + ** we try to go back one step + */ + + if (!(ac->an_Flags & DDF_PatternBit)) + { + /* [4] */ + + must_go_back = TRUE; + } + } + + /* + ** Here we can be sure that the actual AChain is setup, ie: it will + ** have ac->an_Lock set correctly and to indicate this + ** DDF_ExaminedBit was set + */ + + CurrentDir(ac->an_Lock); + + if (ac->an_Flags & DDF_PatternBit) + { + if(ExNext(ac->an_Lock, &ac->an_Info)) + { + if (MatchPatternNoCase(ac->an_String, ac->an_Info.fib_FileName)) + { + /* + ** This file matches the pattern in ac->an_String. If + ** there are no more AChains to follow then we have + ** found a matching file/directory (a result) --> + ** break. + */ + + if (!ac->an_Child) + { + break; + } + else + { + if (ac->an_Info.fib_DirEntryType < 0) + { + /* This is a file, no chance to follow child + AChain. Go to top of "for(;;)" loop */ + continue; + } + } + + } else { + /* Did not match. Go to top of "for(;;)" loop */ + continue; + } + } + else + { + error = IoErr(); + if (error != ERROR_NO_MORE_ENTRIES) goto done; + + /* [3] */ + + must_go_back = TRUE; + } + + } /* if (ac->an_Flags & DDF_PatternBit) */ + + /* + ** Handle the cases where we must (try to) go back to the previous + ** AChain. This can happen if the actual AChain turned out to be a + ** file although there are still more AChains to follow [1]. Or if + ** the actual AChain did not exist at all [2]. Or if in a pattern + ** AChain ExNext() told us that there are no more entries [3]. Or if + ** we were getting to a normal (no pattern) AChain which was already + ** setup (DDF_ExaminedBit) [4]. + */ + + if (must_go_back) + { + /* Check if going back is possible at all */ + + if (!ac->an_Parent) + { + error = ERROR_NO_MORE_ENTRIES; + goto done; + } + + dir_changed = TRUE; + + /* Yep. It is possible. So let's cleanup the AChain. */ + + CurrentDir(ac->an_Parent->an_Lock); + + UnLock(ac->an_Lock); + + ac->an_Lock = BNULL; + ac->an_Flags &= ~DDF_ExaminedBit; + + /* Make ac and AP->ap_Current point to the previous AChain */ + + AP->ap_Current = ac->an_Parent; + + /* + ** If this was an APF_DODIR Achain (indicated by DDF_AllBit) + ** then the AChain must be unlinked and freed. And the user + ** must be informed about the leaving with APF_DIDDIR and + ** a "result" in AnchorPath which points to the directory which + ** was leaved. + */ + + if (ac->an_Flags & DDF_AllBit) + { + AP->ap_Current->an_Child = NULL; + Match_FreeAChain(ac, DOSBase); + AP->ap_Flags |= APF_DIDDIR; + + /* go out of for(;;) loop --> MakeResult */ + + break; + } + + ac = AP->ap_Current; + + } /* if (must_go_back) */ + else + { + if (!ac->an_Child) + { + /* + ** We have reached the last AChain. And this means that + ** we have found a matching file/directory :-)). Go out of + ** for(;;) loop --> MakeResult + */ + + break; + } + + ac = ac->an_Child; + AP->ap_Current = ac; + + dir_changed = TRUE; /* CHECKME!!! Really? */ + } + + } /* for(;;) */ + + error = Match_MakeResult(AP, DOSBase); + +done: + CurrentDir(origdir); + + AP->ap_Flags &= ~APF_DODIR; + + if (dir_changed) + { + AP->ap_Flags |= APF_DirChanged; + } + else + { + AP->ap_Flags &= ~APF_DirChanged; + } + + SetIoErr(error); + + return error; + + AROS_LIBFUNC_EXIT + +} /* MatchNext */ + diff --git a/rom/dos/matchpattern.c b/rom/dos/matchpattern.c index f99b77b5df..9a79d0207c 100644 --- a/rom/dos/matchpattern.c +++ b/rom/dos/matchpattern.c @@ -16,14 +16,14 @@ NAME */ #include - AROS_LH2(BOOL, MatchPattern, + AROS_LH2(BOOL, MatchPattern, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, pat, D1), - AROS_LHA(CONST_STRPTR, str, D2), + AROS_LHA(CONST_STRPTR, pat, D1), + AROS_LHA(CONST_STRPTR, str, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 141, Dos) + struct DosLibrary *, DOSBase, 141, Dos) /* FUNCTION @@ -56,6 +56,6 @@ AROS_LIBFUNC_INIT return patternMatch(pat, str, TRUE, DOSBase); - + AROS_LIBFUNC_EXIT } /* MatchPattern */ diff --git a/rom/dos/matchpatternnocase.c b/rom/dos/matchpatternnocase.c index 2c2ee615ac..5b96b3d289 100644 --- a/rom/dos/matchpatternnocase.c +++ b/rom/dos/matchpatternnocase.c @@ -17,14 +17,14 @@ NAME */ #include - AROS_LH2(BOOL, MatchPatternNoCase, + AROS_LH2(BOOL, MatchPatternNoCase, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, pat, D1), - AROS_LHA(CONST_STRPTR, str, D2), + AROS_LHA(CONST_STRPTR, pat, D1), + AROS_LHA(CONST_STRPTR, str, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 162, Dos) + struct DosLibrary *, DOSBase, 162, Dos) /* FUNCTION diff --git a/rom/dos/maxcli.c b/rom/dos/maxcli.c index 40c98a8af7..340096e8e2 100644 --- a/rom/dos/maxcli.c +++ b/rom/dos/maxcli.c @@ -14,22 +14,22 @@ NAME */ #include - AROS_LH0(ULONG, MaxCli, + AROS_LH0(ULONG, MaxCli, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 92, Dos) + struct DosLibrary *, DOSBase, 92, Dos) /* 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. + 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. INPUTS RESULT - Maximum Cli number (_not_ the number of Clis). + Maximum Cli number (_not_ the number of Clis). NOTES diff --git a/rom/dos/namefrom.c b/rom/dos/namefrom.c index 4ce73d3e16..9e67aec2e5 100644 --- a/rom/dos/namefrom.c +++ b/rom/dos/namefrom.c @@ -13,7 +13,7 @@ BOOL namefrom_internal(struct DosLibrary *DOSBase, BPTR lock, STRPTR buffer, LONG length) { - STRPTR s1, s2, name; + STRPTR s1, s2, name; D(STRPTR origbuffer;) BPTR parentlock, origlock; struct FileInfoBlock *fib; @@ -24,7 +24,7 @@ BOOL namefrom_internal(struct DosLibrary *DOSBase, BPTR lock, STRPTR buffer, LON D(origbuffer = buffer); D(bug("NameFromX(%x,%x,%d,%d)\n", BADDR(lock), buffer, length)); - + if (length < 1) { SetIoErr(ERROR_LINE_TOO_LONG); @@ -54,31 +54,31 @@ BOOL namefrom_internal(struct DosLibrary *DOSBase, BPTR lock, STRPTR buffer, LON /* Loop over path */ do { - error = dopacket2(DOSBase, NULL, port, ACTION_EXAMINE_OBJECT, lock, MKBADDR(fib)) == 0; - //bug("name='%s'\n", fib->fib_FileName); - if (!error) { - parentlock = (BPTR)dopacket1(DOSBase, &code, port, ACTION_PARENT, lock); - if (!parentlock && !first) - error = code; - //bug("parentlock=%x\n", parentlock); - } - if (lock != origlock && lock) - UnLock(lock); - lock = parentlock; - - /* Move name to the top of the buffer. */ - if(!error) - { - fixfib(fib); - s1 = s2 = fib->fib_FileName; + error = dopacket2(DOSBase, NULL, port, ACTION_EXAMINE_OBJECT, lock, MKBADDR(fib)) == 0; + //bug("name='%s'\n", fib->fib_FileName); + if (!error) { + parentlock = (BPTR)dopacket1(DOSBase, &code, port, ACTION_PARENT, lock); + if (!parentlock && !first) + error = code; + //bug("parentlock=%x\n", parentlock); + } + if (lock != origlock && lock) + UnLock(lock); + lock = parentlock; + + /* Move name to the top of the buffer. */ + if(!error) + { + fixfib(fib); + s1 = s2 = fib->fib_FileName; - while(*s2++) + while(*s2++) { ; } - - if(!parentlock) - { + + if(!parentlock) + { if (name > buffer) { *--name=':'; @@ -87,38 +87,38 @@ BOOL namefrom_internal(struct DosLibrary *DOSBase, BPTR lock, STRPTR buffer, LON { error = ERROR_LINE_TOO_LONG; } - } - else if(!first) - { + } + else if(!first) + { if (name > buffer) - { + { *--name = '/'; } else { error = ERROR_LINE_TOO_LONG; } - } + } - if (!error) - { - s2--; + if (!error) + { + s2--; - if (name - (s2 - s1) >= buffer) - { - while(s2 > s1) + if (name - (s2 - s1) >= buffer) + { + while(s2 > s1) { *--name = *--s2; } - } - else - { - error = ERROR_LINE_TOO_LONG; - } - } - - } /* if(!error) */ - first = FALSE; + } + else + { + error = ERROR_LINE_TOO_LONG; + } + } + + } /* if(!error) */ + first = FALSE; } while(!error && parentlock); @@ -127,19 +127,19 @@ BOOL namefrom_internal(struct DosLibrary *DOSBase, BPTR lock, STRPTR buffer, LON if (!error) { UBYTE c, old_c = '\0'; - - do - { - c = *name++; - - if ((c != '/') || (old_c != ':')) - { - *buffer++ = c; - } - - old_c = c; - - } + + do + { + c = *name++; + + if ((c != '/') || (old_c != ':')) + { + *buffer++ = c; + } + + old_c = c; + + } while (c); } diff --git a/rom/dos/namefromfh.c b/rom/dos/namefromfh.c index f858697b51..950f030245 100644 --- a/rom/dos/namefromfh.c +++ b/rom/dos/namefromfh.c @@ -15,30 +15,30 @@ NAME */ #include - AROS_LH3(BOOL, NameFromFH, + AROS_LH3(BOOL, NameFromFH, /* SYNOPSIS */ - AROS_LHA(BPTR, fh , D1), - AROS_LHA(STRPTR, buffer, D2), - AROS_LHA(LONG, length, D3), + AROS_LHA(BPTR, fh , D1), + AROS_LHA(STRPTR, buffer, D2), + AROS_LHA(LONG, length, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 68, Dos) + struct DosLibrary *, DOSBase, 68, Dos) /* FUNCTION - Get the full path name associated with file-handle into a - user supplied buffer. + Get the full path name associated with file-handle into a + user supplied buffer. INPUTS - fh - File-handle to file or directory. - buffer - Buffer to fill. Contains a NUL terminated string if - all went well. - length - Size of the buffer in bytes. + fh - File-handle 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. + !=0 if all went well, 0 in case of an error. IoErr() will + give additional information in that case. *****************************************************************************/ { @@ -55,24 +55,24 @@ fib = AllocDosObject(DOS_FIB, NULL); if (fib) { - parentlock = ParentOfFH(fh); - if (parentlock) { - if (NameFromLock(parentlock, buffer, length)) { - if (ExamineFH(fh, fib)) { - if (AddPart(buffer, fib->fib_FileName, length)) { - res = TRUE; - } - } - } - } - err = IoErr(); /* UnLock() clears pr_Result2 */ - FreeDosObject(DOS_FIB, fib); + parentlock = ParentOfFH(fh); + if (parentlock) { + if (NameFromLock(parentlock, buffer, length)) { + if (ExamineFH(fh, fib)) { + if (AddPart(buffer, fib->fib_FileName, length)) { + res = TRUE; + } + } + } + } + err = IoErr(); /* UnLock() clears pr_Result2 */ + FreeDosObject(DOS_FIB, fib); } else { - err = ERROR_NO_FREE_STORE; + err = ERROR_NO_FREE_STORE; } if (parentlock) - UnLock(parentlock); + UnLock(parentlock); SetIoErr(err); return res; diff --git a/rom/dos/namefromlock.c b/rom/dos/namefromlock.c index a71f81d325..e1a5014fb2 100644 --- a/rom/dos/namefromlock.c +++ b/rom/dos/namefromlock.c @@ -15,30 +15,30 @@ NAME */ #include - AROS_LH3(BOOL, NameFromLock, + AROS_LH3(BOOL, NameFromLock, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), - AROS_LHA(STRPTR, buffer, D2), - AROS_LHA(LONG, length, D3), + AROS_LHA(BPTR, lock, D1), + AROS_LHA(STRPTR, buffer, D2), + AROS_LHA(LONG, length, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 67, Dos) + struct DosLibrary *, DOSBase, 67, Dos) /* FUNCTION - Get the full path name associated with a lock to a file or - directory into a user supplied buffer. - If the lock is zero the buffer will be filled with "SYS:". + Get the full path name associated with a lock to a file or + directory into a user supplied buffer. + If the lock is zero the buffer will be filled with "SYS:". INPUTS - lock - Lock to file or directory or 0. - buffer - Buffer to fill. Contains a NUL terminated string if - all went well. - length - Size of the buffer in bytes. + lock - Lock to file or directory or 0. + 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. + !=0 if all went well, 0 in case of an error. IoErr() will + give additional information in that case. *****************************************************************************/ @@ -61,7 +61,7 @@ * * Duplicating a lock here is a brute-force workaround for this problem. When i have more time, i'll * pick up my old archive with MorphOS dos.library code, and check theirs implementation. - * Sonic + * Sonic */ BOOL res; BPTR lock2; diff --git a/rom/dos/newloadseg.c b/rom/dos/newloadseg.c index 278fba6dfb..493d23f5e4 100644 --- a/rom/dos/newloadseg.c +++ b/rom/dos/newloadseg.c @@ -21,7 +21,7 @@ /* SYNOPSIS */ AROS_LHA(CONST_STRPTR, file, D1), - AROS_LHA(struct TagItem *, tags, D2), + AROS_LHA(struct TagItem *, tags, D2), /* LOCATION */ struct DosLibrary *, DOSBase, 128, Dos) diff --git a/rom/dos/nextdosentry.c b/rom/dos/nextdosentry.c index e8924f48a8..9bdc04e87a 100644 --- a/rom/dos/nextdosentry.c +++ b/rom/dos/nextdosentry.c @@ -13,27 +13,27 @@ NAME */ #include - AROS_LH2I(struct DosList *, NextDosEntry, + AROS_LH2I(struct DosList *, NextDosEntry, /* SYNOPSIS */ - AROS_LHA(struct DosList *, dlist, D1), - AROS_LHA(ULONG , flags, D2), + AROS_LHA(struct DosList *, dlist, D1), + AROS_LHA(ULONG , flags, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 115, Dos) + struct DosLibrary *, DOSBase, 115, Dos) /* FUNCTION - Looks for the next dos list entry with the right type. The list - must be locked for this. + Looks for the next dos list entry with the right type. The list + must be locked for this. INPUTS - dlist - the value given by LockDosList() or the last call to - FindDosEntry(). - flags - the same flags as given to LockDosList() or a subset - of them. + dlist - the value given by LockDosList() or the last call to + FindDosEntry(). + 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. + Pointer to dos list entry found or NULL if the are no more entries. NOTES diff --git a/rom/dos/open.c b/rom/dos/open.c index 25451e8169..061d217cac 100644 --- a/rom/dos/open.c +++ b/rom/dos/open.c @@ -28,28 +28,28 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, NAME */ #include - AROS_LH2(BPTR, Open, + AROS_LH2(BPTR, Open, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(LONG, accessMode, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(LONG, accessMode, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 5, Dos) + struct DosLibrary *, DOSBase, 5, Dos) /* FUNCTION - Opens a file for read and/or write depending on the accessmode given. + Opens a file for read and/or write depending on the accessmode given. INPUTS - name - NUL terminated name of the file. - accessMode - One of MODE_OLDFILE - open existing file - MODE_NEWFILE - delete old, create new file - exclusive lock - MODE_READWRITE - open new one if it doesn't exist + name - NUL terminated name of the file. + accessMode - One of MODE_OLDFILE - open existing file + MODE_NEWFILE - delete old, create new file + exclusive lock + MODE_READWRITE - open new one if it doesn't exist RESULT - Handle to the file or 0 if the file couldn't be opened. - IoErr() gives additional information in that case. + Handle to the file or 0 if the file couldn't be opened. + IoErr() gives additional information in that case. NOTES @@ -76,20 +76,20 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, if (ret != NULL) { - LONG ok = InternalOpen(name, accessMode, ret, MAX_SOFT_LINK_NESTING, DOSBase); - D(bug("[Open] = %p, Error = %d\n", ok ? MKBADDR(ret) : BNULL, IoErr())); - if (ok) - { - return MKBADDR(ret); - } - else - { - error = IoErr(); - FreeDosObject(DOS_FILEHANDLE,ret); - } + LONG ok = InternalOpen(name, accessMode, ret, MAX_SOFT_LINK_NESTING, DOSBase); + D(bug("[Open] = %p, Error = %d\n", ok ? MKBADDR(ret) : BNULL, IoErr())); + if (ok) + { + return MKBADDR(ret); + } + else + { + error = IoErr(); + FreeDosObject(DOS_FILEHANDLE,ret); + } } else - error = ERROR_NO_FREE_STORE; + error = ERROR_NO_FREE_STORE; SetIoErr(error); return BNULL; @@ -146,13 +146,13 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, ASSERT_VALID_PROCESS(me); D(bug("[Open] %s: 0x%p \"%s\", Name: \"%s\" File: %p\n", - __is_process(me) ? "Process" : "Task", me, me->pr_Task.tc_Node.ln_Name, - name, MKBADDR(handle))); + __is_process(me) ? "Process" : "Task", me, me->pr_Task.tc_Node.ln_Name, + name, MKBADDR(handle))); if(soft_nesting == 0) { - SetIoErr(ERROR_TOO_MANY_LEVELS); - return DOSFALSE; + SetIoErr(ERROR_TOO_MANY_LEVELS); + return DOSFALSE; } /* IN:, OUT:, ERR: pseudodevices @@ -169,47 +169,47 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, */ if (!Stricmp(name, "NIL:")) { - SetIoErr(0); + SetIoErr(0); - handle->fh_Type = BNULL; - /* NIL: is not considered interactive */ - handle->fh_Interactive = DOSFALSE; + handle->fh_Type = BNULL; + /* NIL: is not considered interactive */ + handle->fh_Interactive = DOSFALSE; return DOSTRUE; } switch(accessMode) { - case MODE_NEWFILE: - case MODE_READWRITE: - con = me->pr_COS; - ast = me->pr_CES ? me->pr_CES : me->pr_COS; + case MODE_NEWFILE: + case MODE_READWRITE: + con = me->pr_COS; + ast = me->pr_CES ? me->pr_CES : me->pr_COS; - break; + break; - case MODE_OLDFILE: - ast = con = me->pr_CIS; - break; + case MODE_OLDFILE: + ast = con = me->pr_CIS; + break; - default: - SetIoErr(ERROR_NOT_IMPLEMENTED); - return DOSFALSE; + default: + SetIoErr(ERROR_NOT_IMPLEMENTED); + return DOSFALSE; } if (!Stricmp(name, "CONSOLE:")) - error = fs_Open(handle, me->pr_ConsoleTask, con, accessMode, name, DOSBase); + error = fs_Open(handle, me->pr_ConsoleTask, con, accessMode, name, DOSBase); else if (!Stricmp(name, "*")) - error = fs_Open(handle, me->pr_ConsoleTask, ast, accessMode, name, DOSBase); + error = fs_Open(handle, me->pr_ConsoleTask, ast, accessMode, name, DOSBase); else { BPTR cur = BNULL; struct DevProc *dvp = NULL; - STRPTR filename = strchr(name, ':'); + STRPTR filename = strchr(name, ':'); - if (!filename) - { - struct MsgPort *port; + if (!filename) + { + struct MsgPort *port; - /* No ':', pathname relative to current dir */ + /* No ':', pathname relative to current dir */ cur = me->pr_CurrentDir; if (cur && cur != (BPTR)-1) { @@ -219,27 +219,27 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, cur = BNULL; } - error = fs_Open(handle, port, cur, accessMode, name, DOSBase); - } - else - { - filename++; - do - { - if ((dvp = GetDeviceProc(name, dvp)) == NULL) - { + error = fs_Open(handle, port, cur, accessMode, name, DOSBase); + } + else + { + filename++; + do + { + if ((dvp = GetDeviceProc(name, dvp)) == NULL) + { error = IoErr(); break; - } + } - error = fs_Open(handle, dvp->dvp_Port, dvp->dvp_Lock, accessMode, filename, DOSBase); + error = fs_Open(handle, dvp->dvp_Port, dvp->dvp_Lock, accessMode, filename, DOSBase); } while(error == ERROR_OBJECT_NOT_FOUND && accessMode != MODE_NEWFILE); - if (error == ERROR_NO_MORE_ENTRIES) - error = ERROR_OBJECT_NOT_FOUND; + if (error == ERROR_NO_MORE_ENTRIES) + error = ERROR_OBJECT_NOT_FOUND; } - if (error == ERROR_IS_SOFT_LINK) + if (error == ERROR_IS_SOFT_LINK) { STRPTR softname = ResolveSoftlink(cur, dvp, name, DOSBase); @@ -248,27 +248,27 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, /* All OK */ BPTR olddir = BNULL; - if (dvp) - { + if (dvp) + { olddir = me->pr_CurrentDir; - error = RootDir(dvp, DOSBase); - } - else - error = 0; + error = RootDir(dvp, DOSBase); + } + else + error = 0; - if (!error) - { + if (!error) + { ret = InternalOpen(softname, accessMode, handle, soft_nesting - 1, DOSBase); error = ret ? 0 : IoErr(); if (olddir) - UnLock(CurrentDir(olddir)); + UnLock(CurrentDir(olddir)); } FreeVec(softname); } else - error = IoErr(); + error = IoErr(); } FreeDeviceProc(dvp); @@ -283,7 +283,7 @@ static LONG InternalOpen(CONST_STRPTR name, LONG accessMode, } else { - SetIoErr(error); - return DOSFALSE; + SetIoErr(error); + return DOSFALSE; } } diff --git a/rom/dos/openfromlock.c b/rom/dos/openfromlock.c index 17a85b9e65..4ffe477733 100644 --- a/rom/dos/openfromlock.c +++ b/rom/dos/openfromlock.c @@ -17,24 +17,24 @@ NAME */ #include - AROS_LH1(BPTR, OpenFromLock, + AROS_LH1(BPTR, OpenFromLock, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 63, Dos) + struct DosLibrary *, DOSBase, 63, Dos) /* FUNCTION - Convert a lock into a filehandle. If all went well the lock - will be gone. In case of an error it must still be freed. + Convert a lock into a filehandle. If all went well the lock + will be gone. In case of an error it must still be freed. INPUTS - lock - Lock to convert. + lock - Lock to convert. RESULT - New filehandle or 0 in case of an error. IoErr() will give - additional information in that case. + New filehandle or 0 in case of an error. IoErr() will give + additional information in that case. NOTES @@ -84,7 +84,7 @@ SetVBuf(MKBADDR(fh), NULL, BUF_NONE, -1); } } else { - SetIoErr(ERROR_NO_FREE_STORE); + SetIoErr(ERROR_NO_FREE_STORE); } D(bug("[OpenFromLock] %p => fh = %p (%p), error = %d\n", BADDR(lock), fh, fh->fh_Type, err)); diff --git a/rom/dos/output.c b/rom/dos/output.c index 8007d07c65..3ab51d041c 100644 --- a/rom/dos/output.c +++ b/rom/dos/output.c @@ -15,21 +15,21 @@ NAME */ #include - AROS_LH0(BPTR, Output, + AROS_LH0(BPTR, Output, /* SYNOPSIS */ /* LOCATION */ - struct DosLibrary *, DOSBase, 10, Dos) + struct DosLibrary *, DOSBase, 10, Dos) /* FUNCTION - Returns the current output stream or 0 if there is no current - output stream. + Returns the current output stream or 0 if there is no current + output stream. INPUTS RESULT - Output stream handle. + Output stream handle. NOTES diff --git a/rom/dos/packethelper.c b/rom/dos/packethelper.c index b21e9904b6..feea9d2441 100644 --- a/rom/dos/packethelper.c +++ b/rom/dos/packethelper.c @@ -18,10 +18,10 @@ BOOL getpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR name, struct PacketH { if (!strchr(name, ':')) { - /* no ":" */ - struct Process *me = (struct Process *)FindTask(NULL); + /* no ":" */ + struct Process *me = (struct Process *)FindTask(NULL); BPTR cur; - BSTR bstrname = C2BSTR(name); + BSTR bstrname = C2BSTR(name); struct FileLock *fl; ASSERT_VALID_PROCESS(me); @@ -39,7 +39,7 @@ BOOL getpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR name, struct PacketH phs->name = bstrname; return TRUE; } else { /* ":" */ - BSTR bstrname = C2BSTR(name); + BSTR bstrname = C2BSTR(name); struct DevProc *dvp = NULL; if ((dvp = GetDeviceProc(name, dvp))) { phs->name = bstrname; @@ -67,7 +67,7 @@ BOOL getdevpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR devname, CONST_ST phs->lock = BNULL; phs->name = BNULL; if (!name) - return TRUE; + return TRUE; phs->name = C2BSTR(name); if (!phs->name) { FreeDeviceProc(phs->dp); @@ -80,6 +80,6 @@ BOOL getdevpacketinfo(struct DosLibrary *DOSBase, CONST_STRPTR devname, CONST_ST void freepacketinfo(struct DosLibrary *DOSBase, struct PacketHelperStruct *phs) { if (phs->dp) - FreeDeviceProc(phs->dp); + FreeDeviceProc(phs->dp); FREEC2BSTR(phs->name); } diff --git a/rom/dos/parentdir.c b/rom/dos/parentdir.c index 95579e13bf..4653d8420f 100644 --- a/rom/dos/parentdir.c +++ b/rom/dos/parentdir.c @@ -16,25 +16,25 @@ #include #include - AROS_LH1(BPTR, ParentDir, + AROS_LH1(BPTR, ParentDir, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 35, Dos) + struct DosLibrary *, DOSBase, 35, Dos) /* FUNCTION - Returns a lock to the parent directory of the supplied lock. + Returns a lock to the parent directory of the supplied lock. INPUTS - lock - Lock to get parent directory of. + lock - Lock to get parent directory of. RESULT - Returns a lock to the parent directory or NULL, in which case the - supplied lock has no parent directory (because it is the root - directory) or an error occured. IoErr() returns 0 in the former case - and a different value on error. + Returns a lock to the parent directory or NULL, in which case the + supplied lock has no parent directory (because it is the root + directory) or an error occured. IoErr() returns 0 in the former case + and a different value on error. NOTES diff --git a/rom/dos/parentoffh.c b/rom/dos/parentoffh.c index 04ab8f7e4a..a0bb21e1b9 100644 --- a/rom/dos/parentoffh.c +++ b/rom/dos/parentoffh.c @@ -16,24 +16,24 @@ NAME */ #include - AROS_LH1(BPTR, ParentOfFH, + AROS_LH1(BPTR, ParentOfFH, /* SYNOPSIS */ - AROS_LHA(BPTR, fh, D1), + AROS_LHA(BPTR, fh, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 64, Dos) + struct DosLibrary *, DOSBase, 64, Dos) /* FUNCTION - Lock the directory a file is located in. + Lock the directory a file is located in. INPUTS - fh - Filhandle of which you want to obtain the parent - + fh - Filhandle of which you want to obtain the parent + RESULT - lock - Lock on the parent directory of the filehandle or - NULL for failure. - + lock - Lock on the parent directory of the filehandle or + NULL for failure. + NOTES @@ -42,8 +42,8 @@ BUGS SEE ALSO - Lock(), UnLock(), ParentDir() - + Lock(), UnLock(), ParentDir() + INTERNALS *****************************************************************************/ diff --git a/rom/dos/parsepattern.c b/rom/dos/parsepattern.c dissimilarity index 66% index 47c7f37616..fef98b4ca9 100644 --- a/rom/dos/parsepattern.c +++ b/rom/dos/parsepattern.c @@ -1,76 +1,76 @@ -/* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English -*/ -#include -#include -#include -#include -#include "dos_intern.h" - -/***************************************************************************** - - NAME */ -#include - - AROS_LH3(LONG, ParsePattern, - -/* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, Source, D1), - AROS_LHA(STRPTR, Dest, D2), - AROS_LHA(LONG, DestLength, D3), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 140, Dos) - -/* FUNCTION - Takes a pattern containing wildcards and transforms it into some - intermediate representation for use with the MatchPattern() function. - The intermediate representation is longer but generally a buffer - size of 2*(strlen(Source)+1) is enough. Nevertheless you should check - the returncode to be sure that everything went fine. - - INPUTS - Source - Pattern describing the kind of strings that match. - Possible tokens are: - #x - The following character or item is repeaded 0 or - more times. - ? - Item matching a single non-NUL character. - a|b|c - Matches one of multiple strings. - ~x - This item matches if the item x doesn't match. - (a) - Parens - [a-z] - Matches a single character out of the set. - [~a-z] - Matches a single non-NUL character not in the set. - 'c - Escapes the following character. - * - Same as #?, but optional. - Dest - Buffer for the destination. - DestLength - Size of the buffer. - - RESULT - 1 - There are wildcards in the pattern (it might match more than - one string). - 0 - No wildcards in it, all went fine. - -1 - An error happened. IoErr() gives additional information in - that case. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - return patternParse(Source, Dest, DestLength, TRUE, DOSBase); - - AROS_LIBFUNC_EXIT -} /* ParsePattern */ +/* + Copyright © 1995-2008, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ +#include +#include +#include +#include +#include "dos_intern.h" + +/***************************************************************************** + + NAME */ +#include + + AROS_LH3(LONG, ParsePattern, + +/* SYNOPSIS */ + AROS_LHA(CONST_STRPTR, Source, D1), + AROS_LHA(STRPTR, Dest, D2), + AROS_LHA(LONG, DestLength, D3), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 140, Dos) + +/* FUNCTION + Takes a pattern containing wildcards and transforms it into some + intermediate representation for use with the MatchPattern() function. + The intermediate representation is longer but generally a buffer + size of 2*(strlen(Source)+1) is enough. Nevertheless you should check + the returncode to be sure that everything went fine. + + INPUTS + Source - Pattern describing the kind of strings that match. + Possible tokens are: + #x - The following character or item is repeaded 0 or + more times. + ? - Item matching a single non-NUL character. + a|b|c - Matches one of multiple strings. + ~x - This item matches if the item x doesn't match. + (a) - Parens + [a-z] - Matches a single character out of the set. + [~a-z] - Matches a single non-NUL character not in the set. + 'c - Escapes the following character. + * - Same as #?, but optional. + Dest - Buffer for the destination. + DestLength - Size of the buffer. + + RESULT + 1 - There are wildcards in the pattern (it might match more than + one string). + 0 - No wildcards in it, all went fine. + -1 - An error happened. IoErr() gives additional information in + that case. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + return patternParse(Source, Dest, DestLength, TRUE, DOSBase); + + AROS_LIBFUNC_EXIT +} /* ParsePattern */ diff --git a/rom/dos/parsepatternnocase.c b/rom/dos/parsepatternnocase.c index e17b06a9a0..b7db801dc1 100644 --- a/rom/dos/parsepatternnocase.c +++ b/rom/dos/parsepatternnocase.c @@ -17,19 +17,19 @@ NAME */ #include - AROS_LH3(LONG, ParsePatternNoCase, + AROS_LH3(LONG, ParsePatternNoCase, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, Source, D1), - AROS_LHA(STRPTR, Dest, D2), - AROS_LHA(LONG, DestLength, D3), + AROS_LHA(CONST_STRPTR, Source, D1), + AROS_LHA(STRPTR, Dest, D2), + AROS_LHA(LONG, DestLength, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 161, Dos) + struct DosLibrary *, DOSBase, 161, Dos) /* FUNCTION - Similar to ParsePattern(), only case insensitive (see there - for more information). For use with MatchPatternNoCase(). + Similar to ParsePattern(), only case insensitive (see there + for more information). For use with MatchPatternNoCase(). INPUTS @@ -42,7 +42,7 @@ BUGS SEE ALSO - ParsePattern(), MatchPatternNoCase() + ParsePattern(), MatchPatternNoCase() INTERNALS diff --git a/rom/dos/pathpart.c b/rom/dos/pathpart.c index e4016426ee..8849c43ab3 100644 --- a/rom/dos/pathpart.c +++ b/rom/dos/pathpart.c @@ -21,29 +21,29 @@ NAME */ #include - AROS_LH1(STRPTR, PathPart, + AROS_LH1(STRPTR, PathPart, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, path, D1), + AROS_LHA(CONST_STRPTR, path, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 146, Dos) + struct DosLibrary *, DOSBase, 146, Dos) /* FUNCTION - Returns a pointer to the character after the last - directory in path (see examples). + Returns a pointer to the character after the last + directory in path (see examples). INPUTS - path - Search this path. + path - Search this path. RESULT - A pointer to a character in path. + A pointer to a character in path. NOTES EXAMPLE - PathPart("xxx:yyy/zzz/qqq") would return a pointer to the last '/'. - PathPart("xxx:yyy") would return a pointer to the first 'y'). + PathPart("xxx:yyy/zzz/qqq") would return a pointer to the last '/'. + PathPart("xxx:yyy") would return a pointer to the first 'y'). BUGS @@ -60,23 +60,23 @@ /* '/' at the beginning of the string really is part of the path */ while (*path == '/') { - ++path; + ++path; } ptr = path; while (*ptr) { - if (*ptr == '/') - { - path = ptr; - } - else if (*ptr == ':') - { - path = ptr + 1; - } - - ptr++; + if (*ptr == '/') + { + path = ptr; + } + else if (*ptr == ':') + { + path = ptr + 1; + } + + ptr++; } return (STRPTR)path; @@ -94,10 +94,10 @@ int main (int argc, char ** argv) while (--argc) { - s = *++argv; - fileptr = PathPart(s); + s = *++argv; + fileptr = PathPart(s); - printf("Pfad: %s\nErg.: %s\n", s, fileptr); + printf("Pfad: %s\nErg.: %s\n", s, fileptr); } } diff --git a/rom/dos/patternmatching.c b/rom/dos/patternmatching.c dissimilarity index 69% index 7119e73be9..6d7937cb2a 100644 --- a/rom/dos/patternmatching.c +++ b/rom/dos/patternmatching.c @@ -1,638 +1,638 @@ -/* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Pattern matching and parsing functionality - Lang: English -*/ - -#include -#include -#include -#include -#include -#include - -#include "dos_intern.h" - -/* - A simple method for pattern matching with multiple wildcards: - I use markers that consist of both a pointer into the string - and one into the pattern. The marker simply follows the string - and everytime it hits a wildcard it's split into two new markers - (one to assume that the wildcard match has ended and one to assume - that it continues). If a marker doesn't fit any longer it's - removed and if all of them are gone the pattern mismatches. - OTOH if any of the markers reaches the end of both the string - and the pattern simultaneously the pattern matches the string. -*/ - -/* - * INPUTS - * - * pat -- Pattern string (as returned by ParsePatternXXXX()) - * str -- The string to match against the pattern 'pat' - * case -- Determines if the case is important or not - * DOSBase -- dos.library base - * - */ - - -BOOL patternMatch(CONST_STRPTR pat, CONST_STRPTR str, BOOL useCase, - struct DosLibrary *DOSBase) -{ - CONST_STRPTR s; - BOOL match = FALSE; - - struct markerarray ma; - struct markerarray *macur = &ma; - struct markerarray *cur2; - - LONG macnt = 0; - LONG cnt2; - - ULONG level; - UBYTE a, b, c, t; - - LONG error; - -#undef ERROR -#define ERROR(a) { error = (a); goto end; } - - ma.next = ma.prev = NULL; - - while(TRUE) - { - switch(*pat) - { - case P_REPBEG: /* _#(_a), _#a_ or _#[_a] */ - PUSH(0, ++pat, str); - level = 1; - - while(TRUE) - { - c = *pat++; - - if(c == P_REPBEG) - { - level++; - } - else if(c == P_REPEND) - { - if(!--level) - { - break; - } - } - } - break; - - case P_REPEND: /* #(a_)_ */ - level = 1; - - while(TRUE) - { - c = *--pat; - - if(c == P_REPEND) - { - level++; - } - else if(c == P_REPBEG) - { - if(!--level) - { - break; - } - } - } - break; - - case P_NOT: /* _~(_a) */ - s = ++pat; - level = 1; - - while(TRUE) - { - c = *s++; - - if(c == P_NOT) - { - level++; - } - else if(c == P_NOTEND) - { - if(!--level) - { - break; - } - } - } - - PUSH(1, s, str); - break; - - case P_NOTEND: /* ~(a_)_ */ - cnt2 = macnt; - cur2 = macur; - - do - { - cnt2--; - - if(cnt2 < 0) - { - cnt2 = 127; - cur2 = cur2->prev; - } - }while(!cur2->marker[cnt2].type); - - if(!*str++) - { - macnt = cnt2; - macur=cur2; - } - else if(str > cur2->marker[cnt2].str) - { - cur2->marker[cnt2].str = str; - } - - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - - break; - - case P_ORSTART: /* ( */ - s = ++pat; - level = 1; - - while(TRUE) - { - c = *s++; - - if(c == P_ORSTART) - { - level++; - } - else if(c == P_ORNEXT) - { - if(level == 1) - { - PUSH(0, s, str); - } - } - else if(c == P_OREND) - { - if(!--level) - { - break; - } - } - } - - break; - - case P_ORNEXT: /* | */ - pat++; - level = 1; - - while(TRUE) - { - c = *pat++; - - if(c == P_ORSTART) - { - level++; - } - else if(c == P_OREND) - { - if(!--level) - { - break; - } - } - } - - break; - - case P_OREND: /* ) */ - pat++; - break; - - case P_SINGLE: /* ? */ - pat++; - - if(*str) - { - str++; - } - else - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - } - - break; - - case P_CLASS: /* [ */ - pat++; - - while(TRUE) - { - a = b = *pat++; - - if(a == P_CLASS) - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - - break; - } - - if(*pat == '-') - { - b = *++pat; - - if(b == P_CLASS) - { - b = 255; - } - } - - if(useCase) - { - c = *str; - } - else - { - c = ToUpper(*str); - } - - if(c >= a && c <= b) - { - str++; - - while(*pat++ != P_CLASS) - ; - - break; - } - } - - break; - - case P_NOTCLASS: /* [~ */ - if(!*str) - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - - break; - } - - pat++; - - while(TRUE) - { - a = b = *pat++; - - if(a == P_CLASS) - { - str++; - break; - } - - if(*pat == '-') - { - b = *++pat; - - if(b == P_CLASS) - { - b = 255; - } - } - - if(useCase) - { - c = *str; - } - else - { - c = ToUpper(*str); - } - - if(c >= a && c <= b) - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - - break; - } - } - - break; - - case P_ANY: /* #? */ - /* This often used pattern has extra treatment to be faster */ - if(*str) - { - PUSH(0, pat, str + 1); - } - - pat++; - break; - - case 0: - if(!*str) - { - match = TRUE; - ERROR(0); - } - else - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - } - break; - - default: - { - UBYTE ch; - - if(useCase) - { - ch = *str; - } - else - { - ch = ToUpper(*str); - } - - if(*pat++ == ch) - { - str++; - } - else - { - POP(t, pat, str); - - if(t && *str) - { - PUSH(1, pat, str + 1); - } - } - } - - break; - - } /* switch(*pat) */ - } /* while(TRUE) */ - - end: - - macur = ma.next; - - while(macur != NULL) - { - struct markerarray *next = macur->next; - - FreeMem(macur, sizeof(struct markerarray)); - macur = next; - } - - SetIoErr(error); - - return match; -} - - -LONG patternParse(CONST_STRPTR Source, STRPTR Dest, LONG DestLength, - BOOL useCase, struct DosLibrary *DOSBase) -{ - STRPTR stack; - STRPTR end; - UBYTE a; - LONG iswild = 0; - -#undef ERROR -#define ERROR(a) { SetIoErr(a); return -1; } - stack = end = Dest + DestLength; -#define PUT(a) { if(Dest >= stack) ERROR(ERROR_BUFFER_OVERFLOW); *Dest++ = (a); } - - if(!*Source) - { - PUT(0); - return 0; - } - - while(*Source) - { - switch(*Source++) - { - case '#': - iswild = 1; - - switch(*Source) - { - case '?': - Source++; - PUT(P_ANY); - break; - - case ')': - case '\0': - ERROR(ERROR_BAD_TEMPLATE); - break; - - default: - PUT(P_REPBEG); - *--stack = P_REPEND; - continue; - } - - break; - - case '~': - switch(*Source) - { - case '\0': - a = Source[-1]; - PUT(useCase ? a : ToUpper(a)); - break; - - case ')': - ERROR(ERROR_BAD_TEMPLATE); - break; - - default: - iswild = 1; - PUT(P_NOT); - *--stack = P_NOTEND; - continue; - } - - break; - - case '?': - iswild = 1; - PUT(P_SINGLE); - continue; - - case '(': - PUT(P_ORSTART); - *--stack = P_OREND; - continue; - - case '|': - iswild = 1; - - if(stack == end) - { - ERROR(ERROR_BAD_TEMPLATE); - } - - while(!(*stack == P_OREND || stack == end)) - { - PUT(*stack++); - } - - PUT(P_ORNEXT); - continue; - - case ')': - while(!(stack == end || *stack == P_OREND)) - { - PUT(*stack++); - } - - if(stack == end) - { - ERROR(ERROR_BAD_TEMPLATE); - } - else - { - PUT(*stack++); - } - - break; - - case '[': - iswild = 1; - - if(*Source == '~') - { - Source++; - PUT(P_NOTCLASS); - } - else - { - PUT(P_CLASS); - } - - a = *Source++; - - if(!a) - { - ERROR(ERROR_BAD_TEMPLATE); - } - - do - { - if(a == '\'') - { - a=*Source++; - } - - PUT(useCase ? a : ToUpper(a)); - a = *Source++; - - if(!a) - { - ERROR(ERROR_BAD_TEMPLATE); - } - } while(a != ']'); - - PUT(P_CLASS); - break; - - case '*': - if (DOSBase->dl_Root->rn_Flags & RNF_WILDSTAR) - { - iswild = 1; - PUT(P_ANY); - } - else - { - PUT('*'); - } - - break; - - case '%': - continue; - - case '\'': - switch(*Source) - { - case '#': - case '*': - case '?': - case '(': - case '|': - case ')': - case '~': - case '[': - case ']': - case '%': - case '\'': - Source++; - default: - break; - } - - /* Fall through */ - default: - a = Source[-1]; - PUT(useCase ? a : ToUpper(a)); - break; - } - - while(stack != end && *stack != P_OREND) - { - PUT(*stack++); - } - } - - if(stack != end) - { - ERROR(ERROR_BAD_TEMPLATE); - } - - PUT(0); - - return iswild; -} +/* + Copyright © 1995-2011, The AROS Development Team. All rights reserved. + $Id$ + + Desc: Pattern matching and parsing functionality + Lang: English +*/ + +#include +#include +#include +#include +#include +#include + +#include "dos_intern.h" + +/* + A simple method for pattern matching with multiple wildcards: + I use markers that consist of both a pointer into the string + and one into the pattern. The marker simply follows the string + and everytime it hits a wildcard it's split into two new markers + (one to assume that the wildcard match has ended and one to assume + that it continues). If a marker doesn't fit any longer it's + removed and if all of them are gone the pattern mismatches. + OTOH if any of the markers reaches the end of both the string + and the pattern simultaneously the pattern matches the string. +*/ + +/* + * INPUTS + * + * pat -- Pattern string (as returned by ParsePatternXXXX()) + * str -- The string to match against the pattern 'pat' + * case -- Determines if the case is important or not + * DOSBase -- dos.library base + * + */ + + +BOOL patternMatch(CONST_STRPTR pat, CONST_STRPTR str, BOOL useCase, + struct DosLibrary *DOSBase) +{ + CONST_STRPTR s; + BOOL match = FALSE; + + struct markerarray ma; + struct markerarray *macur = &ma; + struct markerarray *cur2; + + LONG macnt = 0; + LONG cnt2; + + ULONG level; + UBYTE a, b, c, t; + + LONG error; + +#undef ERROR +#define ERROR(a) { error = (a); goto end; } + + ma.next = ma.prev = NULL; + + while(TRUE) + { + switch(*pat) + { + case P_REPBEG: /* _#(_a), _#a_ or _#[_a] */ + PUSH(0, ++pat, str); + level = 1; + + while(TRUE) + { + c = *pat++; + + if(c == P_REPBEG) + { + level++; + } + else if(c == P_REPEND) + { + if(!--level) + { + break; + } + } + } + break; + + case P_REPEND: /* #(a_)_ */ + level = 1; + + while(TRUE) + { + c = *--pat; + + if(c == P_REPEND) + { + level++; + } + else if(c == P_REPBEG) + { + if(!--level) + { + break; + } + } + } + break; + + case P_NOT: /* _~(_a) */ + s = ++pat; + level = 1; + + while(TRUE) + { + c = *s++; + + if(c == P_NOT) + { + level++; + } + else if(c == P_NOTEND) + { + if(!--level) + { + break; + } + } + } + + PUSH(1, s, str); + break; + + case P_NOTEND: /* ~(a_)_ */ + cnt2 = macnt; + cur2 = macur; + + do + { + cnt2--; + + if(cnt2 < 0) + { + cnt2 = 127; + cur2 = cur2->prev; + } + }while(!cur2->marker[cnt2].type); + + if(!*str++) + { + macnt = cnt2; + macur=cur2; + } + else if(str > cur2->marker[cnt2].str) + { + cur2->marker[cnt2].str = str; + } + + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + + break; + + case P_ORSTART: /* ( */ + s = ++pat; + level = 1; + + while(TRUE) + { + c = *s++; + + if(c == P_ORSTART) + { + level++; + } + else if(c == P_ORNEXT) + { + if(level == 1) + { + PUSH(0, s, str); + } + } + else if(c == P_OREND) + { + if(!--level) + { + break; + } + } + } + + break; + + case P_ORNEXT: /* | */ + pat++; + level = 1; + + while(TRUE) + { + c = *pat++; + + if(c == P_ORSTART) + { + level++; + } + else if(c == P_OREND) + { + if(!--level) + { + break; + } + } + } + + break; + + case P_OREND: /* ) */ + pat++; + break; + + case P_SINGLE: /* ? */ + pat++; + + if(*str) + { + str++; + } + else + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + } + + break; + + case P_CLASS: /* [ */ + pat++; + + while(TRUE) + { + a = b = *pat++; + + if(a == P_CLASS) + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + + break; + } + + if(*pat == '-') + { + b = *++pat; + + if(b == P_CLASS) + { + b = 255; + } + } + + if(useCase) + { + c = *str; + } + else + { + c = ToUpper(*str); + } + + if(c >= a && c <= b) + { + str++; + + while(*pat++ != P_CLASS) + ; + + break; + } + } + + break; + + case P_NOTCLASS: /* [~ */ + if(!*str) + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + + break; + } + + pat++; + + while(TRUE) + { + a = b = *pat++; + + if(a == P_CLASS) + { + str++; + break; + } + + if(*pat == '-') + { + b = *++pat; + + if(b == P_CLASS) + { + b = 255; + } + } + + if(useCase) + { + c = *str; + } + else + { + c = ToUpper(*str); + } + + if(c >= a && c <= b) + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + + break; + } + } + + break; + + case P_ANY: /* #? */ + /* This often used pattern has extra treatment to be faster */ + if(*str) + { + PUSH(0, pat, str + 1); + } + + pat++; + break; + + case 0: + if(!*str) + { + match = TRUE; + ERROR(0); + } + else + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + } + break; + + default: + { + UBYTE ch; + + if(useCase) + { + ch = *str; + } + else + { + ch = ToUpper(*str); + } + + if(*pat++ == ch) + { + str++; + } + else + { + POP(t, pat, str); + + if(t && *str) + { + PUSH(1, pat, str + 1); + } + } + } + + break; + + } /* switch(*pat) */ + } /* while(TRUE) */ + + end: + + macur = ma.next; + + while(macur != NULL) + { + struct markerarray *next = macur->next; + + FreeMem(macur, sizeof(struct markerarray)); + macur = next; + } + + SetIoErr(error); + + return match; +} + + +LONG patternParse(CONST_STRPTR Source, STRPTR Dest, LONG DestLength, + BOOL useCase, struct DosLibrary *DOSBase) +{ + STRPTR stack; + STRPTR end; + UBYTE a; + LONG iswild = 0; + +#undef ERROR +#define ERROR(a) { SetIoErr(a); return -1; } + stack = end = Dest + DestLength; +#define PUT(a) { if(Dest >= stack) ERROR(ERROR_BUFFER_OVERFLOW); *Dest++ = (a); } + + if(!*Source) + { + PUT(0); + return 0; + } + + while(*Source) + { + switch(*Source++) + { + case '#': + iswild = 1; + + switch(*Source) + { + case '?': + Source++; + PUT(P_ANY); + break; + + case ')': + case '\0': + ERROR(ERROR_BAD_TEMPLATE); + break; + + default: + PUT(P_REPBEG); + *--stack = P_REPEND; + continue; + } + + break; + + case '~': + switch(*Source) + { + case '\0': + a = Source[-1]; + PUT(useCase ? a : ToUpper(a)); + break; + + case ')': + ERROR(ERROR_BAD_TEMPLATE); + break; + + default: + iswild = 1; + PUT(P_NOT); + *--stack = P_NOTEND; + continue; + } + + break; + + case '?': + iswild = 1; + PUT(P_SINGLE); + continue; + + case '(': + PUT(P_ORSTART); + *--stack = P_OREND; + continue; + + case '|': + iswild = 1; + + if(stack == end) + { + ERROR(ERROR_BAD_TEMPLATE); + } + + while(!(*stack == P_OREND || stack == end)) + { + PUT(*stack++); + } + + PUT(P_ORNEXT); + continue; + + case ')': + while(!(stack == end || *stack == P_OREND)) + { + PUT(*stack++); + } + + if(stack == end) + { + ERROR(ERROR_BAD_TEMPLATE); + } + else + { + PUT(*stack++); + } + + break; + + case '[': + iswild = 1; + + if(*Source == '~') + { + Source++; + PUT(P_NOTCLASS); + } + else + { + PUT(P_CLASS); + } + + a = *Source++; + + if(!a) + { + ERROR(ERROR_BAD_TEMPLATE); + } + + do + { + if(a == '\'') + { + a=*Source++; + } + + PUT(useCase ? a : ToUpper(a)); + a = *Source++; + + if(!a) + { + ERROR(ERROR_BAD_TEMPLATE); + } + } while(a != ']'); + + PUT(P_CLASS); + break; + + case '*': + if (DOSBase->dl_Root->rn_Flags & RNF_WILDSTAR) + { + iswild = 1; + PUT(P_ANY); + } + else + { + PUT('*'); + } + + break; + + case '%': + continue; + + case '\'': + switch(*Source) + { + case '#': + case '*': + case '?': + case '(': + case '|': + case ')': + case '~': + case '[': + case ']': + case '%': + case '\'': + Source++; + default: + break; + } + + /* Fall through */ + default: + a = Source[-1]; + PUT(useCase ? a : ToUpper(a)); + break; + } + + while(stack != end && *stack != P_OREND) + { + PUT(*stack++); + } + } + + if(stack != end) + { + ERROR(ERROR_BAD_TEMPLATE); + } + + PUT(0); + + return iswild; +} diff --git a/rom/dos/printfault.c b/rom/dos/printfault.c index c5ee2749d0..5f6a4d7190 100644 --- a/rom/dos/printfault.c +++ b/rom/dos/printfault.c @@ -16,27 +16,27 @@ NAME */ #include - AROS_LH2(BOOL, PrintFault, + AROS_LH2(BOOL, PrintFault, /* SYNOPSIS */ - AROS_LHA(LONG, code, D1), - AROS_LHA(CONST_STRPTR, header, D2), + AROS_LHA(LONG, code, D1), + AROS_LHA(CONST_STRPTR, header, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 79, Dos) + struct DosLibrary *, DOSBase, 79, Dos) /* FUNCTION - Prints the header and the text associated with the error code to - the console (buffered), then sets the value returned by IoErr() to - the error code given. + Prints the header and the text associated with the error code to + the console (buffered), then sets the value returned by IoErr() to + the error code given. INPUTS - code -- Error code. - header -- Text to print before the error message. This may be NULL + code -- Error code. + header -- Text to print before the error message. This may be NULL in which case only the error message is printed. RESULT - Boolean success indicator. + Boolean success indicator. NOTES @@ -45,7 +45,7 @@ BUGS SEE ALSO - IoErr(), Fault(), SetIoErr() + IoErr(), Fault(), SetIoErr() INTERNALS @@ -69,30 +69,30 @@ if (code == 0) { - ret = DOSTRUE; + ret = DOSTRUE; } else if (header != NULL) { - if(!FPuts(stream, header) && !FPuts(stream, ": ") && - !FPuts(stream, buffer) && !FPuts(stream, "\n")) - { - ret = DOSTRUE; - } - else - { - ret = DOSFALSE; - } + if(!FPuts(stream, header) && !FPuts(stream, ": ") && + !FPuts(stream, buffer) && !FPuts(stream, "\n")) + { + ret = DOSTRUE; + } + else + { + ret = DOSFALSE; + } } else { - if (!FPuts(stream, buffer) && !FPuts(stream,"\n")) - { - ret = DOSTRUE; - } - else - { - ret = DOSFALSE; - } + if (!FPuts(stream, buffer) && !FPuts(stream,"\n")) + { + ret = DOSTRUE; + } + else + { + ret = DOSFALSE; + } } /* All done. */ diff --git a/rom/dos/putstr.c b/rom/dos/putstr.c index 1dbb19dde4..0ab27c8af2 100644 --- a/rom/dos/putstr.c +++ b/rom/dos/putstr.c @@ -16,14 +16,14 @@ NAME */ #include - AROS_LH1(LONG, PutStr, + AROS_LH1(LONG, PutStr, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, string, D1), + AROS_LHA(CONST_STRPTR, string, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 158, Dos) + struct DosLibrary *, DOSBase, 158, Dos) /* FUNCTION This routine writes an unformatted string to the default output. No diff --git a/rom/dos/read.c b/rom/dos/read.c index 72d31f37a7..42665de450 100644 --- a/rom/dos/read.c +++ b/rom/dos/read.c @@ -16,33 +16,33 @@ NAME */ #include - AROS_LH3(LONG, Read, + AROS_LH3(LONG, Read, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(APTR, buffer, D2), - AROS_LHA(LONG, length, D3), + AROS_LHA(BPTR, file, D1), + AROS_LHA(APTR, buffer, D2), + AROS_LHA(LONG, length, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 7, Dos) + struct DosLibrary *, DOSBase, 7, Dos) /* FUNCTION - Read some data from a given file. The request is directly - given to the filesystem - no buffering is involved. For - small amounts of data it's probably better to use the - buffered I/O routines. + Read some data from a given file. The request is directly + given to the filesystem - no buffering is involved. For + small amounts of data it's probably better to use the + buffered I/O routines. INPUTS - file - filehandle - buffer - pointer to buffer for the data - length - number of bytes to read. The filesystem is - advised to try to fulfill the request as good - as possible. + file - filehandle + buffer - pointer to buffer for the data + length - number of bytes to read. The filesystem is + advised to try to fulfill the request as good + as possible. RESULT - The number of bytes actually read, 0 if the end of the - file was reached, -1 if an error happened. IoErr() will - give additional information in that case. + The number of bytes actually read, 0 if the end of the + file was reached, -1 if an error happened. IoErr() will + give additional information in that case. NOTES @@ -67,11 +67,11 @@ D(bug("[Read] %x %x %d\n", fh, buffer, length)); if (fh == NULL) - SetIoErr(ERROR_INVALID_LOCK); + SetIoErr(ERROR_INVALID_LOCK); else if (fh->fh_Type == BNULL) - ret = 0; + ret = 0; else - ret = dopacket3(DOSBase, NULL, fh->fh_Type, ACTION_READ, fh->fh_Arg1, (SIPTR)buffer, length); + ret = dopacket3(DOSBase, NULL, fh->fh_Type, ACTION_READ, fh->fh_Arg1, (SIPTR)buffer, length); D(bug("[Read]=%d\n", ret)); return ret; diff --git a/rom/dos/readitem.c b/rom/dos/readitem.c index 9dfb9d1a02..248fab94c8 100644 --- a/rom/dos/readitem.c +++ b/rom/dos/readitem.c @@ -16,57 +16,57 @@ NAME */ #include - AROS_LH3(LONG, ReadItem, + AROS_LH3(LONG, ReadItem, /* SYNOPSIS */ - AROS_LHA(STRPTR, buffer, D1), - AROS_LHA(LONG, maxchars, D2), - AROS_LHA(struct CSource *, input, D3), + AROS_LHA(STRPTR, buffer, D1), + AROS_LHA(LONG, maxchars, D2), + AROS_LHA(struct CSource *, input, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 135, Dos) + struct DosLibrary *, DOSBase, 135, Dos) /* FUNCTION - Read an item from a given character source. Items are words - or quoted strings separated by whitespace or '=' just like on - the commandline. The separator is unread and the output string - is terminated by a NUL character. + Read an item from a given character source. Items are words + or quoted strings separated by whitespace or '=' just like on + the commandline. The separator is unread and the output string + is terminated by a NUL character. INPUTS - buffer - Buffer to be filled. - maxchars - Size of the buffer. Must be at least 1 (for the NUL + buffer - Buffer to be filled. + maxchars - Size of the buffer. Must be at least 1 (for the NUL terminator). - input - A ready to use CSource structure or NULL which means - "read from the input stream". + input - A ready to use CSource structure or NULL which means + "read from the input stream". RESULT - One of ITEM_UNQUOTED - Normal word read. - ITEM_QUOTED - Quoted string read. - ITEM_NOTHING - End of line found. Nothing read. - ITEM_EQUAL - '=' read. Buffer is empty. - ITEM_ERROR - An error happened. IoErr() gives additional - information in that case. + One of ITEM_UNQUOTED - Normal word read. + ITEM_QUOTED - Quoted string read. + ITEM_NOTHING - End of line found. Nothing read. + ITEM_EQUAL - '=' read. Buffer is empty. + ITEM_ERROR - An error happened. IoErr() gives additional + information in that case. NOTES - This function handles conversion of '**', '*"', etc inside quotes. + This function handles conversion of '**', '*"', etc inside quotes. - This function has well known bugs, and should be avoided - in new applications. + This function has well known bugs, and should be avoided + in new applications. EXAMPLE BUGS - 1. Forgets to unread a separator character (equal sign, whitespace or - tabulation). - 2. Tries to unread an end-of-line, which actually causes unreading the - last read character of CSource is supplied. Even if it's not a separator, - but belongs to last read item. - 3. IoErr() is never modified by this function. + 1. Forgets to unread a separator character (equal sign, whitespace or + tabulation). + 2. Tries to unread an end-of-line, which actually causes unreading the + last read character of CSource is supplied. Even if it's not a separator, + but belongs to last read item. + 3. IoErr() is never modified by this function. - As AOS programs that use ReadItem() depend on this broken behaviour, - it will not be fixed. + As AOS programs that use ReadItem() depend on this broken behaviour, + it will not be fixed. - 4. If maxchars == 0, buff[0] is set to 0 anyway. + 4. If maxchars == 0, buff[0] is set to 0 anyway. SEE ALSO @@ -85,16 +85,16 @@ */ /* Macro to get a character from the input source */ -#define GET(c) \ -if(input!=NULL) \ -{ \ - if(input->CS_CurChr>=input->CS_Length) \ - c=EOF; \ - else \ - c=input->CS_Buffer[input->CS_CurChr++]; \ -}else \ -{ \ - c=FGetC(Input()); \ +#define GET(c) \ +if(input!=NULL) \ +{ \ + if(input->CS_CurChr>=input->CS_Length) \ + c=EOF; \ + else \ + c=input->CS_Buffer[input->CS_CurChr++]; \ +}else \ +{ \ + c=FGetC(Input()); \ } /* Macro to push the character back */ diff --git a/rom/dos/readlink.c b/rom/dos/readlink.c index 00a9e3bd58..691c0858dd 100644 --- a/rom/dos/readlink.c +++ b/rom/dos/readlink.c @@ -21,35 +21,35 @@ struct ReadLinkDeviceUnit NAME */ #include - AROS_LH5(LONG, ReadLink, + AROS_LH5(LONG, ReadLink, /* SYNOPSIS */ - AROS_LHA(struct MsgPort *, port, D1), - AROS_LHA(BPTR , lock, D2), - AROS_LHA(CONST_STRPTR , path, D3), - AROS_LHA(STRPTR , buffer, D4), - AROS_LHA(ULONG , size, D5), + AROS_LHA(struct MsgPort *, port, D1), + AROS_LHA(BPTR , lock, D2), + AROS_LHA(CONST_STRPTR , path, D3), + AROS_LHA(STRPTR , buffer, D4), + AROS_LHA(ULONG , size, D5), /* LOCATION */ - struct DosLibrary *, DOSBase, 73, Dos) + struct DosLibrary *, DOSBase, 73, Dos) /* FUNCTION - Read the filename referred to by the soft-linked object contained - in |path| (relative to the lock |lock|) into the buffer |buffer|. - The variable |path| should contain the name of the object that - caused the original OBJECT_IS_SOFT_LINK error. + Read the filename referred to by the soft-linked object contained + in |path| (relative to the lock |lock|) into the buffer |buffer|. + The variable |path| should contain the name of the object that + caused the original OBJECT_IS_SOFT_LINK error. INPUTS - port - The handler to send the request to. - lock - Object that |path| is relative to. - path - Name of the object that caused the error. - buffer - Buffer to fill with resolved filename. - size - Length of the buffer. + port - The handler to send the request to. + lock - Object that |path| is relative to. + path - Name of the object that caused the error. + buffer - Buffer to fill with resolved filename. + size - Length of the buffer. RESULT - >= 0 length of resolved filename in case of success - == -1 failure, see IoErr() for more information - == -2 buffer size was too small to store resolved filename + >= 0 length of resolved filename in case of success + == -1 failure, see IoErr() for more information + == -2 buffer size was too small to store resolved filename NOTES @@ -58,7 +58,7 @@ struct ReadLinkDeviceUnit BUGS SEE ALSO - MakeLink() + MakeLink() INTERNALS diff --git a/rom/dos/relabel.c b/rom/dos/relabel.c index d7c84f6bc3..364217700b 100644 --- a/rom/dos/relabel.c +++ b/rom/dos/relabel.c @@ -14,14 +14,14 @@ NAME */ #include - AROS_LH2(LONG, Relabel, + AROS_LH2(LONG, Relabel, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, drive, D1), - AROS_LHA(CONST_STRPTR, newname, D2), + AROS_LHA(CONST_STRPTR, drive, D1), + AROS_LHA(CONST_STRPTR, newname, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 120, Dos) + struct DosLibrary *, DOSBase, 120, Dos) /* FUNCTION @@ -54,7 +54,7 @@ LONG status = DOSFALSE; if (!getdevpacketinfo(DOSBase, drive, newname, &phs)) - return DOSFALSE; + return DOSFALSE; status = dopacket1(DOSBase, NULL, phs.port, ACTION_RENAME_DISK, phs.name); diff --git a/rom/dos/remassignlist.c b/rom/dos/remassignlist.c dissimilarity index 63% index 874fd3ca62..8cd39f2542 100644 --- a/rom/dos/remassignlist.c +++ b/rom/dos/remassignlist.c @@ -1,136 +1,136 @@ -/* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. - $Id$ - - Desc: RemAssignList() - Remove an entry from a multi-dir assign. - Lang: English -*/ - -#include -#include "dos_intern.h" -#include - -/***************************************************************************** - - NAME */ -#include - - AROS_LH2(LONG, RemAssignList, - -/* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(BPTR , lock, D2), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 106, Dos) - -/* FUNCTION - Remove an entry from a multi-dir assign. The entry removed will be - the first one that the SameLock() function called on the 'lock' - parameter returns that they belong to the same object. - - The entry for this lock will be removed from the lock, and the - lock for the entry in the list will be unlocked. - - INPUTS - name - Name of the device to remove lock from. This should - not contain the trailing ':'. - lock - Lock on the object to remove from the list. - - RESULT - success - Have we actually succeeded - - NOTES - - EXAMPLE - - BUGS - If this is the first lock in a list, this will not set - dol_Device/dol_Unit correctly. - - SEE ALSO - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - struct DosList *dl = NULL; - BOOL res = DOSFALSE; - - D(bug("RemAssignList: name = \"%s\", lock = $%lx\n", name, lock)); - dl = LockDosList(LDF_ASSIGNS | LDF_WRITE); - - while (!res && (dl = FindDosEntry(dl, name, LDF_ASSIGNS))) - { - struct AssignList *al, *lastal = NULL; - - al = dl->dol_misc.dol_assign.dol_List; - - /* - We have a matching element, lets find the correct - member to remove. Initially check the inline lock. - */ - - if (SameLock(dl->dol_Lock, lock) == LOCK_SAME) - { - /* - This is a bit tricky, me move the first element - in the list to the header - */ - - UnLock(dl->dol_Lock); - - if (al) - { - dl->dol_misc.dol_assign.dol_List = al->al_Next; - dl->dol_Lock = al->al_Lock; - FreeVec(al); - } - else - { - RemDosEntry(dl); - FreeDosEntry(dl); - } - - res = DOSTRUE; - } - else - { - while (al) - { - if (SameLock(al->al_Lock, lock) == LOCK_SAME) - { - /* Remove this element. Singly linked list */ - if (lastal == NULL) - { - /* First element of list... */ - dl->dol_misc.dol_assign.dol_List = al->al_Next; - } - else - { - lastal->al_Next = al->al_Next; - } - - UnLock(al->al_Lock); - FreeVec(al); - al = NULL; - res = DOSTRUE; - } - else - { - lastal = al; - al = al->al_Next; - } - } - } /* in the assignlist */ - - } /* the assign exists */ - - UnLockDosList(LDF_ASSIGNS | LDF_WRITE); - - return res; - - AROS_LIBFUNC_EXIT -} /* RemAssignList */ +/* + Copyright © 1995-2008, The AROS Development Team. All rights reserved. + $Id$ + + Desc: RemAssignList() - Remove an entry from a multi-dir assign. + Lang: English +*/ + +#include +#include "dos_intern.h" +#include + +/***************************************************************************** + + NAME */ +#include + + AROS_LH2(LONG, RemAssignList, + +/* SYNOPSIS */ + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(BPTR , lock, D2), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 106, Dos) + +/* FUNCTION + Remove an entry from a multi-dir assign. The entry removed will be + the first one that the SameLock() function called on the 'lock' + parameter returns that they belong to the same object. + + The entry for this lock will be removed from the lock, and the + lock for the entry in the list will be unlocked. + + INPUTS + name - Name of the device to remove lock from. This should + not contain the trailing ':'. + lock - Lock on the object to remove from the list. + + RESULT + success - Have we actually succeeded + + NOTES + + EXAMPLE + + BUGS + If this is the first lock in a list, this will not set + dol_Device/dol_Unit correctly. + + SEE ALSO + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + struct DosList *dl = NULL; + BOOL res = DOSFALSE; + + D(bug("RemAssignList: name = \"%s\", lock = $%lx\n", name, lock)); + dl = LockDosList(LDF_ASSIGNS | LDF_WRITE); + + while (!res && (dl = FindDosEntry(dl, name, LDF_ASSIGNS))) + { + struct AssignList *al, *lastal = NULL; + + al = dl->dol_misc.dol_assign.dol_List; + + /* + We have a matching element, lets find the correct + member to remove. Initially check the inline lock. + */ + + if (SameLock(dl->dol_Lock, lock) == LOCK_SAME) + { + /* + This is a bit tricky, me move the first element + in the list to the header + */ + + UnLock(dl->dol_Lock); + + if (al) + { + dl->dol_misc.dol_assign.dol_List = al->al_Next; + dl->dol_Lock = al->al_Lock; + FreeVec(al); + } + else + { + RemDosEntry(dl); + FreeDosEntry(dl); + } + + res = DOSTRUE; + } + else + { + while (al) + { + if (SameLock(al->al_Lock, lock) == LOCK_SAME) + { + /* Remove this element. Singly linked list */ + if (lastal == NULL) + { + /* First element of list... */ + dl->dol_misc.dol_assign.dol_List = al->al_Next; + } + else + { + lastal->al_Next = al->al_Next; + } + + UnLock(al->al_Lock); + FreeVec(al); + al = NULL; + res = DOSTRUE; + } + else + { + lastal = al; + al = al->al_Next; + } + } + } /* in the assignlist */ + + } /* the assign exists */ + + UnLockDosList(LDF_ASSIGNS | LDF_WRITE); + + return res; + + AROS_LIBFUNC_EXIT +} /* RemAssignList */ diff --git a/rom/dos/remdosentry.c b/rom/dos/remdosentry.c index 74ca6c948c..262c5e1f29 100644 --- a/rom/dos/remdosentry.c +++ b/rom/dos/remdosentry.c @@ -13,30 +13,30 @@ NAME */ #include - AROS_LH1(LONG, RemDosEntry, + AROS_LH1(LONG, RemDosEntry, /* SYNOPSIS */ - AROS_LHA(struct DosList *, dlist, D1), + AROS_LHA(struct DosList *, dlist, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 112, Dos) + struct DosLibrary *, DOSBase, 112, Dos) /* FUNCTION - Removes a given dos list entry from the dos list. Automatically - locks the list for writing. + Removes a given dos list entry from the dos list. Automatically + locks the list for writing. INPUTS - dlist - pointer to dos list entry. + dlist - pointer to dos list entry. RESULT - !=0 if all went well, 0 otherwise. + !=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. + 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. EXAMPLE @@ -52,7 +52,7 @@ struct DosList *dl; if(dlist == NULL) - return 0; + return 0; dl = LockDosList(LDF_ALL | LDF_WRITE); @@ -61,12 +61,12 @@ struct DosList *dl2 = BADDR(dl->dol_Next); if(dl2 == dlist) - { - dl->dol_Next = dlist->dol_Next; - break; - } + { + dl->dol_Next = dlist->dol_Next; + break; + } - dl = dl2; + dl = dl2; } UnLockDosList(LDF_ALL | LDF_WRITE); diff --git a/rom/dos/remsegment.c b/rom/dos/remsegment.c index d5543d8c82..7449be7865 100644 --- a/rom/dos/remsegment.c +++ b/rom/dos/remsegment.c @@ -16,27 +16,27 @@ #include #include - AROS_LH1(LONG, RemSegment, + AROS_LH1(LONG, RemSegment, /* SYNOPSIS */ - AROS_LHA(struct Segment *, seg, D1), + AROS_LHA(struct Segment *, seg, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 131, Dos) + struct DosLibrary *, DOSBase, 131, Dos) /* FUNCTION - Remove the segment seg from the DOS resident command list. + Remove the segment seg from the DOS resident command list. - The segment to be removed should be in the list, and should - have a usercount of 0. System or internal segment cannot be - removed (although they can be replaced). + The segment to be removed should be in the list, and should + have a usercount of 0. System or internal segment cannot be + removed (although they can be replaced). INPUTS - seg - Segment to remove. + seg - Segment to remove. RESULT - != 0 Segment was removed - == 0 Segment was not removed (not in list, or not free). + != 0 Segment was removed + == 0 Segment was not removed (not in list, or not free). NOTES @@ -45,7 +45,7 @@ BUGS SEE ALSO - AddSegment(), FindSegment() + AddSegment(), FindSegment() INTERNALS @@ -60,31 +60,31 @@ if (seg->seg_UC == 0) #endif { - struct Segment *next, *prev; - struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info); - - prev = NULL; - next = BADDR(dinf->di_ResList); - while (next != NULL) - { - if (next == seg) - { - if (prev) - { - prev->seg_Next = next->seg_Next; - } - else - { - dinf->di_ResList = next->seg_Next; - } - UnLoadSeg(seg->seg_Seg); - FreeVec(seg); - return DOSTRUE; - } - - prev = next; - next = BADDR(next->seg_Next); - } + struct Segment *next, *prev; + struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info); + + prev = NULL; + next = BADDR(dinf->di_ResList); + while (next != NULL) + { + if (next == seg) + { + if (prev) + { + prev->seg_Next = next->seg_Next; + } + else + { + dinf->di_ResList = next->seg_Next; + } + UnLoadSeg(seg->seg_Seg); + FreeVec(seg); + return DOSTRUE; + } + + prev = next; + next = BADDR(next->seg_Next); + } } return DOSFALSE; diff --git a/rom/dos/rename.c b/rom/dos/rename.c index 465aca8c29..aaf251abb8 100644 --- a/rom/dos/rename.c +++ b/rom/dos/rename.c @@ -17,26 +17,26 @@ #include #include - AROS_LH2(LONG, Rename, + AROS_LH2(LONG, Rename, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, oldName, D1), - AROS_LHA(CONST_STRPTR, newName, D2), + AROS_LHA(CONST_STRPTR, oldName, D1), + AROS_LHA(CONST_STRPTR, newName, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 13, Dos) + struct DosLibrary *, DOSBase, 13, Dos) /* FUNCTION - Renames a given file. The old name and the new name must point to the - same volume. + Renames a given file. The old name and the new name must point to the + same volume. INPUTS - oldName - Name of the file to rename - newName - New name of the file to rename + oldName - Name of the file to rename + newName - New name of the file to rename RESULT - boolean - DOSTRUE or DOSFALSE. IoErr() provides additional information - on DOSFALSE. + boolean - DOSTRUE or DOSFALSE. IoErr() provides additional information + on DOSFALSE. NOTES @@ -47,7 +47,7 @@ SEE ALSO INTERNALS - Calls the action FSA_RENAME on the filesystem-handler. + Calls the action FSA_RENAME on the filesystem-handler. *****************************************************************************/ { @@ -67,86 +67,86 @@ if (len > 0) { - /* get real name */ - BPTR lock = Lock(oldName, SHARED_LOCK); - if (lock) - { - if (NameFromLock(lock, buf1, sizeof(buf1) - 1)) - oldName = buf1; - UnLock(lock); - } + /* get real name */ + BPTR lock = Lock(oldName, SHARED_LOCK); + if (lock) + { + if (NameFromLock(lock, buf1, sizeof(buf1) - 1)) + oldName = buf1; + UnLock(lock); + } } else { - /* convert to absolute path */ - if (NameFromLock(me->pr_CurrentDir, buf1, sizeof(buf1) - 1)) - { - int namelen = strlen(oldName); - len = strlen(buf1); - if (len + namelen < sizeof(buf1) - 1) - { - if (buf1[len - 1] != ':') - buf1[len++] = '/'; - CopyMem(oldName, buf1 + len, namelen + 1); - oldName = buf1; - } - } + /* convert to absolute path */ + if (NameFromLock(me->pr_CurrentDir, buf1, sizeof(buf1) - 1)) + { + int namelen = strlen(oldName); + len = strlen(buf1); + if (len + namelen < sizeof(buf1) - 1) + { + if (buf1[len - 1] != ':') + buf1[len++] = '/'; + CopyMem(oldName, buf1 + len, namelen + 1); + oldName = buf1; + } + } } len = SplitName(newName, ':', vol, 0, sizeof(vol) - 1); if (len > 0) { - /* get real name of destination path */ - BPTR lock; - char *pos; - const char *pos2; - - strcpy(buf2, newName); - pos = strrchr(buf2, '/'); - if (!pos) - { - pos = buf2 + len; - *pos = '\0'; - } - else - *pos++ = '\0'; - - lock = Lock(buf2, SHARED_LOCK); - if (lock) - { - if (NameFromLock(lock, buf2, sizeof(buf2) - 1)) - { - int namelen; - len = strlen(buf2); - pos2 = newName + (int)(pos - buf2); - namelen = strlen(pos2); - if (len + namelen < sizeof(buf2) - 1) - { - if (buf2[len - 1] != ':') - buf2[len++] = '/'; - CopyMem(pos2, buf2 + len, namelen + 1); - newName = buf2; - } - } - UnLock(lock); - } + /* get real name of destination path */ + BPTR lock; + char *pos; + const char *pos2; + + strcpy(buf2, newName); + pos = strrchr(buf2, '/'); + if (!pos) + { + pos = buf2 + len; + *pos = '\0'; + } + else + *pos++ = '\0'; + + lock = Lock(buf2, SHARED_LOCK); + if (lock) + { + if (NameFromLock(lock, buf2, sizeof(buf2) - 1)) + { + int namelen; + len = strlen(buf2); + pos2 = newName + (int)(pos - buf2); + namelen = strlen(pos2); + if (len + namelen < sizeof(buf2) - 1) + { + if (buf2[len - 1] != ':') + buf2[len++] = '/'; + CopyMem(pos2, buf2 + len, namelen + 1); + newName = buf2; + } + } + UnLock(lock); + } } else { - /* convert to absolute path */ - if (NameFromLock(me->pr_CurrentDir, buf2, sizeof(buf2) - 1)) - { - int namelen = strlen(newName); - len = strlen(buf2); - if (len + namelen < sizeof(buf2) - 1) - { - if (buf2[len - 1] != ':') - buf2[len++] = '/'; - CopyMem(newName, buf2 + len, namelen + 1); - newName = buf2; - } - } + /* convert to absolute path */ + if (NameFromLock(me->pr_CurrentDir, buf2, sizeof(buf2) - 1)) + { + int namelen = strlen(newName); + len = strlen(buf2); + if (len + namelen < sizeof(buf2) - 1) + { + if (buf2[len - 1] != ':') + buf2[len++] = '/'; + CopyMem(newName, buf2 + len, namelen + 1); + newName = buf2; + } + } } D(bug("[Dos] rename %s %s\n", oldName, newName)); diff --git a/rom/dos/replypkt.c b/rom/dos/replypkt.c index f48f4acad5..3085a03be2 100644 --- a/rom/dos/replypkt.c +++ b/rom/dos/replypkt.c @@ -18,15 +18,15 @@ #include #include - AROS_LH3(void, ReplyPkt, + AROS_LH3(void, ReplyPkt, /* SYNOPSIS */ - AROS_LHA(struct DosPacket *, dp, D1), - AROS_LHA(SIPTR , res1, D2), - AROS_LHA(LONG , res2, D3), + AROS_LHA(struct DosPacket *, dp, D1), + AROS_LHA(SIPTR , res1, D2), + AROS_LHA(LONG , res2, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 43, Dos) + struct DosLibrary *, DOSBase, 43, Dos) /* FUNCTION diff --git a/rom/dos/rootnode.c b/rom/dos/rootnode.c index 678716ab64..bb1ec4dd47 100644 --- a/rom/dos/rootnode.c +++ b/rom/dos/rootnode.c @@ -26,7 +26,7 @@ void addprocesstoroot(struct Process *process, struct DosLibrary *DOSBase) ULONG i; struct CommandLineInterface *cli = - (struct CommandLineInterface *)BADDR(process->pr_CLI); + (struct CommandLineInterface *)BADDR(process->pr_CLI); struct RootNode *root = DOSBase->dl_Root; @@ -35,12 +35,12 @@ void addprocesstoroot(struct Process *process, struct DosLibrary *DOSBase) D(bug("Calling addprocesstoroot(%p) with cli = %p\n", process, cli)); if(cli == NULL) - return; + return; ci = (struct CLIInfo *)AllocVec(sizeof(struct CLIInfo), MEMF_PUBLIC); if(ci == NULL) - return; + return; ObtainSemaphore(&root->rn_RootLock); @@ -117,7 +117,7 @@ void removefromrootnode(struct Process *process, struct DosLibrary *DOSBase) if (!__is_process(process) || process->pr_CLI == BNULL) { D(bug("[removefromrootnode] Strange. Doesn't seem be a CLI...\n")); - return; + return; } ObtainSemaphore(&root->rn_RootLock); diff --git a/rom/dos/runcommand.c b/rom/dos/runcommand.c index 7445a39b0f..de119fb9c2 100644 --- a/rom/dos/runcommand.c +++ b/rom/dos/runcommand.c @@ -22,45 +22,45 @@ NAME */ #include - AROS_LH4(LONG, RunCommand, + AROS_LH4(LONG, RunCommand, /* SYNOPSIS */ - AROS_LHA(BPTR, segList, D1), - AROS_LHA(ULONG, stacksize, D2), - AROS_LHA(CONST_STRPTR, argptr, D3), - AROS_LHA(ULONG, argsize, D4), + AROS_LHA(BPTR, segList, D1), + AROS_LHA(ULONG, stacksize, D2), + AROS_LHA(CONST_STRPTR, argptr, D3), + AROS_LHA(ULONG, argsize, D4), /* LOCATION */ - struct DosLibrary *, DOSBase, 84, Dos) + struct DosLibrary *, DOSBase, 84, Dos) /* FUNCTION - RunCommand() will run the command loaded in the |segList| with the - arguments specified with a new stack of |stacksize| bytes. Note - that the stacksize may be extended if this is required. + RunCommand() will run the command loaded in the |segList| with the + arguments specified with a new stack of |stacksize| bytes. Note + that the stacksize may be extended if this is required. - The return code of the command run will be returned. + The return code of the command run will be returned. - This call will not return until the command has completed. + This call will not return until the command has completed. INPUTS - segList - segment of program to run. - stacksize - size of the stack to use. - argptr - pointer to NULL-terminated arguments. - argsize - size of the arguments string. + segList - segment of program to run. + stacksize - size of the stack to use. + argptr - pointer to NULL-terminated arguments. + argsize - size of the arguments string. RESULT - The return code from the program. See also IoErr(). + The return code from the program. See also IoErr(). NOTES - Programs expect the argument string to end with a newline ('\n') - character (ReadArgs() requires it to work properly). + Programs expect the argument string to end with a newline ('\n') + character (ReadArgs() requires it to work properly). EXAMPLE BUGS SEE ALSO - SystemTagList() + SystemTagList() INTERNALS @@ -83,11 +83,11 @@ ASSERT_VALID_PROCESS(me); if(stacksize < AROS_STACKSIZE) - stacksize = AROS_STACKSIZE; + stacksize = AROS_STACKSIZE; stack=(UBYTE *)AllocMem(stacksize,MEMF_ANY); if(stack==NULL) - return -1; + return -1; sss.stk_Lower=stack; sss.stk_Upper=stack+stacksize; diff --git a/rom/dos/runhandler.c b/rom/dos/runhandler.c index 57ba6e4b1f..9fc8184bb1 100644 --- a/rom/dos/runhandler.c +++ b/rom/dos/runhandler.c @@ -27,86 +27,86 @@ void BCPL_RunHandler(void); struct MsgPort *RunHandler(struct DeviceNode *deviceNode, const char *path, struct DosLibrary *DOSBase) { - D(struct FileSysStartupMsg *fssm = NULL;) - struct DosPacket *dp; - struct MsgPort *reply_port; - struct Process *process = NULL; - BSTR bpath; - ULONG len; - CONST_STRPTR handler; - APTR entry; - - handler = AROS_BSTR_ADDR(deviceNode->dn_Handler); - - /* No possible way to continue? */ - if (deviceNode->dn_SegList == BNULL && handler == NULL) - return NULL; - - if (deviceNode->dn_SegList == BNULL) { - struct Segment *seg = NULL; - - /* Try to find in the Resident Segment list */ - Forbid(); - D(bug("[RunHandler] Looking for handler '%s' in resident list\n", - handler)); - seg = FindSegment(handler, NULL, TRUE); - Permit(); - - deviceNode->dn_SegList = seg ? seg->seg_Seg : BNULL; - } - - if (deviceNode->dn_SegList == BNULL) { - D(bug("[RunHandler] LoadSeg(\"%s\")\n", handler)); - - deviceNode->dn_SegList = LoadSeg(handler); + D(struct FileSysStartupMsg *fssm = NULL;) + struct DosPacket *dp; + struct MsgPort *reply_port; + struct Process *process = NULL; + BSTR bpath; + ULONG len; + CONST_STRPTR handler; + APTR entry; + + handler = AROS_BSTR_ADDR(deviceNode->dn_Handler); + + /* No possible way to continue? */ + if (deviceNode->dn_SegList == BNULL && handler == NULL) + return NULL; + + if (deviceNode->dn_SegList == BNULL) { + struct Segment *seg = NULL; + + /* Try to find in the Resident Segment list */ + Forbid(); + D(bug("[RunHandler] Looking for handler '%s' in resident list\n", + handler)); + seg = FindSegment(handler, NULL, TRUE); + Permit(); + + deviceNode->dn_SegList = seg ? seg->seg_Seg : BNULL; + } + + if (deviceNode->dn_SegList == BNULL) { + D(bug("[RunHandler] LoadSeg(\"%s\")\n", handler)); + + deviceNode->dn_SegList = LoadSeg(handler); + } + + if (deviceNode->dn_SegList == BNULL) { + CONST_STRPTR cp = FilePart(handler); + + if (cp != NULL) { + BPTR dir; + dir = Lock("L:", SHARED_LOCK); + if (dir != BNULL) { + BPTR olddir; + olddir = CurrentDir(dir); + D(bug("[RunHandler] LoadSeg(\"L:%s\")\n", cp)); + deviceNode->dn_SegList = LoadSeg(cp); + CurrentDir(olddir); + } + } + } + + if (deviceNode->dn_SegList == BNULL) { + D(bug("[RunHandler] name '%b' seglist=NULL?\n", deviceNode->dn_Name)); + return NULL; + } + + if (path) + { + bpath = CreateBSTR(path); + if (bpath == BNULL) + return NULL; + } + else + { + path = AROS_BSTR_ADDR(deviceNode->dn_Name); + len = AROS_BSTR_strlen(deviceNode->dn_Name); + bpath = MKBADDR(AllocVec(AROS_BSTR_MEMSIZE4LEN(len + 1), MEMF_PUBLIC)); + if (bpath == BNULL) + return NULL; + + CopyMem(path, AROS_BSTR_ADDR(bpath), len); + AROS_BSTR_ADDR(bpath)[len++] = ':'; + AROS_BSTR_setstrlen(bpath, len); } - if (deviceNode->dn_SegList == BNULL) { - CONST_STRPTR cp = FilePart(handler); - - if (cp != NULL) { - BPTR dir; - dir = Lock("L:", SHARED_LOCK); - if (dir != BNULL) { - BPTR olddir; - olddir = CurrentDir(dir); - D(bug("[RunHandler] LoadSeg(\"L:%s\")\n", cp)); - deviceNode->dn_SegList = LoadSeg(cp); - CurrentDir(olddir); - } - } - } - - if (deviceNode->dn_SegList == BNULL) { - D(bug("[RunHandler] name '%b' seglist=NULL?\n", deviceNode->dn_Name)); - return NULL; - } - - if (path) - { - bpath = CreateBSTR(path); - if (bpath == BNULL) - return NULL; - } - else - { - path = AROS_BSTR_ADDR(deviceNode->dn_Name); - len = AROS_BSTR_strlen(deviceNode->dn_Name); - bpath = MKBADDR(AllocVec(AROS_BSTR_MEMSIZE4LEN(len + 1), MEMF_PUBLIC)); - if (bpath == BNULL) - return NULL; - - CopyMem(path, AROS_BSTR_ADDR(bpath), len); - AROS_BSTR_ADDR(bpath)[len++] = ':'; - AROS_BSTR_setstrlen(bpath, len); - } - - D(bug("[RunHandler] in open by Task '%s'\n", FindTask(NULL)->tc_Node.ln_Name)); + D(bug("[RunHandler] in open by Task '%s'\n", FindTask(NULL)->tc_Node.ln_Name)); D(if ((IPTR)deviceNode->dn_Startup >= 64)) /* really an FSSM? */ D(fssm = (struct FileSysStartupMsg *)BADDR(deviceNode->dn_Startup);) - D(bug("[RunHandler] devicenode=%08lx path='%b' devicename '%b' unit %d dosname '%b' handler=%x seg=%08lx startup=%08lx\n", + D(bug("[RunHandler] devicenode=%08lx path='%b' devicename '%b' unit %d dosname '%b' handler=%x seg=%08lx startup=%08lx\n", deviceNode, bpath, fssm ? fssm->fssm_Device : BNULL, @@ -132,13 +132,13 @@ struct MsgPort *RunHandler(struct DeviceNode *deviceNode, const char *path, stru /* start it up */ process = CreateNewProcTags( - NP_Entry, (IPTR)entry, - NP_Seglist, (IPTR)deviceNode->dn_SegList, - NP_FreeSeglist, (IPTR)FALSE, - NP_Name, AROS_BSTR_ADDR(deviceNode->dn_Name), /* GB: always NUL terminated */ - NP_StackSize, deviceNode->dn_StackSize, - NP_Priority, deviceNode->dn_Priority, - TAG_DONE); + NP_Entry, (IPTR)entry, + NP_Seglist, (IPTR)deviceNode->dn_SegList, + NP_FreeSeglist, (IPTR)FALSE, + NP_Name, AROS_BSTR_ADDR(deviceNode->dn_Name), /* GB: always NUL terminated */ + NP_StackSize, deviceNode->dn_StackSize, + NP_Priority, deviceNode->dn_Priority, + TAG_DONE); D(bug("[RunHandler] started, process structure is 0x%08x\n", process)); reply_port = CreateMsgPort(); @@ -168,7 +168,7 @@ struct MsgPort *RunHandler(struct DeviceNode *deviceNode, const char *path, stru GetMsg(reply_port); DeleteMsgPort(reply_port); - FreeVec(BADDR(bpath)); + FreeVec(BADDR(bpath)); if (dp->dp_Res1 == DOSFALSE) { @@ -180,5 +180,5 @@ struct MsgPort *RunHandler(struct DeviceNode *deviceNode, const char *path, stru FreeDosObject(DOS_STDPKT, dp); - return process ? &process->pr_MsgPort : NULL; + return process ? &process->pr_MsgPort : NULL; } diff --git a/rom/dos/samedevice.c b/rom/dos/samedevice.c index f5ce865c8c..f7b3a12c0b 100644 --- a/rom/dos/samedevice.c +++ b/rom/dos/samedevice.c @@ -12,23 +12,23 @@ NAME */ #include - AROS_LH2(BOOL, SameDevice, + AROS_LH2(BOOL, SameDevice, /* SYNOPSIS */ - AROS_LHA(BPTR, lock1, D1), - AROS_LHA(BPTR, lock2, D2), + AROS_LHA(BPTR, lock1, D1), + AROS_LHA(BPTR, lock2, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 164, Dos) + struct DosLibrary *, DOSBase, 164, Dos) /* FUNCTION - Checks if two locks are on the same device. + Checks if two locks are on the same device. INPUTS - lock1, lock2 - locks + lock1, lock2 - locks RESULT - DOSTRUE when they are on the same device + DOSTRUE when they are on the same device NOTES @@ -47,13 +47,13 @@ struct FileLock *fl1, *fl2; if (lock1 == BNULL || lock2 == BNULL) - return DOSFALSE; - + return DOSFALSE; + fl1 = (struct FileLock *)BADDR(lock1); fl2 = (struct FileLock *)BADDR(lock2); if (fl1->fl_Volume == fl2->fl_Volume && fl1->fl_Task == fl2->fl_Task) - return DOSTRUE; + return DOSTRUE; return DOSFALSE; diff --git a/rom/dos/samelock.c b/rom/dos/samelock.c index 83d66492ca..32a2db2af8 100644 --- a/rom/dos/samelock.c +++ b/rom/dos/samelock.c @@ -12,25 +12,25 @@ NAME */ #include - AROS_LH2(LONG, SameLock, + AROS_LH2(LONG, SameLock, /* SYNOPSIS */ - AROS_LHA(BPTR, lock1, D1), - AROS_LHA(BPTR, lock2, D2), + AROS_LHA(BPTR, lock1, D1), + AROS_LHA(BPTR, lock2, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 70, Dos) + struct DosLibrary *, DOSBase, 70, Dos) /* FUNCTION - Compares two locks. + Compares two locks. INPUTS - lock1, lock2 - locks + lock1, lock2 - locks RESULT - LOCK_SAME - locks points to the same object - LOCK_SAME_VOLUME - locks are on the same volume - LOCK_DIFFERENT - locks are different + LOCK_SAME - locks points to the same object + LOCK_SAME_VOLUME - locks are on the same volume + LOCK_DIFFERENT - locks are different NOTES @@ -52,20 +52,20 @@ SIPTR res; if(!SameDevice(lock1, lock2)) - return LOCK_DIFFERENT; - + return LOCK_DIFFERENT; + fl1 = (struct FileLock *)BADDR(lock1); fl2 = (struct FileLock *)BADDR(lock2); status = dopacket2(DOSBase, &res, fl1->fl_Task, ACTION_SAME_LOCK, lock1, lock2); if (status) - return LOCK_SAME; + return LOCK_SAME; if (res == ERROR_ACTION_NOT_KNOWN) { - SetIoErr(0); - if (fl1->fl_Volume == fl2->fl_Volume && fl1->fl_Key == fl2->fl_Key) - return LOCK_SAME; - if (fl1->fl_Volume == fl2->fl_Volume) - return LOCK_SAME_VOLUME; + SetIoErr(0); + if (fl1->fl_Volume == fl2->fl_Volume && fl1->fl_Key == fl2->fl_Key) + return LOCK_SAME; + if (fl1->fl_Volume == fl2->fl_Volume) + return LOCK_SAME_VOLUME; } return LOCK_DIFFERENT; diff --git a/rom/dos/scanvars.c b/rom/dos/scanvars.c dissimilarity index 73% index 6d50272448..4e4dbec9e1 100644 --- a/rom/dos/scanvars.c +++ b/rom/dos/scanvars.c @@ -1,102 +1,102 @@ -/* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English -*/ - -#include - -#include "dos_intern.h" -#include -#include -#include - -/***************************************************************************** - - NAME */ -#include - - AROS_LH3(LONG, ScanVars, - -/* SYNOPSIS */ - AROS_LHA(struct Hook *, hook, D1), - AROS_LHA(ULONG, flags, D2), - AROS_LHA(APTR, userdata, D3), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 169, Dos) - -/* FUNCTION - Scan local and/or global variables accordingly to specified flags. For - each scanned variable hook function is called. Scanning process will - continue as long as hook returns 0. If hook returns a non-zero value, - scanning will be aborted and ScanVars will return this value. - - INPUTS - userdata - Any user-specific data passed to hook function. - flags - Same as in GetVar(). - hook - Hook function that will be called for each scanned variable as: - result = hook_function(hook,userdata,message) with ScanVarsMsg - structure as message parameter containing information about given - variable. - - RESULT - !=0 returned by hook function if scan process was aborted, 0 otherwise. - - NOTES - ScanVarsMsg structure content is valid only during hook call. - See for description of ScanVarsMsg structure. - - This function is compatible with AmigaOS v4. - - EXAMPLE - - BUGS - Currently only local variables scanning is implemented. - - SEE ALSO - DeleteVar(), FindVar(), GetVar(), SetVar(), - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - /* We scan through the process->pr_LocalVars list */ - struct Process *pr; - struct LocalVar *var; - struct ScanVarsMsg msg; - LONG res; - - msg.sv_SVMSize = sizeof(struct ScanVarsMsg); - msg.sv_Flags = flags; - pr = (struct Process *)FindTask(NULL); - - ASSERT_VALID_PROCESS(pr); - - /* not global only? */ - if(0 == (flags & GVF_GLOBAL_ONLY)) - { - var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; - - ForeachNode(&pr->pr_LocalVars, var) - { - if (var->lv_Node.ln_Type == LV_VAR) - { - msg.sv_Name = var->lv_Node.ln_Name; - msg.sv_Var = var->lv_Value; - msg.sv_VarLen = var->lv_Len; - msg.sv_GDir = ""; - res = CallHookPkt(hook, userdata, &msg); - if(res != 0) - return(res); - } - } - } - return 0; - - AROS_LIBFUNC_EXIT -} +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ + +#include + +#include "dos_intern.h" +#include +#include +#include + +/***************************************************************************** + + NAME */ +#include + + AROS_LH3(LONG, ScanVars, + +/* SYNOPSIS */ + AROS_LHA(struct Hook *, hook, D1), + AROS_LHA(ULONG, flags, D2), + AROS_LHA(APTR, userdata, D3), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 169, Dos) + +/* FUNCTION + Scan local and/or global variables accordingly to specified flags. For + each scanned variable hook function is called. Scanning process will + continue as long as hook returns 0. If hook returns a non-zero value, + scanning will be aborted and ScanVars will return this value. + + INPUTS + userdata - Any user-specific data passed to hook function. + flags - Same as in GetVar(). + hook - Hook function that will be called for each scanned variable as: + result = hook_function(hook,userdata,message) with ScanVarsMsg + structure as message parameter containing information about given + variable. + + RESULT + !=0 returned by hook function if scan process was aborted, 0 otherwise. + + NOTES + ScanVarsMsg structure content is valid only during hook call. + See for description of ScanVarsMsg structure. + + This function is compatible with AmigaOS v4. + + EXAMPLE + + BUGS + Currently only local variables scanning is implemented. + + SEE ALSO + DeleteVar(), FindVar(), GetVar(), SetVar(), + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + /* We scan through the process->pr_LocalVars list */ + struct Process *pr; + struct LocalVar *var; + struct ScanVarsMsg msg; + LONG res; + + msg.sv_SVMSize = sizeof(struct ScanVarsMsg); + msg.sv_Flags = flags; + pr = (struct Process *)FindTask(NULL); + + ASSERT_VALID_PROCESS(pr); + + /* not global only? */ + if(0 == (flags & GVF_GLOBAL_ONLY)) + { + var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; + + ForeachNode(&pr->pr_LocalVars, var) + { + if (var->lv_Node.ln_Type == LV_VAR) + { + msg.sv_Name = var->lv_Node.ln_Name; + msg.sv_Var = var->lv_Value; + msg.sv_VarLen = var->lv_Len; + msg.sv_GDir = ""; + res = CallHookPkt(hook, userdata, &msg); + if(res != 0) + return(res); + } + } + } + return 0; + + AROS_LIBFUNC_EXIT +} diff --git a/rom/dos/seek.c b/rom/dos/seek.c index de5deab5ea..c4955cd24f 100644 --- a/rom/dos/seek.c +++ b/rom/dos/seek.c @@ -13,33 +13,33 @@ NAME */ #include - AROS_LH3(LONG, Seek, + AROS_LH3(LONG, Seek, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(LONG, position, D2), - AROS_LHA(LONG, mode, D3), + AROS_LHA(BPTR, file, D1), + AROS_LHA(LONG, position, D2), + AROS_LHA(LONG, mode, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 11, Dos) + struct DosLibrary *, DOSBase, 11, Dos) /* FUNCTION - Changes the current read/write position in a file and/or - reads the current position, e.g to get the current position - do a Seek(file,0,OFFSET_CURRENT). + Changes the current read/write position in a file and/or + reads the current position, e.g to get the current position + do a Seek(file,0,OFFSET_CURRENT). - This function may fail (obviously) on certain devices such - as pipes or console handlers. + This function may fail (obviously) on certain devices such + as pipes or console handlers. INPUTS - file - filehandle - position - relative offset in bytes (positive, negative or 0). - mode - Where to count from. Either OFFSET_BEGINNING, - OFFSET_CURRENT or OFFSET_END. + file - filehandle + position - relative offset in bytes (positive, negative or 0). + mode - Where to count from. Either OFFSET_BEGINNING, + OFFSET_CURRENT or OFFSET_END. RESULT - Absolute position in bytes before the Seek(), -1 if an error - happened. IoErr() will give additional information in that case. + Absolute position in bytes before the Seek(), -1 if an error + happened. IoErr() will give additional information in that case. NOTES @@ -60,32 +60,32 @@ LONG offset = 0, ret; if (fh == NULL) { - SetIoErr(ERROR_INVALID_LOCK); - return -1; + SetIoErr(ERROR_INVALID_LOCK); + return -1; } /* If the file is in append mode, seeking is not allowed. */ if( fh->fh_Flags & FHF_APPEND ) { - return InternalSeek( fh, 0, OFFSET_CURRENT, DOSBase ); + return InternalSeek( fh, 0, OFFSET_CURRENT, DOSBase ); } /* If the file is in write mode flush it. */ if( fh->fh_Flags & FHF_WRITE ) { - InternalFlush( fh, DOSBase ); + InternalFlush( fh, DOSBase ); } else { - /* Read mode. Adjust the offset so that buffering is - taken into account. */ - if (fh->fh_Pos < fh->fh_End && mode == OFFSET_CURRENT) - offset = (LONG)(fh->fh_Pos - fh->fh_End); - - + /* Read mode. Adjust the offset so that buffering is + taken into account. */ + if (fh->fh_Pos < fh->fh_End && mode == OFFSET_CURRENT) + offset = (LONG)(fh->fh_Pos - fh->fh_End); + + /* Read mode. Just reinit the buffers. We can't call Flush() in this case as that would end up in - recursion. */ + recursion. */ fh->fh_Pos = fh->fh_End = 0; } diff --git a/rom/dos/selectinput.c b/rom/dos/selectinput.c index 54326948d4..b1ab15e290 100644 --- a/rom/dos/selectinput.c +++ b/rom/dos/selectinput.c @@ -15,23 +15,23 @@ NAME */ #include - AROS_LH1(BPTR, SelectInput, + AROS_LH1(BPTR, SelectInput, /* SYNOPSIS */ - AROS_LHA(BPTR, fh, D1), + AROS_LHA(BPTR, fh, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 49, Dos) + struct DosLibrary *, DOSBase, 49, Dos) /* FUNCTION - Sets the current input stream returned by Input() to a new - value. Returns the old input stream. + Sets the current input stream returned by Input() to a new + value. Returns the old input stream. INPUTS - fh - New input stream. + fh - New input stream. RESULT - Old input stream handle. + Old input stream handle. NOTES diff --git a/rom/dos/selectoutput.c b/rom/dos/selectoutput.c index a5ab3b7cc2..5f6c9091a1 100644 --- a/rom/dos/selectoutput.c +++ b/rom/dos/selectoutput.c @@ -15,23 +15,23 @@ NAME */ #include - AROS_LH1(BPTR, SelectOutput, + AROS_LH1(BPTR, SelectOutput, /* SYNOPSIS */ - AROS_LHA(BPTR, fh, D1), + AROS_LHA(BPTR, fh, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 50, Dos) + struct DosLibrary *, DOSBase, 50, Dos) /* FUNCTION - Sets the current output stream returned by Output() to a new - value. Returns the old output stream. + Sets the current output stream returned by Output() to a new + value. Returns the old output stream. INPUTS - fh - New output stream. + fh - New output stream. RESULT - Old output stream handle. + Old output stream handle. NOTES diff --git a/rom/dos/sendpkt.c b/rom/dos/sendpkt.c index 88c258d809..f816b68551 100644 --- a/rom/dos/sendpkt.c +++ b/rom/dos/sendpkt.c @@ -22,15 +22,15 @@ NAME */ #include - AROS_LH3I(void, SendPkt, + AROS_LH3I(void, SendPkt, /* SYNOPSIS */ - AROS_LHA(struct DosPacket *, dp, D1), - AROS_LHA(struct MsgPort *, port, D2), - AROS_LHA(struct MsgPort *, replyport, D3), + AROS_LHA(struct DosPacket *, dp, D1), + AROS_LHA(struct MsgPort *, port, D2), + AROS_LHA(struct MsgPort *, replyport, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 41, Dos) + struct DosLibrary *, DOSBase, 41, Dos) /* FUNCTION diff --git a/rom/dos/setargstr.c b/rom/dos/setargstr.c index 42f0c3b36f..d40f110125 100644 --- a/rom/dos/setargstr.c +++ b/rom/dos/setargstr.c @@ -16,23 +16,23 @@ NAME */ #include - AROS_LH1(STRPTR, SetArgStr, + AROS_LH1(STRPTR, SetArgStr, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, string, D1), + AROS_LHA(CONST_STRPTR, string, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 90, Dos) + struct DosLibrary *, DOSBase, 90, Dos) /* FUNCTION - Sets the arguments to the current process. The arguments must be - reset to the original value before process exit. + Sets the arguments to the current process. The arguments must be + reset to the original value before process exit. INPUTS - string - The new argument string. (A C string). + string - The new argument string. (A C string). RESULT - The address of the previous argument string. May be NULL. + The address of the previous argument string. May be NULL. NOTES @@ -41,7 +41,7 @@ BUGS SEE ALSO - GetArgStr(), RunCommand() + GetArgStr(), RunCommand() INTERNALS diff --git a/rom/dos/setcomment.c b/rom/dos/setcomment.c index fb1b48e5c6..28f6fdc1e8 100644 --- a/rom/dos/setcomment.c +++ b/rom/dos/setcomment.c @@ -18,28 +18,28 @@ NAME */ #include - AROS_LH2(LONG, SetComment, + AROS_LH2(LONG, SetComment, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(CONST_STRPTR, comment, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, comment, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 30, Dos) + struct DosLibrary *, DOSBase, 30, Dos) /* FUNCTION - Change the comment on a file or directory. The comment may be any - NUL-terminated string. The supported size varies from filesystem - to filesystem. In order to clear an existing comment, an empty - string should be specified. + Change the comment on a file or directory. The comment may be any + NUL-terminated string. The supported size varies from filesystem + to filesystem. In order to clear an existing comment, an empty + string should be specified. INPUTS - name - name of the file - comment - new comment for the file. + name - name of the file + comment - new comment for the file. RESULT - Boolean success indicator. IoErr() gives additional information upon - failure. + Boolean success indicator. IoErr() gives additional information upon + failure. NOTES @@ -65,14 +65,14 @@ return status; } if (getpacketinfo(DOSBase, name, &phs)) { - BSTR com = C2BSTR(comment); - if (com) { - status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_COMMENT, (SIPTR)NULL, phs.lock, phs.name, com); - FREEC2BSTR(com); - } else { - SetIoErr(ERROR_NO_FREE_STORE); - } - freepacketinfo(DOSBase, &phs); + BSTR com = C2BSTR(comment); + if (com) { + status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_COMMENT, (SIPTR)NULL, phs.lock, phs.name, com); + FREEC2BSTR(com); + } else { + SetIoErr(ERROR_NO_FREE_STORE); + } + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/setconsoletask.c b/rom/dos/setconsoletask.c index 148eae7be2..01401ac86c 100644 --- a/rom/dos/setconsoletask.c +++ b/rom/dos/setconsoletask.c @@ -16,34 +16,34 @@ #include #include - AROS_LH1(struct MsgPort *, SetConsoleTask, + AROS_LH1(struct MsgPort *, SetConsoleTask, /* SYNOPSIS */ - AROS_LHA(struct MsgPort *, handler, D1), + AROS_LHA(struct MsgPort *, handler, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 86, Dos) + struct DosLibrary *, DOSBase, 86, Dos) /* FUNCTION - Set the console handler for the current process, and return the - old handler. + Set the console handler for the current process, and return the + old handler. INPUTS - handler - The new console handler for the process. + handler - The new console handler for the process. RESULT - The address of the old handler. + The address of the old handler. NOTES - The use of Task in the name is because historically filesystem - handlers were tasks (instead of Devices). + The use of Task in the name is because historically filesystem + handlers were tasks (instead of Devices). EXAMPLE BUGS SEE ALSO - GetConsoleTask() + GetConsoleTask() INTERNALS diff --git a/rom/dos/setcurrentdirname.c b/rom/dos/setcurrentdirname.c index 671e53ea4a..d893f75bc6 100644 --- a/rom/dos/setcurrentdirname.c +++ b/rom/dos/setcurrentdirname.c @@ -16,35 +16,35 @@ NAME */ #include - AROS_LH1(BOOL, SetCurrentDirName, + AROS_LH1(BOOL, SetCurrentDirName, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 93, Dos) + struct DosLibrary *, DOSBase, 93, Dos) /* FUNCTION - Sets the name of the current directory in the CLI structure. - If the name doesn't fit the old name is kept and a failure - returned. If the current process doesn't have a CLI structure - this function does nothing. + Sets the name of the current directory in the CLI structure. + If the name doesn't fit the old name is kept and a failure + returned. If the current process doesn't have a CLI structure + this function does nothing. INPUTS - name - Name for the current directory. + name - Name for the current directory. RESULT - !=0 on success, 0 on failure. + !=0 on success, 0 on failure. NOTES EXAMPLE BUGS - Never copies more than 255 bytes. + Never copies more than 255 bytes. SEE ALSO - GetCurrentDirName() + GetCurrentDirName() INTERNALS @@ -58,15 +58,15 @@ ULONG namelen; if ((cli = Cli()) == NULL) - return DOSFALSE; + return DOSFALSE; s = name; while(*s++) - ; + ; namelen = s - name - 1; if (namelen > 255) - return DOSFALSE; + return DOSFALSE; bs = AROS_BSTR_ADDR(cli->cli_SetName); diff --git a/rom/dos/setfiledate.c b/rom/dos/setfiledate.c index 556eddb51b..3b666dedad 100644 --- a/rom/dos/setfiledate.c +++ b/rom/dos/setfiledate.c @@ -19,25 +19,25 @@ #include #include - AROS_LH2(BOOL, SetFileDate, + AROS_LH2(BOOL, SetFileDate, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(const struct DateStamp *, date, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(const struct DateStamp *, date, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 66, Dos) + struct DosLibrary *, DOSBase, 66, Dos) /* FUNCTION - Change the modification time of a file or directory. + Change the modification time of a file or directory. INPUTS - name - name of the file - date - new file time + name - name of the file + date - new file time RESULT - Boolean success indicator. IoErr() gives additional information upon - failure. + Boolean success indicator. IoErr() gives additional information upon + failure. NOTES @@ -59,8 +59,8 @@ D(bug("[SetFileDate] '%s' %x\n", name, date)); if (getpacketinfo(DOSBase, name, &phs)) { - status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_DATE, (IPTR)NULL, phs.lock, phs.name, (IPTR)date); - freepacketinfo(DOSBase, &phs); + status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_DATE, (IPTR)NULL, phs.lock, phs.name, (IPTR)date); + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/setfilesize.c b/rom/dos/setfilesize.c index 4634a27ca7..929888ff80 100644 --- a/rom/dos/setfilesize.c +++ b/rom/dos/setfilesize.c @@ -14,27 +14,27 @@ NAME */ #include - AROS_LH3(LONG, SetFileSize, + AROS_LH3(LONG, SetFileSize, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(LONG, offset, D2), - AROS_LHA(LONG, mode, D3), + AROS_LHA(BPTR, file, D1), + AROS_LHA(LONG, offset, D2), + AROS_LHA(LONG, mode, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 76, Dos) + struct DosLibrary *, DOSBase, 76, Dos) /* FUNCTION - Change the size of a file. + Change the size of a file. INPUTS - file - filehandle - offset - relative size - mode - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END + file - filehandle + offset - relative size + mode - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END RESULT - New size of the file or -1 in case of an error. - IoErr() gives additional information in that case. + New size of the file or -1 in case of an error. + IoErr() gives additional information in that case. NOTES diff --git a/rom/dos/setfilesystask.c b/rom/dos/setfilesystask.c index 9240fe7cd0..2f73ce97af 100644 --- a/rom/dos/setfilesystask.c +++ b/rom/dos/setfilesystask.c @@ -16,23 +16,23 @@ #include #include - AROS_LH1(struct MsgPort *, SetFileSysTask, + AROS_LH1(struct MsgPort *, SetFileSysTask, /* SYNOPSIS */ - AROS_LHA(struct MsgPort *, task, D1), + AROS_LHA(struct MsgPort *, task, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 88, Dos) + struct DosLibrary *, DOSBase, 88, Dos) /* FUNCTION - Set the default filesystem handler for the current process, - the old filesystem handler will be returned. + Set the default filesystem handler for the current process, + the old filesystem handler will be returned. INPUTS - task - The new filesystem handler. + task - The new filesystem handler. RESULT - The old filesystem handler. + The old filesystem handler. NOTES @@ -41,7 +41,7 @@ BUGS SEE ALSO - GetFileSysTask() + GetFileSysTask() INTERNALS diff --git a/rom/dos/setioerr.c b/rom/dos/setioerr.c index 30aa072d75..2b4aa69528 100644 --- a/rom/dos/setioerr.c +++ b/rom/dos/setioerr.c @@ -15,22 +15,22 @@ NAME */ #include - AROS_LH1(SIPTR, SetIoErr, + AROS_LH1(SIPTR, SetIoErr, /* SYNOPSIS */ - AROS_LHA(SIPTR, result, D1), + AROS_LHA(SIPTR, result, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 77, Dos) + struct DosLibrary *, DOSBase, 77, Dos) /* FUNCTION - Sets the dos error code for the current process. + Sets the dos error code for the current process. INPUTS - result -- new error code + result -- new error code RESULT - Old error code. + Old error code. NOTES diff --git a/rom/dos/setmode.c b/rom/dos/setmode.c index a318266b84..6ab6e8672e 100644 --- a/rom/dos/setmode.c +++ b/rom/dos/setmode.c @@ -12,30 +12,30 @@ NAME */ #include - AROS_LH2(LONG, SetMode, + AROS_LH2(LONG, SetMode, /* SYNOPSIS */ - AROS_LHA(BPTR, fh, D1), - AROS_LHA(LONG, mode, D2), + AROS_LHA(BPTR, fh, D1), + AROS_LHA(LONG, mode, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 71, Dos) + struct DosLibrary *, DOSBase, 71, Dos) /* FUNCTION - SetMode() can be used to change a console handler between - RAW: mode and CON: mode. + SetMode() can be used to change a console handler between + RAW: mode and CON: mode. INPUTS - fh - The filehandle describing the console. - mode - The new mode of the console: - 1 - RAW: mode - 0 - CON: mode + fh - The filehandle describing the console. + mode - The new mode of the console: + 1 - RAW: mode + 0 - CON: mode RESULT - This function will return whether it succeeded: + This function will return whether it succeeded: - == DOSTRUE console mode changed - != DOSTRUE console mode change failed. + == DOSTRUE console mode changed + != DOSTRUE console mode change failed. NOTES diff --git a/rom/dos/setowner.c b/rom/dos/setowner.c index b21680160b..462a511fb3 100644 --- a/rom/dos/setowner.c +++ b/rom/dos/setowner.c @@ -16,24 +16,24 @@ NAME */ #include - AROS_LH2(BOOL, SetOwner, + AROS_LH2(BOOL, SetOwner, /* SYNOPSIS */ - AROS_LHA(STRPTR, name, D1), - AROS_LHA(ULONG, owner_info, D2), + AROS_LHA(STRPTR, name, D1), + AROS_LHA(ULONG, owner_info, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 166, Dos) + struct DosLibrary *, DOSBase, 166, Dos) /* FUNCTION INPUTS - name -- name of the file - owner_info -- (UID << 16) + GID + name -- name of the file + owner_info -- (UID << 16) + GID RESULT - != 0 if all went well, 0 else. IoErr() gives additional - information in that case. + != 0 if all went well, 0 else. IoErr() gives additional + information in that case. NOTES @@ -55,8 +55,8 @@ D(bug("[SetOwner] '%s' %x\n", name, owner_info)); if (getpacketinfo(DOSBase, name, &phs)) { - status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_OWNER, (IPTR)NULL, phs.lock, phs.name, (IPTR)owner_info); - freepacketinfo(DOSBase, &phs); + status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_OWNER, (IPTR)NULL, phs.lock, phs.name, (IPTR)owner_info); + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/setprogramdir.c b/rom/dos/setprogramdir.c index 9dcb34535f..7025b44e7e 100644 --- a/rom/dos/setprogramdir.c +++ b/rom/dos/setprogramdir.c @@ -15,37 +15,37 @@ NAME */ #include - AROS_LH1(BPTR, SetProgramDir, + AROS_LH1(BPTR, SetProgramDir, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 99, Dos) + struct DosLibrary *, DOSBase, 99, Dos) /* FUNCTION - This function will set a shared lock on the directory that the - current program was loaded from. This can be accessed through - the path PROGDIR:. The use of this path is to allow the program - to easily access files which are supplied with the program. + This function will set a shared lock on the directory that the + current program was loaded from. This can be accessed through + the path PROGDIR:. The use of this path is to allow the program + to easily access files which are supplied with the program. INPUTS - lock - The lock to set as the new program directory. NULL - is a valid value. + lock - The lock to set as the new program directory. NULL + is a valid value. RESULT - This function will return the old program directory lock. + This function will return the old program directory lock. NOTES - This function will not duplicate the lock, so you should not - free the lock. + This function will not duplicate the lock, so you should not + free the lock. EXAMPLE BUGS SEE ALSO - GetProgramDir() + GetProgramDir() INTERNALS diff --git a/rom/dos/setprogramname.c b/rom/dos/setprogramname.c index d948d63af9..7b99b43b30 100644 --- a/rom/dos/setprogramname.c +++ b/rom/dos/setprogramname.c @@ -17,35 +17,35 @@ #include - AROS_LH1(BOOL, SetProgramName, + AROS_LH1(BOOL, SetProgramName, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 95, Dos) + struct DosLibrary *, DOSBase, 95, Dos) /* FUNCTION - Sets the name for the current program in the CLI structure. If the - name doesn't fit the old name is kept and a failure is returned. - If the current process doesn't have a CLI structure this function - does nothing. + Sets the name for the current program in the CLI structure. If the + name doesn't fit the old name is kept and a failure is returned. + If the current process doesn't have a CLI structure this function + does nothing. INPUTS - name -- Name for the current program. + name -- Name for the current program. RESULT - != 0 on success, 0 on failure. + != 0 on success, 0 on failure. NOTES EXAMPLE BUGS - Never copies more than 255 bytes. + Never copies more than 255 bytes. SEE ALSO - GetProgramName() + GetProgramName() INTERNALS @@ -68,19 +68,19 @@ BOOL internal_SetProgramName(struct CommandLineInterface *cli, if (cli == NULL) { - return FALSE; + return FALSE; } s = name; while(*s++) - ; + ; namelen = s - name - 1; if (namelen > 255) { - return FALSE; + return FALSE; } bs = AROS_BSTR_ADDR(cli->cli_CommandName); diff --git a/rom/dos/setprompt.c b/rom/dos/setprompt.c index abbc08a556..b81acac826 100644 --- a/rom/dos/setprompt.c +++ b/rom/dos/setprompt.c @@ -16,34 +16,34 @@ NAME */ #include - AROS_LH1(BOOL, SetPrompt, + AROS_LH1(BOOL, SetPrompt, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, name, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 97, Dos) + struct DosLibrary *, DOSBase, 97, Dos) /* FUNCTION - Sets the prompt in the current CLI structure. If the name doesn't - fit the old name is kept and a failure is returned. If the current - process doesn't have a CLI structure this function does nothing. + Sets the prompt in the current CLI structure. If the name doesn't + fit the old name is kept and a failure is returned. If the current + process doesn't have a CLI structure this function does nothing. INPUTS - name - The prompt to be set. + name - The prompt to be set. RESULT - !=0 on success, 0 on failure. + !=0 on success, 0 on failure. NOTES EXAMPLE BUGS - Never copies more than 255 bytes. + Never copies more than 255 bytes. SEE ALSO - GetPrompt() + GetPrompt() INTERNALS diff --git a/rom/dos/setprotection.c b/rom/dos/setprotection.c index 803a48571e..aca3593125 100644 --- a/rom/dos/setprotection.c +++ b/rom/dos/setprotection.c @@ -16,24 +16,24 @@ NAME */ #include - AROS_LH2(LONG, SetProtection, + AROS_LH2(LONG, SetProtection, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(ULONG, protect, D2), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(ULONG, protect, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 31, Dos) + struct DosLibrary *, DOSBase, 31, Dos) /* FUNCTION INPUTS - name - name of the file - protect - new protection bits + name - name of the file + protect - new protection bits RESULT - != 0 if all went well, 0 else. IoErr() gives additional - information in that case. + != 0 if all went well, 0 else. IoErr() gives additional + information in that case. NOTES @@ -55,8 +55,8 @@ D(bug("[SetProtection] '%s':%x\n", name, protect)); if (getpacketinfo(DOSBase, name, &phs)) { - status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_PROTECT, BNULL, phs.lock, phs.name, protect); - freepacketinfo(DOSBase, &phs); + status = dopacket4(DOSBase, NULL, phs.port, ACTION_SET_PROTECT, BNULL, phs.lock, phs.name, protect); + freepacketinfo(DOSBase, &phs); } return status; diff --git a/rom/dos/setvar.c b/rom/dos/setvar.c dissimilarity index 61% index 5787619da6..01ea433854 100644 --- a/rom/dos/setvar.c +++ b/rom/dos/setvar.c @@ -1,272 +1,272 @@ -/* - Copyright © 1995-2009, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English -*/ -#include - -#include "dos_intern.h" -#include -#include -#include -#include -#include -#include -#include - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH4(BOOL, SetVar, - -/* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(CONST_STRPTR, buffer, D2), - AROS_LHA(LONG , size, D3), - AROS_LHA(LONG , flags, D4), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 150, Dos) - -/* FUNCTION - This function will set a local or environmental variable. Although - it is recommended that you only use ASCII strings within variables, - this is not actually required. - - Variable names are not case sensitive. - - SetVar() for an already existing variable changes the variable's - value to "buffer". - - INPUTS - name - The name of the variable to set. - buffer - The actual data of the variable. - size - The size of the data in the buffer. - flags - Combination of the type of variable to set (lower - 8 bits of the value), and various flags which control - this function. Flags defined are: - - GVF_LOCAL_ONLY - set a local variable only, - GVF_GLOBAL_ONLY - set a global environmental - variable only. - GVF_SAVE_VAR - If GVF_GLOBAL_ONLY is set, then - this flag will cause SetVar() to - save the variable to ENVARC: as well - as to ENV:. - GVF_BINARY_VAR and GVF_DONT_NULL_TERM are stored in - the lv_Flags field for local variables, but not - used otherwise by SetVar(). - - Note the default is to set a local environmental - variable. - - The following variable types are defined: - LV_VAR - local environment variable - LV_ALIAS - shell alias - LVF_IGNORE - internal shell use - - LV_VAR and LV_ALIAS should be treated as - "exclusive or". - - - RESULT - Zero if this function failed, non-zero otherwise. - - NOTES - It is possible to have two variables with the same name as - long as they have different types. - - EXAMPLE - - BUGS - Only type LV_VAR can be made global. - - If you set GVF_SAVE_VAR, and this function returns failure, the - variable may have still been set in ENV:. - - SEE ALSO - DeleteVar(), FindVar(), GetVar(), - - INTERNALS - See FindVar() for a description of the inner workings of local - variables. - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - - /* valid input? */ - if(name && buffer) - { - /* Local variable is default. */ - if((flags & GVF_GLOBAL_ONLY) == 0) - { - ULONG nameLen = strlen(name); - struct LocalVar *lv; - - /* does a Variable with that name already exist? */ - if (NULL != (lv = FindVar(name, flags))) - { - /* delete old value of that existing variable */ - FreeMem(lv->lv_Value,lv->lv_Len); - } - else - { - /* - ** create a LocalVar-structure and insert it into the list - */ - if (NULL != (lv = AllocVec(sizeof(struct LocalVar) + nameLen + 1, - MEMF_CLEAR|MEMF_PUBLIC) ) ) - { - struct Process *pr = (struct Process *)FindTask(NULL); - struct LocalVar *n; - - ASSERT_VALID_PROCESS(pr); - n = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; - - /* init the newly created structure */ - - lv->lv_Node.ln_Type = flags; /* ln_Type is UBYTE! */ - lv->lv_Node.ln_Name = (UBYTE *)lv + sizeof(struct LocalVar); - CopyMem(name, lv->lv_Node.ln_Name, nameLen); - lv->lv_Flags = flags & (GVF_BINARY_VAR|GVF_DONT_NULL_TERM); - - /* - ** First let's see whether we have to add it at the head - ** of the list as the list is still empty OR - ** the very first element is already greater than the one - ** we want to insert - */ - - if (n == (struct LocalVar *)&(pr->pr_LocalVars.mlh_Tail) || - Stricmp(name, n->lv_Node.ln_Name) < 0) - { - AddHead((struct List *)&pr->pr_LocalVars, - (struct Node *)lv); - } - else - { - /* - ** Now we can be sure that we will have to insert - ** somewhere behind the first element in the list - */ - ForeachNode(&pr->pr_LocalVars, n) - { - if (Stricmp(name, n->lv_Node.ln_Name) < 0) - { - break; - } - } - - if (NULL != n->lv_Node.ln_Succ) - { - Insert((struct List *)&pr->pr_LocalVars , - (struct Node *) lv , - (struct Node *) n->lv_Node.ln_Pred); - } - else - { - AddTail((struct List *)&pr->pr_LocalVars, - (struct Node *) lv); - } - } - } - } - - /* -1 as size means: buffer contains a null-terminated string */ - if (-1 == size) - { - /* Do NOT add 1 byte to account for the NUL char, AmigaOS(R) doesn't - do it that way. */ - lv->lv_Len = strlen(buffer); - } - else - { - lv->lv_Len = size; - } - - /* now get some memory for the value */ - lv->lv_Value = AllocMem(lv->lv_Len, MEMF_PUBLIC); - - CopyMem(buffer, lv->lv_Value, lv->lv_Len); - - if (flags & GVF_LOCAL_ONLY) - return DOSTRUE; - } /* set a local variable */ - - /* Ok, try and set a global variable. */ - if ((flags & GVF_LOCAL_ONLY) == 0) - { - BPTR file; - /* as a standard: look for the file in ENV: if no path is - given in the variable */ - UBYTE nameBuffer[384]= "ENV:"; - - AddPart(nameBuffer, name, 384); - - /* Just try and open the file */ - file = Open(nameBuffer, MODE_NEWFILE); - - if (file != BNULL) - { - /* Write the data to the file */ - /* size = -1 means that the value is a null-terminated - string */ - if (-1 == size) - { - Write(file, buffer, strlen(buffer)); - } - else - { - Write(file, buffer, size); - } - - Close(file); - } - else - { - return DOSFALSE; - } - - /* Let's see whether we're supposed to make a copy of this to - * envarc also... - */ - if (0 != (flags & GVF_SAVE_VAR)) - { - CopyMem("ENVARC:", nameBuffer, 8); - AddPart(nameBuffer, name, 384); - - file = Open(nameBuffer, MODE_NEWFILE); - - if (file != BNULL) - { - /* Write the data to the file */ - /* size = -1 means that the value is a null-terminated - string */ - if (-1 == size) - { - Write(file, buffer, strlen(buffer)); - } - else - { - Write(file, buffer, size); - } - - Close(file); - } - } - - /* We created both, bye bye */ - return DOSTRUE; - } /* try a global variable */ - } /* input was valid */ - - return DOSFALSE; - - AROS_LIBFUNC_EXIT -} /* SetVar */ +/* + Copyright © 1995-2009, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ +#include + +#include "dos_intern.h" +#include +#include +#include +#include +#include +#include +#include + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH4(BOOL, SetVar, + +/* SYNOPSIS */ + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(CONST_STRPTR, buffer, D2), + AROS_LHA(LONG , size, D3), + AROS_LHA(LONG , flags, D4), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 150, Dos) + +/* FUNCTION + This function will set a local or environmental variable. Although + it is recommended that you only use ASCII strings within variables, + this is not actually required. + + Variable names are not case sensitive. + + SetVar() for an already existing variable changes the variable's + value to "buffer". + + INPUTS + name - The name of the variable to set. + buffer - The actual data of the variable. + size - The size of the data in the buffer. + flags - Combination of the type of variable to set (lower + 8 bits of the value), and various flags which control + this function. Flags defined are: + + GVF_LOCAL_ONLY - set a local variable only, + GVF_GLOBAL_ONLY - set a global environmental + variable only. + GVF_SAVE_VAR - If GVF_GLOBAL_ONLY is set, then + this flag will cause SetVar() to + save the variable to ENVARC: as well + as to ENV:. + GVF_BINARY_VAR and GVF_DONT_NULL_TERM are stored in + the lv_Flags field for local variables, but not + used otherwise by SetVar(). + + Note the default is to set a local environmental + variable. + + The following variable types are defined: + LV_VAR - local environment variable + LV_ALIAS - shell alias + LVF_IGNORE - internal shell use + + LV_VAR and LV_ALIAS should be treated as + "exclusive or". + + + RESULT + Zero if this function failed, non-zero otherwise. + + NOTES + It is possible to have two variables with the same name as + long as they have different types. + + EXAMPLE + + BUGS + Only type LV_VAR can be made global. + + If you set GVF_SAVE_VAR, and this function returns failure, the + variable may have still been set in ENV:. + + SEE ALSO + DeleteVar(), FindVar(), GetVar(), + + INTERNALS + See FindVar() for a description of the inner workings of local + variables. + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + + /* valid input? */ + if(name && buffer) + { + /* Local variable is default. */ + if((flags & GVF_GLOBAL_ONLY) == 0) + { + ULONG nameLen = strlen(name); + struct LocalVar *lv; + + /* does a Variable with that name already exist? */ + if (NULL != (lv = FindVar(name, flags))) + { + /* delete old value of that existing variable */ + FreeMem(lv->lv_Value,lv->lv_Len); + } + else + { + /* + ** create a LocalVar-structure and insert it into the list + */ + if (NULL != (lv = AllocVec(sizeof(struct LocalVar) + nameLen + 1, + MEMF_CLEAR|MEMF_PUBLIC) ) ) + { + struct Process *pr = (struct Process *)FindTask(NULL); + struct LocalVar *n; + + ASSERT_VALID_PROCESS(pr); + n = (struct LocalVar *)pr->pr_LocalVars.mlh_Head; + + /* init the newly created structure */ + + lv->lv_Node.ln_Type = flags; /* ln_Type is UBYTE! */ + lv->lv_Node.ln_Name = (UBYTE *)lv + sizeof(struct LocalVar); + CopyMem(name, lv->lv_Node.ln_Name, nameLen); + lv->lv_Flags = flags & (GVF_BINARY_VAR|GVF_DONT_NULL_TERM); + + /* + ** First let's see whether we have to add it at the head + ** of the list as the list is still empty OR + ** the very first element is already greater than the one + ** we want to insert + */ + + if (n == (struct LocalVar *)&(pr->pr_LocalVars.mlh_Tail) || + Stricmp(name, n->lv_Node.ln_Name) < 0) + { + AddHead((struct List *)&pr->pr_LocalVars, + (struct Node *)lv); + } + else + { + /* + ** Now we can be sure that we will have to insert + ** somewhere behind the first element in the list + */ + ForeachNode(&pr->pr_LocalVars, n) + { + if (Stricmp(name, n->lv_Node.ln_Name) < 0) + { + break; + } + } + + if (NULL != n->lv_Node.ln_Succ) + { + Insert((struct List *)&pr->pr_LocalVars , + (struct Node *) lv , + (struct Node *) n->lv_Node.ln_Pred); + } + else + { + AddTail((struct List *)&pr->pr_LocalVars, + (struct Node *) lv); + } + } + } + } + + /* -1 as size means: buffer contains a null-terminated string */ + if (-1 == size) + { + /* Do NOT add 1 byte to account for the NUL char, AmigaOS(R) doesn't + do it that way. */ + lv->lv_Len = strlen(buffer); + } + else + { + lv->lv_Len = size; + } + + /* now get some memory for the value */ + lv->lv_Value = AllocMem(lv->lv_Len, MEMF_PUBLIC); + + CopyMem(buffer, lv->lv_Value, lv->lv_Len); + + if (flags & GVF_LOCAL_ONLY) + return DOSTRUE; + } /* set a local variable */ + + /* Ok, try and set a global variable. */ + if ((flags & GVF_LOCAL_ONLY) == 0) + { + BPTR file; + /* as a standard: look for the file in ENV: if no path is + given in the variable */ + UBYTE nameBuffer[384]= "ENV:"; + + AddPart(nameBuffer, name, 384); + + /* Just try and open the file */ + file = Open(nameBuffer, MODE_NEWFILE); + + if (file != BNULL) + { + /* Write the data to the file */ + /* size = -1 means that the value is a null-terminated + string */ + if (-1 == size) + { + Write(file, buffer, strlen(buffer)); + } + else + { + Write(file, buffer, size); + } + + Close(file); + } + else + { + return DOSFALSE; + } + + /* Let's see whether we're supposed to make a copy of this to + * envarc also... + */ + if (0 != (flags & GVF_SAVE_VAR)) + { + CopyMem("ENVARC:", nameBuffer, 8); + AddPart(nameBuffer, name, 384); + + file = Open(nameBuffer, MODE_NEWFILE); + + if (file != BNULL) + { + /* Write the data to the file */ + /* size = -1 means that the value is a null-terminated + string */ + if (-1 == size) + { + Write(file, buffer, strlen(buffer)); + } + else + { + Write(file, buffer, size); + } + + Close(file); + } + } + + /* We created both, bye bye */ + return DOSTRUE; + } /* try a global variable */ + } /* input was valid */ + + return DOSFALSE; + + AROS_LIBFUNC_EXIT +} /* SetVar */ diff --git a/rom/dos/setvbuf.c b/rom/dos/setvbuf.c index cd33d88bd4..a6cd7b0ecd 100644 --- a/rom/dos/setvbuf.c +++ b/rom/dos/setvbuf.c @@ -15,18 +15,18 @@ #include #include - AROS_LH4(LONG, SetVBuf, + AROS_LH4(LONG, SetVBuf, /* SetVBuf -- set buffering modes and size */ /* SYNOPSIS */ - AROS_LHA(BPTR , file, D1), - AROS_LHA(STRPTR, buff, D2), - AROS_LHA(LONG , type, D3), - AROS_LHA(LONG , size, D4), + AROS_LHA(BPTR , file, D1), + AROS_LHA(STRPTR, buff, D2), + AROS_LHA(LONG , type, D3), + AROS_LHA(LONG , size, D4), /* LOCATION */ - struct DosLibrary *, DOSBase, 61, Dos) + struct DosLibrary *, DOSBase, 61, Dos) /* FUNCTION Changes the buffering modes and buffer size for a filehandle. @@ -79,8 +79,8 @@ fh->fh_Flags = (fh->fh_Flags | FHF_NOBUF) & ~FHF_LINEBUF; break; - default: - return EOF; + default: + return EOF; } if (size >= 0) @@ -105,9 +105,9 @@ vbuf_free(FileHandlePtr fh) { if (fh->fh_Flags & FHF_BUF) { - /* free buffer allocated by system */ - if (fh->fh_Flags & FHF_OWNBUF) - FreeMem(BADDR(fh->fh_Buf), fh->fh_BufSize); + /* free buffer allocated by system */ + if (fh->fh_Flags & FHF_OWNBUF) + FreeMem(BADDR(fh->fh_Buf), fh->fh_BufSize); fh->fh_Buf = BNULL; fh->fh_Pos = fh->fh_End = 0; @@ -123,13 +123,13 @@ APTR vbuf_alloc(FileHandlePtr fh, STRPTR buf, ULONG size) ULONG flags = FHF_BUF; if (size < 208) - size = 208; + size = 208; if (!buf) { - buf = AllocMem(size, MEMF_ANY); - fh->fh_OrigBuf = MKBADDR(buf); - flags |= FHF_OWNBUF; + buf = AllocMem(size, MEMF_ANY); + fh->fh_OrigBuf = MKBADDR(buf); + flags |= FHF_OWNBUF; } if (NULL != buf) @@ -138,7 +138,7 @@ APTR vbuf_alloc(FileHandlePtr fh, STRPTR buf, ULONG size) fh->fh_Flags |= flags; fh->fh_Buf = MKBADDR(buf); fh->fh_Pos = 0; - fh->fh_End = (fh->fh_Flags & FHF_WRITE) ? fh->fh_BufSize : 0; + fh->fh_End = (fh->fh_Flags & FHF_WRITE) ? fh->fh_BufSize : 0; } return buf; @@ -150,7 +150,7 @@ BOOL vbuf_inject(BPTR fh, CONST_STRPTR argptr, ULONG size, struct DosLibrary *DO STRPTR buf; if (!fh || !argptr) - return FALSE; + return FALSE; fhinput = BADDR(fh); /* Handle the trivial case, where we have enough room @@ -189,16 +189,16 @@ BOOL vbuf_inject(BPTR fh, CONST_STRPTR argptr, ULONG size, struct DosLibrary *DO buf = vbuf_alloc(fhinput, NULL, size); if (buf) { - D(bug("[vbuf_inject] Handle 0x%p, buffer 0x%p, injecting string: %s, size: %u\n", fh, buf, argptr, size)); - - /* ugly hack */ - fhinput->fh_Pos = 0; - if (size > 0) - { - CopyMem(argptr, buf, size); - DB2(bug("[vbuf_inject] Buffer contents:\n"); hexdump(buf, (IPTR)buf, size)); - } - fhinput->fh_End = size; + D(bug("[vbuf_inject] Handle 0x%p, buffer 0x%p, injecting string: %s, size: %u\n", fh, buf, argptr, size)); + + /* ugly hack */ + fhinput->fh_Pos = 0; + if (size > 0) + { + CopyMem(argptr, buf, size); + DB2(bug("[vbuf_inject] Buffer contents:\n"); hexdump(buf, (IPTR)buf, size)); + } + fhinput->fh_End = size; } return TRUE; diff --git a/rom/dos/splitname.c b/rom/dos/splitname.c index d3dd54e2a5..6a9ef39831 100644 --- a/rom/dos/splitname.c +++ b/rom/dos/splitname.c @@ -25,40 +25,40 @@ NAME */ #include - AROS_LH5(LONG, SplitName, + AROS_LH5(LONG, SplitName, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, name, D1), - AROS_LHA(ULONG , separator, D2), - AROS_LHA(STRPTR, buf, D3), - AROS_LHA(LONG , oldpos, D4), - AROS_LHA(LONG , size, D5), + AROS_LHA(CONST_STRPTR, name, D1), + AROS_LHA(ULONG , separator, D2), + AROS_LHA(STRPTR, buf, D3), + AROS_LHA(LONG , oldpos, D4), + AROS_LHA(LONG , size, D5), /* LOCATION */ - struct DosLibrary *, DOSBase, 69, Dos) + struct DosLibrary *, DOSBase, 69, Dos) /* FUNCTION - Split a path into parts at the position of separator. + Split a path into parts at the position of separator. INPUTS - name - Split this path - separator - Split it at this separator - buf - Copy the current part into this buffer - oldpos - Begin at this place with the search for separator. - If you call this function for the first time, set it - to 0. - size - The size of the buffer. If the current part of the - path is bigger than size-1, only size-1 bytes will - be copied. + name - Split this path + separator - Split it at this separator + buf - Copy the current part into this buffer + oldpos - Begin at this place with the search for separator. + If you call this function for the first time, set it + to 0. + size - The size of the buffer. If the current part of the + path is bigger than size-1, only size-1 bytes will + be copied. RESULT - The next position to continue for the next part or -1 if - there is no separator after name+oldpos. + The next position to continue for the next part or -1 if + there is no separator after name+oldpos. NOTES EXAMPLE - See below. + See below. BUGS @@ -76,15 +76,15 @@ while (*name != separator && *name && size) { - size --; - *buf++ = *name++; - oldpos ++; + size --; + *buf++ = *name++; + oldpos ++; } *buf = 0; if (*name == separator) - return oldpos + 1; + return oldpos + 1; return -1; AROS_LIBFUNC_EXIT @@ -104,17 +104,17 @@ int main (int argc, char ** argv) if (argc < 3) { - fprintf (stderr, "Usage: %s \n", argv[0]); - return RETURN_ERROR; + fprintf (stderr, "Usage: %s \n", argv[0]); + return RETURN_ERROR; } pos=0; do { - pos = SplitName (argv[1], *(argv[2]), buffer, pos, sizeof(buffer)); + pos = SplitName (argv[1], *(argv[2]), buffer, pos, sizeof(buffer)); - printf ("pos = %3ld buffer = \"%s\"\n", pos, buffer); + printf ("pos = %3ld buffer = \"%s\"\n", pos, buffer); } while (pos != -1); diff --git a/rom/dos/startnotify.c b/rom/dos/startnotify.c index 49d6dbe38f..e7d89c35ef 100644 --- a/rom/dos/startnotify.c +++ b/rom/dos/startnotify.c @@ -18,13 +18,13 @@ NAME */ - AROS_LH1(BOOL, StartNotify, + AROS_LH1(BOOL, StartNotify, /* SYNOPSIS */ - AROS_LHA(struct NotifyRequest *, notify, D1), + AROS_LHA(struct NotifyRequest *, notify, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 148, Dos) + struct DosLibrary *, DOSBase, 148, Dos) /* FUNCTION @@ -184,7 +184,7 @@ /* send the request, with error reporting */ do { - err = fs_AddNotify(notify, dvp, lock, DOSBase); + err = fs_AddNotify(notify, dvp, lock, DOSBase); } while (err != 0 && ErrorReport(err, REPORT_LOCK, 0, notify->nr_Handler) == DOSFALSE); /* cleanup */ diff --git a/rom/dos/strtodate.c b/rom/dos/strtodate.c dissimilarity index 73% index ad9153edf2..5025f92e61 100644 --- a/rom/dos/strtodate.c +++ b/rom/dos/strtodate.c @@ -1,440 +1,440 @@ -/* - Copyright © 1995-2010, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Converts a string into a date - Lang: english -*/ -#include -#include "dos_intern.h" - -#ifdef TEST -# include -# include -# undef AROS_LH1 -# undef StrToDate -# undef AROS_LHA -# define AROS_LH1(ret,name,arg,type,base,offset,libname) \ - ret name (arg) -# define AROS_LHA(type,name,reg) type name - -const ULONG Dos_DayTable[]= -{ - 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 -}; - -const char *const Dos_MonthTable[]= -{ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; - -const char *const Dos_WeekTable[]= -{ - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" -}; - -const char *const Dos_SubstDateTable[]= -{ - "Tomorrow", "Today", "Yesterday" -}; -#else -# include "date.h" -#endif - -/***************************************************************************** - - NAME */ -#include -#include - - AROS_LH1(BOOL, StrToDate, - -/* SYNOPSIS */ - AROS_LHA(struct DateTime *, datetime, D1), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 125, Dos) - -/* FUNCTION - Converts a human readable ASCII string into an AmigaDOS - DateStamp. - - INPUTS - DateTime - a pointer to an initialized DateTime structure. - The structure should be initialized as follows: - - dat_Stamp: The converted date will be written here - - 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_FUTURE. If set, then - a string like "Monday" refers to the next monday. - Otherwise it refers to the last monday. - - dat_StrDay: Ignored. - - dat_StrDate: Pointer to valid string representing the - date. This can be a "DTF_SUBST" style string such - as "Today" "Tomorrow" "Monday", or it may be a - string as specified by the dat_Format byte. This - will be converted to the ds_Days portion of the - DateStamp. If this pointer is NULL, - DateStamp->ds_Days will not be affected. - - dat_StrTime: Pointer to a buffer which contains the - time in the ASCII format hh:mm:ss. This will be - converted to the ds_Minutes and ds_Ticks portions - of the DateStamp. If this pointer is NULL, - ds_Minutes and ds_Ticks will be unchanged. - - - RESULT - A zero return indicates that a conversion could not be performed. A - non-zero return indicates that the DateTime.dat_Stamp variable - contains the converted values. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - DateStamp(), DateToStr() - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - struct DateStamp curr; - LONG days, min, tick, len, t, year, month; - BOOL leap; - UBYTE * ptr, * format; - - if ((ptr = datetime->dat_StrDate)) - { - DateStamp (&curr); - - for (t=0; t<3; t++) - { - if (!Strnicmp (Dos_SubstDateTable[t], ptr, strlen (Dos_SubstDateTable[t]))) - break; - } - - if (t != 3) - days = curr.ds_Days + 1 - t; - else - { - for (t=0; t<7; t++) - { - if (!Strnicmp (Dos_WeekTable[t], ptr, strlen (Dos_WeekTable[t]))) - break; - } - - if (t != 7) - { - #if 1 - LONG diffdays; - - days = curr.ds_Days; - - diffdays = t - (days % 7); - - if (datetime->dat_Flags & DTF_FUTURE) - { - if (diffdays > 0) - { - days += diffdays; - } - else - { - days += 7 + diffdays; - } - } - else - { - if (diffdays < 0) - { - days += diffdays; - } - else - { - days += diffdays - 7; - } - } - #else - days = curr.ds_Days; - - if ((days % 7) == 0) - days -= 7; - else - days -= (days % 7); - - days += t; - - if (datetime->dat_Flags & DTF_FUTURE) - days += 7; - #endif - } - else - { - switch (datetime->dat_Format) - { - case FORMAT_INT: format = "y-M-d"; break; - case FORMAT_USA: format = "m-d-y"; break; - case FORMAT_CDN: format = "d-m-y"; break; - default: format = "d-M-y"; break; - } - - while (*format) - { - switch (*format) - { - case 'y': - t = StrToLong (ptr, &year); - - if (t == -1) - return DOSFALSE; - - if (year < 100) - year += 1900; - - ptr += t; - - break; - - case 'M': - t = StrToLong (ptr, &month); - - if (t == -1) - return DOSFALSE; - - ptr += t; - - break; - - case 'd': - t = StrToLong (ptr, &days); - - if (t == -1) - return DOSFALSE; - - ptr += t; - - break; - - case 'm': - for (t=0; t<12; t++) - { - if (!Strnicmp (Dos_MonthTable[t], ptr, - strlen (Dos_MonthTable[t]))) - break; - } - - if (t == 12) - return DOSFALSE; - - month = t+1; - - ptr += strlen (Dos_MonthTable[t]); - - break; - - default: - if (*ptr != *format) - return DOSFALSE; - - ptr ++; - - break; - - } /* switch */ - - format ++; - } /* while */ - - /* kprintf ("Year=%ld, Month=%ld, Days=%ld\n", - year, month, days); */ - - /* Days go from 1..x */ - days --; - - /* First year must be 1978 */ - if (year < 1978) - return DOSFALSE; - - /* Is this year a leap year ? */ - leap = (((year % 400) == 0) || - (((year % 4) == 0) && !((year % 100) == 0))); - - /* Add the days for all years (without leap years) */ - days += (year - 1978) * 365; - -#if 1 - /* stegerg: we do *not* want a day to be added for *this* - year, if it is a leap year. Only the previous years - are the ones we want to be taken into account. */ - - year--; -#endif - - /* Add leap years */ - days += ((year / 4) - (year / 100) + (year / 400) - - (494 - 19 + 4)); - - //kprintf("strtodate: days1 = %d\n", days); - /* Add days of months */ - days += Dos_DayTable[month-1]; - //kprintf("strtodate: days2 = %d\n", days); - - /* - In Dos_DayTable, February has 29 days. Correct this in - non-leap years and if the day has not yet been reached. - */ - -#if 1 - /* stegerg: if this year is *no* leap year, then Dos_DayTable - is wrong by one day when accessing - Dos_DayTable[March..Dec] */ - - if (!leap && (month >= 3)) days--; -#else - if (month >= 2 || (leap && month < 2)) - days --; -#endif - - //kprintf("strtodate: days3 = %d\n", days); - - } /* Normal date */ - - } /* Not "Tomorrow", "Today" or "Yesterday" */ - - datetime->dat_Stamp.ds_Days = days; - - } /* Convert date ? */ - - if ((ptr = datetime->dat_StrTime)) - { - len = StrToLong (ptr, &t); - - if ((len == -1) || (t < 0) || (t > 23)) - return DOSFALSE; - - min = t * 60; - - ptr += len; - - if (*ptr++ != ':') - return DOSFALSE; - - len = StrToLong (ptr, &t); - - if ((len == -1) || (t < 0) || (t > 59)) - return DOSFALSE; - - min += t; - - ptr += len; - - if (*ptr != '\0') - { - if (*ptr++ != ':') - return DOSFALSE; - - len = StrToLong (ptr, &t); - - if ((len == -1) || (t < 0) || (t > 59)) - return DOSFALSE; - - tick = t * TICKS_PER_SECOND; - } - else - tick = 0; - - datetime->dat_Stamp.ds_Minute = min; - datetime->dat_Stamp.ds_Tick = tick; - - } - - return DOSTRUE; - AROS_LIBFUNC_EXIT -} /* StrToDate */ - -#ifdef TEST -# include - -int main (int argc, char ** argv) -{ - struct DateTime dt; - char * date; - char * time; - char daybuf[LEN_DATSTRING]; - char datebuf[LEN_DATSTRING]; - char timebuf[LEN_DATSTRING]; - - if (argc >= 2) - date = argv[1]; - else - date = NULL; - - if (argc >= 3) - time = argv[2]; - else - time = NULL; - - dt.dat_StrDate = date; - dt.dat_StrTime = time; - dt.dat_Flags = 0; - dt.dat_Format = FORMAT_CDN; - - if (!StrToDate (&dt)) - { - printf ("Cannot convert date/time\n"); - return 10; - } - else - { - printf ("Result: Days=%ld, Minute=%ld, Ticks=%ld\n" - , dt.dat_Stamp.ds_Days - , dt.dat_Stamp.ds_Minute - , dt.dat_Stamp.ds_Tick - ); - - dt.dat_StrDay = daybuf; - dt.dat_StrDate = datebuf; - dt.dat_StrTime = timebuf; - - DateToStr (&dt); - - printf ("Gives: %s, %s %s\n", daybuf, datebuf, timebuf); - - dt.dat_Flags = DTF_SUBST; - - DateToStr (&dt); - - printf ("(With DTF_SUBST): %s, %s %s\n", daybuf, datebuf, timebuf); - - } - - return 0; -} /* main */ - -#endif /* TEST */ +/* + Copyright © 1995-2010, The AROS Development Team. All rights reserved. + $Id$ + + Desc: Converts a string into a date + Lang: english +*/ +#include +#include "dos_intern.h" + +#ifdef TEST +# include +# include +# undef AROS_LH1 +# undef StrToDate +# undef AROS_LHA +# define AROS_LH1(ret,name,arg,type,base,offset,libname) \ + ret name (arg) +# define AROS_LHA(type,name,reg) type name + +const ULONG Dos_DayTable[]= +{ + 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 +}; + +const char *const Dos_MonthTable[]= +{ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; + +const char *const Dos_WeekTable[]= +{ + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" +}; + +const char *const Dos_SubstDateTable[]= +{ + "Tomorrow", "Today", "Yesterday" +}; +#else +# include "date.h" +#endif + +/***************************************************************************** + + NAME */ +#include +#include + + AROS_LH1(BOOL, StrToDate, + +/* SYNOPSIS */ + AROS_LHA(struct DateTime *, datetime, D1), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 125, Dos) + +/* FUNCTION + Converts a human readable ASCII string into an AmigaDOS + DateStamp. + + INPUTS + DateTime - a pointer to an initialized DateTime structure. + The structure should be initialized as follows: + + dat_Stamp: The converted date will be written here + + 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_FUTURE. If set, then + a string like "Monday" refers to the next monday. + Otherwise it refers to the last monday. + + dat_StrDay: Ignored. + + dat_StrDate: Pointer to valid string representing the + date. This can be a "DTF_SUBST" style string such + as "Today" "Tomorrow" "Monday", or it may be a + string as specified by the dat_Format byte. This + will be converted to the ds_Days portion of the + DateStamp. If this pointer is NULL, + DateStamp->ds_Days will not be affected. + + dat_StrTime: Pointer to a buffer which contains the + time in the ASCII format hh:mm:ss. This will be + converted to the ds_Minutes and ds_Ticks portions + of the DateStamp. If this pointer is NULL, + ds_Minutes and ds_Ticks will be unchanged. + + + RESULT + A zero return indicates that a conversion could not be performed. A + non-zero return indicates that the DateTime.dat_Stamp variable + contains the converted values. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + DateStamp(), DateToStr() + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + struct DateStamp curr; + LONG days, min, tick, len, t, year, month; + BOOL leap; + UBYTE * ptr, * format; + + if ((ptr = datetime->dat_StrDate)) + { + DateStamp (&curr); + + for (t=0; t<3; t++) + { + if (!Strnicmp (Dos_SubstDateTable[t], ptr, strlen (Dos_SubstDateTable[t]))) + break; + } + + if (t != 3) + days = curr.ds_Days + 1 - t; + else + { + for (t=0; t<7; t++) + { + if (!Strnicmp (Dos_WeekTable[t], ptr, strlen (Dos_WeekTable[t]))) + break; + } + + if (t != 7) + { + #if 1 + LONG diffdays; + + days = curr.ds_Days; + + diffdays = t - (days % 7); + + if (datetime->dat_Flags & DTF_FUTURE) + { + if (diffdays > 0) + { + days += diffdays; + } + else + { + days += 7 + diffdays; + } + } + else + { + if (diffdays < 0) + { + days += diffdays; + } + else + { + days += diffdays - 7; + } + } + #else + days = curr.ds_Days; + + if ((days % 7) == 0) + days -= 7; + else + days -= (days % 7); + + days += t; + + if (datetime->dat_Flags & DTF_FUTURE) + days += 7; + #endif + } + else + { + switch (datetime->dat_Format) + { + case FORMAT_INT: format = "y-M-d"; break; + case FORMAT_USA: format = "m-d-y"; break; + case FORMAT_CDN: format = "d-m-y"; break; + default: format = "d-M-y"; break; + } + + while (*format) + { + switch (*format) + { + case 'y': + t = StrToLong (ptr, &year); + + if (t == -1) + return DOSFALSE; + + if (year < 100) + year += 1900; + + ptr += t; + + break; + + case 'M': + t = StrToLong (ptr, &month); + + if (t == -1) + return DOSFALSE; + + ptr += t; + + break; + + case 'd': + t = StrToLong (ptr, &days); + + if (t == -1) + return DOSFALSE; + + ptr += t; + + break; + + case 'm': + for (t=0; t<12; t++) + { + if (!Strnicmp (Dos_MonthTable[t], ptr, + strlen (Dos_MonthTable[t]))) + break; + } + + if (t == 12) + return DOSFALSE; + + month = t+1; + + ptr += strlen (Dos_MonthTable[t]); + + break; + + default: + if (*ptr != *format) + return DOSFALSE; + + ptr ++; + + break; + + } /* switch */ + + format ++; + } /* while */ + + /* kprintf ("Year=%ld, Month=%ld, Days=%ld\n", + year, month, days); */ + + /* Days go from 1..x */ + days --; + + /* First year must be 1978 */ + if (year < 1978) + return DOSFALSE; + + /* Is this year a leap year ? */ + leap = (((year % 400) == 0) || + (((year % 4) == 0) && !((year % 100) == 0))); + + /* Add the days for all years (without leap years) */ + days += (year - 1978) * 365; + +#if 1 + /* stegerg: we do *not* want a day to be added for *this* + year, if it is a leap year. Only the previous years + are the ones we want to be taken into account. */ + + year--; +#endif + + /* Add leap years */ + days += ((year / 4) - (year / 100) + (year / 400) + - (494 - 19 + 4)); + + //kprintf("strtodate: days1 = %d\n", days); + /* Add days of months */ + days += Dos_DayTable[month-1]; + //kprintf("strtodate: days2 = %d\n", days); + + /* + In Dos_DayTable, February has 29 days. Correct this in + non-leap years and if the day has not yet been reached. + */ + +#if 1 + /* stegerg: if this year is *no* leap year, then Dos_DayTable + is wrong by one day when accessing + Dos_DayTable[March..Dec] */ + + if (!leap && (month >= 3)) days--; +#else + if (month >= 2 || (leap && month < 2)) + days --; +#endif + + //kprintf("strtodate: days3 = %d\n", days); + + } /* Normal date */ + + } /* Not "Tomorrow", "Today" or "Yesterday" */ + + datetime->dat_Stamp.ds_Days = days; + + } /* Convert date ? */ + + if ((ptr = datetime->dat_StrTime)) + { + len = StrToLong (ptr, &t); + + if ((len == -1) || (t < 0) || (t > 23)) + return DOSFALSE; + + min = t * 60; + + ptr += len; + + if (*ptr++ != ':') + return DOSFALSE; + + len = StrToLong (ptr, &t); + + if ((len == -1) || (t < 0) || (t > 59)) + return DOSFALSE; + + min += t; + + ptr += len; + + if (*ptr != '\0') + { + if (*ptr++ != ':') + return DOSFALSE; + + len = StrToLong (ptr, &t); + + if ((len == -1) || (t < 0) || (t > 59)) + return DOSFALSE; + + tick = t * TICKS_PER_SECOND; + } + else + tick = 0; + + datetime->dat_Stamp.ds_Minute = min; + datetime->dat_Stamp.ds_Tick = tick; + + } + + return DOSTRUE; + AROS_LIBFUNC_EXIT +} /* StrToDate */ + +#ifdef TEST +# include + +int main (int argc, char ** argv) +{ + struct DateTime dt; + char * date; + char * time; + char daybuf[LEN_DATSTRING]; + char datebuf[LEN_DATSTRING]; + char timebuf[LEN_DATSTRING]; + + if (argc >= 2) + date = argv[1]; + else + date = NULL; + + if (argc >= 3) + time = argv[2]; + else + time = NULL; + + dt.dat_StrDate = date; + dt.dat_StrTime = time; + dt.dat_Flags = 0; + dt.dat_Format = FORMAT_CDN; + + if (!StrToDate (&dt)) + { + printf ("Cannot convert date/time\n"); + return 10; + } + else + { + printf ("Result: Days=%ld, Minute=%ld, Ticks=%ld\n" + , dt.dat_Stamp.ds_Days + , dt.dat_Stamp.ds_Minute + , dt.dat_Stamp.ds_Tick + ); + + dt.dat_StrDay = daybuf; + dt.dat_StrDate = datebuf; + dt.dat_StrTime = timebuf; + + DateToStr (&dt); + + printf ("Gives: %s, %s %s\n", daybuf, datebuf, timebuf); + + dt.dat_Flags = DTF_SUBST; + + DateToStr (&dt); + + printf ("(With DTF_SUBST): %s, %s %s\n", daybuf, datebuf, timebuf); + + } + + return 0; +} /* main */ + +#endif /* TEST */ diff --git a/rom/dos/strtolong.c b/rom/dos/strtolong.c index f2edad1d1a..23346ac5d6 100644 --- a/rom/dos/strtolong.c +++ b/rom/dos/strtolong.c @@ -11,31 +11,31 @@ NAME */ #include - AROS_LH2I(LONG, StrToLong, + AROS_LH2I(LONG, StrToLong, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, string, D1), - AROS_LHA(LONG *, value, D2), + AROS_LHA(CONST_STRPTR, string, D1), + AROS_LHA(LONG *, value, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 136, Dos) + struct DosLibrary *, DOSBase, 136, Dos) /* FUNCTION - Convert a string to a long number. + Convert a string to a long number. INPUTS - string - The value to convert - value - The result is returned here + string - The value to convert + value - The result is returned here RESULT - How many characters in the string were considered when it was - converted or -1 if no valid number could be found. + How many characters in the string were considered when it was + converted or -1 if no valid number could be found. NOTES - The routine doesn't check if the number if too large. + The routine doesn't check if the number if too large. EXAMPLE - // Valid number are: 5, -1, +3, +0007, etc. + // Valid number are: 5, -1, +3, +0007, etc. BUGS @@ -52,27 +52,27 @@ /* Skip leading whitespace characters */ while(*s==' '||*s=='\t') - s++; + s++; /* Swallow sign */ if(*s=='+'||*s=='-') - sign=*s++; + sign=*s++; /* If there is no number return an error. */ if(*s<'0'||*s>'9') { - *value=0; - return -1; + *value=0; + return -1; } /* Calculate result */ do - v=v*10+*s++-'0'; + v=v*10+*s++-'0'; while(*s>='0'&&*s<='9'); /* Negative? */ if(sign=='-') - v=-v; + v=-v; /* All done. */ *value=v; diff --git a/rom/dos/systemtaglist.c b/rom/dos/systemtaglist.c index d03fcef31c..19dcb52d2b 100644 --- a/rom/dos/systemtaglist.c +++ b/rom/dos/systemtaglist.c @@ -24,14 +24,14 @@ #include - AROS_LH2(LONG, SystemTagList, + AROS_LH2(LONG, SystemTagList, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR , command, D1), - AROS_LHA(struct TagItem *, tags, D2), + AROS_LHA(CONST_STRPTR , command, D1), + AROS_LHA(struct TagItem *, tags, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 101, Dos) + struct DosLibrary *, DOSBase, 101, Dos) /* FUNCTION @@ -44,19 +44,19 @@ that conflict with SystemTagList(). Currently, these are NP_Seglist - NP_FreeSeglist - NP_Entry - NP_Input - NP_Error - NP_Output - NP_CloseInput - NP_CloseOutput - NP_CloseError - NP_HomeDir - NP_Cli + NP_FreeSeglist + NP_Entry + NP_Input + NP_Error + NP_Output + NP_CloseInput + NP_CloseOutput + NP_CloseError + NP_HomeDir + NP_Cli NP_Arguments - NP_Synchrounous - NP_UserData + NP_Synchrounous + NP_UserData INPUTS @@ -135,48 +135,48 @@ while ((tag = NextTagItem(&tags2))) { - D(bug("Tag=%08x Data=%08x\n", tag->ti_Tag, tag->ti_Data)); + D(bug("Tag=%08x Data=%08x\n", tag->ti_Tag, tag->ti_Data)); switch (tag->ti_Tag) - { - case SYS_ScriptInput: - cis = (BPTR)tag->ti_Data; - break; + { + case SYS_ScriptInput: + cis = (BPTR)tag->ti_Data; + break; - case SYS_Input: - sis = (BPTR)tag->ti_Data; - break; + case SYS_Input: + sis = (BPTR)tag->ti_Data; + break; - case SYS_Output: - sos = (BPTR)tag->ti_Data; - break; + case SYS_Output: + sos = (BPTR)tag->ti_Data; + break; - case SYS_Error: - ses = (BPTR)tag->ti_Data; - break; + case SYS_Error: + ses = (BPTR)tag->ti_Data; + break; - case SYS_CustomShell: - resShell = (STRPTR)tag->ti_Data; - isCustom = TRUE; - isCLI = FALSE; - break; + case SYS_CustomShell: + resShell = (STRPTR)tag->ti_Data; + isCustom = TRUE; + isCLI = FALSE; + break; case SYS_UserShell: - isBoot = !tag->ti_Data; - isCustom = FALSE; - break; - - case SYS_Asynch: - isAsynch = tag->ti_Data ? TRUE : FALSE; - break; - - case SYS_Background: - isBackground = tag->ti_Data ? TRUE : FALSE; - break; - - case SYS_CliType: - cliType = (LONG)tag->ti_Data; - break; - } + isBoot = !tag->ti_Data; + isCustom = FALSE; + break; + + case SYS_Asynch: + isAsynch = tag->ti_Data ? TRUE : FALSE; + break; + + case SYS_Background: + isBackground = tag->ti_Data ? TRUE : FALSE; + break; + + case SYS_CliType: + cliType = (LONG)tag->ti_Data; + break; + } } /* Validate cliType */ @@ -214,9 +214,9 @@ if (sis == (BPTR)SYS_DupStream) { sis = OpenFromLock(DupLockFromFH(Input())); - if (!sis) goto end; + if (!sis) goto end; - sis_opened = TRUE; + sis_opened = TRUE; } if (sis == BNULL) { sis = Open("NIL:", MODE_OLDFILE); @@ -233,18 +233,18 @@ if (sos == (BPTR)SYS_DupStream) { sos = OpenFromLock(DupLockFromFH(Output())); - if (!sos) goto end; + if (!sos) goto end; - sos_opened = TRUE; + sos_opened = TRUE; } D(bug("[SystemTagList] cli_StandardOutput: %p\n", sos)); if (ses == (BPTR)SYS_DupStream) { ses = OpenFromLock(DupLockFromFH(me->pr_CES)); - if (!ses) goto end; + if (!ses) goto end; - ses_opened = TRUE; + ses_opened = TRUE; } D(bug("[SystemTagList] cli_StandardError: %p\n", ses)); @@ -277,16 +277,16 @@ /* Load the shell */ if (!isCustom) { - /* Seglist of default shell is stored in RootNode when loaded */ - if (isCLI) - shellseg = findseg_cli(isBoot, DOSBase); + /* Seglist of default shell is stored in RootNode when loaded */ + if (isCLI) + shellseg = findseg_cli(isBoot, DOSBase); else - shellseg = findseg_shell(isBoot, DOSBase); - /* - * Set shell process name. - */ - if (isCLI) - shellName = "CLI"; + shellseg = findseg_shell(isBoot, DOSBase); + /* + * Set shell process name. + */ + if (isCLI) + shellName = "CLI"; else shellName = "Shell"; } else if (resShell != BNULL) { @@ -336,59 +336,59 @@ newtags = CloneTagItems(tags); if (newtags) { - struct Process *cliproc; - - struct TagItem proctags[] = - { - { NP_Priority , me->pr_Task.tc_Node.ln_Pri }, /* 0 */ - { NP_Name , (IPTR)shellName }, /* 1 */ - { NP_Input , (IPTR)BNULL }, /* 2 */ - { NP_Output , (IPTR)BNULL }, /* 3 */ - { NP_Error , (IPTR)ses }, /* 4 */ - { NP_CloseInput , FALSE }, /* 5 */ - { NP_CloseOutput, FALSE }, /* 6 */ - { NP_CloseError , (isAsynch || ses_opened) - ? TRUE : FALSE, }, /* 7 */ - { NP_Cli , (cliType == CLI_NEWCLI) - ? TRUE : FALSE }, /* 8 */ - { NP_WindowPtr , isAsynch ? (IPTR)NULL : - (IPTR)me->pr_WindowPtr }, /* 9 */ - { NP_Seglist , (IPTR)shellseg }, /* 10 */ - { NP_FreeSeglist, FALSE }, /* 11 */ - { NP_Synchronous, FALSE }, /* 12 */ - { NP_Entry , (IPTR)entry }, /* 13 */ - { NP_CurrentDir , (IPTR)BNULL }, /* 14 */ + struct Process *cliproc; + + struct TagItem proctags[] = + { + { NP_Priority , me->pr_Task.tc_Node.ln_Pri }, /* 0 */ + { NP_Name , (IPTR)shellName }, /* 1 */ + { NP_Input , (IPTR)BNULL }, /* 2 */ + { NP_Output , (IPTR)BNULL }, /* 3 */ + { NP_Error , (IPTR)ses }, /* 4 */ + { NP_CloseInput , FALSE }, /* 5 */ + { NP_CloseOutput, FALSE }, /* 6 */ + { NP_CloseError , (isAsynch || ses_opened) + ? TRUE : FALSE, }, /* 7 */ + { NP_Cli , (cliType == CLI_NEWCLI) + ? TRUE : FALSE }, /* 8 */ + { NP_WindowPtr , isAsynch ? (IPTR)NULL : + (IPTR)me->pr_WindowPtr }, /* 9 */ + { NP_Seglist , (IPTR)shellseg }, /* 10 */ + { NP_FreeSeglist, FALSE }, /* 11 */ + { NP_Synchronous, FALSE }, /* 12 */ + { NP_Entry , (IPTR)entry }, /* 13 */ + { NP_CurrentDir , (IPTR)BNULL }, /* 14 */ { NP_ConsoleTask, (IPTR)BNULL, }, /* 15 */ - { TAG_END , 0 } /* 16 */ - }; - - Tag filterList[] = - { - NP_Seglist, - NP_FreeSeglist, - NP_Entry, - NP_Input, - NP_Output, - NP_CloseInput, + { TAG_END , 0 } /* 16 */ + }; + + Tag filterList[] = + { + NP_Seglist, + NP_FreeSeglist, + NP_Entry, + NP_Input, + NP_Output, + NP_CloseInput, NP_CloseOutput, - NP_CloseError, - NP_HomeDir, - NP_Cli, - NP_Arguments, - NP_Synchronous, - NP_UserData, - 0 - }; + NP_CloseError, + NP_HomeDir, + NP_Cli, + NP_Arguments, + NP_Synchronous, + NP_UserData, + 0 + }; - struct DosPacket *dp; + struct DosPacket *dp; - FilterTagItems(newtags, filterList, TAGFILTER_NOT); + FilterTagItems(newtags, filterList, TAGFILTER_NOT); - proctags[sizeof(proctags)/(sizeof(proctags[0])) - 1].ti_Tag = TAG_MORE; - proctags[sizeof(proctags)/(sizeof(proctags[0])) - 1].ti_Data = (IPTR)newtags; + proctags[sizeof(proctags)/(sizeof(proctags[0])) - 1].ti_Tag = TAG_MORE; + proctags[sizeof(proctags)/(sizeof(proctags[0])) - 1].ti_Data = (IPTR)newtags; - dp = AllocDosObject(DOS_STDPKT, NULL); - if (dp) { + dp = AllocDosObject(DOS_STDPKT, NULL); + if (dp) { cliproc = CreateNewProc(proctags); if (cliproc) @@ -469,7 +469,7 @@ FreeDosObject(DOS_STDPKT, dp); } - FreeTagItems(newtags); + FreeTagItems(newtags); } end: diff --git a/rom/dos/ungetc.c b/rom/dos/ungetc.c index 48d3cecf39..885ad18322 100644 --- a/rom/dos/ungetc.c +++ b/rom/dos/ungetc.c @@ -19,29 +19,29 @@ NAME */ #include - AROS_LH2(LONG, UnGetC, + AROS_LH2(LONG, UnGetC, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(LONG, character, D2), + AROS_LHA(BPTR, file, D1), + AROS_LHA(LONG, character, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 53, Dos) + struct DosLibrary *, DOSBase, 53, Dos) /* FUNCTION - Push a character back into a read filehandle. If you've read - a character from that file you may always push at least 1 character - back. UnGetC(file,-1) ungets the last character read. This also - works for EOF. + Push a character back into a read filehandle. If you've read + a character from that file you may always push at least 1 character + back. UnGetC(file,-1) ungets the last character read. This also + works for EOF. INPUTS - file - Filehandle you've read from. - character - Character to push back or EOF. + file - Filehandle you've read from. + character - Character to push back or EOF. RESULT - !=0 if all went well, 0 if the character couldn't be pushed back. - IoErr() gives additional information in that case. + !=0 if all went well, 0 if the character couldn't be pushed back. + IoErr() gives additional information in that case. NOTES @@ -50,7 +50,7 @@ BUGS SEE ALSO - FGetC(), IoErr() + FGetC(), IoErr() INTERNALS @@ -71,28 +71,28 @@ /* If the file is in write mode there was nothing read recently */ if(fh->fh_Flags&FHF_WRITE) { - *result=ERROR_SEEK_ERROR; - return 0; + *result=ERROR_SEEK_ERROR; + return 0; } /* Unget EOF character if the last character read was an EOF */ if(character==EOF&&fh->fh_End==0) { - fh->fh_Pos++; - return EOF; + fh->fh_Pos++; + return EOF; } /* Test if I may unget a character on this file */ if(fh->fh_Pos==0) { - *result=ERROR_SEEK_ERROR; - return 0; + *result=ERROR_SEEK_ERROR; + return 0; } /* OK. Unget character and return. */ fh->fh_Pos--; if(character!=EOF) - ((UBYTE *)BADDR(fh->fh_Buf))[fh->fh_Pos]=character; + ((UBYTE *)BADDR(fh->fh_Buf))[fh->fh_Pos]=character; return character?character:1; AROS_LIBFUNC_EXIT } /* UnGetC */ diff --git a/rom/dos/unloadseg.c b/rom/dos/unloadseg.c index 98798908f1..69c71ebd3e 100644 --- a/rom/dos/unloadseg.c +++ b/rom/dos/unloadseg.c @@ -12,8 +12,8 @@ #include "dos_intern.h" static AROS_UFH3(void, FreeFunc, - AROS_UFHA(APTR, buffer, A1), - AROS_UFHA(ULONG, length, D0), + AROS_UFHA(APTR, buffer, A1), + AROS_UFHA(ULONG, length, D0), AROS_UFHA(struct ExecBase *, SysBase, A6) ) { diff --git a/rom/dos/unlock.c b/rom/dos/unlock.c index fa45f9b70e..b376b9bb99 100644 --- a/rom/dos/unlock.c +++ b/rom/dos/unlock.c @@ -17,20 +17,20 @@ NAME */ #include - AROS_LH1(BOOL, UnLock, + AROS_LH1(BOOL, UnLock, /* SYNOPSIS */ - AROS_LHA(BPTR, lock, D1), + AROS_LHA(BPTR, lock, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 15, Dos) + struct DosLibrary *, DOSBase, 15, Dos) /* FUNCTION - Free a lock created with Lock(). + Free a lock created with Lock(). INPUTS - lock -- The lock to free + lock -- The lock to free RESULT @@ -58,7 +58,7 @@ /* 0 handles are OK */ if(lock == BNULL) - return 0; + return 0; return dopacket1(DOSBase, NULL, fl->fl_Task, ACTION_FREE_LOCK, lock) != 0; diff --git a/rom/dos/unlockdoslist.c b/rom/dos/unlockdoslist.c index b0039549a1..785de3d532 100644 --- a/rom/dos/unlockdoslist.c +++ b/rom/dos/unlockdoslist.c @@ -14,19 +14,19 @@ NAME */ #include - AROS_LH1(void, UnLockDosList, + AROS_LH1(void, UnLockDosList, /* SYNOPSIS */ - AROS_LHA(ULONG, flags, D1), + AROS_LHA(ULONG, flags, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 110, Dos) + struct DosLibrary *, DOSBase, 110, Dos) /* FUNCTION - Frees a lock on the dos lists given by LockDosList(). + Frees a lock on the dos lists given by LockDosList(). INPUTS - flags - the same value as given to LockDosList(). + flags - the same value as given to LockDosList(). RESULT @@ -41,10 +41,10 @@ INTERNALS HISTORY - 04-06-07 sonic - imported back from MorphOS source code - - removed Permit() - 29-10-95 digulla automatically created from - dos_lib.fd and clib/dos_protos.h + 04-06-07 sonic - imported back from MorphOS source code + - removed Permit() + 29-10-95 digulla automatically created from + dos_lib.fd and clib/dos_protos.h *****************************************************************************/ { @@ -55,13 +55,13 @@ D(bug("UnLockDosList: flags = $%lx\n", flags)); if (flags & LDF_ALL) - ReleaseSemaphore(&di->di_DevLock); + ReleaseSemaphore(&di->di_DevLock); if (flags & LDF_ENTRY) - ReleaseSemaphore(&di->di_EntryLock); + ReleaseSemaphore(&di->di_EntryLock); if (flags & LDF_DELETE) - ReleaseSemaphore(&di->di_DeleteLock); + ReleaseSemaphore(&di->di_DeleteLock); /* This came from MorphOS. Left for reference. Permit(); */ diff --git a/rom/dos/unlockrecord.c b/rom/dos/unlockrecord.c index 48edc22769..096e9f3c5d 100644 --- a/rom/dos/unlockrecord.c +++ b/rom/dos/unlockrecord.c @@ -14,15 +14,15 @@ NAME */ #include - AROS_LH3(BOOL, UnLockRecord, + AROS_LH3(BOOL, UnLockRecord, /* SYNOPSIS */ - AROS_LHA(BPTR , fh, D1), - AROS_LHA(ULONG, offset, D2), - AROS_LHA(ULONG, length, D3), + AROS_LHA(BPTR , fh, D1), + AROS_LHA(ULONG, offset, D2), + AROS_LHA(ULONG, length, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 47, Dos) + struct DosLibrary *, DOSBase, 47, Dos) /* FUNCTION @@ -60,7 +60,7 @@ if (fh == BNULL) { - return DOSFALSE; + return DOSFALSE; } status = dopacket3(DOSBase, NULL, fileH->fh_Type, ACTION_FREE_RECORD, fileH->fh_Arg1, offset, length); diff --git a/rom/dos/unlockrecords.c b/rom/dos/unlockrecords.c index 82904c9db0..db08738b98 100644 --- a/rom/dos/unlockrecords.c +++ b/rom/dos/unlockrecords.c @@ -13,13 +13,13 @@ #include #include - AROS_LH1(BOOL, UnLockRecords, + AROS_LH1(BOOL, UnLockRecords, /* SYNOPSIS */ - AROS_LHA(struct RecordLock *, recArray, D1), + AROS_LHA(struct RecordLock *, recArray, D1), /* LOCATION */ - struct DosLibrary *, DOSBase, 48, Dos) + struct DosLibrary *, DOSBase, 48, Dos) /* FUNCTION @@ -51,16 +51,16 @@ while (NULL != BADDR(recArray->rec_FH)) { - LONG success = UnLockRecord(recArray->rec_FH, recArray->rec_Offset, - recArray->rec_Length); + LONG success = UnLockRecord(recArray->rec_FH, recArray->rec_Offset, + recArray->rec_Length); - if (success != DOSTRUE) - { - return success; - } + if (success != DOSTRUE) + { + return success; + } - /* everything OK -> advance to the next entry */ - recArray++; + /* everything OK -> advance to the next entry */ + recArray++; } return DOSTRUE; diff --git a/rom/dos/vfprintf.c b/rom/dos/vfprintf.c index b4b874a53c..9ba719a89e 100644 --- a/rom/dos/vfprintf.c +++ b/rom/dos/vfprintf.c @@ -12,8 +12,8 @@ #include "dos_intern.h" AROS_UFH2(void,vfp_hook, - AROS_UFHA(UBYTE, chr, D0), - AROS_UFHA(struct vfp *, vfp, A3)) + AROS_UFHA(UBYTE, chr, D0), + AROS_UFHA(struct vfp *, vfp, A3)) { AROS_USERFUNC_INIT @@ -21,14 +21,14 @@ AROS_UFH2(void,vfp_hook, if (vfp->count >= 0 && chr != '\0') { - if (FPutC(vfp->file, chr) < 0) - { - vfp->count = -1; + if (FPutC(vfp->file, chr) < 0) + { + vfp->count = -1; - return; - } + return; + } - vfp->count++; + vfp->count++; } AROS_USERFUNC_EXIT @@ -39,26 +39,26 @@ AROS_UFH2(void,vfp_hook, NAME */ #include - AROS_LH3(LONG, VFPrintf, + AROS_LH3(LONG, VFPrintf, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(CONST_STRPTR, format, D2), - AROS_LHA(const IPTR *, argarray, D3), + AROS_LHA(BPTR, file, D1), + AROS_LHA(CONST_STRPTR, format, D2), + AROS_LHA(const IPTR *, argarray, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 59, Dos) + struct DosLibrary *, DOSBase, 59, Dos) /* FUNCTION - Write a formatted (RawDoFmt) string to a specified file (buffered). + Write a formatted (RawDoFmt) string to a specified file (buffered). INPUTS - file - Filehandle to write to - format - RawDoFmt() style formatting string - argarray - Pointer to array of formatting values + file - Filehandle to write to + format - RawDoFmt() style formatting string + argarray - Pointer to array of formatting values RESULT - Number of bytes written or -1 for an error + Number of bytes written or -1 for an error NOTES @@ -81,14 +81,14 @@ AROS_UFH2(void,vfp_hook, vfp.DOSBase = DOSBase; (void)RawDoFmt(format, (APTR)argarray, - (VOID_FUNC)AROS_ASMSYMNAME(vfp_hook), &vfp); + (VOID_FUNC)AROS_ASMSYMNAME(vfp_hook), &vfp); /* Remove the last character (which is a NUL character) */ /* if (vfp.count > 0) { - vfp.count--; - ((struct FileHandle *)BADDR(file))->fh_Pos--; + vfp.count--; + ((struct FileHandle *)BADDR(file))->fh_Pos--; } */ diff --git a/rom/dos/vfwritef.c b/rom/dos/vfwritef.c dissimilarity index 60% index 3ec1e8c216..d02773e3fd 100644 --- a/rom/dos/vfwritef.c +++ b/rom/dos/vfwritef.c @@ -1,312 +1,312 @@ -/* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English -*/ -#include "dos_intern.h" -#include -#include - -LONG putNumber(CONST_STRPTR *format, IPTR **args, ULONG base, BPTR fh, - struct DosLibrary *DOSBase); -STRPTR writeNumber(char *buffer, ULONG base, ULONG n, BOOL minus, - struct DosLibrary *DOSBase); - -/***************************************************************************** - - NAME */ -#include - - AROS_LH3(LONG, VFWritef, - -/* SYNOPSIS */ - AROS_LHA(BPTR , fh , D1), - AROS_LHA(CONST_STRPTR, fmt , D2), - AROS_LHA(const IPTR *, argarray, D3), - -/* LOCATION */ - struct DosLibrary *, DOSBase, 58, Dos) - -/* FUNCTION - - Write a formatted string (with supplied values) to a specified file. - The string may be of any length and the routine is buffered. - The following format commands may be used (preceded by a '%') a la printf. - - S -- string (C style) - Tx -- writes a left justified string padding it to be (at least) - x bytes long - C -- character - Ox -- octal number; maximum width x characters - Xx -- hexadecimal number; maximum width x characters - Ix -- decimal number; maximum width x chararcters - N -- decimal number; any length - Ux -- unsigned decimal number; maximum width x characters - $ -- ignore parameter - - Note: 'x' above is the character value - '0'. - - INPUTS - - fh -- file to write the output to - fmt -- format string - argarray -- pointer to an array of formatting values - - RESULT - - The number of bytes written or -1 if there was an error. - - NOTES - - EXAMPLE - - BUGS - - SEE ALSO - - VFPrintf(), FPutC() - - INTERNALS - -*****************************************************************************/ -{ - AROS_LIBFUNC_INIT - -#define bLast (sizeof(ULONG)*8/3 + 1) - - char buffer[bLast + 1]; - - LONG count = 0; /* Number of characters written */ - CONST_STRPTR format = fmt; - const IPTR *args = argarray; - - STRPTR string; - STRPTR wBuf; /* Pointer to first number character in buffer */ - LONG len; - LONG i; /* Loop variable */ - LONG number; - BOOL minus; - BOOL quitNow = FALSE; /* Takes care of the case "...%" as format - string */ - - - while (*format != 0 && !quitNow) - { - if (*format == '%') - { - format++; - - switch (*format) - { - case 'S': /* Regular c string */ - case 's': - string = (STRPTR)*args; - args++; - - if (string == NULL) - { - return -1; - } - - while (*string != 0) - { - FPutC(fh, *string++); - count++; - } - - break; - - case 'T': /* BCPL string (possibly filled out) */ - case 't': - format++; - len = *format - '0'; - - if (BADDR(*args) == NULL) - { - return -1; - } - - for (i = 0; i < AROS_BSTR_strlen((BSTR)*args); i++) - { - FPutC(fh, AROS_BSTR_getchar((BSTR)*args, i)); - count++; - } - - args++; - - /* If needed, write out spaces to fill field. */ - for(; i < len; i++) - { - FPutC(fh, ' '); - count++; - } - - break; - - case 'C': /* Character */ - case 'c': - FPutC(fh, (char)*args); - count++; - args++; - break; - - case 'O': /* Octal number */ - case 'o': - count += putNumber(&format, (IPTR **)&args, 8, fh, DOSBase); - break; - - case 'X': /* Hexadecimal number */ - case 'x': - count += putNumber(&format, (IPTR **)&args, 16, fh, DOSBase); - break; - - case 'I': /* Decimal number */ - case 'i': - count += putNumber(&format, (IPTR **)&args, 10, fh, DOSBase); - break; - - case 'N': /* Decimal number (no length restriction) */ - case 'n': - number = *args; - args++; - - if (number < 0) - { - number = -number; - minus = TRUE; - } - else - { - minus = FALSE; - } - - buffer[bLast] = 0; - - /* Write decimal number */ - wBuf = writeNumber(&buffer[bLast], 10, number, minus, DOSBase); - - while (*wBuf != 0) - { - FPutC(fh, *wBuf++); - count++; - } - - break; - - case 'U': /* Unsigned decimal number */ - case 'u': - format++; - len = *format - '0'; - - number = *args; - args++; - - wBuf = writeNumber(&buffer[bLast], 10, number, FALSE, DOSBase); - - for (i = 0; i < len; i++) - { - FPutC(fh, *wBuf++); - count++; - - if (*wBuf == 0) - { - break; - } - } - - break; - - case '$': /* Skip argument */ - args++; - break; - - case 0: /* Stupid user... */ - quitNow = TRUE; - break; - - default: /* Ability to print '%':s */ - FPutC(fh, *format); - count++; - break; - } - } - else - { - /* A regular character */ - FPutC(fh, *format); - count++; - } - - format++; - } - - return count; - - AROS_LIBFUNC_EXIT -} /* VFWritef */ - - -LONG putNumber(CONST_STRPTR *format, IPTR **args, ULONG base, BPTR fh, - struct DosLibrary *DOSBase) -{ - char buffer[bLast + 1]; - LONG icount = 0; - LONG number; - LONG len; /* Maximum width of number (ASCII) */ - BOOL minus = FALSE; - STRPTR aNum; - LONG i; /* Loop variable */ - - buffer[bLast] = 0; - - (*format)++; - len = **format - '0'; - - number = **args; - (*args)++; - - if(number < 0) - { - number = -number; - minus = TRUE; - } - - aNum = writeNumber(&buffer[bLast], base, number, minus, DOSBase); - - /* Write the textual number to the file */ - for (i = 0; i < len; i++) - { - FPutC(fh, *aNum++); - icount++; - - if(*aNum == 0) - break; - } - - return icount; -} /* VFWritef */ - - -/* Generate a text string from a number */ -STRPTR writeNumber(char *buffer, ULONG base, ULONG n, BOOL minus, - struct DosLibrary *DOSBase) -{ - int val; - - do - { - val = n % base; - *--buffer = val < 10 ? val + '0' : val - 10 + 'A'; - n /= base; - } while(n != 0); - - if (minus) - { - *--buffer = '-'; - } - - return buffer; -} - +/* + Copyright © 1995-2008, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English +*/ +#include "dos_intern.h" +#include +#include + +LONG putNumber(CONST_STRPTR *format, IPTR **args, ULONG base, BPTR fh, + struct DosLibrary *DOSBase); +STRPTR writeNumber(char *buffer, ULONG base, ULONG n, BOOL minus, + struct DosLibrary *DOSBase); + +/***************************************************************************** + + NAME */ +#include + + AROS_LH3(LONG, VFWritef, + +/* SYNOPSIS */ + AROS_LHA(BPTR , fh , D1), + AROS_LHA(CONST_STRPTR, fmt , D2), + AROS_LHA(const IPTR *, argarray, D3), + +/* LOCATION */ + struct DosLibrary *, DOSBase, 58, Dos) + +/* FUNCTION + + Write a formatted string (with supplied values) to a specified file. + The string may be of any length and the routine is buffered. + The following format commands may be used (preceded by a '%') a la printf. + + S -- string (C style) + Tx -- writes a left justified string padding it to be (at least) + x bytes long + C -- character + Ox -- octal number; maximum width x characters + Xx -- hexadecimal number; maximum width x characters + Ix -- decimal number; maximum width x chararcters + N -- decimal number; any length + Ux -- unsigned decimal number; maximum width x characters + $ -- ignore parameter + + Note: 'x' above is the character value - '0'. + + INPUTS + + fh -- file to write the output to + fmt -- format string + argarray -- pointer to an array of formatting values + + RESULT + + The number of bytes written or -1 if there was an error. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + VFPrintf(), FPutC() + + INTERNALS + +*****************************************************************************/ +{ + AROS_LIBFUNC_INIT + +#define bLast (sizeof(ULONG)*8/3 + 1) + + char buffer[bLast + 1]; + + LONG count = 0; /* Number of characters written */ + CONST_STRPTR format = fmt; + const IPTR *args = argarray; + + STRPTR string; + STRPTR wBuf; /* Pointer to first number character in buffer */ + LONG len; + LONG i; /* Loop variable */ + LONG number; + BOOL minus; + BOOL quitNow = FALSE; /* Takes care of the case "...%" as format + string */ + + + while (*format != 0 && !quitNow) + { + if (*format == '%') + { + format++; + + switch (*format) + { + case 'S': /* Regular c string */ + case 's': + string = (STRPTR)*args; + args++; + + if (string == NULL) + { + return -1; + } + + while (*string != 0) + { + FPutC(fh, *string++); + count++; + } + + break; + + case 'T': /* BCPL string (possibly filled out) */ + case 't': + format++; + len = *format - '0'; + + if (BADDR(*args) == NULL) + { + return -1; + } + + for (i = 0; i < AROS_BSTR_strlen((BSTR)*args); i++) + { + FPutC(fh, AROS_BSTR_getchar((BSTR)*args, i)); + count++; + } + + args++; + + /* If needed, write out spaces to fill field. */ + for(; i < len; i++) + { + FPutC(fh, ' '); + count++; + } + + break; + + case 'C': /* Character */ + case 'c': + FPutC(fh, (char)*args); + count++; + args++; + break; + + case 'O': /* Octal number */ + case 'o': + count += putNumber(&format, (IPTR **)&args, 8, fh, DOSBase); + break; + + case 'X': /* Hexadecimal number */ + case 'x': + count += putNumber(&format, (IPTR **)&args, 16, fh, DOSBase); + break; + + case 'I': /* Decimal number */ + case 'i': + count += putNumber(&format, (IPTR **)&args, 10, fh, DOSBase); + break; + + case 'N': /* Decimal number (no length restriction) */ + case 'n': + number = *args; + args++; + + if (number < 0) + { + number = -number; + minus = TRUE; + } + else + { + minus = FALSE; + } + + buffer[bLast] = 0; + + /* Write decimal number */ + wBuf = writeNumber(&buffer[bLast], 10, number, minus, DOSBase); + + while (*wBuf != 0) + { + FPutC(fh, *wBuf++); + count++; + } + + break; + + case 'U': /* Unsigned decimal number */ + case 'u': + format++; + len = *format - '0'; + + number = *args; + args++; + + wBuf = writeNumber(&buffer[bLast], 10, number, FALSE, DOSBase); + + for (i = 0; i < len; i++) + { + FPutC(fh, *wBuf++); + count++; + + if (*wBuf == 0) + { + break; + } + } + + break; + + case '$': /* Skip argument */ + args++; + break; + + case 0: /* Stupid user... */ + quitNow = TRUE; + break; + + default: /* Ability to print '%':s */ + FPutC(fh, *format); + count++; + break; + } + } + else + { + /* A regular character */ + FPutC(fh, *format); + count++; + } + + format++; + } + + return count; + + AROS_LIBFUNC_EXIT +} /* VFWritef */ + + +LONG putNumber(CONST_STRPTR *format, IPTR **args, ULONG base, BPTR fh, + struct DosLibrary *DOSBase) +{ + char buffer[bLast + 1]; + LONG icount = 0; + LONG number; + LONG len; /* Maximum width of number (ASCII) */ + BOOL minus = FALSE; + STRPTR aNum; + LONG i; /* Loop variable */ + + buffer[bLast] = 0; + + (*format)++; + len = **format - '0'; + + number = **args; + (*args)++; + + if(number < 0) + { + number = -number; + minus = TRUE; + } + + aNum = writeNumber(&buffer[bLast], base, number, minus, DOSBase); + + /* Write the textual number to the file */ + for (i = 0; i < len; i++) + { + FPutC(fh, *aNum++); + icount++; + + if(*aNum == 0) + break; + } + + return icount; +} /* VFWritef */ + + +/* Generate a text string from a number */ +STRPTR writeNumber(char *buffer, ULONG base, ULONG n, BOOL minus, + struct DosLibrary *DOSBase) +{ + int val; + + do + { + val = n % base; + *--buffer = val < 10 ? val + '0' : val - 10 + 'A'; + n /= base; + } while(n != 0); + + if (minus) + { + *--buffer = '-'; + } + + return buffer; +} + diff --git a/rom/dos/vprintf.c b/rom/dos/vprintf.c index 8f9b8ab7b1..54317e5cac 100644 --- a/rom/dos/vprintf.c +++ b/rom/dos/vprintf.c @@ -22,24 +22,24 @@ AROS_UFP2(void, vfp_hook, NAME */ #include - AROS_LH2(LONG, VPrintf, + AROS_LH2(LONG, VPrintf, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, format, D1), - AROS_LHA(IPTR *, argarray, D2), + AROS_LHA(CONST_STRPTR, format, D1), + AROS_LHA(IPTR *, argarray, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 159, Dos) + struct DosLibrary *, DOSBase, 159, Dos) /* FUNCTION - Writes a formatted string to standard output. + Writes a formatted string to standard output. INPUTS - format - RawDoFmt like format string - argarray - Pointer to array of formatting values + format - RawDoFmt like format string + argarray - Pointer to array of formatting values RESULT - Number of bytes written or -1 for an error + Number of bytes written or -1 for an error NOTES @@ -68,14 +68,14 @@ AROS_UFP2(void, vfp_hook, vfp.DOSBase = DOSBase; (void)RawDoFmt(format, argarray, - (VOID_FUNC)AROS_ASMSYMNAME(vfp_hook), &vfp); + (VOID_FUNC)AROS_ASMSYMNAME(vfp_hook), &vfp); /* Remove the last character (which is a NUL character) */ /* if (vfp.count > 0) { - vfp.count--; - ((struct FileHandle *)BADDR(file))->fh_Pos--; + vfp.count--; + ((struct FileHandle *)BADDR(file))->fh_Pos--; } */ diff --git a/rom/dos/waitforchar.c b/rom/dos/waitforchar.c index 2433fe75cc..0768bfffda 100644 --- a/rom/dos/waitforchar.c +++ b/rom/dos/waitforchar.c @@ -14,32 +14,32 @@ #include #include - AROS_LH2(LONG, WaitForChar, + AROS_LH2(LONG, WaitForChar, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(LONG, timeout, D2), + AROS_LHA(BPTR, file, D1), + AROS_LHA(LONG, timeout, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 34, Dos) + struct DosLibrary *, DOSBase, 34, Dos) /* FUNCTION - Wait for a character to arrive at a filehandle. The filehandle - can be either a console handle, or a regular file. For a regular - file most filesystems will return a character immediately, but - sometimes (for example a network handler) the character may not - have arrived. + Wait for a character to arrive at a filehandle. The filehandle + can be either a console handle, or a regular file. For a regular + file most filesystems will return a character immediately, but + sometimes (for example a network handler) the character may not + have arrived. INPUTS - file - File to wait for a character on. - timeout - Number of microseconds to wait for the character - to arrive. A value of 0 says to wait indefinately. + file - File to wait for a character on. + timeout - Number of microseconds to wait for the character + to arrive. A value of 0 says to wait indefinately. RESULT - != 0 if a character arrived before the timeout expired - == 0 if no character arrived + != 0 if a character arrived before the timeout expired + == 0 if no character arrived NOTES - Many filesystems do not implement this function. + Many filesystems do not implement this function. EXAMPLE diff --git a/rom/dos/waitpkt.c b/rom/dos/waitpkt.c index 5d53b61ef5..cdfaceb47e 100644 --- a/rom/dos/waitpkt.c +++ b/rom/dos/waitpkt.c @@ -17,13 +17,13 @@ NAME */ #include - AROS_LH0I(struct DosPacket *, WaitPkt, + AROS_LH0I(struct DosPacket *, WaitPkt, /* SYNOPSIS */ - /* void */ + /* void */ /* LOCATION */ - struct DosLibrary *, DOSBase, 42, Dos) + struct DosLibrary *, DOSBase, 42, Dos) /* FUNCTION @@ -71,18 +71,18 @@ struct DosPacket *internal_WaitPkt(struct MsgPort *msgPort) if (__is_process(me)) { - /* - * Call the packet wait function if the user has one installed. - * Unfortunately, in case of IOFS the user gets something completely different than - * a packet, but we cannot do anything about that... - */ - if (me->pr_PktWait) - { - msg = AROS_UFC3(struct Message *, me->pr_PktWait, - AROS_UFCA(APTR, me->pr_PktWait, A0), - AROS_UFCA(struct MsgPort *, msgPort, A1), - AROS_UFCA(struct ExecBase *, SysBase, A6)); - } + /* + * Call the packet wait function if the user has one installed. + * Unfortunately, in case of IOFS the user gets something completely different than + * a packet, but we cannot do anything about that... + */ + if (me->pr_PktWait) + { + msg = AROS_UFC3(struct Message *, me->pr_PktWait, + AROS_UFCA(APTR, me->pr_PktWait, A0), + AROS_UFCA(struct MsgPort *, msgPort, A1), + AROS_UFCA(struct ExecBase *, SysBase, A6)); + } } if (!msg) @@ -92,8 +92,8 @@ struct DosPacket *internal_WaitPkt(struct MsgPort *msgPort) message port that waits for packets, too. */ while ((msg = GetMsg(msgPort)) == NULL) { - Wait(1 << msgPort->mp_SigBit); - } + Wait(1 << msgPort->mp_SigBit); + } } D(bug("[DOS] WaitPkt(): got DOS packet 0x%p in message 0x%p\n", msg->mn_Node.ln_Name, msg)); diff --git a/rom/dos/write.c b/rom/dos/write.c index a5b8aacdbe..de47a4b105 100644 --- a/rom/dos/write.c +++ b/rom/dos/write.c @@ -16,33 +16,33 @@ NAME */ #include - AROS_LH3(LONG, Write, + AROS_LH3(LONG, Write, /* SYNOPSIS */ - AROS_LHA(BPTR, file, D1), - AROS_LHA(APTR, buffer, D2), - AROS_LHA(LONG, length, D3), + AROS_LHA(BPTR, file, D1), + AROS_LHA(APTR, buffer, D2), + AROS_LHA(LONG, length, D3), /* LOCATION */ - struct DosLibrary *, DOSBase, 8, Dos) + struct DosLibrary *, DOSBase, 8, Dos) /* FUNCTION - Write some data from a given file. The request is directly - given to the filesystem - no buffering is involved. For - small amounts of data it's probably better to use the - buffered I/O routines. + Write some data from a given file. The request is directly + given to the filesystem - no buffering is involved. For + small amounts of data it's probably better to use the + buffered I/O routines. INPUTS - file - filehandle - buffer - pointer to buffer for the data - length - number of bytes to write. The filesystem is - advised to try to fulfill the request as good - as possible. + file - filehandle + buffer - pointer to buffer for the data + length - number of bytes to write. The filesystem is + advised to try to fulfill the request as good + as possible. RESULT - The number of bytes actually written, 0 if the end of the - file was reached, -1 if an error happened. IoErr() will - give additional information in that case. + The number of bytes actually written, 0 if the end of the + file was reached, -1 if an error happened. IoErr() will + give additional information in that case. NOTES @@ -67,11 +67,11 @@ D(bug("[Write] %x %x %d\n", fh, buffer, length)); if (fh == NULL) - SetIoErr(ERROR_INVALID_LOCK); + SetIoErr(ERROR_INVALID_LOCK); else if (fh->fh_Type == BNULL) /* NIL: */ - ret = length; + ret = length; else - ret = dopacket3(DOSBase, NULL, fh->fh_Type, ACTION_WRITE, fh->fh_Arg1, (SIPTR)buffer, length); + ret = dopacket3(DOSBase, NULL, fh->fh_Type, ACTION_WRITE, fh->fh_Arg1, (SIPTR)buffer, length); D(bug("[Write]=%d\n", ret)); return ret; diff --git a/rom/dos/writechars.c b/rom/dos/writechars.c index b9304ec377..dc4e2b426d 100644 --- a/rom/dos/writechars.c +++ b/rom/dos/writechars.c @@ -14,26 +14,26 @@ NAME */ #include - AROS_LH2(LONG, WriteChars, + AROS_LH2(LONG, WriteChars, /* SYNOPSIS */ - AROS_LHA(CONST_STRPTR, buf, D1), - AROS_LHA(ULONG, buflen, D2), + AROS_LHA(CONST_STRPTR, buf, D1), + AROS_LHA(ULONG, buflen, D2), /* LOCATION */ - struct DosLibrary *, DOSBase, 157, Dos) + struct DosLibrary *, DOSBase, 157, Dos) /* FUNCTION - Writes the contents of the buffer to the current output stream. - The number of bytes written is returned. + Writes the contents of the buffer to the current output stream. + The number of bytes written is returned. INPUTS - buf - Buffer to be written. - buflen - Size of the buffer in bytes. + buf - Buffer to be written. + buflen - Size of the buffer in bytes. RESULT - The number of bytes written or EOF on failure. IoErr() gives - additional information in that case. + The number of bytes written or EOF on failure. IoErr() gives + additional information in that case. NOTES @@ -42,7 +42,7 @@ BUGS SEE ALSO - FPuts(), FPutC(), FWrite(), PutStr() + FPuts(), FPutC(), FWrite(), PutStr() INTERNALS @@ -53,8 +53,8 @@ BPTR file = Output(); for (i = 0; i < buflen; i++) - if (FPutC(file, buf[i]) < 0) - return EOF; + if (FPutC(file, buf[i]) < 0) + return EOF; return (LONG)i; AROS_LIBFUNC_EXIT -- 2.11.4.GIT