diff options
author | Brian Somers <brian@FreeBSD.org> | 1998-06-15 19:06:58 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1998-06-15 19:06:58 +0000 |
commit | d93d3a9c32d3e1ba843e8e7033f6570c714f86df (patch) | |
tree | 688b48f8ca9968b60febe73fe13bf9be4db9b9d6 /usr.sbin | |
parent | c9e11a112d47edb5544b4bbe115837c89329c798 (diff) | |
download | src-d93d3a9c32d3e1ba843e8e7033f6570c714f86df.tar.gz src-d93d3a9c32d3e1ba843e8e7033f6570c714f86df.zip |
o De-staticise things that don't need to be static.
o Bring the static ``ttystate'' into struct prompt so that
the tilde context is per prompt and not global.
o Comment the remaining static variables so that it's
clear why they're static.
o Add some XXX comments suggesting that our interface list
and our hostname should be re-generated after a signal
(say SIGUSR1) so that a machine with PCCARDs has a chance.
Notes
Notes:
svn path=/head/; revision=37010
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/auth.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ccp.h | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/chat.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/deflate.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/ip.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/iplist.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/main.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/mp.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/prompt.c | 11 | ||||
-rw-r--r-- | usr.sbin/ppp/prompt.h | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/route.c | 12 | ||||
-rw-r--r-- | usr.sbin/ppp/timer.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/vjcomp.c | 4 |
16 files changed, 45 insertions, 36 deletions
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index ecc26f3e53d3..244201750c26 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.27.2.26 1998/05/01 19:23:52 brian Exp $ + * $Id: auth.c,v 1.29 1998/05/21 21:44:00 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -181,7 +181,7 @@ auth_GetSecret(struct bundle *bundle, const char *system, int len, FILE *fp; int n; char *vector[5]; - static char buff[LINE_LEN]; + char buff[LINE_LEN]; fp = OpenSecret(SECRETFILE); if (fp == NULL) diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index 8b1787bc6895..f7788858185f 100644 --- a/usr.sbin/ppp/ccp.h +++ b/usr.sbin/ppp/ccp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.h,v 1.15 1998/05/21 21:44:23 brian Exp $ + * $Id: ccp.h,v 1.16 1998/05/23 13:38:02 brian Exp $ * * TODO: */ @@ -93,8 +93,8 @@ struct ccp { struct ccp_algorithm { int id; - int Neg; /* ccp_config neg array item */ - const char *(*Disp)(struct lcp_opt *); + int Neg; /* ccp_config neg array item */ + const char *(*Disp)(struct lcp_opt *); /* Use result immediately ! */ struct { int (*Set)(struct lcp_opt *, const struct ccp_config *); void *(*Init)(struct lcp_opt *); diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index db7356fed7c1..662b7fdce6e5 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.46 1998/05/23 22:24:32 brian Exp $ + * $Id: chat.c,v 1.47 1998/05/28 23:17:38 brian Exp $ */ #include <sys/types.h> @@ -133,7 +133,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n) struct chat *c = descriptor2chat(d); int special, gotabort, gottimeout, needcr; int TimedOut = c->TimedOut; - static char arg_term; + static char arg_term; /* An empty string */ if (c->pause.state == TIMER_RUNNING) return 0; diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index 08e5f85f0265..4bc8bce4fceb 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: deflate.c,v 1.6.4.16 1998/05/15 18:21:03 brian Exp $ + * $Id: deflate.c,v 1.8 1998/05/21 21:45:00 brian Exp $ */ #include <sys/types.h> @@ -433,7 +433,7 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi) static const char * DeflateDispOpts(struct lcp_opt *o) { - static char disp[7]; + static char disp[7]; /* Must be used immediately */ sprintf(disp, "win %d", (o->data[0]>>4) + 8); return disp; diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c index d228eb3c5f42..95177de744a0 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: defs.c,v 1.14 1998/05/29 00:03:00 brian Exp $ + * $Id: defs.c,v 1.15 1998/05/29 18:32:11 brian Exp $ */ @@ -39,7 +39,7 @@ void randinit() { #if __FreeBSD__ >= 3 - static int initdone; + static int initdone; /* srandomdev() call is only required once */ if (!initdone) { initdone = 1; diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 1e0f6cb7f7f9..3a3b1f48fa2a 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.27.2.35 1998/05/01 19:24:32 brian Exp $ + * $Id: fsm.c,v 1.28 1998/05/21 21:45:20 brian Exp $ * * TODO: */ @@ -914,6 +914,7 @@ fsm_Input(struct fsm *fp, struct mbuf *bp) * MUST send a unique id for each REQ.... */ static u_char id; + fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt); mbuf_Free(bp); return; diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index f08031f545ac..3bb75aaea81e 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.41 1998/05/21 21:45:37 brian Exp $ + * $Id: ip.c,v 1.42 1998/06/14 01:21:24 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -252,7 +252,7 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter) int mask, len, n; int pri = PRI_NORMAL; int logit, loglen; - static char logbuf[200]; + char logbuf[200]; logit = log_IsKept(LogTCPIP) && filter->logok; loglen = 0; diff --git a/usr.sbin/ppp/iplist.c b/usr.sbin/ppp/iplist.c index 319f13088534..48e4b5e488c0 100644 --- a/usr.sbin/ppp/iplist.c +++ b/usr.sbin/ppp/iplist.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iplist.c,v 1.4.4.3 1998/05/01 19:24:54 brian Exp $ + * $Id: iplist.c,v 1.5 1998/05/21 21:45:53 brian Exp $ */ #include <sys/types.h> @@ -40,7 +40,7 @@ static int do_inet_aton(const char *start, const char *end, struct in_addr *ip) { - static char ipstr[16]; + char ipstr[16]; if (end - start > 15) { log_Printf(LogWARN, "%.*s: Invalid IP address\n", end-start, start); diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index 01de47a24f97..0c9c276bdcb8 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: log.c,v 1.29 1998/05/28 23:17:42 brian Exp $ + * $Id: log.c,v 1.30 1998/06/15 19:06:15 brian Exp $ */ #include <sys/types.h> @@ -290,7 +290,7 @@ log_Printf(int lev, const char *fmt,...) va_start(ap, fmt); if (log_IsKept(lev)) { - static char nfmt[200]; + char nfmt[200]; if ((log_IsKept(lev) & LOG_KEPT_LOCAL) && promptlist) { if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1) diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 65f62d12a201..4ef527a805ae 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.131 1998/06/15 19:05:22 brian Exp $ + * $Id: main.c,v 1.132 1998/06/15 19:05:46 brian Exp $ * * TODO: */ @@ -155,7 +155,7 @@ BringDownServer(int signo) static const char * ex_desc(int ex) { - static char num[12]; + static char num[12]; /* Used immediately if returned */ static const char *desc[] = { "normal", "start", "sock", "modem", "dial", "dead", "done", "reboot", "errdead", "hangup", "term", "nodial", "nologin" diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index d68d61e117ff..bdedb63daeca 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp.c,v 1.6 1998/05/25 02:22:38 brian Exp $ + * $Id: mp.c,v 1.7 1998/06/15 19:06:22 brian Exp $ */ #include <sys/types.h> @@ -710,7 +710,7 @@ mp_ShowStatus(struct cmdargs const *arg) const char * mp_Enddisc(u_char c, const char *address, int len) { - static char result[100]; + static char result[100]; /* Used immediately after it's returned */ int f, header; switch (c) { diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c index bb10f4b3c1f7..98bcbe4e97f6 100644 --- a/usr.sbin/ppp/prompt.c +++ b/usr.sbin/ppp/prompt.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.c,v 1.3 1998/05/23 22:24:48 brian Exp $ + * $Id: prompt.c,v 1.4 1998/05/27 22:43:37 brian Exp $ */ #include <sys/param.h> @@ -72,6 +72,7 @@ static void prompt_Display(struct prompt *p) { + /* XXX: See Index2Nam() - should we only figure this out once ? */ static char shostname[MAXHOSTNAMELEN]; const char *pconnect, *pauth; @@ -170,7 +171,6 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) struct prompt *p = descriptor2prompt(d); int n; char ch; - static int ttystate; char linebuff[LINE_LEN]; if (p->TermMode == NULL) { @@ -221,10 +221,10 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) log_Printf(LogDEBUG, "Got %d bytes (reading from the terminal)\n", n); if (n > 0) { - switch (ttystate) { + switch (p->readtilde) { case 0: if (ch == '~') - ttystate++; + p->readtilde = 1; else if (physical_Write(p->TermMode->physical, &ch, n) < 0) { log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno)); @@ -259,7 +259,7 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) } break; } - ttystate = 0; + p->readtilde = 0; break; } } @@ -311,6 +311,7 @@ prompt_Create(struct server *s, struct bundle *bundle, int fd) p->TermMode = NULL; p->nonewline = 1; p->needprompt = 1; + p->readtilde = 0; p->bundle = bundle; log_RegisterPrompt(p); } diff --git a/usr.sbin/ppp/prompt.h b/usr.sbin/ppp/prompt.h index cda800beccf4..13a5fccb8090 100644 --- a/usr.sbin/ppp/prompt.h +++ b/usr.sbin/ppp/prompt.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.h,v 1.2 1998/05/21 21:48:02 brian Exp $ + * $Id: prompt.h,v 1.3 1998/05/23 22:24:49 brian Exp $ */ #define LOCAL_AUTH 0x01 @@ -48,6 +48,7 @@ struct prompt { unsigned nonewline : 1; /* need a newline before our prompt ? */ unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */ unsigned active : 1; /* Is the prompt active (^Z) */ + unsigned readtilde : 1; /* We've read a ``~'' from fd_in */ struct { const char *type; /* Type of connection */ diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index d4ac9ed69568..328c0479fb21 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.46 1998/06/10 00:16:07 brian Exp $ + * $Id: route.c,v 1.47 1998/06/15 19:06:23 brian Exp $ * */ @@ -194,8 +194,14 @@ p_flags(struct prompt *prompt, u_long f, int max) const char * Index2Nam(int idx) { - static char **ifs; - static int nifs, debug_done; + /* + * XXX: Maybe we should select() on the routing socket so that we can + * notice interfaces that come & go (PCCARD support). + * Or we could even support a signal that resets these so that + * the PCCARD insert/remove events can signal ppp. + */ + static char **ifs; /* Figure these out once */ + static int nifs, debug_done; /* Figure out how many once, and debug once */ if (!nifs) { int mib[6], have, had; diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c index c8e41f1ff5fd..be8a8b2b2a5d 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: timer.c,v 1.27.2.11 1998/05/08 01:15:18 brian Exp $ + * $Id: timer.c,v 1.28 1998/05/21 21:48:46 brian Exp $ * * TODO: */ @@ -149,8 +149,8 @@ TimerService(void) struct pppTimer *tp, *exp, *wt; if (log_IsKept(LogTIMER)) { - static time_t t; - time_t n = time(NULL); /* Only show timers every second */ + static time_t t; /* Only show timers globally every second */ + time_t n = time(NULL); if (n > t) timer_Show(LogTIMER, NULL); diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index 615ffa99c47e..6fd0d59cae6f 100644 --- a/usr.sbin/ppp/vjcomp.c +++ b/usr.sbin/ppp/vjcomp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vjcomp.c,v 1.17 1998/05/21 21:49:06 brian Exp $ + * $Id: vjcomp.c,v 1.18 1998/06/14 00:56:13 brian Exp $ * * TODO: */ @@ -165,7 +165,7 @@ vj_Input(struct ipcp *ipcp, struct mbuf *bp, int proto) const char * vj2asc(u_int32_t val) { - static char asc[50]; + static char asc[50]; /* The return value is used immediately */ if (val) snprintf(asc, sizeof asc, "%d VJ slots %s slot compression", |