cfg.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. int getIntOption(std::string option);
  28. std::string getWelcomeMessage();
  29. static int absolutepos(const std::string& position, int max, int width);
  30. static int string2int(const char* string, bool* ok = 0);
  31. static void split(std::vector<std::string>& v, const std::string& str,
  32. char c, bool useEmpty=true);
  33. static std::string Trim(const std::string& s);
  34. std::string nextSession(std::string current);
  35. private:
  36. void fillSessionList();
  37. private:
  38. std::map<std::string,std::string> options;
  39. std::vector<std::string> sessions;
  40. int currentSession;
  41. std::string error;
  42. };
  43. #endif /* _CFG_H_ */