/*
 * Monitor a collection.
 *
 * Raises a Fam::Error exception if the collection could not be
 * monitored.  Note that this method exists under Gamin, but does not
 * actually do anything.
 *
 * Aliases:
 *   Fam::Collection#monitor_col
 *   Fam::Collection#col
 *
 * Examples:
 *   req = fam.monitor_col 'download/images', 1, '*.jpg'
 *
 */
static VALUE fam_conn_col(VALUE self, VALUE col, VALUE depth, VALUE mask)
{
  FAMConnection *conn;
  FAMRequest *req = NULL;
  int err;

  Data_Get_Struct(self, FAMConnection, conn);
  req = ALLOC(FAMRequest);
  FAMREQUEST_GETREQNUM(req) = (int) req;
  err = FAMMonitorCollection(conn,
                             RSTRING(col)->ptr,
                             req,
                             NULL,
                             NUM2INT(depth),
                             RSTRING(mask)->ptr);

  if (err == -1) {
    xfree(req);
    rb_raise(eError, "Couldn't monitor collection [\"%s\", %d, \"%s\"]: %s",
             RSTRING(col)->ptr ? RSTRING(col)->ptr : "NULL",
             NUM2INT(depth),
             RSTRING(mask)->ptr ? RSTRING(mask)->ptr : "NULL",
             fam_error());
  }

  return wrap_req(req);
}