From 2eab7cfc483f2a754cc3ea71e8a6e40289850931 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 6 Feb 2000 13:21:14 +0000 Subject: [PATCH] Removed the `lockfile' argument; we now use a configure check to determine 2000-02-06 Martin Baulig * include/glibtop/ppp.h (glibtop_get_ppp): Removed the `lockfile' argument; we now use a configure check to determine the modem lockfile. * include/glibtop/error.h (GLIBTOP_ERROR_NEED_MODEM_LOCKFILE): Removed this now obsolete error constant again. * configure.in (--with-modem-lockfile): New configure parameter to manually specify the modem lockfile. (LIBGTOP_MODEM_LOCKFILE): Define this to be a printf-format string for the modem lockfile; takes the interface number as argument. --- ChangeLog | 14 ++++++++++++++ acconfig.h | 4 ++++ features.def | 2 +- include/glibtop/errors.h | 3 +-- include/glibtop/ppp.h | 8 ++++---- libgtop-sysdeps.m4 | 11 +++++++++++ sysdeps/freebsd/ppp.c | 2 +- sysdeps/linux/ppp.c | 19 +++++++++---------- sysdeps/osf1/ppp.c | 2 +- sysdeps/solaris/ppp.c | 2 +- sysdeps/stub/ppp.c | 2 +- sysdeps/stub_suid/ppp.c | 2 +- 12 files changed, 49 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 702acb85..b0670a9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-02-06 Martin Baulig + + * include/glibtop/ppp.h (glibtop_get_ppp): Removed the `lockfile' + argument; we now use a configure check to determine the modem + lockfile. + + * include/glibtop/error.h (GLIBTOP_ERROR_NEED_MODEM_LOCKFILE): + Removed this now obsolete error constant again. + + * configure.in (--with-modem-lockfile): New configure parameter + to manually specify the modem lockfile. + (LIBGTOP_MODEM_LOCKFILE): Define this to be a printf-format string + for the modem lockfile; takes the interface number as argument. + 2000-02-05 Martin Baulig * include/glibtop/interfaces.h (glibtop_ipv6_scope): New diff --git a/acconfig.h b/acconfig.h index 9c1897bb..f4939101 100644 --- a/acconfig.h +++ b/acconfig.h @@ -176,3 +176,7 @@ /* Define if you have the libxml library */ #undef HAVE_LIBXML +/* Modem lockfile for PPP support. This is a printf-like format string + * which takes the interface number as argument + * (default '/var/lock/LCK..ttyS%u'). */ +#undef LIBGTOP_MODEM_LOCKFILE diff --git a/features.def b/features.def index 258a0191..41c0acde 100644 --- a/features.def +++ b/features.def @@ -21,4 +21,4 @@ retval|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string(mount_dir) array(glibtop_interface)|interface_names|array|ulong(interface,number,instance,strategy) array(glibtop_ifaddr)|netinfo|array:ulong(if_flags,transport,mtu)|string(interface):ulong(transport) retval|netload|ulong(packets_in,packets_out,packets_total,bytes_in,bytes_out,bytes_total,errors_in,errors_out,errors_total,collisions)|string(interface):unsigned(transport,protocol) -retval|ppp|ulong(state,bytes_in,bytes_out)|ushort(device,use_isdn):string(lockfile) +retval|ppp|ulong(state,bytes_in,bytes_out)|ushort(device,use_isdn) diff --git a/include/glibtop/errors.h b/include/glibtop/errors.h index 6523047d..56f5b9a7 100644 --- a/include/glibtop/errors.h +++ b/include/glibtop/errors.h @@ -49,9 +49,8 @@ BEGIN_LIBGTOP_DECLS #define GLIBTOP_ERROR_NO_BACKEND_OPENED 12 #define GLIBTOP_ERROR_DEMARSHAL_ERROR 13 -#define GLIBTOP_ERROR_NEED_MODEM_LOCKFILE 14 -#define GLIBTOP_MAX_ERROR 15 +#define GLIBTOP_MAX_ERROR 14 char * glibtop_get_error_string_l (glibtop *server, unsigned error_number); diff --git a/include/glibtop/ppp.h b/include/glibtop/ppp.h index 29aabb85..2df5bccd 100644 --- a/include/glibtop/ppp.h +++ b/include/glibtop/ppp.h @@ -53,7 +53,7 @@ struct _glibtop_ppp bytes_out; /* GLIBTOP_PPP_BYTES_OUT */ }; -#define glibtop_get_ppp(ppp,device,use_isdn,lockfile) glibtop_get_ppp_l(glibtop_global_server, ppp, device, use_isdn, lockfile) +#define glibtop_get_ppp(ppp,device,use_isdn) glibtop_get_ppp_l(glibtop_global_server, ppp, device, use_isdn) #if GLIBTOP_SUID_PPP #define glibtop_get_ppp_r glibtop_get_ppp_p @@ -61,14 +61,14 @@ struct _glibtop_ppp #define glibtop_get_ppp_r glibtop_get_ppp_s #endif -int glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn, const char *lockfile); +int glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #if GLIBTOP_SUID_PPP int glibtop_init_ppp_p (glibtop *server); -int glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn, const char *lockfile); +int glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #else int glibtop_init_ppp_s (glibtop *server); -int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn, const char *lockfile); +int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #endif #ifdef GLIBTOP_NAMES diff --git a/libgtop-sysdeps.m4 b/libgtop-sysdeps.m4 index 37f8e39d..c4332291 100644 --- a/libgtop-sysdeps.m4 +++ b/libgtop-sysdeps.m4 @@ -348,6 +348,17 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[ ;; esac + AC_MSG_CHECKING(for Modem lockfile) + AC_ARG_WITH(modem-lockfile, + [ --with-modem-lockfile Modem lockfile for PPP support],[libgtop_modem_lockfile="$withval"], + [if test -f /dev/modem ; then + libgtop_modem_lockfile='/var/lock/LCK..modem' + else + libgtop_modem_lockfile='/var/lock/LCK..ttyS%u' + fi]) + AC_MSG_RESULT($libgtop_modem_lockfile) + AC_DEFINE_UNQUOTED(LIBGTOP_MODEM_LOCKFILE, "$libgtop_modem_lockfile") + AC_MSG_CHECKING(for machine.h in libgtop sysdeps dir) AC_MSG_RESULT($libgtop_use_machine_h) diff --git a/sysdeps/freebsd/ppp.c b/sysdeps/freebsd/ppp.c index 0964eb86..5e1bff09 100644 --- a/sysdeps/freebsd/ppp.c +++ b/sysdeps/freebsd/ppp.c @@ -94,7 +94,7 @@ glibtop_init_ppp_p (glibtop *server) int glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) + unsigned short isdn) { #ifdef HAVE_I4B #ifdef HAVE_I4B_ACCT diff --git a/sysdeps/linux/ppp.c b/sysdeps/linux/ppp.c index 61ec7b8a..ec70ecdd 100644 --- a/sysdeps/linux/ppp.c +++ b/sysdeps/linux/ppp.c @@ -116,7 +116,7 @@ get_ISDN_stats (glibtop *server, int *in, int *out) } static int -is_ISDN_on (glibtop *server, int *online) +is_ISDN_on (glibtop *server, int device, int *online) { FILE *f = 0; char buffer [BUFSIZ], *p; @@ -211,11 +211,13 @@ is_ISDN_on (glibtop *server, int *online) } static int -is_Modem_on (glibtop *server, const char *lock_file) +is_Modem_on (glibtop *server, int device) { - FILE *f = 0; - gchar buf[64]; + gchar buf[64], lock_file [BUFSIZ]; pid_t pid = -1; + FILE *f = 0; + + sprintf (lock_file, LIBGTOP_MODEM_LOCKFILE, device); f = fopen (lock_file, "r"); @@ -275,7 +277,7 @@ get_Modem_stats (int device, int *in, int *out) int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short use_isdn, const char *lockfile) + unsigned short use_isdn) { int in, out, online; @@ -285,7 +287,7 @@ glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, if (use_isdn) { /* ISDN */ - if (is_ISDN_on (server, &online)) { + if (is_ISDN_on (server, device, &online)) { buf->state = online ? GLIBTOP_PPP_STATE_ONLINE : GLIBTOP_PPP_STATE_HANGUP; buf->flags |= (1L << GLIBTOP_PPP_STATE); @@ -299,10 +301,7 @@ glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, } } else { /* Modem */ - if (!lockfile) - return -GLIBTOP_ERROR_NEED_MODEM_LOCKFILE; - - buf->state = is_Modem_on (server, lockfile) ? + buf->state = is_Modem_on (server, device) ? GLIBTOP_PPP_STATE_ONLINE : GLIBTOP_PPP_STATE_HANGUP; buf->flags |= (1L << GLIBTOP_PPP_STATE); diff --git a/sysdeps/osf1/ppp.c b/sysdeps/osf1/ppp.c index 8752e0d1..c60a31d0 100644 --- a/sysdeps/osf1/ppp.c +++ b/sysdeps/osf1/ppp.c @@ -43,7 +43,7 @@ glibtop_init_ppp_s (glibtop *server) int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) + unsigned short isdn) { memset (buf, 0, sizeof (glibtop_ppp)); return 0; diff --git a/sysdeps/solaris/ppp.c b/sysdeps/solaris/ppp.c index fdc348e9..a5cd1e0a 100644 --- a/sysdeps/solaris/ppp.c +++ b/sysdeps/solaris/ppp.c @@ -43,7 +43,7 @@ glibtop_init_ppp_s (glibtop *server) int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) + unsigned short isdn) { memset (buf, 0, sizeof (glibtop_ppp)); diff --git a/sysdeps/stub/ppp.c b/sysdeps/stub/ppp.c index fdc348e9..a5cd1e0a 100644 --- a/sysdeps/stub/ppp.c +++ b/sysdeps/stub/ppp.c @@ -43,7 +43,7 @@ glibtop_init_ppp_s (glibtop *server) int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) + unsigned short isdn) { memset (buf, 0, sizeof (glibtop_ppp)); diff --git a/sysdeps/stub_suid/ppp.c b/sysdeps/stub_suid/ppp.c index 30a168c1..cfbcddec 100644 --- a/sysdeps/stub_suid/ppp.c +++ b/sysdeps/stub_suid/ppp.c @@ -45,7 +45,7 @@ glibtop_init_ppp_p (glibtop *server) int glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn, const char *lockfile) + unsigned short isdn) { glibtop_init_p (server, GLIBTOP_SYSDEPS_PPP, 0);