| 1 |
sf-pippijn |
1.1 |
#include "deliantra/exception.h" |
| 2 |
|
|
|
| 3 |
|
|
int |
| 4 |
|
|
main (int argc, char *argv[]) |
| 5 |
|
|
try |
| 6 |
|
|
{ |
| 7 |
|
|
setlocale (LC_ALL, ""); |
| 8 |
|
|
|
| 9 |
|
|
if (argc == 2 && !strcmp (argv[1], "--version")) |
| 10 |
|
|
{ |
| 11 |
|
|
printf ("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); |
| 12 |
|
|
return EXIT_SUCCESS; |
| 13 |
|
|
} |
| 14 |
|
|
|
| 15 |
|
|
if (argc < 3 || !strcmp (argv[1], "--help")) |
| 16 |
|
|
{ |
| 17 |
|
|
printf ("Usage: %s <host> <port> [user] [password]\n", PACKAGE); |
| 18 |
|
|
return EXIT_SUCCESS; |
| 19 |
|
|
} |
| 20 |
|
|
|
| 21 |
|
|
std::string server, port, user, pass; |
| 22 |
|
|
|
| 23 |
|
|
server = argv[1]; |
| 24 |
|
|
port = argv[2]; |
| 25 |
|
|
if (argc == 5) |
| 26 |
|
|
{ |
| 27 |
|
|
user = argv[3]; |
| 28 |
|
|
pass = argv[4]; |
| 29 |
|
|
} |
| 30 |
|
|
|
| 31 |
|
|
start_game (server, port, user, pass); |
| 32 |
|
|
|
| 33 |
|
|
return EXIT_SUCCESS; |
| 34 |
|
|
} |
| 35 |
|
|
catch (exit_success const &e) |
| 36 |
|
|
{ |
| 37 |
|
|
LOG ("exception") << e.what () << "\n"; |
| 38 |
|
|
printf ("exiting: %s\n", e.what ()); |
| 39 |
|
|
return EXIT_SUCCESS; |
| 40 |
|
|
} |
| 41 |
|
|
catch (std::exception const &e) |
| 42 |
|
|
{ |
| 43 |
|
|
LOG ("exception") << e.what () << "\n"; |
| 44 |
|
|
printf ("exception caught: %s\n", e.what ()); |
| 45 |
|
|
return EXIT_FAILURE; |
| 46 |
|
|
} |
| 47 |
|
|
catch (int i) |
| 48 |
|
|
{ |
| 49 |
|
|
LOG ("exception") << '0' << std::oct << std::setfill ('0') << std::setw (3) << i << "\n"; |
| 50 |
|
|
printf ("exception caught: 0%03o\n", i); |
| 51 |
|
|
return EXIT_FAILURE; |
| 52 |
|
|
} |
| 53 |
|
|
catch (std::string const &s) |
| 54 |
|
|
{ |
| 55 |
|
|
LOG ("exception") << s << "\n"; |
| 56 |
|
|
printf ("exception caught: %s\n", s.c_str ()); |
| 57 |
|
|
return EXIT_FAILURE; |
| 58 |
|
|
} |
| 59 |
|
|
catch (char const *s) |
| 60 |
|
|
{ |
| 61 |
|
|
LOG ("exception") << s << "\n"; |
| 62 |
|
|
printf ("exception caught: %s\n", s); |
| 63 |
|
|
return EXIT_FAILURE; |
| 64 |
|
|
} |
| 65 |
|
|
catch (...) |
| 66 |
|
|
{ |
| 67 |
|
|
LOG ("exception"); |
| 68 |
|
|
puts ("exception caught"); |
| 69 |
|
|
return EXIT_FAILURE; |
| 70 |
|
|
} |