开发中,其他模块提出需求,需要我提供一个接口,另一个模块会启动独立线程,不断的调用这个接口,来实现USB事件的分离和提取,详细的接口代码如下:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#define UEVENT_MSG_LEN 2048
#define UEVENT_LOG_SAVE 1
struct uevent_struct {
const char *action;
const char *path;
const char *subsystem;
const char *firmware;
const char *usbstate;
int major;
int minor;
};
static int open_uevent_struct_socket(void);
static void parse_event(const char *msg, struct uevent_struct *uevent_struct);
/*******************************************************************
* Function : main
* Description : Keep Look For Monitor Uevent And Receive Uevent
* Input : int argc
* : char* argv[]
* Date : 20151015
********************************************************************/
int main(int argc, char* argv[])
{
int