⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcplib.c

📁 大量的汇编程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------*/
/*    d c p l i b . c                                                 */
/*                                                                    */
/*    DCP system-dependent library                                    */
/*                                                                    */
/*    Services provided by dcplib.c:                                  */
/*                                                                    */
/*    - login                                                         */
/*    - UNIX commands simulation                                      */
/*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*/
/*    Changes Copyright (c) 1989-1993 by Kendra Electronic            */
/*    Wonderworks.                                                    */
/*                                                                    */
/*    All rights reserved except those explicitly granted by the      */
/*    UUPC/extended license agreement.                                */
/*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*/
/*    Copyright (c) Richard H. Lamb 1985, 1986, 1987                  */
/*    Changes Copyright (c) Stuart Lynne 1987                         */
/*--------------------------------------------------------------------*/

/*
 *    $Id: dcplib.c 1.7 1993/09/29 04:52:03 ahd Exp $
 *
 *    $Log: dcplib.c $
 * Revision 1.7  1993/09/29  04:52:03  ahd
 * Make device name use standard modem file configuration prefix
 *
 * Revision 1.6  1993/09/20  04:48:25  ahd
 * TCP/IP support from Dave Watt
 * 't' protocol support
 * OS/2 2.x support (BC++ 1.0 for OS/2)
 *
 * Revision 1.5  1993/07/24  03:40:55  ahd
 * Correct #ifif to #ifel
 *
 * Revision 1.4  1993/07/22  23:22:27  ahd
 * First pass at changes for Robert Denny's Windows 3.1 support
 *
 * Revision 1.3  1993/05/30  00:01:47  ahd
 * Multiple commuications drivers support
 *
 *
 * Updated:
 *
 *    14May89  - Added system name to login prompt - ahd
 *               Added configuration file controlled user id, password
 *               Added Kermit server option
 *    17May89  - Redo login processing to time out after five minutes;
 *               after all, we have to exit someday.                    ahd
 *    22Sep89  - Add password file processing                           ahd
 *    24Sep89  - Modify login() to issue only one wait command for up
 *               to 32K seconds; this cuts down LOGFILE clutter.        ahd
 *    01Oct89  - Re-do function headers to allow copying for function
 *               prototypes in ulib.h                                   ahd
 *    17Jan90  - Filter unprintable characters from logged userid and
 *               password to prevent premature end of file.             ahd
 *    18Jan90  - Alter processing of alternate shells to directly
 *               invoke program instead of using system() call.         ahd
 * 6  Sep 90   - Change logging of line data to printable               ahd
 *    8 Sep 90 - Split ulib.c into dcplib.c and ulib.c                  ahd
 *    8 Oct 90 - Break rmail.com and rnews.com out of uuio
 *               Add FIXED_SPEED option for no-autobauding              ahd
 *    10Nov 90 - Move sleep call into ssleep and rename                 ahd
 */

/*--------------------------------------------------------------------*/
/*                        System include files                        */
/*--------------------------------------------------------------------*/

#include <ctype.h>
#include <direct.h>
#include <dos.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>

#ifdef __TURBOC__
#include <sys/timeb.h>
#endif

#if defined(_Windows)
#include <windows.h>
#endif

/*--------------------------------------------------------------------*/
/*                    UUPC/extended include files                     */
/*--------------------------------------------------------------------*/

#include "lib.h"
#include "arpadate.h"
#include "dcp.h"
#include "dcplib.h"
#include "dcpsys.h"
#include "hlib.h"
#include "hostable.h"
#include "import.h"
#include "modem.h"
#include "pushpop.h"
#include "security.h"
#include "ssleep.h"
#include "commlib.h"
#include "usertabl.h"
#include "timestmp.h"

/*--------------------------------------------------------------------*/
/*        Define current file name for panic() and printerr()         */
/*--------------------------------------------------------------------*/

#if !defined(_Windows)
currentfile();
#endif

/*--------------------------------------------------------------------*/
/*                    Internal function prototypes                    */
/*--------------------------------------------------------------------*/

static void LoginShell( const   struct UserTable *userp );

void motd( const char *fname, char *buf, const int bufsiz );

/*--------------------------------------------------------------------*/
/*    l o g i n                                                       */
/*                                                                    */
/*    Login handler                                                   */
/*--------------------------------------------------------------------*/

boolean login(void)
{
   char line[BUFSIZ];                  /* Allow for long domain names!  */
   char user[50];
   char pswd[50];
   char attempts = 0;                  /* Allows login tries         */
   char *token;                        /* Pointer to returned token  */
   struct UserTable *userp;

#if defined(_Windows)
   WORD wVersion;
#endif

   if ( E_banner != NULL )
      motd( E_banner, line, sizeof line );

/*--------------------------------------------------------------------*/
/*    Our modem is now connected.  Begin actual login processing      */
/*    by displaying a banner.                                         */
/*--------------------------------------------------------------------*/

#if defined(_Windows)
    wVersion = LOWORD(GetVersion());
    sprintf(line, "\r\n\nMS-Windows(TM) %d.%02d with %s %s (%s) (%s)\r\n",
         (WORD)(LOBYTE(wVersion)),
         (WORD)(HIBYTE(wVersion)),
          compilep,
          compilev,
         E_domain,
         M_device);           // Print a hello message

#else /* not Windows */

   sprintf(line,"\r\n\n%s %d.%02d with %s %s (%s) (%s)\r\n",
#ifdef WIN32
            "Windows NT(TM)",
            _winmajor,
            _winminor,
#elif defined(__OS2__)
            "OS/2(R)",
            (int) _osmajor / 10,
            _osminor,
#elif defined( __TURBOC__ )
            "MS-DOS(R)",
            _osmajor,
            _osminor,
#else
            (_osmode == DOS_MODE) ? "DOS" : "OS/2(R)" ,
            (_osmode == DOS_MODE) ? (int) _osmajor : ((int) _osmajor / 10 ),
            _osminor,
#endif
            compilep,
            compilev,
            E_domain,
            M_device); /* Print a hello message            */
#endif

   wmsg(line,0);
   ddelay(250);

/*--------------------------------------------------------------------*/
/*    Display a login prompt until we get a printable character or    */
/*    the login times out                                             */
/*--------------------------------------------------------------------*/

   for ( attempts = 0; attempts < 5 ; attempts++ )
   {
      boolean invalid = TRUE;
      while (invalid)         /* Spin for a user id or timeout       */
      {
         wmsg("\r\nlogin: ", 0);
         strcpy(user,"");
         if (rmsg(user, 2, 30, sizeof user) == TIMEOUT)
                                    /* Did the user enter data?  */
            return FALSE;   /* No --> Give up                */

         if (equal(user,"NO CARRIER"))
            return FALSE;

         token = user;
         while ((*token != '\0') && invalid) /* Ignore empty lines   */
            invalid = ! isgraph(*token++);
      } /* while */

      printmsg(14, "login: login=%s", user);

/*--------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -