Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
ASSS dir (DOS) equivalent

 
Post new topic   Reply to topic Printable version
 View previous topic  Some kind of infinite loop Post :: Post Friendly Damage  View next topic  
Author Message
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sun Apr 13, 2003 7:45 pm    Post subject: ASSS dir (DOS) equivalent Reply to topic Reply with quote

Does ASSS (or subgame for that matter, im such a newbie) support a command akin to "dir" to list the contents of the directories? That would be really nifty... plus, could someone describe the putfile/getfile system for ASSS... with all those direcotries things are bound to get messy, right?!?!?!
_________________
Signatures just seem so quaint.
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sun Apr 13, 2003 9:52 pm    Post subject: Reply to topic Reply with quote

Without doing any debugging on the code, you can use the following crappy code on a Win32 machine (hopefully). Just pop it into playercmd.c, and set the command access in the conf/ folder (probably conf/svs/groupdef.dir/sysop file).

Code: Show/Hide
local void Cdir(const char *params, Player *p, const Target *target)
{
   /* Just opens 'dir' command as a pipe and sends data back to user */
   FILE *f = _popen("dir", "r");
   char str[255];

   while (!foef(f))
   {
      if (fgets(str, sizeof(str), f) != NULL)
         chat->SendMessage(p, "%s", str);
   }
   _pclose(f);
}


As for linux, someone else can make a cross-platform command. A better method would be to use the same code that is used for the Arena Listing, and instead of looking for just folders, display all files.

BTW: I recommend NEVER passing the arguments of a command to a pipe/system call unless you REALLY know what your doing. Someone could easily make it change the command to something else that they may want, such as a delete command, etc.
Back to top
View users profile Send private message Add User to Ignore List Send email
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sun Apr 13, 2003 10:24 pm    Post subject: Reply to topic Reply with quote

obviously, allowing custom access to any filesystem command is a very bad thing. I appreciate the code... nifty. It always sucked having junk on there you cant remember you named this or that... or that you never knew existed.

still, any explanation of how ASSS handles all those folders?
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Mon Apr 14, 2003 11:12 pm    Post subject: Reply to topic Reply with quote

Handles all the folders? Having folders keeps it organized. That way maps can be in a maps/ folder, arenas in its own folder, etc.

If you mean how does ASSS handle file sendings? Right now, this is the code in admincmd.c (i believe will be in next public release):

Code: Show/Hide
local helptext_t getfile_help =
"Targets: none\n"
"Args: <filename>\n"
"Transfers the specified filefrom the server to the client.\n"
"The filename should include the full relative path from the server's\n"
"base directory.\n";

local void Cgetfile(const char *params, Player *p, const Target *target)
{
   const char *t1 = strrchr(params, '/');
   const char *t2 = strrchr(params, '\\');
   if (t2 > t1) t1 = t2;
   t1 = t1 ? t1 + 1 : params;

   if (params[0] == '/' || strstr(params, ".."))
      lm->LogP(L_MALICIOUS, "playercmd", p, "Attempted ?getfile with bad path: '%s'", params);
   else
      filetrans->SendFile(p, params, t1, 0);
}


So either you setup a nice ftp, or you start to memorize where all the files are. If you mean how does ASSS deal with browsing folders, its in the playercmd.c's Carena function. Directory listings can be found there (snipet of code follows for lazy people).

Code: Show/Hide
#ifndef WIN32
      char aconf[PATH_MAX];
      DIR *dir = opendir("arenas");
      if (dir)
      {
         struct dirent *de;
         while ((de = readdir(dir)))
         {
            /* every arena must have an arena.conf. this filters out
             * ., .., CVS, etc. */
            snprintf(aconf, PATH_MAX, "arenas/%s/arena.conf", de->d_name);
            if (
                  (pos-buf+strlen(de->d_name)) < 480 &&
                  access(aconf, R_OK) == 0 &&
                  (de->d_name[0] != '#' || seehid) &&
                  check_arena(buf, pos-buf, de->d_name)
               )
            {
               l = strlen(de->d_name) + 1;
               strncpy(pos, de->d_name, l);
               pos += l;
               *pos++ = 0;
               *pos++ = 0;
            }
         }
         closedir(dir);
      }
#else
      char aconf[PATH_MAX];
      struct _finddata_t fi;
      long FH = _findfirst("arenas/*", &fi);
      if (FH != -1)
      {
         do
         {
            if ((fi.attrib & _A_SUBDIR) &&
                strcmp(fi.name, "..") &&
                strcmp(fi.name, "."))
            {
               /* every arena must have an arena.conf */
               snprintf(aconf, PATH_MAX, "arenas/%s/arena.conf", fi.name);
               if (
                     (pos-buf+strlen(fi.name)) < 480 &&
                     access(aconf, R_OK) == 0 &&
                     (fi.name[0] != '#' || seehid) &&
                     check_arena(buf, pos-buf, fi.name)
                  )
               {
                  l = strlen(fi.name) + 1;
                  strncpy(pos, fi.name, l);
                  pos += l;
                  *pos++ = 0;
                  *pos++ = 0;
               }
            }
         } while (_findnext(FH,&fi) != -1);
         _findclose(FH);
      }
#endif
Back to top
View users profile Send private message Add User to Ignore List Send email
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Apr 15, 2003 4:11 pm    Post subject: Reply to topic Reply with quote

Anyone think of builgin FTP in?
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Apr 15, 2003 4:24 pm    Post subject: Reply to topic Reply with quote

Why would you built FTP into a subspace server? Since the server will most likely be running on a linux machine (talking about actual hosting, not on a cable modem), you have WAY more options on how to protect the files, setup remote access, shell access, etc.
Back to top
View users profile Send private message Add User to Ignore List Send email
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Tue Apr 15, 2003 4:30 pm    Post subject: Reply to topic Reply with quote

Agreed, no need to reinvent the wheel. Especially if the reinvented one isn't as good.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Apr 15, 2003 5:07 pm    Post subject: Reply to topic Reply with quote

i didnt consider Linux
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 654 page(s) served in previous 5 minutes.

phpBB Created this page in 0.799037 seconds : 33 queries executed (84.3%): GZIP compression disabled