<commit_before>/*
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <ngx_stream.h>
#include "ngx_ssl_ct.h"

static char *ngx_stream_ssl_ct_merge_srv_conf(ngx_conf_t *cf, void *parent,
    void *child);

static ngx_stream_module_t ngx_stream_ssl_ct_module_ctx = {
    NULL,                             /* postconfiguration */

    NULL,                             /* create main configuration */
    NULL,                             /* init main configuration */

    &ngx_ssl_ct_create_srv_conf,      /* create server configuration */
    &ngx_stream_ssl_ct_merge_srv_conf /* merge server configuration */
};

static ngx_command_t ngx_stream_ssl_ct_commands[] = {
    {
        ngx_string("ssl_ct"),
        NGX_STREAM_MAIN_CONF | NGX_STREAM_SRV_CONF | NGX_CONF_FLAG,
        &ngx_conf_set_flag_slot,
        NGX_STREAM_SRV_CONF_OFFSET,
        offsetof(ngx_ssl_ct_srv_conf_t, enable),
        NULL
    },
    {
        ngx_string("ssl_ct_static_scts"),
        NGX_STREAM_MAIN_CONF | NGX_STREAM_SRV_CONF | NGX_CONF_TAKE1,
        &ngx_conf_set_str_slot,
        NGX_STREAM_SRV_CONF_OFFSET,
        offsetof(ngx_ssl_ct_srv_conf_t, sct),
        NULL
    },
    ngx_null_command
};

ngx_module_t ngx_stream_ssl_ct_module = {
    NGX_MODULE_V1,
    &ngx_stream_ssl_ct_module_ctx, /* module context */
    ngx_stream_ssl_ct_commands,    /* module directives */
    NGX_STREAM_MODULE,           /* module type */
    NULL,                        /* init master */
    NULL,                        /* init module */
    NULL,                        /* init process */
    NULL,                        /* init thread */
    NULL,                        /* exit thread */
    NULL,                        /* exit process */
    NULL,                        /* exit master */
    NGX_MODULE_V1_PADDING
};

static char *ngx_stream_ssl_ct_merge_srv_conf(ngx_conf_t *cf, void *parent,
    void *child)
{
    /* merge config */
    ngx_ssl_ct_srv_conf_t *prev = parent;
    ngx_ssl_ct_srv_conf_t *conf = child;

    ngx_conf_merge_value(conf->enable, prev->enable, 0);
    ngx_conf_merge_str_value(conf->sct, prev->sct, "");

    /* validate config */
    if (conf->enable)
    {
        if (conf->sct.len == 0)
        {
            ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
                "no \"ssl_ct_static_scts\" is defined for the \"ssl_ct\""
                "directive");
            return NGX_CONF_ERROR;
        }
    }
    else
    {
        return NGX_CONF_OK;
    }
<commit_msg>Fix comment alignment in the stream module.<commit_after>/*
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <ngx_stream.h>
#include "ngx_ssl_ct.h"

static char *ngx_stream_ssl_ct_merge_srv_conf(ngx_conf_t *cf, void *parent,
    void *child);

static ngx_stream_module_t ngx_stream_ssl_ct_module_ctx = {
    NULL,                             /* postconfiguration */

    NULL,                             /* create main configuration */
    NULL,                             /* init main configuration */

    &ngx_ssl_ct_create_srv_conf,      /* create server configuration */
    &ngx_stream_ssl_ct_merge_srv_conf /* merge server configuration */
};

static ngx_command_t ngx_stream_ssl_ct_commands[] = {
    {
        ngx_string("ssl_ct"),
        NGX_STREAM_MAIN_CONF | NGX_STREAM_SRV_CONF | NGX_CONF_FLAG,
        &ngx_conf_set_flag_slot,
        NGX_STREAM_SRV_CONF_OFFSET,
        offsetof(ngx_ssl_ct_srv_conf_t, enable),
        NULL
    },
    {
        ngx_string("ssl_ct_static_scts"),
        NGX_STREAM_MAIN_CONF | NGX_STREAM_SRV_CONF | NGX_CONF_TAKE1,
        &ngx_conf_set_str_slot,
        NGX_STREAM_SRV_CONF_OFFSET,
        offsetof(ngx_ssl_ct_srv_conf_t, sct),
        NULL
    },
    ngx_null_command
};

ngx_module_t ngx_stream_ssl_ct_module = {
    NGX_MODULE_V1,
    &ngx_stream_ssl_ct_module_ctx, /* module context */
    ngx_stream_ssl_ct_commands,    /* module directives */
    NGX_STREAM_MODULE,             /* module type */
    NULL,                          /* init master */
    NULL,                          /* init module */
    NULL,                          /* init process */
    NULL,                          /* init thread */
    NULL,                          /* exit thread */
    NULL,                          /* exit process */
    NULL,                          /* exit master */
    NGX_MODULE_V1_PADDING
};

static char *ngx_stream_ssl_ct_merge_srv_conf(ngx_conf_t *cf, void *parent,
    void *child)
{
    /* merge config */
    ngx_ssl_ct_srv_conf_t *prev = parent;
    ngx_ssl_ct_srv_conf_t *conf = child;

    ngx_conf_merge_value(conf->enable, prev->enable, 0);
    ngx_conf_merge_str_value(conf->sct, prev->sct, "");

    /* validate config */
    if (conf->enable)
    {
        if (conf->sct.len == 0)
        {
            ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
                "no \"ssl_ct_static_scts\" is defined for the \"ssl_ct\""
                "directive");
            return NGX_CONF_ERROR;
        }
    }
    else
    {
        return NGX_CONF_OK;
    }

{'fraction_non_alphanumeric': 0.08413090460018524, 'fraction_numerical': 0.0030873726458783574, 'mean_word_length': 2.2169811320754715, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '328388', 'n_tokens_mistral': 2141, 'n_tokens_neox': 2039, 'n_words': 506}