cfg.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SLiM - Simple Login Manager
  2. Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
  3. Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. */
  9. #ifndef _CFG_H_
  10. #define _CFG_H_
  11. #include <string>
  12. #include <map>
  13. #include <vector>
  14. #define INPUT_MAXLENGTH_NAME 30
  15. #define INPUT_MAXLENGTH_PASSWD 50
  16. #define CFGFILE SYSCONFDIR"/slim.conf"
  17. #define THEMESDIR PKGDATADIR"/themes"
  18. #define THEMESFILE "/slim.theme"
  19. class Cfg {
  20. public:
  21. Cfg();
  22. ~Cfg();
  23. bool readConf(std::string configfile);
  24. std::string parseOption(std::string line, std::string option);
  25. const std::string& getError() const;
  26. std::string& getOption(std::string option);
  27. std::string getWelcomeMessage();
  28. static int absolutepos(const std::string& position, int max, int width);
  29. static int string2int(const char* string, bool* ok = 0);
  30. static void split(std::vector<std::string>& v, const std::string& str,
  31. char c, bool useEmpty=true);
  32. static std::string Trim(const std::string& s);
  33. std::string nextSession(std::string current);
  34. private:
  35. void fillSessionList();
  36. private:
  37. std::map<std::string,std::string> options;
  38. std::vector<std::string> sessions;
  39. int currentSession;
  40. std::string error;
  41. };
  42. #endif