[19금?]vpenis.c

sheep의 이미지

http://tigert.gimp.org/files/screenshots/vpenis.c

위 링크에서 퍼옵니다

#include <gtk/gtk.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

#define PENIS_COMMAND "echo `uptime | grep days | sed 's/.*up \\([0-9]*\\) day.*/\\1\\/10+/'; \
cat /proc/cpuinfo | grep '^cpu MHz' | awk '{print $4\"/30 +\";}'; \
free | grep '^Mem' | awk '{print $3\"/1024/3+\"}'; \
df -P -k -x nfs | grep -v 1k | awk '{if ($1 ~ \"/dev/(scsi|sd)\"){ s+= $2} s+= $2;} END {print s/1024/50\"/15+70\";}'` |bc|sed 's/\\(.$\\)/.\\1/'"

static char *
calculate_vpenis_size (void)
{
	char *out;
	int fd;
	const char *buf = PENIS_COMMAND;

	unlink ("/tmp/vpenis.sh");
	fd = creat ("/tmp/vpenis.sh", S_IRWXU);
	if (fd < 0) {
		perror ("open busted");
	}
	if (write (fd, buf, strlen (PENIS_COMMAND)) < 0) {
		perror ("write busted");
	}
	close (fd);
	chmod ("/tmp/vpenis.sh", 0700);

	if (g_spawn_command_line_sync ("/bin/sh /tmp/vpenis.sh", &out, NULL, NULL, NULL) == FALSE)
		return NULL;

	unlink ("/tmp/vpenis.sh");
	return out;
}

int main (int argc, char **argv)
{
	GtkWidget *dialog;
	char *size;

	gtk_init (&argc, &argv);

	size = calculate_vpenis_size ();

	if (size)
	{
		dialog = gtk_message_dialog_new (NULL,
				0, GTK_MESSAGE_INFO,
				GTK_BUTTONS_CLOSE,
				"Your virtual penis is long of %s centimeters.",
				size);
	} else {
		dialog = gtk_message_dialog_new (NULL,
				0, GTK_MESSAGE_INFO,
				GTK_BUTTONS_CLOSE,
				"We couldn't calculate your virtual penis size, it be that bad");
	}

	gtk_dialog_run (GTK_DIALOG (dialog));

	return 0;
}

컴파일은

gcc -Wall -o vpenis `pkg-config --cflags --libs gtk+-2.0` vpenis.c

이 수치가 뭘 나타내는지 잘 모르겠네요...
제 컴에서 24.7일 때도 있고, 25.1일 때도 있네요....