1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

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.
This commit is contained in:
Brian Somers 1998-06-15 19:06:58 +00:00
parent c9e11a112d
commit d93d3a9c32
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37010
16 changed files with 45 additions and 36 deletions

View File

@ -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)

View File

@ -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 *);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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"

View File

@ -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) {

View File

@ -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);
}

View File

@ -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 */

View File

@ -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;

View File

@ -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);

View File

@ -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",