ZEDA  1.6.18
zeda_string.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
9 #ifndef __ZEDA_STRING_H__
10 #define __ZEDA_STRING_H__
11 
12 #include <zeda/zeda_misc.h>
13 
15 
16 #ifndef __KERNEL__
17 
24 __EXPORT char *zNullStr(void);
25 
32 __EXPORT char *zStrCopyNC(char *dest, const char *src);
33 
42 __EXPORT char *zStrCopy(char *dest, const char *src, size_t size);
43 
53 __EXPORT char *zStrClone(char *str);
54 
62 __EXPORT char *zStrCat(char *dest, const char *src, size_t size);
63 
79 __EXPORT char *zStrCatPrint(char *str, size_t size, char *fmt, ...);
80 
93 __EXPORT char *zStrChar(const char *s, size_t size, int c);
94 
110 __EXPORT char *zStrCharNul(const char *s, size_t size, int c);
111 
124 __EXPORT char *zStrrChar(const char *s, size_t size, int c);
125 
136 __EXPORT char *zStrAddChar(char *str, size_t size, char c);
137 
152 __EXPORT char *zStrInsChar(char *str, size_t size, int cur, char c);
153 
166 __EXPORT char *zStrOvrChar(char *str, size_t size, int cur, char c);
167 
176 __EXPORT char *zStrDelChar(char *str, int cur);
177 
186 __EXPORT char *zStrBSChar(char *str, int cur);
187 
196 __EXPORT char *zCutNL(char *str);
197 
206 __EXPORT char *zToUpper(char *src, char *dest);
207 
216 __EXPORT char *zToLower(char *src, char *dest);
217 
218 /* ********************************************************** *//* ************************************************** */
221 
231 __EXPORT void zSetDelimiter(char s[]);
232 
255 __EXPORT void zResetDelimiter(void);
256 
265 __EXPORT void zSetOperator(char s[]);
266 
291 __EXPORT void zResetOperator(void);
292 
304 __EXPORT bool zIsIncludedChar(char c, char *s);
305 
312 #define zIsWS(c) ( (c) == ' ' || (c) == '\t' )
313 
323 __EXPORT bool zIsDelimiter(char c);
324 
334 __EXPORT bool zIsOperator(char c);
335 
341 #define zIsQuotation(c) ( (c) == '\'' || (c) == '\"' )
342 
354 __EXPORT bool zStrIsHex(char *str);
355 
365 __EXPORT char zFSkipWS(FILE *fp);
366 
377 __EXPORT char *zSSkipWS(char *str);
378 
389 __EXPORT char zFSkipIncludedChar(FILE *fp, char *s);
390 
401 __EXPORT char *zSSkipIncludedChar(char *str, char *s);
402 
412 __EXPORT char zFSkipDelimiter(FILE *fp);
413 
424 __EXPORT char *zSSkipDelimiter(char *str);
425 
426 #define ZDEFAULT_COMMENT_IDENT '%'
427 
429 __EXPORT void zSetCommentIdent(char ident);
430 
432 __EXPORT void zResetCommentIdent(void);
433 
448 __EXPORT char zFSkipComment(FILE *fp);
449 
470 __EXPORT char *zFToken(FILE *fp, char *tkn, size_t size);
471 
498 __EXPORT char *zSTokenSkim(char *str, char *tkn, size_t size);
499 __EXPORT char *zSToken(char *str, char *tkn, size_t size);
500 
510 __EXPORT char *zFIntToken(FILE *fp, char *tkn, size_t size);
511 
521 __EXPORT char *zFNumToken(FILE *fp, char *tkn, size_t size);
522 
534 __EXPORT char *zSIntToken(char *str, char *tkn, size_t size);
535 
547 __EXPORT char *zSNumToken(char *str, char *tkn, size_t size);
548 
555 __EXPORT char *zFInt(FILE *fp, int *val);
556 
563 __EXPORT char *zSInt(char *str, int *val);
564 
572 __EXPORT char *zFDouble(FILE *fp, double *val);
573 
580 __EXPORT char *zSDouble(char *str, double *val);
581 
584 #define ZDEFAULT_TAG_BEGIN_IDENT '['
585 #define ZDEFAULT_TAG_END_IDENT ']'
586 
588 __EXPORT void zSetTagIdent(char begin_ident, char end_ident);
589 
591 __EXPORT void zResetTagIdent(void);
592 
600 __EXPORT bool zTokenIsTag(char *tkn);
601 
613 __EXPORT char *zExtractTag(char *tag, char *notag);
614 
626 __EXPORT int zFCountTag(FILE *fp, char *tag);
627 
647 __EXPORT bool zTagFScan(FILE *fp, bool (* tag_fscan)(FILE*,void*,char*,bool*), void *instance);
648 
649 #define ZDEFAULT_KEY_IDENT ':'
650 
652 __EXPORT void zSetKeyIdent(char ident);
653 
655 __EXPORT void zResetKeyIdent(void);
656 
658 __EXPORT bool zFPostCheckKey(FILE *fp);
659 
672 __EXPORT int zFCountKey(FILE *fp, char *key);
673 
693 __EXPORT bool zFieldFScan(FILE *fp, bool (* field_fscan)(FILE*,void*,char*,bool*), void *instance);
694 
695 #endif /* __KERNEL__ */
696 
704 #ifndef __KERNEL__
705 __EXPORT void zFIndent(FILE *fp, int n);
706 #define zIndent(n) zFIndent( stdout,(n) )
707 #else
708 void zIndent(int n);
709 #endif /* __KERNEL__ */
710 
714 #ifndef __KERNEL__
715 #define zEndl() printf( "\n" )
716 #else
717 #define zEndl() printk( "\n" )
718 #endif /* __KERNEL__ */
719 
720 /* ********************************************************** *//* ************************************************** */
723 
724 #ifndef __KERNEL__
725 
740 __EXPORT char *zGetBasename(char *path, char *name, size_t size);
741 __EXPORT char *zGetBasenameDRC(char *name);
742 
755 __EXPORT int zGetDirFilename(char *path, char *dirname, char *filename, size_t size);
756 
766 __EXPORT char *zGetSuffix(char *name);
767 
782 __EXPORT char *zAddSuffix(char *org, char *suffix, char *dest, size_t size);
783 
798 __EXPORT char *zReplaceSuffix(char *org, char *suffix, char *dest, size_t size);
799 
811 __EXPORT char *zCutSuffix(char *name);
812 
825 __EXPORT FILE *zOpenFile(char filename[], char *suffix, char *mode);
826 
828 #define ZEDA_ZTK_SUFFIX "ztk"
829 
831 #define zOpenZTKFile(filename,mode) zOpenFile( filename, ZEDA_ZTK_SUFFIX, mode )
832 
835 /* ********************************************************** *//* ************************************************** */
838 
848 __EXPORT char *zStrSearchKMP(char *text, char *pat);
849 
859 __EXPORT char *zStrSearchBM(char *text, char *pat);
860 
863 #endif /* __KERNEL__ */
864 
866 
867 #endif /* __ZEDA_STRING_H__ */
union __zstream::@1 src
char * zStrCopyNC(char *dest, const char *src)
copy a string without checking the buffer size.
char * zGetSuffix(char *name)
get a suffix from a filename.
char * zSDouble(char *str, double *val)
get a d-float value in a string.
char * zFIntToken(FILE *fp, char *tkn, size_t size)
tokenize an integer value in a file.
bool zIsOperator(char c)
check if a charactor is an operator.
char * zGetBasename(char *path, char *name, size_t size)
strip a directory from a filename.
void zResetTagIdent(void)
reset the tag identifiers.
char * zStrrChar(const char *s, size_t size, int c)
find a specified charactor from the last in a string.
char * zGetBasenameDRC(char *name)
void zSetTagIdent(char begin_ident, char end_ident)
specify the tag identifiers.
char * zStrAddChar(char *str, size_t size, char c)
concatenate a string and a charactor.
#define __END_DECLS
Definition: zeda_defs.h:30
bool zFPostCheckKey(FILE *fp)
check if the last token is a key.
size_t size
Definition: zeda_stream.h:39
void zSetDelimiter(char s[])
specify a delimiter set.
char * zFDouble(FILE *fp, double *val)
get a d-float value in a file.
bool zIsIncludedChar(char c, char *s)
check if a charactor is included in a specified set.
char * zStrBSChar(char *str, int cur)
backspace a charactor from a string.
void zResetKeyIdent(void)
reset the key identifier.
miscellanies.
char * zSToken(char *str, char *tkn, size_t size)
FILE * zOpenFile(char filename[], char *suffix, char *mode)
open a file with default suffix.
int zFCountTag(FILE *fp, char *tag)
count a number of tag tokens in a file.
char * zSIntToken(char *str, char *tkn, size_t size)
tokenize an integer value in a string.
char * zSSkipDelimiter(char *str)
skip delimiter in a string.
char * zReplaceSuffix(char *org, char *suffix, char *dest, size_t size)
replace the suffix of a filename to a specified one.
char * zSInt(char *str, int *val)
get an integer value from a string.
void zResetOperator(void)
reset an operator set.
char * zStrCat(char *dest, const char *src, size_t size)
concatenate a string to another.
char * zSNumToken(char *str, char *tkn, size_t size)
tokenize a real number in a string.
char * zFInt(FILE *fp, int *val)
get an integer value from file.
void zSetOperator(char s[])
specify an operator set.
char * zSSkipWS(char *str)
skip whitespaces in a string.
char * zStrCharNul(const char *s, size_t size, int c)
find a specified charactor in a string.
char zFSkipIncludedChar(FILE *fp, char *s)
skip a certain charactors in a stream.
char * zStrCatPrint(char *str, size_t size, char *fmt,...)
concatenate a string with a formatted string.
char * zNullStr(void)
return the null string.
char * zStrSearchBM(char *text, char *pat)
string search by Boyer-Moore algorithm
void zFIndent(FILE *fp, int n)
insert whitespaces before a string.
char * zSSkipIncludedChar(char *str, char *s)
skip a certain charactors in a string.
void zSetCommentIdent(char ident)
specify the comment identifier.
char * zStrOvrChar(char *str, size_t size, int cur, char c)
override a charactor to a string.
FILE * fp
Definition: zeda_stream.h:36
bool zFieldFScan(FILE *fp, bool(*field_fscan)(FILE *, void *, char *, bool *), void *instance)
scan a field in a file.
char * zSTokenSkim(char *str, char *tkn, size_t size)
tokenize a string.
char * zStrCopy(char *dest, const char *src, size_t size)
copy a string.
bool zTokenIsTag(char *tkn)
check if a token is a tag.
void zSetKeyIdent(char ident)
specify the key identifier.
int zGetDirFilename(char *path, char *dirname, char *filename, size_t size)
get a directory name and a file name from a path.
char * zExtractTag(char *tag, char *notag)
extract a tag.
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
char * zStrSearchKMP(char *text, char *pat)
search string by Knuth-Morris-Pratt algorithm
bool zTagFScan(FILE *fp, bool(*tag_fscan)(FILE *, void *, char *, bool *), void *instance)
scan tagged fields in a file.
char zFSkipDelimiter(FILE *fp)
skip delimiter in a file.
char * zToUpper(char *src, char *dest)
convert a string to the uppercase set.
char * zCutSuffix(char *name)
cut a suffix from a filename
char * zStrChar(const char *s, size_t size, int c)
find a specified charactor in a string.
char * zStrClone(char *str)
clone a string.
int zFCountKey(FILE *fp, char *key)
count keywords in a file.
bool zIsDelimiter(char c)
check if a charactor is a delimiter.
void zResetCommentIdent(void)
reset the comment identifier.
#define zIndent(n)
Definition: zeda_string.h:706
#define __EXPORT
Definition: zeda_compat.h:32
char * zStrInsChar(char *str, size_t size, int cur, char c)
insert a charactor to a string.
char zFSkipComment(FILE *fp)
skip comments.
char * zStrDelChar(char *str, int cur)
delete a charactor from a string.
char * zAddSuffix(char *org, char *suffix, char *dest, size_t size)
add a suffix to a filename.
char * zFToken(FILE *fp, char *tkn, size_t size)
tokenize a file.
void zResetDelimiter(void)
reset a delimiter set.
char zFSkipWS(FILE *fp)
skip whitespaces in a file.
bool zStrIsHex(char *str)
check if a string represents a hexadecimal number.
char * zFNumToken(FILE *fp, char *tkn, size_t size)
tokenize a real number in a file.
char * zToLower(char *src, char *dest)
convert a string to the lowercase set.
byte * cur
Definition: zeda_stream.h:38
char * zCutNL(char *str)
cut a newline charactor.