implement Pgfuncs; include "sys.m"; sys : Sys; include "draw.m"; include "bufio.m"; bufio: Bufio; Iobuf: import bufio; include "pgbase.m"; pgbase :PgBase; Connection : import pgbase; include "pg_catalogue.m"; pgcatalogue : PgCatalogue; Catalogue : import pgcatalogue; include "factotum.m"; auth : Factotum; # I did try Pgfuncs: module { init: fn(ctxt: ref Draw->Context, args: list of string); }; debug : con 0; err_chan : chan of string; logger() { txt : string; while((txt = <- err_chan) != nil) { if(debug) sys->print("%s\n", txt); } if(debug) sys->print("Closing\n"); } init(nil: ref Draw->Context, args: list of string) { sys = load Sys Sys->PATH; auth = load Factotum Factotum->PATH; auth->init(); pgcatalogue = load PgCatalogue "pg_catalogue.dis"; err_chan = chan of string; spawn logger(); if(len args != 6) { sys->print("usage : pgfuncs ip port username password database"); return; } ip := hd tl args; port := hd tl tl args; username := hd tl tl tl args; password := hd tl tl tl tl args; database := hd tl tl tl tl tl args; (user, pass) := auth->getuserpasswd("server=" + ip + " service=pgsql user=" + username); if(user != nil) err_chan <- = "password correct from factotum"; conn := pgcatalogue->new_connection(ip, port, username, password, database, nil, nil); cat := pgcatalogue->new_catalogue(conn); if(cat == nil) raise "catalogue creation failed"; cat.err_chan = err_chan; (err, u) := cat.user_sysid("webmaster"); if(err == nil) cat.print_procs(u); pgcatalogue->disconnect(conn); } # Put Limbo pgfuncs ; kill Do; kill PgBase