RTStrNLenEx.cpp revision e86538a7bc028e823f16f8982e90f0c7ef5d4ece
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync/* $Id$ */
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync/** @file
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * IPRT - RTStrNLenEx.
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync */
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2008 Oracle Corporation
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync *
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * available from http://www.virtualbox.org. This file is free software;
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * you can redistribute it and/or modify it under the terms of the GNU
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * General Public License (GPL) as published by the Free Software
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync *
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * The contents of this file may alternatively be used under the terms
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * of the Common Development and Distribution License Version 1.0
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * VirtualBox OSE distribution, in which case the provisions of the
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * CDDL are applicable instead of those of the GPL.
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync *
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * You may elect to license modified versions of this file under the
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync * terms and conditions of either the GPL or the CDDL or both.
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync */
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync/*******************************************************************************
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync* Header Files *
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync*******************************************************************************/
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync#include <iprt/string.h>
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync#include "internal/iprt.h"
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync
7e960d3a0a8a3a84d7aba2cca45d72b1c31cc97bvboxsyncRTDECL(int) RTStrNLenEx(const char *pszString, size_t cchMax, size_t *pcch)
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync{
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync const char *pchEnd = RTStrEnd(pszString, cchMax);
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync if (!pchEnd)
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync {
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync *pcch = cchMax;
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync return VERR_BUFFER_OVERFLOW;
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync }
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync *pcch = pchEnd - pszString;
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync return VINF_SUCCESS;
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync}
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsyncRT_EXPORT_SYMBOL(RTStrNLenEx);
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync
c34f9b1d1526bb5e7fa22d868de402fc50c318fevboxsync