#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ack_w32.h"

char AcksysFile[20];

HANDLE
AcksysOpen(char *numvoie,int flags)
{
	HANDLE hfd;

	if(isdigit(*numvoie)) {
		strcpy(AcksysFile,"\\\\.\\MCX");
		if(atoi(numvoie) < 10)
			strcat(AcksysFile,"10");
		else if(atoi(numvoie) < 100)
			strcat(AcksysFile,"1");
	} else if(*numvoie=='=') {
		strcpy(AcksysFile,"");
		numvoie++;
	} else {
		strcpy(AcksysFile,"\\\\.\\");
	}
	strcat(AcksysFile,numvoie);

	if((hfd=CreateFile(AcksysFile,GENERIC_WRITE|GENERIC_READ,
				0,
				NULL,
				OPEN_EXISTING,
				flags,
				NULL)) == INVALID_HANDLE_VALUE){
		printf("Open '%s' failed, code %d\n",AcksysFile,GetLastError());
		exit(1);
	}
	return hfd;
}

AcksysClose(HANDLE hfd)
{
	CloseHandle(hfd);
}
