#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <process.h>
#include <libp.h>

int system(const char *string)
{
	FILE *f;
	char buf[100],*a;
	a = getenv("COMSPEC");
	if (!string) {
		if (!a)
			return 0;
		else
			if (f = fopen(a,"r")) {
				fclose(f);
				return 1;
			}
			else
				return 0;
	}
	if (!a) {
		errno = ENOENT;
		return -1;
	}
	buf[0] = ' ';
	buf[1] = '-';
	buf[2] = 'C';
	strcpy(buf+3,string);
	spawnlp(P_WAIT,a,a,buf,0);
	return 0;
}