Exemplo n.º 1
0
static bool readObjectAndPageTable( ExeFileInfo *exe )
/****************************************************/
{
    RcStatus    ret;
    size_t      table_size;

    table_size = exe->u.LXInfo.OS2Head.num_objects * sizeof( object_record );
    exe->u.LXInfo.Objects = RESALLOC( table_size );
    ret = SeekRead( exe->fid,
                exe->WinHeadOffset + exe->u.LXInfo.OS2Head.objtab_off,
                exe->u.LXInfo.Objects, table_size );

    if( ret == RS_OK ) {
        table_size = exe->u.LXInfo.OS2Head.num_pages * sizeof( lx_map_entry );
        exe->u.LXInfo.Pages = RESALLOC( table_size );
        ret = SeekRead( exe->fid,
                    exe->WinHeadOffset + exe->u.LXInfo.OS2Head.objmap_off,
                    exe->u.LXInfo.Pages, table_size );
    }
    switch( ret ) {
    case RS_OK:
        break;
    case RS_READ_ERROR:
        RcError( ERR_READING_EXE, exe->name, strerror( errno ) );
        break;
    case RS_READ_INCMPLT:
        RcError( ERR_UNEXPECTED_EOF, exe->name );
        break;
    default:
        RcError( ERR_INTERNAL, INTERR_UNKNOWN_RCSTATUS );
        break;
    }
    CheckDebugOffset( exe );
    return( ret != RS_OK );
}
Exemplo n.º 2
0
static FullFontDirEntry *NewFontDirEntry( FontInfo *info, char *devicename, char *facename, WResID *fontid )
/**********************************************************************************************************/
{
    FullFontDirEntry        *entry;
    int                     structextra;
    int                     devicelen;
    int                     facelen;

    devicelen = strlen( devicename ) + 1;
    facelen = strlen( facename ) + 1;
    structextra = devicelen + facelen;

    /* -1 for the 1 char in the struct already */
    entry = RESALLOC( sizeof( FullFontDirEntry ) + structextra - 1 );
    entry->Next = NULL;
    entry->Prev = NULL;
    /* -1 for the 1 char in the struct already */
    entry->Entry.StructSize = sizeof( FontDirEntry ) + structextra - 1;
    entry->Entry.FontID = fontid->ID.Num;
    entry->Entry.Info = *info;
    memcpy( &(entry->Entry.DevAndFaceName[0]), devicename, devicelen );
    memcpy( &(entry->Entry.DevAndFaceName[devicelen]), facename, facelen );
    /* set dfDevice and dfFace to be the offset of the strings from the start */
    /* of the FontInfo structure (entry->Entry.Info) */
    entry->Entry.Info.dfDevice = sizeof( FontInfo );
    entry->Entry.Info.dfFace = sizeof( FontInfo ) + devicelen;

    return( entry );
}
Exemplo n.º 3
0
static RcStatus readObjectTable( ExeFileInfo *exe )
/*************************************************/
{
    RcStatus        ret;
    unsigned        objects_size;
    long            file_offset;
    exe_pe_header   *pehdr;

    pehdr = exe->u.PEInfo.WinHead;
    if( IS_PE64( *pehdr ) ) {
        objects_size = PE64( *pehdr ).num_objects * sizeof( pe_object );
        file_offset = exe->WinHeadOffset + sizeof( pe_header64 );
    } else {
        objects_size = PE32( *pehdr ).num_objects * sizeof( pe_object );
        file_offset = exe->WinHeadOffset + sizeof( pe_header );
    }
    exe->u.PEInfo.Objects = RESALLOC( objects_size );
    ret = SeekRead( exe->fid, file_offset, exe->u.PEInfo.Objects, objects_size );
    switch( ret ) {
    case RS_OK:
        break;
    case RS_READ_ERROR:
        RcError( ERR_READING_EXE, exe->name, strerror( errno ) );
        break;
    case RS_READ_INCMPLT:
        RcError( ERR_UNEXPECTED_EOF, exe->name );
        break;
    default:
        RcError( ERR_INTERNAL, INTERR_UNKNOWN_RCSTATUS );
        break;
    }
    CheckDebugOffset( exe );
    return( ret );
}
Exemplo n.º 4
0
extern void RcIoTextInputInit( void )
/***********************************/
{
    InStack.Buffer = RESALLOC( IO_BUFFER_SIZE );
    InStack.BufferSize = IO_BUFFER_SIZE;
    InStack.Current = InStack.Stack;
} /* RcIoTextInputInit */
Exemplo n.º 5
0
static bool ChangeTmpToOutFile( FILE *tmpfile, const char *out_name )
/*******************************************************************/
{
    RcStatus    status;      /* error while deleting or renaming */
    FILE        *outfile;
    size_t      numread;
    char        *buffer;

    buffer = RESALLOC( BUFFER_SIZE );

    status = RS_OK;
    RESSEEK( tmpfile, 0, SEEK_SET );
    outfile = ResOpenFileRW( out_name );
    while( (numread = RESREAD( tmpfile, buffer, BUFFER_SIZE )) != 0 ) {
        if( numread != BUFFER_SIZE && RESIOERR( tmpfile, numread ) ) {
            status = RS_READ_ERROR;
            break;
        }
        if( RESWRITE( outfile, buffer, numread ) != numread ) {
            status = RS_WRITE_ERROR;
            break;
        }
    }
    ResCloseFile( outfile );

    RESFREE( buffer );
    return( status == RS_OK );

} /* ChangeTmpToOutFile */
Exemplo n.º 6
0
static RcStatus copyBitmap( BitmapFileHeader *head, WResFileID fid,
                            WResID *name, ResMemFlags flags, int *err_code )
/**************************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    ResLocation         loc;
    WResFileOffset      pos;

    buffer = RESALLOC( BITMAP_BUFFER_SIZE );

    loc.start = SemStartResource();

    pos = RESTELL( fid );
    if( pos == -1 ) {
        ret = RS_READ_ERROR;
        *err_code = errno;
    } else {
        ret = CopyData( pos, head->Size - sizeof(BitmapFileHeader),
                          fid, buffer, BITMAP_BUFFER_SIZE, err_code );
    }

    loc.len = SemEndResource( loc.start );
    /* add the bitmap to the RES file directory */
    SemAddResourceFree( name, WResIDFromNum( RESOURCE2INT( RT_BITMAP ) ), flags, loc );

    RESFREE( buffer );

    return( ret );
} /* copyBitmap */
Exemplo n.º 7
0
static RcStatus readCurFileDir( WResFileID fid, FullCurDir *dir, int *err_code )
/******************************************************************************/
/* this funtion returns one of the above enum constants */
{
    RcStatus            ret;
    int                 currentry;
    FullCurDirEntry *   entry;

    ret = readIcoCurFileDirHeader( &(dir->Header), fid, 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 = RESALLOC( sizeof(FullCurDirEntry) );
        entry->Next = NULL;
        entry->Prev = NULL;
        entry->IsCurFileEntry = true;
        ret = readCurFileDirEntry( &(entry->Entry.Cur), fid, err_code );
        if( ret != RS_OK ) {
            RESFREE( entry );
        } else {
            ResAddLLItemAtEnd( (void **) &(dir->Head), (void **) &(dir->Tail), entry );
        }
    }
    return( ret );

} /* readCurFileDir */
Exemplo n.º 8
0
static RcStatus copyFont( FontInfo *info, FILE *fp, WResID *name,
                                ResMemFlags flags, int *err_code )
/*********************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    ResLocation         loc;
    long                pos;

    buffer = RESALLOC( FONT_BUFFER_SIZE );

    loc.start = SemStartResource();

    if( ResWriteFontInfo( info, CurrResFile.fp ) ) {
        ret = RS_WRITE_ERROR;
        *err_code = LastWresErr();
    } else {
        pos = RESTELL( fp );
        if( pos == -1L ) {
            ret = RS_READ_ERROR;
            *err_code = errno;
        } else {
            ret = SemCopyDataUntilEOF( pos, fp, buffer, FONT_BUFFER_SIZE, err_code );
        }
    }

    loc.len = SemEndResource( loc.start );
    /* add the font to the RES file directory */
    SemAddResourceFree( name, WResIDFromNum( RESOURCE2INT( RT_FONT ) ), flags, loc );

    RESFREE( buffer );

    return( ret );
} /* copyFont */
Exemplo n.º 9
0
ResLocation SemCopyRawFile( const char *filename )
/************************************************/
{
    WResFileID      fid;
    RcStatus        ret;
    char            *buffer;
    char            full_filename[_MAX_PATH];
    ResLocation     loc;
    int             err_code;
    WResFileOffset  pos;

    buffer = RESALLOC( BUFFER_SIZE );

    if( RcFindResource( filename, full_filename ) == -1 ) {
        RcError( ERR_CANT_FIND_FILE, filename );
        goto HANDLE_ERROR;
    }

    if( AddDependency( full_filename ) )
        goto HANDLE_ERROR;

    fid = RcIoOpenInput( full_filename, false );
    if( fid == WRES_NIL_HANDLE ) {
        RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) );
        goto HANDLE_ERROR;
    }

    loc.start = SemStartResource();

    pos = RESTELL( fid );
    if( pos == -1 ) {
        RcError( ERR_READING_DATA, full_filename, strerror( errno ) );
        RESCLOSE( fid );
        goto HANDLE_ERROR;
    } else {
        ret = SemCopyDataUntilEOF( pos, fid, buffer, BUFFER_SIZE, &err_code );
        if( ret != RS_OK ) {
            ReportCopyError( ret, ERR_READING_DATA, full_filename, err_code );
            RESCLOSE( fid );
            goto HANDLE_ERROR;
        }
    }

    loc.len = SemEndResource( loc.start );

    RESCLOSE( fid );

    RESFREE( buffer );

    return( loc );


HANDLE_ERROR:
    ErrorHasOccured = true;
    loc.start = 0;
    loc.len = 0;
    RESFREE( buffer );
    return( loc );
}
Exemplo n.º 10
0
static bool copyResourcesFromRes( const char *full_filename )
/***********************************************************/
{
    WResFileID          fid;
    WResDir             dir;
    bool                dup_discarded;
    WResDirWindow       wind;
    char                *buffer;
    bool                error;

    buffer = NULL;
    dir = WResInitDir();
    fid = RcIoOpenInput( full_filename, false );
    if( fid == WRES_NIL_HANDLE ) {
        RcError( ERR_CANT_OPEN_FILE, full_filename, strerror( errno ) );
        goto HANDLE_ERROR;
    }

    error = WResReadDir( fid, dir, &dup_discarded );
    if( error ) {
        switch( LastWresStatus() ) {
        case WRS_BAD_SIG:
            RcError( ERR_INVALID_RES, full_filename );
            break;
        case WRS_BAD_VERSION:
            RcError( ERR_BAD_RES_VER, full_filename );
            break;
        default:
            RcError( ERR_READING_RES, full_filename, LastWresErrStr() );
            break;
        }
        goto HANDLE_ERROR;
    }

    if( WResGetTargetOS( dir ) != WResGetTargetOS( CurrResFile.dir ) ) {
        RcError( ERR_RES_OS_MISMATCH, full_filename );
        goto HANDLE_ERROR;
    }
    buffer = RESALLOC( BUFFER_SIZE );
    wind = WResFirstResource( dir );
    while( !WResIsEmptyWindow( wind ) ) {
        copyAResource( fid, &wind, buffer, full_filename );
        wind = WResNextResource( wind, dir );
    }
    RESFREE( buffer );
    WResFreeDir( dir );
    RESCLOSE( fid );
    return( false );

HANDLE_ERROR:
    ErrorHasOccured = true;
    WResFreeDir( dir );
    if( fid != WRES_NIL_HANDLE )
        RESCLOSE( fid );
    return( true );
}
Exemplo n.º 11
0
static bool OpenNewPhysicalFile( PhysFileInfo *phys, const char *filename )
/*************************************************************************/
{
    phys->Filename = RESALLOC( strlen( filename ) + 1 );
    strcpy( phys->Filename, filename );
    phys->IsOpen = false;
    phys->Offset = 0;

    return( OpenPhysicalFile( phys ) );
} /* OpenNewPhysicalFile */
Exemplo n.º 12
0
static bool OpenResFileInfo( ExeType type )
/*****************************************/
{
    bool            error;
    ExtraRes        *curfile;
    char            *name;


    if( ( type == EXE_TYPE_NE_WIN || type == EXE_TYPE_NE_OS2 )
        && CmdLineParms.ExtraResFiles != NULL ) {
        RcError( ERR_FR_NOT_VALID_FOR_WIN );
        return( false );
    }
    Pass2Info.AllResFilesOpen = true;
    if( CmdLineParms.NoResFile ) {
        Pass2Info.ResFile = RESALLOC( sizeof( ResFileInfo ) );
        Pass2Info.ResFile->next = NULL;
        Pass2Info.ResFile->name = NULL;
        Pass2Info.ResFile->IsOpen = false;
        Pass2Info.ResFile->fp = NULL;
        Pass2Info.ResFile->Dir = NULL;
        return( true );
    }

    if( CmdLineParms.Pass2Only ) {
        name = CmdLineParms.InFileName;
    } else {
        name = CmdLineParms.OutResFileName;
    }
    curfile = RESALLOC( sizeof( ExtraRes ) + strlen( name ) );
    curfile->next = CmdLineParms.ExtraResFiles;
    CmdLineParms.ExtraResFiles = curfile;
    strcpy( curfile->name, name );

    error = OpenResFiles( CmdLineParms.ExtraResFiles, &Pass2Info.ResFile,
                  &Pass2Info.AllResFilesOpen, type,
                  CmdLineParms.InExeFileName );

    return( error );

} /* OpenResFileInfo */
Exemplo n.º 13
0
static FullFontDir * NewFontDir( void )
/*************************************/
{
    FullFontDir     *newdir;

    newdir = RESALLOC( sizeof( FullFontDir ) );
    newdir->Head = NULL;
    newdir->Tail = NULL;
    newdir->NumOfFonts = 0;

    return( newdir );
}
Exemplo n.º 14
0
static RcStatus copyCursors( FullCurDir * dir, WResFileID fid, ResMemFlags flags, int *err_code )
/***********************************************************************************************/
/* This function uses the same size of buffers to copy info as for icons */
{
    RcStatus            ret = RS_OK; // should this be RS_PARAM_ERROR ??
    char *              buffer;
    FullCurDirEntry *   entry;
    CurFileDirEntry     fileentry;
    CurHotspot          hotspot;
    BitmapInfoHeader    dibhead;
    ResLocation         loc;

    buffer = RESALLOC( BUFFER_SIZE );

    for( entry = dir->Head; entry != NULL; entry = entry->Next ) {
        /* copy the cursor */
        loc.start = SemStartResource();

        hotspot.X = entry->Entry.Cur.XHotspot;
        hotspot.Y = entry->Entry.Cur.YHotspot;
        if( ResWriteCurHotspot( &hotspot, CurrResFile.fid ) ) {
            ret = RS_WRITE_ERROR;
            *err_code = LastWresErr();
            break;
        }

        /* NOTE: the dibhead structure is filled in as a result of this call */
        ret = copyOneCursor( &(entry->Entry.Cur), fid, buffer,
                        BUFFER_SIZE, &(dibhead), err_code );
        if( ret != RS_OK )
            break;

        loc.len = SemEndResource( loc.start );
        /* add the cursor to the RES file directory */
        SemAddResourceFree( WResIDFromNum( CurrResFile.NextCurOrIcon ),
                WResIDFromNum( RESOURCE2INT( RT_CURSOR ) ), flags, loc );
        /* change the reference in the cursor directory */
        fileentry = entry->Entry.Cur;
        entry->IsCurFileEntry = false;
        entry->Entry.Res.Width = dibhead.Width;
        entry->Entry.Res.Height = dibhead.Height;
        entry->Entry.Res.Planes = dibhead.Planes;
        entry->Entry.Res.BitCount = dibhead.BitCount;
        /* the hotspot data is now part of the components */
        entry->Entry.Res.Length = fileentry.Length + sizeof(CurHotspot);
        entry->Entry.Res.CurID = CurrResFile.NextCurOrIcon;
        CurrResFile.NextCurOrIcon += 1;
    }

    RESFREE( buffer );

    return( ret );
} /* copyCursors */
Exemplo n.º 15
0
extern void RcIoSetLogicalFileInfo( int linenum, const char * filename )
/**********************************************************************/
{
    LogicalFileInfo *   log;

    if( !IsEmptyFileStack( InStack ) ) {
        log = &(InStack.Current->Logical);
        log->LineNum = linenum;
        if( filename != NULL ) {
            if( log->Filename == NULL ) {
                log->Filename = RESALLOC( strlen( filename ) + 1 );
                strcpy( log->Filename, filename );
            } else if( strcmp( log->Filename, filename ) != 0 ) {
                RESFREE( log->Filename );
                log->Filename = RESALLOC( strlen( filename ) + 1 );
                strcpy( log->Filename, filename );
            }
            RcIoSetIsCOrHFlag();
        }
    }
} /* RcIoSetLogicalFileInfo */
Exemplo n.º 16
0
DataElemList *SemNewDataElemList( RawDataItem node )
/**************************************************/
{
    DataElemList    *head;

    head = RESALLOC( sizeof( DataElemList ) );
    head->data[0] = node;
    head->count = 1;
    head->next = NULL;

    return( head );
}
Exemplo n.º 17
0
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 );
}
Exemplo n.º 18
0
extern bool RcPass2IoInit( void )
/******************************/
{
    bool    noerror;
    bool    tmpexe_exists;

    memset( &Pass2Info, 0, sizeof( RcPass2Info ) );
    Pass2Info.IoBuffer = RESALLOC( IO_BUFFER_SIZE );

    noerror = openExeFileInfoRO( CmdLineParms.InExeFileName, &(Pass2Info.OldFile) );
    if( noerror ) {
        Pass2Info.TmpFile.name = "Temporary file 2 (exe)";
        Pass2Info.TmpFile.fp = ResOpenFileTmp( NULL );
        if( Pass2Info.TmpFile.fp == NULL ) {
            RcError( ERR_OPENING_TMP, Pass2Info.TmpFile.name, strerror( errno ) );
            noerror = false;
        }
    }
    tmpexe_exists = noerror;

    if( noerror ) {
        Pass2Info.TmpFile.Type = Pass2Info.OldFile.Type;
        Pass2Info.TmpFile.WinHeadOffset = Pass2Info.OldFile.WinHeadOffset;
        if( Pass2Info.OldFile.Type == EXE_TYPE_PE ) {
            Pass2Info.TmpFile.u.PEInfo.WinHead = &Pass2Info.TmpFile.u.PEInfo.WinHeadData;
            *Pass2Info.TmpFile.u.PEInfo.WinHead = *Pass2Info.OldFile.u.PEInfo.WinHead;
        }
        if( ( Pass2Info.OldFile.Type == EXE_TYPE_NE_WIN || Pass2Info.OldFile.Type == EXE_TYPE_NE_OS2 )
          && CmdLineParms.ExtraResFiles != NULL ) {
            RcError( ERR_FR_NOT_VALID_FOR_WIN );
            noerror = false;
        } else {
            noerror = OpenResFileInfo( Pass2Info.OldFile.Type );
        }
    }

    if( !noerror ) {
        RESFREE( Pass2Info.IoBuffer );
        Pass2Info.IoBuffer = NULL;
        ClosePass2FilesAndFreeMem();
        if( tmpexe_exists ) {
            ResCloseFile( Pass2Info.TmpFile.fp );
            Pass2Info.TmpFile.fp = NULL;
        }
    }

    return( noerror );
} /* RcPass2IoInit */
Exemplo n.º 19
0
FullStringTable *SemOS2NewStringTable( void )
/*******************************************/
{
    FullStringTable     *newtable;

    newtable = RESALLOC( sizeof( FullStringTable ) );
    if( newtable != NULL ) {
        newtable->Head = NULL;
        newtable->Tail = NULL;
        newtable->next = NULL;
        newtable->lang.lang = DEF_LANG;
        newtable->lang.sublang = DEF_SUBLANG;
    }

    return( newtable );
} /* SemOS2NewStringTable */
Exemplo n.º 20
0
static FullStringTableBlock *newStringTableBlock( void )
/******************************************************/
{
    FullStringTableBlock        *newblock;

    newblock = RESALLOC( sizeof( FullStringTableBlock ) );
    if( newblock != NULL ) {
        newblock->Next = NULL;
        newblock->Prev = NULL;
        newblock->BlockNum = 0;
        newblock->UseUnicode = (CmdLineParms.TargetOS == RC_TARGET_OS_WIN32);
        newblock->Flags = 0;
        newblock->codePage = 850;
        ResInitStringTableBlock( &(newblock->Block) );
    }

    return( newblock );
} /* newStringTableBlock */
Exemplo n.º 21
0
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 );
}
Exemplo n.º 22
0
static RcStatus copyIcons( FullIconDir * dir, WResFileID fid, ResMemFlags flags, int *err_code )
/**********************************************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    FullIconDirEntry *  entry;
    BitmapInfoHeader    dibhead;
    ResLocation         loc;

    ret = RS_OK;
    buffer = RESALLOC( BUFFER_SIZE );

    for( entry = dir->Head; entry != NULL; entry = entry->Next ) {
        /* copy the icon */
        loc.start = SemStartResource();

        /* NOTE: the dibhead structure is filled in as a result of this call */
        ret = copyOneIcon( &(entry->Entry.Ico), fid, buffer, BUFFER_SIZE, &(dibhead), err_code );
        if( ret != RS_OK )
            break;

        loc.len = SemEndResource( loc.start );
        /* add the icon to the RES file directory */
        SemAddResourceFree( WResIDFromNum( CurrResFile.NextCurOrIcon ),
                WResIDFromNum( RESOURCE2INT( RT_ICON ) ), flags, loc );
        /* change the reference in the ICON directory */
        entry->IsIcoFileEntry = false;
        entry->Entry.Res.IconID = CurrResFile.NextCurOrIcon;
        entry->Entry.Res.Info.Planes = dibhead.Planes;
        entry->Entry.Res.Info.BitCount = dibhead.BitCount;
        CurrResFile.NextCurOrIcon += 1;
    }

    RESFREE( buffer );

    return( ret );
} /* copyIcons */
Exemplo n.º 23
0
void *PP_Malloc( size_t size )
/****************************/
{
    return( RESALLOC( size ) );
}
Exemplo n.º 24
0
void SemOS2AddSingleLineResource( WResID *name, YYTOKENTYPE type,
                       FullOptFlagsOS2 *fullflags, char *filename )
/*****************************************************************/
{
    ResLocation     start;
    ResMemFlags     flags, flagsMDP, flagsMP;
    char            full_filename[_MAX_PATH];
    static bool     firstIcon = true;

    if( ErrorHasOccured ) {
        RESFREE( name );
        RESFREE( filename );
        return;
    }

    if( RcFindSourceFile( filename, full_filename ) == -1 ) {
        RcError( ERR_CANT_FIND_FILE, filename );
        goto HANDLE_ERROR;
    }

    if( AddDependency( full_filename ) )
        goto HANDLE_ERROR;

    flagsMDP = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE | MEMFLAG_PURE;
    flagsMP  = MEMFLAG_MOVEABLE | MEMFLAG_PURE;

    switch( type ) {
    case Y_DEFAULTICON:
        /* DEFAULTICON doesn't have a name, let's make our own */
        name = RESALLOC( sizeof( WResID ) );
        name->IsName = false;
        name->ID.Num = 999;
        firstIcon    = true;    /* Trigger a warning if we have one already */
        /* Note the fallthrough! */
    case Y_POINTER:
    case Y_ICON:
        if( fullflags != NULL ) {
            SemOS2CheckResFlags( fullflags, 0, MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE, 0 );
            flags = fullflags->flags;
        } else {
            flags = flagsMDP;
        }

        /* Duplicate the first icon encountered as the default icon IFF it
           has resource ID equal to 1
        */
        if( firstIcon && !name->IsName && (name->ID.Num == 999 || name->ID.Num == 1) ) {
            WResID      *id;

            id = RESALLOC( sizeof( WResID ) );
            if( id == NULL )
                break;

            firstIcon  = false;
            id->IsName = false;
            id->ID.Num = 22;
            start = SemCopyRawFileOnly( full_filename );
            SemAddResourceFree( name, WResIDFromNum( OS2_RT_POINTER ), flags, start );

            start = SemCopyRawFileOnly( full_filename );
            SemAddResourceFree( id, WResIDFromNum( OS2_RT_DEFAULTICON ), flagsMDP, start );
        } else {
            start = SemCopyRawFileOnly( full_filename );
            SemAddResourceFree( name, WResIDFromNum( OS2_RT_POINTER ), flags, start );
        }
        break;

    case Y_BITMAP:
        if( fullflags != NULL ) {
            SemOS2CheckResFlags( fullflags, 0, MEMFLAG_MOVEABLE, MEMFLAG_PURE );
            flags = fullflags->flags;
        } else {
            flags = flagsMP;
        }
        start = SemCopyRawFileOnly( full_filename );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_BITMAP ), flags, start );
        break;

    case Y_FONT:
        if( fullflags != NULL ) {
            SemOS2CheckResFlags( fullflags, 0, MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE, MEMFLAG_PURE );
            flags = fullflags->flags;
        } else {
            flags = flagsMDP;
        }
        AddFontResources( name, flags, full_filename );
        break;
    default:
        RESFREE( name );
        break;
    }

    RESFREE( filename );

    return;

HANDLE_ERROR:
    ErrorHasOccured = true;
    RESFREE( name );
    RESFREE( filename );
} /* SemOS2AddSingleLineResource */