dccConnections = new DCCManager ();
// Let's read the alias file
- std::ifstream initFile(initFileName);
+ std::ifstream initFile(initFileName.c_str ());
if (initFile)
{
void
Bot::readConfig()
{
- std::ifstream file(configFileName);
+ std::ifstream file(configFileName.c_str ());
String temp;
int line = 1;
else if (command == "LOCALIP")
localIP = parameters;
else if (command == "MAXNICKLENGTH")
- MAX_NICKLENGTH = std::atoi (parameters);
+ MAX_NICKLENGTH = std::atoi (parameters.c_str ());
else if (command == "SERVER") {
if (parameters.indexOf(' ') == -1)
serverList->addServer(new Server(parameters));
void
Bot::set_log_file (String name)
{
- logFileName = name;
+ logFileName = logs_dir + name;
logFile.close ();
logFile.clear ();
#if HAVE_IOSBASE
- logFile.open(logs_dir + logFileName, std::ios_base::out |
+ logFile.open(logFileName.c_str (), std::ios_base::out |
std::ios_base::ate | std::ios_base::app);
#else
- logFile.open(logs_dir + logFileName, ios::out | ios::ate
+ logFile.open(logFileName.c_str (), ios::out | ios::ate
| ios::app);
#endif
{
logs_dir = dir;
- DIR *temp = opendir (logs_dir);
+ DIR *temp = opendir (logs_dir.c_str ());
if (!temp)
{
- mkdir (logs_dir, S_IRWXU);
+ mkdir (logs_dir.c_str (), S_IRWXU);
}
else
{
// sys-dir
scm_c_define ("bot:sys-scripts-dir",
- scm_from_locale_string (String(PREFIX) +
- "/share/bobotpp/scripts/"));
+ scm_from_locale_string ((String(PREFIX) +
+ "/share/bobotpp/scripts/").c_str ()));
// Hooks
scm_c_define ("hooks/action", scm_from_int(Hook::ACTION));
scm_c_define ("hooks/nickname", scm_from_int(Hook::NICKNAME));
// load bobot-utils
scm_primitive_load
- (scm_from_locale_string (String(PREFIX) +
- "/share/bobotpp/scripts/bobot-utils.scm"));
+ (scm_from_locale_string ((String(PREFIX) +
+ "/share/bobotpp/scripts/bobot-utils.scm").c_str ()));
return SCM_UNSPECIFIED;
}
bot = b;
scm_internal_catch(SCM_BOOL_T,
- (scm_t_catch_body) lazy_eval_string, (void *) static_cast<const char *> (command),
+ (scm_t_catch_body) lazy_eval_string, (void *) static_cast<const char *> (command.c_str ()),
(scm_t_catch_handler) Interp::EmptyHandler, 0);
#ifdef MULTITHREAD
bot = b;
scm_internal_catch(SCM_BOOL_T,
(scm_t_catch_body) lazy_eval_file,
- (void *)static_cast<const char * >(filename),
+ (void *)static_cast<const char * >(filename.c_str ()),
(scm_t_catch_handler) Interp::EmptyHandler, 0);
#ifdef MULTITHREAD
// We release the lock
DIR * temp;
- if (! (temp = opendir (String(getenv ("HOME")) + "/.bobotpp/logs")))
+ if (! (temp = opendir ((String(getenv ("HOME")) + "/.bobotpp/logs").c_str ())))
{
- mkdir (String(getenv ("HOME")) + "/.bobotpp/logs",
+ mkdir ((String(getenv ("HOME")) + "/.bobotpp/logs").c_str (),
S_IRWXU);
}
else
bool
Mask::matches(String s) const
{
- return match((const char *)mask, (const char *)s);
+ return match(mask.c_str (), s.c_str ());
}
bool
Mask::matches(const Mask & m) const
{
- return match((const char *)mask, (const char *)m.mask);
+ return match(mask.c_str (), m.mask.c_str ());
}
bool
void
ShitList::read()
{
- std::ifstream file(listFileName);
+ std::ifstream file(listFileName.c_str ());
String temp;
int line = 1;
String level = st.next_token(':');
String expiration = st.next_token(':');
String reason = Utils::trim_str (st.rest());
- l.push_back (new ShitEntry(mask, channelMask, std::atoi(level),
- std::atol(expiration), reason));
+ l.push_back (new ShitEntry(mask, channelMask, std::atoi(level.c_str ()),
+ std::atol(expiration.c_str ()), reason));
line++;
}
file.close();
ShitList::save()
{
std::list<ShitEntry *>::iterator it = l.begin();
- std::ofstream file(listFileName);
+ std::ofstream file(listFileName.c_str ());
if (!file)
return;
{
struct hostent *host;
- if ((host = gethostbyname((const char *)hostname)) == 0)
+ if ((host = gethostbyname(hostname.c_str ())) == 0)
return false;
memcpy(&remoteAddress, host->h_addr, host->h_length);
{
struct hostent *host;
- if ((host = gethostbyname((const char *)hostname)) == 0)
+ if ((host = gethostbyname(hostname.c_str ())) == 0)
return false;
memcpy(&localAddress, host->h_addr, host->h_length);
return false;
if (m) {
- if (::write(fd->fd, (const char *)s, s.length()) +
+ if (::write(fd->fd, s.c_str (), s.length()) +
::write(fd->fd, "\n", 1) != s.length() + 1)
return false;
}
else
- if (::write(fd->fd, (const char *)s, s.length()) +
+ if (::write(fd->fd, s.c_str (), s.length()) +
::write(fd->fd, "\r\n", 2) != s.length() + 2)
return false;
return my_string + s;
}
-String::operator const char *() const
-{
- return my_string.c_str ();
-}
+const char*
+String::c_str () const
+ {
+ return my_string.c_str ();
+ }
String::operator std::string () const
{
friend std::string operator+(const std::string &, const String &);
- operator const char *() const;
+ const char* c_str () const;
operator std::string () const;
friend std::ostream & operator<<(std::ostream &, const String &);
bool a;
time_t e;
- l = atoi((const char *)level);
+ l = atoi(level.c_str ());
if (l < 0 || l > User::FRIEND)
return;
if (l > Utils::get_level(cnx->bot, from->getAddress())) {
from->sendNotice("\002You can not give a level greater than yours.\002");
return;
}
- p = atoi((const char *)prot);
+ p = atoi(prot.c_str ());
if (p < 0 || p > User::NO_DEOP)
return;
- a = (bool)atoi((const char *)aop);
+ a = (bool)atoi(aop.c_str ());
if (a != 0 && a != 1)
return;
if (st.more_tokens_p()) {
String temp = st.next_token();
- port = atoi((const char *)temp);
+ port = atoi(temp.c_str ());
}
Message m = Commands::AddServer(cnx->bot, serverName, port);
int l;
time_t e;
- l = atoi((const char *)level);
+ l = atoi(level.c_str ());
if (l < 0 || l > ShitEntry::SHIT_NODEBAN)
return;
if (result == "")
from->sendNotice("\002I am not on any channel.\002");
else
- from->sendNotice(String("\002I am currently on channel(s):\002 ") +
+ from->sendNotice(String("\002I am currently on channel(s):\002 ")
+ result);
}
return;
}
- int serverNumber = atoi(rest);
+ int serverNumber = atoi(rest.c_str ());
Message m = Commands::DelServer(cnx->bot, serverNumber);
if (m.getCode() != 0)
StringTokenizer st(rest);
String command = Utils::to_upper (st.next_token());
- std::ifstream helpFile(cnx->bot->helpFileName);
+ std::ifstream helpFile(cnx->bot->helpFileName.c_str ());
if (!helpFile) {
from->sendNotice(String("\002Error: I can not find the "
return;
}
- serverNumber = atoi(rest);
+ serverNumber = atoi(rest.c_str ());
if (serverNumber < 0 || serverNumber >= cnx->bot->serverList->size()) {
from->sendNotice(String((long)serverNumber) +
UserCommands::SetFloodRate(ServerConnection *cnx, Person *from,
String channel, String rest)
{
- Message m = Commands::SetFloodRate (cnx->bot, std::atoi (rest));
+ Message m = Commands::SetFloodRate (cnx->bot, std::atoi (rest.c_str ()));
if (m.getCode ())
from->sendNotice (m.getMessage ());
else
- from->sendNotice ("Flood Rate set to:" + String(std::atol(rest)));
+ from->sendNotice ("Flood Rate set to:" + String(std::atol(rest.c_str ())));
}
void
void
UserList::read()
{
- std::ifstream file(listFilename);
+ std::ifstream file(listFilename.c_str ());
String temp, empty = "";
int line = 1;
password = "";
}
- l.push_back(new UserListItem(mask, maskChannel, std::atoi(level),
- std::atoi(prot), std::atoi(aop),
- std::atol(expiration), password));
+ l.push_back(new UserListItem(mask, maskChannel, std::atoi(level.c_str ()),
+ std::atoi(prot.c_str ()), std::atoi(aop.c_str ()),
+ std::atol(expiration.c_str ()), password));
line++;
}
UserList::save()
{
std::list<UserListItem *>::iterator it = l.begin();
- std::ofstream file(listFilename);
+ std::ofstream file(listFilename.c_str ());
if (!file)
return;