Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. #ifndef _STRUTIL_H
  2. #define _STRUTIL_H
  3. /* strutil.h */
  4. /*****************************************************************************/
  5. /* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
  6. /*                                                                           */
  7. /* AS-Portierung                                                             */
  8. /*                                                                           */
  9. /* haeufig benoetigte String-Funktionen                                      */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stddef.h>
  15. #include <stdarg.h>
  16.  
  17. #include "datatypes.h"
  18.  
  19. struct as_dynstr;
  20.  
  21. extern char HexStartCharacter;
  22. extern char SplitByteCharacter;
  23.  
  24. extern const char *Blanks(int cnt);
  25.  
  26. #define HexString(pDest, DestSize, i, Stellen) SysString(pDest, DestSize, i, 16, Stellen, False, HexStartCharacter, SplitByteCharacter)
  27. #define DecString(pDest, DestSize, i, Digits) SysString(pDest, DestSize, i, 10, Digits, False, HexStartCharacter, '\0')
  28.  
  29. extern int SysString(char *pDest, size_t DestSize, LargeWord i, int System, int Stellen, Boolean ForceLeadZero, char StartCharacter, char SplitCharacter);
  30.  
  31. extern char *as_strdup(const char *s);
  32.  
  33. extern int as_vsnprcatf(char *pDest, size_t DestSize, const char *pFormat, va_list ap);
  34. extern int as_snprcatf(char *pDest, size_t DestSize, const char *pFormat, ...);
  35. extern int as_vsnprintf(char *pDest, size_t DestSize, const char *pFormat, va_list ap);
  36. extern int as_snprintf(char *pDest, size_t DestSize, const char *pFormat, ...);
  37.  
  38. extern int as_vsdprcatf(struct as_dynstr *p_dest, const char *pFormat, va_list ap);
  39. extern int as_sdprcatf(struct as_dynstr *p_dest, const char *pFormat, ...);
  40. extern int as_vsdprintf(struct as_dynstr *p_dest, const char *pFormat, va_list ap);
  41. extern int as_sdprintf(struct as_dynstr *p_dest, const char *pFormat, ...);
  42.  
  43. extern int as_strcasecmp(const char *src1, const char *src2);
  44. extern int as_strncasecmp(const char *src1, const char *src2, size_t maxlen);
  45.  
  46. #ifdef NEEDS_STRSTR
  47. extern char *strstr(const char *haystack, const char *needle);
  48. #endif
  49.  
  50. extern char *strrmultchr(const char *haystack, const char *needles);
  51.  
  52. extern size_t strmaxcpy(char *dest, const char *src, size_t Max);
  53. extern size_t strmaxcat(char *Dest, const char *Src, size_t MaxLen);
  54. extern void strprep(char *Dest, const char *Src);
  55. extern void strmaxprep(char *p_dest, const char *p_src, size_t max_len);
  56. extern void strmaxprep2(char *p_dest, const char *p_src, size_t max_len);
  57. extern void strins(char *Dest, const char *Src, int Pos);
  58. extern void strmaxins(char *Dest, const char *Src, int Pos, size_t MaxLen);
  59.  
  60. extern size_t as_strnlen(const char *pStr, size_t MaxLen);
  61.  
  62. extern int strreplace(char *pHaystack, const char *pFrom, const char *pTo, size_t ToMaxLen, size_t HaystackSize);
  63.  
  64. extern int strlencmp(const char *pStr1, unsigned Str1Len,
  65.                      const char *pStr2, unsigned Str2Len);
  66.  
  67. extern unsigned fstrlenprint(FILE *pFile, const char *pStr, unsigned StrLen);
  68.  
  69. extern void ReadLn(FILE *Datei, char *Zeile);
  70.  
  71. extern size_t ReadLnCont(FILE *Datei, struct as_dynstr *p_line);
  72.  
  73. extern int DigitVal(char ch, int Base);
  74.  
  75. extern LargeInt ConstLongInt(const char *inp, Boolean *pErr, LongInt Base);
  76.  
  77. extern char *ParenthPos(char *pHaystack, char Needle);
  78.  
  79. extern void KillBlanks(char *s);
  80.  
  81. extern int CopyNoBlanks(char *pDest, const char *pSrc, size_t MaxLen);
  82.  
  83. extern int KillPrefBlanks(char *s);
  84.  
  85. extern int KillPostBlanks(char *s);
  86.  
  87. extern char TabCompressed(char in);
  88.  
  89. extern int strqcmp(const char *s1, const char *s2);
  90.  
  91. extern char *strmov(char *pDest, const char *pSrc);
  92.  
  93. extern int strmemcpy(char *pDest, size_t DestSize, const char *pSrc, size_t SrcLen);
  94.  
  95. extern void strutil_init(void);
  96.  
  97. /* avoid nasty "subscript has type char..." messages on some platforms */
  98.  
  99. #include <ctype.h>
  100.  
  101. #define __chartouint(c) (((unsigned int)(c)) & 0xff)
  102. #define as_toupper(c) (toupper(__chartouint(c)))
  103. #define as_tolower(c) (tolower(__chartouint(c)))
  104. #define as_isspace(c) (!!isspace(__chartouint(c)))
  105. #define as_isdigit(c) (!!isdigit(__chartouint(c)))
  106. #define as_isxdigit(c) (!!isxdigit(__chartouint(c)))
  107. #define as_isprint(c) (!!isprint(__chartouint(c)))
  108. #define as_isalpha(c) (!!isalpha(__chartouint(c)))
  109. #define as_isupper(c) (!!isupper(__chartouint(c)))
  110. #define as_islower(c) (!!islower(__chartouint(c)))
  111. #define as_isalnum(c) (!!isalnum(__chartouint(c)))
  112.  
  113. #endif /* _STRUTIL_H */
  114.