1:#ifdef 来判断系统类型
2:popen标准管道函数,来执行command中的命令;
3:fgets得到字符串
4:应为MD5命令使用的时候后面会跟上原来的文件名,所以需要使用strtok进行切分;
-
int md5Check( char *pfileName, char *pmd5CheckString )
-
{
-
FILE *fp = NULL;
-
char *pTmp = NULL;
-
-
#ifdef linux
-
char command[MAXFILESIZE] = "md5sum ";
-
#endif
-
-
#ifdef AIX
-
char command[MAXFILESIZE] = "csum "
-
#endif
-
-
strcat( command, pfileName );
-
-
if ( (fp = popen(command, "r")) == NULL )
-
{
-
return -1;
-
}
-
-
if ( (fgets(pmd5CheckString, MAXFILESIZE, fp)) == NULL )
-
{
-
return -1;
-
}
-
-
pmd5CheckString = strtok(pmd5CheckString, " ");
-
-
return 0;
-
}
阅读(5134) | 评论(0) | 转发(0) |