lib_str.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:12k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                               uC/LIB
  4. *                                       CUSTOM LIBRARY MODULES
  5. *
  6. *                          (c) Copyright 2004-2008; Micrium, Inc.; Weston, FL
  7. *
  8. *               All rights reserved.  Protected by international copyright laws.
  9. *
  10. *               uC/LIB is provided in source form for FREE evaluation, for educational
  11. *               use or peaceful research.  If you plan on using uC/LIB in a commercial
  12. *               product you need to contact Micrium to properly license its use in your
  13. *               product.  We provide ALL the source code for your convenience and to
  14. *               help you experience uC/LIB.  The fact that the source code is provided
  15. *               does NOT mean that you can use it without paying a licensing fee.
  16. *
  17. *               Knowledge of the source code may NOT be used to develop a similar product.
  18. *
  19. *               Please help us continue to provide the Embedded community with the finest
  20. *               software available.  Your honesty is greatly appreciated.
  21. *********************************************************************************************************
  22. */
  23. /*
  24. *********************************************************************************************************
  25. *
  26. *                                       ASCII STRING MANAGEMENT
  27. *
  28. * Filename      : lib_str.h
  29. * Version       : V1.25
  30. * Programmer(s) : ITJ
  31. *                 JDH
  32. *********************************************************************************************************
  33. * Note(s)       : (1) NO compiler-supplied standard library functions are used in library or product software.
  34. *
  35. *                     (a) ALL standard library functions are implemented in the custom library modules :
  36. *
  37. *                         (1) <Custom Library Directory>lib*.*
  38. *
  39. *                         (2) <Custom Library Directory>Ports<cpu><compiler>lib*_a.*
  40. *
  41. *                               where
  42. *                                       <Custom Library Directory>      directory path for custom library software
  43. *                                       <cpu>                           directory name for specific processor (CPU)
  44. *                                       <compiler>                      directory name for specific compiler
  45. *
  46. *                     (b) Product-specific library functions are implemented in individual products.
  47. *********************************************************************************************************
  48. */
  49. /*
  50. *********************************************************************************************************
  51. *                                               MODULE
  52. *********************************************************************************************************
  53. */
  54. #ifndef  LIB_STR_MODULE_PRESENT
  55. #define  LIB_STR_MODULE_PRESENT
  56. /*$PAGE*/
  57. /*
  58. *********************************************************************************************************
  59. *                                            INCLUDE FILES
  60. *
  61. * Note(s) : (1) The following common software files are located in the following directories :
  62. *
  63. *               (a) <Custom Library Directory>lib*.*
  64. *
  65. *               (b) (1) <CPU-Compiler Directory>cpu_def.h
  66. *
  67. *                   (2) <CPU-Compiler Directory><cpu><compiler>cpu*.*
  68. *
  69. *                           where
  70. *                                   <Custom Library Directory>      directory path for custom   library      software
  71. *                                   <CPU-Compiler Directory>        directory path for common   CPU-compiler software
  72. *                                   <cpu>                           directory name for specific processor (CPU)
  73. *                                   <compiler>                      directory name for specific compiler
  74. *
  75. *           (2) Compiler MUST be configured to include the '<Custom Library Directory>uC-LIB',
  76. *               '<CPU-Compiler Directory>' directory, & the specific CPU-compiler directory as
  77. *               additional include path directories.
  78. *
  79. *           (3) NO compiler-supplied standard library functions SHOULD be used.
  80. *
  81. *               #### The reference to standard library header files SHOULD be removed once all custom 
  82. *               library functions are implemented WITHOUT reference to ANY standard library function(s).
  83. *
  84. *               See also 'STANDARD LIBRARY MACRO'S  Note #1'.
  85. *********************************************************************************************************
  86. */
  87. #include  <cpu.h>
  88. #include  <lib_def.h>
  89. #include  <app_cfg.h>
  90.                                                                 /* See Note #3.                                         */
  91. #include  <stdlib.h>
  92. #include  <ctype.h>
  93. #include  <errno.h>
  94. #include  <limits.h>
  95. #include  <stdio.h>
  96. /*
  97. *********************************************************************************************************
  98. *                                               EXTERNS
  99. *********************************************************************************************************
  100. */
  101. #ifdef   LIB_STR_MODULE
  102. #define  LIB_STR_EXT
  103. #else
  104. #define  LIB_STR_EXT  extern
  105. #endif
  106. /*$PAGE*/
  107. /*
  108. *********************************************************************************************************
  109. *                                        DEFAULT CONFIGURATION
  110. *********************************************************************************************************
  111. */
  112. /*
  113. *********************************************************************************************************
  114. *                                      MEMORY POOL CONFIGURATION
  115. *
  116. * Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s).
  117. *********************************************************************************************************
  118. */
  119.                                                                 /* Configure floating point feature(s) [see Note #1] :  */
  120. #ifndef  LIB_STR_CFG_FP_EN
  121. #define  LIB_STR_CFG_FP_EN                      DEF_DISABLED
  122.                                                                 /*   DEF_DISABLED     Floating point functions DISABLED */
  123.                                                                 /*   DEF_ENABLED      Floating point functions ENABLED  */
  124. #endif
  125. /*
  126. *********************************************************************************************************
  127. *                                               DEFINES
  128. *********************************************************************************************************
  129. */
  130. /*
  131. *********************************************************************************************************
  132. *                                             DATA TYPES
  133. *********************************************************************************************************
  134. */
  135. /*
  136. *********************************************************************************************************
  137. *                                          GLOBAL VARIABLES
  138. *********************************************************************************************************
  139. */
  140. /*$PAGE*/
  141. /*
  142. *********************************************************************************************************
  143. *                                              MACRO'S
  144. *********************************************************************************************************
  145. */
  146. /*
  147. *********************************************************************************************************
  148. *                                      STANDARD LIBRARY MACRO'S
  149. *
  150. * Note(s) : (1) NO compiler-supplied standard library functions SHOULD be used.
  151. *
  152. *               #### The reference to standard memory functions SHOULD be removed once all custom library 
  153. *               functions are implemented WITHOUT reference to ANY standard library function(s).
  154. *
  155. *               See also 'INCLUDE FILES  Note #3'.
  156. *********************************************************************************************************
  157. */
  158.                                                                 /* See Note #1.                                         */
  159. #define  Str_IsPrint(a)                 isprint(a)
  160. #define  Str_ToLong(a, b, c)            strtol((char *)a, (char **)b, c)
  161. #define  Str_FmtPrint                   snprintf
  162. #define  Str_FmtScan                    sscanf
  163. /*$PAGE*/
  164. /*
  165. *********************************************************************************************************
  166. *                                         FUNCTION PROTOTYPES
  167. *********************************************************************************************************
  168. */
  169. CPU_SIZE_T   Str_Len      (CPU_CHAR     *pstr);
  170. CPU_CHAR    *Str_Copy     (CPU_CHAR     *pdest,
  171.                            CPU_CHAR     *psrc);
  172. CPU_CHAR    *Str_Copy_N   (CPU_CHAR     *pdest,
  173.                            CPU_CHAR     *psrc,
  174.                            CPU_SIZE_T    len_max);
  175. CPU_CHAR    *Str_Cat      (CPU_CHAR     *pdest,
  176.                            CPU_CHAR     *pstr_cat);
  177. CPU_CHAR    *Str_Cat_N    (CPU_CHAR     *pdest,
  178.                            CPU_CHAR     *pstr_cat,
  179.                            CPU_SIZE_T    len_max);
  180. CPU_INT16S   Str_Cmp      (CPU_CHAR     *p1_str,
  181.                            CPU_CHAR     *p2_str);
  182. CPU_INT16S   Str_Cmp_N    (CPU_CHAR     *p1_str,
  183.                            CPU_CHAR     *p2_str,
  184.                            CPU_SIZE_T    len_max);
  185. CPU_CHAR    *Str_Char     (CPU_CHAR     *pstr,
  186.                            CPU_CHAR      srch_char);
  187. CPU_CHAR    *Str_Char_N   (CPU_CHAR     *pstr,
  188.                            CPU_SIZE_T    len_max,
  189.                            CPU_CHAR      srch_char);
  190. CPU_CHAR    *Str_Char_Last(CPU_CHAR     *pstr,
  191.                            CPU_CHAR      srch_char);
  192. CPU_CHAR    *Str_Str      (CPU_CHAR     *pstr,
  193.                            CPU_CHAR     *srch_str);
  194. #if (LIB_STR_CFG_FP_EN  == DEF_ENABLED)
  195. CPU_CHAR    *Str_FmtNbr_32(CPU_FP32      nbr,
  196.                            CPU_INT08U    nbr_dig,
  197.                            CPU_INT08U    nbr_dp,
  198.                            CPU_BOOLEAN   lead_zeros,
  199.                            CPU_BOOLEAN   nul,
  200.                            CPU_CHAR     *pstr_fmt);
  201. #endif
  202. /*$PAGE*/
  203. /*
  204. *********************************************************************************************************
  205. *                                        CONFIGURATION ERRORS
  206. *********************************************************************************************************
  207. */
  208. #ifndef  LIB_STR_CFG_FP_EN
  209. #error  "LIB_STR_CFG_FP_EN        not #define'd in 'app_cfg.h'"
  210. #error  "                   [MUST be  DEF_DISABLED]           "
  211. #error  "                   [     ||  DEF_ENABLED ]           "
  212. #elif  ((LIB_STR_CFG_FP_EN != DEF_DISABLED) && 
  213.         (LIB_STR_CFG_FP_EN != DEF_ENABLED ))
  214. #error  "LIB_STR_CFG_FP_EN  illegally #define'd in 'app_cfg.h'"
  215. #error  "                   [MUST be  DEF_DISABLED]           "
  216. #error  "                   [     ||  DEF_ENABLED ]           "
  217. #endif
  218. /*
  219. *********************************************************************************************************
  220. *                                             MODULE END
  221. *********************************************************************************************************
  222. */
  223. #endif                                                          /* End of lib str module include.                       */