diff options
-rw-r--r-- | client/main.cc | 24 |
1 files changed, 15 insertions, 9 deletions
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(); |