#include <alch.h>

char buf1[300],buf2[300];

// OS/2 installation ******************************************************
#ifdef OS2

import "doscalls" index 348
uint __stdcall DosQuerySysInfo(uint iStart,uint iLast,void *buf,uint buflen);

import "doscalls" index 258
uint __stdcall DosCopy(char *pszOld,char *pszNew,uint option);

#define QSV_BOOT_DRIVE 5

DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,(char*)&buf1,4);
buf1[0]+='@';
buf1[1]=0;
strcat(buf1,":\\OS2");

strcpy(buf2,buf1);
strcat(buf2,"\\alch.exe");
printf("Copying alch.exe ... ");
int rc=DosCopy("os2\\alch.exe",buf2,1);
printf(rc==0?"ok\n":"failed\n");
strcpy(buf2,buf1);
strcat(buf2,"\\dll\\sprtlib.dll");
printf("Copying sprtlib.dll ... ");
int rc=DosCopy("os2\\sprtlib.dll",buf2,1);
printf(rc==0?"ok\n":"failed\n");

#endif // OS2

// Windows installation ******************************************************
#ifdef WIN32

import "kernel32.dll" name "GetWindowsDirectoryA"
uint __stdcall GetWindowsDirectory(char *lpBuffer,uint uSize);

import "kernel32.dll" name "CopyFileA"
uint __stdcall CopyFile(char*lpExistingFileName,char*lpNewFileName,uint bFailIfExists);

GetWindowsDirectory(buf1,300);

strcpy(buf2,buf1);
strcat(buf2,"\\alch.exe");
printf("Copying alch.exe ... ");
int rc=CopyFile("win32\\alch.exe",buf2,0);
printf(rc?"ok\n":"failed\n");
strcpy(buf2,buf1);
strcat(buf2,"\\system32\\sprtlib.dll");
printf("Copying sprtlib.dll ... ");
int rc=CopyFile("win32\\sprtlib.dll",buf2,0);
printf(rc?"ok\n":"failed\n");

#endif // WIN32
