<commit_before>#include <stdio.h>
#include "yairc/connection.h"

void communicate(FILE* fp, int sockfd)
{
  char sendline[YI_MAXLINE] = { 0 };
  char recvline[YI_MAXLINE] = { 0 };

  if (fgets(sendline, YI_MAXLINE, fp) == NULL || ferror(fp))
    exit(EXIT_FAILURE);

  yi_write_ne(sockfd, sendline, strlen(sendline));
  yi_read_n(sockfd, recvline, strlen(sendline));
  fprintf(stdout, "%s", recvline);
}

int main(int argc, char* argv[])
{
  yi_connection_t* connection; 

  ASSERT(argc == 2, "Usage: yairc <url>");

  connection = yi_tcp_connect(argv[1], "echo");
  communicate(stdin, connection->sockfd);

  yi_close(connection->sockfd);
  yi_delete_connection(connection);

  LOG("heu");

  return 0;
}<commit_msg>adds cli help to main<commit_after>#include <stdio.h>
#include "yairc/connection.h"

static const char* CLI_HELP =
    "Usage: yairc <url> <service>\n"
    "\n"
    "url:\tserver authority (url w/out scheme and path\n"
    "serv:\tservice to map port to.\n"
    "\n"
    "Example:\n"
    "\t./yairc irc.mozilla.org dirc\n";

void communicate(FILE* fp, int sockfd)
{
  char sendline[YI_MAXLINE] = { 0 };
  char recvline[YI_MAXLINE] = { 0 };

  if (fgets(sendline, YI_MAXLINE, fp) == NULL || ferror(fp))
    exit(EXIT_FAILURE);

  yi_write_ne(sockfd, sendline, strlen(sendline));
  yi_read_n(sockfd, recvline, strlen(sendline));
  fprintf(stdout, "%s", recvline);
}

int main(int argc, char* argv[])
{
  yi_connection_t* connection;

  if (argc != 3) {
    fprintf(stderr, "%s\n", CLI_HELP);
    return EXIT_FAILURE;
  }

  connection = yi_tcp_connect(argv[1], argv[2]);
  communicate(stdin, connection->sockfd);

  yi_close(connection->sockfd);
  yi_delete_connection(connection);

  return EXIT_SUCCESS;
}
{'fraction_non_alphanumeric': 0.1602787456445993, 'fraction_numerical': 0.005807200929152149, 'mean_word_length': 4.487261146496815, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '1585120', 'n_tokens_mistral': 694, 'n_tokens_neox': 668, 'n_words': 138}