Пример #1
0
int ReturnNLMVersionInfoFromFile( const char *__pathName, long *majorVersion,
                                  long *minorVersion, long *revision, long *year,
                                  long *month, long *day, char *copyrightString,
                                  char *description )
{
    int             handle, bytes, offset;
    bool            found = false;
    nlm_header_3    *verPtr;
    unsigned char   buffer[READ_SIZE];

    handle = open( __pathName, O_BINARY | O_RDONLY );
    if( handle != EFAILURE ) {
        bytes = read( handle, buffer, READ_SIZE );
        close( handle );
        if( bytes == READ_SIZE ) {
            offset = offsetof( nlm_header, descriptionLength );
            if( description != NULL ) {
                LenToASCIIZStr( description, buffer + offset );
            }
            for( ; offset < READ_SIZE; offset++ ) {
                if( !memcmp( VERSION_SIGNATURE, buffer + offset, VERSION_SIGNATURE_LENGTH ) ) {
                    found = true;
                    break;
                }
            }
            if( found ) {
                verPtr = (nlm_header_3 *)( buffer + offset );
                if( majorVersion != NULL ) {
                    *majorVersion = verPtr->majorVersion;
                }
                if( minorVersion != NULL ) {
                    *minorVersion = verPtr->minorVersion;
                }
                if( revision != NULL ) {
                    *revision = verPtr->revision;
                }
                if( year != NULL ) {
                    *year = verPtr->year;
                }
                if( month != NULL ) {
                    *month = verPtr->month;
                }
                if( day != NULL ) {
                    *day = verPtr->day;
                }
                if( copyrightString != NULL ) {
                    found = false;
                    for( ; offset < READ_SIZE; offset++ ) {
                        if( !memcmp( COPYRIGHT_SIGNATURE, buffer + offset, COPYRIGHT_SIGNATURE_LENGTH ) ) {
                            found = true;
                            break;
                        }
                    }
                    if( found ) {
                        LenToASCIIZStr( copyrightString, buffer + offset + COPYRIGHT_SIGNATURE_LENGTH );
                    }
                }
                return( ESUCCESS );
            }
        }
    }
    return( EFAILURE );
}
Пример #2
0
int ReturnNLMVersionInfoFromFile( char *__pathName, LONG *majorVersion,
                                  LONG *minorVersion, LONG *revision, LONG *year,
                                  LONG *month, LONG *day, char *copyrightString,
                                  char *description )
{
    int         handle, bytes, offset, found = FALSE;
    LONG        *verPtr;
    NLMHDR      *nlmHeader;
    BYTE        buffer[READ_SIZE];

    handle = open( __pathName, O_BINARY | O_RDONLY );
    if( handle != EFAILURE ) {
        bytes = read( handle, buffer, READ_SIZE );
        close( handle );
        if( bytes == READ_SIZE ) {
            if( description ) {
                nlmHeader = (NLMHDR *)buffer;
                LenToASCIIZStr( description, &(nlmHeader->descriptionLength) );
            }

            for( offset = 0; !found && ( offset < READ_SIZE ); offset++ ) {
                if( !memcmp( "VeRsIoN", &buffer[offset], 7 ) ) {
                    found = TRUE;
                }
            }
            if( found ) {
                verPtr = (LONG *)(&buffer[offset + 7]);
                if( majorVersion ) {
                    *majorVersion = *verPtr++;
                }
                if( minorVersion ) {
                    *minorVersion = *verPtr++;
                }
                if( revision ) {
                    *revision = *verPtr++;
                }
                if( year ) {
                    *year = *verPtr++;
                }
                if( month ) {
                    *month = *verPtr++;
                }
                if( day ) {
                    *day = *verPtr++;
                }
                found = FALSE;
                for( ; !found && (offset < READ_SIZE); offset++ ) {
                    if( !memcmp( "CoPyRiGhT", &buffer[offset], 9 ) ) {
                        found = TRUE;
                    }
                }
                if( found ) {
                    if( copyrightString ) {
                        LenToASCIIZStr( copyrightString, &buffer[offset + 9] );
                    }
                }
                return( ESUCCESS );
            }
        }
    }
    return( EFAILURE );
}