' Gambas module file ''Declare any constants here: 'The file and directory locations specified here are based on 'VectorLinux's (and Slackware's) prefixing. You may need to 'change this according to your distribution or update your PATH PUBLIC CONST License AS String = "/usr/doc/NdisConfig/COPYING" PUBLIC CONST NdiswrapperBin AS String = "/usr/sbin/ndiswrapper" PUBLIC CONST ModprobeBin AS String = "/sbin/modprobe" PUBLIC CONST RmmodBin AS String = "/sbin/rmmod" PUBLIC CONST TmpDir AS String = "/tmp/NdisConfig" PUBLIC CONST NdisInfo AS String = "/tmp/NdisConfig/ndiswrapper_info" PUBLIC CONST TmpList AS String = "/tmp/NdisConfig/tmp_list" PUBLIC CONST ProcessedDriverList AS String = "/tmp/NdisConfig/driver_list" PUBLIC CONST ModprobeconfBackup AS String = "/etc/modprobe.conf.BACKUP" PUBLIC CONST Modprobeconf AS String = "/etc/modprobe.conf" PUBLIC CONST ModprobeconfTmp AS String = "/tmp/NdisConfig/modprobe.conf.tmp" PUBLIC CONST NdisModuleData AS String = "/tmp/NdisConfig/ndismodule_data" PUBLIC CONST VersionInfo AS String = "/tmp/NdisConfig/version_info" PUBLIC SUB GenerateDriverInfo() DIM hNdisInfo AS File DIM hTmpList AS File DIM sLine AS String DIM sDeviceID AS String DIM iDevicePresent AS Integer DIM iDevIDLeft AS Integer DIM iDevIDMid AS Integer 'Ensure that NdisConfig has a dedicated temporary directory: IF Exist(MGlobal.TmpDir) = FALSE THEN MKDIR MGlobal.TmpDir ENDIF SHELL MGlobal.NdiswrapperBin & " -l > " & MGlobal.NdisInfo WAIT OPEN MGlobal.NdisInfo FOR READ AS #hNdisInfo OPEN MGlobal.TmpList FOR CREATE AS #hTmpList WHILE NOT Eof(hNdisInfo) LINE INPUT #hNdisInfo, sLine iDevicePresent = Instr(sLine, "device") IF iDevicePresent = 0 THEN PRINT #hTmpList, "|" & sLine; ELSE iDevIDLeft = Instr(sLine, ")") iDevIDMid = Instr(sLine, "(") sDeviceID = Mid$(Left$(sLine, iDevIDLeft), iDevIDMid) PRINT #hTmpList, Space$(1) & sDeviceID; ENDIF WEND CLOSE #hNdisInfo END PUBLIC SUB ProcessDriverInfo() DIM hDriverList AS File DIM hTmpList AS File DIM sLine AS String DIM arsDriverStrArray AS String[] DIM sDriverItem AS String OPEN MGlobal.TmpList FOR READ AS #hTmpList IF Lof(hTmpList) > 0 THEN 'There will always be only one line in the temporary list so there 'is no need for a WHILE NOT Eof WEND loop. LINE INPUT #hTmpList, sLine arsDriverStrArray = Split(sLine, "|") OPEN MGlobal.ProcessedDriverList FOR CREATE AS #hDriverList FOR EACH sDriverItem IN arsDriverStrArray IF sDriverItem <> "" THEN PRINT #hDriverList, sDriverItem ENDIF NEXT CLOSE #hDriverList ELSE OPEN MGlobal.ProcessedDriverList FOR CREATE AS #hDriverList CLOSE #hDriverList ENDIF CLOSE #hTmpList END PUBLIC SUB RemoveNdisAlias() DIM hAliasConf AS File DIM hTmpAliasConf AS File DIM sLine AS String OPEN MGlobal.Modprobeconf FOR READ AS #hAliasConf OPEN MGlobal.ModprobeconfTmp FOR CREATE AS #hTmpAliasConf WHILE NOT Eof(hAliasConf) LINE INPUT #hAliasConf, sLine IF Instr(sLine, "ndiswrapper") = 0 THEN PRINT #hTmpAliasConf, sLine ENDIF WEND CLOSE #hTmpAliasConf CLOSE #hAliasConf KILL MGlobal.Modprobeconf COPY MGlobal.ModprobeconfTmp TO MGlobal.Modprobeconf END PUBLIC SUB GenerateVersionInfo() DIM hVersionInfo AS File OPEN MGlobal.VersionInfo FOR CREATE AS #hVersionInfo PRINT #hVersionInfo, "NdisConfig version: " & Application.Version & gb.NewLine PRINT #hVersionInfo, "NdisWrapper:" & gb.NewLine CLOSE #hVersionInfo SHELL MGlobal.NdiswrapperBin & " -v >> " & MGlobal.VersionInfo WAIT END