13d58139fSopenharmony_ci/* 23d58139fSopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved. 33d58139fSopenharmony_ci * Licensed under Mulan PSL v2. 43d58139fSopenharmony_ci * You can use this software according to the terms and conditions of the Mulan PSL v2. 53d58139fSopenharmony_ci * You may obtain a copy of Mulan PSL v2 at: 63d58139fSopenharmony_ci * http://license.coscl.org.cn/MulanPSL2 73d58139fSopenharmony_ci * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 83d58139fSopenharmony_ci * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 93d58139fSopenharmony_ci * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 103d58139fSopenharmony_ci * See the Mulan PSL v2 for more details. 113d58139fSopenharmony_ci * Description: swscanf_s function 123d58139fSopenharmony_ci * Create: 2014-02-25 133d58139fSopenharmony_ci */ 143d58139fSopenharmony_ci 153d58139fSopenharmony_ci#include "securec.h" 163d58139fSopenharmony_ci 173d58139fSopenharmony_ci/* 183d58139fSopenharmony_ci * <FUNCTION DESCRIPTION> 193d58139fSopenharmony_ci * The swscanf_s function is the wide-character equivalent of the sscanf_s function 203d58139fSopenharmony_ci * The swscanf_s function reads data from buffer into the location given by 213d58139fSopenharmony_ci * each argument. Every argument must be a pointer to a variable with a type 223d58139fSopenharmony_ci * that corresponds to a type specifier in format. The format argument controls 233d58139fSopenharmony_ci * the interpretation of the input fields and has the same form and function 243d58139fSopenharmony_ci * as the format argument for the scanf function. If copying takes place between 253d58139fSopenharmony_ci * strings that overlap, the behavior is undefined. 263d58139fSopenharmony_ci * 273d58139fSopenharmony_ci * <INPUT PARAMETERS> 283d58139fSopenharmony_ci * buffer Stored data. 293d58139fSopenharmony_ci * format Format control string, see Format Specifications. 303d58139fSopenharmony_ci * ... Optional arguments. 313d58139fSopenharmony_ci * 323d58139fSopenharmony_ci * <OUTPUT PARAMETERS> 333d58139fSopenharmony_ci * ... the converted value stored in user assigned address 343d58139fSopenharmony_ci * 353d58139fSopenharmony_ci * <RETURN VALUE> 363d58139fSopenharmony_ci * Each of these functions returns the number of fields successfully converted 373d58139fSopenharmony_ci * and assigned; The return value does not include fields that were read but not 383d58139fSopenharmony_ci * assigned. 393d58139fSopenharmony_ci * A return value of 0 indicates that no fields were assigned. 403d58139fSopenharmony_ci * return -1 if an error occurs. 413d58139fSopenharmony_ci */ 423d58139fSopenharmony_ciint swscanf_s(const wchar_t *buffer, const wchar_t *format, ...) 433d58139fSopenharmony_ci{ 443d58139fSopenharmony_ci int ret; /* If initialization causes e838 */ 453d58139fSopenharmony_ci va_list argList; 463d58139fSopenharmony_ci 473d58139fSopenharmony_ci va_start(argList, format); 483d58139fSopenharmony_ci ret = vswscanf_s(buffer, format, argList); 493d58139fSopenharmony_ci va_end(argList); 503d58139fSopenharmony_ci (void)argList; /* To clear e438 last value assigned not used , the compiler will optimize this code */ 513d58139fSopenharmony_ci 523d58139fSopenharmony_ci return ret; 533d58139fSopenharmony_ci} 543d58139fSopenharmony_ci 55