1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
5 * Function:..String Handling Functions *
9 * Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
10 * Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
11 * neuer Dienste, Universitaet Tuebingen, GERMANY *
14 * Creation date: Z D D V V *
15 * February 13 1996 Z D D V V *
16 * Last modification: Z D D V V *
17 * November 3 1998 ZZZZ DDD V *
19 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
22 * $Id: strng.c,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
26 #include "strng_exp.h"
30 * Convert string to integer by means of a dispatcherlist
31 * if string is not in the dispatcher -> return default
34 PUBLIC int cnvt_str2int (stringVal, dispatcher, defaultVal)
39 int retVal = defaultVal;
42 for (disp = dispatcher; disp->stringVal; disp++) {
44 if (!strncmp (stringVal, disp->stringVal, disp->abbr)) {
46 retVal = disp->intVal;
58 * Truncate characters at the beginning of a string
61 PUBLIC char * trimleft (s, what)
65 return (s + strspn (s, what));
71 * Truncate characters at the end of a string
74 PUBLIC char * trimright (s, what)
77 char *tmp = s + strlen (s) - 1;
79 while ((tmp >= s) && strchr (what, *tmp)) *tmp-- = '\0';
87 * Truncate characters at the beginning and end of a string
90 PUBLIC char * trim (s, what)
93 (void) trimright (s, what);
94 return (trimleft (s, what));
100 * Convert a string to lower-case "in place"
104 PUBLIC char *str_tolower (source)
107 char *target = source;
109 for (; *target; target++) *target = tolower (*target);
116 * Convert a string to upper-case "in place"
120 PUBLIC char *str_toupper (source)
123 char *target = source;
125 for (; *target; target++){
126 *target = toupper (*target);
128 /* Patch fuer Umlaute */
129 if(*target == 'ä') *target = 'Ä';
130 else if(*target == 'ö') *target = 'Ö';
131 else if(*target == 'ü') *target = 'Ü';
139 * Substitute a character in a string by another
142 PUBLIC char *tr1 (source, from, to)
146 char *target = source - 1;
148 while ( ( target = strchr( ++target, from )) ) *target = to;
155 PUBLIC int chrcnt(string, c)
162 while( ( string = strpbrk(string+1, c)) )
166 /* end of function: chrcnt */
170 qSortByString( a, b )
173 return strcmp( *a, *b );
175 /* end of function: qSortByString */