/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/20// This is included in SDL_internal.h21//#include "SDL_internal.h"2223#ifndef SDL_utils_h_24#define SDL_utils_h_2526// Common utility functions that aren't in the public API2728// Return the smallest power of 2 greater than or equal to 'x'29extern int SDL_powerof2(int x);3031extern Uint32 SDL_CalculateGCD(Uint32 a, Uint32 b);32extern void SDL_CalculateFraction(float x, int *numerator, int *denominator);3334extern bool SDL_startswith(const char *string, const char *prefix);35extern bool SDL_endswith(const char *string, const char *suffix);3637/** Convert URI to a local filename, stripping the "file://"38* preamble and hostname if present, and writes the result39* to the dst buffer. Since URI-encoded characters take40* three times the space of normal characters, src and dst41* can safely point to the same buffer for in situ conversion.42*43* Returns the number of decoded bytes that wound up in44* the destination buffer, excluding the terminating NULL byte.45*46* On error, -1 is returned.47*/48extern int SDL_URIToLocal(const char *src, char *dst);4950typedef enum51{52SDL_OBJECT_TYPE_UNKNOWN,53SDL_OBJECT_TYPE_WINDOW,54SDL_OBJECT_TYPE_RENDERER,55SDL_OBJECT_TYPE_TEXTURE,56SDL_OBJECT_TYPE_JOYSTICK,57SDL_OBJECT_TYPE_GAMEPAD,58SDL_OBJECT_TYPE_HAPTIC,59SDL_OBJECT_TYPE_SENSOR,60SDL_OBJECT_TYPE_HIDAPI_DEVICE,61SDL_OBJECT_TYPE_HIDAPI_JOYSTICK,62SDL_OBJECT_TYPE_THREAD,63SDL_OBJECT_TYPE_TRAY,6465} SDL_ObjectType;6667extern Uint32 SDL_GetNextObjectID(void);68extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid);69extern bool SDL_ObjectValid(void *object, SDL_ObjectType type);70extern int SDL_GetObjects(SDL_ObjectType type, void **objects, int count);71extern void SDL_SetObjectsInvalid(void);7273extern const char *SDL_GetPersistentString(const char *string);7475extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name);7677#endif // SDL_utils_h_787980