qlibs:

Section: Misc. Reference Manual Pages (str)
Updated: 3
Index Return to Main Contents
 

NAME

str - string evaluation and comparision (for allocated strings)  

SYNTAX

#include "str.h"

unsigned int str_copy(char *dst, const char *src);
unsigned int str_copyb(char *dst, const char *src, unsigned int len);
unsigned int str_chr(const char *s, int c);
unsigned int str_rchr(const char *s, int c);
unsigned int str_diff(const char *s, const char *t);
unsigned int str_diffn(const char *s, const char *t, unsigned int len);
unsigned int str_equal(const char *s, const char *t);
unsigned int str_len(const char *s);
unsigned int str_starts(const char *dst, const char *src);
char *str_append(char *dst, const char *s);  

DESCRIPTION

str_copy copies src into dst up to the first occurance of \0 while including it. It returns the number of bytes written. If dst is smaller than src, str_copy fills up dst to its allocated size and returns the number of bytes it would have be written. str_copyb copies len bytes from src into dst.

str_chr and str_rchr searches for a single character in a string (from left-to-right or from right-to-left) and returns the position of the first occurrance of c or the length len of s.

str_len determines the length of a string. It returns the position of the first occurance of \0 in s.

str_diff, str_diffn, and str_equal compare two strings. str_diff and str_diffn returns negative, zero or positive, depending whether the string s[0], s[1], ..., s[n]=='\0' is ASCII lexicographically smaller than, equal to, or greater than the string t[0], t[1], ..., t[m-1]=='\0'. If the strings are different, both functions do not read bytes past the first difference. str_diffn considers the strings equal if the first n characters match.

str_equal returns 1, if s and t match up to and including the first occurance of \0 or returns 0 otherwise. It is the opposite of str_diff.

str_start compares the two strings from the begining. It returns 1 if t is a prefix of s or 0 otherwise.

*str_append appends a single byte s to out given out is allocated with enough space.  

NOTE

For the str_copy* and *str_append commands dst has to have a preallocated space. Otherwise the result may be unexpected.  

SEE ALSO

byte(3), stralloc(3)


 

Index

NAME
SYNTAX
DESCRIPTION
NOTE
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 14:55:39 GMT, December 15, 2024