fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. #define BOOL int
  5. #define TRUE 1
  6. #define FALSE 0
  7.  
  8. static BOOL match_token(const char *haystack, const char *needle)
  9. {
  10. const char *p, *q;
  11. for (p = haystack; *p; )
  12. {
  13. while (*p && isspace(*p))
  14. p++;
  15. if (! *p)
  16. break;
  17.  
  18. for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++)
  19. p++;
  20. if (! *q && (isspace(*p) || !*p))
  21. return TRUE;
  22.  
  23. while (*p && ! isspace(*p))
  24. p++;
  25. }
  26. return FALSE;
  27. }
  28.  
  29. static BOOL is_tablet_cursor(const char *name, const char *type)
  30. {
  31. int i;
  32. static const char *tablet_cursor_allowlist[] = {
  33. "wacom",
  34. "wizardpen",
  35. "acecad",
  36. "tablet",
  37. "cursor",
  38. "stylus",
  39. "eraser",
  40. "pad",
  41. NULL
  42. };
  43.  
  44. for (i=0; tablet_cursor_allowlist[i] != NULL; i++) {
  45. if (name && match_token(name, tablet_cursor_allowlist[i]))
  46. return TRUE;
  47. if (type && match_token(type, tablet_cursor_allowlist[i]))
  48. return TRUE;
  49. }
  50. return FALSE;
  51. }
  52.  
  53. int main(void) {
  54. BOOL result = is_tablet_cursor( "xwayland-tablet stylus:10", "xwayland-pointer" ) ;
  55. printf( "result is: %d\n", result);
  56.  
  57. // your code goes here
  58. return 0;
  59. }
Success #stdin #stdout 0s 5472KB
stdin
Standard input is empty
stdout
result is: 0