Ignore:
Timestamp:
Feb 27, 2008, 4:47:58 PM (14 years ago)
Author:
charles
Message:

make struct ipc_info opaque. const-ify the ipcparse functions where possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ipcparse.h

    r5138 r5142  
    127127struct tr_stat;
    128128
    129 struct ipc_info
    130 {
    131     struct ipc_funcs * funcs;
    132     int                vers;
    133 };
    134129
    135 #define HASVERS( info )         ( 0 < (info)->vers )
    136 #define TORRENT_ID_VALID( id )  ( 0 < (id) && INT_MAX > (id) )
     130#define TORRENT_ID_VALID( id )  ( ( 0 < (id) ) && ( (id) < INT_MAX ) )
    137131
    138 typedef void ( *trd_msgfunc )( enum ipc_msg, struct tr_benc *, int64_t, void * );
     132typedef void ( *trd_msgfunc )( enum ipc_msg      msg_id,
     133                               struct tr_benc  * benc,
     134                               int64_t           tag,
     135                               void            * arg );
    139136
    140137/* any of these functions that can fail may set errno for any of the
     
    143140/* setup */
    144141struct ipc_funcs * ipc_initmsgs ( void );
    145 void               ipc_addmsg   ( struct ipc_funcs *, enum ipc_msg, trd_msgfunc );
     142void               ipc_addmsg   ( struct ipc_funcs *, enum ipc_msg,
     143                                  trd_msgfunc );
    146144void               ipc_setdefmsg( struct ipc_funcs *, trd_msgfunc );
    147145void               ipc_freemsgs ( struct ipc_funcs * );
    148146struct ipc_info *  ipc_newcon   ( struct ipc_funcs * );
    149147void               ipc_freecon  ( struct ipc_info * );
     148int                ipc_hasvers  ( const struct ipc_info * );
    150149
    151150/* message creation */
    152151/* sets errno to EPERM if requested message not supported by protocol vers */
    153 struct tr_benc * ipc_initval  ( struct ipc_info *, enum ipc_msg, int64_t,
    154                             struct tr_benc *, int );
     152struct tr_benc * ipc_initval  ( const struct ipc_info *, enum ipc_msg,
     153                                int64_t tag, struct tr_benc *, int );
    155154uint8_t *    ipc_mkval    ( const struct tr_benc *, size_t * );
    156 uint8_t *    ipc_mkempty  ( struct ipc_info *, size_t *, enum ipc_msg,
     155uint8_t *    ipc_mkempty  ( const struct ipc_info *, size_t *, enum ipc_msg,
    157156                            int64_t );
    158 uint8_t *    ipc_mkint    ( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
    159                             int64_t );
    160 uint8_t *    ipc_mkstr    ( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
    161                             const char * );
     157uint8_t *    ipc_mkint    ( const struct ipc_info *, size_t *, enum ipc_msg,
     158                            int64_t tag, int64_t val );
     159uint8_t *    ipc_mkstr    ( const struct ipc_info *, size_t *, enum ipc_msg,
     160                            int64_t tag, const char * val );
    162161uint8_t *    ipc_mkvers   ( size_t *, const char * );
    163 uint8_t *    ipc_mkgetinfo( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
    164                             int, const int * );
    165 int          ipc_addinfo  ( struct tr_benc *, int, const struct tr_info *, int );
    166 int          ipc_addstat  ( struct tr_benc *, int, const struct tr_stat *, int );
     162uint8_t *    ipc_mkgetinfo( const struct ipc_info *, size_t *, enum ipc_msg,
     163                            int64_t, int, const int * );
     164int          ipc_addinfo  ( struct tr_benc *, int,
     165                            const struct tr_info *, int );
     166int          ipc_addstat  ( struct tr_benc *, int,
     167                            const struct tr_stat *, int );
    167168
    168169/* sets errno to EINVAL on parse error or
    169170   EPERM for unsupported protocol version */
    170 ssize_t      ipc_parse    ( struct ipc_info *, const uint8_t *, ssize_t, void * );
     171ssize_t      ipc_parse    ( struct ipc_info *, const uint8_t *,
     172                            ssize_t, void * );
    171173
    172174/* misc info functions, these will always succeed */
    173 enum ipc_msg ipc_msgid    ( struct ipc_info *, const char * );
    174 int          ipc_ishandled( struct ipc_info *, enum ipc_msg );
    175 int          ipc_havetags ( struct ipc_info * );
     175enum ipc_msg ipc_msgid    ( const struct ipc_info *, const char * );
     176int          ipc_ishandled( const struct ipc_info *, enum ipc_msg );
     177int          ipc_havetags ( const struct ipc_info * );
    176178int          ipc_infotypes( enum ipc_msg, const struct tr_benc * );
    177179const char * ipc_infoname ( enum ipc_msg, int );
Note: See TracChangeset for help on using the changeset viewer.