winix/core/mount.cpp

125 lines
1.8 KiB
C++
Raw Normal View History

/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa
* All rights reserved.
*
*/
#include "mount.h"
Mount::Mount()
{
type = cms;
dir_id = -1;
}
const char * Mount::TypeToStr()
{
static char buffer[30];
switch( type )
{
case cms:
sprintf(buffer, "cms");
break;
case thread:
sprintf(buffer, "thread");
break;
default:
sprintf(buffer, "the name is not set");
break;
}
return buffer;
}
bool Mount::ParseStrParam(const std::string & param, const std::vector<int> & args)
{
Param p = none;
if( param == "asc" )
p = asc;
else
if( param == "desc" )
p = desc;
else
if( param == "withheader" )
p = withheader;
else
if( param == "withinfo" )
p = withinfo;
else
if( param == "thread_with_header" )
p = thread_with_header;
else
if( param == "thread_with_info" )
p = thread_with_info;
else
if( param == "restrictcreatethread" )
p = restrictcreatethread;
else
if( param == "only_root_can_remove" )
p = only_root_can_remove;
else
if( param == "can_use_emacs_on" )
p = can_use_emacs_on;
else
if( param == "can_use_mkdir_on" )
p = can_use_mkdir_on;
else
if( param == "none" )
return true;
else
return false;
param_table.insert( std::make_pair(p, args) );
return true;
}
bool Mount::IsParam(Param p)
{
ParamTable::iterator i = param_table.find(p);
if( i == param_table.end() )
return false;
return true;
}
bool Mount::IsParam(Param p, int * first_arg)
{
ParamTable::iterator i = param_table.find(p);
if( i == param_table.end() )
{
*first_arg = -1;
return false;
}
if( !i->second.empty() )
*first_arg = i->second[0];
else
*first_arg = -1;
return true;
}
void Mount::ClearParams()
{
param_table.clear();
}