예제 #1
0
static void RcMsgV( unsigned errornum, OutputSeverity sev, va_list arglist )
/***************************************************************************/
{
    const LogicalFileInfo       *currfile;
    OutPutInfo                   errinfo;


    InitOutPutInfo( &errinfo );
    errinfo.severity = sev;
    errinfo.flags |= OUTFLAG_ERRID;
    errinfo.errid = errornum;
    switch (errornum) {
    case ERR_CANT_OPEN_FILE:
    case ERR_READING_TMP:
    case ERR_WRITTING_TMP:
    case ERR_OPENING_TMP:
    case ERR_UNEXPECTED_EOF:
    case ERR_WRITTING_FILE:
    case ERR_READING_FILE:
    case ERR_WRITTING_RES_FILE:
    case ERR_CANT_FIND_FILE:
    case ERR_FILENAME_NEEDED:
    case ERR_NO_OPT_SPECIFIED:
    case ERR_NOT_BITMAP_FILE:
    case ERR_NOT_CURSOR_FILE:
    case ERR_NOT_ICON_FILE:
    case ERR_NOT_VALID_EXE:
    case ERR_OUT_OF_MEMORY:
    case ERR_PARSER_INTERNAL:
    case ERR_RENAMEING_TMP_FILE:
    case ERR_TOO_MANY_ARGS:
    case ERR_UNKNOWN_MULT_OPTION:
    case ERR_UNKNOWN_OPTION:
    case ERR_NONNT_RES_TO_NT_EXE:
    case ERR_NONWIN_RES_TO_WIN_EXE:
    case ERR_NONOS2_RES_TO_OS2_EXE:
    case ERR_OLD_RESOURCE_OBJECT:
    case ERR_READING_EXE:
    case ERR_READING_ICON:
    case ERR_READING_CURSOR:
    case ERR_READING_BITMAP:
    case ERR_READING_FONT:
    case ERR_READING_DATA:
    case ERR_READING_RES:
    case ERR_BAD_RES_VER:
    case ERR_INVALID_RES:
    case ERR_INTERNAL:
        /* don't print the filename & line number before these errors */
        GetRcMsg( errornum, errBuffer, sizeof( errBuffer ) );
        vsprintf( rcStrBuf, errBuffer, arglist );
        sprintf( errBuffer, "%s", rcStrBuf );
        break;
    case ERR_RCSTR_NOT_FOUND:
        /* this message means the error strings cannot be obtained from
         * the exe so its text is hard coded */
        sprintf( errBuffer, "Resource strings not found" );
        break;
    case ERR_NO_MSG:
        /* dont print anything */
        return;
    default:
        GetRcMsg( errornum, errBuffer, sizeof( errBuffer ) );
        vsprintf( rcStrBuf, errBuffer, arglist );
        currfile = RcIoGetLogicalFileInfo();
        if (currfile != NULL) {
            errinfo.flags |= OUTFLAG_FILE | OUTFLAG_LINE;
            errinfo.file = currfile->Filename;
            errinfo.lineno = currfile->LineNum;
        }
        sprintf( errBuffer, "%s", rcStrBuf );
        break;
    }
    RcMsgFprintf( stdout, &errinfo, "%s\n", errBuffer );
}
예제 #2
0
static void RcMsgV( unsigned errornum, OutputSeverity sev, va_list arglist )
/***************************************************************************/
{
    const LogicalFileInfo       *currfile;
    int                         len;
    const char                  *prefix;
    OutPutInfo                   errinfo;


    InitOutPutInfo( &errinfo );
    errinfo.severity = sev;
    errinfo.flags |= OUTFLAG_ERRID;
    errinfo.errid = errornum;
    switch( sev ) {
    case SEV_WARNING:
        prefix = "Warning!";
        break;
    case SEV_ERROR:
        prefix = "Error!";
        break;
    case SEV_FATAL_ERR:
        prefix = "Fatal Error!";
        break;
    default:
        prefix = "";
        break;
    }
    switch (errornum) {
    case ERR_CANT_OPEN_FILE:
    case ERR_READING_TMP:
    case ERR_WRITTING_TMP:
    case ERR_OPENING_TMP:
    case ERR_UNEXPECTED_EOF:
    case ERR_WRITTING_FILE:
    case ERR_READING_FILE:
    case ERR_WRITTING_RES_FILE:
    case ERR_CANT_FIND_FILE:
    case ERR_FILENAME_NEEDED:
    case ERR_NO_OPT_SPECIFIED:
    case ERR_NOT_BITMAP_FILE:
    case ERR_NOT_CURSOR_FILE:
    case ERR_NOT_ICON_FILE:
    case ERR_NOT_VALID_EXE:
    case ERR_OUT_OF_MEMORY:
    case ERR_PARSER_INTERNAL:
    case ERR_RENAMEING_TMP_FILE:
    case ERR_TOO_MANY_ARGS:
    case ERR_UNKNOWN_MULT_OPTION:
    case ERR_UNKNOWN_OPTION:
    case ERR_NONNT_RES_TO_NT_EXE:
    case ERR_NONWIN_RES_TO_WIN_EXE:
    case ERR_NONOS2_RES_TO_OS2_EXE:
    case ERR_OLD_RESOURCE_OBJECT:
    case ERR_READING_EXE:
    case ERR_READING_ICON:
    case ERR_READING_CURSOR:
    case ERR_READING_BITMAP:
    case ERR_READING_FONT:
    case ERR_READING_DATA:
    case ERR_READING_RES:
    case ERR_BAD_RES_VER:
    case ERR_INVALID_RES:
    case ERR_INTERNAL:
        /* don't print the filename & line number before these errors */
        GetRcMsg( errornum, errBuffer, sizeof( errBuffer ) );
        vsprintf( rcStrBuf, errBuffer, arglist );
        sprintf( errBuffer, "%s %d: %n%s", prefix, errornum, &len, rcStrBuf );
        break;
    case ERR_RCSTR_NOT_FOUND:
        /* this message means the error strings cannot be obtained from
         * the exe so its text is hard coded */
        sprintf( errBuffer, "%s %d: %nResource strings not found", prefix,
                    errornum, &len );
        break;
    case ERR_NO_MSG:
        /* dont print anything */
        return;
    default:
        GetRcMsg( errornum, errBuffer, sizeof( errBuffer ) );
        vsprintf( rcStrBuf, errBuffer, arglist );
        currfile = RcIoGetLogicalFileInfo();
        if (currfile != NULL) {
            errinfo.flags |= OUTFLAG_FILE | OUTFLAG_LINE;
            errinfo.file = currfile->Filename;
            errinfo.lineno = currfile->LineNum;
#if !defined( DLL_COMPILE )
            sprintf( errBuffer, "%s(%d): %s %d: %n%s", currfile->Filename,
                        currfile->LineNum, prefix,
                        errornum, &len, rcStrBuf );
#else
            sprintf( errBuffer, "%s %d: %n%s", prefix, errornum,
                        &len, rcStrBuf );
#endif
        } else {
            sprintf( errBuffer, "%s %d: %n%s", prefix, errornum, &len,
                        rcStrBuf );
        }
        break;
    }
#if defined( DLL_COMPILE ) || defined( WR_COMPILED )
    RcFprintf( stdout, &errinfo, "%s\n", errBuffer );
#else
    {
        int             indent;
        char            *start;
        char            *end;

        indent = 0;
        start = errBuffer;
        while( strlen( start ) > MAX_LINE_LEN - indent ) {
            end = start + MAX_LINE_LEN - indent;
            while( !isspace( *end ) && end > start ) end--;
            if( end != start )  {
                *end = '\0';
            } else {
                break;
            }
            RcFprintf( stdout, &errinfo, "%*s%s\n", indent, "", start );
            start = end + 1;
            indent = len;
        }
        RcFprintf( stdout, &errinfo, "%*s%s\n", indent, "", start );
    }
#endif
}