secureinput_a.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved.
  3. * Licensed under Mulan PSL v2.
  4. * You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. * You may obtain a copy of Mulan PSL v2 at:
  6. * http://license.coscl.org.cn/MulanPSL2
  7. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. * See the Mulan PSL v2 for more details.
  11. * Description: By defining data type for ANSI string and including "input.inl",
  12. * this file generates real underlying function used by scanf family API.
  13. * Create: 2014-02-25
  14. */
  15. #define SECUREC_FORMAT_OUTPUT_INPUT 1
  16. #ifdef SECUREC_FOR_WCHAR
  17. #undef SECUREC_FOR_WCHAR
  18. #endif
  19. #include "secinput.h"
  20. #include "input.inl"
  21. SECUREC_INLINE int SecIsDigit(SecInt ch)
  22. {
  23. /* SecInt to unsigned char clear 571, use bit mask to clear negative return of ch */
  24. return isdigit((int)((unsigned int)(unsigned char)(ch) & 0xffU));
  25. }
  26. SECUREC_INLINE int SecIsXdigit(SecInt ch)
  27. {
  28. return isxdigit((int)((unsigned int)(unsigned char)(ch) & 0xffU));
  29. }
  30. SECUREC_INLINE int SecIsSpace(SecInt ch)
  31. {
  32. return isspace((int)((unsigned int)(unsigned char)(ch) & 0xffU));
  33. }