Indentation fix, cleanup.
[AROS.git] / rom / dos / makedosentry.c
blob827fb81bdc857d4890a4f4bf391455e7bbbaa0bf
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Creates an entry for the dos list.
6 Lang: english
7 */
8 #include <exec/memory.h>
9 #include <proto/exec.h>
11 #include <string.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH2(struct DosList *, MakeDosEntry,
22 /* SYNOPSIS */
23 AROS_LHA(CONST_STRPTR, name, D1),
24 AROS_LHA(LONG, type, D2),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 116, Dos)
29 /* FUNCTION
30 Create an entry for the dos list. Depending on the type this may
31 be a device, a volume or an assign node.
33 INPUTS
34 name - pointer to name
35 type - type of list entry to create
37 RESULT
38 The new device entry, or NULL if it couldn't be created.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 AddDosEntry(), RemDosEntry(), FindDosEntry(), LockDosList(),
48 NextDosEntry(), FreeDosEntry()
50 INTERNALS
51 This call should be replaced by a value for AllocDosObject().
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 ULONG len = strlen(name);
58 STRPTR s2;
59 struct DosList *dl;
61 dl = (struct DosList *)AllocVec(sizeof(struct DosList),
62 MEMF_PUBLIC | MEMF_CLEAR);
64 if (dl != NULL)
66 #ifdef AROS_FAST_BPTR
67 s2 = (STRPTR)AllocVec(len+1, MEMF_PUBLIC | MEMF_CLEAR);
68 dl->dol_Name = MKBADDR(s2);
69 #else
70 /* Binary compatibility for BCPL string.
71 * First byte is the length then comes the string.
72 * For ease of use a zero is put at the end so it can be used as a
73 * C string
75 s2 = (STRPTR)AllocVec(len+2, MEMF_PUBLIC | MEMF_CLEAR);
76 dl->dol_Name = MKBADDR(s2);
77 if (s2 != NULL)
78 *s2++ = (UBYTE)(len > 255 ? 255 : len);
79 #endif
80 if (s2 != NULL)
82 strcpy(s2, name);
83 dl->dol_Type = type;
84 return dl;
86 else
88 SetIoErr(ERROR_NO_FREE_STORE);
91 FreeVec(dl);
93 else
95 SetIoErr(ERROR_NO_FREE_STORE);
98 return NULL;
100 AROS_LIBFUNC_EXIT
101 } /* MakeDosEntry */