/* hserv.rexx 33.0 (27.11.2001) by Alfonso Ranieri ** DON'T TOUCH THE LINE ABOVE !!! ** ** Name: hserv.rexx ** Description: HTTP server - main macro ** Version: 33.0 ** Date: 27.11.2001 ** Author: Alfonso Ranieri ** Status: GPL **/ signal on halt signal on break_c signal on break_d call Init() call ReadArguments() if global.sock? then call DoInetd() call StartCreateApp() call AdvanceIntro("Creating application...") call InitGlobal() call CreateApp() call AdvanceIntro("Reading configuration...") res=SetConfig(global.ConfigFile) if global.ArgsPort~="" then hserv.Port=global.ArgsPort call AdvanceIntro("Setting up...") call SetMainGadgets() call SetMainNotifies() if res<2 & global.StartASAP then do call AdvanceIntro("Opening server...") call OpenServer() end if ~OpenWindow("mwin") then call err("Can't open window") call Remove(global.BarConfigObject) call Dispose("iwin") call set(global.BarConfigObject,"ShowMe",1) call set("app","sleep",0) call HandleApp() /* never reached */ /***************************************************************************/ init: procedure expose global. hserv. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit if AddLibrary("rexxsupport.library","rxsocket.library","rxasl.library","rxmui.library","rxlibnet.library")~=0 then exit call MacroEnv("global","ProgDir CD") if global.sock? then if GetSockName(global.sock,"loc")>=0 then call SysLogCtl(global.noextname"["loc.AddrPort"] (inetd)") else call SysLogCtl(global.noextname "(inetd)") else if global.socket? then call SysLogCtl(global.noextname) return /***************************************************************************/ ReadArguments: procedure expose global. hserv. if global.wb? then do c=FindVar("CONFIG") p=FindVar("PORT") s=(FindVar("START")~="") q=(FindVar("QUIET")~="") end else do if ~ReadArgs("CONFIG/K,PORT/K/N,START/S,QUIET/S") then call err "Args error:" DosString() if parm.0.flag then c=parm.0.value; else c="" if parm.1.flag then p=parm.1.value; else p="" s=parm.2.flag q=parm.3.flag n=parm.4.flag end if c="" then c="conf/hserv.conf" global.ConfigFile=c if p~="" then if ~CheckPort(p) then p="" global.ArgsPort=p global.StartASAP=s global.Quiet=q global.idx = 1 global.OldInfo = "Welcome to hserv!" parse value(sourceline(1)) with "/* " hserv.name ".rexx " hserv.ver " " hserv.date " by " hserv.author return /***************************************************************************/ InitGlobal: procedure expose global. hserv. hserv.MacroNotify="HSERV_"time(s) global.mns=MacroNotifyCreate(hserv.MacroNotify) if global.mns=0 then exit global.Images = "images" global.ConfigWindow = 0 global.ConfigWindowOpened = 0 global.noti = -1 global.children = 0 global.ns = 0 global.ss = 2**AllocSignal() return /***************************************************************************/ DoInetd: procedure expose global. hserv. /* if we run from inetd, we are quick */ if ReadConfig(global.ConfigFile,0)<2 then do call CopyConfig("GLOBAL.TEMP","HSERV") call GetSockName(global.sock,"N") hserv.Port=n.AddrPort call HandleSocket(global.sock,1) end else do call ShutDown(global.sock,2) call err(global.error) end exit /***************************************************************************/ InitSocket: procedure expose global. hserv. /* we are opening... */ global.sock=socket("inet","stream") if global.sock<0 then do call set("lamp","color","error") call GuiInfo("Can't create socket") call StackInfo("can't create socket (%m)") return 0 end local.AddrFamily="inet" local.AddrPort=hserv.Port if bind(global.sock,"local")<0 then do call set("lamp","color","error") call GuiInfo("Can't bind socket on port" hserv.port) call StackInfo("can't bind socket on port" hserv.port "(%m)") call CloseSocket(global.sock) global.sock=-1 return 0 end if listen(global.sock,5)<0 then do call set("lamp","color","error") call GuiInfo("Error on listen()") call StackInfo("listen() error (%m)") call CloseSocket(global.sock) global.sock=-1 return 0 end call SetSocketBaseSingle("SIGEVENTMASK",global.ss) call SetSockOpt(global.sock,"SOCKET","EVENTMASK","ACCEPT") call IoCtlSocket(global.sock,"FIOASYNC",1) call IoCtlSocket(global.sock,"FIONBIO",1) return 1 /***************************************************************************/ halt: break_c: break_d: exit: /***************************************************************************/ fin: if ~global.sock? & global.sock~="GLOBAL.SOCK" then if global.sock>-1 then call CloseServer() exit /***************************************************************************/ err: procedure expose global. hserv. parse arg msg if IsLibOn("SOCKET") then call SysLog(msg,"ERR") else call EasyRequest(msg,global.noextname) call fin /***************************************************************************/ OpenServer: procedure expose global. hserv. if ~IsLibOn("Socket") then do call GuiInfo("No TCP/IP stack is running.") call set("lamp","color","error") return 0 end if IsLibOn("TTCP") then do call set("lamp","color","error") call GuiInfo("hserv CANNOT work with TermiteTCP") return 0 end global.ConfigFile=xget("ConfigFile","contents") if global.ConfigFile="" then do call set("lamp","color","error") call GuiInfo("No config file supplied") return 0 end hserv.DocumentDir=xget("DDir","contents") if hserv.DocumentDir="" then do call set("lamp","color","error") call GuiInfo("No Document dir supplied") return 0 end hserv.DocumentIndex=xget("DIndex","contents") if hserv.DocumentIndex="" then do hserv.DocumentIndex="index.html" call set("DIndex","contents",hserv.DocumentIndex) end hserv.Port=xget("MainPort","contents") if hserv.Port="" then do call set("lamp","color","error") call GuiInfo("No port supplied") return 0 end if ~CheckPort(hserv.Port) then do call set("lamp","color","error") call GuiInfo("Invalid port") return 0 end if ~InitSocket() then return 0 call set("app","num1",1) call SysLogCtl(global.noextname"["hserv.Port"]") call StackInfo("Opened HTTP server at port" hserv.Port,"INFO") call GuiInfo("HTTP server at port" hserv.Port "opened","INFO") return 1 /***********************************************************************/ CloseServer: procedure expose global. hserv. if global.sock=-1 then return call CloseSocket(global.sock) global.sock=-1 call MacroNotifySync() call set("app","num1",0) call StackInfo("Closed HTTP server at port" hserv.Port,"INFO") call GuiInfo("Closed HTTP server at port" hserv.Port) call SysLogCtl(global.noextname) return /***********************************************************************/ CreateNotify: procedure expose global. hserv. if global.noti~=-1 then call FreeNotify(global.noti) global.ns=0 global.noti=-1 if global.ConfigFile~="" then do global.noti=StartNotify(global.ConfigFile) if global.noti~=-1 then global.ns=NotifySignal(global.noti) end return /**************************************************************************/ HandleSocket: procedure expose global. hserv. parse arg s,inetdFlag hserv.inetd=inetdFlag call StemToVar("hserv") call RxsCall("hs",s) call CloseSocket(s) return /***************************************************************************/ HandleApp: procedure expose global. hserv. ctrl_c=2**12 do forever call SyncGUI mask=or(global.ns,ctrl_c,global.ss,global.mns) call NewHandle("app","h",mask) /* break-c */ if and(h.signals,ctrl_c)>0 then signal break_c /* GUI */ call HandleAppObject(h.EventFlag,h.event) /* socket */ if and(h.signals,global.ss)>0 then call HandleSocketEvent() /* macro notify */ if and(h.signals,global.mns)>0 then call HandleMacroEvent() /* notify */ if and(h.signals,global.ns)>0 then call OpenConfig(0) end /* never reached */ /***********************************************************************/ SyncGUI: procedure expose global. hserv. if global.sock>-1 then if global.children>0 then do vall="Connections:" global.children vbreak=1 end else do vall="No connection" vbreak=0 end else do vall="" vbreak=0 end call set("msbreak","enabled",vbreak) call set("all","contents",vall) return /***********************************************************************/ HandleAppObject: procedure expose global. hserv. h. parse arg EventFlag,event call SyncGUI if EventFlag then select when event="QUIT" then call fin otherwise interpret event end return /***********************************************************************/ HandleAppObjectOnce: procedure expose global. hserv. h. h.NoWait=1 call NewHandle("app","h",0) call HandleAppObject(h.EventFlag,h.event) return /***********************************************************************/ HandleSocketEvent: procedure expose global. hserv. e=GetSocketEvents("ev") do while e>=0 if ~ev.accept then do call CloseSocket(e) iterate end rs=accept(e,"rem") call HandleSocket(rs,0) e=GetSocketEvents("ev") call HandleMacroEventOnce call HandleAppObjectOnce() if global.sock=-1 then return end return /***********************************************************************/ HandleMacroEventOnce: procedure expose global. hserv. ev=MacroNotifyGetEvent(hserv.MacroNotify) if ev="" then return 0 parse var ev ev child d select when ev="STARTED" then global.children=global.children+1 when ev="ENDED" then global.children=global.children-1 otherwise nop end return 1 /***********************************************************************/ HandleMacroEvent: procedure expose global. hserv. do forever call HandleAppObjectOnce() if ~HandleMacroEventOnce() then return end /* never reached */ /***********************************************************************/ RName: procedure parse arg file if file=="" then return "" od=pragma("D",pathpart(file)) file=AddPart(pragma("D"),FilePart(file)) call pragma("D",od) return file /***************************************************************************/ StartCreateApp: procedure expose global. hserv. if ~BarConfigObject() then call err("Can't create application") app.Title=hserv.name app.Copyright="Under the GNU Public Licence" app.Author=hserv.author app.Version="$" || "VER" hserv.name hserv.ver hserv.date app.Description="HTTP server by" hserv.author app.Base="HSERV" app.DiskObject=hserv.name app.MenuStrip=MakeObj("strip","menustrip") app.Subwindow="iwin" iwin.BorderLess=1 iwin.CloseGadget=0 iwin.DepthGadget=0 iwin.DragBar=0 iwin.NoMenus=1 iwin.SizeGadget=0 iwin.Width=-200-25 iwin.Activate=0 iwin.Contents="igroup" igroup.Frame="inputlist" igroup.0="ititle" ititle.Class="text" ititle.Font="Big" ititle.Contents="1B631B62"x || hserv.name hserv.ver igroup.1=hbar() igroup.2=vspace(2) igroup.3=text("intro",,"none","none") igroup.4=global.BarConfigObject if NewObj("application","app")>0 then call err("Can't create application") call set(global.BarConfigObject,"ShowMe",0) call DoMethod("app","Load","Env") call OpenWindow("iwin") return /**************************************************************************/ AdvanceIntro: procedure expose global. parse arg msg if global.sock<0 then call set("intro","contents",msg) return /**************************************************************************/ CreateApp: procedure expose global. hserv. m1=MakeObj(,"menu","Project",, menuitem("mabout","?\About..."),, menuitem("maboutrxmui","About RxMUI..."),, menuitem("maboutmui","About MUI..."),, menuitem("","bar"),, menuitem("mhide","H\Hide"),, menuitem("","bar"),, menuitem("mquit","Q\Quit")) m2=MakeObj(,"menu","Server",, MenuItem("msanother","Another..."),, MenuItem("","bar"),, MenuItem("msopen","1\Open"),, MenuItem("msclose","2\Close",,"DISABLED"),, MenuItem("","bar"),, MenuItem("msbreak","3\Break",,"DISABLED")) m3=MakeObj(,"menu","Editor",, MenuItem("medit","E\Edit..."),, MenuItem("mopen","O\Open..."),, MenuItem("msave","S\Save..."),, MenuItem("msaveas","W\Save as..."),, menuitem("","bar"),, MenuItem("mlast","L\Last saved..."),, MenuItem("mrestore","R\Restore"),, menuitem("","bar"),, MenuItem("mhserv","V\hserv..."),, MenuItem("mmui","M\MUI...")) if m1="" | m2="" | m3="" then call err("Can't create application") call Add("strip",m3) call Add("strip",m2) call Add("strip",m1) mwin.ID="MAIN" mwin.Title=hserv.name mwin.Contents="mgroup" mgroup.0="barg" barg.class="group" barg.horiz=1 barg.0=CreateBar("sbar",global.images,1) barg.1=hspace() mgroup.1="smg" smg.class="group" smg.frame="group" smg.background="groupback" smg.class="group" smg.columns=2 smg.0=Label("_Config") smg.1="cfgpop" cfgpop.class="popasl" cfgpop.CycleChain=1 cfgpop.string=string("ConfigFile","c") smg.2=label("_Documents") smg.3="ddpop" ddpop.class="popasl" ddpop.DrawersOnly=1 ddpop.CycleChain=1 ddpop.string=string("DDir","d") smg.4=label("_Index") smg.5="dipop" dipop.class="popasl" dipop.FileOnly=1 dipop.CycleChain=1 dipop.string=string("DIndex","i") smg.6=label("S_tatus") MainStatus.CycleChain=1 smg.7=MakeObj("MainStatus","Cycle","Opened|Paused","S_tatus") smg.8=label("_Port") mpg.spacing=1 mpg.0="MainPort" MainPort.class="string" MainPort.frame="string" MainPort.CycleChain=1 MainPort.ControlChar="p" MainPort.FixWidthTxt="6553565535" MainPort.MaxLen=6 MainPort.isnumeric=1 MainPort.MinVal=1 MainPort.MaxVal=65535 MainPort.format="right" FindFreePort.cyclechain=1 mpg.1=MakeObj("FindFreePort","Imagebutton","Popup",) mpg.2=hspace(4) mpg.3=hspace() mpg.4=label("Qui_et") quiet.CycleChain=1; mpg.5=CheckMark("quiet",global.quiet,"e") smg.9=MakeObj("mpg","HGroup") mgroup.2="sg0" sg0.class="group" sg0.frame="text" sg0.background="textback" sg0.0="sg00" sg00.class="group" sg00.horiz=1 sg00.0="lamp" lamp.class="lamp" lamp.type="medium" lamp.color="ok" sg00.1="info" info.class="text" sg0.1="all" all.class="text" if NewObj("window","mwin")>0 then call err("Can't create application") if ~IsLibOn("SOCKET") then call set("lamp","color","error") call add("app","mwin") call set("app","sleep",1) global.RexxPort=xget("app","base") return /***********************************************************************/ CreatePWin: procedure expose global. hserv. parse arg msg if ~RxMUIObjExists("pwin") then do pwin.ID="PWIN" pwin.Title="hserv informations" pwin.Contents="pmgroup" pmgroup.0="plv" plv.class="listview" plv.list="pft" pft.class="floattext" pft.frame="readlist" pft.font="fixed" if NewObj("window","pwin")>0 then call err("Can't create error window") call add("app","pwin") call notify("pwin","closerequest",1,"app","return","call dispose('pwin')") if ~OpenWindow("pwin") then call GuiInfo("Can't open errors window") end call set("pwin","activate",1) call set("pft","text",ParseText(msg)) return /***********************************************************************/ SetMainNotifies: procedure expose global. hserv. call notify("app","active","everytime","MainStatus","set","active","nottriggervalue") call notify("mwin","CloseRequest",1,"app","ReturnID","quit") call notify("mabout","menutrigger","everytime","app","return","call OpenAboutWindow()") call notify("maboutrxmui","menutrigger","everytime","app","aboutrxmui","_first") call notify("maboutmui","menutrigger","everytime","app","aboutmui","_first") call notify("mhide","menutrigger","everytime","app","set","iconified",1) call notify("mquit","menutrigger","everytime","app","returnid","quit") call notify("msopen","menutrigger","everytime","app","return","call OpenServer") call notify("msanother","menutrigger","everytime","app","return","shell AREXX '"global.FullName"'") call notify("msclose","menutrigger","everytime","app","return","call CloseServer") call notify("msbreak","menutrigger","everytime","app","return","call MacroNotifySync()") call notify("msbreak","enabled","EveryTime","sbar","sbset",2,"disabled","NotTriggerValue") call notify("medit","menutrigger","everytime","app","return","call OpenConfigWindow") call notify("mopen","menutrigger","everytime","app","return","Call OpenConfig(1)") call notify("msave","menutrigger","everytime","app","return","call SaveConfig('SAVE')") call notify("msaveas","menutrigger","everytime","app","return","call SaveConfig('SAVEAS')") call notify("mlast","menutrigger","everytime","app","return","call OpenConfig(0)") call notify("mrestore","menutrigger","everytime","app","return","call RestoreConfig()") call notify("mhserv","menutrigger","everytime","app","return","call OpenHservConfigWindow") call notify("mmui","menutrigger","everytime","app","OpenConfigWindow") call notify("ConfigFile","newcontents","everytime","app","return","call OpenConfig(2)") call notify("FindFreePort","pressed",0,"app","return","call FindFreePort()") call notify("quiet","selected","EveryTime","app","setvar","global.Quiet") call notify("DDIr","contents","EveryTime","app","return","call ChangeStatus('DDIR',h.contents)","TriggerAttr") call notify("DIndex","contents","EveryTime","app","return","call ChangeStatus('DINDEX',h.contents)","TriggerAttr") call notify("MainStatus","active","EveryTime","app","return","call ChangeStatus('STATUS',h.active)","TriggerAttr") call notify("app","num1","EveryTime","sbar","sbset",0,"disabled","TriggerValue") call notify("app","num1","EveryTime","sbar","sbset",1,"disabled","NotTriggerValue") call notify("app","num1","everytime","MainPort","set","disabled","triggervalue") call notify("app","num1","everytime","FindFreePort","set","disabled","triggervalue") call notify("app","num1","everytime","msopen","set","enabled","nottriggervalue") call notify("app","num1","everytime","msclose","set","enabled","triggervalue") call notify("app","num1",0,"lamp","set","color","ok") call notify("app","num1",1,"lamp","set","color","processing") call SBNotify("sbar",0,"pressed",0,"app","return","call OpenServer") call SBNotify("sbar",1,"pressed",0,"app","return","call CloseServer") call SBNotify("sbar",2,"pressed",0,"app","return","call MacroNotifySync()") call SBNotify("sbar",4,"pressed",0,"app","return","call OpenConfigWindow") return /***********************************************************************/ SetMainGadgets: procedure expose global. hserv. set.0="ConfigFile"; set.0.attr="contents"; set.0.value=global.ConfigFile set.1="MainPort"; set.1.attr="contents"; set.1.value=hserv.Port set.2="DDir"; set.2.attr="contents"; set.2.value=hserv.DocumentDir set.3="DIndex"; set.3.attr="contents"; set.3.value=hserv.DocumentIndex set.4="MainStatus"; set.4.attr="active"; set.4.value=hserv.status call MultiSetAttr("set",0) return /***********************************************************************/ OpenAboutWindow: procedure expose global. hserv. if RxMUIObjExists("awin") then do call set("awin","open",1) return end call set("app","sleep",1) call GUIInfo("Creating About window...",1) awin.ID="AWIN" awin.Title="About hserv" awin.UseRightBorderScroller=1 awin.Contents="amg" amg.background="requesterback" amg.0="sav" sav.class="scrollgroup" sav.usewinborder=1 sav.freehoriz=0 sav.virtgroupcontents="av" av.class="virtgroup" av.frame="virtual" av.background="groupback" av.spacing=2 pic.class="picture" pic.InputMode="relverify" pic.frame="button" pic.Background="RequesterBack" pic.CycleChain=1 pic.sourcetype="mem" pic.Transparent=0 call DecodeB64(" Rk9STQAADopJTEJNTkFNRQAAABdSYW0gRGlzazpoc2VydjNnaWYuZ2lmAABCTUhEAAAAFACY ADQAAAAACAIBAAACAAAAAAAAQ0FNRwAAAARQABAAQ01BUAAAAwCWlpYAAAD///85ZqJ6enqv r6+qkn7/q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4A//AAwcAAAwBSoo AAAkAECC/QACEAAA7QDtAO4AAJDtAO0A/gAJ+BAABAAPw/6A/P4AAy/gAAAM/5/+A+AAA//g OAB/Af7/A8Af/wD/AAoBABKqrAAQBAGAgP4AAzAgAADtAO0A7gAAkO0A7QAMAeAB/wgABAAD 4/gA/P4AAx/wAAAM/h/+APAAA//4GAH/Af7/A+AP/wAMASABAQ1SpAAAIAYAgP4A/xD/AO0A 7QDuAACQ7QDtAAwHgAD8BgAIAANHgAD+/gADA8AAAAz4f/4B+AAH//wYB/8B/v8D8D//AAwE AAECBpVYAAMEYACC/gADBEAAAO0A7QDuAACQ7QDtAAwDgAC+AYAQAABnwABe/gADB4AAAAz8 f/8B/gAP//+YP/+B/v8D+H//AAwDgADGAZSQAABnwABi/gADB4AAAO0A7QDuAACQ7QDtAP4A AzgAKqD8AAA0+gD+/wPH/9Vf/P8Ay/v/AAD+AAM4ACqg/AAANPoA7QDtAO4AAJDtAO0A7QDu /wAA7QDtAO0A7gAAkO0A7QDtAO7/AADtAO0A7QDuAACQ7QDtAO0A7v8AAO0A7QDtAO4AAJDt AO0AAA==",, "pic.source","string var") call child("picg","pic") email.class="urltext" email.url="mailto:alforan@tin.it" email.text="Alfonso Ranieri" call child("picg",Text(,ParseText("%c%b Version" hserv.ver"%n\n\nARexx HTTP server"),"none","none")) call child("picg",MakeObj(,"HCenter",MakeObj(,"Hgroup",, Text(,"by","none","none"),, "email"))) call child("picg",Text(,ParseText("\nUnder the %uGNU Public Licence"),"none","none")) call child("picg",vfspace()) call child("av",MakeObj(,"HCenter","picg","Group")) call child("av",MakeObj(,"bartitle","Infos")) if global.sock=-1 then status="closed" else if hserv.Status=0 then status="opened" else status="paused" call child("av",MakeObj(,"ColGroup",2,, Label("ARexx port:","left"),, MakeObj(,"HLeft",, Text(,global.RexxPort,"none","none","")),, Label("HTTP port:","left"),, MakeObj(,"HLeft",, Text("ap",hserv.Port,"none","none","")))) call child("av",vfspace()) call child("av",MakeObj("","bartitle","RxSocket")) rxsocket.class="urltext" rxsocket.url="http://web.tiscalinet.it/amiga" call child("av",Text(,ParseText("%c%bhserv%n is made with the magics of:\n\n%bRxSocket%n%l\n\nCopyright 1998-2001 %bAlfonso Ranieri%l"),"none","none")) call child("av",MakeObj(,"HLeft",MakeObj(,"HGroup",, Text(,"Support:","none","none"),, "rxsocket"))) call child("av",vfspace()) call child("av",MakeObj("","bartitle","RxMUI")) call child("av",Text(,ParseText("%c%bhserv%n is powered up by:"),"none","none")) call child("av",vfspace()) RxMUI.SetMax=1 RxMUI.CycleChain=1 call child("av",MakeObj("","HCenter",button("RxMUI","RxMUI"))) call child("av",vfspace()) call child("av",Text(,ParseText("%cCopyright 1999-2001 %bAlfonso Ranieri%l"),"none","none")) call child("av",vfspace()) call child("av",MakeObj("","bartitle","Third parts")) tg0.spacing=0 amui.SetMax=1 t0.SetMax=1 t1.SetMax=1 call child("av",Text(,ParseText("%c%bhserv%n uses:%l\n\n- Textinput.mcc © Oliver Wagner \n- Speedbar.mcc © Simone Tellini \n- Lamp.mcc © Maik Schreiber "),"none","none")) amui.CycleChain=1 call child("av",MakeObj(,"HLeft",MakeObj(,"HGroup",, Text("t0","-","none","none"),, MakeObj("tg0","HGroup",, button("amui","MUI"),, Text("t1",", of course","none","none"))))) call child("av",vfspace()) if NewObj("window","awin")>0 then do call GuiInfo("Can't create about window") return end call notify("awin","closerequest",1,"app","return","call DisposeAWin") call notify("pic","pressed",0,"app","return","call GotoHservURL()") call notify("RxMUI","pressed",0,"app","aboutrxmui","_first") call notify("amui","pressed",0,"app","aboutmui","_first") call set("awin","defaultobject","sav") call notify("MainPort","contents","everytime","ap","set","contents","triggervalue") call add("app","awin") call set("awin","defaultobject","sav") if ~OpenWindow("awin") then call GuiInfo("Can't open about window") else call GuiInfo("") call set("app","sleep",0) return GotoHservURL: procedure call OpenURL("http://web.tiscalinet.it/amiga/english/soft/hserv.html","NewWindow") return DisposeAWin: procedure expose global. hserv. if RxMUIObjExists("awin") then call dispose("awin") return /**************************************************************************/ OpenConfigWindow: procedure expose global. hserv. call set("app","sleep",1) if ~global.ConfigWindow then do call GuiInfo("Creating config window...",1) cwin.Title="hserv Preferences" cwin.ID="CONF" cwin.Contents="cmgroup" cmgroup.0="g" g.class="group" g.horiz=1 g.HorizSpacing=4 g.0="lister" lister.class="listview" lister.FixWidthTxt="12345678901234" lister.CycleChain=1 lister.List="entries" entries.Frame="InputList" entries.Names="Host,Documents,Conns,CGI,Config,Specials,Logs,Flags" g.1="vertical" vertical.class="group" vertical.frame="ReadList" vertical.background="PageBack" vertical.0 = vspace() vertical.1="pager" pager.class="group" pager.PageMode=1 call child("pager","HostPage","group") hostpage.columns=2 hostpage.0=label("_HostName") hostpage.1="hostnameg" hostnameg.class="group" hostnameg.horiz=1 HostName.CycleChain=1 hostnameg.0=string("HostName",'h') hostnameg.1=label("_Port") port.FixWidthTxt="6553565535" port.CycleChain=1 hostnameg.2=MakeObj("port","NumericString","_Port",1,65535,6) hostpage.2=label("A_dmin") Admin.CycleChain=1 hostpage.3=string("admin",'d') hostpage.4=label("Sta_tus") status.CycleChain=1 hostpage.5=MakeObj("status","Cycle","Opened|Paused",""Sta_tus"") call child("pager","DocsPage","group") docspage.columns=2 docspage.0=label("_DocumentDir") docspage.1="pdocumentdir" pdocumentdir.class="popasl" pdocumentdir.drawersonly=1 DocumentDir.CycleChain=1 pdocumentdir.string=String("DocumentDir","d") docspage.2=label("_Index") docspage.3="pindex" pindex.class="popasl" DocumentIndex.CycleChain=1 pindex.string=String("DocumentIndex","i") docspage.4=label("Si_gnature") docspage.5="psig" psig.class="popasl" Signature.CycleChain=1 psig.string=String("Signature","g") cp.columns=5 cp.class="group" cp.0=label("_Timeout") Timeout.FixWidthTxt="12345678" Timeout.CycleChain=1 cp.1=MakeObj("Timeout","NumericString","_Timeout",0,,6) cp.2=hspace(4) cp.3=label("_KeepAlive") KeepAlive.FixWidthTxt="12345678" KeepAlive.Stringify="parse arg v;if v=0 then r='Off';else r=v; return '1b63'x || r" KeepAlive.CycleChain=1 cp.4=MakeObj("KeepAlive","Slider","_KeepAlive",0,4) cp.5=label("Send _Delta") SendDelta.FixWidthTxt="12345678" SendDelta.CycleChain=1 cp.6=MakeObj("SendDelta","NumericString","Send _Delta",0,,6) cp.7=hspace(4) cp.8=label("_Pri") Pri.FixWidthTxt="12345678" Pri.CycleChain=1 cp.9=MakeObj("Pri","NumericString","_Pri",-127,3,6) call child("pager",MakeObj("ConnsPage","HCenter","cp")) CGIPage.class="group" CGIPage.columns=2 CGIPage.0=label("CGI_Dir") CGIPage.1="pcgidir" pcgidir.class="popasl" pcgidir.drawersonly=1 cgidir.CycleChain=1 pcgidir.string=String("cgidir","d") CGIPage.2=label("_Perl") CGIPage.3="pperlpath" pperlpath.class="popasl" perlpath.CycleChain=1 pperlpath.string=String("perlpath","p") CGIPage.4=label("_Rebol") CGIPage.5="prebolpath" prebolpath.class="popasl" rebolpath.CycleChain=1 prebolpath.string=String("rebolpath","r") CGIPage.6=label("CGI_Mod") CGIPage.7="pCGIMod" pCGIMod.class="popasl" CGIMod.CycleChain=1 pCGIMod.string=string("CGIMod","m") DisableCGI.CycleChain=1 call child("pager",, MakeObj(,"VGroup",, "CGIPage",, MakeObj(,"HCenter",, MakeObj(,"HGroup",, label("Disabl_e CGI "),, checkmark("DisableCGI",0,"e"))))) call child("pager","ConfigPage","group") configpage.columns=2 configpage.0=label("Aut_h") configpage.1="pauth" pauth.class="popasl" auth.CycleChain=1 pauth.string=string("auth","h") configpage.2=label("_RejIP") configpage.3="prejip" prejip.class="popasl" rejectedip.CycleChain=1 prejip.string=string("rejectedip","r") configpage.4=label("_Mime") configpage.5="pmime" pmime.class="popasl" mime.CycleChain=1 pmime.string=string("mime","m") configpage.6=label("Handl_ers") configpage.7="phandlers" phandlers.class="popasl" handlers.CycleChain=1 phandlers.string=string("handlers","e") call child("pager","SpecialsPage","group") specialspage.columns=2 SpecialsPage.0=label("_VirtualHosts") SpecialsPage.1="pvirtualhosts" pvirtualhosts.class="popasl" virtualhosts.CycleChain=1 pvirtualhosts.string=string("virtualhosts","v") SpecialsPage.2=label("_Errors") SpecialsPage.3="perrors" perrors.class="popasl" errors.CycleChain=1 perrors.string=string("errors","e") SpecialsPage.4=label("_Referers") SpecialsPage.5="preferers" preferers.class="popasl" referers.CycleChain=1 preferers.string=string("referers","r") SpecialsPage.6=label("S_pecials") SpecialsPage.7="pspecials" pspecials.class="popasl" specials.CycleChain=1 pspecials.string=string("specials","p") call child("pager","LogPage","group") logpage.class="group" logpage.columns=3 logpage.0=label("_Transfers") logpage.1="transferlog" transferlog.class="cycle" transferlog.controlchar="t" transferlog.weight=10 transferlog.entries="on|off|sys" transferlog.CycleChain=1 logpage.2="ptransferfile" ptransferfile.class="popasl" transferfile.CycleChain=1 ptransferfile.string=string("transferfile") logpage.3=label("_Errors") logpage.4="errorlog" errorlog.class="cycle" errorlog.controlchar="e" errorlog.weight=10 errorlog.entries="on|off|sys" errorlog.CycleChain=1 logpage.5="perrorfile" perrorfile.class="popasl" errorfile.CycleChain=1 perrorfile.string=string("errorfile") fg.class="group" fg.columns=2 HostNameLookups.CycleChain=1 fg.0=checkmark("HostNameLookups",0,"h") fg.1=label("_HostNameLookups","left") ident.CycleChain=1 fg.2=checkmark("ident",0,"i") fg.3=label("_Ident","left") onlyamigaclient.CycleChain=1 fg.4=checkmark("onlyamigaclient",0,"o") fg.5=label("_OnlyAmigaClient","left") defimage.CycleChain=1 fg.6=checkmark("defimage",0,"d") fg.7=label("_DefImage","left") call child("pager",MakeObj("FLagsPage","HCenter","fg")) vertical.2 = vspace() cmgroup.1=text("cinfo","") cmgroup.2="cbg" cbg.class="group" cbg.horiz=1 cbg.SameSize=1 csave.CycleChain=1 cbg.0=button("csave","_Save") cbg.1=hvspace() cuse.CycleChain=1 cbg.2=button("cuse","_Use") cbg.3=hvspace() capply.CycleChain=1 cbg.4=button("capply","_Apply") cbg.5=hvspace() cquit.CycleChain=1 cbg.6=button("cquit","_Cancel") if NewObj("window","cwin") then do call GuiInfo("Can't create config window") return end call notify("cwin","open","Everytime","app","setvar","GLOBAL.CONFIGWINDOWOPENED") call notify("cwin","closerequest",1,"cwin","set","open",0) call notify("lister","active","everytime","pager","set","activepage","triggervalue") call notify("ident","selected",1,"HostNameLookups","set","selected",1) call notify("ident","selected","everytime","HostNameLookups","set","disabled","triggervalue") call notify("csave","pressed",0,"app","return","call SaveConfig('SAVE')") call notify("cuse","pressed",0,"app","return","call SaveConfig('USE')") call notify("cuse","pressed",0,"cwin","set","open",0) call notify("capply","pressed",0,"app","return","call SaveConfig('USE')") call notify("cquit","pressed",0,"cwin","set","open",0) call set("lister","active",0) call set("cwin","defaultobject","lister") global.ConfigWindow=1 call add("app","cwin") call GuiInfo("") end if ~OpenWindow("cwin") then call GuiInfo("Can't open config window") call SetGadgets() call set("app","sleep",0) return /***********************************************************************/ SetGadgets: procedure expose global. hserv. i=0; set.i="HostName"; set.i.attr="contents"; set.i.value=hserv.HostName; i=i+1 set.i="port"; set.i.attr="contents"; set.i.value=hserv.Port; i=i+1 set.i="admin"; set.i.attr="contents"; set.i.value=hserv.Admin; i=i+1 set.i="status"; set.i.attr="active"; set.i.value=hserv.Status; i=i+1 set.i="DocumentDir"; set.i.attr="contents"; set.i.value=hserv.DocumentDir; i=i+1 set.i="DocumentIndex"; set.i.attr="contents"; set.i.value=hserv.DocumentIndex; i=i+1 set.i="Signature"; set.i.attr="contents"; set.i.value=hserv.Signature; i=i+1 set.i="Timeout"; set.i.attr="contents"; set.i.value=hserv.Timeout; i=i+1 set.i="KeepAlive"; set.i.attr="value"; set.i.value=hserv.KeepAlive; i=i+1 set.i="SendDelta"; set.i.attr="contents"; set.i.value=hserv.SendDelta; i=i+1 set.i="Pri"; set.i.attr="contents"; set.i.value=hserv.Pri; i=i+1 set.i="CgiDir"; set.i.attr="contents"; set.i.value=hserv.CGIDir; i=i+1 set.i="PerlPath"; set.i.attr="contents"; set.i.value=hserv.PerlPath; i=i+1 set.i="RebolPath"; set.i.attr="contents"; set.i.value=hserv.RebolPath; i=i+1 set.i="CGIMod"; set.i.attr="contents"; set.i.value=hserv.CGIMod; i=i+1 set.i="DisableCGI"; set.i.attr="selected"; set.i.value=hserv.DisableCGI; i=i+1 set.i="auth"; set.i.attr="contents"; set.i.value=hserv.Auth; i=i+1 set.i="rejectedip"; set.i.attr="contents"; set.i.value=hserv.RejectedIP; i=i+1 set.i="mime"; set.i.attr="contents"; set.i.value=hserv.MimeFile; i=i+1 set.i="handlers"; set.i.attr="contents"; set.i.value=hserv.Handlers; i=i+1 set.i="VirtualHosts"; set.i.attr="contents"; set.i.value=hserv.VirtualHosts; i=i+1 set.i="errors"; set.i.attr="contents"; set.i.value=hserv.Errors; i=i+1 set.i="referers"; set.i.attr="contents"; set.i.value=hserv.referers; i=i+1 set.i="specials"; set.i.attr="contents"; set.i.value=hserv.Specials; i=i+1 set.i="TransferLog"; set.i.attr="active"; set.i.value=hserv.TransferLog; i=i+1 set.i="TransferFile"; set.i.attr="contents"; set.i.value=hserv.TransferFile; i=i+1 set.i="ErrorLog"; set.i.attr="active"; set.i.value=hserv.ErrorLog; i=i+1 set.i="ErrorFile"; set.i.attr="contents"; set.i.value=hserv.ErrorFile; i=i+1 set.i="HostNameLookups"; set.i.attr="selected"; set.i.value=hserv.HostNameLookups; i=i+1 set.i="ident"; set.i.attr="selected"; set.i.value=hserv.Ident; i=i+1 set.i="OnlyAmigaClient"; set.i.attr="selected"; set.i.value=hserv.OnlyAmigaClient; i=i+1 set.i="DefImage"; set.i.attr="selected"; set.i.value=hserv.DefImage; i=i+1 set.i="CInfo"; set.i.attr="contents"; if global.ConfigFile="" then set.i.value="No file name" else set.i.value="Editing '"global.ConfigFile"'" call MultiSetAttr("set",0) return /**************************************************************************/ ReadGadgets: procedure expose global. hserv. if ~global.ConfigWindow then return hserv.HostName=xget("HostName","contents") hserv.Port=xget("port","contents") hserv.Admin=xget("admin","contents") hserv.Status=xget("status","active") hserv.DocumentDir=xget("DocumentDir","contents") hserv.DocumentIndex=xget("DocumentIndex","contents") hserv.Signature=xget("Signature","contents") hserv.Timeout=xget("Timeout","contents") hserv.KeepAlive=xget("KeepAlive","value") hserv.SendDelta=xget("SendDelta","contents") hserv.Pri=xget("Pri","contents") hserv.CGIDir=xget("CgiDir","contents") hserv.PerlPath=xget("PerlPath","contents") hserv.RebolPath=xget("RebolPath","contents") hserv.CGIMod=xget("CGIMod","contents") hserv.DisableCGI=xget("DisableCGI","selected") hserv.Auth=xget("auth","contents") hserv.RejectedIP=xget("RejectedIP","contents") hserv.MimeFile=xget("mime","contents") hserv.Handlers=xget("handlers","contents") hserv.VirtualHosts=xget("VirtualHosts","contents") hserv.Errors=xget("errors","contents") hserv.referers=xget("referers","contents") hserv.Specials=xget("specials","contents") hserv.TransferLog=xget("TransferLog","active") hserv.TransferFile=xget("TransferFile","contents") hserv.ErrorLog=xget("ErrorLog","active") hserv.ErrorFile=xget("ErrorFile","contents") hserv.HostNameLookups=xget("HostNameLookups","selected") hserv.Ident=xget("ident","selected") hserv.OnlyAmigaClient=xget("OnlyAmigaClient","selected") hserv.DefImage=xget("DefImage","selected") return /**************************************************************************/ ChangeStatus: procedure expose global. hserv. parse arg what,val select when what="STATUS" then hserv.Status=val when what="DDIR" then hserv.DocumentDir=val when what="DINDEX" then hserv.DocumentIndex=val end return /**************************************************************************/ CopyConfig: procedure expose global. hserv. parse arg from,to interpret to".HostName =" from".HostName" interpret to".Port =" from".Port" interpret to".Admin =" from".Admin" interpret to".Status =" from".Status" interpret to".DocumentDir =" from".DocumentDir" interpret to".CgiDir =" from".CgiDir" interpret to".PerlPath =" from".PerlPath" interpret to".RebolPath =" from".RebolPath" interpret to".CGIMod =" from".CGIMod" interpret to".DisableCGI =" from".DisableCGI" interpret to".DocumentIndex =" from".DocumentIndex" interpret to".Signature =" from".Signature" interpret to".Timeout =" from".Timeout" interpret to".KeepAlive =" from".KeepAlive" interpret to".SendDelta =" from".SendDelta" interpret to".Pri =" from".Pri" interpret to".Auth =" from".Auth" interpret to".RejectedIP =" from".RejectedIP" interpret to".MimeFile =" from".MimeFile" interpret to".Specials =" from".Specials" interpret to".Handlers =" from".Handlers" interpret to".Errors =" from".Errors" interpret to".VirtualHosts =" from".VirtualHosts" interpret to".referers =" from".referers" interpret to".TransferLog =" from".TransferLog" interpret to".TransferFile =" from".TransferFile" interpret to".ErrorLog =" from".ErrorLog" interpret to".ErrorFile =" from".ErrorFile" interpret to".HostNameLookups =" from".HostNameLookups" interpret to".Ident =" from".Ident" interpret to".OnlyAmigaClient =" from".OnlyAmigaClient" interpret to".DefImage =" from".DefImage" return /***************************************************************************/ ReadConfig: procedure expose global. hserv. parse arg file,gui if gui then call set("app","sleep",1) global.error="" global.temp.HostName = "" global.temp.Port = 80 global.temp.Admin = "" global.temp.Status = 0 global.temp.DocumentDir = "" global.temp.CgiDir = "" global.temp.PerlPath = "" global.temp.RebolPath = "" global.temp.CGIMod = "" global.temp.DisableCGI = 0 global.temp.DocumentIndex = "" global.temp.Signature = "" global.temp.Timeout = 300 global.temp.KeepAlive = 4 global.temp.SendDelta = 512 global.temp.Pri = 0 global.temp.Auth = "" global.temp.RejectedIP = "" global.temp.MimeFile = "" global.temp.Specials = "" global.temp.Handlers = "" global.temp.Errors = "" global.temp.VirtualHosts = "" global.temp.referers = "" global.temp.TransferLog = 1 global.temp.TransferFile = "" global.temp.ErrorLog = 2 global.temp.ErrorFile = "" global.temp.HostNameLookups = 0 global.temp.Ident = 0 global.temp.OnlyAmigaClient = 0 global.temp.DefImage = 1 if file=="" then do global.error="No config file found" if gui then call set("app","sleep",0) return 3 end if gui then call GuiInfo("Reading '"file"'...") lines=ParseConfig(file,"CONF") if lines==-1 then do global.error="Config file '"file"' not found" if gui then call set("app","sleep",0) return 2 end /* err severity: 0 ok 1 default 2 nothing ok */ msg="" err=0 do i=0 to lines-1 while err<2 opt=conf.i arg=conf.i.value argu=upper(arg) select when opt=="HOSTNAME" then global.temp.HostName=arg when opt=="PORT" then do if ~DataType(arg,"N") | arg<1 | arg>65535 then do msg=msg||"- %bPORT%n value %b"arg"%n is invalid - switching to default %b80%n\n" err=1 arg=global.temp.port end global.temp.Port=arg if global.sock>-1 then global.temp.port=hserv.Port end when opt=="ADMIN" then global.temp.admin=arg when opt=="STATUS" then do s=find("OPENED PAUSED",argu) if s=0 then do msg=msg||"- %bSTATUS%n value %b"argu"%n is invalid - switching to default %bOPENED%n\n" err=1 s=global.temp.status+1 end global.temp.status=s-1 end when opt=="DOCUMENTDIR" then global.temp.DocumentDir=arg when opt=="DOCUMENTINDEX" then global.temp.DocumentIndex=arg when opt=="SIGNATURE" then global.temp.Signature=arg when opt=="TIMEOUT" then do if ~DataType(arg,"N") | arg<0 then do msg=msg||"- %bTIMEOUT%n value %b"arg"%n is invalid - switching to default %b300%n\n" err=1 arg=global.temp.Timeout end global.temp.Timeout=arg end when opt=="KEEPALIVE" then do if ~DataType(arg,"N") | arg<0 | arg>4 then do msg=msg||"- %bKEEPALIVE%n value %b"arg"%n is invalid - switching to default %b4%n\n" err=1 arg=global.temp.KeepAlive end global.temp.KeepAlive=arg end when opt=="KEEPALIVETIMEOUT" then nop when opt=="SENDDELTA" then do if ~DataType(arg,"N") | arg<0 | arg>8192 then do msg=msg||"- %bSENDDELTA%n value %b"arg"%n is invalid - switching to default %b512%n\n" err=1 arg=global.temp.SendDelta end global.temp.SendDelta=arg end when opt=="PRI" then do if ~DataType(arg,"N") | arg<-127 | arg>3 then do msg=msg||"- %bPRI%n value %b"arg"%n is invalid - switching to default %b0%n\n" err=1 arg=global.temp.Pri end global.temp.Pri=arg end when opt=="CGIDIR" then global.temp.CgiDir=arg when opt=="PERLPATH" then global.temp.PerlPath=arg when opt=="REBOLPATH" then global.temp.RebolPath=arg when opt=="CGIMOD" then global.temp.CGIMod=arg when opt=="DISABLECGI" then do s=find("OFF ON",argu) if s=0 then do msg=msg||"- %bDisableCGI%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=1 end global.temp.DisableCGI=s-1 end when opt=="AUTH" then global.temp.Auth=arg when opt=="REJECTEDIP" then global.temp.RejectedIP=arg when opt=="MIMEFILE" | opt=="MIME" then global.temp.MimeFile=arg when opt=="HANDLERS" then global.temp.Handlers=arg when opt=="VIRTUALHOSTS" then global.temp.VirtualHosts=arg when opt=="ERRORS" then global.temp.Errors=arg when opt=="REFERERS" then global.temp.referers=arg when opt=="SPECIALS" then global.temp.Specials=arg when opt=="TRANSFERLOG" then do s=find("ON OFF SYS",argu) if s=0 then do msg=msg||"- %bTRASFERLOG%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=global.temp.TransferLog+1 end global.temp.TransferLog=s-1 end when opt=="TRANSFERFILE" then global.temp.TransferFile=arg when opt=="ERRORLOG" then do s=find("ON OFF SYS",argu) if s=0 then do msg=msg||"- %bERRORLOG%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=global.temp.ErrorLog+1 end global.temp.ErrorLog=s-1 end when opt=="ERRORFILE" then global.temp.ErrorFile=arg when opt=="HOSTNAMELOOKUPS" then do s=find("OFF ON",argu) if s=0 then do msg=msg||"- %bHOSTNAMELOOKUPS%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=1 end global.temp.HostNameLookups=s-1 end when opt=="IDENT" then do s=find("OFF ON",argu) if s=0 then do msg=msg||"- %bIDENT%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=1 end global.temp.ident=s-1 end when opt=="ONLYAMIGACLIENT" then do s=find("OFF ON",argu) if s=0 then do msg=msg||"- %bONLYAMIGACLIENT%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=1 end global.temp.OnlyAmigaClient=s-1 end when opt=="DEFIMAGE" then do s=find("OFF ON",argu) if s=0 then do msg=msg||"- %bDEFIMAGE%n value %b"arg"%n is invalid - switching to default %bOFF%n\n" err=1 s=1 end global.temp.DefImage=s-1 end otherwise do msg="While parsing '"file"', hserv found the following high serverity error:\n\nUnknonwn option %b"opt"%n in line" conf.i.line if err>0 then msg=msg||"\n\nAre you sure it is a hserv configuration file?" err=2 global.error="Config file '"file"' is invalid" end end end if msg~="" then if gui then do if err<2 then msg="While parsing '"file"', hserv found the following low serverity error(s):\n\n"||msg call CreatePWin(msg) end else global.error=msg if global.temp.ErrorFile=="" & global.temp.ErrorLog~=2 then global.temp.ErrorLog=0 if global.temp.TransferFile=="" & global.temp.TransferLog~=2 then global.temp.TransferLog=0 if gui then call set("app","sleep",0) return err /***************************************************************************/ SetConfig: procedure expose global. hserv. parse arg file res=ReadConfig(file,1) call CopyConfig("GLOBAL.TEMP","HSERV") call CopyConfig("GLOBAL.TEMP","GLOBAL.LAST") if res<2 then do global.ConfigFile=file call GuiInfo("") call CreateNotify() call GuiInfo("File '"file"' read") end else call GuiInfo(global.error) return res /***********************************************************************/ OpenConfig: procedure expose global. hserv. parse arg req select when req=0 then f=global.ConfigFile when req=1 then f=reqF("Select a file to open",0) when req=2 then f=xget("ConfigFile","contents") end if f="" then return res=SetConfig(f) if res<2 then do call SetMainGadgets() if global.ConfigWindowOpened then call SetGadgets() end return /**************************************************************************/ AddConfItem: procedure parse arg item,value if value="" then return "" return left(item || " ",20) || value || "\n" /**************************************************************************/ SaveConfig: procedure expose global. hserv. parse arg where if where~="USE" then do if global.noti~=-1 then do call FreeNotify(global.noti) global.noti=-1 ReNotify=1 end else ReNotify=0 if where="SAVE" then if global.ConfigFile="" then where="SAVEAS" if where="SAVEAS" then do f=reqF("Select a file to save",1) if f="" then return if exists(f) then if ~MUIRequest("app","mwin","hserv","_Ok|*_Cancel",ParseText("File '"f"'\nalready exists.\nDo you want to overwrite it?")) then do if ReNotify then call CreateNotify() return end global.ConfigFile=f end end call CopyConfig("HSERV","GLOBAL.LAST") call ReadGadgets() call SetMainGadgets() if where="USE" then return if global.ConfigWindow then call set("cwin","open",0) call set("app","sleep",1) call GuiInfo("Writing configuration...",1) if ~open("OUT",global.ConfigFile,"W") then do call GuiInfo("Can't open file '"global.file"'") call set("app","sleep",0) return 0 end conf=ParseText(" ## hserv configuration file\n ## created by" hserv.name"/"hserv.ver"\n ##" formatdate(,"%a, %d %b %Y %X")"\n ##\n\n" || , AddConfItem("HostName",hserv.HostName) || , AddConfItem("Port",hserv.Port) || , AddConfItem("Admin",hserv.Admin) || , AddConfItem("Status",word("OPENED PAUSED",hserv.Status+1)) || , AddConfItem("DocumentDir",hserv.DocumentDir) || , AddConfItem("DocumentIndex",hserv.DocumentIndex) || , AddConfItem("Signature",hserv.Signature) || , AddConfItem("Timeout",hserv.Timeout) || , AddConfItem("KeepAlive",hserv.KeepAlive) || , AddConfItem("SendDelta",hserv.SendDelta) || , AddConfItem("CGIDir",hserv.CGIDir) || , AddConfItem("PerlPath",hserv.PerlPath) || , AddConfItem("RebolPath",hserv.RebolPath) || , AddConfItem("CGIMod",hserv.CGIMod) || , AddConfItem("DisableCGI",word("OFF ON",hserv.DisableCGI+1)) || , AddConfItem("Auth",hserv.Auth) || , AddConfItem("RejectedIP",hserv.RejectedIP) || , AddConfItem("Mime",hserv.MimeFile) || , AddConfItem("Handlers",hserv.Handlers) || , AddConfItem("VirtualHosts",hserv.VirtualHosts) || , AddConfItem("Errors",hserv.Errors) || , AddConfItem("Referers",hserv.Referers) || , AddConfItem("Specials",hserv.Specials) || , AddConfItem("TransferLog",word("ON OFF SYS",hserv.TransferLog+1)) || , AddConfItem("TransferFile",hserv.TransferFile) || , AddConfItem("ErrorLog",word("ON OFF SYS",hserv.ErrorLog+1)) || , AddConfItem("ErrorFile",hserv.ErrorFile) || , AddConfItem("HostNameLookups",word("OFF ON",hserv.HostNameLookups+1)) || , AddConfItem("Ident",word("OFF ON",hserv.Ident+1)) || , AddConfItem("OnlyAmigaClient",word("OFF ON",hserv.OnlyAmigaClient+1)) || , AddConfItem("DefImage",word("OFF ON",hserv.DefImage+1))) if WriteCh("OUT",conf)~=length(conf) then call GuiInfo("Error writing") else call GuiInfo("Configuration saved") call close("OUT") if ReNotify then call CreateNotify() call set("app","sleep",0) return 1 /**************************************************************************/ RestoreConfig: procedure expose global. hserv. call CopyConfig('GLOBAL.LAST','HSERV') call SetMainGadgets() if global.ConfigWindowOpened then call SetGadgets() return /**************************************************************************/ StackInfo: procedure expose global. hserv. parse arg msg,level if global.quiet then return if arg(2,'o') then level="ERR" call SysLog(msg,level) return /***********************************************************************/ GuiInfo: procedure expose global. hserv. parse arg msg,ntstore if msg=="" then msg=global.OldInfo else if ntstore~=1 then global.OldInfo=msg call set("info","contents",msg) return /**************************************************************************/ ReqF: procedure expose global. hserv. parse arg t,sm f.title=t if sm="" then sm=0 f.DoSaveMode=sm f.drawer=pathpart(global.configfile) f.file=filepart(global.configfile) f.window="mwin" call set("app","sleep",1) res=ReqFile("F") call set("app","sleep",0) if res~=-1 then do if f.file~="" then f.file=AddPart(f.drawer,f.file) call set("app","sleep",0) return f.file end return "" /**************************************************************************/ FindFreePort: procedure expose global. hserv. if ~IsLibOn("SOCKET") then do call GuiInfo("No TCP/IP stack is running.") call set("lamp","color","error") return 0 end call set("app","sleep",1) s=socket("inet","stream") if s>=0 then do do l.AddrPort=80 to 65535 while bind(s,"L")<0;end if l.AddrPort=65536 then msg="All ports busy !?!" else do call set("MainPort","contents",l.AddrPort) msg="The first suitable port is:" l.AddrPort end call CloseSocket(s) end else msg="Can't create socket" call GuiInfo(msg) call set("app","sleep",0) return /**************************************************************************/ CheckPort: procedure expose global. hserv. parse arg port if port="" then return 0 if DataType(port,"N") then return (port>0 & port<65536) return 0 /**************************************************************************/ CreateBar: procedure expose global. parse arg name,dir,dis bar.Borderless=xget("bl","Selected") bar.SmallImages=xget("si","Selected") bar.RaisingFrame=xget("rf","Selected") bar.Sunny=xget("sn","Selected") bar.ViewMode=xget("vm","Active") bar.Horiz=1 bar.SameHeight=1 bar.SameWidth=1 bar.StripUnderscore=1 bar.ImagesDrawer=dir bar.Spacer="spacer" bar.0.Img="open" bar.0.Text="Open" bar.1.Img="close" bar.1.Text="Close" if dis then bar.1.Flags="disabled" bar.2.Img="break" bar.2.Text="Break" if dis then bar.2.Flags="disabled" bar.3.Img="SPACER" bar.4.Img="edit" bar.4.Text="Edit" return XNewObj("speedbar",name,"bar") /**************************************************************************/ BarConfigObject: procedure expose global. bcg.Class="group" g.Class="group" g.Columns=4 g.0=Label("_BorderLess") bl.CycleChain=1 bl.ObjectID=1 g.1=CheckMark("bl",,'b') g.2=Label("_RaisingFrame") rf.CycleChain=1 rf.ObjectID=2 g.3=CheckMark("rf",,'r') g.4=Label("S_mallImages") si.CycleChain=1 si.ObjectID=3 g.5=CheckMark("si",,'m') g.6=Label("Sunn_y") sn.CycleChain=1 sn.ObjectID=4 g.7=CheckMark("sn",,'y') bcg.0=XNewObj("Group","","g") vm.CycleChain=1 vm.ObjectID=5 bcg.1=MakeObj("vm","Cycle","TextGfx|Gfx|Text") global.BarConfigObject=XNewObj("Group","","bcg") return (global.BarConfigObject~="") /**************************************************************************/ OpenHservConfigWindow: procedure expose global. hserv. if RxMUIObjExists("hcwin") then do call set("hcwin","open",1) return end call set("app","sleep",1) call GuiInfo("Creating hserv config window...",1) hcwin.ID="HWIN" hcwin.Title=hserv.name "preferences" hcwin.Contents="hmgroup" hmgroup.0="chg" chg.Class="group" chg.Horiz=1 chg.HorizSpacing=4 chg.0="hlister" hlister.Class="listview" hlister.FixWidthTxt="123456789012" hlister.List="hlist" hlister.CycleChain=1 hlist.Class="listtree" hlist.Frame="inputlist" hlist.0="Bar" chg.1="hpager" hpager.Class="group" hpager.PageMode=1 hpager.Frame="readlist" hpager.background="PageBack" hpager.0=vspace() BarPage.Class="group" BarPage.0=MakeObj(,"HLeft",CreateBar("csb",global.images,0)) BarPage.1=HBar() BarPage.2=global.BarConfigObject hpager.1=MakeObj(,"VCenter",MakeObj(,"HCenter","BarPage")) hmgroup.1="hcbg" hcbg.Class="group" hcbg.Horiz=1 hcsave.CycleChain=1 hcbg.0=Button("hcsave","_Save") hcbg.1=hspace() hcuse.CycleChain=1 hcbg.2=Button("hcuse","_Use") hcbg.3=hspace() hccancel.CycleChain=1 hcbg.4=Button("hccancel","_Cancel") if NewObj("window","hcwin")>0 then do call GuiInfo("Can't create gui config window") return end call Add("app","hcwin") call Notify("hcwin","CloseRequest",1,"_self","set","open",0) call Notify("hlist","ActiveID","everytime","hpager","set","activepage","triggervalue") call Notify("hcuse","Pressed",0,"hcwin","Set","Open",0) call Notify("hcuse","Pressed",0,"app","Return","call UseConfig(0)") call Notify("hcsave","Pressed",0,"hcwin","Set","Open",0) call Notify("hcsave","Pressed",0,"app","Return","call UseConfig(1)") call Notify("hccancel","Pressed",0,"hcwin","Set","Open",0) call Notify("bl","Selected","EveryTime","csb","Set","BorderLess","TriggerValue") call Notify("rf","Selected","EveryTime","csb","Set","RaisingFrame","TriggerValue") call Notify("si","Selected","EveryTime","csb","Set","SmallImages","TriggerValue") call Notify("sn","Selected","EveryTime","csb","Set","Sunny","TriggerValue") call Notify("vm","Active","everytime","csb","Set","ViewMode","triggervalue") call set("hlist","ActiveID",1) call set("hcwin","defaultobject","hlister") if ~OpenWindow("hcwin") then call GuiInfo("Can't open gui config window") else call GuiInfo("") call set("app","sleep",0) return /**************************************************************************/ UseConfig: procedure expose global. parse arg save set.ViewMode=xget("vm","Active") set.SmallImages=xget("si","selected") set.BorderLess=xget("bl","selected") set.RaisingFrame=xget("rf","selected") set.Sunny=xget("sn","selected") call DoMethod("sbar","InitChanges") call SetAttrs("sbar","set") call DoMethod("sbar","ExitChanges") if save then call DoMethod("app","Save","Envarc") else call DoMethod("app","Save","Env") return /**************************************************************************/ OpenWindow: procedure parse arg win call set(win,"Open",1) if ~xget("app","Iconified") then return xget(win,"Open") return 1 /**************************************************************************/ /* $VER: hserv.rexx 33.0 (27.11.2001)*/