<commit_before>/* test.c
 *
 * Advanced Power Management BIOS test program.
 * (C) 2009-2012 <NAME>.
 * Hackipedia DOS library.
 *
 * This code is licensed under the LGPL.
 * <insert LGPL legal text here>
 *
 * Compiles for intended target environments:
 *   - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box]
 *
 * This program allows you to play with your APM BIOS interface. It should
 * not cause harm, but this code is provided under no warranty express or
 * implied. */
 
#include <stdio.h>
#include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <ctype.h>
#include <fcntl.h>
#include <dos.h>

#include <hw/dos/dos.h>
#include <hw/apm/apm.h>
#include <hw/8254/8254.h>		/* 8254 timer */
#include <hw/8259/8259.h>		/* 8259 PIC */

static void help() {
	fprintf(stderr,"test [options] [action]\n");
	fprintf(stderr,"Test program for APM BIOS functions\n");
#if TARGET_MSDOS == 32
	fprintf(stderr,"32-bit protected mode build\n");
#else
	fprintf(stderr,"16-bit real mode ");
#  if defined(__LARGE__)
	fprintf(stderr,"large");
#  elif defined(__MEDIUM__)
	fprintf(stderr,"medium");
#  elif defined(__COMPACT__)
	fprintf(stderr,"compact");
#  else
	fprintf(stderr,"small");
#  endif
	fprintf(stderr," build\n");
#endif
	fprintf(stderr,"   /h            help\n");
	fprintf(stderr,"   /v1.<n>       Use APM v1.N interface (v1.0, v1.1, or v1.2)\n");
	fprintf(stderr,"   /vn           Don't connect to APM\n");
	fprintf(stderr,"   /nd           Don't disconnect after call\n");
	fprintf(stderr,"   /if:<n>       Use interface (real");
#if TARGET_MSDOS == 32
		fprintf(stderr,", 16pm, 32pm)\n");
#else
		fprintf(stderr,")\n");
#endif
	fprintf(stderr,"Commands\n");
	fprintf(stderr,"   cpu-idle\n");
	fprintf(stderr,"   cpu-busy\n");
	fprintf(stderr,"   events\n");
	fprintf(stderr,"   status\n");
	fprintf(stderr,"   standby\n");
	fprintf(stderr,"   suspend\n");
	fprintf(stderr,"   off\n");
}

#define REQ_VER_NONE 1
int main(int argc,char **argv) {
	unsigned int req_ver = 0;
	unsigned int dont_disconnect = 0;
	unsigned int req_mode = APM_CONNECT_NONE;
	const char *action = NULL;
	int i;

	for (i=1;i < argc;) {
		const char *a = argv[i++];

		if (*a == '/' || *a == '-') {
			do { a++; } while (*a == '/' || *a == '-');

			if (!strncmp(a,"v1.",3)) {
				a += 3;
				req_ver = 0x100 + (atoi(a) & 0xFF);
			}
			else if (!strcmp(a,"vn")) {
				req_ver = REQ_VER_NONE;
			}
			else if (!strcmp(a,"nd")) {
				dont_disconnect = 1;
			}
			else if (!strcmp(a,"h") || !strcmp(a,"help")) {
				help();
			}
			else if (!strncmp(a,"if:",3)) {
				if (!strcmp(a,"real"))
					req_mode = APM_CONNECT_REALMODE;
				else if (!strcmp(a,"16pm"))
					req_mode = APM_CONNECT_16_PM;
				else if (!strcmp(a,"32pm"))
					req_mode = APM_CONNECT_32_PM;
				else {
					fprintf(stderr,"Unknown interface %s\n",a);
					return 1;
				}
			}
			else {
				fprintf(stderr,"Unknown param '%s'\n",a);
				help();
				return 1;
			}
		}
		else if (action == NULL) {
			action = a;
		}
		else {<commit_msg>oh my god... REALLY??? I forgot to adjust a char* pointer for proper parsing of the /if:... option.<commit_after>/* test.c
 *
 * Advanced Power Management BIOS test program.
 * (C) 2009-2012 <NAME>.
 * Hackipedia DOS library.
 *
 * This code is licensed under the LGPL.
 * <insert LGPL legal text here>
 *
 * Compiles for intended target environments:
 *   - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box]
 *
 * This program allows you to play with your APM BIOS interface. It should
 * not cause harm, but this code is provided under no warranty express or
 * implied. */
 
#include <stdio.h>
#include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <ctype.h>
#include <fcntl.h>
#include <dos.h>

#include <hw/dos/dos.h>
#include <hw/apm/apm.h>
#include <hw/8254/8254.h>		/* 8254 timer */
#include <hw/8259/8259.h>		/* 8259 PIC */

static void help() {
	fprintf(stderr,"test [options] [action]\n");
	fprintf(stderr,"Test program for APM BIOS functions\n");
#if TARGET_MSDOS == 32
	fprintf(stderr,"32-bit protected mode build\n");
#else
	fprintf(stderr,"16-bit real mode ");
#  if defined(__LARGE__)
	fprintf(stderr,"large");
#  elif defined(__MEDIUM__)
	fprintf(stderr,"medium");
#  elif defined(__COMPACT__)
	fprintf(stderr,"compact");
#  else
	fprintf(stderr,"small");
#  endif
	fprintf(stderr," build\n");
#endif
	fprintf(stderr,"   /h            help\n");
	fprintf(stderr,"   /v1.<n>       Use APM v1.N interface (v1.0, v1.1, or v1.2)\n");
	fprintf(stderr,"   /vn           Don't connect to APM\n");
	fprintf(stderr,"   /nd           Don't disconnect after call\n");
	fprintf(stderr,"   /if:<n>       Use interface (real");
#if TARGET_MSDOS == 32
		fprintf(stderr,", 16pm, 32pm)\n");
#else
		fprintf(stderr,")\n");
#endif
	fprintf(stderr,"Commands\n");
	fprintf(stderr,"   cpu-idle\n");
	fprintf(stderr,"   cpu-busy\n");
	fprintf(stderr,"   events\n");
	fprintf(stderr,"   status\n");
	fprintf(stderr,"   standby\n");
	fprintf(stderr,"   suspend\n");
	fprintf(stderr,"   off\n");
}

#define REQ_VER_NONE 1
int main(int argc,char **argv) {
	unsigned int req_ver = 0;
	unsigned int dont_disconnect = 0;
	unsigned int req_mode = APM_CONNECT_NONE;
	const char *action = NULL;
	int i;

	for (i=1;i < argc;) {
		const char *a = argv[i++];

		if (*a == '/' || *a == '-') {
			do { a++; } while (*a == '/' || *a == '-');

			if (!strncmp(a,"v1.",3)) {
				a += 3;
				req_ver = 0x100 + (atoi(a) & 0xFF);
			}
			else if (!strcmp(a,"vn")) {
				req_ver = REQ_VER_NONE;
			}
			else if (!strcmp(a,"nd")) {
				dont_disconnect = 1;
			}
			else if (!strcmp(a,"h") || !strcmp(a,"help")) {
				help();
			}
			else if (!strncmp(a,"if:",3)) {
				a += 3;
				if (!strcmp(a,"real"))
					req_mode = APM_CONNECT_REALMODE;
				else if (!strcmp(a,"16pm"))
					req_mode = APM_CONNECT_16_PM;
				else if (!strcmp(a,"32pm"))
					req_mode = APM_CONNECT_32_PM;
				else {
					fprintf(stderr,"Unknown interface %s\n",a);
					return 1;
				}
			}
			else {
				fprintf(stderr,"Unknown param '%s'\n",a);
				help();
				return 1;
			}
		}
		else if (action == NULL) {
			action = a;
		}
		else {
{'fraction_non_alphanumeric': 0.17992424242424243, 'fraction_numerical': 0.02446338383838384, 'mean_word_length': 3.267340067340067, 'pattern_counts': {'":': 0, '<': 41, '<?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': '3655194', 'n_tokens_mistral': 2692, 'n_tokens_neox': 2435, 'n_words': 623}