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

#define DBG_WRITE	if(AcksysWriteDebug)fprintf

int
AcksysWrite(HANDLE hfd,char *str,int len)
{
	DWORD count;

	if(len == 0)
		len = strlen(str);

	if( !WriteFile(hfd,str,len,&count,NULL) )
	{
		DBG_WRITE(stderr, "Write on %s failed, code %s\n",
			AcksysFile, AcksysStringError());
		count = -1;
	}
	else if(len != count) {
		DBG_WRITE(stderr, "Write: len=%d count=%d\n",len,count);
	}
	else {
		if(AcksysDbgIoPrint)printf(str);
	}
	return count;
}
