Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <string.h>
- #define BUF_SIZE 8192
- int main(int argc, char *argv[])
- {
- char *filename = "/proc/bus/input/devices";
- int fd;
- ssize_t fd_size;
- char buffer[BUF_SIZE];
- fd = open(filename, O_RDONLY);
- if (fd == -1) {
- perror("open");
- return 2;
- }
- fd_size = read(fd, &buffer,BUF_SIZE);
- close(fd);
- char *ptr;
- ptr=strstr(buffer,"Logitech");
- ptr=strstr(ptr,"Handlers");
- ptr=strstr(ptr,"event");
- char *text = "/dev/input/";
- write(1,text,strlen(text));
- do {
- write(1,ptr,1);
- } while(*++ptr != ' ');
- write(0,"\n",1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement