2 ** PsdErrorlog by Chris Hodges <chrisly@platon42.de>
9 #include <dos/datetime.h>
10 #include <libraries/poseidon.h>
11 #include <proto/poseidon.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
15 #define ARGS_NOFLUSH 0
19 static const char *template = "NOFLUSH/S,NOTIMESTAMPS=NOTS/S";
20 static const char *version
= "$VER: PsdErrorlog 4.0 (03.06.09) by Chris Hodges <chrisly@platon42.de>";
21 static IPTR ArgsArray
[ARGS_SIZEOF
];
22 static struct RDArgs
*ArgsHook
= NULL
;
39 int main(int argc
, char *argv
[])
50 struct DateStamp currdate
;
51 UBYTE strdate
[LEN_DATSTRING
];
52 UBYTE strtime
[LEN_DATSTRING
];
54 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
55 fail("Wrong arguments!\n");
57 if((ps
= OpenLibrary("poseidon.library", 3)))
60 if(ArgsArray
[ARGS_NOFLUSH
])
66 psdGetAttrs(PGA_STACK
, NULL
, PA_ErrorMsgList
, &errmsgs
, TAG_END
);
67 pem
= errmsgs
->lh_Head
;
71 psdGetAttrs(PGA_ERRORMSG
, pem
,
77 if(ds
&& (!ArgsArray
[ARGS_NOTS
]))
79 dt
.dat_Stamp
.ds_Days
= ds
->ds_Days
;
80 dt
.dat_Stamp
.ds_Minute
= ds
->ds_Minute
;
81 dt
.dat_Stamp
.ds_Tick
= ds
->ds_Tick
;
82 dt
.dat_Format
= FORMAT_DEF
;
85 dt
.dat_StrDate
= strdate
;
86 dt
.dat_StrTime
= strtime
;
88 if(currdate
.ds_Days
== ds
->ds_Days
)
90 Printf("%s| %2ld-%s: %s\n", strtime
, level
, origin
, errstr
);
92 Printf("%s %s| %2ld-%s: %s\n", strdate
, strtime
, level
, origin
, errstr
);
95 Printf("%2ld-%s: %s\n", level
, origin
, errstr
);
99 if(!ArgsArray
[ARGS_NOFLUSH
])
102 while(errmsgs
->lh_Head
->ln_Succ
)
104 psdRemErrorMsg(errmsgs
->lh_Head
);
111 errmsg
= "Unable to open poseidon.library\n";
114 return(0); // never gets here, just to shut the compiler up