iniparser/src/strlib.c

Various string handling routines to complement the C lib. [詳細]

ソースコードを見る。

関数

char * strlwc (const char *s)
 Convert a string to lowercase.
char * strupc (char *s)
 Convert a string to uppercase.
char * strskp (char *s)
 Skip blanks until the first non-blank character.
char * strcrop (char *s)
 Remove blanks at the end of a string.
char * strstrip (char *s)
 Remove blanks at the beginning and the end of a string.
int main (int argc, char *argv[])


説明

Various string handling routines to complement the C lib.

作者:
N. Devillard
日付:
Jan 2001
バージョン:
Revision
1.8
This modules adds a few complementary string routines usually missing in the standard C library.

strlib.c で定義されています。


関数

char* strlwc ( const char *  s  ) 

Convert a string to lowercase.

引数:
s String to convert.
戻り値:
ptr to statically allocated string.
This function returns a pointer to a statically allocated string containing a lowercased version of the input string. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant).

strlib.c54 行で定義されています。

参照元 iniparser_getstring()iniparser_load()iniparser_setstr()iniparser_unset()main().

00055 {
00056     static char l[ASCIILINESZ+1];
00057     int i ;
00058 
00059     if (s==NULL) return NULL ;
00060     memset(l, 0, ASCIILINESZ+1);
00061     i=0 ;
00062     while (s[i] && i<ASCIILINESZ) {
00063         l[i] = (char)tolower((int)s[i]);
00064         i++ ;
00065     }
00066     l[ASCIILINESZ]=(char)0;
00067     return l ;
00068 }

char* strupc ( char *  s  ) 

Convert a string to uppercase.

引数:
s String to convert.
戻り値:
ptr to statically allocated string.
This function returns a pointer to a statically allocated string containing an uppercased version of the input string. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant).

strlib.c85 行で定義されています。

参照元 main().

00086 {
00087     static char l[ASCIILINESZ+1];
00088     int i ;
00089 
00090     if (s==NULL) return NULL ;
00091     memset(l, 0, ASCIILINESZ+1);
00092     i=0 ;
00093     while (s[i] && i<ASCIILINESZ) {
00094         l[i] = (char)toupper((int)s[i]);
00095         i++ ;
00096     }
00097     l[ASCIILINESZ]=(char)0;
00098     return l ;
00099 }

char* strskp ( char *  s  ) 

Skip blanks until the first non-blank character.

引数:
s String to parse.
戻り値:
Pointer to char inside given string.
This function returns a pointer to the first non-blank character in the given string.

strlib.c114 行で定義されています。

参照元 iniparser_load()main().

00115 {
00116     char * skip = s;
00117         if (s==NULL) return NULL ;
00118     while (isspace((int)*skip) && *skip) skip++;
00119     return skip ;
00120 } 

char* strcrop ( char *  s  ) 

Remove blanks at the end of a string.

引数:
s String to parse.
戻り値:
ptr to statically allocated string.
This function returns a pointer to a statically allocated string, which is identical to the input string, except that all blank characters at the end of the string have been removed. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant).

strlib.c139 行で定義されています。

参照元 iniparser_load()main().

00140 {
00141     static char l[ASCIILINESZ+1];
00142         char * last ;
00143 
00144     if (s==NULL) return NULL ;
00145     memset(l, 0, ASCIILINESZ+1);
00146         strcpy(l, s);
00147         last = l + strlen(l);
00148         while (last > l) {
00149                 if (!isspace((int)*(last-1)))
00150                         break ;
00151                 last -- ;
00152         }
00153         *last = (char)0;
00154     return l ;
00155 }

char* strstrip ( char *  s  ) 

Remove blanks at the beginning and the end of a string.

引数:
s String to parse.
戻り値:
ptr to statically allocated string.
This function returns a pointer to a statically allocated string, which is identical to the input string, except that all blank characters at the end and the beg. of the string have been removed. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant).

strlib.c173 行で定義されています。

参照元 main().

00174 {
00175     static char l[ASCIILINESZ+1];
00176         char * last ;
00177         
00178     if (s==NULL) return NULL ;
00179     
00180         while (isspace((int)*s) && *s) s++;
00181         
00182         memset(l, 0, ASCIILINESZ+1);
00183         strcpy(l, s);
00184         last = l + strlen(l);
00185         while (last > l) {
00186                 if (!isspace((int)*(last-1)))
00187                         break ;
00188                 last -- ;
00189         }
00190         *last = (char)0;
00191 
00192         return (char*)l ;
00193 }

int main ( int  argc,
char *  argv[] 
)

strlib.c197 行で定義されています。

参照先 printf()strcrop()strlwc()strskp()strstrip()strupc().

00198 {
00199         char * str ;
00200 
00201         str = "\t\tI'm a lumberkack and I'm OK      " ;
00202         printf("lowercase: [%s]\n", strlwc(str));
00203         printf("uppercase: [%s]\n", strupc(str));
00204         printf("skipped  : [%s]\n", strskp(str));
00205         printf("cropped  : [%s]\n", strcrop(str));
00206         printf("stripped : [%s]\n", strstrip(str));
00207 
00208         return 0 ;
00209 }


Sambaに対してSat Aug 29 21:23:35 2009に生成されました。  doxygen 1.4.7