2009-04-21 01:49:28 +02:00
|
|
|
/*
|
|
|
|
* 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");
|
2009-06-05 22:29:06 +02:00
|
|
|
break;
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
sprintf(buffer, "the name is not set");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool Mount::ParseStrParam(const std::string & param, const std::vector<int> & args)
|
2009-04-21 01:49:28 +02:00
|
|
|
{
|
|
|
|
Param p = none;
|
|
|
|
|
|
|
|
if( param == "asc" )
|
|
|
|
p = asc;
|
|
|
|
else
|
|
|
|
if( param == "desc" )
|
|
|
|
p = desc;
|
|
|
|
else
|
2009-06-05 22:29:06 +02:00
|
|
|
if( param == "withheader" )
|
|
|
|
p = withheader;
|
|
|
|
else
|
|
|
|
if( param == "withinfo" )
|
|
|
|
p = withinfo;
|
|
|
|
else
|
2009-06-07 04:40:27 +02:00
|
|
|
if( param == "thread_with_header" )
|
|
|
|
p = thread_with_header;
|
|
|
|
else
|
|
|
|
if( param == "thread_with_info" )
|
|
|
|
p = thread_with_info;
|
|
|
|
else
|
2009-06-05 22:29:06 +02:00
|
|
|
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
|
2009-04-21 01:49:28 +02:00
|
|
|
if( param == "none" )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
param_table.insert( std::make_pair(p, args) );
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Mount::IsParam(Param p)
|
|
|
|
{
|
2009-06-05 22:29:06 +02:00
|
|
|
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);
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
if( i == param_table.end() )
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
|
|
|
*first_arg = -1;
|
2009-04-21 01:49:28 +02:00
|
|
|
return false;
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !i->second.empty() )
|
|
|
|
*first_arg = i->second[0];
|
|
|
|
else
|
|
|
|
*first_arg = -1;
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-06-05 22:29:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Mount::ClearParams()
|
|
|
|
{
|
|
|
|
param_table.clear();
|
|
|
|
}
|