Blame


1 0f3e84f4 2003-01-13 alex /*
2 0f3e84f4 2003-01-13 alex * ngIRCd -- The Next Generation IRC Daemon
3 0f3e84f4 2003-01-13 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 0f3e84f4 2003-01-13 alex *
5 0f3e84f4 2003-01-13 alex * This program is free software; you can redistribute it and/or modify
6 0f3e84f4 2003-01-13 alex * it under the terms of the GNU General Public License as published by
7 0f3e84f4 2003-01-13 alex * the Free Software Foundation; either version 2 of the License, or
8 0f3e84f4 2003-01-13 alex * (at your option) any later version.
9 0f3e84f4 2003-01-13 alex * Please read the file COPYING, README and AUTHORS for more information.
10 0f3e84f4 2003-01-13 alex *
11 0f3e84f4 2003-01-13 alex * Tool functions
12 0f3e84f4 2003-01-13 alex */
13 0f3e84f4 2003-01-13 alex
14 0f3e84f4 2003-01-13 alex
15 0f3e84f4 2003-01-13 alex #include "portab.h"
16 0f3e84f4 2003-01-13 alex
17 0f3e84f4 2003-01-13 alex static char UNUSED id[] = "$Id: tool.c,v 1.1 2003/01/13 12:20:16 alex Exp $";
18 0f3e84f4 2003-01-13 alex
19 0f3e84f4 2003-01-13 alex #include "imp.h"
20 0f3e84f4 2003-01-13 alex #include <assert.h>
21 0f3e84f4 2003-01-13 alex #include <ctype.h>
22 0f3e84f4 2003-01-13 alex #include <stdio.h>
23 0f3e84f4 2003-01-13 alex #include <string.h>
24 0f3e84f4 2003-01-13 alex
25 0f3e84f4 2003-01-13 alex #include "exp.h"
26 0f3e84f4 2003-01-13 alex #include "tool.h"
27 0f3e84f4 2003-01-13 alex
28 0f3e84f4 2003-01-13 alex
29 0f3e84f4 2003-01-13 alex GLOBAL VOID
30 0f3e84f4 2003-01-13 alex ngt_TrimStr( CHAR *String )
31 0f3e84f4 2003-01-13 alex {
32 0f3e84f4 2003-01-13 alex /* Mit ngt_TrimStr() werden fuehrende und folgende Leerzeichen,
33 0f3e84f4 2003-01-13 alex * Tabulatoren und Zeilenumbrueche (ASCII 10 und ASCII 13) aus
34 0f3e84f4 2003-01-13 alex * dem String entfernt. */
35 0f3e84f4 2003-01-13 alex
36 0f3e84f4 2003-01-13 alex CHAR *start, *ptr;
37 0f3e84f4 2003-01-13 alex
38 0f3e84f4 2003-01-13 alex assert( String != NULL );
39 0f3e84f4 2003-01-13 alex
40 0f3e84f4 2003-01-13 alex start = String;
41 0f3e84f4 2003-01-13 alex
42 0f3e84f4 2003-01-13 alex /* Zeichen am Anfang pruefen ... */
43 0f3e84f4 2003-01-13 alex while(( *start == ' ' ) || ( *start == 9 )) start++;
44 0f3e84f4 2003-01-13 alex
45 0f3e84f4 2003-01-13 alex /* Zeichen am Ende pruefen ... */
46 0f3e84f4 2003-01-13 alex ptr = strchr( start, '\0' ) - 1;
47 0f3e84f4 2003-01-13 alex while((( *ptr == ' ' ) || ( *ptr == 9 ) || ( *ptr == 10 ) || ( *ptr == 13 )) && ptr >= start ) ptr--;
48 0f3e84f4 2003-01-13 alex *(++ptr) = '\0';
49 0f3e84f4 2003-01-13 alex
50 0f3e84f4 2003-01-13 alex memmove( String, start, strlen( start ) + 1 );
51 0f3e84f4 2003-01-13 alex } /* ngt_TrimStr */
52 0f3e84f4 2003-01-13 alex
53 0f3e84f4 2003-01-13 alex
54 0f3e84f4 2003-01-13 alex GLOBAL CHAR *
55 0f3e84f4 2003-01-13 alex ngt_LowerStr( CHAR *String )
56 0f3e84f4 2003-01-13 alex {
57 0f3e84f4 2003-01-13 alex /* String in Kleinbuchstaben konvertieren. Der uebergebene
58 0f3e84f4 2003-01-13 alex * Speicherbereich wird durch das Ergebnis ersetzt, zusaetzlich
59 0f3e84f4 2003-01-13 alex * wird dieser auch als Pointer geliefert. */
60 0f3e84f4 2003-01-13 alex
61 0f3e84f4 2003-01-13 alex CHAR *ptr;
62 0f3e84f4 2003-01-13 alex
63 0f3e84f4 2003-01-13 alex assert( String != NULL );
64 0f3e84f4 2003-01-13 alex
65 0f3e84f4 2003-01-13 alex /* Zeichen konvertieren */
66 0f3e84f4 2003-01-13 alex ptr = String;
67 0f3e84f4 2003-01-13 alex while( *ptr )
68 0f3e84f4 2003-01-13 alex {
69 0f3e84f4 2003-01-13 alex *ptr = tolower( *ptr );
70 0f3e84f4 2003-01-13 alex ptr++;
71 0f3e84f4 2003-01-13 alex }
72 0f3e84f4 2003-01-13 alex
73 0f3e84f4 2003-01-13 alex return String;
74 0f3e84f4 2003-01-13 alex } /* ngt_LowerStr */
75 0f3e84f4 2003-01-13 alex
76 0f3e84f4 2003-01-13 alex
77 0f3e84f4 2003-01-13 alex /* -eof- */