<commit_before>
#include <sys/socket.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <libudev.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
  int sockid = -1, rv = 0;
  ssize_t size_read;
  char buf[32];
	struct sockaddr_rc bt_addr;
	// Clear the bt_addr
	memset(&bt_addr, 0, sizeof(bt_addr));

	// Check input.
  if(argc < 2) {
    fprintf(stderr, "Error, too small input.");
    rv = -1;
    goto out;
  }

	// Create a socket to connect.
  sockid = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
	if(sockid < 0) {
		fprintf(stderr, "Invalid socket. %d\n", sockid);
		rv = -2;
		goto out;
	}

	// Set up the bt_addr
  bt_addr.rc_family = AF_BLUETOOTH;
  bt_addr.rc_channel = (uint8_t) 1;
  str2ba(argv[1], &(bt_addr.rc_bdaddr));

	// Connect the socket to the remote host.
  rv = connect(sockid, (struct sockaddr *) &bt_addr, sizeof(bt_addr));
  if(rv != 0) {
    fprintf(stderr, "Failed to connect: %d\n", rv);
    goto out;
  }

	// Connection went ok, read data untill done.
  printf("Connected\n");
  while((size_read = read(sockid, buf, sizeof(buf))) > 0) {
    printf("Data: %d\n", atoi(buf));
  }
  printf("Disconnected\n");<commit_msg>working version before switching to libuv<commit_after>
#include <sys/socket.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <libudev.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
  int sockid = -1, rv = 0;
  ssize_t size_read;
  char buf[32];
	struct sockaddr_rc bt_addr;
	// Clear the bt_addr
	memset(&bt_addr, 0, sizeof(bt_addr));

	// Check input.
  if(argc < 2) {
    fprintf(stderr, "Error, too small input.");
    rv = -1;
    goto out;
  }

	// Create a socket to connect.
  sockid = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
	if(sockid < 0) {
		fprintf(stderr, "Invalid socket. %d\n", sockid);
		rv = -2;
		goto out;
	}

	// Set up the bt_addr
  bt_addr.rc_family = AF_BLUETOOTH;
  bt_addr.rc_channel = (uint8_t) 1;
  str2ba(argv[1], &(bt_addr.rc_bdaddr));

	// Connect the socket to the remote host.
  rv = connect(sockid, (struct sockaddr *) &bt_addr, sizeof(bt_addr));
  if(rv != 0) {
    fprintf(stderr, "Failed to connect: %d\n", rv);
    goto out;
  }

	// Connection went ok, read data untill done.
  printf("Connected\n");
  while((size_read = read(sockid, buf, sizeof(buf))) > 0) {
    printf("Size: %d Data: %s\n", size_read, buf);
		bzero(buf, sizeof(buf));
		usleep(50 * 1000);
  }
  printf("Disconnected\n");
{'fraction_non_alphanumeric': 0.1620879120879121, 'fraction_numerical': 0.0141287284144427, 'mean_word_length': 3.5845323741007196, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '164092', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1025, 'n_words': 255}