grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / muiscreen / openpubfile.c
blob8a5a82a26cd0cd2ad4083574883d1afdaabf029a
1 /*
2 Copyright © 2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <libraries/muiscreen.h>
7 #include <proto/dos.h>
8 #include <dos/dos.h>
9 #include <proto/iffparse.h>
10 #include <prefs/prefhdr.h>
11 #define DEBUG 1
12 #include <aros/debug.h>
14 #include "fileformat.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/muiscreen.h>
21 AROS_LH2(APTR, MUIS_OpenPubFile,
23 /* SYNOPSIS */
24 AROS_LHA(char*, name, A0),
25 AROS_LHA(ULONG, mode, D0),
27 /* LOCATION */
28 struct Library *, MUIScreenBase, 9, MUIScreen)
30 /* FUNCTION
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 ******************************************************************************/
49 AROS_LIBFUNC_INIT
51 struct IFFHandle *iff;
53 D(bug("MUIS_OpenPubFile(%s, %d)\n", name, mode));
55 if ((iff = AllocIFF()))
57 if ((iff->iff_Stream = (IPTR) Open(name, mode)))
59 InitIFFasDOS(iff);
60 if (!OpenIFF(iff, (mode == MODE_OLDFILE ? IFFF_READ : IFFF_WRITE)))
62 if (mode == MODE_NEWFILE)
64 if (!PushChunk(iff, ID_PREF, ID_FORM, IFFSIZE_UNKNOWN))
66 if (!PushChunk(iff, ID_PREF, ID_PRHD, sizeof(struct FilePrefHeader)))
68 struct FilePrefHeader head;
70 head.ph_Version = 0; // FIXME: shouold be PHV_CURRENT, but see <prefs/prefhdr.h>
71 head.ph_Type = 0;
72 head.ph_Flags[0] =
73 head.ph_Flags[1] =
74 head.ph_Flags[2] =
75 head.ph_Flags[3] = 0;
77 if (WriteChunkBytes(iff, &head, sizeof(head)) == sizeof(head))
79 PopChunk(iff);
80 return (APTR) iff;
85 else
86 return (APTR) iff;
91 return NULL;
93 AROS_LIBFUNC_EXIT