+
+void setup_notifications ( void ) {
+
+ // figure out notify path
+ char *configpath;
+ char *notifypath = NULL;
+
+ configpath = pnd_conf_query_searchpath();
+
+ pnd_conf_handle apph;
+
+ apph = pnd_conf_fetch_by_id ( pnd_conf_apps, configpath );
+
+ if ( apph ) {
+
+ notifypath = pnd_conf_get_as_char ( apph, PND_APPS_NOTIFY_KEY );
+
+ if ( ! notifypath ) {
+ notifypath = PND_APPS_NOTIFYPATH;
+ }
+
+ }
+
+ // given notify path.. ripped from pndnotifyd :(
+ char *searchpath = notifypath;
+
+ // if this is first time through, we can just set it up; for subsequent times
+ // through, we need to close existing fd and re-open it, since we're too lame
+ // to store the list of watches and 'rm' them
+#if 1
+ if ( nh ) {
+ pnd_notify_shutdown ( nh );
+ nh = 0;
+ }
+#endif
+
+ // set up a new set of notifies
+ if ( ! nh ) {
+ nh = pnd_notify_init();
+ }
+
+ if ( ! nh ) {
+ pnd_log ( pndn_rem, "INOTIFY failed to init.\n" );
+ exit ( -1 );
+ }
+
+#if 0
+ pnd_log ( pndn_rem, "INOTIFY is up.\n" );
+#endif
+
+ SEARCHPATH_PRE
+ {
+
+ pnd_log ( pndn_rem, "Watching path '%s' and its descendents.\n", buffer );
+ pnd_notify_watch_path ( nh, buffer, PND_NOTIFY_RECURSE );
+
+ }
+ SEARCHPATH_POST
+
+ return;
+}