From 0b81516682040bd8ce7ce3db62955455d8517464 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 7 Sep 2012 20:32:10 -0700 Subject: [PATCH 01/12] add md5sum to dict header, summing not the whole file but the parts that make the wordlist unique: tile counts and values, and bitmaps, and the data. This happens to be contiguous data on non-palm .xwd files so it's easy to duplicate if the sum isn't there. --- xwords4/dawg/Makefile.langcommon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xwords4/dawg/Makefile.langcommon b/xwords4/dawg/Makefile.langcommon index 78f6a3baa..ac29946ea 100644 --- a/xwords4/dawg/Makefile.langcommon +++ b/xwords4/dawg/Makefile.langcommon @@ -280,7 +280,12 @@ $(XWLANG)%_note.bin: echo -n $(DICTNOTE) > $@ perl -e "print pack(\"c\",0)" >> $@ -$(XWLANG)%_newheader.bin: $(XWLANG)%_wordcount.bin $(XWLANG)%_note.bin +$(XWLANG)%_md5sum.bin: + cat table.bin values.bin frankspecials.bin $(XWLANG)StartLoc.bin \ + dawg$(XWLANG)$*_*.bin | md5sum | awk '{print $$1}' | tr -d '\n' > $@ + perl -e "print pack(\"c\",0)" >> $@ + +$(XWLANG)%_newheader.bin: $(XWLANG)%_wordcount.bin $(XWLANG)%_note.bin $(XWLANG)%_md5sum.bin SIZ=0; \ for FILE in $+; do \ SIZ=$$(($$SIZ + $$(ls -l $$FILE | awk '{print $$5}'))); \ From 5fa9b60846d1d65e9069153fe9a157b351bc4989 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 7 Sep 2012 20:34:06 -0700 Subject: [PATCH 02/12] add md5Sum field to dict struct, and on linux load it if present, otherwise calculate it. In DEBUG builds always calculate and assert they match. --- xwords4/common/dictnry.h | 1 + xwords4/linux/linuxdict.c | 47 ++++++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/xwords4/common/dictnry.h b/xwords4/common/dictnry.h index 1f33b2be1..0b24035d4 100644 --- a/xwords4/common/dictnry.h +++ b/xwords4/common/dictnry.h @@ -74,6 +74,7 @@ struct DictionaryCtxt { XP_UCHAR* langName; XP_UCHAR* faces; XP_UCHAR* desc; + XP_UCHAR* md5Sum; const XP_UCHAR** facePtrs; XP_U8* countsAndValues; diff --git a/xwords4/linux/linuxdict.c b/xwords4/linux/linuxdict.c index 672d78c30..10b0454e1 100644 --- a/xwords4/linux/linuxdict.c +++ b/xwords4/linux/linuxdict.c @@ -107,7 +107,7 @@ skipBitmap( LinuxDictionaryCtxt* XP_UNUSED_DBG(ctxt), const XP_U8** ptrp ) nCols = *ptr++; if ( nCols > 0 ) { - nRows = *ptr++; + nRows = *ptr++; nBytes = ((nRows * nCols) + 7) / 8; @@ -116,8 +116,8 @@ skipBitmap( LinuxDictionaryCtxt* XP_UNUSED_DBG(ctxt), const XP_U8** ptrp ) lbs->nCols = nCols; lbs->nBytes = nBytes; - memcpy( lbs + 1, ptr, nBytes ); - ptr += nBytes; + memcpy( lbs + 1, ptr, nBytes ); + ptr += nBytes; } *ptrp = ptr; @@ -308,6 +308,17 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName ) } else { XP_LOGF( "%s: no note", __func__ ); } + if ( 0 < headerLen ) { + XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)ptr ); + dctx->super.md5Sum = XP_MALLOC( dctx->super.mpool, len ); + XP_MEMCPY( dctx->super.md5Sum, ptr, len ); + XP_LOGF( "%s: got md5Sum of len %d: \"%s\"", __func__, + headerLen-1, dctx->super.md5Sum ); + ptr += len; + headerLen -= len; + } else { + XP_LOGF( "%s: no md5Sum", __func__ ); + } ptr += headerLen; } @@ -319,6 +330,25 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName ) numFaceBytes = numFaces * charSize; } + if ( NULL == dctx->super.md5Sum +#ifdef DEBUG + || XP_TRUE +#endif + ) { + 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 ); + if ( NULL == dctx->super.md5Sum ) { + dctx->super.md5Sum = copyString( dctx->super.mpool, sum ); + } else { + XP_ASSERT( 0 == XP_STRCMP( dctx->super.md5Sum, sum ) ); + } + g_checksum_free( cksum ); + } + dctx->super.nFaces = numFaces; dctx->super.countsAndValues = XP_MALLOC( dctx->super.mpool, @@ -427,14 +457,15 @@ linux_dictionary_destroy( DictionaryCtxt* dict ) freeSpecials( ctxt ); if ( !!ctxt->dictBase ) { - if ( ctxt->useMMap ) { - (void)munmap( ctxt->dictBase, ctxt->dictLength ); - } else { - XP_FREE( dict->mpool, ctxt->dictBase ); - } + if ( ctxt->useMMap ) { + (void)munmap( ctxt->dictBase, ctxt->dictLength ); + } else { + XP_FREE( dict->mpool, ctxt->dictBase ); + } } XP_FREEP( dict->mpool, &ctxt->super.desc ); + XP_FREEP( dict->mpool, &ctxt->super.md5Sum ); XP_FREE( dict->mpool, ctxt->super.countsAndValues ); XP_FREE( dict->mpool, ctxt->super.faces ); XP_FREE( dict->mpool, ctxt->super.facePtrs ); From 8e58d8c1c0868d5175e17e694afb890f9c219211 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 7 Sep 2012 20:34:55 -0700 Subject: [PATCH 03/12] print header elems, including md5sum, if present rather than just skipping. --- xwords4/dawg/dawg2dict.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xwords4/dawg/dawg2dict.pl b/xwords4/dawg/dawg2dict.pl index 38704c229..c8556f8df 100755 --- a/xwords4/dawg/dawg2dict.pl +++ b/xwords4/dawg/dawg2dict.pl @@ -156,6 +156,18 @@ sub readNodesToEnd($) { return @nodes; } # readNodesToEnd +sub printHeader($$) { + my ( $buf, $len ) = @_; + printf STDERR "skipped %d bytes of header:\n", $len + 2; + my $asStr = Encode::decode_utf8($buf); + my @strs = split( '\0', $asStr ); + foreach my $str (@strs) { + if ( 0 < length($str) ) { + print STDERR 'Got: ', $str, "\n"; + } + } +} + sub nodeSizeFromFlags($$) { my ( $fh, $flags ) = @_; @@ -167,7 +179,7 @@ sub nodeSizeFromFlags($$) { 2 == sysread( $fh, $buf, 2 ) || die "couldn't read length of header"; my $len = unpack( "n", $buf ); $len == sysread( $fh, $buf, $len ) || die "couldn't read header bytes"; - printf STDERR "skipped %d bytes of header\n", $len + 2; + printHeader( $buf, $len ); } if ( $flags == 2 || $ flags == 4 ) { From 14a77ff7f189a69715a3e1d6cc09857fefff4902 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 07:45:18 -0700 Subject: [PATCH 04/12] factor out common code --- xwords4/linux/linuxdict.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/xwords4/linux/linuxdict.c b/xwords4/linux/linuxdict.c index 10b0454e1..76788be50 100644 --- a/xwords4/linux/linuxdict.c +++ b/xwords4/linux/linuxdict.c @@ -83,6 +83,20 @@ linux_dictionary_make( MPFORMAL const char* dictFileName, XP_Bool useMMap ) return (DictionaryCtxt*)result; } /* gtk_dictionary_make */ +static XP_UCHAR* +getNullTermParam( LinuxDictionaryCtxt* dctx, const XP_U8** ptr, + XP_U16* headerLen ) +{ + XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)*ptr ); + XP_UCHAR* result = XP_MALLOC( dctx->super.mpool, len ); + XP_MEMCPY( result, *ptr, len ); + XP_LOGF( "%s: got param of len %d: \"%s\"", __func__, + len, result ); + *ptr += len; + *headerLen -= len; + return result; +} + static XP_U16 countSpecials( LinuxDictionaryCtxt* ctxt ) { @@ -298,24 +312,12 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName ) XP_DEBUGF( "dict contains %ld words", dctx->super.nWords ); if ( 0 < headerLen ) { - XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)ptr ); - dctx->super.desc = XP_MALLOC( dctx->super.mpool, len ); - XP_MEMCPY( dctx->super.desc, ptr, len ); - XP_LOGF( "%s: got note of len %d: \"%s\"", __func__, - headerLen-1, dctx->super.desc ); - ptr += len; - headerLen -= len; + dctx->super.desc = getNullTermParam( dctx, &ptr, &headerLen ); } else { XP_LOGF( "%s: no note", __func__ ); } if ( 0 < headerLen ) { - XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)ptr ); - dctx->super.md5Sum = XP_MALLOC( dctx->super.mpool, len ); - XP_MEMCPY( dctx->super.md5Sum, ptr, len ); - XP_LOGF( "%s: got md5Sum of len %d: \"%s\"", __func__, - headerLen-1, dctx->super.md5Sum ); - ptr += len; - headerLen -= len; + dctx->super.md5Sum = getNullTermParam( dctx, &ptr, &headerLen ); } else { XP_LOGF( "%s: no md5Sum", __func__ ); } From 077560bcd3016d23b0609d3cd24978589ab27a83 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 09:42:23 -0700 Subject: [PATCH 05/12] load md5sum if present --- xwords4/android/XWords4/jni/anddict.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/xwords4/android/XWords4/jni/anddict.c b/xwords4/android/XWords4/jni/anddict.c index 03e5bdfc7..4bddb2990 100644 --- a/xwords4/android/XWords4/jni/anddict.c +++ b/xwords4/android/XWords4/jni/anddict.c @@ -265,6 +265,18 @@ splitFaces_via_java( JNIEnv* env, AndDictionaryCtxt* ctxt, const XP_U8* ptr, ctxt->super.facePtrs = ptrs; } /* splitFaces_via_java */ +static XP_UCHAR* +getNullTermParam( AndDictionaryCtxt* dctx, const XP_U8** ptr, + XP_U16* headerLen ) +{ + XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)*ptr ); + XP_UCHAR* result = XP_MALLOC( dctx->super.mpool, len ); + XP_MEMCPY( result, *ptr, len ); + *ptr += len; + *headerLen -= len; + return result; +} + static XP_Bool parseDict( AndDictionaryCtxt* ctxt, XP_U8 const* ptr, XP_U32 dictLength, XP_U32* numEdges ) @@ -294,12 +306,10 @@ parseDict( AndDictionaryCtxt* ctxt, XP_U8 const* ptr, XP_U32 dictLength, } if ( 1 <= headerLen ) { /* have description? */ - XP_U16 len = 1 + XP_STRLEN( (XP_UCHAR*)ptr ); - ctxt->super.desc = - (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, len); - XP_MEMCPY( ctxt->super.desc, ptr, len ); - ptr += len; - headerLen -= len; + ctxt->super.desc = getNullTermParam( ctxt, &ptr, &headerLen ); + } + if ( 1 <= headerLen ) { /* have md5sum? */ + ctxt->super.md5Sum = getNullTermParam( ctxt, &ptr, &headerLen ); } CHECK_PTR( ptr, headerLen, end ); @@ -440,6 +450,7 @@ and_dictionary_destroy( DictionaryCtxt* dict ) XP_FREE( ctxt->super.mpool, ctxt->super.bitmaps ); } + XP_FREEP( ctxt->super.mpool, &ctxt->super.md5Sum ); XP_FREEP( ctxt->super.mpool, &ctxt->super.desc ); XP_FREEP( ctxt->super.mpool, &ctxt->super.faces ); XP_FREEP( ctxt->super.mpool, &ctxt->super.facePtrs ); From 50a4f32bfaa593452a152625af7a9ac31aa7daad Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 10:08:39 -0700 Subject: [PATCH 06/12] new versions of dicts with checksums and descriptions --- .../android/XWords4/assets/BasEnglish2to8.xwd | Bin 4151 -> 4236 bytes .../XWords4/assets/CollegeEng_2to8.xwd | Bin 101048 -> 101112 bytes xwords4/android/XWords4/assets/Top5000.xwd | Bin 19817 -> 19850 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/xwords4/android/XWords4/assets/BasEnglish2to8.xwd b/xwords4/android/XWords4/assets/BasEnglish2to8.xwd index 038ef39b8ba9f92b1bd9410efddc34203a9bb91d..7a27713cc994ee9ea8395b6fb8d00c8200d12899 100644 GIT binary patch delta 102 zcmdn4(4!d3z{3#9z`!gYo?n!blUZD%kX)3SSdyBekeR1Yl98%lXlZOvtdN#pq>z)C zmtLBfo~n?Onpl*VT2#znW@?yZnPQn_kY-|FVV-QBXr7joWMW}xnP_HWk(iXou#rPw F002Mp9;g5S delta 17 YcmeBC+^)dEz{9}8z`!iOF;-sy03GZD3;+NC diff --git a/xwords4/android/XWords4/assets/CollegeEng_2to8.xwd b/xwords4/android/XWords4/assets/CollegeEng_2to8.xwd index bff3d12454f0b9aa1547c2c84c2c98c69dad24b8..c7c4bb8a54d96273dfdee2964bb25c928b6eea53 100644 GIT binary patch delta 86 zcmdlnmF>q=HV+0K1{Vf~#rFGJC3Q_BMSo$gWg0Iy^X= Date: Sat, 8 Sep 2012 10:09:31 -0700 Subject: [PATCH 07/12] add dict_getMd5Sum --- xwords4/common/dictnry.c | 6 ++++++ xwords4/common/dictnry.h | 1 + 2 files changed, 7 insertions(+) diff --git a/xwords4/common/dictnry.c b/xwords4/common/dictnry.c index c3644b3f0..d4952ec2a 100644 --- a/xwords4/common/dictnry.c +++ b/xwords4/common/dictnry.c @@ -505,6 +505,12 @@ dict_getDesc( const DictionaryCtxt* dict ) return dict->desc; } +const XP_UCHAR* +dict_getMd5Sum( const DictionaryCtxt* dict ) +{ + return dict->md5Sum; +} + #ifdef STUBBED_DICT #define BLANK_FACE '\0' diff --git a/xwords4/common/dictnry.h b/xwords4/common/dictnry.h index 0b24035d4..5eb04e6a5 100644 --- a/xwords4/common/dictnry.h +++ b/xwords4/common/dictnry.h @@ -166,6 +166,7 @@ XP_LangCode dict_getLangCode( const DictionaryCtxt* dict ); XP_U32 dict_getWordCount( const DictionaryCtxt* dict ); const XP_UCHAR* dict_getDesc( const DictionaryCtxt* dict ); +const XP_UCHAR* dict_getMd5Sum( const DictionaryCtxt* dict ); void dict_writeToStream( const DictionaryCtxt* ctxt, XWStreamCtxt* stream ); void dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream ); From 977bee15d907be8a0c5654b29346e5eff92846cf Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 10:10:17 -0700 Subject: [PATCH 08/12] add DICTNOTEs --- xwords4/dawg/English/BasEnglish2to8.xwd | Bin 4189 -> 4737 bytes xwords4/dawg/English/Makefile.BasEnglish | 2 +- xwords4/dawg/English/Makefile.CollegeEng | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xwords4/dawg/English/BasEnglish2to8.xwd b/xwords4/dawg/English/BasEnglish2to8.xwd index 31703c91d74da25d7f17927e57e1079dbd633f8b..97af65b9646ee93908e79a0012a10ce3efe310a2 100644 GIT binary patch literal 4737 zcmX9>34B!5x&MFPIVY1#W(ku7XT)W&HU=UR;0Z#oIwY55LS`o1xi=AT3#%aFdx)ZK z@u`o1uL=o}K5JXWB`#P|p{w>OQpKfULJ10Ki?xE4y42RKYC-#*kzc|u%gsIC^4|`^ zm<^~|9apbdux!aSD^v4VEbLsla6xLx^3=*J7N*8enOJvCYSGmzQp-A*FTS>O@xs)y zg`F#wFI;gACN7*mrE~nblP63bU$n73eJ-Mr566ULu6Z_<>>7&#K@=?#tU zjHc#H%goknF5foGEBHZs$3?T}+zf_8tXOFd6Kln+9imb)T7Ft0U$CNKC8WuIvSv-C z@;Qty!`J_ABGOF%tLQDwCmUW~!gqvtUnzg=sFGnSQKlNh>ZXXgH>!5U^jYP4(r~>h zZbny_b(QA-s!ZPq^M{knyVCt`-~f^V5@DR2M>2;~1Duuzo(Bdos(>@{I9(y-;2UxK zB>GX4$LI{k_^8bwS-{u;r@9!IMV*WB1x(0bqL2UZaITB9HO?7^N$tRXOm$K3V{AXp z&tSZZZxJr=Fjfw_9n-VGi*Td%=ov9g2!J75Pm2faMK+CG7WEy#8q5qK@1U&$=(W#` z3ee%>qBLfE$hBi`9&^b4;l&;fmvh69zr59~%d8*FQdG8~Rt@a&YDn~-d_ z??0k(v6fd@xD5GeE%A-^v-}c%e*JS9_G@a(t=^hd?lP25F;xLWM0sD|^ptCYmP3SXJ z6S3uOGnNsDJ^BXGXhUNi8W&)&fdv0jKlan4wC%mK5~+aBGc=_Lcp2kV+1(ntFl@JZ zw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ix?Z$!8slC1o_1v0^}PjsUryiOp?^sF0r5jo zsJN@l#9{1~iB@T)fF{pt>F4y{cj}+Y!-8<~S(((bCh13wo-CrJ1IOd~iGtow`bUHM zfTJHt>c>3&WMp@E;kIC9camXxC6FPapULQv7{ z2p$%yhbCprJSl3AJ$J3>PMEXPKAlOizH81Glc~%FnGsF)!NIoA{*^u+GfU!TY0@n7 q*hG?s(8 Date: Sat, 8 Sep 2012 10:11:18 -0700 Subject: [PATCH 09/12] add md5Sum to DictInfo and add a getter --- xwords4/android/XWords4/jni/xwjni.c | 1 + .../XWords4/src/org/eehouse/android/xw4/DictLangCache.java | 5 +++++ .../XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index abc439271..1135634e9 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -299,6 +299,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getInfo if ( NULL != jinfo ) { setInt( env, jinfo, "langCode", dict_getLangCode( dict ) ); setInt( env, jinfo, "wordCount", dict_getWordCount( dict ) ); + setString( env, jinfo, "md5Sum", dict_getMd5Sum( dict ) ); } dict_destroy( dict ); result = true; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java index 193f8bb43..d07fa8b83 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java @@ -197,6 +197,11 @@ public class DictLangCache { return getInfo( context, dal ).langCode; } + public static String getDictMD5Sum( Context context, String dict ) + { + return getInfo( context, dict ).md5Sum; + } + public static int getDictLangCode( Context context, String dict ) { return getInfo( context, dict ).langCode; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java index 26aa1f7bb..d9cf8ca9b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java @@ -21,7 +21,11 @@ package org.eehouse.android.xw4.jni; public class DictInfo { + // set in java code + public String name; + + // set in jni code public int langCode; public int wordCount; - public String name; + public String md5Sum; }; From ca88c9850e8a60f0e6f64a163eecba8f867bac08 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 13:17:49 -0700 Subject: [PATCH 10/12] add DICTNOTE --- xwords4/dawg/English/Makefile.SOWPODS | 1 + 1 file changed, 1 insertion(+) diff --git a/xwords4/dawg/English/Makefile.SOWPODS b/xwords4/dawg/English/Makefile.SOWPODS index 1016f0678..270adf1b3 100644 --- a/xwords4/dawg/English/Makefile.SOWPODS +++ b/xwords4/dawg/English/Makefile.SOWPODS @@ -18,6 +18,7 @@ XWLANG = SOWPODS LANGCODE = en_US TARGET_TYPE = WINCE +DICTNOTE = "Used in Scrabbleâ„¢ tournaments especially outside the US" include ../Makefile.langcommon From 047f68aafdf85cf32dec7657e2ee40601388de28 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 8 Sep 2012 13:18:58 -0700 Subject: [PATCH 11/12] version with checksum and note --- xwords4/dawg/English/BasEnglish2to8.xwd | Bin 4737 -> 4236 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/xwords4/dawg/English/BasEnglish2to8.xwd b/xwords4/dawg/English/BasEnglish2to8.xwd index 97af65b9646ee93908e79a0012a10ce3efe310a2..7a27713cc994ee9ea8395b6fb8d00c8200d12899 100644 GIT binary patch literal 4236 zcmX9>3wV^}m446pzAuxX%q9Fu=nSkf(LOd@OA_SPb?l#HOh%HK;h&j=0G0;1c;yzX zYtgdM1h6I{P19{{m#x+t!A9DxHuVDAdZAVz@L(*Y?%LMw+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Obeaq+b&Zl&HGmWL!BYt`EuO#ojDbw!vbcCa;f>e#_{;#4sRtnY5P7UuW!fQo>KQ zB)UQt{{bj^nK+vPV@k_E-=e z7WOrm5;CO*{V_8v(0?cWvC*G9hGM47<2QX%DH=lbY!l6BLtn-uJ#%uKsbUc~zE+zN zA@Nz6l}VJFksdZ1uFY_*YpQ*7Rza^OeVfvE8T~}5{-vXLmg(oidT&JUkLo{k>tp5m z{oy87X-=s!XP#tgBs)n&*=uu=)y6V2B}`j{O@}bhY|;&AX)p~r)94zv(M%^ZLo`|V zE($Mhz5(0Ci;G*9dCGk}`I7OPOhK+@g4o>>Gb9R{z?hCa>KpM%#LUf^7Ba0}Chr(O zW@g9D#euys3G!utHe79BxpyD)%~Dr&d1jexHZaSZWTfWGkhv;iu8#70iCaB5Y%{Hq zgkVwR7@LBIbe8~|&FX@=F)%j}u5ipvQlZ?N Date: Sat, 8 Sep 2012 13:20:12 -0700 Subject: [PATCH 12/12] add options, that sometimes work, to print desc and md5sum from .xwd files. Still need to figure out how to parse binary into UTF-8. --- xwords4/dawg/dawg2dict.pl | 81 ++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/xwords4/dawg/dawg2dict.pl b/xwords4/dawg/dawg2dict.pl index c8556f8df..629131270 100755 --- a/xwords4/dawg/dawg2dict.pl +++ b/xwords4/dawg/dawg2dict.pl @@ -26,6 +26,10 @@ use Encode 'from_to'; use Encode; my $gInFile; +my $gSumOnly = 0; +my $gSum; +my $gDescOnly = 0; +my $gDesc; my $gDoRaw = 0; my $gDoJSON = 0; my $gFileType; @@ -35,9 +39,11 @@ use Fcntl 'SEEK_CUR'; sub systell { sysseek($_[0], 0, SEEK_CUR) } sub usage() { - print STDERR "USAGE: $0 " - . "[-raw | -json] " - . "-dict " + print STDERR "USAGE: $0" + . " [-raw | -json] " + . " [-get-sum]" + . " [-get-desc]" + . " -dict " . "\n" . "\t(Takes a .pdb or .xwd and prints its words to stdout)\n"; exit 1; @@ -52,6 +58,10 @@ sub parseARGV() { $gDoJSON = 1; } elsif ( $parm eq "-dict" ) { $gInFile = shift(@ARGV); + } elsif ( $parm eq "-get-sum" ) { + $gSumOnly = 1; + } elsif ( $parm eq "-get-desc" ) { + $gDescOnly = 1; } else { usage(); } @@ -161,6 +171,10 @@ sub printHeader($$) { printf STDERR "skipped %d bytes of header:\n", $len + 2; my $asStr = Encode::decode_utf8($buf); my @strs = split( '\0', $asStr ); + # There are variable numbers of strings showing up in this thing. + # Need to figure out the right way to unpack the thing. + $gDesc = $strs[1]; + $gSum = $strs[2]; foreach my $str (@strs) { if ( 0 < length($str) ) { print STDERR 'Got: ', $str, "\n"; @@ -204,6 +218,7 @@ sub mergeSpecials($$) { sub prepXWD($$$$) { my ( $fh, $facRef, $nodesRef, $startRef ) = @_; + my $done = 1; printf STDERR "at 0x%x at start\n", systell($fh); my $buf; @@ -212,33 +227,44 @@ sub prepXWD($$$$) { $gNodeSize = nodeSizeFromFlags( $fh, $flags ); - my $nSpecials; - my $faceCount = readXWDFaces( $fh, $facRef, \$nSpecials ); + if ( $gSumOnly ) { + print STDOUT $gSum, "\n"; + } elsif( $gDescOnly ) { + print STDOUT $gDesc, "\n"; + } else { + $done = 0; + } - printf STDERR "at 0x%x before header read\n", systell($fh); - # skip xloc header - $nRead = sysread( $fh, $buf, 2 ); + if ( !$done ) { + my $nSpecials; + my $faceCount = readXWDFaces( $fh, $facRef, \$nSpecials ); - # skip values info. - printf STDERR "at 0x%x before reading %d values\n", systell($fh), $faceCount; - sysread( $fh, $buf, $faceCount * 2 ); - printf STDERR "at 0x%x after values read\n", systell($fh); + printf STDERR "at 0x%x before header read\n", systell($fh); + # skip xloc header + $nRead = sysread( $fh, $buf, 2 ); - printf STDERR "at 0x%x before specials read\n", systell($fh); - my @specials; - getSpecials( $fh, $nSpecials, \@specials ); - mergeSpecials( $facRef, \@specials ); - printf STDERR "at 0x%x after specials read\n", systell($fh); + # skip values info. + printf STDERR "at 0x%x before reading %d values\n", systell($fh), $faceCount; + sysread( $fh, $buf, $faceCount * 2 ); + printf STDERR "at 0x%x after values read\n", systell($fh); - printf STDERR "at 0x%x before offset read\n", systell($fh); - sysread( $fh, $buf, 4 ); - $$startRef = unpack( 'N', $buf ); - print STDERR "startRef=$$startRef\n"; + printf STDERR "at 0x%x before specials read\n", systell($fh); + my @specials; + getSpecials( $fh, $nSpecials, \@specials ); + mergeSpecials( $facRef, \@specials ); + printf STDERR "at 0x%x after specials read\n", systell($fh); - my @nodes = readNodesToEnd( $fh ); + printf STDERR "at 0x%x before offset read\n", systell($fh); + sysread( $fh, $buf, 4 ); + $$startRef = unpack( 'N', $buf ); + print STDERR "startRef=$$startRef\n"; - @$nodesRef = @nodes; + my @nodes = readNodesToEnd( $fh ); + + @$nodesRef = @nodes; + } print STDERR "prepXWD done\n"; + return $done; } # prepXWD sub readPDBSpecials($$$$$) { @@ -448,17 +474,20 @@ binmode INFILE; my @faces; my @nodes; my $startIndex; +my $done; if ( $gFileType eq "xwd" ){ - prepXWD( *INFILE, \@faces, \@nodes, \$startIndex ); + $done = prepXWD( *INFILE, \@faces, \@nodes, \$startIndex ); } elsif ( $gFileType eq "pdb" ) { - prepPDB( *INFILE, \@faces, \@nodes, \$startIndex ); + $done = prepPDB( *INFILE, \@faces, \@nodes, \$startIndex ); } close INFILE; die "no nodes!!!" if 0 == @nodes; -if ( $gDoRaw ) { +if ( $done ) { + # we're done... +} elsif ( $gDoRaw ) { printNodes( \@nodes, \@faces ); } elsif ( $gDoJSON ) { print "dict = {\n";