ReactOS  r74431
StaticStrings

Functions

TRIO_STRING_PUBLIC char
*trio_create 
TRIO_ARGS1 ((size), size_t size)
 
TRIO_STRING_PUBLIC void
trio_destroy 
TRIO_ARGS1 ((string), char *string)
 
TRIO_STRING_PUBLIC size_t
trio_length 
TRIO_ARGS1 ((string), TRIO_CONST char *string)
 
TRIO_STRING_PUBLIC int trio_append TRIO_ARGS2 ((target, source), char *target, TRIO_CONST char *source)
 
TRIO_STRING_PUBLIC int
trio_append_max 
TRIO_ARGS3 ((target, max, source), char *target, size_t max, TRIO_CONST char *source)
 
TRIO_STRING_PUBLIC int
trio_contains 
TRIO_ARGS2 ((string, substring), TRIO_CONST char *string, TRIO_CONST char *substring)
 
TRIO_STRING_PRIVATE char
*TrioDuplicateMax 
TRIO_ARGS2 ((source, size), TRIO_CONST char *source, size_t size)
 
TRIO_STRING_PUBLIC char
*trio_duplicate 
TRIO_ARGS1 ((source), TRIO_CONST char *source)
 
TRIO_STRING_PUBLIC char
*trio_duplicate_max 
TRIO_ARGS2 ((source, max), TRIO_CONST char *source, size_t max)
 
TRIO_STRING_PUBLIC int trio_equal TRIO_ARGS2 ((first, second), TRIO_CONST char *first, TRIO_CONST char *second)
 
TRIO_STRING_PUBLIC int
trio_equal_case_max 
TRIO_ARGS3 ((first, max, second), TRIO_CONST char *first, size_t max, TRIO_CONST char *second)
 
TRIO_STRING_PUBLIC TRIO_CONST
char *trio_error 
TRIO_ARGS1 ((error_number), int error_number)
 
TRIO_STRING_PUBLIC size_t
trio_format_date_max 
TRIO_ARGS4 ((target, max, format, datetime), char *target, size_t max, TRIO_CONST char *format, TRIO_CONST struct tm *datetime)
 
TRIO_STRING_PUBLIC unsigned
long trio_hash 
TRIO_ARGS2 ((string, type), TRIO_CONST char *string, int type)
 
TRIO_STRING_PUBLIC char *trio_index TRIO_ARGS2 ((string, character), TRIO_CONST char *string, int character)
 
TRIO_STRING_PUBLIC int trio_lower TRIO_ARGS1 ((target), char *target)
 
TRIO_STRING_PUBLIC int trio_match TRIO_ARGS2 ((string, pattern), TRIO_CONST char *string, TRIO_CONST char *pattern)
 
TRIO_STRING_PUBLIC size_t
trio_span_function 
TRIO_ARGS3 ((target, source, Function), char *target, TRIO_CONST char *source, int(*Function) TRIO_PROTO((int)))
 
TRIO_STRING_PUBLIC char
*trio_substring_max 
TRIO_ARGS3 ((string, max, substring), TRIO_CONST char *string, size_t max, TRIO_CONST char *substring)
 
TRIO_STRING_PUBLIC char
*trio_tokenize 
TRIO_ARGS2 ((string, delimiters), char *string, TRIO_CONST char *delimiters)
 
TRIO_STRING_PUBLIC
trio_long_double_t
trio_to_long_double 
TRIO_ARGS2 ((source, endp), TRIO_CONST char *source, char **endp)
 
TRIO_STRING_PUBLIC long
trio_to_long 
TRIO_ARGS3 ((string, endp, base), TRIO_CONST char *string, char **endp, int base)
 
TRIO_STRING_PUBLIC int
trio_to_lower 
TRIO_ARGS1 ((source), int source)
 

Detailed Description

Function Documentation

TRIO_STRING_PUBLIC char* trio_create TRIO_ARGS1 ( (size ,
size_t  size 
)

Create new string.

Parameters
sizeSize of new string.
Returns
Pointer to string, or NULL if allocation failed.

Definition at line 132 of file triostr.c.

134 {
135  return (char *)TRIO_MALLOC(size);
136 }
#define TRIO_MALLOC(n)
Definition: triop.h:71
GLsizeiptr size
Definition: glext.h:5919
TRIO_STRING_PUBLIC void trio_destroy TRIO_ARGS1 ( (string ,
char string 
)

Destroy string.

Parameters
stringString to be freed.

Definition at line 146 of file triostr.c.

148 {
149  if (string)
150  {
151  TRIO_FREE(string);
152  }
153 }
#define TRIO_FREE(x)
Definition: triop.h:77
TRIO_STRING_PUBLIC size_t trio_length TRIO_ARGS1 ( (string ,
TRIO_CONST char string 
)

Count the number of characters in a string.

Parameters
stringString to measure.
Returns
Number of characters in .

Definition at line 164 of file triostr.c.

166 {
167  return strlen(string);
168 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
TRIO_STRING_PUBLIC char* trio_duplicate TRIO_ARGS1 ( (source ,
TRIO_CONST char source 
)

Duplicate source.

Parameters
sourceSource string.
Returns
A copy of the source string.
Postcondition
target will be zero terminated.

Definition at line 353 of file triostr.c.

355 {
356  return TrioDuplicateMax(source, trio_length(source));
357 }
TRIO_STRING_PUBLIC TRIO_CONST char* trio_error TRIO_ARGS1 ( (error_number)  ,
int  error_number 
)

Provide a textual description of an error code (errno).

Parameters
error_numberError number.
Returns
Textual description of error_number.

Definition at line 563 of file triostr.c.

565 {
566 #if defined(USE_STRERROR)
567 
568  return strerror(error_number);
569 
570 #elif defined(USE_SYS_ERRLIST)
571 
572  extern char *sys_errlist[];
573  extern int sys_nerr;
574 
575  return ((error_number < 0) || (error_number >= sys_nerr))
576  ? "unknown"
577  : sys_errlist[error_number];
578 
579 #else
580 
581  return "unknown";
582 
583 #endif
584 }
int sys_nerr
const char * strerror(int err)
Definition: compat.c:38
char * sys_errlist[]
TRIO_STRING_PUBLIC int trio_upper TRIO_ARGS1 ( (target ,
char target 
)

Convert the alphabetic letters in the string to lower-case.

Parameters
targetString to be converted.
Returns
Number of processed characters (converted or not).

Convert the alphabetic letters in the string to upper-case.

Parameters
targetThe string to be converted.
Returns
The number of processed characters (converted or not).

Definition at line 709 of file triostr.c.

711 {
712  assert(target);
713 
714  return trio_span_function(target, target, trio_to_lower);
715 }
#define assert(x)
Definition: debug.h:53
TRIO_STRING_PUBLIC int trio_to_upper TRIO_ARGS1 ( (source ,
int  source 
)

Convert one alphabetic letter to lower-case.

Parameters
sourceThe letter to be converted.
Returns
The converted letter.

Convert one alphabetic letter to upper-case.

Parameters
sourceThe letter to be converted.
Returns
The converted letter.

Definition at line 1169 of file triostr.c.

1171 {
1172 #if defined(USE_TOLOWER)
1173 
1174  return tolower(source);
1175 
1176 #else
1177 
1178  /* Does not handle locales or non-contiguous alphabetic characters */
1179  return ((source >= (int)'A') && (source <= (int)'Z'))
1180  ? source - 'A' + 'a'
1181  : source;
1182 
1183 #endif
1184 }
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
int tolower(int c)
Definition: utclib.c:902
TRIO_STRING_PUBLIC int trio_copy TRIO_ARGS2 ( (target, source ,
char target,
TRIO_CONST char source 
)

Append source at the end of target.

Parameters
targetTarget string.
sourceSource string.
Returns
Boolean value indicating success or failure.
Precondition
target must point to a memory chunk with sufficient room to contain the target string and source string.
No boundary checking is performed, so insufficient memory will result in a buffer overrun.
Postcondition
target will be zero terminated.

Copy source to target.

Parameters
targetTarget string.
sourceSource string.
Returns
Boolean value indicating success or failure.
Precondition
target must point to a memory chunk with sufficient room to contain the source string.
No boundary checking is performed, so insufficient memory will result in a buffer overrun.
Postcondition
target will be zero terminated.

Definition at line 187 of file triostr.c.

190 {
191  assert(target);
192  assert(source);
193 
194  return (strcat(target, source) != NULL);
195 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define assert(x)
Definition: debug.h:53
#define NULL
Definition: triostr.c:42
TRIO_STRING_PUBLIC char *trio_substring TRIO_ARGS2 ( (string, substring)  ,
TRIO_CONST char string,
TRIO_CONST char substring 
)

Determine if a string contains a substring.

Parameters
stringString to be searched.
substringString to be found.
Returns
Boolean value indicating success or failure.

Search for a substring in a string.

Parameters
stringString to be searched.
substringString to be found.
Returns
Pointer to first occurrence of substring in string, or NULL if no match was found.

Definition at line 247 of file triostr.c.

250 {
251  assert(string);
252  assert(substring);
253 
254  return (0 != strstr(string, substring));
255 }
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define assert(x)
Definition: debug.h:53
TRIO_STRING_PRIVATE char* TrioDuplicateMax TRIO_ARGS2 ( (source, size ,
TRIO_CONST char source,
size_t  size 
)

Definition at line 324 of file triostr.c.

327 {
328  char *target;
329 
330  assert(source);
331 
332  /* Make room for string plus a terminating zero */
333  size++;
334  target = trio_create(size);
335  if (target)
336  {
337  trio_copy_max(target, size, source);
338  }
339  return target;
340 }
#define assert(x)
Definition: debug.h:53
GLsizeiptr size
Definition: glext.h:5919
GLenum target
Definition: glext.h:7315
TRIO_STRING_PUBLIC char* trio_duplicate_max TRIO_ARGS2 ( (source, max ,
TRIO_CONST char source,
size_t  max 
)

Duplicate at most max characters of source.

Parameters
sourceSource string.
maxMaximum number of characters to duplicate.
Returns
A copy of the source string.
Postcondition
target will be zero terminated.

Definition at line 371 of file triostr.c.

374 {
375  size_t length;
376 
377  assert(source);
378  assert(max > 0);
379 
380  length = trio_length(source);
381  if (length > max)
382  {
383  length = max;
384  }
385  return TrioDuplicateMax(source, length);
386 }
#define assert(x)
Definition: debug.h:53
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define max(a, b)
Definition: slicer.cc:81
TRIO_STRING_PUBLIC int trio_equal_locale TRIO_ARGS2 ( (first, second)  ,
TRIO_CONST char first,
TRIO_CONST char second 
)

Compare if two strings are equal.

Parameters
firstFirst string.
secondSecond string.
Returns
Boolean indicating whether the two strings are equal or not.

Case-insensitive comparison.

Compare if two strings are equal.

Parameters
firstFirst string.
secondSecond string.
Returns
Boolean indicating whether the two strings are equal or not.

Case-sensitive comparison.

Compare if two strings are equal.

Parameters
firstFirst string.
secondSecond string.
Returns
Boolean indicating whether the two strings are equal or not.

Collating characters are considered equal.

Definition at line 401 of file triostr.c.

404 {
405  assert(first);
406  assert(second);
407 
408  if ((first != NULL) && (second != NULL))
409  {
410 #if defined(USE_STRCASECMP)
411  return (0 == strcasecmp(first, second));
412 #else
413  while ((*first != NIL) && (*second != NIL))
414  {
415  if (trio_to_upper(*first) != trio_to_upper(*second))
416  {
417  break;
418  }
419  first++;
420  second++;
421  }
422  return ((*first == NIL) && (*second == NIL));
423 #endif
424  }
425  return FALSE;
426 }
#define strcasecmp
Definition: fake.h:9
const GLint * first
Definition: glext.h:5794
#define assert(x)
Definition: debug.h:53
#define FALSE
Definition: triostr.c:48
#define NULL
Definition: triostr.c:42
#define NIL
Definition: triostr.c:45
TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_ARGS2 ( (string, type ,
TRIO_CONST char string,
int  type 
)

Calculate a hash value for a string.

Parameters
stringString to be calculated on.
typeHash function.
Returns
Calculated hash value.

type can be one of the following

  • TRIO_HASH_PLAIN Plain hash function.

Definition at line 631 of file triostr.c.

634 {
635  unsigned long value = 0L;
636  char ch;
637 
638  assert(string);
639 
640  switch (type)
641  {
642  case TRIO_HASH_PLAIN:
643  while ( (ch = *string++) != NIL )
644  {
645  value *= 31;
646  value += (unsigned long)ch;
647  }
648  break;
649  default:
650  assert(FALSE);
651  break;
652  }
653  return value;
654 }
Definition: get.c:139
Definition: bidi.c:75
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
unsigned long
Definition: typeof.h:98
#define FALSE
Definition: triostr.c:48
#define NIL
Definition: triostr.c:45
GLsizei const GLfloat * value
Definition: glext.h:6069
TRIO_STRING_PUBLIC char *trio_index_last TRIO_ARGS2 ( (string, character)  ,
TRIO_CONST char string,
int  character 
)

Find first occurrence of a character in a string.

Parameters
stringString to be searched.
characterCharacter to be found.
Apointer to the found character, or NULL if character was not found.

Find last occurrence of a character in a string.

Parameters
stringString to be searched.
characterCharacter to be found.
Apointer to the found character, or NULL if character was not found.

Definition at line 668 of file triostr.c.

671 {
672  assert(string);
673 
674  return strchr(string, character);
675 }
#define assert(x)
Definition: debug.h:53
char * strchr(const char *String, int ch)
Definition: utclib.c:501
TRIO_STRING_PUBLIC int trio_match_case TRIO_ARGS2 ( (string, pattern ,
TRIO_CONST char string,
TRIO_CONST char pattern 
)

Compare two strings using wildcards.

Parameters
stringString to be searched.
patternPattern, including wildcards, to search for.
Returns
Boolean value indicating success or failure.

Case-insensitive comparison.

The following wildcards can be used

  • * Match any number of characters.
  • ? Match a single character.

Compare two strings using wildcards.

Parameters
stringString to be searched.
patternPattern, including wildcards, to search for.
Returns
Boolean value indicating success or failure.

Case-sensitive comparison.

The following wildcards can be used

  • * Match any number of characters.
  • ? Match a single character.

Definition at line 735 of file triostr.c.

738 {
739  assert(string);
740  assert(pattern);
741 
742  for (; ('*' != *pattern); ++pattern, ++string)
743  {
744  if (NIL == *string)
745  {
746  return (NIL == *pattern);
747  }
748  if ((trio_to_upper((int)*string) != trio_to_upper((int)*pattern))
749  && ('?' != *pattern))
750  {
751  return FALSE;
752  }
753  }
754  /* two-line patch to prevent *too* much recursiveness: */
755  while ('*' == pattern[1])
756  pattern++;
757 
758  do
759  {
760  if ( trio_match(string, &pattern[1]) )
761  {
762  return TRUE;
763  }
764  }
765  while (*string++);
766 
767  return FALSE;
768 }
#define assert(x)
Definition: debug.h:53
#define FALSE
Definition: triostr.c:48
#define TRUE
Definition: triostr.c:49
#define NIL
Definition: triostr.c:45
char string[160]
Definition: util.h:11
GLubyte * pattern
Definition: glext.h:7787
TRIO_STRING_PUBLIC char* trio_tokenize TRIO_ARGS2 ( (string, delimiters)  ,
char string,
TRIO_CONST char delimiters 
)

Tokenize string.

Parameters
stringString to be tokenized.
tokensString containing list of delimiting characters.
Returns
Start of new token.
Warning
string will be destroyed.

Definition at line 933 of file triostr.c.

936 {
937  assert(delimiters);
938 
939  return strtok(string, delimiters);
940 }
#define assert(x)
Definition: debug.h:53
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
TRIO_STRING_PUBLIC float trio_to_float TRIO_ARGS2 ( (source, endp)  ,
TRIO_CONST char source,
char **  endp 
)

Convert string to floating-point number.

Parameters
sourceString to be converted.
endpPointer to end of the converted string.
Returns
A floating-point number.

The following Extended Backus-Naur form is used

double        ::= [ <sign> ]
                  ( <number> |
                    <number> <decimal_point> <number> |
                    <decimal_point> <number> )
                  [ <exponential> [ <sign> ] <number> ]
number        ::= 1*( <digit> )
digit         ::= ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' )
exponential   ::= ( 'e' | 'E' )
sign          ::= ( '-' | '+' )
decimal_point ::= '.'

Convert string to floating-point number.

Parameters
sourceString to be converted.
endpPointer to end of the converted string.
Returns
A floating-point number.

See trio_to_long_double.

Definition at line 968 of file triostr.c.

971 {
972 #if defined(USE_STRTOLD)
973  return strtold(source, endp);
974 #else
975  int isNegative = FALSE;
976  int isExponentNegative = FALSE;
977  trio_long_double_t integer = 0.0;
978  trio_long_double_t fraction = 0.0;
979  unsigned long exponent = 0;
981  trio_long_double_t fracdiv = 1.0;
983 
984  /* First try hex-floats */
985  if ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X')))
986  {
987  base = 16.0;
988  source += 2;
989  while (isxdigit((int)*source))
990  {
991  integer *= base;
992  integer += (isdigit((int)*source)
993  ? (*source - '0')
994  : 10 + (trio_to_upper((int)*source) - 'A'));
995  source++;
996  }
997  if (*source == '.')
998  {
999  source++;
1000  while (isxdigit((int)*source))
1001  {
1002  fracdiv /= base;
1003  fraction += fracdiv * (isdigit((int)*source)
1004  ? (*source - '0')
1005  : 10 + (trio_to_upper((int)*source) - 'A'));
1006  source++;
1007  }
1008  if ((*source == 'p') || (*source == 'P'))
1009  {
1010  source++;
1011  if ((*source == '+') || (*source == '-'))
1012  {
1013  isExponentNegative = (*source == '-');
1014  source++;
1015  }
1016  while (isdigit((int)*source))
1017  {
1018  exponent *= 10;
1019  exponent += (*source - '0');
1020  source++;
1021  }
1022  }
1023  }
1024  /* For later use with exponent */
1025  base = 2.0;
1026  }
1027  else /* Then try normal decimal floats */
1028  {
1029  base = 10.0;
1030  isNegative = (*source == '-');
1031  /* Skip sign */
1032  if ((*source == '+') || (*source == '-'))
1033  source++;
1034 
1035  /* Integer part */
1036  while (isdigit((int)*source))
1037  {
1038  integer *= base;
1039  integer += (*source - '0');
1040  source++;
1041  }
1042 
1043  if (*source == '.')
1044  {
1045  source++; /* skip decimal point */
1046  while (isdigit((int)*source))
1047  {
1048  fracdiv /= base;
1049  fraction += (*source - '0') * fracdiv;
1050  source++;
1051  }
1052  }
1053  if ((*source == 'e')
1054  || (*source == 'E')
1055 #if TRIO_MICROSOFT
1056  || (*source == 'd')
1057  || (*source == 'D')
1058 #endif
1059  )
1060  {
1061  source++; /* Skip exponential indicator */
1062  isExponentNegative = (*source == '-');
1063  if ((*source == '+') || (*source == '-'))
1064  source++;
1065  while (isdigit((int)*source))
1066  {
1067  exponent *= (int)base;
1068  exponent += (*source - '0');
1069  source++;
1070  }
1071  }
1072  }
1073 
1074  value = integer + fraction;
1075  if (exponent != 0)
1076  {
1077  if (isExponentNegative)
1078  value /= pow(base, (double)exponent);
1079  else
1080  value *= pow(base, (double)exponent);
1081  }
1082  if (isNegative)
1083  value = -value;
1084 
1085  if (endp)
1086  *endp = (char *)source;
1087  return value;
1088 #endif
1089 }
Definition: get.c:139
double trio_long_double_t
Definition: triodef.h:132
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
float pow(float __x, int __y)
Definition: _cmath.h:458
#define isdigit(c)
Definition: acclib.h:68
#define FALSE
Definition: triostr.c:48
GLsizei const GLfloat * value
Definition: glext.h:6069
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
#define isxdigit(c)
Definition: acclib.h:70
#define TRIO_MICROSOFT
Definition: triop.h:58
long double __cdecl strtold(const char *__restrict__, char **__restrict__)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
TRIO_STRING_PUBLIC int trio_copy_max TRIO_ARGS3 ( (target, max, source ,
char target,
size_t  max,
TRIO_CONST char source 
)

Append at most max characters from source to target.

Parameters
targetTarget string.
maxMaximum number of characters to append.
sourceSource string.
Returns
Boolean value indicating success or failure.
Precondition
target must point to a memory chuck with sufficient room to contain the target string and the source string (at most max characters).
No boundary checking is performed, so insufficient memory will result in a buffer overrun.
Postcondition
target will be zero terminated.

Copy at most max characters from source to target.

Parameters
targetTarget string.
maxMaximum number of characters to append.
sourceSource string.
Returns
Boolean value indicating success or failure.
Precondition
target must point to a memory chunk with sufficient room to contain the source string (at most max characters).
No boundary checking is performed, so insufficient memory will result in a buffer overrun.
Postcondition
target will be zero terminated.

Definition at line 216 of file triostr.c.

220 {
221  size_t length;
222 
223  assert(target);
224  assert(source);
225 
226  length = trio_length(target);
227 
228  if (max > length)
229  {
230  strncat(target, source, max - length - 1);
231  }
232  return TRUE;
233 }
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
#define assert(x)
Definition: debug.h:53
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define TRUE
Definition: triostr.c:49
#define max(a, b)
Definition: slicer.cc:81
TRIO_STRING_PUBLIC int trio_equal_max TRIO_ARGS3 ( (first, max, second)  ,
TRIO_CONST char first,
size_t  max,
TRIO_CONST char second 
)

Compare if two strings up until the first max characters are equal.

Parameters
firstFirst string.
maxMaximum number of characters to compare.
secondSecond string.
Returns
Boolean indicating whether the two strings are equal or not.

Case-sensitive comparison.

Compare if two strings up until the first max characters are equal.

Parameters
firstFirst string.
maxMaximum number of characters to compare.
secondSecond string.
Returns
Boolean indicating whether the two strings are equal or not.

Case-insensitive comparison.

Definition at line 468 of file triostr.c.

472 {
473  assert(first);
474  assert(second);
475 
476  if ((first != NULL) && (second != NULL))
477  {
478  return (0 == strncmp(first, second, max));
479  }
480  return FALSE;
481 }
const GLint * first
Definition: glext.h:5794
#define assert(x)
Definition: debug.h:53
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define FALSE
Definition: triostr.c:48
#define NULL
Definition: triostr.c:42
#define max(a, b)
Definition: slicer.cc:81
TRIO_STRING_PUBLIC size_t trio_span_function TRIO_ARGS3 ( (target, source, Function ,
char target,
TRIO_CONST char source,
int *Function   TRIO_PROTO(int) 
)

Execute a function on each character in string.

Parameters
targetTarget string.
sourceSource string.
FunctionFunction to be executed.
Returns
Number of processed characters.

Definition at line 836 of file triostr.c.

840 {
841  size_t count = 0;
842 
843  assert(target);
844  assert(source);
845  assert(Function);
846 
847  while (*source != NIL)
848  {
849  *target++ = Function(*source++);
850  count++;
851  }
852  return count;
853 }
IN OUT PIRP IN ULONG IN WMIENABLEDISABLECONTROL Function
Definition: wmilib.h:37
#define assert(x)
Definition: debug.h:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define NIL
Definition: triostr.c:45
TRIO_STRING_PUBLIC char* trio_substring_max TRIO_ARGS3 ( (string, max, substring)  ,
TRIO_CONST char string,
size_t  max,
TRIO_CONST char substring 
)

Search for a substring in the first max characters of a string.

Parameters
stringString to be searched.
maxMaximum characters to be searched.
substringString to be found.
Returns
Pointer to first occurrence of substring in string, or NULL if no match was found.

Definition at line 892 of file triostr.c.

896 {
897  size_t count;
898  size_t size;
899  char *result = NULL;
900 
901  assert(string);
902  assert(substring);
903 
904  size = trio_length(substring);
905  if (size <= max)
906  {
907  for (count = 0; count <= max - size; count++)
908  {
909  if (trio_equal_max(substring, size, &string[count]))
910  {
911  result = (char *)&string[count];
912  break;
913  }
914  }
915  }
916  return result;
917 }
#define assert(x)
Definition: debug.h:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define NULL
Definition: triostr.c:42
GLsizeiptr size
Definition: glext.h:5919
#define max(a, b)
Definition: slicer.cc:81
GLuint64EXT * result
Definition: glext.h:11304
TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_ARGS3 ( (string, endp, base ,
TRIO_CONST char string,
char **  endp,
int  base 
)

Convert string to signed integer.

Parameters
stringString to be converted.
endpPointer to end of converted string.
baseRadix number of number.

Convert string to unsigned integer.

Parameters
stringString to be converted.
endpPointer to end of converted string.
baseRadix number of number.

Definition at line 1148 of file triostr.c.

1152 {
1153  assert(string);
1154  assert((base >= 2) && (base <= 36));
1155 
1156  return strtol(string, endp, base);
1157 }
#define assert(x)
Definition: debug.h:53
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_ARGS4 ( (target, max, format, datetime)  ,
char target,
size_t  max,
TRIO_CONST char format,
TRIO_CONST struct tm datetime 
)

Format the date/time according to format.

Parameters
targetTarget string.
maxMaximum number of characters to format.
formatFormatting string.
datetimeDate/time structure.
Returns
Number of formatted characters.

The formatting string accepts the same specifiers as the standard C function strftime.

Definition at line 602 of file triostr.c.

607 {
608  assert(target);
609  assert(format);
610  assert(datetime);
611  assert(max > 0);
612 
613  return strftime(target, max, format, datetime);
614 }
#define assert(x)
Definition: debug.h:53
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:293
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define max(a, b)
Definition: slicer.cc:81