1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
/*
* Copyright (c) 2012 Sasha Vasko <sasha at aftercode.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#define LOCAL_DEBUG
#include "../configure.h"
#include "../libAfterStep/asapp.h"
#include "../libAfterStep/afterstep.h"
#include "../libAfterStep/mystyle.h"
#include "../libAfterStep/parser.h"
#include "../libAfterStep/balloon.h"
#include "afterconf.h"
/*****************************************************************************
*
* This routine is responsible for reading and parsing the config file
*
****************************************************************************/
extern SyntaxDef AlignSyntax;
/*#define ASMOUNT_FEEL_TERMS \
ASCF_DEFINE_KEYWORD(ASMOUNT, TF_DONT_SPLIT , Action , TT_TEXT, NULL), \
ASCF_DEFINE_KEYWORD(ASMOUNT, 0 , FillRowsFirst , TT_FLAG, NULL), \
ASCF_DEFINE_KEYWORD(ASMOUNT, 0 , UseSkipList , TT_FLAG, NULL)
*/
#define ASMOUNT_LOOK_TERMS \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, 0 , Align , TT_FLAG , &AlignSyntax,ASMountConfig), \
ASCF_DEFINE_KEYWORD (ASMOUNT, 0 , Bevel , TT_FLAG , &BevelSyntax), \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, 0 , MountedBevel , TT_FLAG , &BevelSyntax,ASMountConfig), \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, 0 , UnmountedBevel , TT_FLAG , &BevelSyntax,ASMountConfig), \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, TF_QUOTES_OPTIONAL, MountedStyle , TT_QUOTED_TEXT , NULL,ASMountConfig), \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, TF_QUOTES_OPTIONAL, UnmountedStyle , TT_QUOTED_TEXT , NULL,ASMountConfig), \
ASCF_DEFINE_KEYWORD (ASMOUNT, 0 , ShapeToContents , TT_FLAG , NULL), \
ASCF_DEFINE_KEYWORD (ASMOUNT, 0 , ShowHints , TT_FLAG , NULL)
#define ASMOUNT_PRIVATE_TERMS \
ASCF_DEFINE_KEYWORD_S(ASMOUNT, 0 , TileSize , TT_GEOMETRY , NULL,ASMountConfig), \
ASCF_DEFINE_KEYWORD (ASMOUNT, 0 , Vertical , TT_FLAG , NULL)
TermDef ASMountFeelTerms[] = {
/* Feel */
// ASMOUNT_FEEL_TERMS,
BALLOON_FEEL_TERMS,
{0, NULL, 0, 0, 0}
};
TermDef ASMountLookTerms[] = {
/* Look */
ASMOUNT_LOOK_TERMS,
/* now special cases that should be processed by it's own handlers */
BALLOON_LOOK_TERMS,
{0, NULL, 0, 0, 0}
};
TermDef ASMountPrivateTerms[] = {
ASMOUNT_PRIVATE_TERMS,
BALLOON_FLAG_TERM,
{0, NULL, 0, 0, 0}
};
#define ASMOUNT_ALL_TERMS ASMOUNT_PRIVATE_TERMS, ASMOUNT_LOOK_TERMS
TermDef ASMountDefaultsTerms[] = {
ASMOUNT_ALL_TERMS,
/* now special cases that should be processed by it's own handlers */
BALLOON_TERMS,
INCLUDE_MODULE_DEFAULTS_END,
{0, NULL, 0, 0, 0}
};
SyntaxDef ASMountDefaultsSyntax =
{ '\n', '\0', ASMountDefaultsTerms, 0, ' ', "", "\t",
"Module:ASMount_defaults", "ASMount",
"AfterStep module for mounting/unmounting volumes", NULL, 0
};
TermDef ASMountTerms[] = {
INCLUDE_MODULE_DEFAULTS (&ASMountDefaultsSyntax),
ASMOUNT_ALL_TERMS,
/* including MyStyles definitions processing */
INCLUDE_MYSTYLE,
/* now special cases that should be processed by it's own handlers */
BALLOON_TERMS,
{0, NULL, 0, 0, 0}
};
SyntaxDef ASMountFeelSyntax =
{ '\n', '\0', ASMountFeelTerms, 0, '\t', "", "\t", "ASMountFeel",
"ASMountFeel",
"AfterStep Volumes manager module feel", NULL, 0
};
SyntaxDef ASMountLookSyntax =
{ '\n', '\0', ASMountLookTerms, 0, '\t', "", "\t", "ASMountLook",
"ASMountLook",
"AfterStep Volumes manager module look", NULL, 0
};
SyntaxDef ASMountPrivateSyntax =
{ '\n', '\0', ASMountPrivateTerms, 0, '\t', "", "\t", "ASMount",
"ASMount", "AfterStep Volumes manager module",
NULL, 0
};
SyntaxDef ASMountSyntax =
{ '\n', '\0', ASMountTerms, 0, ' ', "", "\t", "Module:ASMount",
"ASMount",
"AfterStep module for management of storage volumes", NULL, 0
};
flag_options_xref ASMountFlags[] = {
ASCF_DEFINE_MODULE_FLAG_XREF (ASMOUNT, Vertical, ASMountConfig),
ASCF_DEFINE_MODULE_FLAG_XREF (ASMOUNT, ShapeToContents, ASMountConfig),
ASCF_DEFINE_MODULE_FLAG_XREF (ASMOUNT, ShowHints, ASMountConfig),
{0, 0, 0}
};
static void InitASMountConfig (ASModuleConfig * asm_config,
Bool free_resources);
void ASMount_fs2config (ASModuleConfig * asmodule_config,
FreeStorageElem * Storage);
void MergeASMountOptions (ASModuleConfig * to, ASModuleConfig * from);
static ASModuleConfigClass _asmount_config_class = { CONFIG_ASMount_ID,
0,
sizeof (ASMountConfig),
"asmount",
InitASMountConfig,
ASMount_fs2config,
MergeASMountOptions,
&ASMountSyntax,
&ASMountLookSyntax,
&ASMountFeelSyntax,
ASMountFlags,
offsetof (ASMountConfig, set_flags),
ASDefaultBalloonTypes
};
ASModuleConfigClass *getASMountConfigClass ()
{
return &_asmount_config_class;
}
static void
InitASMountConfig (ASModuleConfig * asm_config, Bool free_resources)
{
ASMountConfig *config = AS_ASMOUNT_CONFIG (asm_config);
if (config) {
if (free_resources) {
destroy_string (&(config->MountedStyle));
destroy_string (&(config->UnmountedStyle));
}
config->flags = 0;
init_asgeometry (&(config->TileSize));
config->MountedBevel = config->UnmountedBevel = DEFAULT_TBAR_HILITE;
}
}
void PrintASMountConfig (ASMountConfig * config)
{
fprintf (stderr, "ASMountConfig = %p;\n", config);
if (config == NULL)
return;
fprintf (stderr, "ASMountConfig.flags = 0x%lX;\n", config->flags);
fprintf (stderr, "ASMountConfig.set_flags = 0x%lX;\n",
config->set_flags);
ASCF_PRINT_FLAG_KEYWORD (stderr, ASMOUNT, config, ShapeToContents);
ASCF_PRINT_FLAG_KEYWORD (stderr, ASMOUNT, config, Vertical);
ASCF_PRINT_GEOMETRY_KEYWORD (stderr, ASMOUNT, config, TileSize);
ASCF_PRINT_FLAGS_KEYWORD (stderr, ASMOUNT, config, Align);
ASCF_PRINT_FLAGS_KEYWORD (stderr, ASMOUNT, config, MountedBevel);
ASCF_PRINT_FLAGS_KEYWORD (stderr, ASMOUNT, config, UnmountedBevel);
ASCF_PRINT_STRING_KEYWORD (stderr, ASMOUNT, config, UnmountedStyle);
ASCF_PRINT_STRING_KEYWORD (stderr, ASMOUNT, config, MountedStyle);
}
void
ASMount_fs2config (ASModuleConfig * asmodule_config,
FreeStorageElem * Storage)
{
FreeStorageElem *pCurr;
ConfigItem item;
ASMountConfig *config = AS_ASMOUNT_CONFIG (asmodule_config);
if (config == NULL)
return;
item.memory = NULL;
for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
if (pCurr->term == NULL)
continue;
if (pCurr->term->type == TT_FLAG) {
if (pCurr->term->id == ASMOUNT_Bevel_ID) {
set_scalar_value (&(config->MountedBevel),
ParseBevelOptions (pCurr->sub),
&(config->set_flags), ASMOUNT_Bevel);
config->UnmountedBevel = config->MountedBevel;
}
} else {
if (!ReadConfigItem (&item, pCurr))
continue;
item.ok_to_free = 1;
}
}
ReadConfigItem (&item, NULL);
}
void
MergeASMountOptions (ASModuleConfig * asm_to, ASModuleConfig * asm_from)
{
START_TIME (option_time);
ASMountConfig *to = AS_ASMOUNT_CONFIG (asm_to);
ASMountConfig *from = AS_ASMOUNT_CONFIG (asm_from);
if (to && from) {
ASCF_MERGE_FLAGS (to, from);
ASCF_MERGE_GEOMETRY_KEYWORD (ASMOUNT, to, from, TileSize);
ASCF_MERGE_STRING_KEYWORD (ASMOUNT, to, from, MountedStyle);
ASCF_MERGE_STRING_KEYWORD (ASMOUNT, to, from, UnmountedStyle);
}
SHOW_TIME ("to parsing", option_time);
}
ASFlagType DigestASMountAlign (ASMountConfig * Config, ASFlagType align)
{
return align;
}
void
CheckASMountConfigSanity (ASMountConfig * Config,
ASGeometry * default_tile_size)
{
if (Config == NULL)
Config =
AS_ASMOUNT_CONFIG (create_ASModule_config
(getASMountConfigClass ()));
if (default_tile_size && default_tile_size->flags != 0)
Config->TileSize = *default_tile_size;
}
|