fsl_str.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * The Clear BSD License
  3. * Copyright 2017 NXP
  4. * All rights reserved.
  5. *
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. */
  35. #ifndef _FSL_STR_H
  36. #define _FSL_STR_H
  37. #include "fsl_common.h"
  38. /*!
  39. * @addtogroup debugconsole
  40. * @{
  41. */
  42. /*******************************************************************************
  43. * Prototypes
  44. ******************************************************************************/
  45. #if defined(__cplusplus)
  46. extern "C" {
  47. #endif /* __cplusplus */
  48. /*!
  49. * @brief A function pointer which is used when format printf log.
  50. */
  51. typedef void (*printfCb)(char *buf, int32_t *indicator, char val, int len);
  52. /*!
  53. * @brief This function outputs its parameters according to a formatted string.
  54. *
  55. * @note I/O is performed by calling given function pointer using following
  56. * (*func_ptr)(c);
  57. *
  58. * @param[in] fmt_ptr Format string for printf.
  59. * @param[in] args_ptr Arguments to printf.
  60. * @param[in] buf pointer to the buffer
  61. * @param cb print callbck function pointer
  62. *
  63. * @return Number of characters to be print
  64. */
  65. int StrFormatPrintf(const char *fmt, va_list ap, char *buf, printfCb cb);
  66. /*!
  67. * @brief Converts an input line of ASCII characters based upon a provided
  68. * string format.
  69. *
  70. * @param[in] line_ptr The input line of ASCII data.
  71. * @param[in] format Format first points to the format string.
  72. * @param[in] args_ptr The list of parameters.
  73. *
  74. * @return Number of input items converted and assigned.
  75. * @retval IO_EOF When line_ptr is empty string "".
  76. */
  77. int StrFormatScanf(const char *line_ptr, char *format, va_list args_ptr);
  78. #if defined(__cplusplus)
  79. }
  80. #endif /* __cplusplus */
  81. /*! @} */
  82. #endif /* _FSL_STR_H */