2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-30 02:05:03 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "functions.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void Functions::Clear()
|
|
|
|
{
|
|
|
|
table.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Functions::ReadFunctions()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
Function f;
|
|
|
|
|
|
|
|
f.item.user_id = -1;
|
|
|
|
f.item.group_id = -1;
|
2009-11-16 18:43:23 +01:00
|
|
|
f.item.privileges = 0755;
|
2008-12-30 02:05:03 +01:00
|
|
|
f.item.parent_id = -1; // !! temporarily doesn't matter
|
|
|
|
f.item.id = -1;
|
|
|
|
f.item.type = Item::file;
|
|
|
|
|
|
|
|
// in the future we will read these functions from the database
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_LS;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "ls";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_CAT;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "cat";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_NODE;
|
2008-12-30 02:05:03 +01:00
|
|
|
f.item.url = "node";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_EMACS;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "emacs";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_MKDIR;
|
2008-12-31 14:36:46 +01:00
|
|
|
f.item.url = "mkdir";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_DEFAULT;
|
2008-12-31 19:28:12 +01:00
|
|
|
f.item.url = "default";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_PRIV;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "priv";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_RM;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "rm";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_LOGOUT;
|
2009-01-14 21:11:12 +01:00
|
|
|
f.item.url = "logout";
|
2008-12-30 02:05:03 +01:00
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-26 21:49:28 +01:00
|
|
|
f.code = FUN_LOGIN;
|
2008-12-30 02:05:03 +01:00
|
|
|
f.item.url = "login";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2009-01-26 21:49:28 +01:00
|
|
|
|
|
|
|
f.code = FUN_RUN;
|
|
|
|
f.item.url = "run";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
f.code = FUN_WHO;
|
|
|
|
f.item.url = "who";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
f.code = FUN_LAST;
|
|
|
|
f.item.url = "last";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2009-01-26 21:49:28 +01:00
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
f.code = FUN_CREATETHREAD;
|
|
|
|
f.item.url = "createthread";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
|
|
|
f.code = FUN_THREAD;
|
|
|
|
f.item.url = "thread";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
f.code = FUN_UPLOAD;
|
|
|
|
f.item.url = "upload";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2009-11-16 18:43:23 +01:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
f.code = FUN_CREATETICKET;
|
|
|
|
f.item.url = "createticket";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
|
|
|
f.code = FUN_EDITTICKET;
|
|
|
|
f.item.url = "editticket";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
|
|
|
f.code = FUN_TICKET;
|
|
|
|
f.item.url = "ticket";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
f.code = FUN_UPTIME;
|
|
|
|
f.item.url = "uptime";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
|
|
|
f.code = FUN_MV;
|
|
|
|
f.item.url = "mv";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2010-03-15 02:47:26 +01:00
|
|
|
/*
|
2010-02-11 21:56:52 +01:00
|
|
|
f.code = FUN_UNAME;
|
|
|
|
f.item.url = "uname";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2010-02-16 19:34:41 +01:00
|
|
|
*/
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
f.code = FUN_CHMOD;
|
|
|
|
f.item.url = "chmod";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
|
|
|
f.code = FUN_CHOWN;
|
|
|
|
f.item.url = "chown";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2010-02-16 19:34:41 +01:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
f.code = FUN_CKEDITOR;
|
|
|
|
f.item.url = "ckeditor";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2010-02-19 00:30:22 +01:00
|
|
|
f.code = FUN_DOWNLOAD;
|
|
|
|
f.item.url = "download";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2010-02-28 01:08:10 +01:00
|
|
|
f.code = FUN_ADDUSER;
|
|
|
|
f.item.url = "adduser";
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2009-11-16 18:43:23 +01:00
|
|
|
// functions which need more privileges
|
|
|
|
|
|
|
|
f.code = FUN_RELOAD;
|
|
|
|
f.item.url = "reload";
|
|
|
|
f.item.privileges = 0700;
|
|
|
|
table.insert( std::make_pair(f.item.url, f) );
|
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function * Functions::GetFunction(const std::string & name)
|
|
|
|
{
|
|
|
|
Table::iterator i = table.find(name);
|
|
|
|
|
|
|
|
if( i == table.end() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return &(i->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// !! in the future there will be a special container where we can search through the Code object
|
2009-01-26 21:49:28 +01:00
|
|
|
Function * Functions::GetFunction(int code)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
|
|
|
Table::iterator i = table.begin();
|
|
|
|
|
|
|
|
for( ; i != table.end() ; ++i )
|
|
|
|
{
|
|
|
|
if( i->second.code == code )
|
|
|
|
return &(i->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|