diff options
author | senator <senator> | 2008-03-24 14:57:37 +0000 |
---|---|---|
committer | senator <senator> | 2008-03-24 14:57:37 +0000 |
commit | fdb7aadb054f233401a9f3dd882b79ac5ccd5191 (patch) | |
tree | 43f460bd29f8a7ad91ae1c04c395a827a9b48fb9 /client/main.cc | |
parent | 860e3e8a6af9108d74187c6a48a4d2428b312cbe (diff) |
exits if no cpr number and user is given
Diffstat (limited to 'client/main.cc')
-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(); |