winaspi+libscg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Here's my winaspi patches that uses libscg for the scsi transport layer. It 
statically links libscg, which is the part of the cdrtools package (all 
distribution have it). It allows the use of aspi on more architectures (I 
tested only on linux). The 16 bit interface (winaspi.dll) is not tested, the 
32 bit version is tested with Nero, Isobuster and Philips firmware update 
tool. I attached 2 files: winaspi diff is the actual code patch, 
winaspi-configure.diff is a patch to configure.ac for libscg detection.

Best regards,
György Szombathelyi
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/Makefile.in dlls/winaspi/Makefile.in
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/Makefile.in	Thu Sep 19 00:30:01 2002
+++ dlls/winaspi/Makefile.in	Thu Sep 19 00:27:50 2002
@@ -5,7 +5,8 @@
 MODULE    = wnaspi32.dll
 IMPORTS   = advapi32 kernel32
 ALTNAMES  = winaspi.dll
-
+EXTRAINCL = @SCG_CPPFLAGS@
+EXTRALIBS =  @SCG_LIBS@/libscg.a @SCG_LIBS@/libschily.a
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/aspi.c dlls/winaspi/aspi.c
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/aspi.c	Thu Sep 19 00:30:03 2002
+++ dlls/winaspi/aspi.c	Thu Sep 19 00:40:01 2002
@@ -17,39 +17,18 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* These routines are to be called from either WNASPI32 or WINASPI */
-
-/* FIXME:
- * - Registry format is stupid for now.. fix that later
- * - No way to override automatic /proc detection, maybe provide an
- *   HKEY_LOCAL_MACHINE\Software\Wine\Wine\Scsi regkey
- * - Somewhat debating an #ifdef linux... technically all this code will
- *   run on another UNIX.. it will fail nicely.
- * - Please add support for mapping multiple channels on host adapters to
- *   aspi controllers, e-mail me if you need help.
- */
-
 /*
-Registry format is currently:
-HKEY_DYN_DATA
-	WineScsi
-		(default)=number of host adapters
-		hHHcCCtTTdDD=linux device name
+Modified to use libscg 
+(C) 2002 Gyorgy Szombathelyi <gyurco@freemail.hu>
+- removed registry support
+- libscg works on many platforms
 */
 
+/* These routines are to be called from either WNASPI32 or WINASPI */
+
 #include "config.h"
 
 #include <stdio.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-#include <fcntl.h>
-#include <dirent.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <errno.h>
 #include <string.h>
 
 #include "wine/debug.h"
@@ -57,609 +36,114 @@
 #include "winerror.h"
 #include "winescsi.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(aspi);
+#include "wnaspi32.h"
 
-/* Internal function prototypes */
-static void
-SCSI_GetProcinfo();
-
-#ifdef linux
-static void
-SCSI_MapHCtoController();
-#endif
+#ifdef HAVE_SCG
+#include "xconfig.h"
+#include "scg/scgcmd.h"
+#include "scg/scsitransp.h"
+#endif /* HAVE_SCG */
 
-static void set_last_error(void)
-{
-    int save_errno = errno; /* errno gets overwritten by printf */
-    switch (errno)
-    {
-    case EAGAIN:
-        SetLastError( ERROR_SHARING_VIOLATION );
-        break;
-    case EBADF:
-        SetLastError( ERROR_INVALID_HANDLE );
-        break;
-    case ENOSPC:
-        SetLastError( ERROR_HANDLE_DISK_FULL );
-        break;
-    case EACCES:
-    case EPERM:
-    case EROFS:
-        SetLastError( ERROR_ACCESS_DENIED );
-        break;
-    case EBUSY:
-        SetLastError( ERROR_LOCK_VIOLATION );
-        break;
-    case ENOENT:
-        SetLastError( ERROR_FILE_NOT_FOUND );
-        break;
-    case EISDIR:
-        SetLastError( ERROR_CANNOT_MAKE );
-        break;
-    case ENFILE:
-    case EMFILE:
-        SetLastError( ERROR_NO_MORE_FILES );
-        break;
-    case EEXIST:
-        SetLastError( ERROR_FILE_EXISTS );
-        break;
-    case EINVAL:
-    case ESPIPE:
-        SetLastError( ERROR_SEEK );
-        break;
-    case ENOTEMPTY:
-        SetLastError( ERROR_DIR_NOT_EMPTY );
-        break;
-    case ENOEXEC:
-        SetLastError( ERROR_BAD_FORMAT );
-        break;
-    default:
-        WARN( "unknown file error: %s\n", strerror(save_errno) );
-        SetLastError( ERROR_GEN_FAILURE );
-        break;
-    }
-    errno = save_errno;
-}
+WINE_DEFAULT_DEBUG_CHANNEL(aspi);
+
+#ifdef HAVE_SCG
+static SCSI *scgp_;
+static CRITICAL_SECTION ASPI_CritSection = CRITICAL_SECTION_INIT("ASPI_CritSection");
+#endif /* HAVE_SCG */
+static int buses ;
 
 /* Exported functions */
 void
 SCSI_Init()
 {
-	/* For now we just call SCSI_GetProcinfo */
-	SCSI_GetProcinfo();
-#ifdef linux
-	SCSI_MapHCtoController();
-#endif
-}
-
-int
-ASPI_GetNumControllers()
-{
-	HKEY hkeyScsi;
-	HKEY hkeyControllerMap;
-	DWORD error;
-	DWORD type = REG_DWORD;
-	DWORD num_ha = 0;
-	DWORD cbData = sizeof(num_ha);
-
-	if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		return 0;
-	}
-
-	if( (error=RegOpenKeyExA(hkeyScsi, KEYNAME_SCSI_CONTROLLERMAP, 0, KEY_ALL_ACCESS, &hkeyControllerMap )) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\\%s\n", KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
-		RegCloseKey(hkeyScsi);
-		SetLastError(error);
-		return 0;
-	}
-	if( RegQueryValueExA(hkeyControllerMap, NULL, NULL, &type, (LPBYTE)&num_ha, &cbData ) != ERROR_SUCCESS )
-	{
-		ERR("Could not query value HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		num_ha=0;
-	}
-	RegCloseKey(hkeyControllerMap);
-	RegCloseKey(hkeyScsi);
-	TRACE("Returning %ld host adapters\n", num_ha );
-	return num_ha;
-}
-
-BOOL
-SCSI_GetDeviceName( int h, int c, int t, int d, LPSTR devstr, LPDWORD lpcbData )
-{
-
-	char idstr[20];
-	HKEY hkeyScsi;
-	DWORD type;
-
-	if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		return FALSE;
-	}
-
-
-	sprintf(idstr, "h%02dc%02dt%02dd%02d", h, c, t, d);
-
-	if( RegQueryValueExA(hkeyScsi, idstr, NULL, &type, devstr, lpcbData) != ERROR_SUCCESS )
-	{
-		WARN("Could not query value HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, idstr);
-		RegCloseKey(hkeyScsi);
-		return FALSE;
-	}
-	RegCloseKey(hkeyScsi);
-
-	TRACE("scsi %s: Device name: %s\n",idstr,devstr);
-	return TRUE;
-}
-
-/* SCSI_GetHCforController
- * RETURNS
- * 	HIWORD: Host Adapter
- * 	LOWORD: Channel
- */
-DWORD
-ASPI_GetHCforController( int controller )
-{
-	DWORD hc = 0xFFFFFFFF;
-	char cstr[20];
-	DWORD error;
-	HKEY hkeyScsi;
-	HKEY hkeyControllerMap;
-	DWORD type = REG_DWORD;
-	DWORD cbData = sizeof(DWORD);
-	DWORD disposition;
-#if 0
-	FIXME("Please fix to map each channel of each host adapter to the proper ASPI controller number!\n");
-	hc = (controller << 16);
-	return hc;
-#endif
-	if( (error=RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition )) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		SetLastError(error);
-		return hc;
-	}
-	if( disposition != REG_OPENED_EXISTING_KEY )
-	{
-		WARN("Created HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-	}
-	if( (error=RegCreateKeyExA(hkeyScsi, KEYNAME_SCSI_CONTROLLERMAP, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyControllerMap, &disposition )) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\\%s\n", KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
-		RegCloseKey(hkeyScsi);
-		SetLastError(error);
-		return hc;
-	}
-	if( disposition != REG_OPENED_EXISTING_KEY )
-	{
-		WARN("Created HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
-	}
-
-	sprintf(cstr, "c%02d", controller);
-	if( (error=RegQueryValueExA( hkeyControllerMap, cstr, 0, &type, (LPBYTE)&hc, &cbData)) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\\%s\\%s, error=%lx\n", KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP, cstr, error );
-		SetLastError( error );
-	}
-	RegCloseKey(hkeyControllerMap);
-	RegCloseKey(hkeyScsi);
-	return hc;
-
-};
+    buses = 0;
 
-int
-SCSI_OpenDevice( int h, int c, int t, int d )
-{
-	char devstr[20];
-	DWORD cbData = 20;
-	int fd = -1;
-	char dainbread_linux_hack = 1;
-
-	if(!SCSI_GetDeviceName( h, c, t, d, devstr, &cbData ))
-	{
-		WARN("Could not get device name for h%02dc%02dt%02dd%02d\n", h, c, t, d);
-		return -1;
-	}
-
-linux_hack:
-	TRACE("Opening device %s mode O_RDWR\n",devstr);
-	fd = open(devstr, O_RDWR);
-
-	if( fd < 0 )
-	{
-		int len = strlen(devstr);
-		set_last_error(); /* SetLastError() to errno */
-		TRACE("Open failed (%s)\n", strerror(errno));
-
-		/* in case of "/dev/sgX", convert from sga to sg0
-		 * and the other way around.
-		 * FIXME: remove it if the distributions
-		 * finally manage to agree on something.
-		 * The best would probably be a complete
-		 * rewrite of the Linux SCSI layer
-		 * to use CAM + devfs :-) */
-		if ( (dainbread_linux_hack) &&
-		     (len >= 3) &&
-		     (devstr[len-3] == 's') && (devstr[len-2] == 'g') )
-		{
-			char *p = &devstr[len-1];
-			*p = (*p >= 'a') ? *p - 'a' + '0' : *p - '0' + 'a';
-			dainbread_linux_hack = 0;
-			TRACE("Retry with \"equivalent\" Linux device '%s'\n", devstr);
-			goto linux_hack;
-		}
-	}
-	return fd;
+#ifdef HAVE_SCG
+    char errstr[80];
+    int i;
+    
+    scgp_ = scg_open(NULL,errstr,sizeof(errstr),0,0);
+    if (!scgp_) {
+	ERR("Cannot open libscg\n");	
+	return;
+    }
+    
+    for (i=0;i<8;i++) {
+	if (scg_havebus(scgp_,i)) buses++; else break;
+    }
+    TRACE("Found %d buses\n",buses);
+#else /* HAVE_SCG */
+    ERR("ASPI support not compiled in\n");
+#endif /* HAVE_SCG */
 }
 
-#ifdef linux
-/* SCSI_Fix_CMD_LEN
- * 	Checks to make sure the CMD_LEN is correct
- */
 void
-SCSI_Fix_CMD_LEN(int fd, int cmd, int len)
+SCSI_UnInit()
 {
-	int index=(cmd>>5)&7;
-
-	if (len!=scsi_command_size[index])
-	{
-		TRACE("CDBLen for command %d claims to be %d, expected %d\n",
-				cmd, len, scsi_command_size[index]);
-		ioctl(fd,SG_NEXT_CMD_LEN,&len);
-	}
+#ifdef HAVE_SCG
+    if (scgp_) scg_close(scgp_);
+    DeleteCriticalSection( &ASPI_CritSection );
+#endif /* HAVE_SCG */
 }
 
 int
-SCSI_LinuxSetTimeout( int fd, int timeout )
+SCSI_GetNumControllers()
 {
-	int retval;
-	TRACE("Setting timeout to %d jiffies\n", timeout);
-	retval=ioctl(fd,SG_SET_TIMEOUT,&timeout);
-	if(retval)
-	{
-		WARN("Could not set timeout ! (%s)\n", strerror(errno));
-	}
-	return retval;
-
+    return buses;
 }
 
-/* This function takes care of the write/read to the linux sg device.
- * It returns TRUE or FALSE and uses set_last_error() to convert
- * UNIX errno to Windows GetLastError().  The reason for that is that
- * several programs will check that error and we might as well set
- * it here.  We also return the value of the read call in
- * lpcbBytesReturned.
- */
-BOOL /* NOTE: This function SHOULD BLOCK */
-SCSI_LinuxDeviceIo( int fd,
-		struct sg_header * lpInBuffer, DWORD cbInBuffer,
-		struct sg_header * lpOutBuffer, DWORD cbOutBuffer,
-		LPDWORD lpcbBytesReturned )
+int SCSI_SendCmd(int ha,int ta,int lu, 
+    const char *cmd, int cmdLen,
+    char *data, int *dataLen, int flags,
+    char *senseArea, int senseLen,char *taStat)
 {
-	DWORD dwBytes;
-	DWORD save_error;
+#ifdef HAVE_SCG
+    struct scg_cmd *scmd = scgp_->scmd;
+    int retval;
+    				
+    EnterCriticalSection(&ASPI_CritSection);
 
-	TRACE("Writing to Linux sg device\n");
-	dwBytes = write( fd, lpInBuffer, cbInBuffer );
-	if( dwBytes != cbInBuffer )
-	{
-		set_last_error();
-		save_error = GetLastError();
-		WARN("Not enough bytes written to scsi device. bytes=%ld .. %ld\n", cbInBuffer, dwBytes );
-                /* FIXME: set_last_error() never sets error to ERROR_NOT_ENOUGH_MEMORY... */
-		if( save_error == ERROR_NOT_ENOUGH_MEMORY )
-			MESSAGE("Your Linux kernel was not able to handle the amount of data sent to the scsi device. Try recompiling with a larger SG_BIG_BUFF value (kernel 2.0.x sg.h)");
-		WARN("error= %ld\n", save_error );
-		*lpcbBytesReturned = 0;
-		return FALSE;
-	}
-
-	TRACE("Reading reply from Linux sg device\n");
-	*lpcbBytesReturned = read( fd, lpOutBuffer, cbOutBuffer );
-	if( *lpcbBytesReturned != cbOutBuffer )
-	{
-		set_last_error();
-		save_error = GetLastError();
-		WARN("Not enough bytes read from scsi device. bytes=%ld .. %ld\n", cbOutBuffer, *lpcbBytesReturned);
-		WARN("error= %ld\n", save_error );
-		return FALSE;
-	}
-	return TRUE;
-}
-
-/* Internal functions */
-struct LinuxProcScsiDevice
-{
-	int host;
-	int channel;
-	int target;
-	int lun;
-	char vendor[9];
-	char model[17];
-	char rev[5];
-	char type[33];
-	int ansirev;
-};
-
-/*
- * we need to declare white spaces explicitly via %*1[ ],
- * as there are very dainbread CD-ROM devices out there
- * which have their manufacturer name blanked out via spaces,
- * which confuses fscanf's parsing (skips all blank spaces)
- */
-static int
-SCSI_getprocentry( FILE * procfile, struct LinuxProcScsiDevice * dev )
-{
-	int result;
-	result = fscanf( procfile,
-		"Host:%*1[ ]scsi%d%*1[ ]Channel:%*1[ ]%d%*1[ ]Id:%*1[ ]%d%*1[ ]Lun:%*1[ ]%d\n",
-		&dev->host,
-		&dev->channel,
-		&dev->target,
-		&dev->lun );
-	if( result == EOF )
-	{
-		/* "end of entries" return, so no TRACE() here */
-		return EOF;
-	}
-	if( result != 4 )
-	{
-		ERR("bus id line scan count error\n");
-		return 0;
-	}
-	result = fscanf( procfile,
-		"  Vendor:%*1[ ]%8c%*1[ ]Model:%*1[ ]%16c%*1[ ]Rev:%*1[ ]%4c\n",
-		dev->vendor,
-		dev->model,
-		dev->rev );
-	if( result != 3 )
-	{
-		ERR("model line scan count error\n");
-		return 0;
-	}
-
-	result = fscanf( procfile,
-		"  Type:%*3[ ]%32c%*1[ ]ANSI%*1[ ]SCSI%*1[ ]revision:%*1[ ]%d\n",
-		dev->type,
-		&dev->ansirev );
-	if( result != 2 )
-	{
-		ERR("SCSI type line scan count error\n");
-		return 0;
-	}
-	/* Since we fscanf with %XXc instead of %s.. put a NULL at end */
-	dev->vendor[8] = 0;
-	dev->model[16] = 0;
-	dev->rev[4] = 0;
-	dev->type[32] = 0;
-
-	return 1;
-}
-
-static void
-SCSI_printprocentry( const struct LinuxProcScsiDevice * dev )
-{
-	TRACE( "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n",
-		dev->host,
-		dev->channel,
-		dev->target,
-		dev->lun );
-	TRACE( "  Vendor: %s Model: %s Rev: %s\n",
-		dev->vendor,
-		dev->model,
-		dev->rev );
-	TRACE( "  Type:   %s ANSI SCSI revision: %02d\n",
-		dev->type,
-		dev->ansirev );
-}
-
-static BOOL
-SCSI_PutRegControllerMap( HKEY hkeyControllerMap, int num_controller, int ha, int chan)
-{
-	DWORD error;
-	char cstr[20];
-	DWORD hc;
-	hc = (ha << 16) + chan;
-	sprintf(cstr, "c%02d", num_controller);
-	if( (error=RegSetValueExA( hkeyControllerMap, cstr, 0, REG_DWORD, (LPBYTE)&hc, sizeof(DWORD))) != ERROR_SUCCESS )
-	{
-		ERR("Could not create HKEY_DYN_DATA\\%s\\%s\\%s\n", KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP, cstr );
-	}
-	return error;
-}
-
-static void
-SCSI_MapHCtoController()
-{
-	HKEY hkeyScsi;
-	HKEY hkeyControllerMap;
-	DWORD disposition;
-
-	char idstr[20];
-	DWORD cbIdStr;
-	int i = 0;
-	DWORD type = 0;
-	DWORD error;
-
-	DWORD num_controller = 0;
-	int last_ha = -1;
-	int last_chan = -1;
-
-	int ha = 0;
-	int chan = 0;
-
-	if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS )
-	{
-		ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		return;
-	}
-	if( disposition != REG_OPENED_EXISTING_KEY )
-	{
-		WARN("Created HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-	}
-	if( RegCreateKeyExA(hkeyScsi, KEYNAME_SCSI_CONTROLLERMAP, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyControllerMap, &disposition ) != ERROR_SUCCESS )
-	{
-		ERR("Could not create HKEY_DYN_DATA\\%s\\%s\n", KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
-		RegCloseKey(hkeyScsi);
-		return;
-	}
-
-	for( i=0; cbIdStr = sizeof(idstr), (error=RegEnumValueA( hkeyScsi, i, idstr, &cbIdStr, NULL, &type, NULL, NULL )) == ERROR_SUCCESS; i++ )
-	{
-	        if(idstr[0] == '\0') continue; /* skip the default value */
-
-		if(sscanf(idstr, "h%02dc%02dt%*02dd%*02d", &ha, &chan) != 2) {
-			ERR("incorrect reg. value %s\n", debugstr_a(idstr));
-			continue;
-		}
-
-		if( last_ha < ha )
-		{	/* Next HA */
-			last_ha = ha;
-			last_chan = chan;
-			SCSI_PutRegControllerMap( hkeyControllerMap, num_controller, ha, chan);
-			num_controller++;
-		}
-		else if( last_ha > ha )
-		{
-			FIXME("Expected registry to be sorted\n");
-		}
-		/* last_ha == ha */
-		else if( last_chan < chan )
-		{
-			last_chan = chan;
-			SCSI_PutRegControllerMap( hkeyControllerMap, num_controller, ha, chan);
-			num_controller++;
-		}
-		else if( last_chan > chan )
-		{
-			FIXME("Expected registry to be sorted\n");
-		}
-		/* else last_ha == ha && last_chan == chan so do nothing */
-	}
-	/* Set (default) value to number of controllers */
-	if( RegSetValueExA(hkeyControllerMap, NULL, 0, REG_DWORD, (LPBYTE)&num_controller, sizeof(DWORD) ) != ERROR_SUCCESS )
-	{
-		ERR("Could not set value HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
-	}
-	RegCloseKey(hkeyControllerMap);
-	RegCloseKey(hkeyScsi);
-	return;
-}
-#endif
-
-int SCSI_Linux_CheckDevices(void)
-{
-    DIR *devdir;
-    struct dirent *dent = NULL;
-
-    devdir = opendir("/dev");
-    for (dent=readdir(devdir);dent;dent=readdir(devdir))
-    {
-        if (!(strncmp(dent->d_name, "sg", 2)))
-            break;
+    if (ha>=buses) {
+	LeaveCriticalSection(&ASPI_CritSection);
+	return SS_INVALID_HA;
     }
-    closedir(devdir);
-
-    if (dent == NULL)
-    {
-	TRACE("WARNING: You don't have any /dev/sgX generic scsi devices ! \"man MAKEDEV\" !\n");
-	return 0;
+    if (scg_settarget(scgp_,ha,ta,lu)<0) {
+	LeaveCriticalSection(&ASPI_CritSection);
+	return SS_NO_DEVICE;
     }
-    return 1;
-}
-
-static void
-SCSI_GetProcinfo()
-/* I'll admit, this function is somewhat of a mess... it was originally
- * designed to make some sort of linked list then I realized that
- * HKEY_DYN_DATA would be a lot less messy
- */
-{
-#ifdef linux
-	static const char procname[] = "/proc/scsi/scsi";
-	FILE * procfile = NULL;
-
-	char read_line[40], read1[10] = "\0", read2[10] = "\0";
-	int result = 0;
-
-	struct LinuxProcScsiDevice dev;
-
-	char idstr[20];
-	char devstr[20];
-
-	int devnum=0;
-	int num_ha = 0;
-
-	HKEY hkeyScsi;
-	DWORD disposition;
-
-	/* Check whether user has generic scsi devices at all */
-	if (!(SCSI_Linux_CheckDevices()))
-	    return;
-
-	procfile = fopen( procname, "r" );
-	if( !procfile )
-	{
-		ERR("Could not open %s\n", procname);
-		return;
-	}
-
-	fgets(read_line, 40, procfile);
-	sscanf( read_line, "Attached %9s %9s", read1, read2);
-
-	if(strcmp(read1, "devices:"))
-	{
-		ERR("Incorrect %s format\n", procname);
-		return;
-	}
-
-	if(!(strcmp(read2, "none")))
-	{
-		ERR("No devices found in %s. Make sure you loaded your SCSI driver or set up ide-scsi emulation for your IDE device if this app needs it !\n", procname);
-		return;
-	}
-
-	if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS )
-	{
-		ERR("Could not create HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-		return;
+    
+    memset(scmd, 0, sizeof(*scmd));
+    memset(senseArea,0,senseLen);
+				    
+    memcpy(scmd->cdb.cmd_cdb, cmd, cmdLen);
+    scmd->cdb_len = cmdLen;
+					    
+    scmd->addr = data;
+    scmd->size = *dataLen;
+    if (flags & SRB_DIR_IN) scmd->flags = SCG_RECV_DATA;
+															   
+    scmd->flags |= SCG_DISRE_ENA;
+//	scmd->timeout = timeout;
+    scmd->sense_len = CCS_SENSE_LEN;
+    scgp_->cmdname = " ";
+    scgp_->verbose = 0;
+    scgp_->silent = 1;
+	
+    retval=SS_COMP;
+    if ((scg_cmd(scgp_)) < 0) {
+	retval=SS_ERR;
+	if (scmd->sense_count > 0) {
+    	    memcpy(senseArea,scmd->u_sense.cmd_sense,
+	        (scmd->sense_count>senseLen) ? senseLen : scmd->sense_count);
 	}
+    }
+    if (flags & SRB_ENABLE_RESIDUAL_COUNT) *dataLen=scg_getresid(scgp_);
+    LeaveCriticalSection(&ASPI_CritSection);
 
-	/* Read info for one device */
-	while( (result = SCSI_getprocentry(procfile, &dev)) > 0 )
-	{
-		/* Add to registry */
-
-		sprintf(idstr, "h%02dc%02dt%02dd%02d", dev.host, dev.channel, dev.target, dev.lun);
-		sprintf(devstr, "/dev/sg%c", 'a'+devnum);
-		if( RegSetValueExA(hkeyScsi, idstr, 0, REG_SZ, devstr, strlen(devstr)+1 ) != ERROR_SUCCESS )
-		{
-			ERR("Could not set value HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, idstr);
-		}
-
-		/* Debug output */
-		SCSI_printprocentry( &dev );
-
-		/* FIXME: We *REALLY* need number of controllers.. not ha */
-		/* num of hostadapters is highest ha + 1 */
-		if( dev.host >= num_ha )
-			num_ha = dev.host+1;
-		devnum++;
-	} /* while(1) */
-	if( result != EOF )
-	{
-		ERR("Sorry, incorrect %s format\n", procname);
-	}
-	fclose( procfile );
-	if( RegSetValueExA(hkeyScsi, NULL, 0, REG_DWORD, (LPBYTE)&num_ha, sizeof(num_ha) ) != ERROR_SUCCESS )
-	{
-		ERR("Could not set value HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
-	}
-	RegCloseKey(hkeyScsi);
-	return;
-#endif
+    *taStat=scmd->u_scb.cmd_scb[0];
+    return retval;    
+#else /* HAVE_SCG */
+    ERR("ASPI support not compiled in\n");
+    return SS_ERR;
+#endif /* HAVE_SCG */
 }
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/aspi.h dlls/winaspi/aspi.h
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/aspi.h	Sun Mar 10 00:44:32 2002
+++ dlls/winaspi/aspi.h	Tue Sep 17 23:46:06 2002
@@ -17,6 +17,13 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/*
+Modified to use libscg 
+(C) 2002 Gyorgy Szombathelyi <gyurco@freemail.hu>
+- removed registry support
+- libscg works on many platforms
+*/
+
 #ifndef __WINE_ASPI_H
 #define __WINE_ASPI_H
 
@@ -73,6 +80,23 @@
 
 #define SENSE_BUFFER(prb) (&prb->CDBByte[prb->SRB_CDBLen])
 
+void
+SCSI_Init();
+
+void
+SCSI_UnInit();
+
+int
+SCSI_GetNumControllers();
+
+int 
+SCSI_SendCmd(int ha,int ta,int lu, 
+    const char *cmd, int cmdLen,
+    char *data, int *dataLen, int flags,
+    char *senseArea, int senseLen,char *taStat);
+
+
+
 #ifdef __cplusplus
 }
 #endif /* #ifdef __cplusplus */
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winaspi16.c dlls/winaspi/winaspi16.c
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winaspi16.c	Thu Sep 19 00:30:03 2002
+++ dlls/winaspi/winaspi16.c	Tue Sep 17 23:46:33 2002
@@ -17,18 +17,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "config.h"
+/*
+Modified to use libscg 
+(C) 2002 Gyorgy Szombathelyi <gyurco@freemail.hu>
+- removed registry support
+- libscg works on many platforms
+*/
 
-#include <stdlib.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <memory.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <string.h>
-#include <stdio.h>
+#include "config.h"
 
 #include "winbase.h"
 #include "wine/windef16.h"
@@ -41,86 +37,12 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(aspi);
 
-
-/* FIXME!
- * 1) Residual byte length reporting not handled
- * 2) Make this code re-entrant for multithreading
- * 3) Only linux supported so far
- */
-
 /* ### start build ### */
 extern LONG CALLBACK ASPI_CallTo16_long_l(FARPROC16,SEGPTR);
 /* ### stop build ### */
 
-#ifdef linux
-
-static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;
-
 static FARPROC16 ASPIChainFunc = NULL;
-static WORD HA_Count = 1; /* host adapter count; FIXME: detect it */
-
-static int
-ASPI_OpenDevice16(SRB_ExecSCSICmd16 *prb)
-{
-    HKEY hkey;
-    int	fd;
-    char	idstr[50];
-    char	device_str[50];
-    ASPI_DEVICE_INFO *curr;
-
-    /* search list of devices to see if we've opened it already.
-     * There is not an explicit open/close in ASPI land, so hopefully
-     * keeping a device open won't be a problem.
-     */
-
-    for (curr = ASPI_open_devices; curr; curr = curr->next) {
-	if (curr->hostId == prb->SRB_HaId &&
-	    curr->target == prb->SRB_Target &&
-	    curr->lun == prb->SRB_Lun) {
-	    return curr->fd;
-	}
-    }
-
-    /* device wasn't cached, go ahead and open it */
-    sprintf( idstr, "Software\\Wine\\Wine\\Config\\scsi c%1dt%1dd%1d",
-             prb->SRB_HaId, prb->SRB_Target, prb->SRB_Lun);
-
-    device_str[0] = 0;
-    if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, idstr, 0, KEY_ALL_ACCESS, &hkey ))
-    {
-        DWORD type, count = sizeof(device_str);
-        if (RegQueryValueExA( hkey, "Device", 0, &type, device_str, &count )) device_str[0] = 0;
-        RegCloseKey( hkey );
-    }
-
-    if (!device_str[0])
-    {
-	TRACE("Trying to open unlisted scsi device %s\n", idstr);
-	return -1;
-    }
-
-    TRACE("Opening device %s=%s\n", idstr, device_str);
-
-    fd = open(device_str, O_RDWR);
-    if (fd == -1) {
-	int save_error = errno;
-	ERR("Error opening device %s, error '%s'\n", device_str, strerror(save_error));
-	return -1;
-    }
-
-    /* device is now open */
-    curr = HeapAlloc( GetProcessHeap(), 0, sizeof(ASPI_DEVICE_INFO) );
-    curr->fd = fd;
-    curr->hostId = prb->SRB_HaId;
-    curr->target = prb->SRB_Target;
-    curr->lun = prb->SRB_Lun;
-
-    /* insert new record at beginning of open device list */
-    curr->next = ASPI_open_devices;
-    ASPI_open_devices = curr;
-    return fd;
-}
-
+static int init=0;
 
 static void
 ASPI_DebugPrintCmd(SRB_ExecSCSICmd16 *prb, UINT16 mode)
@@ -244,177 +166,76 @@
 static WORD
 ASPI_ExecScsiCmd(DWORD ptrPRB, UINT16 mode)
 {
-  SRB_ExecSCSICmd16 *lpPRB = 0;
-  struct sg_header *sg_hd, *sg_reply_hdr;
-  int	status;
-  BYTE *lpBuf = 0;
-  int	in_len, out_len;
-  int	error_code = 0;
-  int	fd;
-
-  switch (mode)
-  {
-      case ASPI_DOS:
-	if (ptrPRB)
-	    lpPRB = PTR_REAL_TO_LIN( SELECTOROF(ptrPRB), OFFSETOF(ptrPRB));
-	break;
-      case ASPI_WIN16:
-	lpPRB = MapSL(ptrPRB);
-	break;
-  }
+    DWORD SRB_Status;
+    SRB_ExecSCSICmd16 *lpPRB = 0;
+    BYTE *lpBuf = 0;
 
-  ASPI_DebugPrintCmd(lpPRB, mode);
-
-  fd = ASPI_OpenDevice16(lpPRB);
-  if (fd == -1) {
-      WARN("Failed: could not open device. Device permissions !?\n");
-      lpPRB->SRB_Status = SS_ERR;
-      return SS_ERR;
-  }
+    switch (mode)
+    {
+	case ASPI_DOS:
+	    if (ptrPRB) {
+		lpPRB = PTR_REAL_TO_LIN( SELECTOROF(ptrPRB), OFFSETOF(ptrPRB));
+		lpBuf = PTR_REAL_TO_LIN( SELECTOROF(lpPRB->SRB_BufPointer),
+            	    OFFSETOF(lpPRB->SRB_BufPointer));
+	    }
+	    break;
+	case ASPI_WIN16:
+	    lpPRB = MapSL(ptrPRB);
+	    lpBuf = MapSL(lpPRB->SRB_BufPointer);
+	    break;
+    }
 
-  sg_hd = NULL;
-  sg_reply_hdr = NULL;
+    ASPI_DebugPrintCmd(lpPRB, mode);
 
-  lpPRB->SRB_Status = SS_PENDING;
+    lpPRB->SRB_Status = SS_PENDING;
 
-  switch (mode)
-  {
-      case ASPI_DOS:
-	/* translate real mode address */
-	if (ptrPRB)
-	    lpBuf = PTR_REAL_TO_LIN( SELECTOROF(lpPRB->SRB_BufPointer),
-                                     OFFSETOF(lpPRB->SRB_BufPointer));
-	break;
-      case ASPI_WIN16:
-	lpBuf = MapSL(lpPRB->SRB_BufPointer);
-	break;
-  }
-
-  if (!lpPRB->SRB_CDBLen) {
-      WARN("Failed: lpPRB->SRB_CDBLen = 0.\n");
-      lpPRB->SRB_Status = SS_ERR;
-      return SS_ERR;
-  }
-
-  /* build up sg_header + scsi cmd */
-  if (HOST_TO_TARGET(lpPRB)) {
-    /* send header, command, and then data */
-    in_len = SCSI_OFF + lpPRB->SRB_CDBLen + lpPRB->SRB_BufLen;
-    sg_hd = (struct sg_header *) malloc(in_len);
-    memset(sg_hd, 0, SCSI_OFF);
-    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
-    if (lpPRB->SRB_BufLen) {
-      memcpy(((BYTE *) sg_hd) + SCSI_OFF + lpPRB->SRB_CDBLen, lpBuf, lpPRB->SRB_BufLen);
+    if (!lpPRB->SRB_CDBLen) {
+	ERR("Failed: lpPRB->SRB_CDBLen = 0.\n");
+	return SS_INVALID_SRB;
     }
-  }
-  else {
-    /* send header and command - no data */
-    in_len = SCSI_OFF + lpPRB->SRB_CDBLen;
-    sg_hd = (struct sg_header *) malloc(in_len);
-    memset(sg_hd, 0, SCSI_OFF);
-    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
-  }
-
-  if (TARGET_TO_HOST(lpPRB)) {
-    out_len = SCSI_OFF + lpPRB->SRB_BufLen;
-    sg_reply_hdr = (struct sg_header *) malloc(out_len);
-    memset(sg_reply_hdr, 0, SCSI_OFF);
-    sg_hd->reply_len = out_len;
-  }
-  else {
-    out_len = SCSI_OFF;
-    sg_reply_hdr = (struct sg_header *) malloc(out_len);
-    memset(sg_reply_hdr, 0, SCSI_OFF);
-    sg_hd->reply_len = out_len;
-  }
 
-  status = write(fd, sg_hd, in_len);
-  if (status < 0 || status != in_len) {
-      int save_error = errno;
-
-    WARN("Not enough bytes written to scsi device bytes=%d .. %d\n", in_len, status);
-    if (status < 0) {
-		if (save_error == ENOMEM) {
-	    MESSAGE("ASPI: Linux generic scsi driver\n  You probably need to re-compile your kernel with a larger SG_BIG_BUFF value (sg.h)\n  Suggest 130560\n");
+    SRB_Status = SCSI_SendCmd(lpPRB->SRB_HaId, lpPRB->SRB_Target, lpPRB->SRB_Lun,
+	    (char*) &lpPRB->CDBByte, lpPRB->SRB_CDBLen,
+	    (char*) lpPRB->SRB_BufPointer, &lpPRB->SRB_BufLen, lpPRB->SRB_Flags,
+	    SENSE_BUFFER(lpPRB), lpPRB->SRB_SenseLen, &lpPRB->SRB_TargStat);
+
+    lpPRB->SRB_HaStat = HASTAT_OK;
+    ASPI_PrintSenseArea16(lpPRB);
+
+    if( lpPRB->SRB_TargStat == STATUS_CHKCOND ) {
+	switch (lpPRB->CDBByte[0]) {
+	case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
+	case 0xa3: /* SEND KEY (DVD) MMC-2 */
+	    SRB_Status = SS_COMP;
+	    lpPRB->SRB_TargStat = STATUS_GOOD;
+	    FIXME("Program wants to do DVD Region switching, but fails (non compliant DVD drive). Ignoring....\n");
+	    break;
 	}
-		WARN("error:= '%s'\n", strerror(save_error));
     }
-    goto error_exit;
-  }
-
-  status = read(fd, sg_reply_hdr, out_len);
-  if (status < 0 || status != out_len) {
-    WARN("not enough bytes read from scsi device%d\n", status);
-    goto error_exit;
-  }
-
-  if (sg_reply_hdr->result != 0) {
-    error_code = sg_reply_hdr->result;
-    WARN("reply header error (%d)\n", sg_reply_hdr->result);
-    goto error_exit;
-  }
-
-  if (TARGET_TO_HOST(lpPRB) && lpPRB->SRB_BufLen) {
-    memcpy(lpBuf, sg_reply_hdr + 1, lpPRB->SRB_BufLen);
-  }
-
-  /* copy in sense buffer to amount that is available in client */
-  if (lpPRB->SRB_SenseLen) {
-    int sense_len = lpPRB->SRB_SenseLen;
-    if (lpPRB->SRB_SenseLen > 16)
-      sense_len = 16;
-    memcpy(SENSE_BUFFER(lpPRB), &sg_reply_hdr->sense_buffer[0], sense_len);
-  }
-
-
-  lpPRB->SRB_Status = SS_COMP;
-  lpPRB->SRB_HaStat = HASTAT_OK;
-  lpPRB->SRB_TargStat = STATUS_GOOD;
 
   /* now do posting */
 
-  if (ASPI_POSTING(lpPRB) && lpPRB->SRB_PostProc) {
-    TRACE("Post Routine (%lx) called\n", (DWORD) lpPRB->SRB_PostProc);
-    switch (mode)
-    {
-      case ASPI_DOS:
-      {
-	SEGPTR spPRB = MapLS(lpPRB);
+    if (ASPI_POSTING(lpPRB) && lpPRB->SRB_PostProc) {
+	TRACE("Post Routine (%lx) called\n", (DWORD) lpPRB->SRB_PostProc);
+	switch (mode)
+	{
+	case ASPI_DOS:
+	    {
+	    SEGPTR spPRB = MapLS(lpPRB);
 
-	ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, spPRB);
-	UnMapLS(spPRB);
-	break;
-      }
-      case ASPI_WIN16:
-        ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, ptrPRB);
-	break;
+	    ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, spPRB);
+	    UnMapLS(spPRB);
+	    break;
+	    }
+	case ASPI_WIN16:
+    	    ASPI_CallTo16_long_l(lpPRB->SRB_PostProc, ptrPRB);
+	    break;
+	}
     }
-  }
-
-  free(sg_reply_hdr);
-  free(sg_hd);
-  ASPI_DebugPrintResult(lpPRB, mode);
-  return SS_COMP;
-
-error_exit:
-  if (error_code == EBUSY) {
-      lpPRB->SRB_Status = SS_ASPI_IS_BUSY;
-      TRACE("Device busy\n");
-  }
-  else {
-      WARN("Failed\n");
-      lpPRB->SRB_Status = SS_ERR;
-  }
 
-  /* I'm not sure exactly error codes work here
-   * We probably should set lpPRB->SRB_TargStat, SRB_HaStat ?
-   */
-  WARN("error_exit\n");
-  free(sg_reply_hdr);
-  free(sg_hd);
-  return lpPRB->SRB_Status;
+    ASPI_DebugPrintResult(lpPRB, mode);
+    return SRB_Status;
 }
-#endif
 
 
 /***********************************************************************
@@ -423,21 +244,24 @@
 
 WORD WINAPI GetASPISupportInfo16(void)
 {
-#ifdef linux
+    if (!init) {
+	SCSI_Init();
+	init=1;
+    }
     TRACE("GETASPISupportInfo16\n");
     /* high byte SS_COMP - low byte number of host adapters */
-    return ((SS_COMP << 8) | HA_Count);
-#else
-    return ((SS_NO_ASPI << 8) | 0);
-#endif
+    return ((SS_COMP << 8) | SCSI_GetNumControllers());
 }
 
 
 DWORD ASPI_SendASPICommand(DWORD ptrSRB, UINT16 mode)
 {
-#ifdef linux
   LPSRB16 lpSRB = 0;
 
+    if (!init) {
+	SCSI_Init();
+	init=1;
+    }
   switch (mode)
   {
       case ASPI_DOS:
@@ -466,7 +290,7 @@
 	TRACE("Extended request detected (Adaptec's ASPIxDOS).\nWe don't support it at the moment.\n");
     }
     lpSRB->inquiry.SRB_ExtBufferSize = 0x2000; /* bogus value */
-    lpSRB->inquiry.HA_Count = HA_Count;
+    lpSRB->inquiry.HA_Count = SCSI_GetNumControllers();
     lpSRB->inquiry.HA_SCSI_ID = 7;             /* not always ID 7 */
     strcat(lpSRB->inquiry.HA_ManagerId, "Wine ASPI16"); /* max 15 chars */
     strcat(lpSRB->inquiry.HA_Identifier, "Wine host"); /* FIXME: return host
@@ -487,7 +311,6 @@
   default:
     FIXME("Unknown command %d\n", lpSRB->common.SRB_Cmd);
   }
-#endif
   return SS_INVALID_SRB;
 }
 
@@ -497,11 +320,7 @@
  */
 WORD WINAPI SendASPICommand16(SEGPTR segptr_srb)
 {
-#ifdef linux
     return ASPI_SendASPICommand(segptr_srb, ASPI_WIN16);
-#else
-    return 0;
-#endif
 }
 
 
@@ -510,7 +329,6 @@
  */
 WORD WINAPI InsertInASPIChain16(BOOL16 remove, FARPROC16 pASPIChainFunc)
 {
-#ifdef linux
     if (remove == TRUE) /* Remove */
     {
 	if (ASPIChainFunc == pASPIChainFunc)
@@ -528,7 +346,6 @@
 	    return SS_COMP;
 	}
     }
-#endif
     return SS_ERR;
 }
 
@@ -539,10 +356,5 @@
 
 DWORD WINAPI GetASPIDLLVersion16()
 {
-#ifdef linux
 	return 2;
-#else
-	return 0;
-#endif
 }
-
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winaspi32.c dlls/winaspi/winaspi32.c
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winaspi32.c	Thu Sep 19 00:30:03 2002
+++ dlls/winaspi/winaspi32.c	Tue Sep 17 23:47:29 2002
@@ -17,18 +17,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/*
+Modified to use libscg 
+(C) 2002 Gyorgy Szombathelyi <gyurco@freemail.hu>
+- removed registry support
+- libscg works on many platforms
+*/
+
 #include "config.h"
 
 #include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <memory.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
 
 #include "winbase.h"
 #include "aspi.h"
@@ -39,96 +37,26 @@
 WINE_DEFAULT_DEBUG_CHANNEL(aspi);
 
 /* FIXME!
- * 1) Residual byte length reporting not handled
- * 2) Make this code re-entrant for multithreading
- *    -- Added CriticalSection to OpenDevices function
- * 3) Only linux supported so far
- * 4) Leaves sg devices open. This may or may not be okay.  A better solution
- *    would be to close the file descriptors when the thread/process using
- *    them no longer needs them.
+ * 1) Improve the asynchronous calls by the use of a worker thread?
  */
 
-#ifdef linux
-
-static ASPI_DEVICE_INFO *ASPI_open_devices = NULL;
-static CRITICAL_SECTION ASPI_CritSection = CRITICAL_SECTION_INIT("ASPI_CritSection");
-
-#endif /* defined(linux) */
-
-
 BOOL WINAPI WNASPI32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
 {
-#ifdef linux
 	switch( fdwReason )
 	{
 	case DLL_PROCESS_ATTACH:
             SCSI_Init();
             break;
 	case DLL_PROCESS_DETACH:
-            DeleteCriticalSection( &ASPI_CritSection );
+	    SCSI_UnInit();
             break;
 	case DLL_THREAD_ATTACH:
 	case DLL_THREAD_DETACH:
-		break;
+	    break;
 	}
-#endif /* defined(linux) */
 	return TRUE;
 }
 
-
-#ifdef linux
-
-static int
-ASPI_OpenDevice(SRB_ExecSCSICmd *prb)
-{
-    int	fd;
-    DWORD	hc;
-    ASPI_DEVICE_INFO *curr;
-
-    /* search list of devices to see if we've opened it already.
-     * There is not an explicit open/close in ASPI land, so hopefully
-     * keeping a device open won't be a problem.
-     */
-
-    EnterCriticalSection(&ASPI_CritSection);
-    for (curr = ASPI_open_devices; curr; curr = curr->next) {
-	if (curr->hostId == prb->SRB_HaId &&
-	    curr->target == prb->SRB_Target &&
-	    curr->lun == prb->SRB_Lun) {
-            LeaveCriticalSection(&ASPI_CritSection);
-	    return curr->fd;
-	}
-    }
-    LeaveCriticalSection(&ASPI_CritSection);
-
-    if (prb->SRB_HaId > ASPI_GetNumControllers())
-	return -1;
-
-    hc = ASPI_GetHCforController( prb->SRB_HaId );
-    fd = SCSI_OpenDevice( HIWORD(hc), LOWORD(hc), prb->SRB_Target, prb->SRB_Lun);
-
-    if (fd == -1)
-	return -1;
-
-    /* device is now open */
-    /* FIXME: Let users specify SCSI timeout in registry */
-    SCSI_LinuxSetTimeout( fd, SCSI_DEFAULT_TIMEOUT );
-
-    curr = HeapAlloc( GetProcessHeap(), 0, sizeof(ASPI_DEVICE_INFO) );
-    curr->fd = fd;
-    curr->hostId = prb->SRB_HaId;
-    curr->target = prb->SRB_Target;
-    curr->lun = prb->SRB_Lun;
-
-    /* insert new record at beginning of open device list */
-    EnterCriticalSection(&ASPI_CritSection);
-    curr->next = ASPI_open_devices;
-    ASPI_open_devices = curr;
-    LeaveCriticalSection(&ASPI_CritSection);
-    return fd;
-}
-
-
 static void
 ASPI_DebugPrintCmd(SRB_ExecSCSICmd *prb)
 {
@@ -244,17 +172,17 @@
 ASPI_DebugPrintResult(SRB_ExecSCSICmd *prb)
 {
 
-  TRACE("SRB_Status: %x\n", prb->SRB_Status);
-  TRACE("SRB_HaStat: %x\n", prb->SRB_HaStat);
-  TRACE("SRB_TargStat: %x\n", prb->SRB_TargStat);
-  switch (prb->CDBByte[0]) {
-  case CMD_INQUIRY:
-    TRACE("Vendor: '%s'\n", prb->SRB_BufPointer + INQUIRY_VENDOR);
-    break;
-  case CMD_TEST_UNIT_READY:
-    ASPI_PrintSenseArea(prb);
-    break;
-  }
+    TRACE("SRB_Status: %x\n", prb->SRB_Status);
+    TRACE("SRB_HaStat: %x\n", prb->SRB_HaStat);
+    TRACE("SRB_TargStat: %x\n", prb->SRB_TargStat);
+    switch (prb->CDBByte[0]) {
+    case CMD_INQUIRY:
+	TRACE("Vendor: '%s'\n", prb->SRB_BufPointer + INQUIRY_VENDOR);
+	break;
+    case CMD_TEST_UNIT_READY:
+	ASPI_PrintSenseArea(prb);
+	break;
+    }
 }
 
 /* Posting must be done in such a way that as soon as the SRB_Status is set
@@ -296,13 +224,8 @@
 static WORD
 ASPI_ExecScsiCmd(SRB_ExecSCSICmd *lpPRB)
 {
-  struct sg_header *sg_hd, *sg_reply_hdr;
-  WORD ret;
-  DWORD	status;
-  int	in_len, out_len;
-  int	error_code = 0;
-  int	fd;
-  DWORD SRB_Status;
+    WORD ret;
+    DWORD SRB_Status;
 
   /* FIXME: hackmode */
 #define MAKE_TARGET_TO_HOST(lpPRB) \
@@ -315,17 +238,17 @@
 	    WARN("program was not sending host_to_target for cmd %x (flags=%x),correcting.\n",lpPRB->CDBByte[0],lpPRB->SRB_Flags); \
 	    lpPRB->SRB_Flags |= 0x10; \
 	}
-  switch (lpPRB->CDBByte[0]) {
-  case 0x12: /* INQUIRY */
-  case 0x5a: /* MODE_SENSE_10 */
-  case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
-  case 0xad: /* READ DVD STRUCTURE MMC-2 */
-        MAKE_TARGET_TO_HOST(lpPRB)
+    switch (lpPRB->CDBByte[0]) {
+    case 0x12: /* INQUIRY */
+    case 0x5a: /* MODE_SENSE_10 */
+    case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
+    case 0xad: /* READ DVD STRUCTURE MMC-2 */
+	MAKE_TARGET_TO_HOST(lpPRB)
 	break;
-  case 0xa3: /* SEND KEY (DVD) MMC-2 */
+    case 0xa3: /* SEND KEY (DVD) MMC-2 */
         MAKE_HOST_TO_TARGET(lpPRB)
 	break;
-  default:
+    default:
 	if ((((lpPRB->SRB_Flags & 0x18) == 0x00) ||
 	     ((lpPRB->SRB_Flags & 0x18) == 0x18)
 	    ) && lpPRB->SRB_BufLen
@@ -333,152 +256,55 @@
 	    FIXME("command 0x%02x, no data transfer specified, but buflen is %ld!!!\n",lpPRB->CDBByte[0],lpPRB->SRB_BufLen);
 	}
 	break;
-  }
-  ASPI_DebugPrintCmd(lpPRB);
-  if (lpPRB->SRB_HaId > ASPI_GetNumControllers()) {
-      ERR("Failed: Wanted hostadapter %d, but we have only %d.\n",
-	  lpPRB->SRB_HaId,ASPI_GetNumControllers()
-      );
-      return WNASPI32_DoPosting( lpPRB, SS_INVALID_HA );
-  }
-  fd = ASPI_OpenDevice(lpPRB);
-  if (fd == -1) {
-      return WNASPI32_DoPosting( lpPRB, SS_NO_DEVICE );
-  }
-
-  sg_hd = NULL;
-  sg_reply_hdr = NULL;
-
-  lpPRB->SRB_Status = SS_PENDING;
-
-  if (!lpPRB->SRB_CDBLen) {
-      ERR("Failed: lpPRB->SRB_CDBLen = 0.\n");
-      return WNASPI32_DoPosting( lpPRB, SS_INVALID_SRB );
-  }
-
-  /* build up sg_header + scsi cmd */
-  if (HOST_TO_TARGET(lpPRB)) {
-    /* send header, command, and then data */
-    in_len = SCSI_OFF + lpPRB->SRB_CDBLen + lpPRB->SRB_BufLen;
-    sg_hd = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, in_len);
-    memset(sg_hd, 0, SCSI_OFF);
-    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
-    if (lpPRB->SRB_BufLen) {
-      memcpy(((BYTE *) sg_hd) + SCSI_OFF + lpPRB->SRB_CDBLen, lpPRB->SRB_BufPointer, lpPRB->SRB_BufLen);
     }
-  }
-  else {
-    /* send header and command - no data */
-    in_len = SCSI_OFF + lpPRB->SRB_CDBLen;
-    sg_hd = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, in_len);
-    memset(sg_hd, 0, SCSI_OFF);
-    memcpy(sg_hd + 1, &lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
-  }
+    ASPI_DebugPrintCmd(lpPRB);
 
-  if (TARGET_TO_HOST(lpPRB)) {
-    out_len = SCSI_OFF + lpPRB->SRB_BufLen;
-    sg_reply_hdr = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, out_len);
-    memset(sg_reply_hdr, 0, SCSI_OFF);
-    sg_hd->reply_len = out_len;
-  }
-  else {
-    out_len = SCSI_OFF;
-    sg_reply_hdr = (struct sg_header *) HeapAlloc(GetProcessHeap(), 0, out_len);
-    memset(sg_reply_hdr, 0, SCSI_OFF);
-    sg_hd->reply_len = out_len;
-  }
-
-  SCSI_Fix_CMD_LEN(fd, lpPRB->CDBByte[0], lpPRB->SRB_CDBLen);
-
-  if(!SCSI_LinuxDeviceIo( fd,
-			  sg_hd, in_len,
-			  sg_reply_hdr, out_len,
-			  &status) )
-  {
-    goto error_exit;
-  }
-
-  if (sg_reply_hdr->result != 0) {
-    error_code = sg_reply_hdr->result;
-    WARN("reply header error (%d)\n", sg_reply_hdr->result);
-    goto error_exit;
-  }
-
-  if (TARGET_TO_HOST(lpPRB) && lpPRB->SRB_BufLen) {
-    memcpy(lpPRB->SRB_BufPointer, sg_reply_hdr + 1, lpPRB->SRB_BufLen);
-  }
+    lpPRB->SRB_Status = SS_PENDING;
 
-  /* copy in sense buffer to amount that is available in client */
-  if (lpPRB->SRB_SenseLen) {
-    int sense_len = lpPRB->SRB_SenseLen;
-    if (lpPRB->SRB_SenseLen > 16)
-      sense_len = 16;
+    if (!lpPRB->SRB_CDBLen) {
+	ERR("Failed: lpPRB->SRB_CDBLen = 0.\n");
+	return WNASPI32_DoPosting( lpPRB, SS_INVALID_SRB );
+    }
 
-    /* CDB is fixed in WNASPI32 */
-    memcpy(lpPRB->SenseArea, &sg_reply_hdr->sense_buffer[0], sense_len);
+    SRB_Status = SCSI_SendCmd(lpPRB->SRB_HaId, lpPRB->SRB_Target, lpPRB->SRB_Lun,
+	    (char*) &lpPRB->CDBByte, lpPRB->SRB_CDBLen,
+	    (char*) lpPRB->SRB_BufPointer, &lpPRB->SRB_BufLen, lpPRB->SRB_Flags,
+	    (char*) &lpPRB->SenseArea, lpPRB->SRB_SenseLen, &lpPRB->SRB_TargStat);
 
+    lpPRB->SRB_HaStat = HASTAT_OK;
     ASPI_PrintCDBArea(lpPRB);
     ASPI_PrintSenseArea(lpPRB);
-  }
 
-  SRB_Status = SS_COMP;
-  lpPRB->SRB_HaStat = HASTAT_OK;
-  lpPRB->SRB_TargStat = sg_reply_hdr->target_status << 1;
-
-  HeapFree(GetProcessHeap(), 0, sg_reply_hdr);
-  HeapFree(GetProcessHeap(), 0, sg_hd);
-
-  /* FIXME: Should this be != 0 maybe? */
-  if( lpPRB->SRB_TargStat == 2 ) {
-    SRB_Status = SS_ERR;
-    switch (lpPRB->CDBByte[0]) {
-    case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
-    case 0xa3: /* SEND KEY (DVD) MMC-2 */
-          SRB_Status = SS_COMP;
-	  lpPRB->SRB_TargStat = 0;
-	  FIXME("Program wants to do DVD Region switching, but fails (non compliant DVD drive). Ignoring....\n");
-	  break;
+    if( lpPRB->SRB_TargStat == STATUS_CHKCOND ) {
+	switch (lpPRB->CDBByte[0]) {
+	case 0xa4: /* REPORT_KEY (DVD) MMC-2 */
+	case 0xa3: /* SEND KEY (DVD) MMC-2 */
+	    SRB_Status = SS_COMP;
+	    lpPRB->SRB_TargStat = STATUS_GOOD;
+	    FIXME("Program wants to do DVD Region switching, but fails (non compliant DVD drive). Ignoring....\n");
+	    break;
+	}
     }
-  }
 
-  ASPI_DebugPrintResult(lpPRB);
-  /* now do posting */
-  ret = WNASPI32_DoPosting( lpPRB, SRB_Status );
+    ASPI_DebugPrintResult(lpPRB);
+    /* now do posting */
+    ret = WNASPI32_DoPosting( lpPRB, SRB_Status );
 
-  switch (lpPRB->CDBByte[0]) {
-  case CMD_INQUIRY:
-      if (SRB_Status == SS_COMP)
-	  return SS_COMP; /* some junk expects ss_comp here. */
-      /*FALLTHROUGH*/
-  default:
-      break;
-  }
+    switch (lpPRB->CDBByte[0]) {
+    case CMD_INQUIRY:
+	if (SRB_Status == SS_COMP)
+	    return SS_COMP; /* some junk expects ss_comp here. */
+	/*FALLTHROUGH*/
+    default:
+	break;
+    }
 
   /* In real WNASPI32 stuff really is always pending because ASPI does things
      in the background, but we are not doing that (yet) */
 
-  return ret;
-
-error_exit:
-  SRB_Status = SS_ERR;
-  if (error_code == EBUSY) {
-      WNASPI32_DoPosting( lpPRB, SS_ASPI_IS_BUSY );
-      TRACE("Device busy\n");
-  } else
-      FIXME("Failed\n");
-
-  /* I'm not sure exactly error codes work here
-   * We probably should set lpPRB->SRB_TargStat, SRB_HaStat ?
-   */
-  WARN("error_exit\n");
-  HeapFree(GetProcessHeap(), 0, sg_reply_hdr);
-  HeapFree(GetProcessHeap(), 0, sg_hd);
-  WNASPI32_DoPosting( lpPRB, SRB_Status );
-  return SS_PENDING;
+    return ret;
 }
 
-#endif /* defined(linux) */
-
 
 /*******************************************************************
  *     GetASPI32SupportInfo		[WNASPI32.1]
@@ -492,7 +318,7 @@
  */
 DWORD __cdecl GetASPI32SupportInfo(void)
 {
-    DWORD controllers = ASPI_GetNumControllers();
+    DWORD controllers = SCSI_GetNumControllers();
 
     if (!controllers)
 	return SS_NO_ADAPTERS << 8;
@@ -504,23 +330,25 @@
  */
 DWORD __cdecl SendASPI32Command(LPSRB lpSRB)
 {
-#ifdef linux
   switch (lpSRB->common.SRB_Cmd) {
   case SC_HA_INQUIRY:
+    if (lpSRB->inquiry.SRB_HaId >= SCSI_GetNumControllers()) {
+	lpSRB->inquiry.SRB_Status = SS_INVALID_HA;
+	return SS_INVALID_HA;
+    }
     lpSRB->inquiry.SRB_Status = SS_COMP;       /* completed successfully */
-    lpSRB->inquiry.HA_Count = ASPI_GetNumControllers();
+    lpSRB->inquiry.HA_Count = SCSI_GetNumControllers();
     lpSRB->inquiry.HA_SCSI_ID = 7;             /* not always ID 7 */
-    strcpy(lpSRB->inquiry.HA_ManagerId, "ASPI for WIN32"); /* max 15 chars, don't change */
-    strcpy(lpSRB->inquiry.HA_Identifier, "Wine host"); /* FIXME: return host adapter name */
+    memcpy(lpSRB->inquiry.HA_ManagerId, "ASPI for WIN32  ", 16);
+    memcpy(lpSRB->inquiry.HA_Identifier, "Wine host       ",16); /* FIXME: return host adapter name */
     memset(lpSRB->inquiry.HA_Unique, 0, 16); /* default HA_Unique content */
     lpSRB->inquiry.HA_Unique[6] = 0x02; /* Maximum Transfer Length (128K, Byte> 4-7) */
     lpSRB->inquiry.HA_Unique[3] = 0x08; /* Maximum number of SCSI targets */
+    lpSRB->inquiry.HA_Unique[2] = 0x01; /* libscg supports residual byte count */
     FIXME("ASPI: Partially implemented SC_HA_INQUIRY for adapter %d.\n", lpSRB->inquiry.SRB_HaId);
     return SS_COMP;
 
   case SC_GET_DEV_TYPE: {
-    /* FIXME: We should return SS_NO_DEVICE if the device is not configured */
-    /* FIXME: We should return SS_INVALID_HA if HostAdapter!=0 */
     SRB		tmpsrb;
     char	inqbuf[200];
     DWORD	ret;
@@ -530,14 +358,13 @@
     /* Copy header */
     memcpy(&tmpsrb.common,&(lpSRB->common),sizeof(tmpsrb.common));
 
-    tmpsrb.cmd.SRB_Flags	|= 8; /* target to host */
+    tmpsrb.cmd.SRB_Flags	|= SRB_DIR_IN; /* target to host */
     tmpsrb.cmd.SRB_Cmd 		= SC_EXEC_SCSI_CMD;
     tmpsrb.cmd.SRB_Target	= lpSRB->devtype.SRB_Target;
     tmpsrb.cmd.SRB_Lun		= lpSRB->devtype.SRB_Lun;
     tmpsrb.cmd.SRB_BufLen	= sizeof(inqbuf);
     tmpsrb.cmd.SRB_BufPointer	= inqbuf;
     tmpsrb.cmd.CDBByte[0]	= 0x12; /* INQUIRY  */
-    				  /* FIXME: handle lun */
     tmpsrb.cmd.CDBByte[4]	= sizeof(inqbuf);
     tmpsrb.cmd.SRB_CDBLen	= 6;
 
@@ -571,9 +398,6 @@
     FIXME("Unknown command %d\n", lpSRB->common.SRB_Cmd);
   }
   return SS_INVALID_SRB;
-#else
-  return SS_INVALID_SRB;
-#endif
 }
 
 
@@ -582,13 +406,8 @@
  */
 DWORD __cdecl GetASPI32DLLVersion(void)
 {
-#ifdef linux
 	TRACE("Returning version 1\n");
         return (DWORD)1;
-#else
-	FIXME("Please add SCSI support for your operating system, returning 0\n");
-        return (DWORD)0;
-#endif
 }
 
 /***********************************************************************
diff -u /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winescsi.h dlls/winaspi/winescsi.h
--- /home/gyuri/rpms/BUILD/wine-20020710/dlls/winaspi/winescsi.h	Sat Jun  1 01:40:54 2002
+++ dlls/winaspi/winescsi.h	Tue Sep 17 23:49:42 2002
@@ -16,83 +16,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/*
+Modified to use libscg 
+(C) 2002 Gyorgy Szombathelyi <gyurco@freemail.hu>
+- removed registry support
+- libscg works on many platforms
+*/
+
 #ifndef __WINESCSI_H__
 #define __WINESCSI_H__
 
-#ifdef linux
-/* Copy of info from 2.2.x kernel */
-#define SG_MAX_SENSE 16   /* too little, unlikely to change in 2.2.x */
-
-#define SG_NEXT_CMD_LEN 0x2283  /* override SCSI command length with given
-		   number on the next write() on this file descriptor */
-
-/* This is what the linux kernel thinks.... */
-static const unsigned char scsi_command_size[8] =
-{
-	6, 10, 10, 12,
-	12, 12, 10, 10
-};
-
-struct sg_header
-{
-    int pack_len;    /* [o] reply_len (ie useless), ignored as input */
-    int reply_len;   /* [i] max length of expected reply (inc. sg_header) */
-    int pack_id;     /* [io] id number of packet (use ints >= 0) */
-    int result;      /* [o] 0==ok, else (+ve) Unix errno (best ignored) */
-    unsigned int twelve_byte:1;
-        /* [i] Force 12 byte command length for group 6 & 7 commands  */
-    unsigned int target_status:5;   /* [o] scsi status from target */
-    unsigned int host_status:8;     /* [o] host status (see "DID" codes) */
-    unsigned int driver_status:8;   /* [o] driver status+suggestion */
-    unsigned int other_flags:10;    /* unused */
-    unsigned char sense_buffer[SG_MAX_SENSE]; /* [o] Output in 3 cases:
-           when target_status is CHECK_CONDITION or
-           when target_status is COMMAND_TERMINATED or
-           when (driver_status & DRIVER_SENSE) is true. */
-};      /* This structure is 36 bytes long on i386 */
-
-#define SCSI_OFF sizeof(struct sg_header)
-
-#define SG_SET_TIMEOUT	0x2201
-#define SG_GET_TIMEOUT	0x2202
-#define SCSI_DEFAULT_TIMEOUT 6000*5 /* 5 minutes */
-#endif
-
-
-/* RegKey used for SCSI info under HKEY_DYN_DATA */
-#define KEYNAME_SCSI "WineScsi"
-#define KEYNAME_SCSI_CONTROLLERMAP "ControllerMap"
-
-/* Function prototypes from dlls/wnaspi32/aspi.c */
-void
-SCSI_Init();
-
-int
-ASPI_GetNumControllers();
-
-int
-SCSI_OpenDevice( int h, int c, int t, int d );
-
-int
-SCSI_LinuxSetTimeout( int fd, int timeout );
-
-#ifdef linux
-BOOL
-SCSI_LinuxDeviceIo( int fd,
-		struct sg_header * lpvInBuffer, DWORD cbInBuffer,
-		struct sg_header * lpvOutBuffer, DWORD cbOutBuffer,
-		LPDWORD lpcbBytesReturned );
-
-void
-SCSI_Fix_CMD_LEN( int fd, int cmd, int len );
-#endif
-
-BOOL
-SCSI_GetDeviceName(int h, int c, int t, int d, LPSTR devstr, LPDWORD lpcbData);
-
-DWORD
-ASPI_GetHCforController( int controller );
-
 /*** This is where we throw some miscellaneous crap ***/
 
 #define ASPI_POSTING(prb) (prb->SRB_Flags & 0x1)
@@ -119,17 +52,6 @@
 
 #define SENSE_BUFFER(prb) (&prb->CDBByte[prb->SRB_CDBLen])
 
-/* Just a container for seeing what devices are open */
-struct ASPI_DEVICE_INFO {
-    struct ASPI_DEVICE_INFO *   next;
-    int                         fd;
-    int                         hostId;
-    int                         target;
-    int                         lun;
-};
-
-typedef struct ASPI_DEVICE_INFO ASPI_DEVICE_INFO;
-
 /*** End Miscellaneous crap ***/
 
 #endif /* #ifndef __WINESCSI_H */
--- /home/gyuri/rpms/BUILD/wine-20020710/configure.ac	Thu Sep 19 00:30:02 2002
+++ configure.ac	Thu Sep 19 00:17:50 2002
@@ -434,6 +434,58 @@
 fi
 AC_SUBST(FREETYPEINCL)
 
+dnl *** Test for libscg, and define SCG_CPPFLAGS and SCG_LIBS ***
+dnl
+AC_ARG_WITH(scg,
+  AC_HELP_STRING([--with-scg=prefix],
+                 [Prefix where libscg is installed (optional)]),
+  scg_prefix="$withval", scg_prefix="")
+AC_ARG_WITH(scg-libraries,
+  AC_HELP_STRING([--with-scg-libraries=DIR],
+                 [Directory where libscg library is installed (optional)]),
+  scg_libraries="$withval", scg_libraries="")
+AC_ARG_WITH(scg-includes,
+  AC_HELP_STRING([--with-scg-includes=DIR],
+                 [Directory where libscg header files are installed (optional)]),
+  scg_includes="$withval", scg_includes="")
+
+ac_cppflags_save=$CPPFLAGS
+
+scg_include=""
+scg_lib_dir=""
+
+if test "x$scg_includes" != "x" ; then
+    scg_include="$scg_includes"
+elif test "x$scg_prefix" != "x" ; then
+    scg_include="$scg_prefix/include/schily"
+elif test "x$prefix" != "x" ; then
+    scg_include="$prefix/include/schily"
+fi
+
+CPPFLAGS="-I$scg_include $CPPFLAGS"
+AC_CHECK_HEADER(schily.h,
+		wine_enable_scg=yes,
+		wine_enable_scg=no)
+
+if test "$wine_enable_scg" = "yes" ; then
+
+    if test "x$scg_libraries" != "x" ; then
+	scg_lib_dir="$scg_libraries"
+    elif test "x$scg_prefix" != "x" ; then
+	scg_lib_dir="$scg_prefix/lib"
+    elif test "x$prefix" != "x" ; then
+	scg_lib_dir="$prefix/lib"
+    fi
+
+    AC_DEFINE(HAVE_SCG, 1, [Define if we have libscg])
+fi
+
+
+CPPFLAGS=$ac_cppflags_save
+
+AC_SUBST(SCG_CPPFLAGS,-I$scg_include)
+AC_SUBST(SCG_LIBS,$scg_lib_dir)
+
 dnl **** Check for parport (currently Linux only) ****
 AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev,
  AC_TRY_COMPILE(
@@ -1577,6 +1629,16 @@
   echo "*** enable Wine to use TrueType fonts."
 fi
 
+if test "$wine_enable_scg" = "no"
+then
+  echo 
+  echo "*** Warning: libscg not found. ASPI support will disabled."
+  echo "*** Please install cdrecord devel packages to get libscg"
+  echo "*** If it's installed, then use --with-scg, --with-scg-includes"
+  echo "*** and --with-scg-libraries options to specify the paths to "
+  echo "*** the installed libraries."
+fi
+
 echo
 echo "Configure finished.  Do 'make depend && make' to compile Wine."
 echo

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux