<commit_before>/*
 * Copyright (c) 2012, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *  1 Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  2 Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  4 Neither the name of the author nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * html.c
 *
 * HTML display functions
 */
#include <stdio.h>
#include <stdlib.h>

#include <libintl.h>

#include "extern.h"
#include "html.h"
#include "util.h"

/*
 * TODO: Add some CSS to make this cool :)
 */
static void
html_disp_init(void)
{
	(void)puts("<!DOCTYPE html>");
	(void)puts("<html>");
	(void)puts("  <head>");
	(void)puts("    <meta http-equiv=\"Content-Type\" content=\"text/html; "
			"charset=utf-8\"/>");
	(void)puts("    <meta name=\"author\" content=\"<NAME>\"/>");
	(void)printf("    <meta name=\"description\" content=\"%s-%s - Display "
			"file system space usage using graph and colors\"/>\n",
			PACKAGE, VERSION);
	(void)puts("    <meta name=\"keywords\" content=\"dfc,file system, usage, "
			"display, cli, df\"/>");
	(void)puts("    <title>dfc</title>");
	(void)puts("  </head>\n  <body>");
}

static void
html_disp_deinit(void)
{
    (void)puts("\t</tr>\n    </table>\n  </body>\n</html>");
}

void
init_disp_html(struct Display *disp)
{
	disp->init         = html_disp_init;
	disp->deinit       = html_disp_deinit;
	disp->print_header = html_disp_header;
	disp->print_sum    = html_disp_sum;
	disp->print_bar    = html_disp_bar;
	disp->print_at     = html_disp_at;
	disp->print_fs     = html_disp_fs;
	disp->print_type   = html_disp_type;
	disp->print_inodes = html_disp_inodes;
	disp->print_mount  = html_disp_mount;
	disp->print_mopt   = html_disp_mopt;
	disp->print_perct  = html_disp_perct;
}

void
html_disp_header(struct list *lst)
{
	(void) lst;

	(void)printf("    <table border=\"1\">\n\t<tr>\n");
	(void)printf("\t  <th>%s</th>\n", _("FILESYSTEM"));

	if (Tflag)
		(void)printf("\t  <th>%s</th>\n", _("TYPE"));
	if (!bflag)
		(void)printf("\t  <th>USAGE</th>\n");

	(void)printf("\t  <th>%s</th>\n", _("%USED"));
	(void)printf("\t  <th>%s</th>\n", _("AVAILABLE"));
	(void)printf("\t  <th>%s</th>\n", _("TOTAL"));

	if (iflag) {
		(void)printf("\t  <th>%s</th>\n", _("#INODES"));
		(void)printf("\t  <th>%s</th>\n", _("AV.INODES,"));
	}

	(void)printf("\t  <th>%s</th>\n", _("MOUNTED ON"));

	if (oflag)
		(void)printf("\t  <th>%s</th>\n", _("MOUNT OPTIONS"));

	(void)puts("\t</tr>");
}

void
html_disp_sum(struct list *lst, double stot, double atot, double utot,
              double ifitot, double ifatot)
{
	double ptot = stot == 0 ? 100.0 : 100.0 * (utot / stot);

	(void)lst;

	(void)puts("\t</tr>\n\t<tr>\n\t  <td><strong>SUM</strong></td>");

	if (Tflag)
		(void)puts("\t  <td>N/A</td>");

	if (!bflag)
		(void)puts("\t  <td>N/A</td>");

	html_disp_perct(ptot);<commit_msg>added a little bit of css to html output to make it more pretty<commit_after>/*
 * Copyright (c) 2012, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *  1 Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  2 Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  4 Neither the name of the author nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * html.c
 *
 * HTML display functions
 */
#include <stdio.h>
#include <stdlib.h>

#include <libintl.h>

#include "extern.h"
#include "html.h"
#include "util.h"

/*
 * TODO: Add some CSS to make this cool :)
 */
static void
html_disp_init(void)
{
	(void)puts("<!DOCTYPE html>");
	(void)puts("<html>");
	(void)puts("  <head>");
	(void)puts("    <meta http-equiv=\"Content-Type\" content=\"text/html; "
			"charset=utf-8\"/>");
	(void)puts("    <meta name=\"author\" content=\"<NAME>\"/>");
	(void)printf("    <meta name=\"description\" content=\"%s-%s - Display "
			"file system space usage using graph and colors\"/>\n",
			PACKAGE, VERSION);
	(void)puts("    <meta name=\"keywords\" content=\"dfc,file system, usage, "
			"display, cli, df\"/>");
	(void)puts("    <style type=\"text/css\">");
	(void)puts("\ttable { }");
	(void)puts("\ttd, th { padding: .3em; border: 1px #BBBBBB solid; }");
	(void)puts("\tthead { background: #DDDDDD; }");
	(void)puts("\ttbody { background: #F5F5F5; }");
	(void)puts("    </style>");
	(void)puts("    <title>dfc</title>");
	(void)puts("  </head>\n  <body>");
}

static void
html_disp_deinit(void)
{
    (void)puts("\t</tr>\n    </table>\n  </body>\n</html>");
}

void
init_disp_html(struct Display *disp)
{
	disp->init         = html_disp_init;
	disp->deinit       = html_disp_deinit;
	disp->print_header = html_disp_header;
	disp->print_sum    = html_disp_sum;
	disp->print_bar    = html_disp_bar;
	disp->print_at     = html_disp_at;
	disp->print_fs     = html_disp_fs;
	disp->print_type   = html_disp_type;
	disp->print_inodes = html_disp_inodes;
	disp->print_mount  = html_disp_mount;
	disp->print_mopt   = html_disp_mopt;
	disp->print_perct  = html_disp_perct;
}

void
html_disp_header(struct list *lst)
{
	(void) lst;

	(void)printf("    <table>\n\t<thead>\n\t<tr>\n");
	(void)printf("\t  <th>%s</th>\n", _("FILESYSTEM"));

	if (Tflag)
		(void)printf("\t  <th>%s</th>\n", _("TYPE"));
	if (!bflag)
		(void)printf("\t  <th>USAGE</th>\n");

	(void)printf("\t  <th>%s</th>\n", _("%USED"));
	(void)printf("\t  <th>%s</th>\n", _("AVAILABLE"));
	(void)printf("\t  <th>%s</th>\n", _("TOTAL"));

	if (iflag) {
		(void)printf("\t  <th>%s</th>\n", _("#INODES"));
		(void)printf("\t  <th>%s</th>\n", _("AV.INODES,"));
	}

	(void)printf("\t  <th>%s</th>\n", _("MOUNTED ON"));

	if (oflag)
		(void)printf("\t  <th>%s</th>\n", _("MOUNT OPTIONS"));

	(void)puts("\t</tr>\n\t</thead>");
}

void
html_disp_sum(struct list *lst, double stot, double atot, double utot,
              double ifitot, double ifatot)
{
	double ptot = stot == 0 ? 100.0 : 100.0 * (utot / stot);

	(void)lst;

	(void)puts("\t</tr>\n\t<tr>\n\t  <td><strong>SUM</strong></td>");

	if (Tflag)
		(void)puts("\t  <td>N/A</td>");

	if (!bflag)
		(void)puts("\t  <td>N/A</td>");

	html_disp_perct(ptot);
{'fraction_non_alphanumeric': 0.17196702002355713, 'fraction_numerical': 0.004711425206124852, 'mean_word_length': 3.9568009340338586, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 137, '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': '3245251', 'n_tokens_mistral': 3159, 'n_tokens_neox': 2983, 'n_words': 847}