Beispiel #1
0
bool InitMsg( void )
{
    char        msg_buff[RESOURCE_MAX_SIZE];
#if defined( IDE_PGM ) || !defined( __WATCOMC__ )
    char        imageName[_MAX_PATH];
#else
    char        *imageName;
#endif

#if defined( IDE_PGM )
    _cmdname( imageName );
#elif !defined( __WATCOMC__ )
    get_dllname( imageName, sizeof( imageName ) );
#else
    imageName = _LpDllName;;
#endif
    BannerPrinted = false;
    hInstance.status = 0;
    if( OpenResFile( &hInstance, imageName ) ) {
        MsgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( Msg_Get( MSG_GENERAL_HELP_0, msg_buff ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    WriteStdOutInfo( NO_RES_MESSAGE, ERR, NULL );
    return( false );
}
Beispiel #2
0
int InitMsg( void )
{
    char        buff[_MAX_PATH];
#if defined( IDE_PGM ) || !defined( __WATCOMC__ )
    char        imageName[_MAX_PATH];
#else
    char        *imageName;
#endif

    hInstance.handle = NIL_HANDLE;
#if defined( IDE_PGM )
    _cmdname( imageName );
#elif !defined( __WATCOMC__ )
    get_dllname( imageName, sizeof( imageName ) );
#else
    imageName = _LpDllName;;
#endif
    BannerPrinted = false;
    if( !OpenResFile( &hInstance, imageName ) ) {
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( Msg_Get( MSG_PRODUCT, buff ) ) {
                Res_Flag = EXIT_SUCCESS;
                return( Res_Flag );
            }
        }
        CloseResFile( &hInstance );
        hInstance.handle = NIL_HANDLE;
    }
    WriteStdOutInfo( NO_RES_MESSAGE, ERR, NULL );
    Res_Flag = EXIT_FAILURE;
    return( Res_Flag );
}
Beispiel #3
0
bool InitRcMsgs( void )
{
    bool        error;
    char        testbuf[1];
#if defined( IDE_PGM ) || !defined( __WATCOMC__ )
    char        imageName[_MAX_PATH];
#else
    char        *imageName;
#endif

#if defined( IDE_PGM )
    _cmdname( imageName );
#elif !defined( __WATCOMC__ )
    get_dllname( imageName, sizeof( imageName ) );
#else
    imageName = _LpDllName;
#endif
    /*
     * swap open functions so this file handle is not buffered.
     * This makes it easier for layer0 to fool WRES into thinking
     * that the resource information starts at offset 0
     */
    error = RCOpenResFile( &Instance, imageName );
    MsgShift = _WResLanguage() * MSG_LANG_SPACING;
    if( !error && !GetRcMsg( USAGE_MSG_FIRST, testbuf, sizeof( testbuf ) ) ) {
        error = true;
    }
    if( error ) {
        RcFatalError( ERR_RCSTR_NOT_FOUND );
    }
    return( true );
}
Beispiel #4
0
static bool MsgReadErrArray( void )
#endif
{
    int         i;
    char        buffer[128];
    unsigned    msg_shift;

    msg_shift = _WResLanguage() * MSG_LANG_SPACING;
    for( i = ERR_FIRST_MESSAGE; i <= ERR_LAST_MESSAGE; i++ ) {
#if !defined(__WINDOWS__)
        if( WResLoadString( &hInstance, i + msg_shift, (lpstr)buffer, sizeof( buffer ) ) <= 0 ) {
#else
        if( LoadString( inst, i + msg_shift, (LPSTR)buffer, sizeof( buffer ) ) <= 0 ) {
#endif
            if( i == ERR_FIRST_MESSAGE )
                return( false );
            buffer[0] = '\0';
        }
        MsgArray[i - ERR_FIRST_MESSAGE] = my_alloc( strlen( buffer ) + 1 );
        if( MsgArray[i - ERR_FIRST_MESSAGE] == NULL )
            return( false );
        _fstrcpy( MsgArray[i - ERR_FIRST_MESSAGE], buffer );
    }
    return( true );
}

#if !defined(__WINDOWS__)
bool MsgInit( void )
{
    char        buffer[_MAX_PATH];
#if defined(_PLS)
    char        *fname;
    char        fullpath[_MAX_PATH];
#endif
    bool        rc;

    hInstance.status = 0;
    if( _cmdname( buffer ) != NULL ) {
        rc = OpenResFile( &hInstance, buffer );
#if defined(_PLS)
        if( !rc ) {
            _splitpath2( buffer, fullpath, NULL, NULL, &fname, NULL );
            _makepath( buffer, NULL, NULL, fname, ".exp" );
            _searchenv( buffer, "PATH", fullpath );
            if( fullpath[0] != '\0' ) {
                rc = OpenResFile( &hInstance, fullpath );
            }
        }
#endif
        if( rc ) {
            MsgReadErrArray();
            CloseResFile( &hInstance );
            return( true );
        }
    }
    CloseResFile( &hInstance );
    posix_write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    return( false );
}
Beispiel #5
0
char *ResName( char *res )
{
    static char buff[80];
    unsigned    len;

    len = strlen( res );
    memcpy( buff, res, len );
    buff[len+0] = _WResLanguage() + '0';
    buff[len+1] = '\0';
    return( buff );
}
Beispiel #6
0
static  void    ErrorInit( const char *pgm_name )
{
    hInstance.handle = NIL_HANDLE;
    if( OpenResFile( &hInstance, pgm_name ) )
        return;
    ResFlags |= RF_OPENED;
    if( FindResources( &hInstance ) )
        return;
    if( InitResources( &hInstance ) )
        return;
    MsgShift = _WResLanguage() * MSG_LANG_SPACING;
    ResFlags |= RF_INITIALIZED;
}
Beispiel #7
0
bool Msg_Init( void )
{
    char        name[_MAX_PATH];

    hInstance.status = 0;
    if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
        MsgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( Msg_Get( MSG_USAGE_FIRST, name ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    printf( NO_RES_MESSAGE );
    return( false );
}
Beispiel #8
0
bool AsMsgInit( void )
//********************
{
#ifdef _STANDALONE_
    char        name[_MAX_PATH];

    hInstance.status = 0;
    if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
        msgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( AsMsgGet( USAGE_1, AsResBuffer ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    printf( NO_RES_MESSAGE );
    return( false );
#else
    msgShift = _WResLanguage() * TXT_MSG_LANG_SPACING;
    if( msgShift >= TXT_MSG_SIZE )
        msgShift = 0;
    msgShift -= AS_MSG_BASE;
    return( true );
#endif
}
Beispiel #9
0
bool MsgInit( void )
{
    char        name[_MAX_PATH];
    char        msgbuf[MAX_RESOURCE_SIZE];

    hInstance.status = 0;
    if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
        MsgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( GetMsg( msgbuf, MSG_USAGE_FIRST ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    printf( "%s\n", NO_RES_MESSAGE );
    return( false );
}
Beispiel #10
0
int InitRcMsgs( void )
{
    int         error;
    WResFileID  (* oldopen)(const char *, int, ...);
    char        testbuf[1];
#if defined( IDE_PGM ) || !defined( __WATCOMC__ )
    char        imageName[_MAX_PATH];
#else
    char        *imageName;
#endif

#if defined( IDE_PGM )
    _cmdname( imageName );
#elif !defined( __WATCOMC__ )
    get_dllname( imageName, sizeof( imageName ) );
#else
    imageName = _LpDllName;
#endif
    /*
     * swap open functions so this file handle is not buffered.
     * This makes it easier for layer0 to fool WRES into thinking
     * that the resource information starts at offset 0
     */
    oldopen = WResRtns.open;
    WResRtns.open = open;
    error = OpenResFile( &Instance, imageName );
    WResRtns.open = oldopen;
    if( !error ) {
        RegisterOpenFile( Instance.handle );
        error = FindResources( &Instance );
        if( !error ) {
            error = InitResources( &Instance );
        }
        if( error ) {
            CloseResFile( &Instance );
            UnRegisterOpenFile( Instance.handle );
        }
    }
    MsgShift = _WResLanguage() * MSG_LANG_SPACING;
    if( !error && !GetRcMsg( USAGE_MSG_FIRST, testbuf, sizeof( testbuf ) ) ) {
        error = TRUE;
    }
    if( error ) {
        RcFatalError( ERR_RCSTR_NOT_FOUND );
    }
    return( 1 );
}
Beispiel #11
0
int MsgInit( void )
{
    char        name[_MAX_PATH];

    hInstance.handle = NIL_HANDLE;
    if( _cmdname( name ) != NULL && !OpenResFile( &hInstance, name ) ) {
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( GetMsg( name, MSG_USAGE_FIRST ) ) {
                return( 1 );
            }
        }
    }
    write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    MsgFini();
    return( 0 );
}
Beispiel #12
0
IntlData *LoadInternationalData(
    const char *file_prefix )
{
    IntlData *data;
    int fh;
    res_language_enumeration language;
    unsigned len;
    char *drive;
    char *dir;
    char cmd_name[_MAX_PATH];
    char split_buff[_MAX_PATH2];
    char base[16];

    language = _WResLanguage();
    if( language == RLE_ENGLISH ) {
        return( NULL );
    }
    if( imageName( cmd_name ) == NULL ) {
        return( NULL );
    }
    _splitpath2( cmd_name, split_buff, &drive, &dir, NULL, NULL );
    len = strlen( file_prefix );
    if( len > 6 ) {
        len = 6;
    }
    memcpy( base, file_prefix, len );
    base[len++] = '0';
    base[len++] = '0' + language;
    base[len] = '\0';
    _makepath( cmd_name, drive, dir, base, "." LOCALE_DATA_EXT );
    fh = sopen3( cmd_name, O_RDONLY | O_BINARY, SH_DENYWR );
    if( fh == -1 ) {
        return( NULL );
    }
    data = getData( fh );
    if( data != NULL ) {
        if( data->usage_text == NULL || data->errors_text == NULL ) {
            FreeInternationalData( data );
            data = NULL;
        }
    }
    close( fh );
    return( data );
}
Beispiel #13
0
bool MsgInit( void )
{
#if !defined( USE_TEXT_MSGS )
    char        name[_MAX_PATH];

    hInstance.status = 0;
    if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
        MsgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( MsgGet( MSG_USAGE_BASE, name ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    posix_write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    return( false );
#else
    return( true );
#endif
}
Beispiel #14
0
bool MsgInit( void )
{
    char            name[_MAX_PATH];

    hInstance.handle = NIL_HANDLE;
    if( _cmdname( name ) != NULL && !OpenResFile( &hInstance, name ) ) {
        res_failure = false;
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( MsgGet( WDIS_LITERAL_BASE, name ) ) {
                return( true );
            }
        }
        MsgFini();
    }
    write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    res_failure = true;
    return( false );
}
Beispiel #15
0
int MsgInit( void )
/******************/
{
    char        name[_MAX_PATH];
    char        dummy[MAX_RESOURCE_SIZE];

    hInstance.handle = NIL_HANDLE;
    if( _cmdname( name ) != NULL && !OpenResFile( &hInstance, name ) ) {
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( MsgGet( MSG_USAGE_BASE, dummy ) ) {
                return( true );
            }
        }
    }
    write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    MsgFini();
    return( false );
}
Beispiel #16
0
int Msg_Init( void )
{
    char        name[_MAX_PATH];

    hInstance.handle = NIL_HANDLE;
    if( _cmdname( name ) != NULL && !OpenResFile( &hInstance, name ) ) {
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( Msg_Get( MSG_USAGE_FIRST, name ) ) {
                Res_Flag = EXIT_SUCCESS;
                return( Res_Flag );
            }
        }
        CloseResFile( &hInstance );
        hInstance.handle = NIL_HANDLE;
    }
    Res_Flag = EXIT_FAILURE;
    write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    return Res_Flag;
}
Beispiel #17
0
bool MsgInit( void )
/******************/
{
#ifndef BOOTSTRAP
    static char     name[_MAX_PATH]; // static because address passed outside.

    hInstance.status = 0;
    if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
        MsgShift = _WResLanguage() * MSG_LANG_SPACING;
        if( MsgGet( MSG_USAGE_BASE, name ) ) {
            return( true );
        }
    }
    CloseResFile( &hInstance );
    posix_write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    return( false );
#else
    return( true );
#endif
}
Beispiel #18
0
int MsgInit( void )
/*****************/
{
#ifndef BOOTSTRAP
    static char     name[_MAX_PATH]; // static because address passed outside.

    hInstance.handle = NIL_HANDLE;
    if( _cmdname( name ) != NULL && !OpenResFile( &hInstance, name ) ) {
        if( !FindResources( &hInstance ) && !InitResources( &hInstance ) ) {
            MsgShift = _WResLanguage() * MSG_LANG_SPACING;
            if( MsgGet( MSG_USAGE_BASE, name ) ) {
                return( 1 );
            }
        }
    }
    write( STDOUT_FILENO, NO_RES_MESSAGE, NO_RES_SIZE );
    MsgFini();
    return( 0 );
#else    
    return( 1 );
#endif
}