1# Include pid_t but Windows doesn't have it 2# Don't use "IF" so that the generated C is portable and can be included 3# in the sdist. 4cdef extern from * nogil: 5 """ 6#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) 7 typedef signed pid_t; 8#else 9 #include <fcntl.h> 10#endif 11 """ 12 ctypedef signed pid_t 13 14from psycopg_c.pq cimport libpq 15 16ctypedef char *(*conn_bytes_f) (const libpq.PGconn *) 17ctypedef int(*conn_int_f) (const libpq.PGconn *) 18 19 20cdef class PGconn: 21 cdef libpq.PGconn* _pgconn_ptr 22 cdef object __weakref__ 23 cdef public object notice_handler 24 cdef public object notify_handler 25 cdef pid_t _procpid 26 27 @staticmethod 28 cdef PGconn _from_ptr(libpq.PGconn *ptr) 29 30 cpdef object notifies(self) 31 32 33cdef class PGresult: 34 cdef libpq.PGresult* _pgresult_ptr 35 36 @staticmethod 37 cdef PGresult _from_ptr(libpq.PGresult *ptr) 38 39 40cdef class PGcancel: 41 cdef libpq.PGcancel* pgcancel_ptr 42 43 @staticmethod 44 cdef PGcancel _from_ptr(libpq.PGcancel *ptr) 45 46 47cdef class Escaping: 48 cdef PGconn conn 49 50 cpdef escape_literal(self, data) 51 cpdef escape_identifier(self, data) 52 cpdef escape_string(self, data) 53 cpdef escape_bytea(self, data) 54 cpdef unescape_bytea(self, const unsigned char *data) 55 56 57cdef class PQBuffer: 58 cdef unsigned char *buf 59 cdef Py_ssize_t len 60 61 @staticmethod 62 cdef PQBuffer _from_buffer(unsigned char *buf, Py_ssize_t length) 63 64 65cdef class ViewBuffer: 66 cdef unsigned char *buf 67 cdef Py_ssize_t len 68 cdef object obj 69 70 @staticmethod 71 cdef ViewBuffer _from_buffer( 72 object obj, unsigned char *buf, Py_ssize_t length) 73 74 75cdef int _buffer_as_string_and_size( 76 data: "Buffer", char **ptr, Py_ssize_t *length 77) except -1 78