Fix crash when providing bad command line argument
[clinton/bobotpp.git] / source / UserList.C
index b1038d0..afd49fa 100644 (file)
@@ -17,6 +17,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 // 02110-1301, USA.
 
+#include <cstdlib>
 #include <fstream>
 #include <iostream>
 
@@ -38,7 +39,7 @@ UserList::~UserList()
 void
 UserList::read()
 {
-  std::ifstream file(listFilename);
+  std::ifstream file(listFilename.c_str ());
   String temp, empty = "";
   int line = 1;
 
@@ -74,9 +75,9 @@ UserList::read()
          password = "";
        }
       
-      l.push_back(new UserListItem(mask, maskChannel, atoi(level),
-                                  atoi(prot), atoi(aop),
-                                  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++;
     }
 
@@ -87,7 +88,7 @@ void
 UserList::save()
 {
   std::list<UserListItem *>::iterator it = l.begin();
-  std::ofstream file(listFilename);
+  std::ofstream file(listFilename.c_str ());
   
   if (!file)
     return;