streecmp/test.c

155 lines
4.4 KiB
C
Raw Normal View History

2024-08-25 12:04:27 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "streecmp.h"
char *strs = "A-IM\n"
"Accept\n"
"Accept-Charset\n"
"Accept-Datetime\n"
"Accept-Encoding\n"
"Accept-Language\n"
"Access-Control-Request-Method\n"
"Access-Control-Request-Headers\n"
"Authorization\n"
"Cache-Control\n"
"Connection\n"
"Content-Encoding\n"
"Content-Length\n"
"Content-MD5\n"
"Content-Type\n"
"Cookie\n"
"Date\n"
"Expect\n"
"Forwarded\n"
"From\n"
"Host\n"
"HTTP2-Settings\n"
"If-Match\n"
"If-Modified-Since\n"
"If-None-Match\n"
"If-Range\n"
"If-Unmodified-Since\n"
"Max-Forwards\n"
"Origin\n"
"Pragma\n"
"Prefer\n"
"Proxy-Authorization\n"
"Range\n"
"Referer\n"
"TE\n"
"Trailer\n"
"Transfer-Encoding\n"
"User-Agent\n"
"Upgrade\n"
"Via\n"
"Warning\n"
"Upgrade-Insecure-Requests\n"
"X-Requested-With\n"
"DNT\n"
"X-Forwarded-For\n"
"X-Forwarded-Host\n"
"X-Forwarded-Proto\n"
"Front-End-Https\n"
"X-Http-Method-Override\n"
"X-ATT-DeviceID\n"
"X-Wap-Profile\n"
"Proxy-Connection\n"
"X-UIDH\n"
"X-Csrf-Token\n"
"X-Request-ID\n"
"X-Correlation-ID\n"
"Correlation-ID\n"
"Save-Data\n"
"Sec-GPC\n"
"Accept-CH\n"
"Access-Control-Allow-Origin\n"
"Access-Control-Allow-Credentials\n"
"Access-Control-Expose-Headers\n"
"Access-Control-Max-Age\n"
"Access-Control-Allow-Methods\n"
"Access-Control-Allow-Headers\n"
"Accept-Patch\n"
"Accept-Ranges\n"
"Age\n"
"Allow\n"
"Alt-Svc\n"
"Content-Disposition\n"
"Content-Language\n"
"Content-Location\n"
"Content-Range\n"
"Delta-Base\n"
"ETag\n"
"Expires\n"
"IM\n"
"Last-Modified\n"
"Link\n"
"Location\n"
"P3P\n"
"Preference-Applied\n"
"Proxy-Authenticate\n"
"Public-Key-Pins\n"
"Retry-After\n"
"Server\n"
"Set-Cookie\n"
"Strict-Transport-Security\n"
"Tk\n"
"Vary\n"
"WWW-Authenticate\n"
"X-Frame-Options\n"
"Content-Security-Policy\n"
"Expect-CT\n"
"NEL\n"
"Permissions-Policy\n"
"Refresh\n"
"Report-To\n"
"Status\n"
"Timing-Allow-Origin\n"
"X-Content-Duration\n"
"X-Content-Type-Options\n"
"X-Powered-By\n"
"X-Redirect-By\n"
"X-UA-Compatible\n"
"X-XSS-Protection";
int main(void) {
int ret;
struct nod *rot = allocnod();
2024-08-25 12:04:27 +00:00
if (rot == NULL) {
fprintf(stderr, "[-] Failed: not enough dynamic memory\n");
return -1;
}
ret = gentree(rot, strs);
if (ret < 0) {
fprintf(stderr, "[-] Failed: could not generate tree\n");
return -1;
}
char *strs_cpy = strdup(strs);
if (strs_cpy == NULL) {
fprintf(stderr, "[-] Failed: not enough dynamic memory\n");
return -1;
}
fprintf(stdout, "------------------------\n");
int cnt = 1;
2024-08-25 12:19:42 +00:00
for (char *tok = strtok(strs_cpy, "\n"); tok != NULL; tok
= strtok(NULL, "\n"), cnt++) {
2024-08-25 12:04:27 +00:00
int found = streecmp(rot, tok);
if (found == cnt) {
2024-08-25 12:19:42 +00:00
fprintf(stdout, "[+][%d\t] Success: could find"
" '%s' in tree\n", cnt, tok);
2024-08-25 12:04:27 +00:00
} else {
2024-08-25 12:19:42 +00:00
fprintf(stderr, "[-][%d\t] Error: could not find"
" '%s' in tree\n", cnt, tok);
2024-08-25 12:04:27 +00:00
}
}
fprintf(stdout, "------------------------\n");
fprintf(stdout, "[*] Done\n");
return 0;
}