dnparse.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 63 行
C,V
63 行
head 1.1;
access;
symbols;
locks
dls:1.1; strict;
comment @ * @;
1.1
date 97.09.21.19.27.59; author dls; state Dist;
branches;
next ;
desc
@@
1.1
log
@pre-3e code
@
text
@/* dnparse.c - dnparse */
#include <conf.h>
#include <kernel.h>
#include <network.h>
#include <ctype.h>
/*------------------------------------------------------------------------
* dnparse - parse foreign address specification; get IP and port #s
*------------------------------------------------------------------------
*/
int dnparse(fspec, paddr, pport)
char *fspec;
IPaddr *paddr;
short *pport;
{
int i;
char ch, *index();
if (fspec == ANYFPORT) {
*pport = 0;
return OK;
}
/* parse forms like 192.5.48.30:3 into (ip-address,port) */
*paddr = dot2ip(fspec);
fspec = index(fspec, ':');
if (fspec == 0 || *fspec != ':')
return SYSERR;
fspec++;
i = 0;
while (isdigit(ch = *fspec++))
i = 10*i + (ch - '0');
if (i==0 || ch!='\0')
return SYSERR;
*pport = i;
return OK;
}
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?