Ejemplo n.º 1
0
static void newParseStack( parse_stack *stack )
{
    /* get new stack */
    stack->vstack = RcMemMalloc( STACK_MAX * sizeof( YYSTYPE ) );
    stack->sstack = RcMemMalloc( STACK_MAX * sizeof( YYACTTYPE ) );
    initParseStack( stack );
}
Ejemplo n.º 2
0
extern void RcAddCPPArg( char * newarg )
/***************************************/
{
    size_t  numargs;    /* number of args in list at end of this function */
    char    **arg;
    char    **cppargs;

    cppargs = CmdLineParms.CPPArgs;

    if( CmdLineParms.CPPArgs == NULL ) {
        /* 3 is 1 for the command, 1 for newarg, 1 for NULL */
        numargs = 3;
        cppargs = RcMemMalloc( numargs * sizeof( char * ) );
        /* cppargs[0] is reserved for the name of the command so set it */
        /* to the null string for now */
        cppargs[0] = "";
    } else {
        arg = CmdLineParms.CPPArgs;
        while( *arg != NULL ) {
            arg++;
        }
        /* + 2 for the NULL arg and the new arg */
        numargs = ( arg - CmdLineParms.CPPArgs ) + 2;
        cppargs = RcMemRealloc( cppargs, numargs * sizeof( char * ) );
    }

    cppargs[numargs - 2] = RcMemMalloc( strlen( newarg ) + 1 );
    strcpy( cppargs[numargs - 2], newarg );
    cppargs[numargs - 1] = NULL;

    CmdLineParms.CPPArgs = cppargs;
} /* RcAddCPPArg */
Ejemplo n.º 3
0
static int readObjectTable( ExeFileInfo * exe )
/*********************************************/
{
    RcStatus    error;

    exe->u.PEInfo.Objects = RcMemMalloc( exe->u.PEInfo.WinHead->num_objects
                                * sizeof(pe_object) );
    error = SeekRead( exe->Handle, exe->WinHeadOffset + sizeof(pe_header),
                exe->u.PEInfo.Objects,
                exe->u.PEInfo.WinHead->num_objects * sizeof(pe_object) );
    switch( error ) {
    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( error != RS_OK );
}
Ejemplo n.º 4
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 = RcMemMalloc( 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 );
}
Ejemplo n.º 5
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 */
Ejemplo n.º 6
0
extern void RcIoTextInputInit( void )
/***********************************/
{
    InStack.Buffer = RcMemMalloc( IO_BUFFER_SIZE );
    InStack.BufferSize = IO_BUFFER_SIZE;
    InStack.Current = InStack.Stack;
} /* RcIoTextInputInit */
Ejemplo n.º 7
0
ToolBar *SemCreateToolBar( void ) {
    ToolBar     *ret;

    ret = RcMemMalloc( sizeof( ToolBar ) );
    ret->last = &ret->first;
    ret->nodecnt = 1;
    initToolBarItems( &ret->first );
    return( ret );
}
Ejemplo n.º 8
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 */
Ejemplo n.º 9
0
extern PresParamListOS2 *SemOS2NewPresParamList( PresParamsOS2 presparam )
/************************************************************************/
{
    PresParamListOS2    *newlist;

    newlist = RcMemMalloc( sizeof( PresParamListOS2 ) );
    newlist->head = NULL;
    newlist->tail = NULL;
    return( SemOS2AppendPresParam( newlist, presparam ) );
}
Ejemplo n.º 10
0
extern FullDiagCtrlList *SemEmptyDiagCtrlList( void )
/***************************************************/
{
    FullDiagCtrlList    *newlist;

    newlist = RcMemMalloc( sizeof( FullDiagCtrlList ) );
    newlist->head = NULL;
    newlist->tail = NULL;
    newlist->numctrls = 0;
    return( newlist );
}
Ejemplo n.º 11
0
static FullDiagCtrlListOS2 *SemOS2EmptyDiagCtrlList( void )
/*********************************************************/
{
    FullDiagCtrlListOS2     *newlist;

    newlist = RcMemMalloc( sizeof(FullDiagCtrlListOS2) );
    newlist->head = NULL;
    newlist->tail = NULL;
    newlist->numctrls = 0;
    return( newlist );
}
Ejemplo n.º 12
0
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 );
}
Ejemplo n.º 13
0
static FullFontDir * NewFontDir( void )
/*************************************/
{
    FullFontDir *   newdir;

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

    return( newdir );
}
Ejemplo n.º 14
0
extern FullDialogBoxControl *SemInitDiagCtrl( void )
/**************************************************/
{
    FullDialogBoxControl        *newctrl;

    newctrl = RcMemMalloc( sizeof( FullDialogBoxControl ) );
    newctrl->next = NULL;
    newctrl->prev = NULL;
    newctrl->Win32 = (CmdLineParms.TargetOS == RC_TARGET_OS_WIN32);

    return( newctrl );
} /* SemInitDiagCtrl */
Ejemplo n.º 15
0
static char *MakeFileName( char *infilename, const char *ext )
/************************************************************/
{
    char    name[_MAX_FNAME];
    char    dir[_MAX_DIR];
    char    drive[_MAX_DRIVE];
    char    xext[_MAX_EXT];
    size_t  len;
    char    *out;

    len = strlen( infilename ) + 1;
    if( ext == NULL ) {
        out = RcMemMalloc( len );
        strcpy( out, infilename );
    } else {
        _splitpath( infilename, drive, dir, name, xext );
        out = RcMemMalloc( len - strlen( xext ) + strlen( ext ) + 1 );
        _makepath( out, drive, dir, name, ext );
    }
    return( out );
} /* MakeFileName */
Ejemplo n.º 16
0
static int OpenResFileInfo( ExeType type )
/****************************************/
{
    int             rc;
    ExtraRes        *curfile;


    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.ResFiles = RcMemMalloc( sizeof( ResFileInfo ) );
        Pass2Info.ResFiles->name = NULL;
        Pass2Info.ResFiles->IsOpen = FALSE;
        Pass2Info.ResFiles->Handle = NIL_HANDLE;
        Pass2Info.ResFiles->Dir = NULL;
        return( TRUE );
    }

    curfile = RcMemMalloc( sizeof( ExtraRes ) );
    curfile->next = CmdLineParms.ExtraResFiles;
    CmdLineParms.ExtraResFiles = curfile;

    if( CmdLineParms.Pass2Only ) {
        strcpy( curfile->name, CmdLineParms.InFileName );
    } else {
        strcpy( curfile->name, CmdLineParms.OutResFileName );
    }

    rc = OpenResFiles( CmdLineParms.ExtraResFiles, &Pass2Info.ResFiles,
                  &Pass2Info.AllResFilesOpen, type,
                  CmdLineParms.InExeFileName );

    return( rc );

} /* OpenResFileInfo */
Ejemplo n.º 17
0
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 );
}
Ejemplo n.º 18
0
extern FullDialogBoxControlOS2 *SemOS2InitDiagCtrl( void )
/********************************************************/
{
    FullDialogBoxControlOS2     *newctrl;

    newctrl = RcMemMalloc( sizeof(FullDialogBoxControlOS2) );
    newctrl->next = NULL;
    newctrl->prev = NULL;
    newctrl->children = NULL;
    newctrl->framectl = 0;
    newctrl->presParams = NULL;

    return( newctrl );
}
Ejemplo n.º 19
0
static RcBuffer * NewRcBuffer( void )
/***********************************/
{
    RcBuffer *  new_buff;

    new_buff = RcMemMalloc( sizeof(RcBuffer) );
    new_buff->IsDirty = FALSE;
    new_buff->Count = 0;
    new_buff->BytesRead = 0;
    new_buff->NextChar = new_buff->Buffer;
    memset( new_buff->Buffer, 0, RC_BUFFER_SIZE );

    return( new_buff );
} /* NewRcBuffer */
Ejemplo n.º 20
0
void SemAddToolBarItem( ToolBar *toolbar, uint_16 item ) {

    ToolBarItems        *node;

    if( toolbar->last->cnt == TB_ITEM_CNT ) {
        toolbar->last->next = RcMemMalloc( sizeof( ToolBarItems ) );
        toolbar->last = toolbar->last->next;
        initToolBarItems( toolbar->last );
        toolbar->nodecnt++;
    }
    node = toolbar->last;
    node->items[ node->cnt ] = item;
    node->cnt++;
}
Ejemplo n.º 21
0
FullMenu *SemNewMenu( FullMenuItem firstitem )
/*********************************************/
{
    FullMenu       *newmenu;
    FullMenuItem   *newitem;

    newmenu = RcMemMalloc( sizeof(FullMenu) );
    newitem = RcMemMalloc( sizeof(FullMenuItem) );

    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 );
}
Ejemplo n.º 22
0
FullAccelTableOS2 *SemOS2NewAccelTable( FullAccelEntryOS2 firstentry )
/***************************************************************/
{
    FullAccelTableOS2   *newtable;
    FullAccelEntryOS2   *newentry;

    newtable = RcMemMalloc( sizeof( FullAccelTableOS2 ) );
    newentry = RcMemMalloc( 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 );
}
Ejemplo n.º 23
0
extern FullStringTable *SemOS2NewStringTable( void )
/**************************************************/
{
    FullStringTable     *newtable;

    newtable = RcMemMalloc( 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 */
Ejemplo n.º 24
0
static RcStatus readDBTable( int fp ) {
    int                 ret;
    int                 size;

    size = charInfo.header.num_entries * sizeof( uint_16 );
    charInfo.entries = RcMemMalloc( size );
    ret = RcRead( fp, charInfo.entries, size );
    if( ret != size ) {
        if( ret == -1 ) {
            return( RS_READ_ERROR );
        } else {
            return( RS_READ_INCMPLT );
        }
    }
    return( RS_OK );
}
Ejemplo n.º 25
0
static FullDialogBoxHeader *NewDialogBoxHeader( void )
/****************************************************/
{
    FullDialogBoxHeader     *newheader;

    newheader = RcMemMalloc( sizeof( FullDialogBoxHeader ) );

    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) {
        newheader->Win32 = FALSE;
        newheader->u.Head.Style = 0L;
        newheader->u.Head.NumOfItems = 0;
        newheader->u.Head.Size.x = 0;
        newheader->u.Head.Size.y = 0;
        newheader->u.Head.Size.width = 0;
        newheader->u.Head.Size.height = 0;
        newheader->u.Head.MenuName = NULL;
        newheader->u.Head.ClassName = NULL;
        newheader->u.Head.Caption = NULL;
        newheader->u.Head.PointSize = 0;
        newheader->u.Head.FontName = NULL;
    } else {
        newheader->Win32 = TRUE;
        newheader->u.Head32.Head.Style = 0L;
        newheader->u.Head32.Head.ExtendedStyle = 0L;
        newheader->u.Head32.Head.NumOfItems = 0;
        newheader->u.Head32.Head.Size.x = 0;
        newheader->u.Head32.Head.Size.y = 0;
        newheader->u.Head32.Head.Size.width = 0;
        newheader->u.Head32.Head.Size.height = 0;
        newheader->u.Head32.Head.MenuName = NULL;
        newheader->u.Head32.Head.ClassName = NULL;
        newheader->u.Head32.Head.Caption = NULL;
        newheader->u.Head32.Head.PointSize = 0;
        newheader->u.Head32.Head.FontName = NULL;

        newheader->u.Head32.ExHead.FontWeight = 0;
        newheader->u.Head32.ExHead.FontItalic = 0;
        newheader->u.Head32.ExHead.FontExtra = 1;
        newheader->u.Head32.ExHead.HelpId = 0L;
        newheader->u.Head32.ExHead.FontWeightDefined = FALSE;
        newheader->u.Head32.ExHead.FontItalicDefined = FALSE;
    }

    newheader->StyleGiven = FALSE;

    return( newheader );
} /* NewDialogBoxHeader */
Ejemplo n.º 26
0
static RcStatus readDBIndex( WResFileID fp )
{
    int                 ret;
    int                 size;

    size = charInfo.header.num_indices * sizeof( DBIndexEntry );
    charInfo.index = RcMemMalloc( size );
    ret = RcRead( fp, charInfo.index, size );
    if( ret != size ) {
        if( ret == -1 ) {
            return( RS_READ_ERROR );
        } else {
            return( RS_READ_INCMPLT );
        }
    }
    return( RS_OK );
}
Ejemplo n.º 27
0
extern int RcPass2IoInit( void )
/******************************/
{
    int     noerror;
    int     tmpexe_exists;

    memset( &Pass2Info, '\0', sizeof( RcPass2Info ) );
    Pass2Info.IoBuffer = RcMemMalloc( IO_BUFFER_SIZE );
    MakeTmpInSameDir( CmdLineParms.OutExeFileName, Pass2Info.TmpFileName,
                            "tmp" );
    noerror = openExeFileInfoRO( CmdLineParms.InExeFileName,
                    &(Pass2Info.OldFile) );
    if( noerror ) {
        noerror = openNewExeFileInfo( Pass2Info.TmpFileName,
                                      &(Pass2Info.TmpFile) );
    }
    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 ) {
        RcMemFree( Pass2Info.IoBuffer );
        Pass2Info.IoBuffer = NULL;
        ClosePass2FilesAndFreeMem();
        if( tmpexe_exists ) {
            remove( Pass2Info.TmpFileName );
            UnregisterTmpFile( Pass2Info.TmpFileName );
        }
    }

    return( noerror );
} /* RcPass2IoInit */
Ejemplo n.º 28
0
static FullStringTableBlock *newStringTableBlock( void )
/******************************************************/
{
    FullStringTableBlock        *newblock;

    newblock = RcMemMalloc( 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 */
Ejemplo n.º 29
0
extern FullAccelTableOS2 *SemOS2AddAccelEntry( FullAccelEntryOS2 currentry,
                                               FullAccelTableOS2 * currtable )
/******************************************************************/
{
    FullAccelEntryOS2     *newentry;

    newentry = RcMemMalloc( 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 );
}
Ejemplo n.º 30
0
static char *CheckExtension( char *filename, const char *defext )
/***************************************************************/
{
    char    name[_MAX_FNAME];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    ext[_MAX_EXT];
    size_t  len;
    char    *out;

    out = filename;
    _splitpath( filename, drive, dir, name, ext );
    if( *ext == '\0' ) {
        len = strlen( filename ) + strlen( defext ) + 1;
        RcMemFree( filename );
        out = RcMemMalloc( len );
        _makepath( out, drive, dir, name, defext );
    }
    return( out );
} /* CheckExtension */