The xtype C Library, Version 1.00

The XSTR Type

Contents:

  1. fgetxstr
  2. xstrcast
  3. xstrcat
  4. xstrcatc
  5. xstrch
  6. xstrcpy
  7. xstrcvt
  8. xstrdel
  9. xstrfree
  10. xstrlen
  11. xstrncat
  12. xstrncpy
  13. xstrnew
  14. xstrtrunc

XSTR *fgetxstr(XSTR *xstr, FILE *f)

Function

Read one line of a stream f, terminated by a line feed ('\n') character, into a string pointed to by xstr, as fgets().

Returns


char *xstrcast(XSTR *xstr)

Function

Typecast the string pointed to by xstr as a normal null-terminated character string. xstrcast() is implemented as a macro.

Returns


XSTR *xstrcat(XSTR *xstr, char *psz)

Function

Concatenate the string pointed to by psz to the end of the string pointed to by xstr, as strcat().

Returns


XSTR *xstrcatc(XSTR *xstr, char ch)

Function

Concatenate the character ch to the end of the string pointed to by xstr.

Returns


char xstrch(XSTR *xstr, int n)

Function

Pick out the nth character of the string pointed to by xstr; equivalent to xstrcast(xstr)[n]. xstrch() is implemented as a macro.

Returns


XSTR *xstrcpy(XSTR *xstr, char *psz)

Function

Copy the string pointed to by psz into the string pointed to by xstr, as strcpy().

Returns


char *xstrcvt(XSTR *xstr)

Function

Convert the string pointed to by xstr into a normal null-terminated character string. All the memory associated with xstr will be de-allocated, so do not use xstr after calling this function. The pointer returned should be freed with free() when it is no longer required.

Returns


XSTR *xstrdel(XSTR *xstr, int n1, int n2)

Function

Shorten the string pointed to by xstr by removing characters n1 to n2, inclusive.

Returns


void xstrfree(XSTR *xstr)

Function

De-allocate the memory used by the string pointed to by xstr. Do not use xstr after calling this function.


int xstrlen(XSTR *xstr)

Function

Compute the length of the string pointed to by xstr, equivalent to strlen(xstrcast(xstr)). xstrlen() is implemented as a macro.

Returns


XSTR *xstrncat(XSTR *xstr, char *psz, int n)

Function

Concatenate at most n characters from the string pointed to by psz to the string pointed to by xstr. Unlike strncat(), this function will ensure that the resulting string is null-terminated.

Returns


XSTR *xstrncpy(XSTR *xstr, char *psz, int n)

Function

Copy at most n characters from the string pointed to by psz into the string pointed to by xstr. Unlike strncpy(), this function will ensure that the resulting string is null-terminated.

Returns


XSTR *xstrnew(int n, int b)

Function

Create a new string with initial space for n characters. The space allocated for the string will grow by b characters whenever the string exceeds the length currently set aside for it.

Returns


XSTR *xstrtrunc(XSTR *xstr, int n)

Function

Truncate the string pointed to by xstr to be no longer than n characters. If the length of xstr is less than n, this function does nothing.

Returns