(Didn't add all error checking or the example would grow into gigantic proportions)
How do I obtain msgtype/msgid and msgdata?
What types of messages is there? (yyyy/zzzz)
Edited by orgin on 2009/3/21 7:25:07 Edited by orgin on 2009/3/21 8:09:00 Edited by orgin on 2009/3/21 8:32:21 Edited by orgin on 2009/3/21 8:32:35 Edited by orgin on 2009/3/21 8:45:45
The autodocs does not have any information on how to deal with "NRF_SEND_MESSAGE" notifications, it just states that you can use it.
The example you supplied seems to be using "NRF_SEND_SIGNAL".
Or are you saying that all I need to do is to receive the message (msg = IExec->GetMsg(FSMsgPort))) , and if I do I can assume that the entry is updated and that the message does not provide any more information than that? How do I obtain ADO_NotifyUserData ?
Why is it so difficult to read the *entire* description ?
If you requested that messages should be sent, via the
NRF_SEND_MESSAGE method, the MsgPort pointed to by the
NotifyRequest->nr_stuff.nr_Msg.nr_Port field will receive
a NotifyMessage. The following message fields are of
interest:
NotifyMessage->nm_Class
This is set to the value NOTIFY_CLASS.
NotifyMessage->nm_Code
This is set to the value NOTIFY_CODE.
NotifyMessage->nm_NReq
This points back to the NotifyRequest which caused
the NotifyMessage to be sent.
Note that you must return this message when you no longer need
it. Specifically, all NotifyMessages must be returned before you
can safely end the notification process by calling EndNotify().
And the include file (dos/notify.h) for additional information:
/* --- NotifyMessage Class ------------------------------------------------ */
#define NOTIFY_CLASS 0x40000000
/* Sent to the application if SEND_MESSAGE is specified. */
struct NotifyMessage
{
struct Message
nm_ExecMessage;
ULONG nm_Class;
UWORD nm_Code;
struct NotifyRequest *
nm_NReq; /* don't modify the request! */
ULONG nm_DoNotTouch; /* like it says! For use by handlers */
ULONG nm_DoNotTouch2; /* ditto */
};
You can get the user data from NotifyMessage->nm_NReq->nr_UserData.
Am I supposed to use the ((struct NotifyRequest *)ptr)->nr_stuff.nr_Msg.nr_Port instead of the supplied port to receive messages? (why then supply a port to AllocDocObjectTagListTags() if it's supplying me with a new port anyway?)
How do I query the message port for something else than struct Message * ? (IExec->GetMsg() returns struct Message *, not struct NotifyMessage* or can you safely typecast it)
Am I supposed to use the ((struct NotifyRequest *)ptr)->nr_stuff.nr_Msg.nr_Port instead of the supplied port to receive messages? (why then supply a port to AllocDosObjectTags() if it's supplying me with a new port anyway?)
As I understand it, it's the "same" port you supply with AllocDosObjectTags().
Quote:
How do I query the message port for something else than struct Message * ? (IExec->GetMsg() returns struct Message *, not struct NotifyMessage* or can you safely typecast it)
If you use the Port only for your filenotification it should be save to typecast it, or not?
@orgin Here's the source code for a test program I used for the DOS notify handler. It's a bit messy, but i'm too-lazy to tidy it up. Compile it as is (with -nostdlib) and you will see all three methods at work.
Start it from a shell with one argument that is the path to the filesystem object to be monitored.
such kind of code source could integrate very well in the SDK's Examples drawer. Any sample code is good to take in our current situation. There are many different source samples I'd like to see into this so desperatly *near* empty Examples drawer : a sample generic device, a sample animation datatype, a sample generic handler, a sample boopsi class, to name just a few of them. Of course I understand that currently time is best spent on improving the OS itself rather than on writing sample tutorials however when some test code exists why not just share it ?
Anyone that wants to contribute source code examples to future versions of the SDK is more than welcome to do so.
As credits for included stuff would be a real headache in this situation, I would suggest that you include any information you want to be made public in the source code itself.
Obviously, examples need to be kept simple, be well commented, and be compilable with the minumum of ease. That means either a makefile, or (in the old SAS/c days) executing the source file.
Examples can be sent to me, and I'll see about adding them to the CVS for future SDK disttributions.
Yes but if I was asking it's because for the mentionned things I don't know the right way to do things myself, else I won't be asking for them Anyway my comment was mainly because Colin often has some small test codes for DOS.library (which is really a tricky under documented part of AmigaOS) that he publish here and there to demonstrate usage of one DOS.library's function or another, they are generaly relatively small and more importantly they work (as they constitute part of his DOS.library testing process .
Anyway if Colin is okay (and has no time to do it himself) I could try to gather all his samples I can find on websites, provide a makefile and then send them to you for inclusion in the SDK.