<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>

#include <fcntl.h>

#include <sys/types.h>
#include <sys/stat.h>

#include "types.h"
#include "list.h"
#include "namespaces.h"
#include "compiler.h"
#include "crtools.h"
#include "util.h"
#include "sockets.h"
#include "image.h"
#include "uts_ns.h"
#include "ipc_ns.h"
#include "pstree.h"

#include "protobuf.h"
#include "protobuf/fdinfo.pb-c.h"
#include "protobuf/regfile.pb-c.h"
#include "protobuf/ghost-file.pb-c.h"
#include "protobuf/fifo.pb-c.h"
#include "protobuf/remap-file-path.pb-c.h"
#include "protobuf/fown.pb-c.h"
#include "protobuf/fs.pb-c.h"
#include "protobuf/pstree.pb-c.h"
#include "protobuf/pipe.pb-c.h"
#include "protobuf/pipe-data.pb-c.h"
#include "protobuf/sa.pb-c.h"
#include "protobuf/itimer.pb-c.h"
#include "protobuf/mm.pb-c.h"
#include "protobuf/vma.pb-c.h"
#include "protobuf/creds.pb-c.h"
#include "protobuf/core.pb-c.h"

#define DEF_PAGES_PER_LINE	6

#ifndef CONFIG_X86_64
# error No x86-32 support yet
#endif


#define PR_SYMBOL(sym)			\
	(isprint(sym) ? sym : '.')

static LIST_HEAD(pstree_list);

void show_files(int fd_files, struct cr_options *o)
{
	pb_show_plain(fd_files, fdinfo_entry);
}

void show_fown_cont(void *p)
{
	FownEntry *fown = p;
	pr_msg("fown: uid: %#x euid: %#x signum: %#x pid_type: %#x pid: %u",
	       fown->uid, fown->euid, fown->signum, fown->pid_type, fown->pid);
}

void show_reg_files(int fd_reg_files, struct cr_options *o)
{
	pb_show_plain(fd_reg_files, reg_file_entry);
}

void show_remap_files(int fd, struct cr_options *o)
{
	pb_show_plain(fd, remap_file_path_entry);
}

void show_ghost_file(int fd, struct cr_options *o)
{
	pb_show_vertical(fd, ghost_file_entry);
}

void __show_pipes_data(int fd, struct cr_options *o)
{
	PipeDataEntry *e;

	while (1) {
		if (pb_read_eof(fd, &e, pipe_data_entry) <= 0)
			break;
		pr_msg("pipeid: 0x%8x bytes: 0x%8x\n", e->pipe_id, e->bytes);
		lseek(fd, e->bytes, SEEK_CUR);
		pipe_data_entry__free_unpacked(e, NULL);
	}
}

void show_pipes_data(int fd_pipes, struct cr_options *o)
{
	pr_img_head(CR_FD_PIPES_DATA);
	__show_pipes_data(fd_pipes, o);
	pr_img_tail(CR_FD_PIPES_DATA);
}

void show_pipes(int fd_pipes, struct cr_options *o)
{
	pb_show_plain(fd_pipes, pipe_entry);
}

void show_fifo_data(int fd, struct cr_options *o)
{
	pr_img_head(CR_FD_FIFO_DATA);
	__show_pipes_data(fd, o);
	pr_img_tail(CR_FD_FIFO_DATA);<commit_msg>protobuf: use generic show function for pipe data<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>

#include <fcntl.h>

#include <sys/types.h>
#include <sys/stat.h>

#include "types.h"
#include "list.h"
#include "namespaces.h"
#include "compiler.h"
#include "crtools.h"
#include "util.h"
#include "sockets.h"
#include "image.h"
#include "uts_ns.h"
#include "ipc_ns.h"
#include "pstree.h"

#include "protobuf.h"
#include "protobuf/fdinfo.pb-c.h"
#include "protobuf/regfile.pb-c.h"
#include "protobuf/ghost-file.pb-c.h"
#include "protobuf/fifo.pb-c.h"
#include "protobuf/remap-file-path.pb-c.h"
#include "protobuf/fown.pb-c.h"
#include "protobuf/fs.pb-c.h"
#include "protobuf/pstree.pb-c.h"
#include "protobuf/pipe.pb-c.h"
#include "protobuf/pipe-data.pb-c.h"
#include "protobuf/sa.pb-c.h"
#include "protobuf/itimer.pb-c.h"
#include "protobuf/mm.pb-c.h"
#include "protobuf/vma.pb-c.h"
#include "protobuf/creds.pb-c.h"
#include "protobuf/core.pb-c.h"

#define DEF_PAGES_PER_LINE	6

#ifndef CONFIG_X86_64
# error No x86-32 support yet
#endif


#define PR_SYMBOL(sym)			\
	(isprint(sym) ? sym : '.')

static LIST_HEAD(pstree_list);

void show_files(int fd_files, struct cr_options *o)
{
	pb_show_plain(fd_files, fdinfo_entry);
}

void show_fown_cont(void *p)
{
	FownEntry *fown = p;
	pr_msg("fown: uid: %#x euid: %#x signum: %#x pid_type: %#x pid: %u",
	       fown->uid, fown->euid, fown->signum, fown->pid_type, fown->pid);
}

void show_reg_files(int fd_reg_files, struct cr_options *o)
{
	pb_show_plain(fd_reg_files, reg_file_entry);
}

void show_remap_files(int fd, struct cr_options *o)
{
	pb_show_plain(fd, remap_file_path_entry);
}

void show_ghost_file(int fd, struct cr_options *o)
{
	pb_show_vertical(fd, ghost_file_entry);
}

static void pipe_data_handler(int fd, void *obj)
{
	PipeDataEntry *e = obj;
	pr_msg("\n");
	print_image_data(fd, e->bytes);
}

void show_pipes_data(int fd, struct cr_options *o)
{
	pb_show_plain_payload(fd, pipe_data_entry, pipe_data_handler);
}

void show_pipes(int fd_pipes, struct cr_options *o)
{
	pb_show_plain(fd_pipes, pipe_entry);
}

void show_fifo_data(int fd, struct cr_options *o)
{
	show_pipes_data(fd, o);
{'fraction_non_alphanumeric': 0.1625130890052356, 'fraction_numerical': 0.005026178010471204, 'mean_word_length': 5.351063829787234, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 39, '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': '697515', 'n_tokens_mistral': 2153, 'n_tokens_neox': 2123, 'n_words': 396}