From fdb7aadb054f233401a9f3dd882b79ac5ccd5191 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 24 Mar 2008 14:57:37 +0000 Subject: exits if no cpr number and user is given --- client/main.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'client') diff --git a/client/main.cc b/client/main.cc index af3dbf5..ca0d2c1 100644 --- a/client/main.cc +++ b/client/main.cc @@ -40,9 +40,9 @@ int main(int argc, char *argv[]) MyEventHandler *eventhandler = new MyEventHandler(); app.installEventFilter( eventhandler ); - char macro[100] = "example"; - char _cpr[11] = "0000000000"; - char _user[20] = "testuser"; + char macro[100] = "start"; + char _cpr[11] = ""; + char _user[20] = ""; char config[30] = "pracro.ini"; int a; @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) printf("Missing argument for macro, exiting...\n"); exit(1); } - strcpy(macro, argv[a+1]); + strncpy(macro, argv[a+1], sizeof(macro) - 1); a++; continue; } @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) printf("Missing argument for cpr, exiting...\n"); exit(1); } - strcpy(_cpr, argv[a+1]); + strncpy(_cpr, argv[a+1], sizeof(_cpr) - 1); a++; continue; } @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) printf("Missing argument for user, exiting...\n"); exit(1); } - strcpy(_user, argv[a+1]); + strncpy(_user, argv[a+1], sizeof(_user) - 1); a++; continue; } @@ -94,15 +94,21 @@ int main(int argc, char *argv[]) printf("Missing argument for config, exiting...\n"); exit(1); } - strcpy(config, argv[a+1]); + strncpy(config, argv[a+1], sizeof(config) - 1); a++; continue; } } - + cpr = _cpr; user = _user; - new_macro("start"); + + if(cpr == "" || user == "") { + printf("cpr and user not set, exiting...\n"); + return 1; + } + + new_macro(macro); //app.setQuitOnLastWindowClosed(false); return app.exec(); -- cgit v1.2.3