mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
move md5sum code into separate function that relay can copy
This commit is contained in:
parent
6c756533e3
commit
17eda4e5e1
3 changed files with 27 additions and 7 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "dictnryp.h"
|
||||
#include "linuxmain.h"
|
||||
#include "strutils.h"
|
||||
#include "linuxutl.h"
|
||||
|
||||
typedef struct DictStart {
|
||||
XP_U32 numNodes;
|
||||
|
@ -374,16 +375,16 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
|
|||
) {
|
||||
XP_U32 curPos = ptr - dctx->dictBase;
|
||||
gssize dictLength = dctx->dictLength - curPos;
|
||||
GChecksum* cksum = g_checksum_new( G_CHECKSUM_MD5 );
|
||||
g_checksum_update( cksum, ptr, dictLength );
|
||||
const gchar* sum = g_checksum_get_string( cksum );
|
||||
XP_LOGF( "calculated sum on %d bytes: %s", dictLength, sum );
|
||||
|
||||
XP_UCHAR buf[128];
|
||||
XP_U16 buflen = VSIZE(buf);
|
||||
figureMD5Sum( ptr, dictLength, buf, &buflen );
|
||||
assert( buflen < VSIZE(buf) );
|
||||
if ( NULL == dctx->super.md5Sum ) {
|
||||
dctx->super.md5Sum = copyString( dctx->super.mpool, sum );
|
||||
dctx->super.md5Sum = copyString( dctx->super.mpool, buf );
|
||||
} else {
|
||||
XP_ASSERT( 0 == XP_STRCMP( dctx->super.md5Sum, sum ) );
|
||||
XP_ASSERT( 0 == XP_STRCMP( dctx->super.md5Sum, buf ) );
|
||||
}
|
||||
g_checksum_free( cksum );
|
||||
}
|
||||
|
||||
dctx->super.nFaces = numFaces;
|
||||
|
|
|
@ -651,6 +651,21 @@ writeNoConnMsgs( CommonGlobals* cGlobals, int fd )
|
|||
cGlobals->noConnMsgs = NULL;
|
||||
} /* writeNoConnMsgs */
|
||||
|
||||
void
|
||||
figureMD5Sum( const XP_U8* data, XP_U16 datalen, XP_UCHAR* buf, XP_U16* buflen )
|
||||
{
|
||||
GChecksum* cksum = g_checksum_new( G_CHECKSUM_MD5 );
|
||||
g_checksum_update( cksum, data, datalen );
|
||||
const gchar* sum = g_checksum_get_string( cksum );
|
||||
XP_LOGF( "%s calculated sum on %d bytes: %s", __func__, datalen, sum );
|
||||
int sumlen = strlen( sum );
|
||||
if ( sumlen < *buflen ) {
|
||||
(void)snprintf( buf, *buflen, "%s", sum );
|
||||
}
|
||||
*buflen = sumlen;
|
||||
g_checksum_free( cksum );
|
||||
}
|
||||
|
||||
#ifdef TEXT_MODEL
|
||||
/* This is broken for UTF-8, even Spanish */
|
||||
void
|
||||
|
|
|
@ -49,6 +49,10 @@ XP_Bool storeNoConnMsg( CommonGlobals* cGlobals, const XP_U8* msg, XP_U16 len,
|
|||
const XP_UCHAR* relayID );
|
||||
void writeNoConnMsgs( CommonGlobals* cGlobals, int fd );
|
||||
|
||||
void figureMD5Sum( const XP_U8* data, XP_U16 datalen,
|
||||
XP_UCHAR* buf, XP_U16* buflen );
|
||||
|
||||
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
void setSquareBonuses( const CommonGlobals* cGlobals );
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue