Commit of the code which was suggested by Georg as a fix for:
[cake.git] / rom / dos / vfprintf.c
blobb8ce490d5615083f7ed0ebd0dedb03de3c0c1026
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include <dos/dosextens.h>
10 #include <dos/filesystem.h>
11 #include <proto/dos.h>
12 #include <aros/asmcall.h>
13 #include "dos_intern.h"
15 AROS_UFH2(void,vfp_hook,
16 AROS_UFHA(UBYTE, chr, D0),
17 AROS_UFHA(struct vfp *, vfp, A3))
19 AROS_USERFUNC_INIT
21 struct DosLibrary *DOSBase = vfp->DOSBase;
23 if (vfp->count >= 0 && chr != '\0')
25 if (FPutC(vfp->file, chr) < 0)
27 vfp->count = -1;
29 return;
32 vfp->count++;
35 AROS_USERFUNC_EXIT
38 /*****************************************************************************
40 NAME */
41 #include <proto/dos.h>
43 AROS_LH3(LONG, VFPrintf,
45 /* SYNOPSIS */
46 AROS_LHA(BPTR, file, D1),
47 AROS_LHA(CONST_STRPTR, format, D2),
48 AROS_LHA(const IPTR *, argarray, D3),
50 /* LOCATION */
51 struct DosLibrary *, DOSBase, 59, Dos)
53 /* FUNCTION
55 INPUTS
57 RESULT
59 NOTES
61 EXAMPLE
63 BUGS
65 SEE ALSO
67 INTERNALS
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 struct vfp vfp;
75 vfp.file = file;
76 vfp.count = 0;
77 vfp.DOSBase = DOSBase;
79 (void)RawDoFmt(format, argarray,
80 (VOID_FUNC)AROS_ASMSYMNAME(vfp_hook), &vfp);
82 /* Remove the last character (which is a NUL character) */
84 if (vfp.count > 0)
86 vfp.count--;
87 ((struct FileHandle *)BADDR(file))->fh_Pos--;
91 return vfp.count;
93 AROS_LIBFUNC_EXIT
94 } /* VFPrintf */