strversion.cpp revision c72f00ff9f31a65845a8722126d37708b61bb6ae
/* $Id$ */
/** @file
* IPRT - Version String Parsing.
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define RTSTRVER_IS_PUNCTUACTION(ch) \
/**
* Parses a out the next block from a version string.
*
* @returns true if numeric, false if not.
* @param pi32Value Where to return the value if numeric.
* @param pcchBlock Where to return the block length.
*/
{
/* Check for end-of-string. */
if (!*psz)
{
*pi32Value = 0;
*pcchBlock = 0;
return false;
}
if (fNumeric)
{
do
psz++;
char *pszNext;
{
fNumeric = false;
*pi32Value = 0;
}
}
else
{
do
psz++;
/* Translate standard pre release terms to negative values. */
if ( *pcchBlock == 2
*pi32Value = -100;
else if ( *pcchBlock == 3
*pi32Value = -200;
else if ( *pcchBlock == 5
*pi32Value = -300;
else if ( *pcchBlock == 4
*pi32Value = -400;
else if ( *pcchBlock == 5
*pi32Value = -500;
else
*pi32Value = 0;
if (*pi32Value < 0)
{
/* Trailing number, if so add it? */
}
}
/* skip punctuation */
if (RTSTRVER_IS_PUNCTUACTION(*psz))
psz++;
return fNumeric;
}
{
/*
* Do a parallel parse of the strings.
*/
{
{
}
)
{
/* 1.0 == 1.0.0.0.0. */;
}
else
{
if (iDiff)
{
/*
* Special hacks for dealing with 3.1.0_BETA1-r99 vs 3.1.0r99.
* Note that 3.1.0_BETA1 vs 3.0.1 is handled above with help of
* negative values returned by the parser.
*/
/** @todo finish at home */
}
}
}
return 0;
}