1 /* SysLog Listview hooks */
7 #include <proto/exec.h>
8 #include <proto/muimaster.h>
10 #include <proto/locale.h>
11 #include <clib/alib_protos.h>
12 #include <libraries/asl.h>
13 #include <mui/NList_mcc.h>
14 //#include <exec/rawfmt.h>
17 #include "colorlist.h"
19 extern STRPTR levels
[];
21 /* PutCharFunc hook for FormatDate */
23 #if !defined(__AROS__)
24 void PutCharFunc(void)
26 struct Hook
*h
= (struct Hook
*)REG_A0
;
27 BYTE ch
= (BYTE
)REG_A1
;
31 AROS_UFHA(struct Hook
*, h
, A0
),
32 AROS_UFHA(APTR
*, obj
, A2
),
33 AROS_UFHA(BYTE
, ch
, A1
)
39 #if !defined(__AROS__)
40 *((STRPTR
)h
->h_Data
)++ = ch
;
46 #if !defined(__AROS__)
47 struct EmulLibEntry g_PutCharFunc
= {TRAP_LIB
, 0, (void (*)(void))PutCharFunc
};
48 struct Hook h_PutCharFunc
= {{NULL
, NULL
}, (HOOKFUNC
)&g_PutCharFunc
, NULL
, NULL
};
50 struct Hook h_PutCharFunc
;
53 /* SaveAs hook called on menu notification, saves all log to a text file. */
57 Object *list = (Object*)REG_A2;
58 struct FileRequester *freq;
60 if (freq = MUI_AllocAslRequest(ASL_FileRequest, NULL))
62 if (MUI_AslRequestTags(freq,
63 ASLFR_Window, (ULONG)_window(list),
64 ASLFR_TitleText, "Save media log file",
65 ASLFR_DoSaveMode, TRUE,
70 if (lock = Lock(freq->fr_Drawer, SHARED_LOCK))
74 olddir = CurrentDir(lock);
75 if (logfile = Open(freq->fr_File, MODE_NEWFILE))
78 struct SysLogEntry *sle;
80 for (entry = 0; ; entry++)
82 DoMethod(list, MUIM_List_GetEntry, entry, (ULONG)&sle);
84 FPrintf(logfile, "\"%s\", \"%s\", \"%s\", \"%s\"\n", sle->Time, levels[LOG_PRI(sle->Level)],
85 sle->ProcessName, sle->EventDescription);
93 MUI_FreeAslRequest(freq);
98 struct EmulLibEntry g_SaveAsHook = {TRAP_LIB, 0, (void (*)(void))SaveAsHook};
99 struct Hook h_SaveAsHook = {{NULL, NULL}, (HOOKFUNC)&g_SaveAsHook, NULL, NULL};