global.c revision 178825
1285612Sdelphij/* 2258945Sroberto * Copyright (c) 1989, 1993 3275970Scy * The Regents of the University of California. All rights reserved. 4285612Sdelphij * 5285612Sdelphij * Redistribution and use in source and binary forms, with or without 6285612Sdelphij * modification, are permitted provided that the following conditions 7258945Sroberto * are met: 8258945Sroberto * 1. Redistributions of source code must retain the above copyright 9258945Sroberto * notice, this list of conditions and the following disclaimer. 10258945Sroberto * 2. Redistributions in binary form must reproduce the above copyright 11285612Sdelphij * notice, this list of conditions and the following disclaimer in the 12258945Sroberto * documentation and/or other materials provided with the distribution. 13258945Sroberto * 3. All advertising materials mentioning features or use of this software 14258945Sroberto * must display the following acknowledgement: 15258945Sroberto * This product includes software developed by the University of 16285612Sdelphij * California, Berkeley and its contributors. 17258945Sroberto * 4. Neither the name of the University nor the names of its contributors 18258945Sroberto * may be used to endorse or promote products derived from this software 19258945Sroberto * without specific prior written permission. 20258945Sroberto * 21258945Sroberto * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22258945Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23258945Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24258945Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25258945Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26258945Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27258945Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28258945Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29285612Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30258945Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31258945Sroberto * SUCH DAMAGE. 32258945Sroberto */ 33278284Scy 34278284Scy/* a *lot* of ugly global definitions that really should be removed... 35285612Sdelphij */ 36275970Scy 37275970Scy#include "telnetd.h" 38275970Scy 39275970ScyRCSID("$Id: global.c 14939 2005-04-24 20:59:35Z lha $"); 40275970Scy 41275970Scy/* 42258945Sroberto * Telnet server variable declarations 43285612Sdelphij */ 44258945Srobertochar options[256]; 45258945Srobertochar do_dont_resp[256]; 46285612Sdelphijchar will_wont_resp[256]; 47285612Sdelphijint linemode; /* linemode on/off */ 48285612Sdelphijint flowmode; /* current flow control state */ 49285612Sdelphijint restartany; /* restart output on any character state */ 50285612Sdelphij#ifdef DIAGNOSTICS 51285612Sdelphijint diagnostic; /* telnet diagnostic capabilities */ 52285612Sdelphij#endif /* DIAGNOSTICS */ 53285612Sdelphijint require_otp; 54285612Sdelphij 55285612Sdelphijslcfun slctab[NSLC + 1]; /* slc mapping table */ 56285612Sdelphij 57285612Sdelphijchar terminaltype[41]; 58285612Sdelphij 59285612Sdelphij/* 60285612Sdelphij * I/O data buffers, pointers, and counters. 61285612Sdelphij */ 62285612Sdelphijchar ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; 63285612Sdelphij 64285612Sdelphijchar netibuf[BUFSIZ], *netip; 65285612Sdelphij 66285612Sdelphijchar netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp; 67285612Sdelphijchar *neturg; /* one past last bye of urgent data */ 68285612Sdelphij 69285612Sdelphijint pcc, ncc; 70285612Sdelphij 71285612Sdelphijint ourpty, net; 72285612Sdelphijint SYNCHing; /* we are in TELNET SYNCH mode */ 73285612Sdelphij 74285612Sdelphij/* 75285612Sdelphij * The following are some clocks used to decide how to interpret 76285612Sdelphij * the relationship between various variables. 77285612Sdelphij */ 78285612Sdelphij 79285612Sdelphijstruct clocks_t clocks; 80285612Sdelphij 81285612Sdelphij 82285612Sdelphij/* whether to log unauthenticated login attempts */ 83285612Sdelphijint log_unauth; 84285612Sdelphij 85285612Sdelphij/* do not print warning if connection is not encrypted */ 86285612Sdelphijint no_warn; 87285612Sdelphij 88285612Sdelphij/* 89285612Sdelphij * This function appends data to nfrontp and advances nfrontp. 90285612Sdelphij */ 91285612Sdelphij 92285612Sdelphijint 93285612Sdelphijoutput_data (const char *format, ...) 94285612Sdelphij{ 95285612Sdelphij va_list args; 96285612Sdelphij int remaining, ret; 97285612Sdelphij 98285612Sdelphij va_start(args, format); 99285612Sdelphij remaining = BUFSIZ - (nfrontp - netobuf); 100285612Sdelphij ret = vsnprintf (nfrontp, 101285612Sdelphij remaining, 102285612Sdelphij format, 103285612Sdelphij args); 104285612Sdelphij nfrontp += min(ret, remaining-1); 105285612Sdelphij va_end(args); 106285612Sdelphij return ret; 107285612Sdelphij} 108285612Sdelphij