[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: {dir,file}_notice_changes wrapper in libshouldbeinlibc?

From: Niels Möller
Subject: Re: {dir,file}_notice_changes wrapper in libshouldbeinlibc?
Date: 08 Jan 2002 17:49:46 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Moritz Schulte <> writes:

> error_t
> request_dir_change_notifications ((void) (*callback) (dir_changed_type_t 
> change_type,
>                                                       char *name),
>                                    char *dirname);
> Which would request dir notifications for DIRNAME and call *CALLBACK
> with the according information whenever a notification message arives.
> Is something like that the right way[tm]?

I think there should also be a place for application specific context,

request_dir_change_notifications (void *ctx,
                                  (void) (*callback) (dir_changed_type_t 
                                                      char *name,
                                                      void *ctx),
                                   char *dirname);

What is it that will invoke the callback? I guess you're thinking that
request_dir_change_notifications should spawn a thread that invokes
the callback whenever anything interesting happens. Sounds right, if
we can assume that the application is prepared to handle multithreading.

Further more, you probably want to return some id that can be used for
cancelling the notification request.

It would be nice to also have a select-friendly interface. I.e. a
function that returns an fd that you can select on, together with all
other fd:s you may have. Closing the fd would cancel the notification
request. Using the read function on the fd might not make sense, but
one could have a specialized function for that.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]