openal-soft/al/extension.cpp

80 lines
2.1 KiB
C++
Raw Normal View History

2007-11-13 18:02:18 -08:00
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2007 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2007-11-13 18:02:18 -08:00
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
2008-01-16 14:09:04 -08:00
#include "config.h"
2019-07-28 21:29:59 -07:00
#include <cctype>
2019-01-09 19:42:40 +01:00
#include <cstdlib>
#include <cstring>
2007-11-13 18:02:18 -08:00
#include "AL/al.h"
#include "AL/alc.h"
2019-07-28 21:29:59 -07:00
#include "alcontext.h"
#include "alexcpt.h"
#include "alstring.h"
2019-07-28 21:29:59 -07:00
#include "opthelpers.h"
2007-11-13 18:02:18 -08:00
2010-03-19 14:34:18 -07:00
AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
START_API_FUNC
2007-11-13 18:02:18 -08:00
{
2018-11-16 06:08:25 -08:00
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return AL_FALSE;
2010-03-16 17:35:51 -07:00
if(!extName)
SETERR_RETURN(context, AL_INVALID_VALUE, AL_FALSE, "NULL pointer");
2012-04-24 03:52:21 -07:00
2018-11-16 06:08:25 -08:00
size_t len{strlen(extName)};
2019-07-30 09:05:54 -07:00
const char *ptr{context->mExtensionList};
2013-10-07 12:05:39 -07:00
while(ptr && *ptr)
{
if(al::strncasecmp(ptr, extName, len) == 0 && (ptr[len] == '\0' || isspace(ptr[len])))
2018-11-16 06:08:25 -08:00
return AL_TRUE;
2019-01-07 12:37:13 +01:00
if((ptr=strchr(ptr, ' ')) != nullptr)
2007-11-13 18:02:18 -08:00
{
2013-10-07 12:05:39 -07:00
do {
++ptr;
} while(isspace(*ptr));
2007-11-13 18:02:18 -08:00
}
}
2018-11-16 06:08:25 -08:00
return AL_FALSE;
2007-11-13 18:02:18 -08:00
}
END_API_FUNC
2007-11-13 18:02:18 -08:00
2010-03-22 15:12:20 -07:00
AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
START_API_FUNC
2007-11-13 18:02:18 -08:00
{
2018-11-16 06:08:25 -08:00
if(!funcName) return nullptr;
return alcGetProcAddress(nullptr, funcName);
2007-11-13 18:02:18 -08:00
}
END_API_FUNC
2007-11-13 18:02:18 -08:00
2010-03-19 14:34:18 -07:00
AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
START_API_FUNC
2007-11-13 18:02:18 -08:00
{
if(!enumName) return static_cast<ALenum>(0);
2018-11-16 06:08:25 -08:00
return alcGetEnumValue(nullptr, enumName);
2007-11-13 18:02:18 -08:00
}
END_API_FUNC