Hi, just updated hooktest.c to use OS4 hooks "mode". It works fine. IS this the right way if updating/coding? Or must I for every AllocSys.. add FreeSys..?
TIA
;/* gcc hooktest2.c -o HookTest2 -Wall -lauto -gstabs quit */ #include <proto/dos.h> #include <proto/locale.h> #include <proto/exec.h> void fmtfunct(struct Hook *hook, struct Locale *locale, ULONG ch) { char *buffer = (char *)hook->h_Data; *buffer++ = ch; hook->h_Data = (APTR)buffer; } int main(void) { struct DateStamp ds; char buffer[30]; struct Hook *prhook; IDOS->DateStamp(&ds); // fmthook.h_Entry = (HOOKFUNC)fmtfunct; // fmthook.h_Data = (APTR)buffer; prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, fmtfunct, ASOHOOK_Data, buffer, TAG_DONE); ILocale->FormatDate(NULL,"%d-%m-%Y", &ds, prhook); IDOS->Printf("Fecha: %s\n",buffer); // fmthook.h_Entry = (HOOKFUNC)fmtfunct; // fmthook.h_Data = (APTR)buffer; prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, fmtfunct, ASOHOOK_Data, buffer, TAG_DONE); ILocale->FormatDate(NULL,"%d", &ds, prhook); IDOS->Printf("Day: %s\n",buffer); // fmthook.h_Entry = (HOOKFUNC)fmtfunct; // fmthook.h_Data = (APTR)buffer; prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, fmtfunct, ASOHOOK_Data, buffer, TAG_DONE); ILocale->FormatDate(NULL,"%m", &ds, prhook); IDOS->Printf("Month: %s ",buffer); // fmthook.h_Entry = (HOOKFUNC)fmtfunct; // fmthook.h_Data = (APTR)buffer; prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, fmtfunct, ASOHOOK_Data, buffer, TAG_DONE); ILocale->FormatDate(NULL,"%B", &ds, prhook); IDOS->Printf("(%s)\n",buffer); // fmthook.h_Entry = (HOOKFUNC)fmtfunct; // fmthook.h_Data = (APTR)buffer; prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, fmtfunct, ASOHOOK_Data, buffer, TAG_DONE); ILocale->FormatDate(NULL,"%Y", &ds, prhook); IDOS->Printf("Year: %s\n",buffer); IExec->FreeSysObject(ASOT_HOOK, prhook); return(RETURN_OK); }