1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2 * Copyright (C) 2003-2004 Martin Baehr
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * $Id: debug.pike.in,v 1.1 2009/09/28 14:19:52 nicke Exp $
20 inherit "applauncher.pike";
21 //inherit "/usr/local/lib/steam/server/modules/groups.pike";
22 class edit : public applauncher.pike{
27 void ping(string host, string port, string user, string|void pw)
29 call_out(ping, 10, host, port, user, pw);
30 mixed a = conn->send_command(14, 0);
31 if (a=="sTeam connection lost.")
33 conn = ((program)"client_base.pike")();
35 if (conn->connect_server(host, port) && user != "guest")
37 if(conn->send_command(14,0)!="sTeam connection lost.")
39 conn->login(user, pw, 1);
40 _Server=conn->SteamObj(0);
41 user_obj = _Server->get_module("users")->lookup(options->user);
42 gp = user_obj->get_groups();
51 mapping conn_options = ([]);
52 object _Server,user_obj,file;
55 int main(int argc, array argv)
59 // program pGroup = (program)"/classes/Group.pike";
60 mapping options=init(argv);
61 // gp=_Server->get_module("groups")->lookup("helloworld");
62 _Server=conn->SteamObj(0);
63 user_obj = _Server->get_module("users")->lookup(options->user);
64 gp = user_obj->get_groups();
66 /* WORKING AND GIVING GROUP OBJECTS AND NAMES */
68 write("Listing all groups : \n\n");
69 foreach(gp, object obj) {
70 write("Group "+i+" : "+obj->get_group_name()+".\n");
74 // groups_pgm = ((program)"/usr/local/lib/steam/server/modules/groups.pike")();
75 // gp= _Server->get_module("groups")->lookup(1);
76 /* gp=_Server->get_module("filepath:tree")->path_to_object("/home/WikiGroups");
77 // write(gp->get_group_name());
79 // mystr = gp->get_group_name();
81 // array gps = ({ "Admin" , "coder" , "help" , "PrivGroups" , "WikiGroups" , "sTeam" });
83 return applaunch(file,demo);
88 void get_file_object()
91 if ((string)(int)options->file == options->file)
92 file = conn->find_object(options->file);
93 else if (options->file[0] == '/')
94 file = _Server->get_module("filepath:tree")->path_to_object(options->file);
95 else // FIXME: try to find out how to use relative paths
97 string a = options->file;
99 while(!file && tmp_len!=(len+2)){
100 write("Checking in "+(string)a+"\n");
101 file = _Server->get_module("filepath:tree")->path_to_object(a);
104 string gp_name = gp[tmp_len]->get_group_name();
105 if(gp_name[.. 10] == "WikiGroups.")
107 gp_name=gp_name[11 ..];
108 a = "/wiki/"+gp_name+"/"+options->file;
112 a="/home/"+gp_name+"/"+options->file;
118 if (file->get_class() == "Link")
119 file = file->get_link_object();
122 mapping options = ([ ]);
123 mapping init(array argv)
126 array opt=Getopt.find_all_options(argv,aggregate(
127 ({"host",Getopt.HAS_ARG,({"-h","--host"})}),
128 ({"user",Getopt.HAS_ARG,({"-u","--user"})}),
129 ({"port",Getopt.HAS_ARG,({"-p","--port"})}),
132 foreach(opt, array option)
134 options[option[0]]=option[1];
137 options->host="127.0.0.1";
139 options->user="root";
143 options->port=(int)options->port;
145 options->file = argv[-1];
147 string server_path = "/usr/local/lib/steam";
149 master()->add_include_path(server_path+"/server/include");
150 master()->add_program_path(server_path+"/server/");
151 master()->add_program_path(server_path+"/server/modules/groups.pike");
152 master()->add_program_path(server_path+"/conf/");
153 master()->add_program_path(server_path+"/spm/");
154 master()->add_program_path(server_path+"/server/net/coal/");
156 conn = ((program)"client_base.pike")();
157 // groups_pgm = ((program)"groups.pike")();
158 int start_time = time();
160 werror("Connecting to sTeam server...\n");
161 while ( !conn->connect_server(options->host, options->port) )
163 if ( time() - start_time > 120 )
165 throw (({" Couldn't connect to server. Please check steam.log for details! \n", backtrace()}));
167 werror("Failed to connect... still trying ... (server running ?)\n");
171 if(lower_case(options->user) == "guest")
173 ping(options->host, options->port, options->user);
180 //readln->set_echo( 0 );
183 pw = Input.read_password( sprintf("Password for %s@%s", options->user,
184 options->host), "steam" );
186 //pw=readln->read(sprintf("passwd for %s@%s: ", options->user, options->host));
188 while((err = catch(conn->login(options->user, pw, 1))) && --tries);
189 //readln->set_echo( 1 );
193 werror("Failed to log in!\nWrong Password!\n");
196 ping(options->host, options->port, options->user, pw);