void SemOS2AddStrToStringTable( FullStringTable *currtable, uint_16 stringid, char *string ) /***************************************************************/ { FullStringTableBlock *currblock; uint_16 blocknum; uint_16 stringnum; blocknum = stringid >> 4; stringnum = stringid & 0x000f; currblock = findStringTableBlock( currtable, blocknum ); if( currblock != NULL ) { if( currblock->Block.String[stringnum] != NULL ) { /* duplicate stringid */ RcError( ERR_DUPLICATE_STRING_CONST, stringid ); ErrorHasOccured = true; } } else { currblock = newStringTableBlock(); currblock->BlockNum = blocknum; ResAddLLItemAtEnd( (void **)&(currtable->Head), (void **)&(currtable->Tail), currblock ); } currblock->Block.String[stringnum] = WResIDNameFromStr( string ); } /* SemOS2AddStrToStringTable */
static void semMergeStringTables( FullStringTable *currtable, FullStringTable *oldtable, ResMemFlags newblockflags, uint_32 codepage ) /****************************************************************/ /* merge oldtable into currtable and free oldtable when done */ /* returns TRUE if there was one or more duplicate entries */ { FullStringTableBlock *currblock; FullStringTableBlock *oldblock; FullStringTableBlock *nextblock; /* run through the list of block in oldtable */ oldblock = oldtable->Head; while( oldblock != NULL ) { /* find oldblock in currtable if it is there */ nextblock = oldblock->Next; currblock = findStringTableBlock( currtable, oldblock->BlockNum ); if( currblock == NULL ) { /* if oldblock in not in currtable move it there from oldtable */ ResDeleteLLItem( (void **)&(oldtable->Head), (void **)&(oldtable->Tail), oldblock ); oldblock->Flags = newblockflags; oldblock->codePage = codepage; ResAddLLItemAtEnd( (void **)&(currtable->Head), (void **)&(currtable->Tail), oldblock ); } else { /* otherwise move the WSemID's to that block */ mergeStringTableBlocks( currblock, oldblock ); } oldblock = nextblock; } SemOS2FreeStringTable( oldtable ); } /* semMergeStringTables */
static RcStatus readCurFileDir( WResFileID handle, FullCurDir *dir, int *err_code ) /*********************************************************************************/ /* this funtion returns one of the above enum constants */ { RcStatus ret; int currentry; FullCurDirEntry * entry; ret = readIcoCurFileDirHeader( &(dir->Header), handle, err_code ); /* type 2 is a cursor file */ if( ret == RS_OK && dir->Header.Type != 2 ) { return( RS_INVALID_RESOURCE ); } for( currentry = 0; ret == RS_OK && currentry < dir->Header.ResCount; currentry++ ) { entry = RCALLOC( sizeof(FullCurDirEntry) ); entry->Next = NULL; entry->Prev = NULL; entry->IsCurFileEntry = true; ret = readCurFileDirEntry( &(entry->Entry.Cur), handle, err_code ); if( ret != RS_OK ) { RCFREE( entry ); } else { ResAddLLItemAtEnd( (void **) &(dir->Head), (void **) &(dir->Tail), entry ); } } return( ret ); } /* readCurFileDir */
static int readLangInfoList( WResFileID handle, WResResNode *res, void *fileinfo ) { unsigned i; WResLangNode *langnode; int error; int numread; error = FALSE; for( i=0; i < res->Info.NumResources; i++ ) { langnode = WRESALLOC( sizeof(WResLangNode) ); if( langnode == NULL ) { error = TRUE; WRES_ERROR( WRS_MALLOC_FAILED ); } if( error ) break; numread = (* WRESREAD) ( handle, &(langnode->Info), sizeof( WResLangInfo ) ); if( numread != sizeof( WResLangInfo ) ) { error = TRUE; WRES_ERROR( numread == -1 ? WRS_READ_FAILED:WRS_READ_INCOMPLETE ); WRESFREE( langnode ); break; } langnode->data = NULL; langnode->fileInfo = fileinfo; ResAddLLItemAtEnd( (void **)&(res->Head), (void **)&(res->Tail), langnode ); } return( error ); }
FullVerBlockNest * SemWINAddBlockNest( FullVerBlockNest * parent, FullVerBlock * child ) /***************************************************************/ { ResAddLLItemAtEnd( (void **) &(parent->Head), (void **) &(parent->Tail), child ); return( parent ); }
extern PresParamListOS2 *SemOS2AppendPresParam( PresParamListOS2 *list, PresParamsOS2 presparams ) /*************************************************************************/ { PresParamsOS2 *params; params = RcMemMalloc( sizeof( PresParamsOS2 ) ); *params = presparams; ResAddLLItemAtEnd( (void **)&(list->head), (void **)&(list->tail), params ); return( list ); }
extern FullDiagCtrlList *SemAddDiagCtrlList( FullDiagCtrlList *list, FullDialogBoxControl *ctrl, DataElemList *dataList ) /**********************************************************************/ { if( ctrl != NULL ) { ctrl->dataListHead = dataList; ResAddLLItemAtEnd( (void **) &(list->head), (void **) &(list->tail), ctrl ); list->numctrls++; } return( list ); } /* SemAddDiagCtrlList */
extern FullDiagCtrlListOS2 *SemOS2AddDiagCtrlList( FullDiagCtrlListOS2 *list, FullDialogBoxControlOS2 *ctrl, DataElemList *dataList, PresParamListOS2 *presparams ) /***************************************************************************/ { if( ctrl != NULL ) { ctrl->dataListHead = dataList; // ctrl->presParams = presparams; ResAddLLItemAtEnd( (void **)&(list->head), (void **)&(list->tail), ctrl ); list->numctrls++; } return( list ); }
static int readTypeList( WResFileID handle, WResDirHead * currdir, uint_16 ver, void *fileinfo ) { WResTypeNode * newnode; WResTypeInfo newtype; int error; int typenum; int extrabytes; /* loop through the list of types */ for (error = FALSE, typenum = 0; typenum < currdir->NumTypes && !error; typenum++) { /* read a type record from disk */ if( ver < 3 ) { error = WResReadFixedTypeRecord2( &newtype, handle ); } else { error = WResReadFixedTypeRecord( &newtype, handle ); } if( !error ) { /* allocate a new node */ extrabytes = WResIDExtraBytes( &(newtype.TypeName) ); newnode = WRESALLOC( sizeof(WResTypeNode) + extrabytes ); if( newnode == NULL ) { error = TRUE; WRES_ERROR( WRS_MALLOC_FAILED ); } } if( !error ) { /* initialize the linked list of resources */ newnode->Head = NULL; newnode->Tail = NULL; /* copy the new type info into the new node */ memcpy( &(newnode->Info), &newtype, sizeof(WResTypeInfo) ); /* read the extra bytes (if any) */ if( extrabytes > 0 ) { error = WResReadExtraWResID( &(newnode->Info.TypeName), handle ); } } if( !error ) { /* add the type node to the linked list */ ResAddLLItemAtEnd( (void **)&(currdir->Head), (void **)&(currdir->Tail), newnode ); /* read in the list of resources of this type */ error = readResList( handle, newnode, ver, fileinfo ); } } return( error ); } /* readTypeList */
FullVerBlockNest * SemWINMergeBlockNest( FullVerBlockNest * nest1, FullVerBlockNest * nest2 ) /****************************************************************/ { FullVerBlock * block; for( block = nest2->Head; block != NULL; block = block->Next ) { ResAddLLItemAtEnd( (void **) &nest1->Head, (void **) &nest1->Tail, block ); } RCFREE( nest2 ); return( nest1 ); }
static void AddFontToDir( FontInfo *info, char *devicename, char *facename, WResID *fontid ) /******************************************************************************************/ { FullFontDirEntry *entry; entry = NewFontDirEntry( info, devicename, facename, fontid ); if( CurrResFile.FontDir == NULL ) { CurrResFile.FontDir = NewFontDir(); } ResAddLLItemAtEnd( (void **)&(CurrResFile.FontDir->Head), (void **)&(CurrResFile.FontDir->Tail), entry ); CurrResFile.FontDir->NumOfFonts += 1; }
FullAccelTableOS2 *SemOS2AddAccelEntry( FullAccelEntryOS2 currentry, FullAccelTableOS2 * currtable ) /**************************************************************************************************/ { FullAccelEntryOS2 *newentry; newentry = RESALLOC( sizeof( FullAccelEntryOS2 ) ); if( newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = true; return( NULL ); } *newentry = currentry; ResAddLLItemAtEnd( (void **) &(currtable->head), (void **) &(currtable->tail), newentry ); return( currtable ); }
FullMenuOS2 *SemOS2AddMenuItem( FullMenuOS2 *currmenu, FullMenuItemOS2 curritem ) /*******************************************************************************/ { FullMenuItemOS2 *newitem; newitem = RCALLOC( sizeof(FullMenuItemOS2) ); if (newitem == NULL) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = TRUE; return( NULL ); } *newitem = curritem; ResAddLLItemAtEnd( (void **)&(currmenu->head), (void **)&(currmenu->tail), newitem ); return( currmenu ); }
static void addExeResRecord( ResTable *restab, FullTypeRecord *type, WResID *name, uint_16 mem_flags, uint_16 exe_offset, uint_16 exe_length ) /******************************************************************/ { FullResourceRecord *exe_res; exe_res = RCALLOC( sizeof( FullResourceRecord ) ); exe_res->Info.offset = exe_offset; exe_res->Info.length = exe_length; exe_res->Info.flags = mem_flags; exe_res->Info.reserved = 0; exe_res->Info.name = findResOrTypeName( restab, name ); exe_res->Next = NULL; exe_res->Prev = NULL; /* use the general purpose linked list routines from WRes */ ResAddLLItemAtEnd( (void **)&(type->Head), (void **)&(type->Tail), exe_res ); } /* addExeResRecord */
extern FullHelpTableOS2 *SemOS2AddHelpItem( FullHelpEntryOS2 currentry, FullHelpTableOS2 * currtable ) /******************************************************************/ { FullHelpEntryOS2 *newentry; newentry = RcMemMalloc( sizeof(FullHelpEntryOS2) ); if( newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = TRUE; return( NULL ); } *newentry = currentry; ResAddLLItemAtEnd( (void **) &(currtable->head), (void **) &(currtable->tail), newentry ); return( currtable ); }
FullHelpSubTableOS2 *SemOS2AddHelpSubItem( DataElemList * data, FullHelpSubTableOS2 * currtable ) /*************************************************************/ { FullHelpSubEntryOS2 *newentry; newentry = RCALLOC( sizeof( FullHelpSubEntryOS2 ) ); if( newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = true; return( NULL ); } newentry->dataListHead = data; ResAddLLItemAtEnd( (void **)&(currtable->head), (void **)&(currtable->tail), newentry ); return( currtable ); }
static FullTypeRecord *addExeTypeRecord( ResTable *restab, WResTypeInfo *type ) /********************************************************/ { FullTypeRecord *exe_type; exe_type = RCALLOC( sizeof( FullTypeRecord ) ); exe_type->Info.reserved = 0; exe_type->Info.num_resources = type->NumResources; exe_type->Info.type = findResOrTypeName( restab, &(type->TypeName) ); exe_type->Head = NULL; exe_type->Tail = NULL; exe_type->Next = NULL; exe_type->Prev = NULL; /* use the general purpose linked list routines from WRes */ ResAddLLItemAtEnd( (void **)&(restab->Dir.Head), (void **)&(restab->Dir.Tail), exe_type ); return( exe_type ); } /* addExeTypeRecord */
FullHelpSubTableOS2 *SemOS2NewHelpSubTable( DataElemList * data ) /***************************************************************/ { FullHelpSubTableOS2 *newtable; FullHelpSubEntryOS2 *newentry; newtable = RcMemMalloc( sizeof( FullHelpSubTableOS2 ) ); newentry = RcMemMalloc( sizeof( FullHelpSubEntryOS2 ) ); if( newtable == NULL || newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = TRUE; return( NULL ); } newentry->dataListHead = data; newtable->head = NULL; newtable->tail = NULL; ResAddLLItemAtEnd( (void **) &(newtable->head), (void **) &(newtable->tail), newentry ); return( newtable ); }
FullHelpTableOS2 *SemOS2NewHelpTable( FullHelpEntryOS2 firstentry ) /***************************************************************/ { FullHelpTableOS2 *newtable; FullHelpEntryOS2 *newentry; newtable = RcMemMalloc( sizeof( FullHelpTableOS2 ) ); newentry = RcMemMalloc( sizeof( FullHelpEntryOS2 ) ); if( newtable == NULL || newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = TRUE; return( NULL ); } *newentry = firstentry; newtable->head = NULL; newtable->tail = NULL; ResAddLLItemAtEnd( (void **) &(newtable->head), (void **) &(newtable->tail), newentry ); return( newtable ); }
FullAccelTableOS2 *SemOS2NewAccelTable( FullAccelEntryOS2 firstentry ) /***************************************************************/ { FullAccelTableOS2 *newtable; FullAccelEntryOS2 *newentry; newtable = RESALLOC( sizeof( FullAccelTableOS2 ) ); newentry = RESALLOC( sizeof( FullAccelEntryOS2 ) ); if( newtable == NULL || newentry == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = true; return( NULL ); } *newentry = firstentry; newtable->head = NULL; newtable->tail = NULL; ResAddLLItemAtEnd( (void **)&(newtable->head), (void **)&(newtable->tail), newentry ); return( newtable ); }
FullMenuOS2 *SemOS2NewMenu( FullMenuItemOS2 firstitem ) /*****************************************************/ { FullMenuOS2 *newmenu; FullMenuItemOS2 *newitem; newmenu = RCALLOC( sizeof(FullMenuOS2) ); newitem = RCALLOC( sizeof(FullMenuItemOS2) ); if( newmenu == NULL || newitem == NULL ) { RcError( ERR_OUT_OF_MEMORY ); ErrorHasOccured = TRUE; return( NULL ); } *newitem = firstitem; newmenu->head = NULL; newmenu->tail = NULL; ResAddLLItemAtEnd( (void **)&(newmenu->head), (void **)&(newmenu->tail), newitem ); return( newmenu ); }
static int readResList( WResFileID handle, WResTypeNode * currtype, uint_16 ver, void *fileinfo ) { WResResNode *newnode; WResResInfo newres; WResResInfo1 newres1; WResLangNode *langnode; WResID *resid; WResID tmpresid; int error; int resnum; int extrabytes; /* loop through the list of resources of this type */ for (resnum = 0, error = FALSE; resnum < currtype->Info.NumResources && !error; resnum++) { /* read a resource record from disk */ if( ver < 2 ) { error = WResReadFixedResRecord1( &newres1, handle ); resid = &tmpresid; tmpresid.IsName = newres1.ResName.IsName; if( tmpresid.IsName ) { tmpresid.ID.Name.Name[0] = newres1.ResName.ID.Name.Name[0]; tmpresid.ID.Name.NumChars = newres1.ResName.ID.Name.NumChars; } else { tmpresid.ID.Num = newres1.ResName.ID.Num; } } else if( ver == 2 ) { error = WResReadFixedResRecord2( &newres, handle ); resid = &( newres.ResName ); } else { error = WResReadFixedResRecord( &newres, handle ); resid = &( newres.ResName ); } if( !error ) { /* allocate a new node */ extrabytes = WResIDExtraBytes( resid ); newnode = WRESALLOC( sizeof(WResResNode) + extrabytes ); if( newnode == NULL ) { error = TRUE; WRES_ERROR( WRS_MALLOC_FAILED ); } } if( !error ) { newnode->Head = NULL; newnode->Tail = NULL; /* copy the new resource info into the new node */ if( ver < 2 ) { newnode->Info.NumResources = 1; memcpy( &(newnode->Info.ResName), &( newres1.ResName ), sizeof( WResID ) ); } else { memcpy( &(newnode->Info), &newres, sizeof(WResResInfo) ); } /* read the extra bytes (if any) */ if( extrabytes > 0 ) { error = WResReadExtraWResID( &(newnode->Info.ResName), handle ); } if( ver < 2 ) { langnode = WRESALLOC( sizeof(WResLangNode) ); if( langnode == NULL ) { error = TRUE; WRES_ERROR( WRS_MALLOC_FAILED ); } if( !error ) { langnode->data = NULL; langnode->fileInfo = fileinfo; langnode->Info.MemoryFlags = newres1.MemoryFlags; langnode->Info.Offset = newres1.Offset; langnode->Info.Length = newres1.Length; langnode->Info.lang.lang = DEF_LANG; langnode->Info.lang.sublang = DEF_SUBLANG; ResAddLLItemAtEnd( (void **)&(newnode->Head), (void **)&(newnode->Tail), langnode ); } } else { error = readLangInfoList( handle, newnode, fileinfo ); } } if( !error ) { /* add the resource node to the linked list */ ResAddLLItemAtEnd( (void **)&(currtype->Head), (void **)&(currtype->Tail), newnode ); } } return( error ); } /* readResList */