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