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
20 static const char *template = "NOFLUSH/S,DEBUG/S,NOTIMESTAMPS=NOTS/S";
21 const char *version
= "$VER: PsdErrorlog 4.0 (28.06.09) by Chris Hodges <chrisly@platon42.de>";
22 static IPTR ArgsArray
[ARGS_SIZEOF
];
23 static struct RDArgs
*ArgsHook
= NULL
;
40 int main(int argc
, char *argv
[])
51 struct DateStamp currdate
;
52 UBYTE strdate
[LEN_DATSTRING
];
53 UBYTE strtime
[LEN_DATSTRING
];
55 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
56 fail("Wrong arguments!\n");
58 if((ps
= OpenLibrary("poseidon.library", 4)))
61 if(ArgsArray
[ARGS_DEBUG
])
65 if(ArgsArray
[ARGS_NOFLUSH
])
72 psdGetAttrs(PGA_STACK
, NULL
, PA_ErrorMsgList
, &errmsgs
, TAG_END
);
73 pem
= errmsgs
->lh_Head
;
77 psdGetAttrs(PGA_ERRORMSG
, pem
,
83 if(ds
&& (!ArgsArray
[ARGS_NOTS
]))
85 dt
.dat_Stamp
.ds_Days
= ds
->ds_Days
;
86 dt
.dat_Stamp
.ds_Minute
= ds
->ds_Minute
;
87 dt
.dat_Stamp
.ds_Tick
= ds
->ds_Tick
;
88 dt
.dat_Format
= FORMAT_DEF
;
91 dt
.dat_StrDate
= strdate
;
92 dt
.dat_StrTime
= strtime
;
94 if(currdate
.ds_Days
== ds
->ds_Days
)
96 Printf("%s| %2ld-%s: %s\n", strtime
, level
, origin
, errstr
);
98 Printf("%s %s| %2ld-%s: %s\n", strdate
, strtime
, level
, origin
, errstr
);
101 Printf("%2ld-%s: %s\n", level
, origin
, errstr
);
105 if(!ArgsArray
[ARGS_NOFLUSH
])
108 while(errmsgs
->lh_Head
->ln_Succ
)
110 psdRemErrorMsg(errmsgs
->lh_Head
);
114 if(!ArgsArray
[ARGS_DEBUG
])
120 errmsg
= "Unable to open poseidon.library\n";
123 return(0); // never gets here, just to shut the compiler up