/usr/lib/Wt/examples/hangman/HangmanDb.h is in witty-examples 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #ifndef DB_H_
#define DB_H_
#include <string>
#include <vector>
class HangmanDb
{
public:
// this function returns false if user existed, true if user inserted
// It guarantees atomic userExists() checking and adding it if the user
// did not yet exits.
static bool addUser(const std::wstring &user, const std::wstring &password);
// This function returns true when the credentials are found in the
// database, otherwise false
static bool validLogin(const std::wstring &user, const std::wstring &pass);
// Increments the number of games played, and adds delta to the score
static void addToScore(const std::wstring &user, int delta);
struct Score {
int number; // position of the user
std::wstring user;
int numgames;
int score;
std::wstring lastseen; // Last seen, in GMT
};
// Returns the top n highest scoring users
static std::vector<Score> getHighScores(int top);
// Returns the score structure for the given user
static Score getUserPosition(const std::wstring &user);
private:
static std::string DbUser();
static std::string DbPass();
};
#endif
|