/* Generated from "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod" by precompile.pike running Pike v8.1 release 13
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 6

#undef PRECOMPILE_SUB_PIKEVARS
#define PRECOMPILE_SUB_PIKEVARS 1

#undef PRECOMPILE_DYNAMIC_TYPES
#define PRECOMPILE_DYNAMIC_TYPES 1



#undef cmod___CMOD__
#define cmod___CMOD__ 1
#line 1 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#line 3003 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"







#line 3010 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"
#line 1 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
/*! @module System
 */

/*! @module Wnotify
 *!
 *! An interface to Windows filesystem change information. 
 *!
 */

#line 10 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#include "global.h"
#include "interpret.h"
#include "module.h"
#include "program.h"
#include "stralloc.h"
#include "svalue.h"
#include "threads.h"
#include "object.h"
#include "pike_types.h"
#include "builtin_functions.h"

#include "wnotify_config.h"

#define ADD_ICONST(name) do {                   \
        add_integer_constant(#name, name, 0);   \
} while(0);

#ifdef HAVE_FILEAPI_H
#include <FileAPI.h>
#endif /* HAVE_FILEAPI_H */

#ifdef HAVE_WINDOWS_H
#include <Windows.h>
#endif /* HAVE_WINDOWS_H */

#ifdef HAVE_WINBASE_H
#include <WinBase.h>
#endif /* HAVE_WINBASE_H */

#ifndef MAX_LEN
#define MAX_LEN 255
#endif /* !MAX_LEN */



#ifndef PIKE_UNUSED_ATTRIBUTE
#define PIKE_UNUSED_ATTRIBUTE
#endif
#define CMOD_MAP_PROGRAM_IDS_DEFINED 1
static int ___cmod_map_program_ids(int id) PIKE_UNUSED_ATTRIBUTE;
#ifndef TYPEOF
/* Compat with older Pikes. */
#define TYPEOF(SVAL)	((SVAL).type)
#define SUBTYPEOF(SVAL)	((SVAL).subtype)
#define SET_SVAL_TYPE(SVAL, TYPE)	(TYPEOF(SVAL) = TYPE)
#define SET_SVAL_SUBTYPE(SVAL, TYPE)	(SUBTYPEOF(SVAL) = TYPE)
#define SET_SVAL(SVAL, TYPE, SUBTYPE, FIELD, EXPR) do {	\
    /* Set the type afterwards to avoid a clobbered	\
     * svalue in case EXPR throws. */			\
    (SVAL).u.FIELD = (EXPR);				\
    SET_SVAL_TYPE((SVAL), (TYPE));			\
    SET_SVAL_SUBTYPE((SVAL), (SUBTYPE));		\
  } while(0)
#endif /* !TYPEOF */
#ifndef PIKE_UNUSED
/* Compat with Pike 7.8 and earlier. */
/* NB: Not strictly correct; PIKE_UNUSED was added the
 *     day after set_program_id_to_id(), but good enough.
 */
#ifndef UNUSED
#define UNUSED(X)	X
#endif
#ifndef set_program_id_to_id
/* NB: Recent Pike 7.8 has a #define that conflicts with
 *     the following declaration.
 */
static void set_program_id_to_id(void*UNUSED(id)){}
#endif
#else /* */
PMOD_EXPORT void set_program_id_to_id( int (*to)(int) );
#endif /* !PIKE_UNUSED */


#ifndef DEFAULT_CMOD_STORAGE
#define CMOD_COND_USED
#define DEFAULT_CMOD_STORAGE static
#endif
#ifndef CMOD_COND_USED
# define f_Wnotify_NotificationHandle_create_fun_num_used 1
#else
#undef f_Wnotify_NotificationHandle_create_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Wnotify_NotificationHandle_get_error_fun_num_used 1
#else
#undef f_Wnotify_NotificationHandle_get_error_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Wnotify_NotificationHandle_read_change_fun_num_used 1
#else
#undef f_Wnotify_NotificationHandle_read_change_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Wnotify_NotificationHandle_program_fun_num_used 1
#else
#undef Wnotify_NotificationHandle_program_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Wnotify_EventPoller_add_handle_fun_num_used 1
#else
#undef f_Wnotify_EventPoller_add_handle_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Wnotify_EventPoller_poll_fun_num_used 1
#else
#undef f_Wnotify_EventPoller_poll_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Wnotify_EventPoller_program_fun_num_used 1
#else
#undef Wnotify_EventPoller_program_fun_num_used
#endif
#line 44 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#ifdef HAVE_FINDFIRSTCHANGENOTIFICATION

/*! @class NotificationHandle
 */


#undef class_Wnotify_NotificationHandle_defined
#define class_Wnotify_NotificationHandle_defined
DEFAULT_CMOD_STORAGE struct program *Wnotify_NotificationHandle_program=NULL;

#ifdef Wnotify_NotificationHandle_program_fun_num_used
DEFAULT_CMOD_STORAGE int Wnotify_NotificationHandle_program_fun_num=-1;
#endif /* Wnotify_NotificationHandle_program_fun_num_used */

#undef var_handle_Wnotify_NotificationHandle_defined
#define var_handle_Wnotify_NotificationHandle_defined

#undef var_path_Wnotify_NotificationHandle_defined
#define var_path_Wnotify_NotificationHandle_defined

#undef var_watch_subtree_Wnotify_NotificationHandle_defined
#define var_watch_subtree_Wnotify_NotificationHandle_defined

#undef var_filter_Wnotify_NotificationHandle_defined
#define var_filter_Wnotify_NotificationHandle_defined

#undef var_triggered_Wnotify_NotificationHandle_defined
#define var_triggered_Wnotify_NotificationHandle_defined

#undef THIS
#define THIS ((struct Wnotify_NotificationHandle_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_WNOTIFY_NOTIFICATIONHANDLE
#define THIS_WNOTIFY_NOTIFICATIONHANDLE ((struct Wnotify_NotificationHandle_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_WNOTIFY_NOTIFICATIONHANDLE
#define OBJ2_WNOTIFY_NOTIFICATIONHANDLE(o) ((struct Wnotify_NotificationHandle_struct *)(o->storage+Wnotify_NotificationHandle_storage_offset))

#undef GET_WNOTIFY_NOTIFICATIONHANDLE_STORAGE
#define GET_WNOTIFY_NOTIFICATIONHANDLE_STORAGE(o) ((struct Wnotify_NotificationHandle_struct *)(o->storage+Wnotify_NotificationHandle_storage_offset)
static ptrdiff_t Wnotify_NotificationHandle_storage_offset;
struct Wnotify_NotificationHandle_struct {

#ifdef var_handle_Wnotify_NotificationHandle_defined
#line 51 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
HANDLE handle;
#endif /* var_handle_Wnotify_NotificationHandle_defined */

#ifdef var_path_Wnotify_NotificationHandle_defined
  struct pike_string * path;

#endif /* var_path_Wnotify_NotificationHandle_defined */

#ifdef var_watch_subtree_Wnotify_NotificationHandle_defined
  INT_TYPE watch_subtree;

#endif /* var_watch_subtree_Wnotify_NotificationHandle_defined */

#ifdef var_filter_Wnotify_NotificationHandle_defined
  INT_TYPE filter;

#endif /* var_filter_Wnotify_NotificationHandle_defined */

#ifdef var_triggered_Wnotify_NotificationHandle_defined
  INT_TYPE triggered;

#endif /* var_triggered_Wnotify_NotificationHandle_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Wnotify_NotificationHandle_struct *Wnotify_NotificationHandle_gdb_dummy_ptr;
#endif
/*! @decl void create(string path, int watch_subtree, int filter)
 */
  #define f_Wnotify_NotificationHandle_create_defined

#ifdef f_Wnotify_NotificationHandle_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Wnotify_NotificationHandle_create_fun_num = 0;

#endif /* f_Wnotify_NotificationHandle_create_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Wnotify_NotificationHandle_create(INT32 args) {
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
struct pike_string * path;
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
INT_TYPE watch_subtree;
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
INT_TYPE filter;
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(args != 3) wrong_number_of_args_error("create",args,3);
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("create",1,"string");
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
debug_malloc_pass(path=Pike_sp[0-3].u.string);
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("create",2,"int");
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
watch_subtree=Pike_sp[1-3].u.integer;
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("create",3,"int");
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
filter=Pike_sp[2-3].u.integer;
{
    HANDLE h;

    THIS->path = path;
    add_ref(path);
    THIS->watch_subtree = watch_subtree;
    THIS->filter = filter;
    if(string_has_null(path))
    {
      pop_n_elems(args);
      Pike_error("NotificationHandle: path cannot contain null.\n");
    }
    if((1 << path->size_shift)>1)
    {
      pop_n_elems(args);
      Pike_error("NotificationHandle: path cannot be a wide string.\n");
    }
    if(THIS->path->len > MAX_LEN)
    {
      pop_n_elems(args);
      Pike_error("NotificationHandle: length of path is too long.\n");
    }
    h = FindFirstChangeNotification(path->str, (BOOL)THIS->watch_subtree, (DWORD)THIS->filter);
    if(h == INVALID_HANDLE_VALUE)
    {
      pop_n_elems(args);
      Pike_error("NotificationHandle: failed to create handle.\n");
    }
    else
      THIS->handle = h;
    pop_n_elems(args);
    return;
  }

  }
/*! @decl int get_error()
   */
  #define f_Wnotify_NotificationHandle_get_error_defined

#ifdef f_Wnotify_NotificationHandle_get_error_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Wnotify_NotificationHandle_get_error_fun_num = 0;

#endif /* f_Wnotify_NotificationHandle_get_error_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Wnotify_NotificationHandle_get_error(INT32 args) {
#line 96 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(args != 0) wrong_number_of_args_error("get_error",args,0);
{
    DWORD e;

    e = GetLastError();

    push_int(e);
  }

  }
#define f_Wnotify_NotificationHandle_read_change_defined

#ifdef f_Wnotify_NotificationHandle_read_change_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Wnotify_NotificationHandle_read_change_fun_num = 0;

#endif /* f_Wnotify_NotificationHandle_read_change_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Wnotify_NotificationHandle_read_change(INT32 args) {
#line 105 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(args != 0) wrong_number_of_args_error("read_change",args,0);
{
/*
    BOOL res;
*/	
    if(!THIS->triggered)
    {
      Pike_error("NotificationHandle.read_change(): no change event triggered.\n");
    }

/*    res = ReadDirectoryChangesW(THIS->handle, );     */
  }

  }

#undef internal_init_Wnotify_NotificationHandle_defined
#define internal_init_Wnotify_NotificationHandle_defined

#undef Wnotify_NotificationHandle_event_handler_defined
#define Wnotify_NotificationHandle_event_handler_defined
static void init_Wnotify_NotificationHandle_struct(void)
#line 119 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
{
  }

  
#undef Wnotify_NotificationHandle_gc_live_obj
#define Wnotify_NotificationHandle_gc_live_obj

#undef internal_exit_Wnotify_NotificationHandle_defined
#define internal_exit_Wnotify_NotificationHandle_defined

#undef Wnotify_NotificationHandle_event_handler_defined
#define Wnotify_NotificationHandle_event_handler_defined
static void exit_Wnotify_NotificationHandle_struct(void)
#line 123 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
{
    if(THIS->path) free_string(THIS->path);
    if(THIS->handle) FindCloseChangeNotification(THIS->handle);
  }

#ifdef Wnotify_NotificationHandle_event_handler_defined
static void Wnotify_NotificationHandle_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Wnotify_NotificationHandle_defined
  case PROG_EVENT_INIT: init_Wnotify_NotificationHandle_struct(); break;

#endif /* internal_init_Wnotify_NotificationHandle_defined */

#ifdef internal_exit_Wnotify_NotificationHandle_defined
  case PROG_EVENT_EXIT: exit_Wnotify_NotificationHandle_struct(); break;

#endif /* internal_exit_Wnotify_NotificationHandle_defined */
  default: break; 
  }
}

#endif /* Wnotify_NotificationHandle_event_handler_defined */
/*! @endclass */

/*! @class EventPoller
 */

#undef class_Wnotify_EventPoller_defined
#define class_Wnotify_EventPoller_defined
DEFAULT_CMOD_STORAGE struct program *Wnotify_EventPoller_program=NULL;

#ifdef Wnotify_EventPoller_program_fun_num_used
DEFAULT_CMOD_STORAGE int Wnotify_EventPoller_program_fun_num=-1;
#endif /* Wnotify_EventPoller_program_fun_num_used */
#line 135 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
/* Do not meddle with this array; it must be kept in sync with the handles array. */
  
#undef var_phandles_Wnotify_EventPoller_defined
#define var_phandles_Wnotify_EventPoller_defined

#undef var_handles_Wnotify_EventPoller_defined
#define var_handles_Wnotify_EventPoller_defined

#undef var_handles_size_Wnotify_EventPoller_defined
#define var_handles_size_Wnotify_EventPoller_defined

#undef var_handles_used_Wnotify_EventPoller_defined
#define var_handles_used_Wnotify_EventPoller_defined

#undef THIS
#define THIS ((struct Wnotify_EventPoller_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_WNOTIFY_EVENTPOLLER
#define THIS_WNOTIFY_EVENTPOLLER ((struct Wnotify_EventPoller_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_WNOTIFY_EVENTPOLLER
#define OBJ2_WNOTIFY_EVENTPOLLER(o) ((struct Wnotify_EventPoller_struct *)(o->storage+Wnotify_EventPoller_storage_offset))

#undef GET_WNOTIFY_EVENTPOLLER_STORAGE
#define GET_WNOTIFY_EVENTPOLLER_STORAGE(o) ((struct Wnotify_EventPoller_struct *)(o->storage+Wnotify_EventPoller_storage_offset)
static ptrdiff_t Wnotify_EventPoller_storage_offset;
struct Wnotify_EventPoller_struct {

#ifdef var_phandles_Wnotify_EventPoller_defined
  struct array * phandles;

#endif /* var_phandles_Wnotify_EventPoller_defined */

#ifdef var_handles_Wnotify_EventPoller_defined
#line 139 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
HANDLE * handles;
#endif /* var_handles_Wnotify_EventPoller_defined */

#ifdef var_handles_size_Wnotify_EventPoller_defined
#line 140 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
int handles_size;
#endif /* var_handles_size_Wnotify_EventPoller_defined */

#ifdef var_handles_used_Wnotify_EventPoller_defined
#line 141 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
int handles_used;
#endif /* var_handles_used_Wnotify_EventPoller_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Wnotify_EventPoller_struct *Wnotify_EventPoller_gdb_dummy_ptr;
#endif
/*! @decl void add_handle(NotificationHandle handle) 
   */
  #define f_Wnotify_EventPoller_add_handle_defined

#ifdef f_Wnotify_EventPoller_add_handle_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Wnotify_EventPoller_add_handle_fun_num = 0;

#endif /* f_Wnotify_EventPoller_add_handle_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Wnotify_EventPoller_add_handle(INT32 args) {
#line 145 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
struct object * handle;
#line 145 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(args != 1) wrong_number_of_args_error("add_handle",args,1);
#line 145 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("add_handle",1,"object");
#line 145 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
debug_malloc_pass(handle=Pike_sp[0-1].u.object);
{
    void * h;
    int s,  n;
    struct array * ph;
    HANDLE nh;
    HANDLE * handles;
    h = get_storage(handle, Wnotify_NotificationHandle_program);
    if(!h)
    {
      pop_stack();
      Pike_error("add_handle: invalid object type.\n");
    }

    ph = append_array(THIS->phandles, &Pike_sp[-args]);
    THIS->phandles = ph;
    nh = OBJ2_WNOTIFY_NOTIFICATIONHANDLE(handle)->handle;

    if(THIS->handles_size <= THIS->handles_used)
    {
       s = n = THIS->handles_size || 1;
       s*=2;
       handles = realloc(THIS->handles, sizeof(HANDLE) * s);
       if(!handles) 
       {
         pop_stack();
         Pike_error("add_handle: failed to allocate memory.\n");
       }

       THIS->handles = handles;
    }

    THIS->handles[THIS->handles_used++] = nh;

    pop_stack();
  }

  }
/*! @decl NotificationHandle|int poll(void|float timeout)
   */
  #define f_Wnotify_EventPoller_poll_defined

#ifdef f_Wnotify_EventPoller_poll_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Wnotify_EventPoller_poll_fun_num = 0;

#endif /* f_Wnotify_EventPoller_poll_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Wnotify_EventPoller_poll(INT32 args) {
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
struct svalue * timeout;
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(args > 1) wrong_number_of_args_error("poll",args,1);
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if (args > 0 &&
    (TYPEOF(Pike_sp[0-args]) != PIKE_T_INT ||
     Pike_sp[0-args].u.integer)) {
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_FLOAT) SIMPLE_ARG_TYPE_ERROR("poll",1,"void|float");
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
timeout=Pike_sp+0-args; dmalloc_touch_svalue(Pike_sp+0-args);
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
} else timeout = NULL;
{
    DWORD res;
    DWORD to;

    if(THIS->handles_used < 1)
    {
      pop_stack();
      Pike_error("poll: no paths to monitor.\n");
    }     

    if(!timeout || SAFE_IS_ZERO(timeout))
    {
       to = INFINITE;
    }
    else if(TYPEOF(*timeout) == PIKE_T_FLOAT)
    {
      to = (DWORD)timeout->u.float_number * 1000;
    }
    else
    {
      Pike_error("poll: invalid timeout.\n");
    }

    pop_n_elems(args);

    res = WaitForMultipleObjects(THIS->handles_used, THIS->handles, FALSE, to);

    if(res >= WAIT_OBJECT_0 && res <= (WAIT_OBJECT_0 + THIS->handles_used - 1))
    {
      /* we have a hit. */
      struct svalue * sv;
      sv = THIS->phandles->item+res;
      /* TODO: proper value checking of the items in the array! */
      OBJ2_WNOTIFY_NOTIFICATIONHANDLE(sv->u.object)->triggered = 1;
      push_svalue(&ITEM(THIS->phandles)[res]);
      FindNextChangeNotification(THIS->handles+res);

    }
    else if(res >= WAIT_ABANDONED_0 && res <= (WAIT_ABANDONED_0 + THIS->handles_used - 1))
    {
      /* don't think this applies to us, so let's flag an exception. */
      Pike_error("poll: unexpected result (WAIT_ABANDONED)\n");
    }
    else if(res == WAIT_TIMEOUT)
    {
      push_int(0);
    }
  }

  }

#undef internal_init_Wnotify_EventPoller_defined
#define internal_init_Wnotify_EventPoller_defined

#undef Wnotify_EventPoller_event_handler_defined
#define Wnotify_EventPoller_event_handler_defined
static void init_Wnotify_EventPoller_struct(void)
#line 235 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
{
    struct array * a;
    a = allocate_array(0);
   THIS->phandles = a;
  }

  
#undef Wnotify_EventPoller_gc_live_obj
#define Wnotify_EventPoller_gc_live_obj

#undef internal_exit_Wnotify_EventPoller_defined
#define internal_exit_Wnotify_EventPoller_defined

#undef Wnotify_EventPoller_event_handler_defined
#define Wnotify_EventPoller_event_handler_defined
static void exit_Wnotify_EventPoller_struct(void)
#line 242 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
{
    if(THIS->handles)
      free(THIS->handles);
    if(THIS->phandles)
      free_array(THIS->phandles);
  }

#ifdef Wnotify_EventPoller_event_handler_defined
static void Wnotify_EventPoller_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Wnotify_EventPoller_defined
  case PROG_EVENT_INIT: init_Wnotify_EventPoller_struct(); break;

#endif /* internal_init_Wnotify_EventPoller_defined */

#ifdef internal_exit_Wnotify_EventPoller_defined
  case PROG_EVENT_EXIT: exit_Wnotify_EventPoller_struct(); break;

#endif /* internal_exit_Wnotify_EventPoller_defined */
  default: break; 
  }
}

#endif /* Wnotify_EventPoller_event_handler_defined */
/*! @endclass */

#line 252 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#endif /* HAVE_FINDFIRSTCHANGENOTIFICATION */

PIKE_MODULE_INIT
{
  
#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( ___cmod_map_program_ids );

#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */

#ifdef class_Wnotify_NotificationHandle_defined

#ifdef PROG_WNOTIFY_NOTIFICATIONHANDLE_ID
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  START_NEW_PROGRAM_ID(WNOTIFY_NOTIFICATIONHANDLE);
#else
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  start_new_program();

#endif /* PROG_WNOTIFY_NOTIFICATIONHANDLE_ID */
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  Wnotify_NotificationHandle_program = Pike_compiler->new_program;

#ifndef tObjImpl_WNOTIFY_NOTIFICATIONHANDLE

#undef tObjIs_WNOTIFY_NOTIFICATIONHANDLE
#define tObjIs_WNOTIFY_NOTIFICATIONHANDLE "\3\1\177\0\0\2"

#undef tObjImpl_WNOTIFY_NOTIFICATIONHANDLE
#define tObjImpl_WNOTIFY_NOTIFICATIONHANDLE "\3\0\177\0\0\2"

#endif /* tObjImpl_WNOTIFY_NOTIFICATIONHANDLE */

#ifdef THIS_WNOTIFY_NOTIFICATIONHANDLE
  Wnotify_NotificationHandle_storage_offset = ADD_STORAGE(struct Wnotify_NotificationHandle_struct);
#endif /* THIS_WNOTIFY_NOTIFICATIONHANDLE */

#ifdef var_path_Wnotify_NotificationHandle_defined
  PIKE_MAP_VARIABLE("path", Wnotify_NotificationHandle_storage_offset + OFFSETOF(Wnotify_NotificationHandle_struct, path),
                    tStr, PIKE_T_STRING, 0);
#endif /* var_path_Wnotify_NotificationHandle_defined */

#ifdef var_watch_subtree_Wnotify_NotificationHandle_defined
  PIKE_MAP_VARIABLE("watch_subtree", Wnotify_NotificationHandle_storage_offset + OFFSETOF(Wnotify_NotificationHandle_struct, watch_subtree),
                    "\10\200\0\0\0\177\377\377\377", PIKE_T_INT, 0);
#endif /* var_watch_subtree_Wnotify_NotificationHandle_defined */

#ifdef var_filter_Wnotify_NotificationHandle_defined
  PIKE_MAP_VARIABLE("filter", Wnotify_NotificationHandle_storage_offset + OFFSETOF(Wnotify_NotificationHandle_struct, filter),
                    "\10\200\0\0\0\177\377\377\377", PIKE_T_INT, 0);
#endif /* var_filter_Wnotify_NotificationHandle_defined */

#ifdef var_triggered_Wnotify_NotificationHandle_defined
  PIKE_MAP_VARIABLE("triggered", Wnotify_NotificationHandle_storage_offset + OFFSETOF(Wnotify_NotificationHandle_struct, triggered),
                    "\10\200\0\0\0\177\377\377\377", PIKE_T_INT, 0);
#endif /* var_triggered_Wnotify_NotificationHandle_defined */

#ifdef Wnotify_NotificationHandle_event_handler_defined
  pike_set_prog_event_callback(Wnotify_NotificationHandle_event_handler);

#ifndef Wnotify_NotificationHandle_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Wnotify_NotificationHandle_gc_live_obj */

#endif /* Wnotify_NotificationHandle_event_handler_defined */

#ifdef f_Wnotify_NotificationHandle_create_defined

#ifdef f_Wnotify_NotificationHandle_create_fun_num_used
  f_Wnotify_NotificationHandle_create_fun_num =
#endif /* f_Wnotify_NotificationHandle_create_fun_num_used */
#line 59 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    ADD_FUNCTION2("create", f_Wnotify_NotificationHandle_create, tFunc(tStr "\10\200\0\0\0\177\377\377\377" "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Wnotify_NotificationHandle_create_defined */

#ifdef f_Wnotify_NotificationHandle_get_error_defined

#ifdef f_Wnotify_NotificationHandle_get_error_fun_num_used
  f_Wnotify_NotificationHandle_get_error_fun_num =
#endif /* f_Wnotify_NotificationHandle_get_error_fun_num_used */
#line 96 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    ADD_FUNCTION2("get_error", f_Wnotify_NotificationHandle_get_error, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Wnotify_NotificationHandle_get_error_defined */

#ifdef f_Wnotify_NotificationHandle_read_change_defined

#ifdef f_Wnotify_NotificationHandle_read_change_fun_num_used
  f_Wnotify_NotificationHandle_read_change_fun_num =
#endif /* f_Wnotify_NotificationHandle_read_change_fun_num_used */
    ADD_FUNCTION2("read_change", f_Wnotify_NotificationHandle_read_change, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Wnotify_NotificationHandle_read_change_defined */
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  Wnotify_NotificationHandle_program=end_program();
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#ifdef Wnotify_NotificationHandle_program_fun_num_used
Wnotify_NotificationHandle_program_fun_num=
#endif
 add_program_constant("NotificationHandle",Wnotify_NotificationHandle_program,0);

#endif /* class_Wnotify_NotificationHandle_defined */

#ifdef class_Wnotify_EventPoller_defined

#ifdef PROG_WNOTIFY_EVENTPOLLER_ID
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  START_NEW_PROGRAM_ID(WNOTIFY_EVENTPOLLER);
#else
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  start_new_program();

#endif /* PROG_WNOTIFY_EVENTPOLLER_ID */
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  Wnotify_EventPoller_program = Pike_compiler->new_program;

#ifndef tObjImpl_WNOTIFY_EVENTPOLLER

#undef tObjIs_WNOTIFY_EVENTPOLLER
#define tObjIs_WNOTIFY_EVENTPOLLER "\3\1\177\0\0\3"

#undef tObjImpl_WNOTIFY_EVENTPOLLER
#define tObjImpl_WNOTIFY_EVENTPOLLER "\3\0\177\0\0\3"

#endif /* tObjImpl_WNOTIFY_EVENTPOLLER */

#ifdef THIS_WNOTIFY_EVENTPOLLER
  Wnotify_EventPoller_storage_offset = ADD_STORAGE(struct Wnotify_EventPoller_struct);
#endif /* THIS_WNOTIFY_EVENTPOLLER */

#ifdef var_phandles_Wnotify_EventPoller_defined
  PIKE_MAP_VARIABLE("phandles", Wnotify_EventPoller_storage_offset + OFFSETOF(Wnotify_EventPoller_struct, phandles),
                    tArray, PIKE_T_ARRAY, ID_PRIVATE);
#endif /* var_phandles_Wnotify_EventPoller_defined */

#ifdef Wnotify_EventPoller_event_handler_defined
  pike_set_prog_event_callback(Wnotify_EventPoller_event_handler);

#ifndef Wnotify_EventPoller_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Wnotify_EventPoller_gc_live_obj */

#endif /* Wnotify_EventPoller_event_handler_defined */

#ifdef f_Wnotify_EventPoller_add_handle_defined

#ifdef f_Wnotify_EventPoller_add_handle_fun_num_used
  f_Wnotify_EventPoller_add_handle_fun_num =
#endif /* f_Wnotify_EventPoller_add_handle_fun_num_used */
#line 145 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    ADD_FUNCTION2("add_handle", f_Wnotify_EventPoller_add_handle, tFunc(tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Wnotify_EventPoller_add_handle_defined */

#ifdef f_Wnotify_EventPoller_poll_defined

#ifdef f_Wnotify_EventPoller_poll_fun_num_used
  f_Wnotify_EventPoller_poll_fun_num =
#endif /* f_Wnotify_EventPoller_poll_fun_num_used */
#line 184 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    ADD_FUNCTION2("poll", f_Wnotify_EventPoller_poll, tFunc(tOr(tVoid,tFloat),"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Wnotify_EventPoller_poll_defined */
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
  Wnotify_EventPoller_program=end_program();
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
#ifdef Wnotify_EventPoller_program_fun_num_used
Wnotify_EventPoller_program_fun_num=
#endif
 add_program_constant("EventPoller",Wnotify_EventPoller_program,0);

#endif /* class_Wnotify_EventPoller_defined */

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( 0 );
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
#line 256 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
;
/*! @decl constant FILE_NOTIFY_CHANGE_FILE_NAME
 */

/*! @decl constant FILE_NOTIFY_CHANGE_DIR_NAME
 */

/*! @decl constant FILE_NOTIFY_CHANGE_ATTRIBUTES
 */

/*! @decl constant FILE_NOTIFY_CHANGE_SIZE
 */

/*! @decl constant FILE_NOTIFY_CHANGE_LAST_WRITE
 */

/*! @decl constant FILE_NOTIFY_CHANGE_SECURITY
 */

#ifdef HAVE_FINDFIRSTCHANGENOTIFICATION
 ADD_ICONST(FILE_NOTIFY_CHANGE_FILE_NAME);
 ADD_ICONST(FILE_NOTIFY_CHANGE_DIR_NAME);
 ADD_ICONST(FILE_NOTIFY_CHANGE_ATTRIBUTES);
 ADD_ICONST(FILE_NOTIFY_CHANGE_SIZE);
 ADD_ICONST(FILE_NOTIFY_CHANGE_LAST_WRITE);
 ADD_ICONST(FILE_NOTIFY_CHANGE_SECURITY);
#endif /* HAVE_FINDFIRSTCHANGENOTIFICATION */

}

PIKE_MODULE_EXIT
{
  
#ifdef class_Wnotify_NotificationHandle_defined
  if(Wnotify_NotificationHandle_program) {
#line 49 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    free_program(Wnotify_NotificationHandle_program);
    Wnotify_NotificationHandle_program=0;
  }

#endif /* class_Wnotify_NotificationHandle_defined */

#ifdef class_Wnotify_EventPoller_defined
  if(Wnotify_EventPoller_program) {
#line 133 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
    free_program(Wnotify_EventPoller_program);
    Wnotify_EventPoller_program=0;
  }

#endif /* class_Wnotify_EventPoller_defined */
#line 288 "/Users/hww3/devel/pike/src/modules/Wnotify/wnotify.cmod"
;
}

/*! @endmodule
 */

/*! @endmodule
 */


#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
static int ___cmod_map_program_ids(int id)
{
  int i = 0;
  if( (id&0x7f000000) != 0x7f000000 ) return id;
  id = id&0x00ffffff;
#ifdef class_Wnotify_NotificationHandle_defined
if(id==2) return Wnotify_NotificationHandle_program->id;
#endif
#ifdef class_Wnotify_EventPoller_defined
if(id==3) return Wnotify_EventPoller_program->id;
#endif
  return 0;
}
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
