1 | /* |
---|
2 | * bbftpd/bbftpd_utils.c |
---|
3 | * Copyright (C) 1999, 2000, 2001, 2002 IN2P3, CNRS |
---|
4 | * bbftp@in2p3.fr |
---|
5 | * http://doc.in2p3.fr/bbftp |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License |
---|
9 | * as published by the Free Software Foundation; either version 2 |
---|
10 | * of the License, or any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
20 | */ |
---|
21 | |
---|
22 | /**************************************************************************** |
---|
23 | |
---|
24 | |
---|
25 | Routines : void strip_trailing_slashes (char *path) |
---|
26 | void free_all_var() |
---|
27 | |
---|
28 | bbftpd_utils.c v 2.0.0 2000/12/19 - Routine creation |
---|
29 | v 2.0.1 2001/04/23 - Correct indentation |
---|
30 | |
---|
31 | |
---|
32 | *****************************************************************************/ |
---|
33 | |
---|
34 | #include <bbftpd.h> |
---|
35 | |
---|
36 | #include <stdlib.h> |
---|
37 | #include <stdio.h> |
---|
38 | #if HAVE_STRING_H |
---|
39 | # include <string.h> |
---|
40 | #endif |
---|
41 | |
---|
42 | extern char *curfilename ; |
---|
43 | extern char *realfilename ; |
---|
44 | extern int curfilenamelen ; |
---|
45 | extern int *myports ; |
---|
46 | extern int *mychildren ; |
---|
47 | extern int *mysockets ; |
---|
48 | extern int *readbuffer; |
---|
49 | extern int *compbuffer; |
---|
50 | extern int nbpidchild ; |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | /* |
---|
55 | ** Taken from Free Software Foundation |
---|
56 | */ |
---|
57 | void strip_trailing_slashes (char *path) |
---|
58 | { |
---|
59 | int last; |
---|
60 | |
---|
61 | last = strlen (path) - 1; |
---|
62 | while (last > 0 && path[last] == '/') |
---|
63 | path[last--] = '\0'; |
---|
64 | } |
---|
65 | |
---|
66 | /******************************************************************************* |
---|
67 | ** free_all_var : * |
---|
68 | ** * |
---|
69 | ** Routine to free all global variables * |
---|
70 | ** * |
---|
71 | ** * |
---|
72 | ** GLOBAL VARIABLE USED : * * |
---|
73 | ** all * |
---|
74 | ** * |
---|
75 | ** * |
---|
76 | *******************************************************************************/ |
---|
77 | |
---|
78 | void free_all_var() |
---|
79 | { |
---|
80 | if ( curfilename != NULL ) { |
---|
81 | free(curfilename) ; |
---|
82 | curfilename = NULL ; |
---|
83 | curfilenamelen = 0 ; |
---|
84 | } |
---|
85 | if ( realfilename != NULL ) { |
---|
86 | free(realfilename) ; |
---|
87 | realfilename = NULL ; |
---|
88 | } |
---|
89 | if ( myports != NULL ) { |
---|
90 | free(myports) ; |
---|
91 | myports = NULL ; |
---|
92 | } |
---|
93 | if ( mychildren != NULL ) { |
---|
94 | free(mychildren) ; |
---|
95 | mychildren = NULL ; |
---|
96 | } |
---|
97 | if ( mysockets != NULL ) { |
---|
98 | free(mysockets) ; |
---|
99 | mysockets = NULL ; |
---|
100 | } |
---|
101 | if ( readbuffer != NULL ) { |
---|
102 | free(readbuffer) ; |
---|
103 | readbuffer = NULL ; |
---|
104 | } |
---|
105 | if ( compbuffer != NULL ) { |
---|
106 | free(compbuffer) ; |
---|
107 | compbuffer = NULL ; |
---|
108 | } |
---|
109 | nbpidchild = 0 ; |
---|
110 | } |
---|
111 | |
---|