cleanup: remove '2' from function and struct names

This commit is contained in:
Eric House 2013-12-20 18:08:50 -08:00
parent bba0b79763
commit 6d84dfea7e
6 changed files with 56 additions and 71 deletions

View file

@ -1490,8 +1490,8 @@ handle_invite_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
const CurGameInfo* gi = globals->cGlobals.gi; const CurGameInfo* gi = globals->cGlobals.gi;
gchar gameName[64]; gchar gameName[64];
snprintf( gameName, VSIZE(gameName), "Game %ld", gi->gameID ); snprintf( gameName, VSIZE(gameName), "Game %ld", gi->gameID );
linux_sms2_invite( globals->cGlobals.params, gi, gameName, 1, linux_sms_invite( globals->cGlobals.params, gi, gameName, 1,
phone, port ); phone, port );
} }
g_free( phone ); g_free( phone );
g_free( portstr ); g_free( portstr );

View file

@ -702,7 +702,7 @@ gtkmain( LaunchParams* params )
.inviteReceived = smsInviteReceived, .inviteReceived = smsInviteReceived,
.msgReceived = smsMsgReceived, .msgReceived = smsMsgReceived,
}; };
linux_sms2_init( params, phone, port, &smsProcs, &apg ); linux_sms_init( params, phone, port, &smsProcs, &apg );
} else { } else {
XP_LOGF( "not activating SMS: I don't have a phone" ); XP_LOGF( "not activating SMS: I don't have a phone" );
} }
@ -715,7 +715,7 @@ gtkmain( LaunchParams* params )
closeGamesDB( params->pDb ); closeGamesDB( params->pDb );
relaycon_cleanup( params ); relaycon_cleanup( params );
#ifdef XWFEATURE_SMS #ifdef XWFEATURE_SMS
linux_sms2_cleanup( params ); linux_sms_cleanup( params );
#endif #endif
return 0; return 0;
} /* gtkmain */ } /* gtkmain */

View file

@ -1179,9 +1179,9 @@ linux_send( const XP_U8* buf, XP_U16 buflen, const CommsAddrRec* addrRec,
comms_getAddr( cGlobals->game.comms, &addr ); comms_getAddr( cGlobals->game.comms, &addr );
addrRec = &addr; addrRec = &addr;
} }
nSent = linux_sms2_send( cGlobals->params, buf, buflen, nSent = linux_sms_send( cGlobals->params, buf, buflen,
addrRec->u.sms.phone, addrRec->u.sms.port, addrRec->u.sms.phone, addrRec->u.sms.port,
gameID ); gameID );
#endif #endif
} else { } else {
XP_ASSERT(0); XP_ASSERT(0);

View file

@ -60,7 +60,7 @@ makeQueuePath( const XP_UCHAR* phone, XP_U16 port,
snprintf( path, pathlen, "%s/%s_%d", SMS_DIR, phone, port ); snprintf( path, pathlen, "%s/%s_%d", SMS_DIR, phone, port );
} }
typedef struct _LinSMS2Data { typedef struct _LinSMSData {
int fd, wd; int fd, wd;
XP_UCHAR myQueue[256]; XP_UCHAR myQueue[256];
XP_U16 port; XP_U16 port;
@ -70,18 +70,18 @@ typedef struct _LinSMS2Data {
const gchar* myPhone; const gchar* myPhone;
const SMSProcs* procs; const SMSProcs* procs;
void* procClosure; void* procClosure;
} LinSMS2Data; } LinSMSData;
typedef enum { NONE, INVITE, DATA, DEATH, ACK, } SMS_CMD; typedef enum { NONE, INVITE, DATA, DEATH, ACK, } SMS_CMD;
#define SMS_PROTO_VERSION 0 #define SMS_PROTO_VERSION 0
static LinSMS2Data* getStorage( LaunchParams* params ); static LinSMSData* getStorage( LaunchParams* params );
static void writeHeader( XWStreamCtxt* stream, SMS_CMD cmd ); static void writeHeader( XWStreamCtxt* stream, SMS_CMD cmd );
static void static void
lock_queue2( LinSMS2Data* storage ) lock_queue( LinSMSData* storage )
{ {
char lock[256]; char lock[256];
snprintf( lock, sizeof(lock), "%s/%s", storage->myQueue, LOCK_FILE ); snprintf( lock, sizeof(lock), "%s/%s", storage->myQueue, LOCK_FILE );
@ -91,7 +91,7 @@ lock_queue2( LinSMS2Data* storage )
} }
static void static void
unlock_queue2( LinSMS2Data* storage ) unlock_queue( LinSMSData* storage )
{ {
XP_ASSERT( NULL != storage->lock ); XP_ASSERT( NULL != storage->lock );
fclose( storage->lock ); fclose( storage->lock );
@ -100,7 +100,7 @@ unlock_queue2( LinSMS2Data* storage )
static XP_S16 static XP_S16
send_sms( LinSMS2Data* storage, XWStreamCtxt* stream, send_sms( LinSMSData* storage, XWStreamCtxt* stream,
const XP_UCHAR* phone, XP_U16 port ) const XP_UCHAR* phone, XP_U16 port )
{ {
const XP_U8* buf = stream_getPtr( stream ); const XP_U8* buf = stream_getPtr( stream );
@ -110,7 +110,7 @@ send_sms( LinSMS2Data* storage, XWStreamCtxt* stream,
XP_ASSERT( !!storage ); XP_ASSERT( !!storage );
char path[256]; char path[256];
lock_queue2( storage ); lock_queue( storage );
#ifdef DEBUG #ifdef DEBUG
gchar* str64 = g_base64_encode( buf, buflen ); gchar* str64 = g_base64_encode( buf, buflen );
@ -146,7 +146,7 @@ send_sms( LinSMS2Data* storage, XWStreamCtxt* stream,
fclose( fp ); fclose( fp );
sync(); sync();
unlock_queue2( storage ); unlock_queue( storage );
nSent = buflen; nSent = buflen;
@ -154,8 +154,8 @@ send_sms( LinSMS2Data* storage, XWStreamCtxt* stream,
} /* linux_sms_send */ } /* linux_sms_send */
static XP_S16 static XP_S16
decodeAndDelete2( LinSMS2Data* storage, const gchar* name, decodeAndDelete( LinSMSData* storage, const gchar* name,
XP_U8* buf, XP_U16 buflen, CommsAddrRec* addr ) XP_U8* buf, XP_U16 buflen, CommsAddrRec* addr )
{ {
LOG_FUNC(); LOG_FUNC();
XP_S16 nRead = -1; XP_S16 nRead = -1;
@ -199,10 +199,10 @@ decodeAndDelete2( LinSMS2Data* storage, const gchar* name,
LOG_RETURNF( "%d", nRead ); LOG_RETURNF( "%d", nRead );
return nRead; return nRead;
} /* decodeAndDelete2 */ } /* decodeAndDelete */
static void static void
dispatch_invite( LinSMS2Data* storage, XP_U16 XP_UNUSED(proto), dispatch_invite( LinSMSData* storage, XP_U16 XP_UNUSED(proto),
XWStreamCtxt* stream, const CommsAddrRec* addr ) XWStreamCtxt* stream, const CommsAddrRec* addr )
{ {
XP_UCHAR gameName[256]; XP_UCHAR gameName[256];
@ -222,7 +222,7 @@ dispatch_invite( LinSMS2Data* storage, XP_U16 XP_UNUSED(proto),
} }
static void static void
dispatch_data( LinSMS2Data* storage, XP_U16 XP_UNUSED(proto), dispatch_data( LinSMSData* storage, XP_U16 XP_UNUSED(proto),
XWStreamCtxt* stream, const CommsAddrRec* addr ) XWStreamCtxt* stream, const CommsAddrRec* addr )
{ {
XP_USE( addr ); XP_USE( addr );
@ -239,7 +239,7 @@ static void
parseAndDispatch( LaunchParams* params, uint8_t* buf, int len, parseAndDispatch( LaunchParams* params, uint8_t* buf, int len,
const CommsAddrRec* addr ) const CommsAddrRec* addr )
{ {
LinSMS2Data* storage = getStorage( params ); LinSMSData* storage = getStorage( params );
XWStreamCtxt* stream = mem_stream_make( MPPARM(params->mpool) XWStreamCtxt* stream = mem_stream_make( MPPARM(params->mpool)
params->vtMgr, params->vtMgr,
NULL, CHANNEL_NONE, NULL ); NULL, CHANNEL_NONE, NULL );
@ -266,16 +266,16 @@ parseAndDispatch( LaunchParams* params, uint8_t* buf, int len,
} }
static void static void
sms2_receive( void* closure, int socket ) sms_receive( void* closure, int socket )
{ {
LOG_FUNC(); LOG_FUNC();
LaunchParams* params = (LaunchParams*)closure; LaunchParams* params = (LaunchParams*)closure;
XP_ASSERT( !!params->sms2Storage ); XP_ASSERT( !!params->smsStorage );
LinSMS2Data* storage = getStorage( params ); LinSMSData* storage = getStorage( params );
XP_ASSERT( socket == storage->fd ); XP_ASSERT( socket == storage->fd );
lock_queue2( storage ); lock_queue( storage );
/* read required or we'll just get the event again. But we don't care /* read required or we'll just get the event again. But we don't care
about the result or the buffer contents. */ about the result or the buffer contents. */
@ -304,27 +304,27 @@ sms2_receive( void* closure, int socket )
CommsAddrRec fromAddr = {0}; CommsAddrRec fromAddr = {0};
if ( !!shortest[0] ) { if ( !!shortest[0] ) {
XP_LOGF( "%s: decoding message %s", __func__, shortest ); XP_LOGF( "%s: decoding message %s", __func__, shortest );
nRead = decodeAndDelete2( storage, shortest, buf, nRead = decodeAndDelete( storage, shortest, buf,
sizeof(buf), &fromAddr ); sizeof(buf), &fromAddr );
} }
unlock_queue2( storage ); unlock_queue( storage );
if ( 0 < nRead ) { if ( 0 < nRead ) {
parseAndDispatch( params, buf, nRead, &fromAddr ); parseAndDispatch( params, buf, nRead, &fromAddr );
lock_queue2( storage ); lock_queue( storage );
} else { } else {
break; break;
} }
} }
} /* sms2_receive */ } /* sms_receive */
void void
linux_sms2_init( LaunchParams* params, const gchar* phone, XP_U16 port, linux_sms_init( LaunchParams* params, const gchar* phone, XP_U16 port,
const SMSProcs* procs, void* procClosure ) const SMSProcs* procs, void* procClosure )
{ {
XP_ASSERT( !!phone ); XP_ASSERT( !!phone );
LinSMS2Data* storage = getStorage( params ); LinSMSData* storage = getStorage( params );
XP_ASSERT( !!storage ); XP_ASSERT( !!storage );
storage->myPhone = phone; storage->myPhone = phone;
storage->procs = procs; storage->procs = procs;
@ -340,13 +340,13 @@ linux_sms2_init( LaunchParams* params, const gchar* phone, XP_U16 port,
storage->fd = fd; storage->fd = fd;
storage->wd = inotify_add_watch( fd, storage->myQueue, IN_MODIFY ); storage->wd = inotify_add_watch( fd, storage->myQueue, IN_MODIFY );
(*procs->socketChanged)( procClosure, fd, -1, sms2_receive, params ); (*procs->socketChanged)( procClosure, fd, -1, sms_receive, params );
} /* linux_sms2_init */ } /* linux_sms_init */
void void
linux_sms2_invite( LaunchParams* params, const CurGameInfo* gi, linux_sms_invite( LaunchParams* params, const CurGameInfo* gi,
const gchar* gameName, XP_U16 nMissing, const gchar* phone, const gchar* gameName, XP_U16 nMissing, const gchar* phone,
int port ) int port )
{ {
LOG_FUNC(); LOG_FUNC();
XWStreamCtxt* stream; XWStreamCtxt* stream;
@ -360,14 +360,14 @@ linux_sms2_invite( LaunchParams* params, const CurGameInfo* gi,
stream_putU8( stream, nMissing ); stream_putU8( stream, nMissing );
stream_putU8( stream, gi->nPlayers ); stream_putU8( stream, gi->nPlayers );
LinSMS2Data* storage = getStorage( params ); LinSMSData* storage = getStorage( params );
send_sms( storage, stream, phone, port ); send_sms( storage, stream, phone, port );
stream_destroy( stream ); stream_destroy( stream );
} }
XP_S16 XP_S16
linux_sms2_send( LaunchParams* params, const XP_U8* buf, linux_sms_send( LaunchParams* params, const XP_U8* buf,
XP_U16 buflen, const XP_UCHAR* phone, XP_U16 port, XP_U16 buflen, const XP_UCHAR* phone, XP_U16 port,
XP_U32 gameID ) XP_U32 gameID )
{ {
@ -378,7 +378,7 @@ linux_sms2_send( LaunchParams* params, const XP_U8* buf,
stream_putU32( stream, gameID ); stream_putU32( stream, gameID );
stream_putBytes( stream, buf, buflen ); stream_putBytes( stream, buf, buflen );
LinSMS2Data* storage = getStorage( params ); LinSMSData* storage = getStorage( params );
if ( 0 >= send_sms( storage, stream, phone, port ) ) { if ( 0 >= send_sms( storage, stream, phone, port ) ) {
buflen = -1; buflen = -1;
} }
@ -388,18 +388,18 @@ linux_sms2_send( LaunchParams* params, const XP_U8* buf,
} }
void void
linux_sms2_cleanup( LaunchParams* params ) linux_sms_cleanup( LaunchParams* params )
{ {
XP_FREEP( params->mpool, &params->sms2Storage ); XP_FREEP( params->mpool, &params->smsStorage );
} }
static LinSMS2Data* static LinSMSData*
getStorage( LaunchParams* params ) getStorage( LaunchParams* params )
{ {
LinSMS2Data* storage = (LinSMS2Data*)params->sms2Storage; LinSMSData* storage = (LinSMSData*)params->smsStorage;
if ( NULL == storage ) { if ( NULL == storage ) {
storage = XP_CALLOC( params->mpool, sizeof(*storage) ); storage = XP_CALLOC( params->mpool, sizeof(*storage) );
params->sms2Storage = storage; params->smsStorage = storage;
} }
return storage; return storage;
} }

View file

@ -24,14 +24,6 @@
#include "main.h" #include "main.h"
/* void linux_sms_init( CommonGlobals* globals, const CommsAddrRec* addr ); */
/* void linux_sms_close( CommonGlobals* globals ); */
/* XP_S16 linux_sms_send( CommonGlobals* globals, const XP_U8* buf, */
/* XP_U16 buflen, const XP_UCHAR* phone, XP_U16 port ); */
/* XP_S16 linux_sms_receive( CommonGlobals* globals, int sock, */
/* XP_U8* buf, XP_U16 buflen, CommsAddrRec* addr ); */
typedef struct _SMSProcs { typedef struct _SMSProcs {
void (*inviteReceived)( void* closure, const XP_UCHAR* gameName, void (*inviteReceived)( void* closure, const XP_UCHAR* gameName,
XP_U32 gameID, XP_U16 dictLang, XP_U32 gameID, XP_U16 dictLang,
@ -49,15 +41,15 @@ typedef struct _SMSProcs {
} SMSProcs; } SMSProcs;
void linux_sms2_init( LaunchParams* params, const gchar* phone, void linux_sms_init( LaunchParams* params, const gchar* phone,
XP_U16 port, const SMSProcs* procs, void* procClosure ); XP_U16 port, const SMSProcs* procs, void* procClosure );
XP_S16 linux_sms2_send( LaunchParams* params, const XP_U8* buf, XP_S16 linux_sms_send( LaunchParams* params, const XP_U8* buf,
XP_U16 buflen, const XP_UCHAR* phone, XP_U16 port, XP_U16 buflen, const XP_UCHAR* phone, XP_U16 port,
XP_U32 gameID ); XP_U32 gameID );
void linux_sms2_invite( LaunchParams* params, const CurGameInfo* info, void linux_sms_invite( LaunchParams* params, const CurGameInfo* info,
const gchar* gameName, XP_U16 nMissing, const gchar* gameName, XP_U16 nMissing,
const gchar* phone, int port ); const gchar* phone, int port );
void linux_sms2_cleanup( LaunchParams* params ); void linux_sms_cleanup( LaunchParams* params );
#endif /* XWFEATURE_SMS */ #endif /* XWFEATURE_SMS */
#endif /* #ifndef _LINUXSMS_H_ */ #endif /* #ifndef _LINUXSMS_H_ */

View file

@ -64,7 +64,7 @@ typedef struct LaunchParams {
#endif #endif
void* relayConStorage; /* opaque outside of relaycon.c */ void* relayConStorage; /* opaque outside of relaycon.c */
#ifdef XWFEATURE_SMS #ifdef XWFEATURE_SMS
void* sms2Storage; void* smsStorage;
#endif #endif
char* pipe; char* pipe;
char* nbs; char* nbs;
@ -163,10 +163,6 @@ typedef XP_Bool (*Acceptor)( int sock, void* ctxt );
typedef void (*AddAcceptorFunc)(int listener, Acceptor func, typedef void (*AddAcceptorFunc)(int listener, Acceptor func,
CommonGlobals* globals, void** storage ); CommonGlobals* globals, void** storage );
#ifdef XWFEATURE_SMS
typedef struct LinSMSData LinSMSData;
#endif
typedef struct _TimerInfo { typedef struct _TimerInfo {
XWTimerProc proc; XWTimerProc proc;
void* closure; void* closure;
@ -226,9 +222,6 @@ struct CommonGlobals {
#if defined XWFEATURE_IP_DIRECT #if defined XWFEATURE_IP_DIRECT
struct LinUDPStuff* udpStuff; struct LinUDPStuff* udpStuff;
#endif #endif
#ifdef XWFEATURE_SMS
LinSMSData* smsData;
#endif
TimerInfo timerInfo[NUM_TIMERS_PLUS_ONE]; TimerInfo timerInfo[NUM_TIMERS_PLUS_ONE];