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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-20 20:28:19 +02:00
|
|
|
void Functions::AddFun(int code, const char * url)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-05-20 20:28:19 +02:00
|
|
|
fun.code = code;
|
|
|
|
fun.item.url = url;
|
|
|
|
table.insert( std::make_pair(fun.item.url, fun) );
|
|
|
|
}
|
2008-12-31 14:36:46 +01:00
|
|
|
|
2008-12-31 19:28:12 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-05-20 20:28:19 +02:00
|
|
|
// in the future we will read these functions from the database
|
|
|
|
void Functions::ReadFunctions()
|
|
|
|
{
|
|
|
|
Clear();
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-05-20 20:28:19 +02:00
|
|
|
fun.item.user_id = -1;
|
|
|
|
fun.item.group_id = -1;
|
|
|
|
fun.item.privileges = 0755;
|
|
|
|
fun.item.parent_id = -1; // !! temporarily doesn't matter
|
|
|
|
fun.item.id = -1;
|
|
|
|
fun.item.type = Item::file;
|
2010-02-16 19:34:41 +01:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
|
2010-05-20 20:28:19 +02:00
|
|
|
AddFun(FUN_LS, "ls");
|
|
|
|
AddFun(FUN_CAT, "cat");
|
|
|
|
AddFun(FUN_NODE, "node");
|
|
|
|
AddFun(FUN_EMACS, "emacs");
|
|
|
|
AddFun(FUN_MKDIR, "mkdir");
|
|
|
|
AddFun(FUN_DEFAULT, "default");
|
|
|
|
AddFun(FUN_PRIV, "priv");
|
|
|
|
AddFun(FUN_RM, "rm");
|
|
|
|
AddFun(FUN_LOGOUT, "logout");
|
|
|
|
AddFun(FUN_LOGIN, "login");
|
|
|
|
AddFun(FUN_RUN, "run");
|
|
|
|
AddFun(FUN_WHO, "who");
|
|
|
|
AddFun(FUN_LAST, "last");
|
|
|
|
AddFun(FUN_CREATETHREAD, "createthread");
|
|
|
|
AddFun(FUN_THREAD, "thread");
|
|
|
|
AddFun(FUN_UPLOAD, "upload");
|
|
|
|
AddFun(FUN_CREATETICKET, "createticket");
|
|
|
|
AddFun(FUN_EDITTICKET, "editticket");
|
|
|
|
AddFun(FUN_TICKET, "ticket");
|
|
|
|
AddFun(FUN_UPTIME, "uptime");
|
|
|
|
AddFun(FUN_MV, "mv");
|
|
|
|
AddFun(FUN_UNAME, "uname");
|
|
|
|
AddFun(FUN_CHMOD, "chmod");
|
|
|
|
AddFun(FUN_CHOWN, "chown");
|
|
|
|
AddFun(FUN_CKEDITOR, "ckeditor");
|
|
|
|
AddFun(FUN_DOWNLOAD, "download");
|
|
|
|
AddFun(FUN_ADDUSER, "adduser");
|
|
|
|
AddFun(FUN_SUBJECT, "subject");
|
2010-06-03 19:38:18 +02:00
|
|
|
AddFun(FUN_CP, "cp");
|
2010-06-21 00:47:24 +02:00
|
|
|
AddFun(FUN_TINYMCE, "tinymce");
|
2010-02-19 00:30:22 +01:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2009-11-16 18:43:23 +01:00
|
|
|
// functions which need more privileges
|
2010-05-20 20:28:19 +02:00
|
|
|
fun.item.privileges = 0700;
|
2009-11-16 18:43:23 +01:00
|
|
|
|
2010-05-20 20:28:19 +02:00
|
|
|
AddFun(FUN_RELOAD, "reload");
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|