<commit_before>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include "sandbird.h"


static int event_handler(sb_Event *e) {
  if (e->type == SB_EV_REQUEST) {
    char buf[512], *p;
    /* Log request */
    printf("%s - %s %s\n", e->address, e->method, e->path);
    /* Get var and replace non-alpha numeric / space chars with underscore */
    sb_get_var(e->stream, "q", buf, sizeof(buf));
    for (p = buf; *p; p++) {
      if ( !(isspace(*p) || isalnum(*p)) ) {
        *p = '_';
      }
    }
    /* Send page */
    sb_send_status(e->stream, 200, "OK");
    sb_send_header(e->stream, "Content-Type", "text/html");
    sb_writef(e->stream,
              "<html><body>q = '%s'<br><br>"
              "<form method='post'><input type='text' name='q'></input></form>"
              "</body></html>", buf);
  }
  return SB_RES_OK;
}


int main(void) {
  sb_Options opt;
  sb_Server *server;

  memset(&opt, 0, sizeof(opt));
  opt.port = "8000";
  opt.handler = event_handler;

  server = sb_new_server(&opt);

  if (!server) {
    fprintf(stderr, "failed to initialize server\n");
    exit(EXIT_FAILURE);
  }

  printf("Server running at http://localhost:%s\n", opt.port);<commit_msg>Fixed HTML on input.c example<commit_after>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include "sandbird.h"


static int event_handler(sb_Event *e) {
  if (e->type == SB_EV_REQUEST) {
    char buf[512], *p;
    /* Log request */
    printf("%s - %s %s\n", e->address, e->method, e->path);
    /* Get var and replace non-alpha numeric / space chars with underscore */
    sb_get_var(e->stream, "q", buf, sizeof(buf));
    for (p = buf; *p; p++) {
      if ( !(isspace(*p) || isalnum(*p)) ) {
        *p = '_';
      }
    }
    /* Send page */
    sb_send_status(e->stream, 200, "OK");
    sb_send_header(e->stream, "Content-Type", "text/html");
    sb_writef(e->stream,
              "<!DOCTYPE html>"
              "<html><body>q = '%s'<br><br>"
              "<form method='post'><input type='text' name='q'></form>"
              "</body></html>", buf);
  }
  return SB_RES_OK;
}


int main(void) {
  sb_Options opt;
  sb_Server *server;

  memset(&opt, 0, sizeof(opt));
  opt.port = "8000";
  opt.handler = event_handler;

  server = sb_new_server(&opt);

  if (!server) {
    fprintf(stderr, "failed to initialize server\n");
    exit(EXIT_FAILURE);
  }

  printf("Server running at http://localhost:%s\n", opt.port);
{'fraction_non_alphanumeric': 0.1983037156704362, 'fraction_numerical': 0.008885298869143781, 'mean_word_length': 2.864274570982839, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1625514', 'n_tokens_mistral': 940, 'n_tokens_neox': 907, 'n_words': 201}