#include <stdio.h>
#include <ctype.h>
#define BOOL int
#define TRUE 1
#define FALSE 0
static BOOL match_token(const char *haystack, const char *needle)
{
const char *p, *q;
for (p = haystack; *p; )
{
p++;
if (! *p)
break;
p++;
return TRUE;
p++;
}
return FALSE;
}
static BOOL is_tablet_cursor(const char *name, const char *type)
{
int i;
static const char *tablet_cursor_allowlist[] = {
"wacom",
"wizardpen",
"acecad",
"tablet",
"cursor",
"stylus",
"eraser",
"pad",
NULL
};
for (i=0; tablet_cursor_allowlist[i] != NULL; i++) {
if (name && match_token(name, tablet_cursor_allowlist[i]))
return TRUE;
if (type && match_token(type, tablet_cursor_allowlist[i]))
return TRUE;
}
return FALSE;
}
int main(void) {
BOOL result = is_tablet_cursor( "xwayland-tablet stylus:10", "xwayland-pointer" ) ;
printf( "result is: %d\n", result
);
// your code goes here
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxjdHlwZS5oPgoKI2RlZmluZSBCT09MIGludAojZGVmaW5lIFRSVUUgMQojZGVmaW5lIEZBTFNFIDAKCnN0YXRpYyBCT09MIG1hdGNoX3Rva2VuKGNvbnN0IGNoYXIgKmhheXN0YWNrLCBjb25zdCBjaGFyICpuZWVkbGUpCnsKICAgIGNvbnN0IGNoYXIgKnAsICpxOwogICAgZm9yIChwID0gaGF5c3RhY2s7ICpwOyApCiAgICB7CiAgICAgICAgd2hpbGUgKCpwICYmIGlzc3BhY2UoKnApKQogICAgICAgICAgICBwKys7CiAgICAgICAgaWYgKCEgKnApCiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBmb3IgKHEgPSBuZWVkbGU7ICpxICYmICpwICYmIHRvbG93ZXIoKnApID09IHRvbG93ZXIoKnEpOyBxKyspCiAgICAgICAgICAgIHArKzsKICAgICAgICBpZiAoISAqcSAmJiAoaXNzcGFjZSgqcCkgfHwgISpwKSkKICAgICAgICAgICAgcmV0dXJuIFRSVUU7CgogICAgICAgIHdoaWxlICgqcCAmJiAhIGlzc3BhY2UoKnApKQogICAgICAgICAgICBwKys7CiAgICB9CiAgICByZXR1cm4gRkFMU0U7Cn0KCiBzdGF0aWMgQk9PTCBpc190YWJsZXRfY3Vyc29yKGNvbnN0IGNoYXIgKm5hbWUsIGNvbnN0IGNoYXIgKnR5cGUpCiB7CiAgICAgaW50IGk7CiAgICAgIHN0YXRpYyBjb25zdCBjaGFyICp0YWJsZXRfY3Vyc29yX2FsbG93bGlzdFtdID0gewogICAgICAgICAgIndhY29tIiwKICAgICAgICAgICJ3aXphcmRwZW4iLAogICAgICAgICAgImFjZWNhZCIsCiAgICAgICAgICAidGFibGV0IiwKICAgICAgICAgICJjdXJzb3IiLAogICAgICAgICAgInN0eWx1cyIsCiAgICAgICAgICAiZXJhc2VyIiwKICAgICAgICAgICJwYWQiLAogICAgICAgICAgTlVMTAogICAgICB9OwogIAogICAgICBmb3IgKGk9MDsgdGFibGV0X2N1cnNvcl9hbGxvd2xpc3RbaV0gIT0gTlVMTDsgaSsrKSB7CiAgICAgICAgICBpZiAobmFtZSAmJiBtYXRjaF90b2tlbihuYW1lLCB0YWJsZXRfY3Vyc29yX2FsbG93bGlzdFtpXSkpCiAgICAgICAgICAgICAgcmV0dXJuIFRSVUU7CiAgICAgICAgICBpZiAodHlwZSAmJiBtYXRjaF90b2tlbih0eXBlLCB0YWJsZXRfY3Vyc29yX2FsbG93bGlzdFtpXSkpCiAgICAgICAgICAgICAgcmV0dXJuIFRSVUU7CiAgICAgIH0KICAgICAgcmV0dXJuIEZBTFNFOwogIH0KCmludCBtYWluKHZvaWQpIHsKCUJPT0wgcmVzdWx0ID0gaXNfdGFibGV0X2N1cnNvciggInh3YXlsYW5kLXRhYmxldCBzdHlsdXM6MTAiLCAieHdheWxhbmQtcG9pbnRlciIgKSA7CglwcmludGYoICJyZXN1bHQgaXM6ICVkXG4iLCByZXN1bHQpOwoKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCXJldHVybiAwOwp9