return -1;\r
}\r
\r
+/* Convert dictionary info chunk between native and on-disk (big-endian). */\r
+static void\r
+convertDictionaryInfoWrite (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
+ * This assumes they are all 32-bit integers.\r
+ */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
+ }\r
+}\r
+\r
+static void\r
+convertDictionaryInfoRead (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in structure from BigEndian to Native. */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
+ }\r
+}\r
+\r
/****************************************************************\r
** Save Dictionary in File.\r
** If EntryPoint is NULL, save as development environment.\r
uint32_t NameChunkSize = 0;\r
uint32_t CodeChunkSize;\r
uint32_t relativeCodePtr;\r
- int i;\r
\r
fid = sdOpenFile( FileName, "wb" );\r
if( fid == NULL )\r
uint32_t relativeHeaderPtr;\r
/* Development mode. */\r
SD.sd_RelContext = ABS_TO_NAMEREL(gVarContext);\r
- relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr.Byte);\r
+ relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr);\r
SD.sd_RelHeaderPtr = relativeHeaderPtr;\r
\r
/* How much real name space is there? */\r
SD.sd_CodeSize = CodeSize;\r
\r
\r
-/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
- * This assumes they are all 32-bit integers.\r
- */\r
- {\r
- uint32_t *p = (uint32_t *) &SD;\r
- for( i=0; i<((int)(sizeof(SD)/sizeof(uint32_t))); i++ )\r
- {\r
- Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
- }\r
- }\r
+ convertDictionaryInfoWrite (&SD);\r
\r
if( WriteChunkToFile( fid, ID_P4DI, (char *) &SD, sizeof(DictionaryInfoChunk) ) < 0 ) goto error;\r
\r
uint32_t FormSize;\r
uint32_t BytesLeft;\r
uint32_t numr;\r
- int i;\r
int isDicBigEndian;\r
\r
DBUG(("pfLoadDictionary( %s )\n", FileName ));\r
if( numr != ChunkSize ) goto read_error;\r
BytesLeft -= ChunkSize;\r
\r
-/* Convert all fields in structure from BigEndian to Native. */\r
- {\r
- uint32_t *p = (uint32_t *) sd;\r
- for( i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++ )\r
- {\r
- p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
- }\r
- }\r
- \r
+ convertDictionaryInfoRead (sd);\r
+\r
isDicBigEndian = sd->sd_Flags & SD_F_BIG_ENDIAN_DIC;\r
\r
if( !gVarQuiet )\r
if( sd->sd_NameSize > 0 )\r
{\r
gVarContext = (char *) NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */\r
- gCurrentDictionary->dic_HeaderPtr.Byte = (uint8_t *)\r
+ gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *)\r
NAMEREL_TO_ABS(sd->sd_RelHeaderPtr);\r
}\r
else\r
{\r
gVarContext = 0;\r
- gCurrentDictionary->dic_HeaderPtr.Byte = NULL;\r
+ gCurrentDictionary->dic_HeaderPtr = (ucell_t)NULL;\r
}\r
gCurrentDictionary->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(sd->sd_RelCodePtr);\r
gNumPrimitives = sd->sd_NumPrimitives; /* Must match compiled dictionary. */\r
if( NAME_BASE != NULL)\r
{\r
/* Setup name space. */\r
- dic->dic_HeaderPtr.Byte = (uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
+ dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
gVarContext = (char *) NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */\r
\r
/* Find special words in dictionary for global XTs. */\r