configuration.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: configuration.cc,v 1.28 2004/04/30 04:00:15 mdz Exp $
  4. /* ######################################################################
  5. Configuration Class
  6. This class provides a configuration file and command line parser
  7. for a tree-oriented configuration environment. All runtime configuration
  8. is stored in here.
  9. This source is placed in the Public Domain, do with it what you will
  10. It was originally written by Jason Gunthorpe <jgg@debian.org>.
  11. ##################################################################### */
  12. /*}}}*/
  13. // Include files /*{{{*/
  14. #ifdef __GNUG__
  15. #pragma implementation "apt-pkg/configuration.h"
  16. #endif
  17. #include <apt-pkg/configuration.h>
  18. #include <apt-pkg/error.h>
  19. #include <apt-pkg/strutl.h>
  20. #include <apt-pkg/fileutl.h>
  21. #include <apti18n.h>
  22. #include <vector>
  23. #include <algorithm>
  24. #include <fstream>
  25. #include <iostream>
  26. #include <stdio.h>
  27. #include <dirent.h>
  28. #include <sys/stat.h>
  29. #include <unistd.h>
  30. using namespace std;
  31. /*}}}*/
  32. Configuration *_config = new Configuration;
  33. // Configuration::Configuration - Constructor /*{{{*/
  34. // ---------------------------------------------------------------------
  35. /* */
  36. Configuration::Configuration() : ToFree(true)
  37. {
  38. Root = new Item;
  39. }
  40. Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
  41. {
  42. };
  43. /*}}}*/
  44. // Configuration::~Configuration - Destructor /*{{{*/
  45. // ---------------------------------------------------------------------
  46. /* */
  47. Configuration::~Configuration()
  48. {
  49. if (ToFree == false)
  50. return;
  51. Item *Top = Root;
  52. for (; Top != 0;)
  53. {
  54. if (Top->Child != 0)
  55. {
  56. Top = Top->Child;
  57. continue;
  58. }
  59. while (Top != 0 && Top->Next == 0)
  60. {
  61. Item *Parent = Top->Parent;
  62. delete Top;
  63. Top = Parent;
  64. }
  65. if (Top != 0)
  66. {
  67. Item *Next = Top->Next;
  68. delete Top;
  69. Top = Next;
  70. }
  71. }
  72. }
  73. /*}}}*/
  74. // Configuration::Lookup - Lookup a single item /*{{{*/
  75. // ---------------------------------------------------------------------
  76. /* This will lookup a single item by name below another item. It is a
  77. helper function for the main lookup function */
  78. Configuration::Item *Configuration::Lookup(Item *Head,const char *S,
  79. unsigned long Len,bool Create)
  80. {
  81. int Res = 1;
  82. Item *I = Head->Child;
  83. Item **Last = &Head->Child;
  84. // Empty strings match nothing. They are used for lists.
  85. if (Len != 0)
  86. {
  87. for (; I != 0; Last = &I->Next, I = I->Next)
  88. if ((Res = stringcasecmp(I->Tag,S,S + Len)) == 0)
  89. break;
  90. }
  91. else
  92. for (; I != 0; Last = &I->Next, I = I->Next);
  93. if (Res == 0)
  94. return I;
  95. if (Create == false)
  96. return 0;
  97. I = new Item;
  98. I->Tag = string(S,Len);
  99. I->Next = *Last;
  100. I->Parent = Head;
  101. *Last = I;
  102. return I;
  103. }
  104. /*}}}*/
  105. // Configuration::Lookup - Lookup a fully scoped item /*{{{*/
  106. // ---------------------------------------------------------------------
  107. /* This performs a fully scoped lookup of a given name, possibly creating
  108. new items */
  109. Configuration::Item *Configuration::Lookup(const char *Name,bool Create)
  110. {
  111. if (Name == 0)
  112. return Root->Child;
  113. const char *Start = Name;
  114. const char *End = Start + strlen(Name);
  115. const char *TagEnd = Name;
  116. Item *Itm = Root;
  117. for (; End - TagEnd >= 2; TagEnd++)
  118. {
  119. if (TagEnd[0] == ':' && TagEnd[1] == ':')
  120. {
  121. Itm = Lookup(Itm,Start,TagEnd - Start,Create);
  122. if (Itm == 0)
  123. return 0;
  124. TagEnd = Start = TagEnd + 2;
  125. }
  126. }
  127. // This must be a trailing ::, we create unique items in a list
  128. if (End - Start == 0)
  129. {
  130. if (Create == false)
  131. return 0;
  132. }
  133. Itm = Lookup(Itm,Start,End - Start,Create);
  134. return Itm;
  135. }
  136. /*}}}*/
  137. // Configuration::Find - Find a value /*{{{*/
  138. // ---------------------------------------------------------------------
  139. /* */
  140. string Configuration::Find(const char *Name,const char *Default) const
  141. {
  142. const Item *Itm = Lookup(Name);
  143. if (Itm == 0 || Itm->Value.empty() == true)
  144. {
  145. if (Default == 0)
  146. return string();
  147. else
  148. return Default;
  149. }
  150. return Itm->Value;
  151. }
  152. /*}}}*/
  153. // Configuration::FindFile - Find a Filename /*{{{*/
  154. // ---------------------------------------------------------------------
  155. /* Directories are stored as the base dir in the Parent node and the
  156. sub directory in sub nodes with the final node being the end filename
  157. */
  158. string Configuration::FindFile(const char *Name,const char *Default) const
  159. {
  160. const Item *Itm = Lookup(Name);
  161. if (Itm == 0 || Itm->Value.empty() == true)
  162. {
  163. if (Default == 0)
  164. return string();
  165. else
  166. return Default;
  167. }
  168. string val = Itm->Value;
  169. while (Itm->Parent != 0 && Itm->Parent->Value.empty() == false)
  170. {
  171. // Absolute
  172. if (val.length() >= 1 && val[0] == '/')
  173. break;
  174. // ~/foo or ./foo
  175. if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/')
  176. break;
  177. // ../foo
  178. if (val.length() >= 3 && val[0] == '.' && val[1] == '.' && val[2] == '/')
  179. break;
  180. if (Itm->Parent->Value.end()[-1] != '/')
  181. val.insert(0, "/");
  182. val.insert(0, Itm->Parent->Value);
  183. Itm = Itm->Parent;
  184. }
  185. return val;
  186. }
  187. /*}}}*/
  188. // Configuration::FindDir - Find a directory name /*{{{*/
  189. // ---------------------------------------------------------------------
  190. /* This is like findfile execept the result is terminated in a / */
  191. string Configuration::FindDir(const char *Name,const char *Default) const
  192. {
  193. string Res = FindFile(Name,Default);
  194. if (Res.end()[-1] != '/')
  195. return Res + '/';
  196. return Res;
  197. }
  198. /*}}}*/
  199. // Configuration::FindI - Find an integer value /*{{{*/
  200. // ---------------------------------------------------------------------
  201. /* */
  202. int Configuration::FindI(const char *Name,int Default) const
  203. {
  204. const Item *Itm = Lookup(Name);
  205. if (Itm == 0 || Itm->Value.empty() == true)
  206. return Default;
  207. char *End;
  208. int Res = strtol(Itm->Value.c_str(),&End,0);
  209. if (End == Itm->Value.c_str())
  210. return Default;
  211. return Res;
  212. }
  213. /*}}}*/
  214. // Configuration::FindB - Find a boolean type /*{{{*/
  215. // ---------------------------------------------------------------------
  216. /* */
  217. bool Configuration::FindB(const char *Name,bool Default) const
  218. {
  219. const Item *Itm = Lookup(Name);
  220. if (Itm == 0 || Itm->Value.empty() == true)
  221. return Default;
  222. return StringToBool(Itm->Value,Default);
  223. }
  224. /*}}}*/
  225. // Configuration::FindAny - Find an arbitrary type /*{{{*/
  226. // ---------------------------------------------------------------------
  227. /* a key suffix of /f, /d, /b or /i calls Find{File,Dir,B,I} */
  228. string Configuration::FindAny(const char *Name,const char *Default) const
  229. {
  230. string key = Name;
  231. char type = 0;
  232. if (key.size() > 2 && key.end()[-2] == '/')
  233. {
  234. type = key.end()[-1];
  235. key.resize(key.size() - 2);
  236. }
  237. switch (type)
  238. {
  239. // file
  240. case 'f':
  241. return FindFile(key.c_str(), Default);
  242. // directory
  243. case 'd':
  244. return FindDir(key.c_str(), Default);
  245. // bool
  246. case 'b':
  247. return FindB(key, Default) ? "true" : "false";
  248. // int
  249. case 'i':
  250. {
  251. char buf[16];
  252. snprintf(buf, sizeof(buf)-1, "%d", FindI(key, Default ? atoi(Default) : 0 ));
  253. return buf;
  254. }
  255. }
  256. // fallback
  257. return Find(Name, Default);
  258. }
  259. /*}}}*/
  260. // Configuration::CndSet - Conditinal Set a value /*{{{*/
  261. // ---------------------------------------------------------------------
  262. /* This will not overwrite */
  263. void Configuration::CndSet(const char *Name,string Value)
  264. {
  265. Item *Itm = Lookup(Name,true);
  266. if (Itm == 0)
  267. return;
  268. if (Itm->Value.empty() == true)
  269. Itm->Value = Value;
  270. }
  271. /*}}}*/
  272. // Configuration::Set - Set a value /*{{{*/
  273. // ---------------------------------------------------------------------
  274. /* */
  275. void Configuration::Set(const char *Name,string Value)
  276. {
  277. Item *Itm = Lookup(Name,true);
  278. if (Itm == 0)
  279. return;
  280. Itm->Value = Value;
  281. }
  282. /*}}}*/
  283. // Configuration::Set - Set an integer value /*{{{*/
  284. // ---------------------------------------------------------------------
  285. /* */
  286. void Configuration::Set(const char *Name,int Value)
  287. {
  288. Item *Itm = Lookup(Name,true);
  289. if (Itm == 0)
  290. return;
  291. char S[300];
  292. snprintf(S,sizeof(S),"%i",Value);
  293. Itm->Value = S;
  294. }
  295. /*}}}*/
  296. // Configuration::Clear - Clear an entire tree /*{{{*/
  297. // ---------------------------------------------------------------------
  298. /* */
  299. void Configuration::Clear(string Name)
  300. {
  301. Item *Top = Lookup(Name.c_str(),false);
  302. if (Top == 0)
  303. return;
  304. Top->Value = string();
  305. Item *Stop = Top;
  306. Top = Top->Child;
  307. Stop->Child = 0;
  308. for (; Top != 0;)
  309. {
  310. if (Top->Child != 0)
  311. {
  312. Top = Top->Child;
  313. continue;
  314. }
  315. while (Top != 0 && Top->Next == 0)
  316. {
  317. Item *Tmp = Top;
  318. Top = Top->Parent;
  319. delete Tmp;
  320. if (Top == Stop)
  321. return;
  322. }
  323. Item *Tmp = Top;
  324. if (Top != 0)
  325. Top = Top->Next;
  326. delete Tmp;
  327. }
  328. }
  329. /*}}}*/
  330. // Configuration::Exists - Returns true if the Name exists /*{{{*/
  331. // ---------------------------------------------------------------------
  332. /* */
  333. bool Configuration::Exists(const char *Name) const
  334. {
  335. const Item *Itm = Lookup(Name);
  336. if (Itm == 0)
  337. return false;
  338. return true;
  339. }
  340. /*}}}*/
  341. // Configuration::ExistsAny - Returns true if the Name, possibly /*{{{*/
  342. // ---------------------------------------------------------------------
  343. /* qualified by /[fdbi] exists */
  344. bool Configuration::ExistsAny(const char *Name) const
  345. {
  346. string key = Name;
  347. if (key.size() > 2 && key.end()[-2] == '/')
  348. if (key.find_first_of("fdbi",key.size()-1) < key.size())
  349. {
  350. key.resize(key.size() - 2);
  351. if (Exists(key.c_str()))
  352. return true;
  353. }
  354. else
  355. {
  356. _error->Warning(_("Unrecognized type abbreviation: '%c'"), key.end()[-3]);
  357. }
  358. return Exists(Name);
  359. }
  360. /*}}}*/
  361. // Configuration::Dump - Dump the config /*{{{*/
  362. // ---------------------------------------------------------------------
  363. /* Dump the entire configuration space */
  364. void Configuration::Dump(ostream& str)
  365. {
  366. /* Write out all of the configuration directives by walking the
  367. configuration tree */
  368. const Configuration::Item *Top = Tree(0);
  369. for (; Top != 0;)
  370. {
  371. str << Top->FullTag() << " \"" << Top->Value << "\";" << endl;
  372. if (Top->Child != 0)
  373. {
  374. Top = Top->Child;
  375. continue;
  376. }
  377. while (Top != 0 && Top->Next == 0)
  378. Top = Top->Parent;
  379. if (Top != 0)
  380. Top = Top->Next;
  381. }
  382. }
  383. /*}}}*/
  384. // Configuration::Item::FullTag - Return the fully scoped tag /*{{{*/
  385. // ---------------------------------------------------------------------
  386. /* Stop sets an optional max recursion depth if this item is being viewed as
  387. part of a sub tree. */
  388. string Configuration::Item::FullTag(const Item *Stop) const
  389. {
  390. if (Parent == 0 || Parent->Parent == 0 || Parent == Stop)
  391. return Tag;
  392. return Parent->FullTag(Stop) + "::" + Tag;
  393. }
  394. /*}}}*/
  395. // ReadConfigFile - Read a configuration file /*{{{*/
  396. // ---------------------------------------------------------------------
  397. /* The configuration format is very much like the named.conf format
  398. used in bind8, in fact this routine can parse most named.conf files.
  399. Sectional config files are like bind's named.conf where there are
  400. sections like 'zone "foo.org" { .. };' This causes each section to be
  401. added in with a tag like "zone::foo.org" instead of being split
  402. tag/value. AsSectional enables Sectional parsing.*/
  403. bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional,
  404. unsigned Depth)
  405. {
  406. // Open the stream for reading
  407. ifstream F(FName.c_str(),ios::in);
  408. if (!F != 0)
  409. return _error->Errno("ifstream::ifstream",_("Opening configuration file %s"),FName.c_str());
  410. char Buffer[1024];
  411. string LineBuffer;
  412. string Stack[100];
  413. unsigned int StackPos = 0;
  414. // Parser state
  415. string ParentTag;
  416. int CurLine = 0;
  417. bool InComment = false;
  418. while (F.eof() == false)
  419. {
  420. F.getline(Buffer,sizeof(Buffer));
  421. CurLine++;
  422. // This should be made to work instead, but this is better than looping
  423. if (F.fail() && !F.eof())
  424. return _error->Error(_("Line %d too long (max %d)"), CurLine, sizeof(Buffer));
  425. _strtabexpand(Buffer,sizeof(Buffer));
  426. _strstrip(Buffer);
  427. // Multi line comment
  428. if (InComment == true)
  429. {
  430. for (const char *I = Buffer; *I != 0; I++)
  431. {
  432. if (*I == '*' && I[1] == '/')
  433. {
  434. memmove(Buffer,I+2,strlen(I+2) + 1);
  435. InComment = false;
  436. break;
  437. }
  438. }
  439. if (InComment == true)
  440. continue;
  441. }
  442. // Discard single line comments
  443. bool InQuote = false;
  444. for (char *I = Buffer; *I != 0; I++)
  445. {
  446. if (*I == '"')
  447. InQuote = !InQuote;
  448. if (InQuote == true)
  449. continue;
  450. if (*I == '/' && I[1] == '/')
  451. {
  452. *I = 0;
  453. break;
  454. }
  455. }
  456. // Look for multi line comments
  457. InQuote = false;
  458. for (char *I = Buffer; *I != 0; I++)
  459. {
  460. if (*I == '"')
  461. InQuote = !InQuote;
  462. if (InQuote == true)
  463. continue;
  464. if (*I == '/' && I[1] == '*')
  465. {
  466. InComment = true;
  467. for (char *J = Buffer; *J != 0; J++)
  468. {
  469. if (*J == '*' && J[1] == '/')
  470. {
  471. memmove(I,J+2,strlen(J+2) + 1);
  472. InComment = false;
  473. break;
  474. }
  475. }
  476. if (InComment == true)
  477. {
  478. *I = 0;
  479. break;
  480. }
  481. }
  482. }
  483. // Blank
  484. if (Buffer[0] == 0)
  485. continue;
  486. // We now have a valid line fragment
  487. InQuote = false;
  488. for (char *I = Buffer; *I != 0;)
  489. {
  490. if (*I == '"')
  491. InQuote = !InQuote;
  492. if (InQuote == false && (*I == '{' || *I == ';' || *I == '}'))
  493. {
  494. // Put the last fragment into the buffer
  495. char *Start = Buffer;
  496. char *Stop = I;
  497. for (; Start != I && isspace(*Start) != 0; Start++);
  498. for (; Stop != Start && isspace(Stop[-1]) != 0; Stop--);
  499. if (LineBuffer.empty() == false && Stop - Start != 0)
  500. LineBuffer += ' ';
  501. LineBuffer += string(Start,Stop - Start);
  502. // Remove the fragment
  503. char TermChar = *I;
  504. memmove(Buffer,I + 1,strlen(I + 1) + 1);
  505. I = Buffer;
  506. // Syntax Error
  507. if (TermChar == '{' && LineBuffer.empty() == true)
  508. return _error->Error(_("Syntax error %s:%u: Block starts with no name."),FName.c_str(),CurLine);
  509. // No string on this line
  510. if (LineBuffer.empty() == true)
  511. {
  512. if (TermChar == '}')
  513. {
  514. if (StackPos == 0)
  515. ParentTag = string();
  516. else
  517. ParentTag = Stack[--StackPos];
  518. }
  519. continue;
  520. }
  521. // Parse off the tag
  522. string Tag;
  523. const char *Pos = LineBuffer.c_str();
  524. if (ParseQuoteWord(Pos,Tag) == false)
  525. return _error->Error(_("Syntax error %s:%u: Malformed tag"),FName.c_str(),CurLine);
  526. // Parse off the word
  527. string Word;
  528. bool NoWord = false;
  529. if (ParseCWord(Pos,Word) == false &&
  530. ParseQuoteWord(Pos,Word) == false)
  531. {
  532. if (TermChar != '{')
  533. {
  534. Word = Tag;
  535. Tag = "";
  536. }
  537. else
  538. NoWord = true;
  539. }
  540. if (strlen(Pos) != 0)
  541. return _error->Error(_("Syntax error %s:%u: Extra junk after value"),FName.c_str(),CurLine);
  542. // Go down a level
  543. if (TermChar == '{')
  544. {
  545. if (StackPos <= 100)
  546. Stack[StackPos++] = ParentTag;
  547. /* Make sectional tags incorperate the section into the
  548. tag string */
  549. if (AsSectional == true && Word.empty() == false)
  550. {
  551. Tag += "::" ;
  552. Tag += Word;
  553. Word = "";
  554. }
  555. if (ParentTag.empty() == true)
  556. ParentTag = Tag;
  557. else
  558. ParentTag += string("::") + Tag;
  559. Tag = string();
  560. }
  561. // Generate the item name
  562. string Item;
  563. if (ParentTag.empty() == true)
  564. Item = Tag;
  565. else
  566. {
  567. if (TermChar != '{' || Tag.empty() == false)
  568. Item = ParentTag + "::" + Tag;
  569. else
  570. Item = ParentTag;
  571. }
  572. // Specials
  573. if (Tag.length() >= 1 && Tag[0] == '#')
  574. {
  575. if (ParentTag.empty() == false)
  576. return _error->Error(_("Syntax error %s:%u: Directives can only be done at the top level"),FName.c_str(),CurLine);
  577. Tag.erase(Tag.begin());
  578. if (Tag == "clear")
  579. Conf.Clear(Word);
  580. else if (Tag == "include")
  581. {
  582. if (Depth > 10)
  583. return _error->Error(_("Syntax error %s:%u: Too many nested includes"),FName.c_str(),CurLine);
  584. if (Word.length() > 2 && Word.end()[-1] == '/')
  585. {
  586. if (ReadConfigDir(Conf,Word,AsSectional,Depth+1) == false)
  587. return _error->Error(_("Syntax error %s:%u: Included from here"),FName.c_str(),CurLine);
  588. }
  589. else
  590. {
  591. if (ReadConfigFile(Conf,Word,AsSectional,Depth+1) == false)
  592. return _error->Error(_("Syntax error %s:%u: Included from here"),FName.c_str(),CurLine);
  593. }
  594. }
  595. else
  596. return _error->Error(_("Syntax error %s:%u: Unsupported directive '%s'"),FName.c_str(),CurLine,Tag.c_str());
  597. }
  598. else
  599. {
  600. // Set the item in the configuration class
  601. if (NoWord == false)
  602. Conf.Set(Item,Word);
  603. }
  604. // Empty the buffer
  605. LineBuffer = string();
  606. // Move up a tag, but only if there is no bit to parse
  607. if (TermChar == '}')
  608. {
  609. if (StackPos == 0)
  610. ParentTag = string();
  611. else
  612. ParentTag = Stack[--StackPos];
  613. }
  614. }
  615. else
  616. I++;
  617. }
  618. // Store the fragment
  619. const char *Stripd = _strstrip(Buffer);
  620. if (*Stripd != 0 && LineBuffer.empty() == false)
  621. LineBuffer += " ";
  622. LineBuffer += Stripd;
  623. }
  624. if (LineBuffer.empty() == false)
  625. return _error->Error(_("Syntax error %s:%u: Extra junk at end of file"),FName.c_str(),CurLine);
  626. return true;
  627. }
  628. /*}}}*/
  629. // ReadConfigDir - Read a directory of config files /*{{{*/
  630. // ---------------------------------------------------------------------
  631. /* */
  632. bool ReadConfigDir(Configuration &Conf,string Dir,bool AsSectional,
  633. unsigned Depth)
  634. {
  635. DIR *D = opendir(Dir.c_str());
  636. if (D == 0)
  637. return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
  638. vector<string> List;
  639. for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
  640. {
  641. if (Ent->d_name[0] == '.')
  642. continue;
  643. // Skip bad file names ala run-parts
  644. const char *C = Ent->d_name;
  645. for (; *C != 0; C++)
  646. if (isalpha(*C) == 0 && isdigit(*C) == 0 && *C != '_' && *C != '-')
  647. break;
  648. if (*C != 0)
  649. continue;
  650. // Make sure it is a file and not something else
  651. string File = flCombine(Dir,Ent->d_name);
  652. struct stat St;
  653. if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
  654. continue;
  655. List.push_back(File);
  656. }
  657. closedir(D);
  658. sort(List.begin(),List.end());
  659. // Read the files
  660. for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
  661. if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
  662. return false;
  663. return true;
  664. }
  665. /*}}}*/