/* * call-seq: * conn.notifies() * * Returns an array of the unprocessed notifiers. * If there is no unprocessed notifier, it returns +nil+. */ static VALUE pgconn_notifies(VALUE self) { PGconn* conn = get_pgconn(self); PGnotify *notify; VALUE hash; VALUE sym_relname, sym_be_pid, sym_extra; VALUE relname, be_pid, extra; sym_relname = ID2SYM(rb_intern("relname")); sym_be_pid = ID2SYM(rb_intern("be_pid")); sym_extra = ID2SYM(rb_intern("extra")); notify = PQnotifies(conn); if (notify == NULL) { return Qnil; } hash = rb_hash_new(); relname = rb_tainted_str_new2(notify->relname); be_pid = INT2NUM(notify->be_pid); extra = rb_tainted_str_new2(PGNOTIFY_EXTRA(notify)); rb_hash_aset(hash, sym_relname, relname); rb_hash_aset(hash, sym_be_pid, be_pid); rb_hash_aset(hash, sym_extra, extra); PQfreemem(notify); return hash; }