Path: blob/a-new-beginning/libavutil.xcframework/ios-arm64-simulator/libavutil.framework/Headers/getenv_utf8.h
2 views
/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718#ifndef AVUTIL_GETENV_UTF8_H19#define AVUTIL_GETENV_UTF8_H2021#include <stdlib.h>2223#include "config.h"24#include "mem.h"2526#if HAVE_GETENV && defined(_WIN32)2728#include "libavutil/wchar_filename.h"2930static inline char *getenv_utf8(const char *varname)31{32wchar_t *varname_w, *var_w;33char *var;3435if (utf8towchar(varname, &varname_w))36return NULL;37if (!varname_w)38return NULL;3940var_w = _wgetenv(varname_w);41av_free(varname_w);4243if (!var_w)44return NULL;45if (wchartoutf8(var_w, &var))46return NULL;4748return var;4950// No CP_ACP fallback compared to other *_utf8() functions:51// non UTF-8 strings must not be returned.52}5354static inline void freeenv_utf8(char *var)55{56av_free(var);57}5859static inline char *getenv_dup(const char *varname)60{61return getenv_utf8(varname);62}6364#else6566static inline char *getenv_utf8(const char *varname)67{68return getenv(varname);69}7071static inline void freeenv_utf8(char *var)72{73}7475static inline char *getenv_dup(const char *varname)76{77char *var = getenv(varname);78if (!var)79return NULL;80return av_strdup(var);81}8283#endif // HAVE_GETENV && defined(_WIN32)8485#endif // AVUTIL_GETENV_UTF8_H868788