Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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; /* Input and output file descriptors */
  15. ssize_t fd_size; /* Number of bytes returned by read() and write() */
  16. char buffer[BUF_SIZE]; /* Character buffer */
  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. char *ptr;
  25. ptr=strstr(buffer,"Logitech G400s");
  26. ptr=strstr(ptr,"Handlers");
  27. ptr=strstr(ptr,"event");
  28. char *text = "/dev/input/";
  29. write(1,text,strlen(text));
  30. do {
  31. write(1,ptr,1);
  32. } while(*++ptr != ' ');
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement