moved winix directories to winixdsubdirectory
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1028 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
28
winixd/plugins/group/Makefile
Normal file
28
winixd/plugins/group/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
name = group.so
|
||||
|
||||
|
||||
all: $(name)
|
||||
|
||||
$(name): $(o)
|
||||
$(CXX) -shared -Wl,-soname,$(name) -o $(name) $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $(LDFLAGS) *.o
|
||||
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.so
|
||||
rm -f $(name)
|
||||
|
||||
include Makefile.dep
|
||||
248
winixd/plugins/group/Makefile.dep
Normal file
248
winixd/plugins/group/Makefile.dep
Normal file
@@ -0,0 +1,248 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
groupinfo.o: groupinfo.h groups.h ../../../pikotools/space/spaceparser.h
|
||||
groupinfo.o: ../../../pikotools/space/space.h
|
||||
groupinfo.o: ../../../pikotools/textstream/types.h ../../../winix/core/item.h
|
||||
groupinfo.o: ../../../pikotools/space/space.h ../../../pikotools/date/date.h
|
||||
groupinfo.o: ../../../winix/core/system.h ../../../winix/core/job.h
|
||||
groupinfo.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
|
||||
groupinfo.o: ../../../winix/core/dirs.h ../../../winix/core/item.h
|
||||
groupinfo.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
groupinfo.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
groupinfo.o: ../../../winix/db/dbtextstream.h
|
||||
groupinfo.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
groupinfo.o: ../../../winix/core/requesttypes.h
|
||||
groupinfo.o: ../../../pikotools/textstream/textstream.h
|
||||
groupinfo.o: ../../../pikotools/convert/convert.h
|
||||
groupinfo.o: ../../../pikotools/convert/inttostr.h
|
||||
groupinfo.o: ../../../pikotools/membuffer/membuffer.h
|
||||
groupinfo.o: ../../../pikotools/textstream/types.h
|
||||
groupinfo.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
|
||||
groupinfo.o: ../../../winix/core/error.h ../../../winix/db/dbitemquery.h
|
||||
groupinfo.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
groupinfo.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
|
||||
groupinfo.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
|
||||
groupinfo.o: ../../../winix/core/textstream.h
|
||||
groupinfo.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
|
||||
groupinfo.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
groupinfo.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
groupinfo.o: ../../../winix/core/htmlfilter.h
|
||||
groupinfo.o: ../../../winix/templates/htmltextstream.h
|
||||
groupinfo.o: ../../../pikotools/space/spacetojson.h
|
||||
groupinfo.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
|
||||
groupinfo.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
|
||||
groupinfo.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
|
||||
groupinfo.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
|
||||
groupinfo.o: ../../../winix/notify/notify.h
|
||||
groupinfo.o: ../../../winix/notify/notifypool.h
|
||||
groupinfo.o: ../../../winix/templates/patterns.h
|
||||
groupinfo.o: ../../../winix/templates/locale.h
|
||||
groupinfo.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
groupinfo.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
groupinfo.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
groupinfo.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
groupinfo.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
groupinfo.o: ../../../winix/notify/notifythread.h
|
||||
groupinfo.o: ../../../winix/core/basethread.h
|
||||
groupinfo.o: ../../../winix/notify/templatesnotify.h
|
||||
groupinfo.o: ../../../winix/core/config.h ../../../winix/core/users.h
|
||||
groupinfo.o: ../../../winix/core/ugcontainer.h
|
||||
groupinfo.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
|
||||
groupinfo.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
|
||||
groupinfo.o: ../../../winix/core/run.h ../../../winix/core/users.h
|
||||
groupinfo.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
|
||||
groupinfo.o: ../../../winix/core/threadmanager.h
|
||||
groupinfo.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
groupinfo.o: ../../../winix/core/log.h
|
||||
groups.o: groups.h ../../../pikotools/space/spaceparser.h
|
||||
groups.o: ../../../pikotools/space/space.h
|
||||
groups.o: ../../../pikotools/textstream/types.h ../../../winix/core/log.h
|
||||
init.o: ../../../winix/core/log.h ../../../winix/core/plugin.h
|
||||
init.o: ../../../winix/core/pluginmsg.h ../../../winix/core/log.h
|
||||
init.o: ../../../winix/core/textstream.h
|
||||
init.o: ../../../winix/core/logmanipulators.h
|
||||
init.o: ../../../pikotools/textstream/textstream.h
|
||||
init.o: ../../../pikotools/space/space.h ../../../pikotools/date/date.h
|
||||
init.o: ../../../pikotools/convert/convert.h
|
||||
init.o: ../../../pikotools/convert/inttostr.h
|
||||
init.o: ../../../pikotools/membuffer/membuffer.h
|
||||
init.o: ../../../pikotools/textstream/types.h ../../../winix/core/slog.h
|
||||
init.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/requesttypes.h ../../../winix/core/item.h
|
||||
init.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
init.o: ../../../pikotools/space/spaceparser.h
|
||||
init.o: ../../../pikotools/space/space.h
|
||||
init.o: ../../../pikotools/textstream/types.h
|
||||
init.o: ../../../winix/core/htmlfilter.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
init.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
|
||||
init.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
|
||||
init.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
init.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
init.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
init.o: ../../../winix/templates/locale.h ../../../winix/core/system.h
|
||||
init.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
|
||||
init.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
init.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
init.o: ../../../winix/db/dbtextstream.h ../../../winix/core/error.h
|
||||
init.o: ../../../winix/db/dbitemquery.h ../../../winix/core/item.h
|
||||
init.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
init.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
|
||||
init.o: ../../../winix/core/ugcontainer.h ../../../winix/notify/notify.h
|
||||
init.o: ../../../winix/notify/notifypool.h
|
||||
init.o: ../../../winix/templates/patterns.h ../../../winix/templates/locale.h
|
||||
init.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
init.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
init.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
init.o: ../../../winix/notify/notifythread.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/notify/templatesnotify.h ../../../winix/core/config.h
|
||||
init.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
|
||||
init.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
|
||||
init.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
|
||||
init.o: ../../../winix/core/run.h ../../../winix/core/users.h groups.h
|
||||
init.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
|
||||
init.o: ../../../winix/core/threadmanager.h ../../../winix/core/timezones.h
|
||||
init.o: ../../../winix/core/timezone.h ../../../winix/core/sessionmanager.h
|
||||
init.o: ../../../winix/core/sessioncontainer.h
|
||||
init.o: ../../../winix/core/ipbancontainer.h
|
||||
init.o: ../../../winix/core/sessionidmanager.h ../../../tito/src/base64.h
|
||||
init.o: ../../../tito/src/aes.h ../../../winix/functions/functions.h
|
||||
init.o: ../../../winix/functions/functionbase.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/system.h ../../../winix/core/synchro.h
|
||||
init.o: ../../../winix/functions/functionparser.h ../../../winix/core/cur.h
|
||||
init.o: ../../../winix/functions/account.h ../../../winix/functions/adduser.h
|
||||
init.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
|
||||
init.o: ../../../winix/functions/privchanger.h
|
||||
init.o: ../../../winix/functions/chown.h ../../../winix/functions/ckeditor.h
|
||||
init.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
|
||||
init.o: ../../../winix/functions/download.h ../../../winix/functions/emacs.h
|
||||
init.o: ../../../winix/functions/env.h ../../../winix/functions/imgcrop.h
|
||||
init.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
|
||||
init.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
|
||||
init.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
|
||||
init.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
|
||||
init.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
|
||||
init.o: ../../../winix/functions/node.h ../../../winix/functions/passwd.h
|
||||
init.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
|
||||
init.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
|
||||
init.o: ../../../winix/functions/rmuser.h ../../../winix/functions/sort.h
|
||||
init.o: ../../../winix/functions/specialdefault.h
|
||||
init.o: ../../../winix/functions/stat.h ../../../winix/functions/subject.h
|
||||
init.o: ../../../winix/functions/template.h
|
||||
init.o: ../../../winix/functions/tinymce.h ../../../winix/functions/uname.h
|
||||
init.o: ../../../winix/functions/upload.h ../../../winix/functions/uptime.h
|
||||
init.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
|
||||
init.o: ../../../winix/core/htmlfilter.h ../../../winix/templates/templates.h
|
||||
init.o: ../../../winix/templates/patterncacher.h
|
||||
init.o: ../../../winix/templates/indexpatterns.h
|
||||
init.o: ../../../winix/templates/patterns.h
|
||||
init.o: ../../../winix/templates/changepatterns.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/sessionmanager.h groupinfo.h
|
||||
templates.o: ../../../winix/templates/templates.h ../../../ezc/src/ezc.h
|
||||
templates.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
templates.o: ../../../winix/core/item.h ../../../ezc/src/cache.h
|
||||
templates.o: ../../../ezc/src/functions.h ../../../pikotools/utf8/utf8.h
|
||||
templates.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
templates.o: ../../../ezc/src/pattern.h ../../../ezc/src/outstreams.h
|
||||
templates.o: ../../../ezc/src/patternparser.h ../../../winix/core/misc.h
|
||||
templates.o: ../../../winix/core/requesttypes.h
|
||||
templates.o: ../../../pikotools/textstream/textstream.h
|
||||
templates.o: ../../../pikotools/space/space.h ../../../pikotools/date/date.h
|
||||
templates.o: ../../../pikotools/convert/convert.h
|
||||
templates.o: ../../../pikotools/convert/inttostr.h
|
||||
templates.o: ../../../pikotools/membuffer/membuffer.h
|
||||
templates.o: ../../../pikotools/textstream/types.h
|
||||
templates.o: ../../../winix/core/winix_const.h
|
||||
templates.o: ../../../winix/templates/patterncacher.h
|
||||
templates.o: ../../../winix/core/item.h
|
||||
templates.o: ../../../winix/templates/indexpatterns.h
|
||||
templates.o: ../../../winix/templates/patterns.h
|
||||
templates.o: ../../../winix/templates/locale.h
|
||||
templates.o: ../../../winix/templates/changepatterns.h
|
||||
templates.o: ../../../winix/templates/htmltextstream.h
|
||||
templates.o: ../../../winix/templates/localefilter.h
|
||||
templates.o: ../../../winix/core/config.h ../../../winix/core/cur.h
|
||||
templates.o: ../../../winix/core/system.h ../../../winix/core/job.h
|
||||
templates.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
|
||||
templates.o: ../../../winix/core/dirs.h ../../../winix/core/dircontainer.h
|
||||
templates.o: ../../../winix/db/db.h ../../../winix/db/dbbase.h
|
||||
templates.o: ../../../winix/db/dbconn.h ../../../winix/db/dbtextstream.h
|
||||
templates.o: ../../../winix/core/textstream.h ../../../winix/core/error.h
|
||||
templates.o: ../../../pikotools/space/spaceparser.h
|
||||
templates.o: ../../../pikotools/space/space.h
|
||||
templates.o: ../../../pikotools/textstream/types.h
|
||||
templates.o: ../../../winix/db/dbitemquery.h
|
||||
templates.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
templates.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
|
||||
templates.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
|
||||
templates.o: ../../../winix/core/textstream.h
|
||||
templates.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
|
||||
templates.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
templates.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
templates.o: ../../../winix/core/htmlfilter.h
|
||||
templates.o: ../../../winix/templates/htmltextstream.h
|
||||
templates.o: ../../../pikotools/space/spacetojson.h
|
||||
templates.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
templates.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
templates.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
templates.o: ../../../winix/templates/locale.h ../../../winix/notify/notify.h
|
||||
templates.o: ../../../winix/notify/notifypool.h
|
||||
templates.o: ../../../winix/templates/patterns.h
|
||||
templates.o: ../../../winix/notify/notifythread.h
|
||||
templates.o: ../../../winix/core/basethread.h
|
||||
templates.o: ../../../winix/notify/templatesnotify.h
|
||||
templates.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
|
||||
templates.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
|
||||
templates.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
|
||||
templates.o: ../../../winix/core/run.h ../../../winix/core/users.h groups.h
|
||||
templates.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
|
||||
templates.o: ../../../winix/core/threadmanager.h
|
||||
templates.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
templates.o: ../../../winix/core/sessionmanager.h
|
||||
templates.o: ../../../winix/core/htmlfilter.h ../../../winix/core/plugin.h
|
||||
templates.o: ../../../winix/core/pluginmsg.h ../../../winix/core/system.h
|
||||
templates.o: ../../../winix/core/sessionmanager.h
|
||||
templates.o: ../../../winix/core/sessioncontainer.h
|
||||
templates.o: ../../../winix/core/ipbancontainer.h
|
||||
templates.o: ../../../winix/core/sessionidmanager.h
|
||||
templates.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
|
||||
templates.o: ../../../winix/functions/functions.h
|
||||
templates.o: ../../../winix/functions/functionbase.h
|
||||
templates.o: ../../../winix/core/request.h ../../../winix/core/synchro.h
|
||||
templates.o: ../../../winix/functions/functionparser.h
|
||||
templates.o: ../../../winix/functions/account.h
|
||||
templates.o: ../../../winix/functions/adduser.h
|
||||
templates.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
|
||||
templates.o: ../../../winix/functions/privchanger.h
|
||||
templates.o: ../../../winix/functions/chown.h
|
||||
templates.o: ../../../winix/functions/ckeditor.h
|
||||
templates.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
|
||||
templates.o: ../../../winix/functions/download.h
|
||||
templates.o: ../../../winix/functions/emacs.h ../../../winix/functions/env.h
|
||||
templates.o: ../../../winix/functions/imgcrop.h
|
||||
templates.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
|
||||
templates.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
|
||||
templates.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
|
||||
templates.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
|
||||
templates.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
|
||||
templates.o: ../../../winix/functions/node.h
|
||||
templates.o: ../../../winix/functions/passwd.h
|
||||
templates.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
|
||||
templates.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
|
||||
templates.o: ../../../winix/functions/rmuser.h
|
||||
templates.o: ../../../winix/functions/sort.h
|
||||
templates.o: ../../../winix/functions/specialdefault.h
|
||||
templates.o: ../../../winix/functions/stat.h
|
||||
templates.o: ../../../winix/functions/subject.h
|
||||
templates.o: ../../../winix/functions/template.h
|
||||
templates.o: ../../../winix/functions/tinymce.h
|
||||
templates.o: ../../../winix/functions/uname.h
|
||||
templates.o: ../../../winix/functions/upload.h
|
||||
templates.o: ../../../winix/functions/uptime.h ../../../winix/functions/who.h
|
||||
templates.o: ../../../winix/functions/vim.h groupinfo.h
|
||||
templates.o: ../../../winix/core/misc.h
|
||||
1
winixd/plugins/group/Makefile.o.dep
Normal file
1
winixd/plugins/group/Makefile.o.dep
Normal file
@@ -0,0 +1 @@
|
||||
o = groupinfo.o groups.o init.o templates.o
|
||||
207
winixd/plugins/group/groupinfo.cpp
Normal file
207
winixd/plugins/group/groupinfo.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "groupinfo.h"
|
||||
#include "core/log.h"
|
||||
#include "core/system.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
|
||||
|
||||
GroupInfo::GroupInfo()
|
||||
{
|
||||
mount_par_group_conf = -1;
|
||||
}
|
||||
|
||||
|
||||
void GroupInfo::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
void GroupInfo::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
Groups * GroupInfo::FindGroups(long dir_id)
|
||||
{
|
||||
GroupsWrap::iterator i = groups_wrap.find(dir_id);
|
||||
|
||||
if( i == groups_wrap.end() )
|
||||
return 0;
|
||||
|
||||
return &(i->second.groups);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GroupInfo::ParseGroups(const std::wstring & str, Groups & groups)
|
||||
{
|
||||
groups.Clear();
|
||||
PT::Space & space = *groups.GetSpace();
|
||||
conf_parser.SetSpace(space);
|
||||
|
||||
if( conf_parser.ParseString(str) == PT::SpaceParser::ok )
|
||||
{
|
||||
groups.Reindex();
|
||||
}
|
||||
else
|
||||
{
|
||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
||||
log << log1 << "Syntax error in line: " << conf_parser.line << logend;
|
||||
groups.Clear();
|
||||
}
|
||||
|
||||
return conf_parser.status == PT::SpaceParser::ok;
|
||||
}
|
||||
|
||||
|
||||
void GroupInfo::MarkAllGroupsToDelete()
|
||||
{
|
||||
GroupsWrap::iterator i = groups_wrap.begin();
|
||||
|
||||
for( ; i != groups_wrap.end() ; ++i)
|
||||
i->second.to_delete = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void GroupInfo::DeleteAllMarkedGroups()
|
||||
{
|
||||
GroupsWrap::iterator inext;
|
||||
GroupsWrap::iterator i = groups_wrap.begin();
|
||||
|
||||
while( i != groups_wrap.end() )
|
||||
{
|
||||
inext = i;
|
||||
++inext;
|
||||
|
||||
if( i->second.to_delete )
|
||||
{
|
||||
log << log3 << "GroupItem: deleting group for dir id: " << i->first << logend;
|
||||
groups_wrap.erase(i);
|
||||
}
|
||||
|
||||
i = inext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GroupInfo::GetConfContent(const std::wstring & path)
|
||||
{
|
||||
int status = system->FollowAllLinks(path, config_dir_tab, config_file, false, false, false);
|
||||
|
||||
if( status != 1 )
|
||||
{
|
||||
log << log1 << "GroupItem: problem with reading a config file: " << path << ", status: " << status << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// if skip_existing_configs is true then only new config files will be parsed
|
||||
void GroupInfo::ReadGroupsConf(Mounts & mounts, bool skip_existing_configs)
|
||||
{
|
||||
Mounts::MountTab::const_iterator i;
|
||||
const Mounts::MountTab * mtab = mounts.GetMountTab();
|
||||
|
||||
// loop through all mount points
|
||||
for(i=mtab->begin() ; i!=mtab->end() ; ++i)
|
||||
{
|
||||
const Mount & mount = i->second;
|
||||
|
||||
if( mount.param[mount_par_group_conf].defined &&
|
||||
mount.param[mount_par_group_conf].arg.size() == 1 )
|
||||
{
|
||||
const std::wstring & file_name = mount.param[mount_par_group_conf].arg[0];
|
||||
GroupsWrap::iterator c = groups_wrap.find(mount.dir_id);
|
||||
bool exists = (c != groups_wrap.end() && c->second.file_name == file_name);
|
||||
|
||||
if( exists )
|
||||
c->second.to_delete = false;
|
||||
|
||||
if( !(skip_existing_configs && exists) )
|
||||
{
|
||||
if( GetConfContent(file_name) )
|
||||
{
|
||||
log << log3 << "GroupItem: parsing conf file: " << config_file.url << logend;
|
||||
groups_wrap[mount.dir_id].file_name = file_name;
|
||||
|
||||
if( !ParseGroups(config_file.content, groups_wrap[mount.dir_id].groups) )
|
||||
groups_wrap[mount.dir_id].to_delete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( exists )
|
||||
c->second.to_delete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if skip_existing_configs is true then only new config files will be parsed
|
||||
void GroupInfo::ReadGroupsConfigs(bool skip_existing_configs)
|
||||
{
|
||||
MarkAllGroupsToDelete();
|
||||
ReadGroupsConf(system->mounts, skip_existing_configs);
|
||||
DeleteAllMarkedGroups();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
115
winixd/plugins/group/groupinfo.h
Normal file
115
winixd/plugins/group/groupinfo.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_groupitem_groupinfo
|
||||
#define headerfile_winix_plugins_groupitem_groupinfo
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "groups.h"
|
||||
#include "space/spaceparser.h"
|
||||
#include "core/item.h"
|
||||
#include "core/system.h"
|
||||
#include "core/config.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
|
||||
struct GroupsWrapItem
|
||||
{
|
||||
bool to_delete;
|
||||
std::wstring file_name;
|
||||
Groups groups;
|
||||
|
||||
GroupsWrapItem()
|
||||
{
|
||||
to_delete = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class GroupInfo
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
GroupInfo();
|
||||
|
||||
void SetSystem(System * psystem);
|
||||
void SetConfig(Config * pconfig);
|
||||
|
||||
void ReadGroupsConfigs(bool skip_existing_configs);
|
||||
Groups * FindGroups(long dir_id); // can return a null pointer
|
||||
|
||||
|
||||
int mount_par_group_conf;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
System * system;
|
||||
Config * config;
|
||||
|
||||
// map[mount_dir_id] -> GroupsWrapItem
|
||||
typedef std::map<long, GroupsWrapItem> GroupsWrap;
|
||||
GroupsWrap groups_wrap;
|
||||
|
||||
PT::SpaceParser conf_parser;
|
||||
std::vector<Item*> config_dir_tab;
|
||||
Item config_file;
|
||||
|
||||
void MarkAllGroupsToDelete();
|
||||
void DeleteAllMarkedGroups();
|
||||
bool GetConfContent(const std::wstring & path);
|
||||
bool ParseGroupsConf(long mount_dir_id, const std::wstring & path);
|
||||
bool ParseGroups(const std::wstring & str, Groups & groups);
|
||||
void ReadGroupsConf(Mounts & mounts, bool skip_existing_configs);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
254
winixd/plugins/group/groups.cpp
Normal file
254
winixd/plugins/group/groups.cpp
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
#include "groups.h"
|
||||
#include "core/log.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
|
||||
|
||||
|
||||
PT::Space * Groups::GetSpace()
|
||||
{
|
||||
return &space;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Groups::Reindex()
|
||||
{
|
||||
set_index.clear();
|
||||
group_index_tab.clear();
|
||||
size_t seti = 0;
|
||||
|
||||
while( seti < space.spaces.size() )
|
||||
{
|
||||
const std::wstring & name = space.spaces[seti]->name;
|
||||
|
||||
if( set_index.find(name) == set_index.end() )
|
||||
{
|
||||
set_index[name] = seti;
|
||||
group_index_tab.push_back(GroupIndex());
|
||||
ReindexGroups(group_index_tab.back(), *space.spaces[seti]);
|
||||
seti += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
slog << logerror << "set: " << name << " already defined (skipping)" << logend;
|
||||
space.spaces.erase(space.spaces.begin() + seti);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Groups::ReindexGroups(GroupIndex & group_index, PT::Space & set)
|
||||
{
|
||||
size_t i, v;
|
||||
|
||||
// loop through all groups in the set
|
||||
for( i=0 ; i < set.spaces.size() ; ++i )
|
||||
{
|
||||
PT::Space & group = *set.spaces[i];
|
||||
// !! IMPROVE ME will be safer to copy the value out
|
||||
// if we used accidently the group.Text later the key
|
||||
// would be overwritten
|
||||
const std::wstring & key = group.Text(L"key", L"value");
|
||||
|
||||
// loop through all values in the group
|
||||
for(v=0 ; v<group.spaces.size() ; )
|
||||
{
|
||||
std::wstring * vali = group.spaces[v]->GetValue(key);
|
||||
|
||||
if( vali )
|
||||
{
|
||||
GroupIndex::iterator g = group_index.find(*vali);
|
||||
|
||||
if( g == group_index.end() )
|
||||
{
|
||||
group_index[*vali] = i;
|
||||
v += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
slog << logwarning << "set: " << set.name << " has a group with a duplicated value: "
|
||||
<< *vali << " (skipping)" << logend;
|
||||
|
||||
group.spaces.erase(group.spaces.begin() + v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "key: " << key << " was not found" << logend;
|
||||
slog << logwarning << "set: " << set.name
|
||||
<< " has a group without a value (skipping)" << logend;
|
||||
|
||||
group.spaces.erase(group.spaces.begin() + v);
|
||||
}
|
||||
}
|
||||
|
||||
SortValues(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Groups::SortValues(PT::Space & group)
|
||||
{
|
||||
sort_by = group.Text(L"sort_by");
|
||||
sort_asc = (group.Text(L"sort_asc", L"true") == L"true");
|
||||
|
||||
if( !sort_by.empty() )
|
||||
{
|
||||
group.ListText(L"sort", sort_value);
|
||||
std::sort(group.spaces.begin(), group.spaces.end(), SortFunHelper(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Groups::SortFunHelper::operator()(PT::Space * sp1, PT::Space * sp2)
|
||||
{
|
||||
const std::wstring & val1 = sp1->Text(groups->sort_by, L"");
|
||||
const std::wstring & val2 = sp2->Text(groups->sort_by, L"");
|
||||
|
||||
if( groups->sort_asc )
|
||||
return SortValue(val1) < SortValue(val2);
|
||||
else
|
||||
return SortValue(val1) > SortValue(val2);
|
||||
}
|
||||
|
||||
|
||||
size_t Groups::SortFunHelper::SortValue(const std::wstring & val)
|
||||
{
|
||||
for(size_t i=0 ; i<groups->sort_value.size() ; ++i)
|
||||
if( val == groups->sort_value[i] )
|
||||
return i;
|
||||
|
||||
return std::numeric_limits<size_t>::max();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Groups::Find(const std::wstring & set, const std::wstring & value, size_t & seti, size_t & groupi)
|
||||
{
|
||||
SetIndex::iterator i = set_index.find(set);
|
||||
|
||||
if( i != set_index.end() )
|
||||
{
|
||||
if( i->second < group_index_tab.size() )
|
||||
{
|
||||
GroupIndex::iterator viter = group_index_tab[i->second].find(value);
|
||||
|
||||
if( viter != group_index_tab[i->second].end() )
|
||||
{
|
||||
seti = i->second;
|
||||
groupi = viter->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::wstring & Groups::GetOption(size_t seti, size_t groupi, size_t valuei, const wchar_t * option)
|
||||
{
|
||||
if( seti < space.spaces.size() )
|
||||
{
|
||||
PT::Space & groups = *space.spaces[seti];
|
||||
|
||||
if( groupi < groups.spaces.size() )
|
||||
{
|
||||
PT::Space & value = *groups.spaces[groupi];
|
||||
|
||||
if( valuei < value.spaces.size() )
|
||||
return value.spaces[valuei]->Text(option);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return empty_str;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Groups::GetOption(size_t seti, size_t groupi, size_t valuei, const std::wstring & option)
|
||||
{
|
||||
return GetOption(seti, groupi, valuei, option.c_str());
|
||||
}
|
||||
|
||||
|
||||
size_t Groups::Size(size_t seti, size_t groupi)
|
||||
{
|
||||
if( seti < space.spaces.size() )
|
||||
{
|
||||
PT::Space & groups = *space.spaces[seti];
|
||||
|
||||
if( groupi < groups.spaces.size() )
|
||||
return groups.spaces[groupi]->spaces.size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Groups::Clear()
|
||||
{
|
||||
space.Clear();
|
||||
set_index.clear();
|
||||
group_index_tab.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
159
winixd/plugins/group/groups.h
Normal file
159
winixd/plugins/group/groups.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_groupitem_groups
|
||||
#define headerfile_winix_plugins_groupitem_groups
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "space/spaceparser.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
|
||||
|
||||
class Groups
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
reading all space
|
||||
(sets and groups)
|
||||
*/
|
||||
PT::Space * GetSpace();
|
||||
|
||||
|
||||
/*
|
||||
building all indexes
|
||||
*/
|
||||
void Reindex();
|
||||
|
||||
|
||||
bool Find(const std::wstring & set, const std::wstring & value, size_t & seti, size_t & groupi);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
size_t Size(size_t seti, size_t groupi);
|
||||
|
||||
const std::wstring & GetOption(size_t seti, size_t groupi, size_t valuei, const wchar_t * option);
|
||||
const std::wstring & GetOption(size_t seti, size_t groupi, size_t valuei, const std::wstring & option);
|
||||
|
||||
|
||||
/*
|
||||
removing all groups
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
our space:
|
||||
set1 (
|
||||
|
||||
# group1
|
||||
(
|
||||
( value = "value1"
|
||||
other = "foo" )
|
||||
|
||||
( value = "something"
|
||||
other = "x" )
|
||||
)
|
||||
|
||||
# group2
|
||||
(
|
||||
|
||||
)
|
||||
|
||||
) # end of set1
|
||||
|
||||
# we can have more sets
|
||||
# sets should have a unique name
|
||||
# groups don't have a name
|
||||
*/
|
||||
PT::Space space;
|
||||
|
||||
|
||||
/*
|
||||
indexes to a set of groups
|
||||
*/
|
||||
typedef std::map<std::wstring, size_t> SetIndex;
|
||||
SetIndex set_index;
|
||||
|
||||
/*
|
||||
indexes to a groups in a set
|
||||
mapping: value->group index
|
||||
*/
|
||||
typedef std::map<std::wstring, size_t> GroupIndex;
|
||||
|
||||
/*
|
||||
group indexes in a specified set
|
||||
std::vector<how many sets there are>
|
||||
*/
|
||||
std::vector<GroupIndex> group_index_tab;
|
||||
|
||||
const std::wstring empty_str;
|
||||
|
||||
|
||||
std::wstring sort_by;
|
||||
bool sort_asc;
|
||||
PT::Space::Value sort_value;
|
||||
|
||||
struct SortFunHelper
|
||||
{
|
||||
Groups * groups;
|
||||
SortFunHelper(Groups * pgroups) : groups(pgroups) {};
|
||||
size_t SortValue(const std::wstring & val);
|
||||
bool operator()(PT::Space * sp1, PT::Space * sp2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
void ReindexGroups(GroupIndex & group_index, PT::Space & set);
|
||||
void SortValues(PT::Space & group);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
|
||||
107
winixd/plugins/group/init.cpp
Normal file
107
winixd/plugins/group/init.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/plugin.h"
|
||||
#include "groupinfo.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
|
||||
|
||||
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
const wchar_t plugin_name[] = L"group";
|
||||
GroupInfo group_info;
|
||||
|
||||
|
||||
|
||||
|
||||
void AddMountPar(PluginInfo & info)
|
||||
{
|
||||
group_info.mount_par_group_conf = info.system->mounts.AddMountPar(L"group_conf");
|
||||
}
|
||||
|
||||
|
||||
void FstabChanged(PluginInfo & info)
|
||||
{
|
||||
group_info.ReadGroupsConfigs(true);
|
||||
}
|
||||
|
||||
|
||||
void ProcessRequest(PluginInfo & info)
|
||||
{
|
||||
if( info.cur->request->function == &info.functions->fun_reload )
|
||||
{
|
||||
if( info.cur->request->IsParam(L"group") )
|
||||
group_info.ReadGroupsConfigs(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace GroupItem;
|
||||
|
||||
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
||||
plugin.Assign(WINIX_ADD_MOUNTS, AddMountPar);
|
||||
plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
||||
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
|
||||
|
||||
group_info.SetSystem(info.system);
|
||||
group_info.SetConfig(info.config);
|
||||
|
||||
info.p1 = (void*)(plugin_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
187
winixd/plugins/group/templates.cpp
Normal file
187
winixd/plugins/group/templates.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates/templates.h"
|
||||
#include "core/plugin.h"
|
||||
#include "groupinfo.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace GroupItem
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
using TemplatesFunctions::system;
|
||||
|
||||
|
||||
extern GroupInfo group_info;
|
||||
|
||||
|
||||
static bool group_tab_found = false;
|
||||
static Groups * pgroups;
|
||||
static size_t req_id = 0;
|
||||
static size_t set_index;
|
||||
static size_t group_index;
|
||||
static size_t value_index;
|
||||
static std::wstring last_set, last_value;
|
||||
static std::wstring path;
|
||||
|
||||
|
||||
|
||||
|
||||
void group_tab_init(const std::wstring & set, const std::wstring & value)
|
||||
{
|
||||
if( req_id != cur->request->id || last_set != set || last_value != value )
|
||||
{
|
||||
req_id = cur->request->id;
|
||||
pgroups = group_info.FindGroups(cur->mount->dir_id);
|
||||
last_set = set;
|
||||
last_value = value;
|
||||
group_tab_found = false;
|
||||
|
||||
if( pgroups && pgroups->Find(set, value, set_index, group_index) )
|
||||
group_tab_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void group_tab(Info & i)
|
||||
{
|
||||
if( i.params.size() == 2 )
|
||||
{
|
||||
group_tab_init(i.params[0].str, i.params[1].str);
|
||||
value_index = i.iter;
|
||||
|
||||
if( group_tab_found )
|
||||
i.res = value_index < pgroups->Size(set_index, group_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
group_tab_found = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void build_current_path()
|
||||
{
|
||||
system->dirs.MakePath(cur->request->dir_tab, path);
|
||||
|
||||
if( cur->request->is_item )
|
||||
{
|
||||
path += cur->request->item.url;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we assume that directories are without the last trailing slash
|
||||
NoLastSlash(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void group_link_tab(Info & i)
|
||||
{
|
||||
if( i.params.size() == 1 )
|
||||
{
|
||||
build_current_path();
|
||||
group_tab_init(i.params[0].str, path);
|
||||
value_index = i.iter;
|
||||
|
||||
if( group_tab_found )
|
||||
i.res = value_index < pgroups->Size(set_index, group_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
group_tab_found = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void group_tab_value(Info & i)
|
||||
{
|
||||
if( group_tab_found )
|
||||
{
|
||||
if( !i.par.empty() )
|
||||
i.out << pgroups->GetOption(set_index, group_index, value_index, i.par);
|
||||
else
|
||||
i.out << pgroups->GetOption(set_index, group_index, value_index, L"value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void group_tab_is_current_link(Info & i)
|
||||
{
|
||||
if( group_tab_found )
|
||||
{
|
||||
build_current_path();
|
||||
|
||||
if( !i.par.empty() )
|
||||
i.res = (pgroups->GetOption(set_index, group_index, value_index, i.par) == path);
|
||||
else
|
||||
i.res = (pgroups->GetOption(set_index, group_index, value_index, L"value") == path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::EzcFun;
|
||||
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
|
||||
|
||||
/*
|
||||
*/
|
||||
fun->Insert("group_tab", group_tab);
|
||||
fun->Insert("group_link_tab", group_link_tab);
|
||||
fun->Insert("group_tab_value", group_tab_value);
|
||||
fun->Insert("group_tab_is_current_link", group_tab_is_current_link);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user