<commit_before>/*
 * audioextract
 *
 * Author: <NAME>
 * This is derived from oggextract:
 * http://ner.mine.nu/oggextract/
 *
 * Original author of oggextract: <NAME>
 */

#include <getopt.h>
#include <strings.h>
#include <inttypes.h>
#include <errno.h>

#include "audioextract.h"
#include "riff.h"
#include "aiff.h"
#include "ogg.h"
#include "mpg123.h"
#include "mp4.h"
#include "id3.h"
#include "midi.h"
#include "mod.h"
#include "s3m.h"
#include "xm.h"
#include "it.h"
#include "asf.h"
#include "bink.h"

#if defined(__WINDOWS__) && !defined(__CYGWIN__)
#	ifdef _WIN64
#		define PRIuz PRIu64
#		define EXTRACTED_FILE_FMT "%s%c%s_%08"PRIx64".%s"
#	else
#		define PRIuz PRIu32
#		define EXTRACTED_FILE_FMT "%s%c%s_%08"PRIx32".%s"
#	endif
#else
#	define PRIuz "zu"
#	define EXTRACTED_FILE_FMT "%s%c%s_%08zx.%s"
#endif

#define SEE_HELP "See --help for usage information.\n"

enum fileformat {
	NONE   =    0,
	OGG    =    1,
	RIFF   =    2,
	AIFF   =    4,
	MPG123 =    8,
	ID3v2  =   16,
	MP4    =   32,
	MIDI   =   64,
	MOD    =  128,
	S3M    =  256,
	IT     =  512,
	XM     = 1024,
	ASF    = 2048,
	BINK   = 4096
};

#define ALL_FORMATS     (OGG | RIFF | AIFF | MPG123 | MP4 | ID3v2 | MIDI | MOD | S3M | IT | XM | ASF | BINK)
#define DEFAULT_FORMATS (OGG | RIFF | AIFF |          MP4 | ID3v2 | MIDI |       S3M | IT | XM | ASF | BINK)
#define TRACKER_FORMATS (MOD | S3M  | IT   | XM)

int usage(int argc, char **argv)
{
	const char *progname = argc <= 0 ? "audioextract" : argv[0]; 
	fprintf(stderr,
		"audioextract - extracts audio files that are embedded within other files\n"
		"\n"
		"Usage:\n"
		"  %s [option...] <filename> [<filename> ...]\n"
		"\n"
		"Options:\n"
		"  -h, --help             Print this help message.\n"
		"  -q, --quiet            Do not print status messages.\n"
		"  -o, --output=DIR       Directory where extracted files should be written. (default: \".\")\n"
		"  -i, --offset=OFFSET    Start processing at byte OFFSET. (default: 0)\n"
		"  -n, --length=LENGTH    Only process LENGTH bytes.\n"
		"                         (default and maximum: %"PRIuz")\n"

#ifndef __LP64__

		"\n"
		"                         NOTE: This program is compiled as a 32bit binary. This means\n"
		"                         the maximum amount of bytes that can be processed at once are\n"
		"                         limited to 2 GB. The rest of bigger files will be ignored. You\n"
		"                         need to run this program several times with different offsets\n"
		"                         to process such a file whole.\n"
		"\n"
		"                         This also means that extracted files can never be larger than\n"
		"                         2 GB.\n"
		"\n"

#endif

		"  -m, --min-size=SIZE    Minumum size of extracted files (skip smaller). (default: 0)\n"
		"  -x, --max-size=SIZE    Maximum size of extracted files (skip larger).\n"
		"                         (default and maximum: %"PRIuz")\n"
		"\n"
		"                         The last character of OFFSET, LENGTH and SIZE may be one of the\n"
		"                         following:\n"
		"                           B (or none)  for bytes\n"
		"                           k            for Kilobytes (units of 1024 bytes)\n"
		"                           M            for Megabytes (units of 1024 Kilobytes)\n"
		"                           G            for Gigabytes (units of 1024 Megabytes)\n"<commit_msg>fix help message on win64<commit_after>/*
 * audioextract
 *
 * Author: <NAME>
 * This is derived from oggextract:
 * http://ner.mine.nu/oggextract/
 *
 * Original author of oggextract: <NAME>
 */

#include <getopt.h>
#include <strings.h>
#include <inttypes.h>
#include <errno.h>

#include "audioextract.h"
#include "riff.h"
#include "aiff.h"
#include "ogg.h"
#include "mpg123.h"
#include "mp4.h"
#include "id3.h"
#include "midi.h"
#include "mod.h"
#include "s3m.h"
#include "xm.h"
#include "it.h"
#include "asf.h"
#include "bink.h"

#if defined(__WINDOWS__) && !defined(__CYGWIN__)
#	ifdef _WIN64
#		define PRIuz PRIu64
#		define EXTRACTED_FILE_FMT "%s%c%s_%08"PRIx64".%s"
#	else
#		define PRIuz PRIu32
#		define EXTRACTED_FILE_FMT "%s%c%s_%08"PRIx32".%s"
#	endif
#else
#	define PRIuz "zu"
#	define EXTRACTED_FILE_FMT "%s%c%s_%08zx.%s"
#endif

#define SEE_HELP "See --help for usage information.\n"

enum fileformat {
	NONE   =    0,
	OGG    =    1,
	RIFF   =    2,
	AIFF   =    4,
	MPG123 =    8,
	ID3v2  =   16,
	MP4    =   32,
	MIDI   =   64,
	MOD    =  128,
	S3M    =  256,
	IT     =  512,
	XM     = 1024,
	ASF    = 2048,
	BINK   = 4096
};

#define ALL_FORMATS     (OGG | RIFF | AIFF | MPG123 | MP4 | ID3v2 | MIDI | MOD | S3M | IT | XM | ASF | BINK)
#define DEFAULT_FORMATS (OGG | RIFF | AIFF |          MP4 | ID3v2 | MIDI |       S3M | IT | XM | ASF | BINK)
#define TRACKER_FORMATS (MOD | S3M  | IT   | XM)

int usage(int argc, char **argv)
{
	const char *progname = argc <= 0 ? "audioextract" : argv[0]; 
	fprintf(stderr,
		"audioextract - extracts audio files that are embedded within other files\n"
		"\n"
		"Usage:\n"
		"  %s [option...] <filename> [<filename> ...]\n"
		"\n"
		"Options:\n"
		"  -h, --help             Print this help message.\n"
		"  -q, --quiet            Do not print status messages.\n"
		"  -o, --output=DIR       Directory where extracted files should be written. (default: \".\")\n"
		"  -i, --offset=OFFSET    Start processing at byte OFFSET. (default: 0)\n"
		"  -n, --length=LENGTH    Only process LENGTH bytes.\n"
		"                         (default and maximum: %"PRIuz")\n"

#if !defined(__LP64__) && !defined(_WIN64)

		"\n"
		"                         NOTE: This program is compiled as a 32bit binary. This means\n"
		"                         the maximum amount of bytes that can be processed at once are\n"
		"                         limited to 2 GB. The rest of bigger files will be ignored. You\n"
		"                         need to run this program several times with different offsets\n"
		"                         to process such a file whole.\n"
		"\n"
		"                         This also means that extracted files can never be larger than\n"
		"                         2 GB.\n"
		"\n"

#endif

		"  -m, --min-size=SIZE    Minumum size of extracted files (skip smaller). (default: 0)\n"
		"  -x, --max-size=SIZE    Maximum size of extracted files (skip larger).\n"
		"                         (default and maximum: %"PRIuz")\n"
		"\n"
		"                         The last character of OFFSET, LENGTH and SIZE may be one of the\n"
		"                         following:\n"
		"                           B (or none)  for bytes\n"
		"                           k            for Kilobytes (units of 1024 bytes)\n"
		"                           M            for Megabytes (units of 1024 Kilobytes)\n"
		"                           G            for Gigabytes (units of 1024 Megabytes)\n"
{'fraction_non_alphanumeric': 0.1307017543859649, 'fraction_numerical': 0.028362573099415204, 'mean_word_length': 1.8611459640317858, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1503456', 'n_tokens_mistral': 2679, 'n_tokens_neox': 2464, 'n_words': 724}