<commit_before>
/*
 * Licensed Materials - Property of IBM
 *
 * trousers - An open source TCG Software Stack
 *
 * (C) Copyright International Business Machines Corp. 2004-2006
 *
 */


#include <stdio.h>
#include <string.h>
#include <syslog.h>

#include "tcslog.h"

int foreground = 0;

/*
 * LogBlobData()
 *
 *   Log a blob's data to the debugging stream
 *
 * szDescriptor - The APPID tag found in the caller's environment at build time
 * sizeOfBlob - The size of the data to log
 * blob - the data to log
 *
 */

void
LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
{
	char temp[64];
	unsigned int i;

	if (!foreground)
		openlog(szDescriptor, LOG_NDELAY|LOG_PID, TSS_SYSLOG_LVL);
	memset(temp, 0, sizeof(temp));

	for (i = 0; (unsigned long)i < sizeOfBlob; i++) {
		if ((i > 0) && ((i % 16) == 0)) {
			if (foreground)
				fprintf(stdout, "%s %s\n", szDescriptor, temp);
			else
				syslog(LOG_DEBUG, temp);
			memset(temp, 0, sizeof(temp));
		}
		snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]);
	}

	if (i == sizeOfBlob) {
		if (foreground)
			fprintf(stdout, "%s %s\n", szDescriptor, temp);
		else
			syslog(LOG_DEBUG, temp);
	}
}

<commit_msg>added new logging functions; only build file when debug is on<commit_after>
/*
 * Licensed Materials - Property of IBM
 *
 * trousers - An open source TCG Software Stack
 *
 * (C) Copyright International Business Machines Corp. 2004-2006
 *
 */


#include <stdio.h>
#include <string.h>
#include <syslog.h>

#include "trousers/tss.h"
#include "tcslog.h"

int foreground = 0;

#ifdef TSS_DEBUG

/*
 * LogBlobData()
 *
 *   Log a blob's data to the debugging stream
 *
 * szDescriptor - The APPID tag found in the caller's environment at build time
 * sizeOfBlob - The size of the data to log
 * blob - the data to log
 *
 */

void
LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
{
	char temp[64];
	unsigned int i;

	if (!foreground)
		openlog(szDescriptor, LOG_NDELAY|LOG_PID, TSS_SYSLOG_LVL);
	memset(temp, 0, sizeof(temp));

	for (i = 0; (unsigned long)i < sizeOfBlob; i++) {
		if ((i > 0) && ((i % 16) == 0)) {
			if (foreground)
				fprintf(stdout, "%s %s\n", szDescriptor, temp);
			else
				syslog(LOG_DEBUG, temp);
			memset(temp, 0, sizeof(temp));
		}
		snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]);
	}

	if (i == sizeOfBlob) {
		if (foreground)
			fprintf(stdout, "%s %s\n", szDescriptor, temp);
		else
			syslog(LOG_DEBUG, temp);
	}
}

void
LogTPMERR(TSS_RESULT result, char *file, int line)
{
	if (getenv("TSS_DEBUG_OFF") == NULL)
		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", "TPM", file, line, result);
}

TSS_RESULT
LogTDDLERR(TSS_RESULT result, char *file, int line)
{
	if (getenv("TSS_DEBUG_OFF") == NULL)
		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);

	return (result | TSS_LAYER_TDDL);
}

TSS_RESULT
LogTCSERR(TSS_RESULT result, char *file, int line)
{
	if (getenv("TSS_DEBUG_OFF") == NULL)
		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);

	return (result | TSS_LAYER_TCS);
}

#endif
{'fraction_non_alphanumeric': 0.15558424790187217, 'fraction_numerical': 0.0158166559070368, 'mean_word_length': 3.903481012658228, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '452050', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1177, 'n_words': 341}