<commit_before>/*
 * The Qubes OS Project, http://www.qubes-os.org
 *
 * Copyright (C) 2010  <NAME>  <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <xs.h>
int check_name(unsigned char *s)
{
	int c;
	for (; *s; s++) {
		c = *s;
		if (c >= 'a' && c <= 'z')
			continue;
		if (c >= 'A' && c <= 'Z')
			continue;
		if (c == '_' || c == '-')
			continue;
		return 0;
	}
	return 1;
}

int main(int argc, char **argv)
{
	char buf[256] = "new";
	struct xs_handle *xs;
	xs = xs_domain_open();
	setuid(getuid());
	if (!xs) {
		perror("xs_domain_open");
		exit(1);
	}
	if (argc < 2) {
		fprintf(stderr, "usage: %s new\n"
			"%s send vmname\n", argv[0], argv[0]);
		exit(1);
	}
	if (argc > 2) {
		if (!check_name((unsigned char*)argv[2])) {
			fprintf(stderr, "invalid vmname %s\n", argv[2]);
			exit(1);
		}
		snprintf(buf, sizeof(buf), "send %s", argv[2]);
	}
	if (!xs_write(xs, 0, "device/qpen", buf, strlen(buf))) {
		perror("xs_write");
		exit(1);
	}
	xs_daemon_close(xs);
	return 0;
}<commit_msg>penctl: 3rd arg is seq<commit_after>/*
 * The Qubes OS Project, http://www.qubes-os.org
 *
 * Copyright (C) 2010  <NAME>  <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <xs.h>
void check_name(unsigned char *s)
{
	int c;
	for (; *s; s++) {
		c = *s;
		if (c >= 'a' && c <= 'z')
			continue;
		if (c >= 'A' && c <= 'Z')
			continue;
		if (c == '_' || c == '-')
			continue;
		fprintf(stderr, "invalid string %s\n", s);
		exit(1);
	}
}

void usage(char *argv0)
{
	fprintf(stderr, "usage: %s new\n"
		"%s send vmname [seq]\n", argv0, argv0);
	exit(1);
}

int main(int argc, char **argv)
{
	char buf[256] = "new";
	struct xs_handle *xs;
	xs = xs_domain_open();
	setuid(getuid());
	if (!xs) {
		perror("xs_domain_open");
		exit(1);
	}
	switch (argc) {
	case 2:
		break;
	case 3:
		check_name((unsigned char *) argv[2]);
		snprintf(buf, sizeof(buf), "send %s", argv[2]);
		break;
	case 4:
		check_name((unsigned char *) argv[2]);
		check_name((unsigned char *) argv[3]);
		snprintf(buf, sizeof(buf), "send %s %s", argv[2], argv[3]);
	default:
		usage(argv[0]);
	}

	if (!xs_write(xs, 0, "device/qpen", buf, strlen(buf))) {
		perror("xs_write");
		exit(1);
	}
	xs_daemon_close(xs);
	return 0;
}
{'fraction_non_alphanumeric': 0.15783841626538256, 'fraction_numerical': 0.019529159978598182, 'mean_word_length': 3.64472049689441, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6159388', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1345, 'n_words': 471}