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

📄 sock_ini.c

📁 dos 下 网络协议 dos 下 网络协议
💻 C
字号:
/*
 * sock_init - easy way to guarentee:
 *	- card is ready
 *	- shutdown is handled
 *	- cbreaks are handled
 *      - config file is read
 *	- bootp is run
 *
 * 0.1 : May 2, 1991  Erick - reorganized operations
 */

#include <copyright.h>
#include <wattcp.h>
#include <stdlib.h>

int _survivebootp = 0;
static char _initialized = 0;		// S. Lawson

void sock_exit( void )
{
    if (_initialized)			// S. Lawson
       tcp_shutdown();
    _initialized = 0;			// S. Lawson
}

// S. Lawson - keep an exiting sock_init()
void sock_init(void)
{
    int r;
    r=sock_init_noexit();
    if (r) exit(r);
}

int sock_init_noexit(void )			// S. Lawson
{
    int r;					// S. Lawson

    if (_initialized) return 0;			// S. Lawson
// S. Lawson    tcp_init();	/* must precede tcp_config because we need eth addr */
    r=tcp_init_noexit();	/* (S. Lawson) must precede tcp_config because we need eth addr */
    if (r) return r;		// S. Lawson
    _initialized=1;		// S. Lawson
    atexit(sock_exit);	/* must not precede tcp_init() incase no PD */
    tcp_cbrk( 0x10 );	/* allow control breaks, give message */

#ifndef SKIPINI // S. Lawson
    if (tcp_config( NULL )) {	/* if no config file use BOOTP w/broadcast */
#endif // SKIPINI  S. Lawson
	_bootpon = 1;
	outs("Configuring through BOOTP/DHCP\r\n");    // S. Lawson
#ifndef SKIPINI // S. Lawson
    }
#endif // SKIPINI  S. Lawson

    if (_bootpon)	/* non-zero if we use bootp */
	if (_dobootp()) {
	    outs("BOOTP/DHCP failed\r\n");             // S. Lawson
	    if ( !_survivebootp )
	       return 3;			       // S. Lawson
// S. Lawson		exit( 3 );
	}
    return 0;					       // S. Lawson
}

⌨️ 快捷键说明

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