qmsk/net/libc.pxd
author Tero Marttila <terom@fixme.fi>
Sun, 16 Aug 2009 19:01:21 +0300
changeset 7 74fde84264b1
child 10 94b0d5a208c1
permissions -rw-r--r--
broke Cython with this package magic
7
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    Libc stuff
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
cdef extern from "stdint.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
    # yes, these are "wrong"
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
    ctypedef unsigned char uint8_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
    ctypedef unsigned short uint16_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
    ctypedef unsigned int uint32_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
    ctypedef signed char int8_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    ctypedef signed short int16_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
    ctypedef signed int int32_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
cdef extern from "sys/types.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    # potentially wrong...
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
    ctypedef signed long ssize_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
# <linux/types.h>
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
cdef extern from "linux/types.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
    ctypedef uint8_t __u8
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
    ctypedef uint16_t __u16
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
    ctypedef uint32_t __u32
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
    ctypedef int8_t __s8
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
    ctypedef int16_t __s16
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
    ctypedef int32_t __s32
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
cdef extern from "errno.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
    int errno
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
cdef extern from "string.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
    void* memcpy (void *dest, void *src, size_t n)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
    void* memset (void *s, int c, size_t n)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
    char* strerror (int errno)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
cdef extern from "alloca.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
    void* alloca (size_t size)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
cdef extern from "sys/uio.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
    struct iovec :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
        void *iov_base
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
        size_t iov_len
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
cdef extern from "arpa/inet.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
    # XXX: correct?!
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
    ctypedef uint32_t socklen_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
    char* c_inet_ntop "inet_ntop" (int af, void *sockaddr, char *buf, socklen_t len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
    int c_inet_pton "inet_pton" (int af, char *src, void *dst)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
# <sys/socket.h>
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
cdef extern from "sys/socket.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
    # socket types
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
        SOCK_STREAM
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
        SOCK_DGRAM
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
        SOCK_RAW
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
        SOCK_RDM
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
        SOCK_SEQPACKET
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    62
        SOCK_PACKET
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
    # packet/address families
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
        PF_UNSPEC
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
        PF_LOCAL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
        PF_UNIX     # same as PF_LOCAL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
        PF_FILE     # same as PF_LOCAL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
        PF_INET
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
        PF_INET6
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
        PF_NETLINK
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
        PF_ROUTE    # same as PF_NETLINK
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    74
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
    # aliases for PF_*
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    77
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    78
        AF_UNSPEC
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
        AF_LOCAL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
        AF_UNIX
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
        AF_FILE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
        AF_INET
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
        AF_INET6
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
        AF_NETLINK
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
        AF_ROUTE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
    # base sockaddr stuff
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
    ctypedef uint16_t sa_family_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
    struct sockaddr :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
        sa_family_t     sa_family
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
    struct sockaddr_storage :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
        sa_family_t     ss_family
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
    # flag values
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
        MSG_OOB
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
        MSG_PEEK
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
        MSG_DONTROUTE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
        MSG_CTRUNC
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
        MSG_PROXY
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
        MSG_TRUNC
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
        MSG_DONTWAIT
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
        MSG_EOR
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
        MSG_WAITALL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
        MSG_FIN
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
        MSG_SYN
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
        MSG_CONFIRM
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
        MSG_RST
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
        MSG_ERRQUEUE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
        MSG_NOSIGNAL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
        MSG_MORE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
        MSG_CMSG_CLOEXEC
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
    ## send/recv-msg
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
    struct msghdr :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   118
        void *msg_name              # sockaddr
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
        socklen_t msg_namelen
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
        iovec *msg_iov              # message data
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
        size_t msg_iovlen
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
        void *msg_control           # aux data
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
        size_t msg_controllen
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   127
        int msg_flags               # flags
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
    struct cmsghdr :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
        size_t cmsg_len             # length including this cmsghdr struct
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
        int cmsg_level              # originating protocol (IPPROTO_* ???)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
        int cmsg_type               # protocol-specific type
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
    ## socket-level cmsghdr types
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   136
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
        SCM_RIGHTS
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
        SCM_CREDENTIALS
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   139
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
    #- ucred
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
    # SO_LINGER parameters
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
    struct linger :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
        int l_onoff
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
        int l_linger
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
    ## API
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
    int socket (int domain, int socktype, int protocol)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
    int bind (int fd, sockaddr *addr, socklen_t len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
    int connect (int fd, sockaddr *addr, socklen_t len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
    int listen (int fd, int n)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
    int accept (int fd, sockaddr *addr, socklen_t *len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
    int shutdown (int fd, int how)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
    int getsockname (int fd, sockaddr *addr, socklen_t *len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
    int getpeername (int fd, sockaddr *addr, socklen_t *len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
    ssize_t send (int fd, void *buf, size_t n, int flags)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
    ssize_t recv (int fd, void *buf, size_t n, int flags)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
    ssize_t sendto (int fd, void *buf, size_t n, int flags, sockaddr *addr, socklen_t addr_len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
    ssize_t recvfrom (int fd, void *buf, size_t n, int flags, sockaddr *addr, socklen_t addr_len)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   163
    ssize_t sendmsg (int fd, msghdr *msg, int flags)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   164
    ssize_t recvmsg (int fd, msghdr *msg, int flags)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   165
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   166
    int getsockopt (int fd, int level, int optname, void *optval, socklen_t optlen)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   167
    int setsockopt (int fd, int level, int optname, void *optval, socklen_t optlen)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   168
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   169
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   170
        SHUT_RD
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   171
        SHUT_WR
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   172
        SHUT_RDWR
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   173
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   174
cdef extern from "netinet/in.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   175
    ## socket protocol types
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   176
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   177
        IPPROTO_IP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   178
        IPPROTO_ICMP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   179
        IPPROTO_IGMP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   180
        IPPROTO_TCP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   181
        IPPROTO_UDP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   182
        IPPROTO_IPV6
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   183
        IPPROTO_ICMPV6
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   184
        IPPROTO_SCTP
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   185
        IPPROTO_RAW
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   186
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   187
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   188
    ## ports
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   189
    ctypedef uint16_t in_port_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   190
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   191
    ## AF_INET
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   192
    ctypedef uint32_t in_addr_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   193
    struct in_addr :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   194
        in_addr_t s_addr
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   195
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   196
    # XXX: should these be in another cdef?
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   197
    in_addr_t INADDR_ANY
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   198
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   199
    ## AF_INET6
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   200
    struct in6_addr :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   201
        # XXX: check POSIX...
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   202
        uint8_t s6_addr[16]
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   203
        uint16_t s6_addr16[8]
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   204
        uint32_t s6_addr32[4]
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   205
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   206
    # common in6_addr's
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   207
    in6_addr in6addr_any
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   208
    in6_addr in6addr_loopback
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   209
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   210
    ## constants
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   211
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   212
        INET_ADDRSTRLEN
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   213
        INET6_ADDRSTRLEN
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   214
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   215
    ## sockaddrs
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   216
    struct sockaddr_in :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   217
        sa_family_t     sin_family
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   218
        in_port_t       sin_port
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   219
        in_addr         sin_addr
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   220
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   221
    struct sockaddr_in6 :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   222
        sa_family_t     sin6_family
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   223
        in_port_t       sin6_port
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   224
        uint32_t        sin6_flowinfo
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   225
        in6_addr        sin6_addr
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   226
        uint32_t        sin6_scope_id
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   227
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   228
    uint16_t htons(uint16_t)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   229
    uint32_t htonl(uint32_t)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   230
    uint16_t ntohs(uint16_t)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   231
    uint32_t ntohl(uint32_t)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   232
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   233
cdef extern from "netdb.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   234
    ## getaddrinfo
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   235
    struct addrinfo :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   236
        int         ai_flags
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   237
        int         ai_family
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   238
        int         ai_socktype
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   239
        int         ai_protocol
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   240
        int         ai_addrlen
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   241
        sockaddr   *ai_addr
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   242
        char       *ai_canonname
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   243
        addrinfo   *ai_next
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   244
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   245
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   246
        AI_PASSIVE
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   247
        AI_CANONNAME
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   248
        AI_NUMERICHOST
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   249
        AI_V4MAPPED
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   250
        AI_ALL
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   251
        AI_ADDRCONFIG
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   252
        # AI_*IDN*
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   253
        AI_NUMERICSERV
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   254
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   255
    int c_getaddrinfo "getaddrinfo" (
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   256
            char *node, char *service, 
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   257
            addrinfo *hints, addrinfo **res
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   258
    )
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   259
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   260
    void c_freeaddrinfo "freeaddrinfo" (addrinfo *res)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   261
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   262
    ## getnameinfo
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   263
    int c_getnameinfo "getnameinfo" (
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   264
            sockaddr *sa, socklen_t salen, 
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   265
            char *host, size_t hostlen, 
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   266
            char *serv, size_t servlen, 
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   267
            int flags
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   268
    )
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   269
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   270
    enum :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   271
        NI_NOFQDN
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   272
        NI_NUMERICHOST
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   273
        NI_NAMEREQD
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   274
        NI_NUMERICSERV
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   275
        NI_DGRAM
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   276
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   277
        NI_MAXHOST
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   278
        NI_MAXSERV
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   279
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   280
    char* gai_strerror (int err)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   281
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   282
# python-friendly wrapper around inet_ntop
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   283
cdef object inet_ntop (int af, void *sockaddr)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   284
cdef object inet_pton (int af, char *addr, void *sockaddr_out)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   285
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   286
# sockaddr, flags -> (host, service)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   287
cdef object getnameinfo (sockaddr *sa, socklen_t salen, int flags)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   288
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   289
## general errno-based errors
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   290
#cdef class Errno (py.OSError) :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   291
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   292
#        Some libc function returned an error code:
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   293
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   294
#            func        - the name of the function called
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   295
#            err         - the system error code
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   296
#            strerror    - human-readable error code -> message
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   297
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   298
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   299
#    cdef readonly char *func
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   300
#    cdef readonly int err
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   301
#    cdef readonly object strerror
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   302
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   303
#cdef class GAIError (py.OSError) :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   304
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   305
#        Some libc GAI function returnd an error code:
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   306
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   307
#            func        - the name of the function called
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   308
#            err         - the GAI_* error code
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   309
#            strerror    - human-readable error code -> message
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   310
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   311
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   312
#    cdef readonly char *func
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   313
#    cdef readonly int err
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   314
#    cdef readonly object strerror
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   315
#