codekingpro/portable-devtools
114k
1# Include pid_t but Windows doesn't have it2# Don't use "IF" so that the generated C is portable and can be included3# in the sdist.4cdef extern from * nogil:5 """6#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)7 typedef signed pid_t;8#else9 #include <fcntl.h>10#endif11 """12 ctypedef signed pid_t13 14from psycopg_c.pq cimport libpq15 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_ptr22 cdef object __weakref__23 cdef public object notice_handler24 cdef public object notify_handler25 cdef pid_t _procpid26 27 @staticmethod28 cdef PGconn _from_ptr(libpq.PGconn *ptr)29 30 cpdef int flush(self) except -131 cpdef object notifies(self)32 33 34cdef class PGresult:35 cdef libpq.PGresult* _pgresult_ptr36 37 @staticmethod38 cdef PGresult _from_ptr(libpq.PGresult *ptr)39 40 41cdef class PGcancel:42 cdef libpq.PGcancel* pgcancel_ptr43 44 @staticmethod45 cdef PGcancel _from_ptr(libpq.PGcancel *ptr)46 47 48cdef class Escaping:49 cdef PGconn conn50 51 cpdef escape_literal(self, data)52 cpdef escape_identifier(self, data)53 cpdef escape_string(self, data)54 cpdef escape_bytea(self, data)55 cpdef unescape_bytea(self, const unsigned char *data)56 57 58cdef class PQBuffer:59 cdef unsigned char *buf60 cdef Py_ssize_t len61 62 @staticmethod63 cdef PQBuffer _from_buffer(unsigned char *buf, Py_ssize_t length)64 65 66cdef class ViewBuffer:67 cdef unsigned char *buf68 cdef Py_ssize_t len69 cdef object obj70 71 @staticmethod72 cdef ViewBuffer _from_buffer(73 object obj, unsigned char *buf, Py_ssize_t length)74 75 76cdef int _buffer_as_string_and_size(77 data: "Buffer", char **ptr, Py_ssize_t *length78) except -179 