strversion.cpp revision 9564a8ca24a6d845630efb74917497db8f6f5571
* IPRT - Version String Parsing. * Copyright (C) 2009 Sun Microsystems, Inc. * This file is part of VirtualBox Open Source Edition (OSE), as * you can redistribute it and/or modify it under the terms of the GNU * 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 * additional information or have any questions. /******************************************************************************* *******************************************************************************/ /******************************************************************************* *******************************************************************************/ #
define ISDIGIT(c) ((c) >=
'0' && (c) <=
'9')
/******************************************************************************* *******************************************************************************/ /* Adjust block count to also count in the very first block */ /* First make a copy of the version string so that we can modify it */ /* Go to the beginning of the block we want to parse */ /* Skip trailing non-digits at the start of the block */ /* Mark ending of the block */ /* Skip trailing warnings */ * Compares two version strings and returns the result. The version string has * to be made of at least one number section, each section delimited by a ".", * e.g. "123.45.67". Trailing zeros at the beginning and non-digits in a section * will be skipped, so "12.foo006" becomes "12.6". * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszVer1 First version string to compare. * @param pszVer2 First version string to compare. * @param pui8Res Pointer uint8_t value where to store the comparison result: * 0 if equal, 1 if pszVer1 is greater, 2 if pszVer2 is greater. /* Figure out which version string is longer and set the corresponding /* Now process each section (delimited by a ".") */ /* If we're in the padding range, there are no numbers left * to compare with anymore, so just assume "0" then */