<commit_before>/* copyright (c) 2014 <NAME> <<EMAIL>> */

/* the functions in this file handle the whole "receiving" thing */

#include "net.h"

#define BUFSIZE 2048


int main(int argc, char* argv[])
{
    int datafd, controlfd;
    ssize_t rval, rval_send;
    uint8_t buf[BUFSIZE];
    uint8_t statusbyte;

    if (argc != 4) {
        printf("usage: %s host dataport controlport\n", argv[0]);
        exit(10);
    }
    controlfd = make_socket(argv[1], argv[3]);
    sleep(1);

    while (1) {
        rval = read(controlfd, &statusbyte, 1);

        if (rval != 1) {
            perror("read on controlfd");
            exit(1);
        }

        if (statusbyte == DONE) {
            break;
        }

        assert (statusbyte == CONT);

        datafd = make_socket(argv[1], argv[2]);
        rval = read_all(datafd, buf, BUFSIZE);

        if (rval == -1) {
            perror("read on datafd");
            exit(1);
        }

        if (rval == 0) { /* eof on datafd */
            perror("unexpected EOF on the datafd");
            exit(1);
        }

        rval_send = write_all(1, buf, (size_t)rval);
<commit_msg>fprintf for usage error, fprintf for unexpected EOF and not perror<commit_after>/* copyright (c) 2014 <NAME> <<EMAIL>> */

/* the functions in this file handle the whole "receiving" thing */

#include "net.h"

#define BUFSIZE 2048


int main(int argc, char* argv[])
{
    int datafd, controlfd;
    ssize_t rval, rval_send;
    uint8_t buf[BUFSIZE];
    uint8_t statusbyte;

    if (argc != 4) {
        fprintf(stderr, "usage: %s host dataport controlport\n", argv[0]);
        exit(10);
    }
    controlfd = make_socket(argv[1], argv[3]);
    sleep(1);

    while (1) {
        rval = read(controlfd, &statusbyte, 1);

        if (rval != 1) {
            perror("read on controlfd");
            exit(1);
        }

        if (statusbyte == DONE) {
            break;
        }

        assert (statusbyte == CONT);

        datafd = make_socket(argv[1], argv[2]);
        rval = read_all(datafd, buf, BUFSIZE);

        if (rval == -1) {
            perror("read on datafd");
            exit(1);
        }

        if (rval == 0) { /* eof on datafd */
            fprintf(stderr, "unexpected EOF on datafd\n");
            exit(1);
        }

        rval_send = write_all(1, buf, (size_t)rval);

{'fraction_non_alphanumeric': 0.14291827128797605, 'fraction_numerical': 0.02396234488660676, 'mean_word_length': 1.940880503144654, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6967803', 'n_tokens_mistral': 836, 'n_tokens_neox': 792, 'n_words': 211}