home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / QM95REAL.ZIP / SCRIPTS.Z / HOSTCFG.QSC < prev    next >
Text File  |  1995-08-24  |  6KB  |  147 lines

  1. ' Configuration routines for host mode.
  2. '
  3. ' DO NOT COMPILE THIS FILE BY ITSELF!
  4. '
  5. ' This file is a part of the complete HOST.QSC and will not compile
  6. ' alone.  To recompile the host scripts, select Scripts/Compile from
  7. ' the QmodemPro for Windows menu and select HOST.QSC in the "Compile
  8. ' script" dialog box.  This file will automatically be compiled as
  9. ' part of the full script.
  10.  
  11. declare sub GetPrivateProfileString lib "kernel32" alias "GetPrivateProfileStringA" (section as string, entry as string, default as string, buffer as string, bufsize as integer, filename as string)
  12. declare function GetPrivateProfileInt lib "kernel32" alias "GetPrivateProfileIntA" (section as string, entry as string, default as integer, filename as string) as integer
  13. declare sub WritePrivateProfileString lib "kernel32" alias "WritePrivateProfileStringA" (section as string, entry as string, data as string, filename as string)
  14.  
  15. declare function GetDlgItem lib "user32" (hwindow as integer, id as integer) as integer
  16. declare function EnableWindow lib "user32" (hwindow as integer, on as integer) as integer
  17.  
  18. function GetHostProfileString(entry as string, default as string) as string
  19.   dim buf as string
  20.   buf = space(128)
  21.   call GetPrivateProfileString("Host", entry, default, buf, 128, "qmwin.ini")
  22.   GetHostProfileString = buf
  23. end function
  24.  
  25. function GetHostProfileInt(entry as string, default as integer) as integer
  26.   GetHostProfileInt = GetPrivateProfileInt("Host", entry, default, "qmwin.ini")
  27. end function
  28.  
  29. sub WriteHostProfileString(entry as string, data as string)
  30.   call WritePrivateProfileString("Host", entry, data, "qmwin.ini")
  31. end sub
  32.  
  33. sub WriteHostProfileInt(entry as string, data as integer)
  34.   call WriteHostProfileString(entry, str(data))
  35. end sub
  36.  
  37. function GetModemIndex(byval s as string) as integer
  38.   GetModemIndex = 0
  39.   dim i as integer
  40.   for i = 0 to GetModemCount-1
  41.     if OemUpper(s) = OemUpper(GetModemName(i)) then
  42.       GetModemIndex = i
  43.       exit function
  44.     end if
  45.   next
  46.   if left(s, 3) = "COM" then
  47.     i = asc(s(4)) - asc("1")
  48.     if i >= 0 and i <= 3 then
  49.       GetModemIndex = i + GetModemCount
  50.     end if
  51.   end if
  52. end function
  53.  
  54. sub SetupDialog.Init
  55.   dim count as integer
  56.   count = GetModemCount
  57.   dim i as integer
  58.   for i = 0 to count-1
  59.     AddComboBoxItem(HWindow, 111, GetModemName(i))    
  60.   next
  61.   AddComboBoxItem(HWindow, 111, "COM1")
  62.   AddComboBoxItem(HWindow, 111, "COM2")
  63.   AddComboBoxItem(HWindow, 111, "COM3")
  64.   AddComboBoxItem(HWindow, 111, "COM4")
  65.   if modem < GetModemCount then
  66.     EnableWindow(GetDlgItem(HWindow, 200), False)
  67.   else
  68.     Enablewindow(GetDlgItem(HWindow, 200), True)
  69.   end if
  70.   modem = GetModemIndex(GetHostProfileString("Modem", ""))
  71. end sub
  72.  
  73. function SetupDialog.id(111) as integer
  74.   if modem < GetModemCount then
  75.     EnableWindow(GetDlgItem(HWindow, 200), False)
  76.   else
  77.     Enablewindow(GetDlgItem(HWindow, 200), True)
  78.   end if
  79. end function
  80.  
  81. function SetupDialog.id(200) as integer
  82.   dim d as ModemSetupDialog
  83.   d = ModemSetup
  84.   if dialogbox(d) = IDOK then
  85.     ModemSetup = d
  86.     call WriteHostProfileString("ModemInit", ModemSetup.init)
  87.     call WriteHostProfileString("ModemAnswer", ModemSetup.answer)
  88.     call WriteHostProfileString("ModemBusy", ModemSetup.busy)
  89.     call WriteHostProfileString("ModemOK", ModemSetup.ok)
  90.     call WriteHostProfileString("ModemRing", ModemSetup.ring)
  91.     call WriteHostProfileString("ModemRingCount", ModemSetup.ringcount)
  92.   end if
  93. end function
  94.  
  95. sub SetupHost
  96.   dim d as SetupDialog
  97.   d = Setup
  98.   if dialogbox(d) = IDOK then
  99.     Setup = d
  100.     if Setup.modeopen then
  101.       call WriteHostProfileInt("Mode", 0)
  102.     elseif Setup.modeclosed then
  103.       call WriteHostProfileInt("Mode", 1)
  104.     elseif Setup.modecallback then
  105.       call WriteHostProfileInt("Mode", 2)
  106.     end if
  107.     call WriteHostProfileString("MaxTime", Setup.maxtime)
  108.     call WriteHostProfileString("DosPassword", Setup.dospass)
  109.     call WriteHostProfileString("ShutdownPassword", Setup.shutdownpass)
  110.     call WriteHostProfileString("DownloadPath", Setup.dlpath)
  111.     call WriteHostProfileString("UploadPath", Setup.ulpath)
  112.     call WriteHostProfileInt("SysopAnyPath", Setup.sysopanypath)
  113.     if Setup.Modem < GetModemCount then
  114.       call WriteHostProfileString("Modem", GetModemName(Setup.modem))
  115.     else
  116.       call WriteHostProfileString("Modem", "COM"+chr(asc("1")+Setup.modem-GetModemCount))
  117.     end if
  118.   end if
  119. end sub
  120.  
  121. sub LoadConfig
  122.   Setup.modeopen = 0
  123.   Setup.modeclosed = 0
  124.   Setup.modecallback = 0
  125.   select case GetHostProfileInt("Mode", 0)
  126.     case 0
  127.       Setup.modeopen = 1
  128.     case 1
  129.       Setup.modeclosed = 1
  130.     case 2
  131.       Setup.modecallback = 1
  132.   end select
  133.   Setup.maxtime = str(GetHostProfileInt("MaxTime", 60))
  134.   Setup.dospass = GetHostProfileString("DosPassword", "")
  135.   Setup.shutdownpass = GetHostProfileString("ShutdownPassword", "")
  136.   Setup.dlpath = GetHostProfileString("DownloadPath", "")
  137.   Setup.ulpath = GetHostProfileString("UploadPath", "")
  138.   Setup.sysopanypath = GetHostProfileInt("SysopAnyPath", 0)
  139.   Setup.modem = GetModemIndex(GetHostProfileString("Modem", ""))
  140.   ModemSetup.init = GetHostProfileString("ModemInit", "ATQ0H0S0=0^M")
  141.   ModemSetup.answer = GetHostProfileString("ModemAnswer", "ATA^M")
  142.   ModemSetup.busy = GetHostProfileString("ModemBusy", "ATH1M0^M")
  143.   ModemSetup.ok = GetHostProfileString("ModemOK", "OK")
  144.   ModemSetup.ring = GetHostProfileString("ModemRing", "RING")
  145.   ModemSetup.ringcount = str(GetHostProfileInt("ModemRingCount", 1))
  146. end sub
  147.