<commit_before>#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <jansson.h>

#include "profile.h"
#include "util.h"

void default_profile(Profile* profile) {
    int port0 = 5678;
    profile->ip = strdup("127.0.0.1");
    profile->transport = strdup("tcp");
    profile->stdin_port = port0;
    profile->control_port = port0+1;
    profile->hb_port = port0+2;
    profile->shell_port = port0+3;
    profile->iopub_port = port0+4;
    profile->key = uuid4();
    profile->signature_scheme = strdup("sha256");
}

void init_profile(Profile* profile, const char* existing) {
    FILE* file;
    char name[100];
    json_t* json;

    if (existing == NULL) {
        sprintf(name, "profile-%d.json", getpid());
        printf("connect ipython with --existing %s\n", name);

        default_profile(profile);

        json = json_object();
        json_object_set(json, "ip", json_string(profile->ip));
        json_object_set(json, "transport", json_string(profile->transport));
        json_object_set(json, "iopub_port", json_integer(profile->iopub_port));
        json_object_set(json, "shell_port", json_integer(profile->shell_port));
        json_object_set(json, "control_port", json_integer(profile->control_port));
        json_object_set(json, "stdin_port", json_integer(profile->stdin_port));
        json_object_set(json, "hb_port", json_integer(profile->hb_port));
        json_object_set(json, "key", json_string(profile->key));
        json_object_set(json, "signature_scheme", json_string(profile->signature_scheme));

        file = fopen(name, "w");
        json_dumpf(json, file, 0);
        json_decref(json);
        fclose(file);<commit_msg>Add hmac- prefix to signature_scheme<commit_after>#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <jansson.h>

#include "profile.h"
#include "util.h"

void default_profile(Profile* profile) {
    int port0 = 5678;
    profile->ip = strdup("127.0.0.1");
    profile->transport = strdup("tcp");
    profile->stdin_port = port0;
    profile->control_port = port0+1;
    profile->hb_port = port0+2;
    profile->shell_port = port0+3;
    profile->iopub_port = port0+4;
    profile->key = uuid4();
    profile->signature_scheme = strdup("hmac-sha256");
}

void init_profile(Profile* profile, const char* existing) {
    FILE* file;
    char name[100];
    json_t* json;

    if (existing == NULL) {
        sprintf(name, "profile-%d.json", getpid());
        printf("connect ipython with --existing %s\n", name);

        default_profile(profile);

        json = json_object();
        json_object_set(json, "ip", json_string(profile->ip));
        json_object_set(json, "transport", json_string(profile->transport));
        json_object_set(json, "iopub_port", json_integer(profile->iopub_port));
        json_object_set(json, "shell_port", json_integer(profile->shell_port));
        json_object_set(json, "control_port", json_integer(profile->control_port));
        json_object_set(json, "stdin_port", json_integer(profile->stdin_port));
        json_object_set(json, "hb_port", json_integer(profile->hb_port));
        json_object_set(json, "key", json_string(profile->key));
        json_object_set(json, "signature_scheme", json_string(profile->signature_scheme));

        file = fopen(name, "w");
        json_dumpf(json, file, 0);
        json_decref(json);
        fclose(file);
{'fraction_non_alphanumeric': 0.1512108682811577, 'fraction_numerical': 0.016538688718251624, 'mean_word_length': 3.8454935622317596, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7409862', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1125, 'n_words': 199}