当前位置: 技术问答>linux和unix
ping()的用法
来源: 互联网 发布时间:2016-06-08
本文导语: static FILEPATH * findmatchfile(FILEDLGDATA *one, FILEPATH **cur ) { struct dirent *pDir; DIR *dir; struct stat ftype; char fullpath [PATH_MAX + NAME_MAX + 1]; FIL...
static FILEPATH * findmatchfile(FILEDLGDATA *one, FILEPATH **cur )
{
struct dirent *pDir;
DIR *dir;
struct stat ftype;
char fullpath [PATH_MAX + NAME_MAX + 1];
FILEPATH *head = NULL;
FILEPATH *temp = NULL;
dir = opendir (one->filepath);
while ( (pDir = readdir ( dir )) != NULL ) {
strncpy (fullpath, one->filepath, PATH_MAX);
if ( fullpath[ strlen(fullpath) - 1 ] != '/' )
strcat (fullpath, "/");
strcat (fullpath, pDir->d_name);
if (lstat (fullpath, &ftype) d_name) ) {
if( temp == NULL ) {
temp = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->previous = NULL;
temp->next = NULL;
strcpy ( temp->name, fullpath);
head = temp;
}
else {
temp->next = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->next->previous = temp;
temp->next->next = NULL;
temp = temp->next;
strcpy ( temp->name, fullpath);
}
/*indicate current file pointer*/
if ( !strcmp( pDir->d_name, one->filename ) )
*cur = temp;
}
}
closedir(dir);
return head;
}
此函数中Ping()的作用是什么?
此函数的资料在哪里可以找到?
只有回答关于函数ping()有关的才会得分
{
struct dirent *pDir;
DIR *dir;
struct stat ftype;
char fullpath [PATH_MAX + NAME_MAX + 1];
FILEPATH *head = NULL;
FILEPATH *temp = NULL;
dir = opendir (one->filepath);
while ( (pDir = readdir ( dir )) != NULL ) {
strncpy (fullpath, one->filepath, PATH_MAX);
if ( fullpath[ strlen(fullpath) - 1 ] != '/' )
strcat (fullpath, "/");
strcat (fullpath, pDir->d_name);
if (lstat (fullpath, &ftype) d_name) ) {
if( temp == NULL ) {
temp = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->previous = NULL;
temp->next = NULL;
strcpy ( temp->name, fullpath);
head = temp;
}
else {
temp->next = (FILEPATH *) malloc(sizeof(FILEPATH));
temp->next->previous = temp;
temp->next->next = NULL;
temp = temp->next;
strcpy ( temp->name, fullpath);
}
/*indicate current file pointer*/
if ( !strcmp( pDir->d_name, one->filename ) )
*cur = temp;
}
}
closedir(dir);
return head;
}
此函数中Ping()的作用是什么?
此函数的资料在哪里可以找到?
只有回答关于函数ping()有关的才会得分
|
http://read.pudn.com/downloads135/sourcecode/unix_linux/573391/work.c__.htm
估计主要就是出错处理之类的,如打印出错信息等...
static FILEITEM * findmatchfile(FILEDLGDATA *one, FILEITEM **cur )
{
struct dirent *pDir;
DIR *dir;
struct stat ftype;
char fullpath [PATH_MAX + NAME_MAX + 1];
FILEITEM *head = NULL;
FILEITEM *temp = NULL;
dir = opendir (one->filepath);
while ( (pDir = readdir ( dir )) != NULL ) {
strncpy (fullpath, one->filepath, PATH_MAX);
if ( fullpath[ strlen(fullpath) - 1 ] != '/' )
strcat (fullpath, "/");
strcat (fullpath, pDir->d_name);
if (lstat (fullpath, &ftype) d_name) ) {
if( temp == NULL ) {
temp = (FILEITEM *) malloc(sizeof(FILEITEM));
temp->previous = NULL;
temp->next = NULL;
strcpy ( temp->name, fullpath);
head = temp;
}
else {
temp->next = (FILEITEM *) malloc(sizeof(FILEITEM));
temp->next->previous = temp;
temp->next->next = NULL;
temp = temp->next;
strcpy ( temp->name, fullpath);
}
/*indicate current file pointer*/
if ( !strcmp( pDir->d_name, one->filename ) )
*cur = temp;
}
}
closedir(dir);
return head;
}
估计主要就是出错处理之类的,如打印出错信息等...
|
哪个软件中的一段代码?
|
系统好像没有这个函数,会不会是作者自己编写的一个和ping有相似功能的函数呢
|
先说说这个函数的功能,还是该函数是从哪儿来的?
|
ping就是用icmp包来检测网络状况啊。
就是用socket发icmp包啊。
我这有源码的,但是现在不是那台机器。
http://hi.baidu.com/veryfun/blog/item/cee09a51126ae68c8c5430b6.html
你参考下这里吧
就是用socket发icmp包啊。
我这有源码的,但是现在不是那台机器。
http://hi.baidu.com/veryfun/blog/item/cee09a51126ae68c8c5430b6.html
你参考下这里吧