/*    .(  script(                        core) .
      .( version(                        01r4) .
      .(  author(                       daedo) .
      .(   email(         cosmith@mix-net.net) .
      .(     www(  http://daedo.hypermart.net) .   */

/* version and client checking */

if (bitchx(0) != 1) { echo BitchX 75p1+ is needed for core to load...; quit core!bx }
if (V < 19980221) { echo BitchX 75p1+ is needed for core to load...; quit core!bx }

/* initiallizing status bar variables and aliases */

@prog=[0]
@perc=[0]
alias percbar {   
        @prog++
        @perc = perc + 5
        ^set input_prompt $cparse("%c[%C$[20]repeat($prog þ)%c]%c-%c\[%w$([3]perc)")%%%c]-[%wloading core.bx%c] 
}
percbar

/* script and client settings */

set auto_away off
set msglog off
set show_channel_names off
set mangle_inbound ansi
set client_information  segmentation fault, core dumped.
set nick_completion off
set nick_completion_char :
set dcc_bar_type 1
percbar
@cl   = [\[0m]
@blk  = [\[0;30m]
@red  = [\[0;31m]
@grn  = [\[0;32m]
@yel  = [\[0;33m]
@blu  = [\[0;34m]
@mag  = [\[0;35m]
@cyn  = [\[0;36m]
@wht  = [\[0;37m]
@hblk = [\[1;30m]
@hred = [\[1;31m]
@hgrn = [\[1;32m]
@hyel = [\[1;33m]
@hblu = [\[1;34m]
@hmag = [\[1;35m]
@hcyn = [\[1;36m]
@hwht = [\[1;37m]
@bwht = [\[47m]  
@bmag = [\[45m]  
@bblu = [\[44m]  
@bred = [\[41m]  
@bblk = [\[40m]  
@bgrn = [\[42m]  
@byel = [\[43m]  
@bcyn = [\[46m]
percbar  
@altnick        = [$(N)_]
@defumode       = [+iw]
percbar
@ delarray(rwin)
@ delarray(rmsg)
@ delarray(rnot)
@ delarray(smsg)
@ delarray(snot)
@ rstat         = [0]
percbar
@c1             = hcyn
@c2             = cyn
@c3             = wht
@c4             = hblk
percbar
@actionform     = [1]
@abotform       = [1]
@awayform       = [1]
@boxesform      = [1]
@cdccform       = [1]
@colorsform     = [6]
@ctcpform       = [1]
@ctcprform      = [1]
@dccform        = [1]
@estringform    = [1]
@joinform       = [1]
@killform       = [1]
@kickform       = [1]
percbar
@kstringform    = [1]
@modeform       = [1]
@msgform        = [1]
@ncompform      = [1]
@nickform       = [1]
@noticeform     = [1]
@partform       = [1]
@pubform        = [1]
@qstringform    = [1]
@quitform       = [1]
@sactionform    = [1]
@sbarform       = [1]
@scform         = [1]
@sctcpform      = [1]
@sdccform       = [1]
@smsgform       = [1]
@snoticeform    = [1]
@spubform       = [1]
@svform         = [1]
@wallform       = [1]
@whoisform      = [1]
percbar
@corelog        = [core.log]
@modpath        = [~/core/modules/]
@formpath       = [~/core/formats/]
@themepath      = [~/core/themes/]
@corepath       = [~/core/]
@savefile       = [~/.core.save]
@fsavefile      = [~/.core.fsave]
@csavefile      = [~/.core.csave]
@bsavefile      = [~/.core.bsave]
@fsetfile       = [$formpath] ## [fsets]
@scriptname     = [core]
@scriptversion  = [01r4]
@scriptauthor   = [daedo]
@internalversion= [1.4]

/* modular settings aliases */

@delarray(set)
^assign -setlist
alias addset {
        if (!match($before(& $0) $setlist)) {
                @ setitem(set 0 *)
                @ setitem(set $numitems(set) $0-)
                ^push setlist $before(& $0-)
                if ([$($before(& $0))] == []) {
                        @ $before(& $0) = [$after(& $0)]
                }
        }
}

@delarray(chelp)
^assign -helplist
percbar
alias addhelp {
        if (!match($before(& $0) $helplist)) {
                @ setitem(chelp 0 *)      
                @ setitem(chelp $numitems(chelp) $0-)
		^push helplist $before(& $0-)
        }
}


percbar
@delarray(sconf)
@delarray(tconf)
^assign -configlist
alias addconf {
	if (!match(before(& $1) $configlist)) {
		if ([$0] == [-s]) {
			@ setitem(sconf 0 *)
			@ setitem(sconf $numitems(sconf) $1-)
		}
		if ([$0] == [-t]) {
			@ setitem(tconf 0 *)
			@ setitem(tconf $numitems(tconf) $1-)
		}
		^push configlist $before(& $1-)
	}
}


alias restub {
        ^alias -$0
        makestub $0 $1
}


alias makestub {
        ^stub alias $0 $modpath$1
}


alias modprobe {
        if ([$0]) {
                if (!match($0 $nomods)) {
                        @module = [$(modpath)$0]
                        ^load $module 
                        if (!match($after($count(/ $module) / $module) $mods)) {
	                        push mods $after($count(/ $module) / $module)
			}
                }
        }
        {
                fe ($glob($(corepath)modules\/*.m)) module {
                        if (!match($after($count(/ $module) / $module) $nomods)) { 
                                ^load $module 
                                if (!match($after($count(/ $module) / $module) $mods)) {
                                        push mods $after($count(/ $module) / $module)   
                                }
                        }
                }
        }
}

^eval load $csavefile
^eval load $savefile 
percbar
^modprobe
percbar
^stubprobe
percbar
^loadset
^eval load $csavefile
^eval load $savefile
^eval load $bsavefile
percbar
^eval load $fsavefile
percbar


alias loadformats {
        ^load $(formpath)colors/colors$colorsform
        ^eval load $fsetfile
        ^load $(formpath)estring/estring$estringform
        ^load $(formpath)action/action$actionform
	^load $(formpath)abot/abot$abotform
        ^load $(formpath)away/away$awayform
        ^load $(formpath)boxes/boxes$boxesform
        ^load $(formpath)cdcc/cdcc$cdccform
        ^load $(formpath)ctcp/ctcp$ctcpform
        ^load $(formpath)ctcpr/ctcpr$ctcprform
        ^load $(formpath)dcc/dcc$dccform
        ^load $(formpath)estring/estring$estringform
        ^load $(formpath)join/join$joinform
        ^load $(formpath)kick/kick$kickform
        ^load $(formpath)kill/kill$killform
        ^load $(formpath)kstring/kstring$kstringform
        ^load $(formpath)mode/mode$modeform
        ^load $(formpath)msg/msg$msgform
        ^load $(formpath)ncomp/ncomp$ncompform
        ^load $(formpath)nick/nick$nickform
        ^load $(formpath)notice/notice$noticeform
        ^load $(formpath)part/part$partform
        ^load $(formpath)pub/pub$pubform
        ^load $(formpath)qstring/qstring$qstringform
        ^load $(formpath)quit/quit$quitform
        ^load $(formpath)saction/saction$sactionform
        ^load $(formpath)sbar/sbar$sbarform
        ^load $(formpath)sc/sc$scform
        ^load $(formpath)sctcp/sctcp$sctcpform
        ^load $(formpath)sdcc/sdcc$sdccform
        ^load $(formpath)smsg/smsg$smsgform
        ^load $(formpath)snotice/snotice$snoticeform
        ^load $(formpath)spub/spub$spubform
        ^load $(formpath)sv/sv$svform
        ^load $(formpath)wall/wall$wallform
        ^load $(formpath)whois/whois$whoisform
}
percbar
if (autocdcc == [on]) {
	^cdcc doffer *
	^cdcc load
}
percbar
set auto_away off
set mangle_inbound ansi
percbar
if ([$autosave] == [on]) {                             
        ^botload sil
}
percbar
^loadformats
^keybind
^core
^eval xecho -b $(scriptname).$(scriptversion) by $scriptauthor loaded.
