Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <fcntl.h>
  4. #include <errno.h>
  5. #include <sys/types.h>
  6. #include <unistd.h>
  7. #include <string.h>
  8. #define BUF_SIZE 8192
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12.  
  13.         char *filename = "/proc/bus/input/devices";
  14.         int fd;
  15.         ssize_t fd_size;
  16.         char buffer[BUF_SIZE];
  17.  
  18.         fd = open(filename, O_RDONLY);
  19.         if (fd == -1) {
  20.                 perror("open");
  21.                 return 2;
  22.         }
  23.         fd_size = read(fd, &buffer,BUF_SIZE);
  24.         close(fd);
  25.         char *ptr;
  26.         ptr=strstr(buffer,"Logitech");
  27.         ptr=strstr(ptr,"Handlers");
  28.         ptr=strstr(ptr,"event");
  29.         char *text = "/dev/input/";
  30.         write(1,text,strlen(text));
  31.         do {
  32.                 write(1,ptr,1);
  33.         } while(*++ptr != ' ');
  34.         write(0,"\n",1);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement