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

/* the functions in this file handle the whole "sending data out" thing */

#include "net.h"




int main(int argc, char* argv[])
{
    int data_listener, controlfd, control_listener, datafd = -1;
    ssize_t rval, numbytes, rval_send;
    uint8_t *buf;
    size_t bufsize;
    uint8_t cont = CONT;
    uint8_t done = DONE;

    if (argc != 4) {
        fprintf(stderr, "usage: %s chunksize dataport controlport\nchunksize is in bytes\n", argv[0]);
        exit(10);
    }

    bufsize = (size_t) atol(argv[1]);
    buf = malloc(bufsize);
    assert(buf != NULL);

    control_listener = make_listener(argv[3]);
    controlfd = accept(control_listener, NULL, NULL);
    if (controlfd == -1) {
        perror("accept on control port");
        exit(1);
    }

    data_listener = make_listener(argv[2]);
    while (1) {
        numbytes = read_all(0, buf, bufsize);
        if (numbytes == -1) {
            perror("read on stdin");
            exit(1);
        }
        if (numbytes == 0) { /* eof on stdin */
            rval = write(controlfd, &done, 1);
            if (rval != 1) {
                perror("write on controlfd (while exiting, which makes this even more humiliating)");
                exit(1);
            }

            break;
        }
        rval = write(controlfd, &cont, 1);<commit_msg>listening in send.c<commit_after>/* copyright (c) 2014 <NAME> <<EMAIL>> */

/* the functions in this file handle the whole "sending data out" thing */

#include "net.h"




int main(int argc, char* argv[])
{
    int data_listener, controlfd, control_listener, listening, datafd = -1;
    ssize_t rval, numbytes, rval_send;
    uint8_t *buf;
    size_t bufsize;
    uint8_t cont = CONT;
    uint8_t done = DONE;

    if ((argc != 4) || (argc != 5)) {
        fprintf(stderr, "usage: %s chunksize dataport controlport [host]\nchunksize is in bytes\n", argv[0]);
        exit(10);
    }

    if (argc == 4) {
        listening = 1;
    } else {
        listening = 0;
    }


    bufsize = (size_t) atol(argv[1]);
    buf = malloc(bufsize);
    assert(buf != NULL);

    control_listener = make_listener(argv[3]);
    controlfd = accept(control_listener, NULL, NULL);
    if (controlfd == -1) {
        perror("accept on control port");
        exit(1);
    }

    data_listener = make_listener(argv[2]);
    while (1) {
        numbytes = read_all(0, buf, bufsize);
        if (numbytes == -1) {
            perror("read on stdin");
            exit(1);
        }
        if (numbytes == 0) { /* eof on stdin */
            rval = write(controlfd, &done, 1);
            if (rval != 1) {
                perror("write on controlfd (while exiting, which makes this even more humiliating)");
                exit(1);
            }

            break;
        }
        rval = write(controlfd, &cont, 1);
{'fraction_non_alphanumeric': 0.1380271871732311, 'fraction_numerical': 0.01951899616591147, 'mean_word_length': 2.1161780673181325, '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': '3564140', 'n_tokens_mistral': 985, 'n_tokens_neox': 942, 'n_words': 263}