parsav  Diff

Differences From Artifact [350801ad24]:

To Artifact [aed7239c9c]:


    24     24   	var fr = lib.file.open(befile, [lib.file.mode.read])
    25     25   	if fr.ok == false then
    26     26   		lib.bail('could not open configuration file ', befile)
    27     27   	end
    28     28   
    29     29   	var f = fr.val
    30     30   	var c: lib.mem.vec(lib.store.source) c:init(8)
    31         -	var text: lib.string.acc text:init(64)
           31  +	var text: lib.str.acc text:init(64)
    32     32   	do var buf: int8[64]
    33     33   		while true do
    34     34   			var ct = f:read(buf, [buf.type.N])
    35     35   			if ct == 0 then break end
    36     36   			text:push(buf, ct)
    37     37   		end
    38     38   	end
................................................................................
    92     92   	s.sources = c:crush()
    93     93   end
    94     94   
    95     95   --srv.methods.conf_set = terra(self: &srv, key: rawstring, val:rawstring)
    96     96   --	self.sources.ptr[0]:conf_set(key, val)
    97     97   --end
    98     98   
           99  +terra srv:actor_auth_how(ip: lib.store.inet, usn: rawstring)
          100  +	var cs: lib.store.credset cs:clear()
          101  +	for i=0,self.sources.ct do
          102  +		var set: lib.store.credset = self.sources.ptr[i]:actor_auth_how(ip, usn)
          103  +		cs = cs + set
          104  +	end
          105  +	return cs
          106  +end
    99    107   srv.metamethods.__methodmissing = macro(function(meth, self, ...)
   100         -	local primary, ptr, stat, simple = 0,1,2,3
          108  +	local primary, ptr, stat, simple, oid = 0,1,2,3,4
   101    109   	local tk, rt = primary
   102    110   	local expr = {...}
   103    111   	for _,f in pairs(lib.store.backend.entries) do
   104    112   		local fn = f.field or f[1]
   105    113   		local ft = f.type or f[2]
   106    114   		if fn == meth then
   107    115   			rt = ft.type.returntype
   108    116   			if rt == bool then tk = simple
          117  +			elseif rt.type == 'integer' then tk = oid
   109    118   			elseif rt.stat_basetype then tk = stat
   110    119   			elseif rt.ptr_basetype then tk = ptr end
   111    120   			break
   112    121   		end
   113    122   	end
   114    123   	
   115    124   	if tk == primary then
................................................................................
   116    125   		return `self.sources.ptr[0]:[meth]([expr])
   117    126   	else local ok, empty
   118    127   		local r = symbol(rt)
   119    128   		if tk == ptr then
   120    129   			ok = `r.ptr ~= nil
   121    130   			empty = `[rt]{ptr=nil,ct=0}
   122    131   		elseif tk == stat then
   123         -			ok = `r.ok ~= false
          132  +			ok = `r.ok == true
   124    133   			empty = `[rt]{ok=false,error=1}
   125    134   		elseif tk == simple then
   126    135   			ok = `r == true
   127    136   			empty = `false
          137  +		elseif tk == oid then
          138  +			ok = `r ~= 0
          139  +			empty = `0
   128    140   		end
   129    141   		return quote
   130    142   			var [r] = empty
   131    143   			for i=0,self.sources.ct do var src = self.sources.ptr + i
   132    144   				if src.handle ~= nil then
   133    145   					r = src:[meth]([expr])
   134    146   					if [ok] then break
................................................................................
   159    171   	elseif dbbind.ptr ~= nil then
   160    172   		bind = dbbind.ptr
   161    173   	else bind = '[::]:10917' end
   162    174   
   163    175   	lib.report('binding to ', bind)
   164    176   	lib.net.mg_mgr_init(&self.webmgr)
   165    177   	self.webcon = lib.net.mg_http_listen(&self.webmgr, bind, handle.http, nil)
   166         -	dbbind:free()
          178  +
   167    179   
          180  +	if dbbind.ptr ~= nil then dbbind:free() end
   168    181   end
   169    182   
   170    183   srv.methods.poll = terra(self: &srv)
   171    184   	lib.net.mg_mgr_poll(&self.webmgr,1000)
   172    185   end
   173    186   
   174    187   srv.methods.shutdown = terra(self: &srv)