2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
17 static char UNUSED id[] = "$Id: tool.c,v 1.3 2005/03/19 18:43:52 fw Exp $";
30 ngt_TrimStr( char *String )
32 /* Mit ngt_TrimStr() werden fuehrende und folgende Leerzeichen,
33 * Tabulatoren und Zeilenumbrueche (ASCII 10 und ASCII 13) aus
34 * dem String entfernt. */
38 assert( String != NULL );
42 /* Zeichen am Anfang pruefen ... */
43 while(( *start == ' ' ) || ( *start == 9 )) start++;
45 /* Zeichen am Ende pruefen ... */
46 ptr = strchr( start, '\0' ) - 1;
47 while((( *ptr == ' ' ) || ( *ptr == 9 ) || ( *ptr == 10 ) || ( *ptr == 13 )) && ptr >= start ) ptr--;
50 memmove( String, start, strlen( start ) + 1 );
55 ngt_LowerStr( char *String )
57 /* String in Kleinbuchstaben konvertieren. Der uebergebene
58 * Speicherbereich wird durch das Ergebnis ersetzt, zusaetzlich
59 * wird dieser auch als Pointer geliefert. */
63 assert( String != NULL );
65 /* Zeichen konvertieren */
69 *ptr = tolower( *ptr );
78 ngt_TrimLastChr( char *String, const char Chr)
80 /* If last character in the string matches Chr, remove it.
81 * Empty strings are handled correctly. */
85 assert( String != NULL );
87 len = strlen( String );
88 if( len == 0 ) return;
92 if( String[len] == Chr ) String[len] = '\0';
93 } /* ngt_TrimLastChr */