Example #1
0
static void SemOS2FreeDiagCtrlList( FullDiagCtrlListOS2 *list )
/*************************************************************/
{
    FullDialogBoxControlOS2     *ctrl;
    FullDialogBoxControlOS2     *oldctrl;

    ctrl = list->head;
    while( ctrl != NULL ) {
        /* free the contents of pointers within the structure */
        if( ctrl->ctrl.ClassID != NULL ) {
            RcMemFree( ctrl->ctrl.ClassID );
        }
        if( ctrl->ctrl.Text != NULL ) {
            RcMemFree( ctrl->ctrl.Text );
        }

        oldctrl = ctrl;

        if( ctrl->children != NULL )
            SemOS2FreeDiagCtrlList( ctrl->children );

        SemFreeDataElemList( ctrl->dataListHead );
        SemOS2FreePresParamList( ctrl->presParams );

        ctrl = ctrl->next;

        RcMemFree( oldctrl );
    }

    RcMemFree( list );
} /* SemOS2FreeDiagCtrlList */
Example #2
0
extern void SemOS2AddDlgincResource( WResID *name, char *filename )
/*****************************************************************/
{
    ResLocation loc;
    int         error, err_code;

    loc.start = SemStartResource();
    error = ResWriteString( filename, FALSE, CurrResFile.handle );
    if( error ) {
        err_code = LastWresErr();
        goto OutputWriteError;
    }
    loc.len = SemEndResource( loc.start );
    SemAddResourceFree( name, WResIDFromNum( OS2_RT_DLGINCLUDE ),
                        MEMFLAG_DISCARDABLE | MEMFLAG_MOVEABLE | MEMFLAG_PURE,
                        loc );
    RcMemFree( filename );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    RcMemFree( filename );
    return;
}
Example #3
0
void SemAddResource2( WResID * name, WResID * type, ResMemFlags flags,
                ResLocation loc, char *filename )
/******************************************************************/
{
    int                 error;
    int                 duplicate;
    char *              namestr;
    WResLangType        *lang;

    if( resourceHasLang ) {
        lang = &resourceLang;
        resourceHasLang = FALSE;
    } else {
        lang = &curLang;
    }
    // Windows 95 is currently unable to load an exe that contains a resource
    // with numeric type or numeric identifier greater than 0x7FFF
    // so we warn the user
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        if( !type->IsName && type->ID.Num > 0x7FFF ) {
            namestr = WResIDToStr( name );
            RcWarning( ERR_TYPE_GT_7FFF, namestr );
            RcMemFree( namestr );
        }
        if( !name->IsName && name->ID.Num > 0x7FFF ) {
            namestr = WResIDToStr( name );
            RcWarning( ERR_NAME_GT_7FFF, namestr );
            RcMemFree( namestr );
        }
    }
    error = WResAddResource( type, name, flags, loc.start, loc.len,
                        CurrResFile.dir, lang, &duplicate );

    if (duplicate) {
        if( filename == NULL ) {
            ReportDupResource( name, type, NULL, NULL, TRUE );
        } else {
            ReportDupResource( name, type, filename, CmdLineParms.InFileName,
                               TRUE );
        }
        /* The resource has already been written but we can't add it to */
        /* directory. This will make the .RES file larger but will otherwise */
        /* not affect it since there will be no references to the resource in */
        /* the directory. */
    } else if (error) {
        RcError( ERR_OUT_OF_MEMORY );
        ErrorHasOccured = TRUE;
    }

    if (!CurrResFile.IsWatcomRes) {
        if (!duplicate) {
            copyMSFormatRes( name, type, flags, loc, lang );
        }
        /* erase the temporary file */
        remove( MSFormatTmpFile );
        UnregisterTmpFile( MSFormatTmpFile );
        MSFormatTmpFile[0] = '\0';
    }
}
Example #4
0
void SemAddResourceFree( WResID * name, WResID * type, ResMemFlags flags,
                ResLocation loc )
/***********************************************************************/
{
    SemAddResource2( name, type, flags, loc, NULL );
    RcMemFree( name );
    RcMemFree( type );
}
Example #5
0
static void deleteStack( parse_stack *stack )
{
    if( stack->vstack ) {
        RcMemFree( stack->vstack );
    }
    if( stack->sstack ) {
        RcMemFree( stack->sstack );
    }
}
Example #6
0
void FiniTable( void ) {
/***********************/
    if( charInfo.index != NULL ) {
        RcMemFree( charInfo.index );
        charInfo.index = NULL;
    }
    if( charInfo.entries != NULL ) {
        RcMemFree( charInfo.entries );
        charInfo.entries = NULL;
    }
}
Example #7
0
static void FreeLXFileInfoPtrs( LXExeInfo *info )
/***********************************************/
{
    if( info->Objects != NULL ) {
        RcMemFree( info->Objects );
    }
    if( info->Pages != NULL ) {
        RcMemFree( info->Pages );
    }
    if( info->Res.resources != NULL ) {
        RcMemFree( info->Res.resources );
    }
}
Example #8
0
void static semFreeToolBar( ToolBar *toolbar ) {

    ToolBarItems        *cur;
    ToolBarItems        *tmp;

    cur = toolbar->first.next;
    while( cur != NULL ) {
        tmp = cur;
        cur = cur->next;
        RcMemFree( tmp );
    }
    RcMemFree( toolbar );
}
Example #9
0
static void SemOS2FreeAccelTable( FullAccelTableOS2 * acctable )
/**************************************************************/
{
    FullAccelEntryOS2   *currentry;
    FullAccelEntryOS2   *oldentry;

    currentry = acctable->head;
    while( currentry != NULL ) {
        oldentry = currentry;
        currentry = currentry->next;
        RcMemFree( oldentry );
    }
    RcMemFree( acctable );
}
Example #10
0
static void SemFreeMenuItem( FullMenuItem *curritem )
/****************************************************/
{
    if (curritem->IsPopup) {
        SemFreeSubMenu( curritem->item.popup.submenu );
        if (curritem->item.popup.item.menuData.ItemText != NULL) {
            RcMemFree( curritem->item.popup.item.menuData.ItemText );
        }
    } else {
        if (curritem->item.normal.menuData.ItemText != NULL) {
            RcMemFree( curritem->item.normal.menuData.ItemText );
        }
    }
}
Example #11
0
static YYTOKENTYPE yylexOS2( void )
/*********************************/
{
    YYTOKENTYPE curtoken;
    ScanValue   value;

    curtoken = ScanOS2( &value );

    while( RcIoIsCOrHFile() ) {
        switch( curtoken ) {
        case Y_NAME:
        case Y_STRING:
        case Y_DOS_FILENAME:
            RcMemFree( value.string.string );
            break;
        case Y_INTEGER:
            RcMemFree( value.intinfo.str );
            break;
        case YYEOFTOKEN:
    /**/    goto END_LOOP;
            break;
        case Y_SCAN_ERROR:
            break;          /* ignore unknown chars in a c or h file */
        default:
            break;
        }

        curtoken = ScanOS2( &value );
    }
    END_LOOP:

    switch( curtoken ) {
    case Y_INTEGER:
        yylval.intinfo = value.intinfo;
        break;
    case Y_NAME:
    case Y_STRING:
    case Y_DOS_FILENAME:
        yylval.string = value.string;
        break;
    case Y_SCAN_ERROR:
        RcError( ERR_UNKNOWN_CHAR, value.UnknownChar );
        break;
    default:
        break;
    }
    return( curtoken );
}
Example #12
0
static void AddDiagOption32( DlgHeader32 *head,
                             FullDialogOptions *opt )
/***************************************************/
{
    switch( opt->token ) {
    case Y_STYLE:
        head->Head.Style |= opt->Opt.Style;
        break;
    case Y_EXSTYLE:
        head->Head.ExtendedStyle |= opt->Opt.Exstyle;
        break;
    case Y_MENU:
        if( head->Head.MenuName != NULL ) {
            RcMemFree( head->Head.MenuName );
        }
        head->Head.MenuName = opt->Opt.Name;
        break;
    case Y_CLASS:
        if( head->Head.ClassName != NULL ) {
            RcMemFree( head->Head.ClassName );
        }
        head->Head.ClassName = opt->Opt.Name;
        break;
    case Y_FONT:
        head->Head.Style |= DS_SETFONT;
        head->Head.PointSize = opt->Opt.Font.PointSize;
        if( head->Head.FontName != NULL ) {
            RcMemFree( head->Head.FontName );
        }
        head->Head.FontName = opt->Opt.Font.FontName;
        head->ExHead.FontItalic = opt->Opt.Font.FontItalic;
        head->ExHead.FontWeight = opt->Opt.Font.FontWeight;
        head->ExHead.FontExtra = opt->Opt.Font.FontExtra;
        head->ExHead.FontItalicDefined = opt->Opt.Font.FontItalicDefined;
        head->ExHead.FontWeightDefined = opt->Opt.Font.FontWeightDefined;
        break;
    case Y_CAPTION:
        head->Head.Style |= WS_CAPTION;
        if( head->Head.Caption != NULL ) {
            RcMemFree( head->Head.Caption );
        }
        head->Head.Caption = opt->Opt.Str;
        break;
    case Y_LANGUAGE:
        SemSetResourceLanguage( &opt->Opt.lang, TRUE );
        break;
    }
} /* AddDiagOptions32 */
Example #13
0
static void SemFreeSubMenu( FullMenu *submenu )
/**********************************************/
{
    FullMenuItem   *curritem;
    FullMenuItem   *olditem;

    curritem = submenu->head;
    while( curritem != NULL ) {
        SemFreeMenuItem( curritem );
        olditem = curritem;
        curritem = curritem->next;
        RcMemFree( olditem );
    }

    RcMemFree( submenu );
}
Example #14
0
static RcStatus copyFont( FontInfo * info, int handle, WResID * name,
                                ResMemFlags flags, int *err_code )
/************************************************************************/
{
    RcStatus            error;
    char *              buffer;
    ResLocation         loc;
    long                pos;

    buffer = RcMemMalloc( FONT_BUFFER_SIZE );

    loc.start = SemStartResource();

    if( ResWriteFontInfo( info, CurrResFile.handle ) ) {
        error = RS_WRITE_ERROR;
        *err_code = LastWresErr();
    } else {
        pos = RcTell( handle );
        if( pos == -1 ) {
            error = RS_READ_ERROR;
            *err_code = errno;
        } else {
            error = SemCopyDataUntilEOF( pos, handle, buffer,
                                         FONT_BUFFER_SIZE, err_code );
        }
    }

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

    RcMemFree( buffer );

    return( error );
} /* copyFont */
Example #15
0
static void FreeFontDir( FullFontDir * olddir )
/*********************************************/
{
    FullFontDirEntry *  currentry;
    FullFontDirEntry *  oldentry;

    currentry = olddir->Head;
    while (currentry != NULL) {
        oldentry = currentry;
        currentry = currentry->Next;

        RcMemFree( oldentry );
    }

    RcMemFree( olddir );
}
Example #16
0
static void FreePEFileInfoPtrs( PEExeInfo * info )
/************************************************/
{
    if( info->Objects != NULL ) {
        RcMemFree( info->Objects );
    }
}
Example #17
0
static void FreeNEFileInfoPtrs( NEExeInfo * info )
/*************************************************/
{
    if( info->Seg.Segments != NULL ) {
        RcMemFree( info->Seg.Segments );
        info->Seg.Segments = NULL;
    }
    if( info->Res.Str.StringBlock != NULL ) {
        RcMemFree( info->Res.Str.StringBlock );
        info->Res.Str.StringBlock = NULL;
    }
    if( info->Res.Str.StringList != NULL ) {
        RcMemFree( info->Res.Str.StringList );
        info->Res.Str.StringList = NULL;
    }
} /* FreeNEFileInfoPtrs */
Example #18
0
static void SemOS2FreeHelpTable( FullHelpTableOS2 *helptable )
/************************************************************/
{
    FullHelpEntryOS2   *currentry;
    FullHelpEntryOS2   *oldentry;

    if( helptable != NULL ) {
        currentry = helptable->head;
        while( currentry != NULL ) {
            oldentry = currentry;
            currentry = currentry->next;
            RcMemFree( oldentry );
        }
        RcMemFree( helptable );
    }
}
Example #19
0
static p_action doParse( parse_stack *resource_state )
{
    p_action    what;
    bool        error_state;
    YYTOKENTYPE token;
    int         token_count = 0;

    error_state = false;

    do {
        token = yylexOS2();
        if( error_state ) {
            token_count++;
            if( token_count >= YYERRORTHRESHOLD ) {
                error_state = false;
            }
        }

        what = doAction( token, resource_state );

        if( what == P_SYNTAX ) {
            handleError( token, resource_state, error_state );
            error_state = true;
            yysyntaxerror = true;
            ErrorHasOccured = true;
            token_count = 0;
        } else if( token == Y_INTEGER && yylval.intinfo.str != NULL ) {
            RcMemFree( yylval.intinfo.str );
            yylval.intinfo.str = NULL;
        }
    } while( what != P_ACCEPT && what != P_ERROR );

    return( what );
}
Example #20
0
extern void SemOS2WriteAccelTable( WResID *name, ResMemFlags flags,
                                   uint_32 codepage,
                                   FullAccelTableOS2 *acctable )
/*****************************************************************/
{
    ResLocation     loc;
    int             error;
    int             err_code;

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();
        error = writeAccelTableEntries( acctable, CurrResFile.handle, codepage );
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_ACCELTABLE ), flags, loc );
    } else {
        RcMemFree( name );
    }

    SemOS2FreeAccelTable( acctable );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    SemOS2FreeAccelTable( acctable );
    return;
}
Example #21
0
static void SemOS2FreeHelpSubTable( FullHelpSubTableOS2 *helptable )
/******************************************************************/
{
    FullHelpSubEntryOS2   *currentry;
    FullHelpSubEntryOS2   *oldentry;

    if( helptable != NULL ) {
        currentry = helptable->head;
        while( currentry != NULL ) {
            SemFreeDataElemList( currentry->dataListHead );
            oldentry = currentry;
            currentry = currentry->next;
            RcMemFree( oldentry );
        }
        RcMemFree( helptable );
    }
}
Example #22
0
extern void SemOS2FreeStringTable( FullStringTable *oldtable )
/************************************************************/
{
    FullStringTableBlock        *currblock;
    FullStringTableBlock        *oldblock;

    currblock = oldtable->Head;
    while( currblock != NULL ) {
        ResFreeStringTableBlock( &(currblock->Block) );

        oldblock = currblock;
        currblock = currblock->Next;

        RcMemFree( oldblock );
    }

    RcMemFree( oldtable );
} /* SemOS2FreeStringTable */
Example #23
0
/* The OS/2 dialog templates present us with a problem because the
   template items contain a number of offsets that are not known until
   the template is processed; this means we cannot just start spitting
   the data into a file. Instead we build an in-memory image of the
   resource (the size must be < 64K) and then dump the entire resource
   into the file - which certainly shouldn't hurt performance either.
*/
extern void SemOS2WriteDialogTemplate( WResID *name, ResMemFlags flags,
                                       uint_32 codepage,
                                       FullDiagCtrlListOS2 *ctrls )
/*********************************************************************/
{
    ResLocation              loc;
    int                      err_code;
    int                      error;
    int                      size;
    DialogHeaderOS2          *head = NULL;
    char                     *tmpl;
    char                     *ptr;

    size = sizeof( DialogHeaderOS2 ) + SemOS2CalcControlSize( ctrls );
    if( size > 65536 ) {
        // TODO: Error, template is too big
    }

    tmpl = RcMemMalloc( size );

    head = (DialogHeaderOS2 *)tmpl;
    InitOS2DialogBoxHeader( head, codepage );
    head->Size = size;
    ptr = tmpl + sizeof( DialogHeaderOS2 );

    // Create the DLGTITEM array in memory
    ptr = SemOS2BuildTemplateArray( ptr, ctrls );

    // Dump all other data into memory and update the offsets
    SemOS2DumpTemplateData( tmpl, ptr, ctrls );

    // Write the resource to file
    loc.start = SemStartResource();

    error = ResOS2WriteDlgTemplate( tmpl, size, CurrResFile.handle );
    if( error ) {
        err_code = LastWresErr();
        goto OutputWriteError;
    }

    RcMemFree( tmpl );

    loc.len = SemEndResource( loc.start );
    SemAddResourceFree( name, WResIDFromNum( OS2_RT_DIALOG ), flags, loc );

    SemOS2FreeDiagCtrlList( ctrls );

    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
                strerror( err_code )  );
    ErrorHasOccured = TRUE;
    SemOS2FreeDiagCtrlList( ctrls );
    return;
} /* SemOS2WriteDialogTemplate */
Example #24
0
static void SemOS2FreePresParamList( PresParamListOS2 *list )
/***********************************************************/
{
    PresParamsOS2       *presparam;
    PresParamsOS2       *currparam;

    if( list == NULL )
        return;

    presparam = list->head;
    while( presparam != NULL ) {
        RcMemFree( presparam->Name );
        SemFreeDataElemList( presparam->dataList );
        currparam = presparam;
        presparam = presparam->next;
        RcMemFree( currparam );
    }
    RcMemFree( list );
}
Example #25
0
extern void SemOS2WriteStringTable( FullStringTable *currtable, WResID *type )
/****************************************************************************/
/* write the table identified by currtable as a table of type type and then */
/* free the memory that it occupied */
{
    FullStringTableBlock    *currblock;
    FullStringTable         *tofree;
    WResID                  *name;
    int                     error;
    ResLocation             loc;

    while( currtable != NULL ) {
        for( currblock = currtable->Head; currblock != NULL;
                    currblock = currblock->Next ) {
            loc.start = SemStartResource();

            error = ResOS2WriteStringTableBlock( &(currblock->Block),
                                                 CurrResFile.handle,
                                                 currblock->codePage );
            if( error) {
                RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
                         LastWresErrStr() );
                ErrorHasOccured = TRUE;
                SemOS2FreeStringTable( currtable );
                return;
            }


            loc.len = SemEndResource( loc.start );
            /* +1 because WResID's can't be 0 */
            name = WResIDFromNum( currblock->BlockNum + 1 );
            SemAddResource( name, type, currblock->Flags, loc );
            RcMemFree( name );
        }

        tofree = currtable;
        currtable = currtable->next;
        SemOS2FreeStringTable( tofree );
    }
    RcMemFree( type );
    return;
}
Example #26
0
void SemWriteMenu( WResID *name, ResMemFlags flags, FullMenu *menu,
                   uint_16 tokentype )
/********************************************************************/
{
    MenuHeader      head;
    ResLocation     loc;
    int             error = 0;
    int             err_code;
    uint_8          headerdata[ RES_HEADER_SIZE ];


    if(!ErrorHasOccured) {
        if( tokentype == Y_MENU ) {
            head.Version = 0;    /* currently these fields are both 0 */
            head.HeaderSize = 0;
            loc.start = SemStartResource();
            error = ResWriteMenuHeader( &head, CurrResFile.handle );
        } else if( tokentype == Y_MENU_EX ) {
            head.Version = RES_HEADER_VERSION;
            head.HeaderSize = RES_HEADER_SIZE;
            memset( headerdata, 0, head.HeaderSize );
            ResPadDWord( CurrResFile.handle );
            loc.start = SemStartResource();
            error = ResWriteMenuExHeader( &head, CurrResFile.handle, headerdata );
        } else {
            loc.start = 0;      // Is this valid?
        }
        if(error) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        error = SemWriteSubMenu( menu, &err_code, tokentype );
        if( !error && CmdLineParms.MSResFormat &&
                      CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            error = ResPadDWord( CurrResFile.handle );
        }
        if(error) goto OutputWriteError;
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( RT_MENU ), flags, loc );
    } else {
        RcMemFree( name );
    }

    SemFreeSubMenu( menu );
    return;


OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    SemFreeSubMenu( menu );
    return;
}
Example #27
0
static void AddDiagOption( DialogBoxHeader *head, FullDialogOptions *opt )
/************************************************************************/
{
    switch( opt->token ) {
    case Y_STYLE:
        head->Style |= opt->Opt.Style;
        break;
    case Y_MENU:
        if( head->MenuName != NULL ) {
            RcMemFree( head->MenuName );
        }
        head->MenuName = opt->Opt.Name;
        break;
    case Y_CLASS:
        if( head->ClassName != NULL ) {
            RcMemFree( head->ClassName );
        }
        head->ClassName = opt->Opt.Name;
        break;
    case Y_FONT:
        head->Style |= DS_SETFONT;
        head->PointSize = opt->Opt.Font.PointSize;
        if( head->FontName != NULL ) {
            RcMemFree( head->FontName );
        }
        head->FontName = opt->Opt.Font.FontName;
        break;
    case Y_CAPTION:
        head->Style |= WS_CAPTION;
        if( head->Caption != NULL ) {
            RcMemFree( head->Caption );
        }
        head->Caption = opt->Opt.Str;
        break;
    case Y_EXSTYLE:
        RcWarning( ERR_NT_KEYWORD, SemTokenToString( opt->token ) );
        break;
    }
} /* AddDiagOptions */
Example #28
0
static void QueueEmpty( DirEntryQueue * queue )
/*********************************************/
{
    QueueNode * curr;
    QueueNode * old;

    curr = queue->front;
    while( curr != NULL ) {
        old = curr;
        curr = curr->next;
        RcMemFree( old );
    }

    QueueInit( queue );
} /* QueueEmpty */
Example #29
0
static void handleError( YYTOKENTYPE token, parse_stack *state, bool error_state )
{
    if( !error_state ) {
        switch( token ) {
        case Y_INTEGER:
            RcError( ERR_SYNTAX_STR, yylval.intinfo.str );
            RcMemFree( yylval.intinfo.str );
            break;
        case Y_NAME:
        case Y_STRING:
        case Y_DOS_FILENAME:
            RcError( ERR_SYNTAX_STR, yylval.string.string );
            RcMemFree( yylval.string.string );
            break;
        case Y_SCAN_ERROR:
            break;
        default:
            RcError( ERR_SYNTAX_STR, SemOS2TokenToString( token ) );
            break;
        }
    }

    initParseStack( state );
}
Example #30
0
extern void RcPass2IoShutdown( int noerror )
/******************************************/
{
    ClosePass2FilesAndFreeMem();
    if( Pass2Info.IoBuffer != NULL ) {
        RcMemFree( Pass2Info.IoBuffer );
        Pass2Info.IoBuffer = NULL;
    }
    if( noerror ) {
        ChangeTmpToOutFile( Pass2Info.TmpFileName,
                            CmdLineParms.OutExeFileName);
    } else {
        UnregisterTmpFile( Pass2Info.TmpFileName );
        remove( Pass2Info.TmpFileName );
    }
} /* RcPass2IoShutdown */