linux 平台递归读取读取所有文件夹和文件名称
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/types.h>
#include<dirent.h>
#define MAX 1024
char path[100];
char *strmin(char *des,const char *min)
{
int i=strlen(des);
int j=strlen(min);
if(i>=j)
{
strncpy(des+i-j,"\0",1);
}
return des;
}
void print(char *path,char *tmpname)
{
struct stat buf;
if(stat(path,&buf)<0)
{
printf("stat error!\n");
return;
}
struct dirent *filename;
if(S_ISDIR(buf.st_mode))
{
DIR *dp;
dp=opendir(path);
while(1)
{
filename=readdir(dp);
if(filename == NULL)
{
strmin(path,tmpname);
closedir(dp);
return ;
}
else
{
if(strcmp(filename->d_name,".")==0 ||strcmp(filename->d_name,"..")==0)
continue;
printf("%s\n",filename->d_name);
strcat(path,"/");
strcat(path,filename->d_name);
print(path,filename->d_name);
strmin(path,"/");
}
}
}
else
{
int fd;
fd=open(path,O_RDWR);
char buf[MAX];
int size;
while(1)
{
size=read(fd,buf,MAX);
if(size==0)
{
close(fd);
break;
}
}
strmin(path,tmpname);
}
}
int
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......
语 法:ifconfig [网络设备][down up -allmulti -arp -promisc][add<地址>][del<地址>][<网络设备类型> <硬件地址>][io_addr][irq ][media<网络媒介类型>][mem_start<内存地址>][metric<数目>][mtu<字节>][netmask<子网掩码>][tunnel<地址>][-broadc ......