Settings: Sanitize setting name everywhere, not just LuaSettings
[oweals/minetest.git] / src / settings.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "settings.h"
21 #include "irrlichttypes_bloated.h"
22 #include "exceptions.h"
23 #include "jthread/jmutexautolock.h"
24 #include "strfnd.h"
25 #include <iostream>
26 #include <fstream>
27 #include <sstream>
28 #include "debug.h"
29 #include "log.h"
30 #include "util/serialize.h"
31 #include "filesys.h"
32 #include "noise.h"
33 #include <cctype>
34 #include <algorithm>
35
36
37 Settings::~Settings()
38 {
39         clear();
40 }
41
42
43 Settings & Settings::operator += (const Settings &other)
44 {
45         update(other);
46
47         return *this;
48 }
49
50
51 Settings & Settings::operator = (const Settings &other)
52 {
53         if (&other == this)
54                 return *this;
55
56         JMutexAutoLock lock(m_mutex);
57         JMutexAutoLock lock2(other.m_mutex);
58
59         clearNoLock();
60         updateNoLock(other);
61
62         return *this;
63 }
64
65
66 std::string Settings::getMultiline(std::istream &is, size_t *num_lines)
67 {
68         size_t lines = 1;
69         std::string value;
70         std::string line;
71
72         while (is.good()) {
73                 lines++;
74                 std::getline(is, line);
75                 if (line == "\"\"\"")
76                         break;
77                 value += line;
78                 value.push_back('\n');
79         }
80
81         size_t len = value.size();
82         if (len)
83                 value.erase(len - 1);
84
85         if (num_lines)
86                 *num_lines = lines;
87
88         return value;
89 }
90
91
92 bool Settings::readConfigFile(const char *filename)
93 {
94         std::ifstream is(filename);
95         if (!is.good())
96                 return false;
97
98         return parseConfigLines(is, "");
99 }
100
101
102 bool Settings::parseConfigLines(std::istream &is, const std::string &end)
103 {
104         JMutexAutoLock lock(m_mutex);
105
106         std::string line, name, value;
107
108         while (is.good()) {
109                 std::getline(is, line);
110                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
111
112                 switch (event) {
113                 case SPE_NONE:
114                 case SPE_INVALID:
115                 case SPE_COMMENT:
116                         break;
117                 case SPE_KVPAIR:
118                         m_settings[name] = SettingsEntry(value);
119                         break;
120                 case SPE_END:
121                         return true;
122                 case SPE_GROUP: {
123                         Settings *group = new Settings;
124                         if (!group->parseConfigLines(is, "}")) {
125                                 delete group;
126                                 return false;
127                         }
128                         m_settings[name] = SettingsEntry(group);
129                         break;
130                 }
131                 case SPE_MULTILINE:
132                         m_settings[name] = SettingsEntry(getMultiline(is));
133                         break;
134                 }
135         }
136
137         return end.empty();
138 }
139
140
141 void Settings::writeLines(std::ostream &os, u32 tab_depth) const
142 {
143         JMutexAutoLock lock(m_mutex);
144
145         for (std::map<std::string, SettingsEntry>::const_iterator
146                         it = m_settings.begin();
147                         it != m_settings.end(); ++it)
148                 printEntry(os, it->first, it->second, tab_depth);
149 }
150
151
152 void Settings::printEntry(std::ostream &os, const std::string &name,
153         const SettingsEntry &entry, u32 tab_depth)
154 {
155         for (u32 i = 0; i != tab_depth; i++)
156                 os << "\t";
157
158         if (entry.is_group) {
159                 os << name << " = {\n";
160
161                 entry.group->writeLines(os, tab_depth + 1);
162
163                 for (u32 i = 0; i != tab_depth; i++)
164                         os << "\t";
165                 os << "}\n";
166         } else {
167                 os << name << " = ";
168
169                 if (entry.value.find('\n') != std::string::npos)
170                         os << "\"\"\"\n" << entry.value << "\n\"\"\"\n";
171                 else
172                         os << entry.value << "\n";
173         }
174 }
175
176
177 bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
178         const std::string &end, u32 tab_depth)
179 {
180         std::map<std::string, SettingsEntry>::const_iterator it;
181         std::set<std::string> present_entries;
182         std::string line, name, value;
183         bool was_modified = false;
184         bool end_found = false;
185
186         // Add any settings that exist in the config file with the current value
187         // in the object if existing
188         while (is.good() && !end_found) {
189                 std::getline(is, line);
190                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
191
192                 switch (event) {
193                 case SPE_END:
194                         os << line << (is.eof() ? "" : "\n");
195                         end_found = true;
196                         break;
197                 case SPE_MULTILINE:
198                         value = getMultiline(is);
199                         /* FALLTHROUGH */
200                 case SPE_KVPAIR:
201                         it = m_settings.find(name);
202                         if (it != m_settings.end() &&
203                                 (it->second.is_group || it->second.value != value)) {
204                                 printEntry(os, name, it->second, tab_depth);
205                                 was_modified = true;
206                         } else {
207                                 assert(it->second.group == NULL);
208                                 os << line << "\n";
209                                 if (event == SPE_MULTILINE)
210                                         os << value << "\n\"\"\"\n";
211                         }
212                         present_entries.insert(name);
213                         break;
214                 case SPE_GROUP:
215                         it = m_settings.find(name);
216                         if (it != m_settings.end() && it->second.is_group) {
217                                 os << line << "\n";
218                                 assert(it->second.group != NULL);
219                                 was_modified |= it->second.group->updateConfigObject(is, os,
220                                         "}", tab_depth + 1);
221                         } else {
222                                 printEntry(os, name, it->second, tab_depth);
223                                 was_modified = true;
224                         }
225                         present_entries.insert(name);
226                         break;
227                 default:
228                         os << line << (is.eof() ? "" : "\n");
229                         break;
230                 }
231         }
232
233         // Add any settings in the object that don't exist in the config file yet
234         for (it = m_settings.begin(); it != m_settings.end(); ++it) {
235                 if (present_entries.find(it->first) != present_entries.end())
236                         continue;
237
238                 printEntry(os, it->first, it->second, tab_depth);
239                 was_modified = true;
240         }
241
242         return was_modified;
243 }
244
245
246 bool Settings::updateConfigFile(const char *filename)
247 {
248         JMutexAutoLock lock(m_mutex);
249
250         std::ifstream is(filename);
251         std::ostringstream os(std::ios_base::binary);
252
253         bool was_modified = updateConfigObject(is, os, "");
254         is.close();
255
256         if (!was_modified)
257                 return true;
258
259         if (!fs::safeWriteToFile(filename, os.str())) {
260                 errorstream << "Error writing configuration file: \""
261                         << filename << "\"" << std::endl;
262                 return false;
263         }
264
265         return true;
266 }
267
268
269 bool Settings::parseCommandLine(int argc, char *argv[],
270                 std::map<std::string, ValueSpec> &allowed_options)
271 {
272         int nonopt_index = 0;
273         for (int i = 1; i < argc; i++) {
274                 std::string arg_name = argv[i];
275                 if (arg_name.substr(0, 2) != "--") {
276                         // If option doesn't start with -, read it in as nonoptX
277                         if (arg_name[0] != '-'){
278                                 std::string name = "nonopt";
279                                 name += itos(nonopt_index);
280                                 set(name, arg_name);
281                                 nonopt_index++;
282                                 continue;
283                         }
284                         errorstream << "Invalid command-line parameter \""
285                                         << arg_name << "\": --<option> expected." << std::endl;
286                         return false;
287                 }
288
289                 std::string name = arg_name.substr(2);
290
291                 std::map<std::string, ValueSpec>::iterator n;
292                 n = allowed_options.find(name);
293                 if (n == allowed_options.end()) {
294                         errorstream << "Unknown command-line parameter \""
295                                         << arg_name << "\"" << std::endl;
296                         return false;
297                 }
298
299                 ValueType type = n->second.type;
300
301                 std::string value = "";
302
303                 if (type == VALUETYPE_FLAG) {
304                         value = "true";
305                 } else {
306                         if ((i + 1) >= argc) {
307                                 errorstream << "Invalid command-line parameter \""
308                                                 << name << "\": missing value" << std::endl;
309                                 return false;
310                         }
311                         value = argv[++i];
312                 }
313
314                 set(name, value);
315         }
316
317         return true;
318 }
319
320
321
322 /***********
323  * Getters *
324  ***********/
325
326
327 const SettingsEntry &Settings::getEntry(const std::string &name) const
328 {
329         JMutexAutoLock lock(m_mutex);
330
331         std::map<std::string, SettingsEntry>::const_iterator n;
332         if ((n = m_settings.find(name)) == m_settings.end()) {
333                 if ((n = m_defaults.find(name)) == m_defaults.end())
334                         throw SettingNotFoundException("Setting [" + name + "] not found.");
335         }
336         return n->second;
337 }
338
339
340 Settings *Settings::getGroup(const std::string &name) const
341 {
342         const SettingsEntry &entry = getEntry(name);
343         if (!entry.is_group)
344                 throw SettingNotFoundException("Setting [" + name + "] is not a group.");
345         return entry.group;
346 }
347
348
349 std::string Settings::get(const std::string &name) const
350 {
351         const SettingsEntry &entry = getEntry(name);
352         if (entry.is_group)
353                 throw SettingNotFoundException("Setting [" + name + "] is a group.");
354         return entry.value;
355 }
356
357
358 bool Settings::getBool(const std::string &name) const
359 {
360         return is_yes(get(name));
361 }
362
363
364 u16 Settings::getU16(const std::string &name) const
365 {
366         return stoi(get(name), 0, 65535);
367 }
368
369
370 s16 Settings::getS16(const std::string &name) const
371 {
372         return stoi(get(name), -32768, 32767);
373 }
374
375
376 s32 Settings::getS32(const std::string &name) const
377 {
378         return stoi(get(name));
379 }
380
381
382 float Settings::getFloat(const std::string &name) const
383 {
384         return stof(get(name));
385 }
386
387
388 u64 Settings::getU64(const std::string &name) const
389 {
390         u64 value = 0;
391         std::string s = get(name);
392         std::istringstream ss(s);
393         ss >> value;
394         return value;
395 }
396
397
398 v2f Settings::getV2F(const std::string &name) const
399 {
400         v2f value;
401         Strfnd f(get(name));
402         f.next("(");
403         value.X = stof(f.next(","));
404         value.Y = stof(f.next(")"));
405         return value;
406 }
407
408
409 v3f Settings::getV3F(const std::string &name) const
410 {
411         v3f value;
412         Strfnd f(get(name));
413         f.next("(");
414         value.X = stof(f.next(","));
415         value.Y = stof(f.next(","));
416         value.Z = stof(f.next(")"));
417         return value;
418 }
419
420
421 u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc,
422         u32 *flagmask) const
423 {
424         std::string val = get(name);
425         return std::isdigit(val[0])
426                 ? stoi(val)
427                 : readFlagString(val, flagdesc, flagmask);
428 }
429
430
431 // N.B. if getStruct() is used to read a non-POD aggregate type,
432 // the behavior is undefined.
433 bool Settings::getStruct(const std::string &name, const std::string &format,
434         void *out, size_t olen) const
435 {
436         std::string valstr;
437
438         try {
439                 valstr = get(name);
440         } catch (SettingNotFoundException &e) {
441                 return false;
442         }
443
444         if (!deSerializeStringToStruct(valstr, format, out, olen))
445                 return false;
446
447         return true;
448 }
449
450
451 bool Settings::getNoiseParams(const std::string &name, NoiseParams &np) const
452 {
453         return getNoiseParamsFromGroup(name, np) || getNoiseParamsFromValue(name, np);
454 }
455
456
457 bool Settings::getNoiseParamsFromValue(const std::string &name,
458         NoiseParams &np) const
459 {
460         std::string value;
461
462         if (!getNoEx(name, value))
463                 return false;
464
465         Strfnd f(value);
466
467         np.offset   = stof(f.next(","));
468         np.scale    = stof(f.next(","));
469         f.next("(");
470         np.spread.X = stof(f.next(","));
471         np.spread.Y = stof(f.next(","));
472         np.spread.Z = stof(f.next(")"));
473         f.next(",");
474         np.seed     = stoi(f.next(","));
475         np.octaves  = stoi(f.next(","));
476         np.persist  = stof(f.next(""));
477
478         return true;
479 }
480
481
482 bool Settings::getNoiseParamsFromGroup(const std::string &name,
483         NoiseParams &np) const
484 {
485         Settings *group = NULL;
486
487         if (!getGroupNoEx(name, group))
488                 return false;
489
490         group->getFloatNoEx("offset",      np.offset);
491         group->getFloatNoEx("scale",       np.scale);
492         group->getV3FNoEx("spread",        np.spread);
493         group->getS32NoEx("seed",          np.seed);
494         group->getU16NoEx("octaves",       np.octaves);
495         group->getFloatNoEx("persistence", np.persist);
496         group->getFloatNoEx("lacunarity",  np.lacunarity);
497
498         np.flags = 0;
499         if (!group->getFlagStrNoEx("flags", np.flags, flagdesc_noiseparams))
500                 np.flags = NOISE_FLAG_DEFAULTS;
501
502         return true;
503 }
504
505
506 bool Settings::exists(const std::string &name) const
507 {
508         JMutexAutoLock lock(m_mutex);
509
510         return (m_settings.find(name) != m_settings.end() ||
511                 m_defaults.find(name) != m_defaults.end());
512 }
513
514
515 std::vector<std::string> Settings::getNames() const
516 {
517         std::vector<std::string> names;
518         for (std::map<std::string, SettingsEntry>::const_iterator
519                         i = m_settings.begin();
520                         i != m_settings.end(); ++i) {
521                 names.push_back(i->first);
522         }
523         return names;
524 }
525
526
527
528 /***************************************
529  * Getters that don't throw exceptions *
530  ***************************************/
531
532 bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const
533 {
534         try {
535                 val = getEntry(name);
536                 return true;
537         } catch (SettingNotFoundException &e) {
538                 return false;
539         }
540 }
541
542
543 bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const
544 {
545         try {
546                 val = getGroup(name);
547                 return true;
548         } catch (SettingNotFoundException &e) {
549                 return false;
550         }
551 }
552
553
554 bool Settings::getNoEx(const std::string &name, std::string &val) const
555 {
556         try {
557                 val = get(name);
558                 return true;
559         } catch (SettingNotFoundException &e) {
560                 return false;
561         }
562 }
563
564
565 bool Settings::getFlag(const std::string &name) const
566 {
567         try {
568                 return getBool(name);
569         } catch(SettingNotFoundException &e) {
570                 return false;
571         }
572 }
573
574
575 bool Settings::getFloatNoEx(const std::string &name, float &val) const
576 {
577         try {
578                 val = getFloat(name);
579                 return true;
580         } catch (SettingNotFoundException &e) {
581                 return false;
582         }
583 }
584
585
586 bool Settings::getU16NoEx(const std::string &name, u16 &val) const
587 {
588         try {
589                 val = getU16(name);
590                 return true;
591         } catch (SettingNotFoundException &e) {
592                 return false;
593         }
594 }
595
596
597 bool Settings::getS16NoEx(const std::string &name, s16 &val) const
598 {
599         try {
600                 val = getS16(name);
601                 return true;
602         } catch (SettingNotFoundException &e) {
603                 return false;
604         }
605 }
606
607
608 bool Settings::getS32NoEx(const std::string &name, s32 &val) const
609 {
610         try {
611                 val = getS32(name);
612                 return true;
613         } catch (SettingNotFoundException &e) {
614                 return false;
615         }
616 }
617
618
619 bool Settings::getU64NoEx(const std::string &name, u64 &val) const
620 {
621         try {
622                 val = getU64(name);
623                 return true;
624         } catch (SettingNotFoundException &e) {
625                 return false;
626         }
627 }
628
629
630 bool Settings::getV2FNoEx(const std::string &name, v2f &val) const
631 {
632         try {
633                 val = getV2F(name);
634                 return true;
635         } catch (SettingNotFoundException &e) {
636                 return false;
637         }
638 }
639
640
641 bool Settings::getV3FNoEx(const std::string &name, v3f &val) const
642 {
643         try {
644                 val = getV3F(name);
645                 return true;
646         } catch (SettingNotFoundException &e) {
647                 return false;
648         }
649 }
650
651
652 // N.B. getFlagStrNoEx() does not set val, but merely modifies it.  Thus,
653 // val must be initialized before using getFlagStrNoEx().  The intention of
654 // this is to simplify modifying a flags field from a default value.
655 bool Settings::getFlagStrNoEx(const std::string &name, u32 &val,
656         FlagDesc *flagdesc) const
657 {
658         try {
659                 u32 flags, flagmask;
660
661                 flags = getFlagStr(name, flagdesc, &flagmask);
662
663                 val &= ~flagmask;
664                 val |=  flags;
665
666                 return true;
667         } catch (SettingNotFoundException &e) {
668                 return false;
669         }
670 }
671
672
673 /***********
674  * Setters *
675  ***********/
676
677 void Settings::setEntry(const std::string &name, const void *data,
678         bool set_group, bool set_default)
679 {
680         Settings *old_group = NULL;
681
682         // Strip any potentially dangerous characters from the name (note the value
683         // has no such restrictions)
684         std::string n(name);
685         for (const char *s = "\t\n\v\f\r\b =\""; *s; s++)
686                 n.erase(std::remove(n.begin(), n.end(), *s), n.end());
687
688         {
689                 JMutexAutoLock lock(m_mutex);
690
691                 SettingsEntry &entry = set_default ? m_defaults[n] : m_settings[n];
692                 old_group = entry.group;
693
694                 entry.value    = set_group ? "" : *(const std::string *)data;
695                 entry.group    = set_group ? *(Settings **)data : NULL;
696                 entry.is_group = set_group;
697         }
698
699         delete old_group;
700 }
701
702
703 void Settings::set(const std::string &name, const std::string &value)
704 {
705         setEntry(name, &value, false, false);
706
707         doCallbacks(name);
708 }
709
710
711 void Settings::setDefault(const std::string &name, const std::string &value)
712 {
713         setEntry(name, &value, false, true);
714 }
715
716
717 void Settings::setGroup(const std::string &name, Settings *group)
718 {
719         setEntry(name, &group, true, false);
720 }
721
722
723 void Settings::setGroupDefault(const std::string &name, Settings *group)
724 {
725         setEntry(name, &group, true, true);
726 }
727
728
729 void Settings::setBool(const std::string &name, bool value)
730 {
731         set(name, value ? "true" : "false");
732 }
733
734
735 void Settings::setS16(const std::string &name, s16 value)
736 {
737         set(name, itos(value));
738 }
739
740
741 void Settings::setU16(const std::string &name, u16 value)
742 {
743         set(name, itos(value));
744 }
745
746
747 void Settings::setS32(const std::string &name, s32 value)
748 {
749         set(name, itos(value));
750 }
751
752
753 void Settings::setU64(const std::string &name, u64 value)
754 {
755         std::ostringstream os;
756         os << value;
757         set(name, os.str());
758 }
759
760
761 void Settings::setFloat(const std::string &name, float value)
762 {
763         set(name, ftos(value));
764 }
765
766
767 void Settings::setV2F(const std::string &name, v2f value)
768 {
769         std::ostringstream os;
770         os << "(" << value.X << "," << value.Y << ")";
771         set(name, os.str());
772 }
773
774
775 void Settings::setV3F(const std::string &name, v3f value)
776 {
777         std::ostringstream os;
778         os << "(" << value.X << "," << value.Y << "," << value.Z << ")";
779         set(name, os.str());
780 }
781
782
783 void Settings::setFlagStr(const std::string &name, u32 flags,
784         const FlagDesc *flagdesc, u32 flagmask)
785 {
786         set(name, writeFlagString(flags, flagdesc, flagmask));
787 }
788
789
790 bool Settings::setStruct(const std::string &name, const std::string &format,
791         void *value)
792 {
793         std::string structstr;
794         if (!serializeStructToString(&structstr, format, value))
795                 return false;
796
797         set(name, structstr);
798         return true;
799 }
800
801
802 void Settings::setNoiseParams(const std::string &name,
803         const NoiseParams &np, bool set_default)
804 {
805         Settings *group = new Settings;
806
807         group->setFloat("offset",      np.offset);
808         group->setFloat("scale",       np.scale);
809         group->setV3F("spread",        np.spread);
810         group->setS32("seed",          np.seed);
811         group->setU16("octaves",       np.octaves);
812         group->setFloat("persistence", np.persist);
813         group->setFloat("lacunarity",  np.lacunarity);
814         group->setFlagStr("flags",     np.flags, flagdesc_noiseparams, np.flags);
815
816         setEntry(name, &group, true, set_default);
817 }
818
819
820 bool Settings::remove(const std::string &name)
821 {
822         JMutexAutoLock lock(m_mutex);
823
824         delete m_settings[name].group;
825         return m_settings.erase(name);
826 }
827
828
829 void Settings::clear()
830 {
831         JMutexAutoLock lock(m_mutex);
832         clearNoLock();
833 }
834
835
836 void Settings::updateValue(const Settings &other, const std::string &name)
837 {
838         if (&other == this)
839                 return;
840
841         JMutexAutoLock lock(m_mutex);
842
843         try {
844                 std::string val = other.get(name);
845
846                 m_settings[name] = val;
847         } catch (SettingNotFoundException &e) {
848         }
849 }
850
851
852 void Settings::update(const Settings &other)
853 {
854         if (&other == this)
855                 return;
856
857         JMutexAutoLock lock(m_mutex);
858         JMutexAutoLock lock2(other.m_mutex);
859
860         updateNoLock(other);
861 }
862
863
864 SettingsParseEvent Settings::parseConfigObject(const std::string &line,
865         const std::string &end, std::string &name, std::string &value)
866 {
867         std::string trimmed_line = trim(line);
868
869         if (trimmed_line.empty())
870                 return SPE_NONE;
871         if (trimmed_line[0] == '#')
872                 return SPE_COMMENT;
873         if (trimmed_line == end)
874                 return SPE_END;
875
876         size_t pos = trimmed_line.find('=');
877         if (pos == std::string::npos)
878                 return SPE_INVALID;
879
880         name  = trim(trimmed_line.substr(0, pos));
881         value = trim(trimmed_line.substr(pos + 1));
882
883         if (value == "{")
884                 return SPE_GROUP;
885         if (value == "\"\"\"")
886                 return SPE_MULTILINE;
887
888         return SPE_KVPAIR;
889 }
890
891
892 void Settings::updateNoLock(const Settings &other)
893 {
894         m_settings.insert(other.m_settings.begin(), other.m_settings.end());
895         m_defaults.insert(other.m_defaults.begin(), other.m_defaults.end());
896 }
897
898
899 void Settings::clearNoLock()
900 {
901         std::map<std::string, SettingsEntry>::const_iterator it;
902         for (it = m_settings.begin(); it != m_settings.end(); ++it)
903                 delete it->second.group;
904         m_settings.clear();
905
906         for (it = m_defaults.begin(); it != m_defaults.end(); ++it)
907                 delete it->second.group;
908         m_defaults.clear();
909 }
910
911
912 void Settings::registerChangedCallback(std::string name,
913         setting_changed_callback cbf)
914 {
915         m_callbacks[name].push_back(cbf);
916 }
917
918
919 void Settings::doCallbacks(const std::string name)
920 {
921         std::vector<setting_changed_callback> tempvector;
922         {
923                 JMutexAutoLock lock(m_mutex);
924                 if (m_callbacks.find(name) != m_callbacks.end())
925                 {
926                         tempvector = m_callbacks[name];
927                 }
928         }
929
930         std::vector<setting_changed_callback>::iterator iter;
931         for (iter = tempvector.begin(); iter != tempvector.end(); iter++)
932         {
933                 (*iter)(name);
934         }
935 }