128 lines
2.2 KiB
C++
Executable File
128 lines
2.2 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "functions.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Functions::Clear()
|
|
{
|
|
table.clear();
|
|
}
|
|
|
|
|
|
|
|
void Functions::AddFun(int code, const char * url)
|
|
{
|
|
fun.code = code;
|
|
fun.item.url = url;
|
|
table.insert( std::make_pair(fun.item.url, fun) );
|
|
}
|
|
|
|
|
|
|
|
// in the future we will read these functions from the database
|
|
void Functions::ReadFunctions()
|
|
{
|
|
Clear();
|
|
|
|
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;
|
|
|
|
|
|
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");
|
|
AddFun(FUN_CP, "cp");
|
|
AddFun(FUN_TINYMCE, "tinymce");
|
|
|
|
|
|
// functions which need more privileges
|
|
fun.item.privileges = 0700;
|
|
|
|
AddFun(FUN_RELOAD, "reload");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
Function * Functions::GetFunction(int code)
|
|
{
|
|
Table::iterator i = table.begin();
|
|
|
|
for( ; i != table.end() ; ++i )
|
|
{
|
|
if( i->second.code == code )
|
|
return &(i->second);
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|