Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- // List of ad domains to block
- const char* blocked_domains[] = {
- "adserver.com",
- "adservice.net",
- "exampleads.com"
- };
- int main() {
- // Simulating network requests
- const char* requests[] = {
- "https://example.com",
- "https://adserver.com/ad1",
- "https://exampleads.com/banner"
- };
- int num_requests = sizeof(requests) / sizeof(requests[0]);
- int num_domains = sizeof(blocked_domains) / sizeof(blocked_domains[0]);
- // Check each request
- for (int i = 0; i < num_requests; i++) {
- int blocked = 0;
- // Check against each blocked domain
- for (int j = 0; j < num_domains; j++) {
- if (strstr(requests[i], blocked_domains[j]) != NULL) {
- blocked = 1;
- break;
- }
- }
- // Print the result
- printf("%s: %s\n", requests[i], blocked ? "Blocked" : "Allowed");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement