Delete the QTimer before assigning null.
[kdenetwork.git] / kppp / utils.cpp
blob48fd0fafbc62ff698e48676d511e09cdc3f725b9
1 //---------------------------------------------------------------------------
2 //
3 // kPPP: A pppd front end for the KDE project
4 //
5 //---------------------------------------------------------------------------
6 //
7 // (c) 1997-1998 Bernd Johannes Wuebben <wuebben@kde.org>
8 // (c) 1997-1999 Mario Weilguni <mweilguni@kde.org>
9 // (c) 1998-1999 Harri Porten <porten@kde.org>
11 // derived from Jay Painters "ezppp"
13 //---------------------------------------------------------------------------
15 // $Id$
17 //---------------------------------------------------------------------------
19 // This program is free software; you can redistribute it and-or
20 // modify it under the terms of the GNU Library General Public
21 // License as published by the Free Software Foundation; either
22 // version 2 of the License, or (at your option) any later version.
24 // This program is distributed in the hope that it will be useful,
25 // but WITHOUT ANY WARRANTY; without even the implied warranty of
26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 // Library General Public License for more details.
29 // You should have received a copy of the GNU Library General Public
30 // License along with this program; if not, write to the Free
31 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 //---------------------------------------------------------------------------
35 #include <sys/types.h>
36 #include <sys/stat.h>
38 #include <unistd.h>
39 #include <stdio.h>
40 #include <limits.h>
42 #include "utils.h"
43 #include "kpppconfig.h"
45 // in case of error, we simply return "0" and hope it's ok :-)
46 int pppInterfaceNumber() {
47 char ifname[PATH_MAX];
49 for(int i = 0; i < 8; i++) {
50 snprintf(ifname, sizeof(ifname), "%s/ppp%d.pid", PPP_PID_DIR, i);
51 if(access(ifname, F_OK) == -1)
52 return i;
55 // panic
56 fprintf(stderr, "pppInterfaceNumber: cannot detect ppp interface number!\n");
57 return 0;