Commit 1350a74adf5594dff7165f44c16388e90d77f413
1 parent
453689cc
Exists in
master
and in
2 other branches
Adiciona exit code
Showing
1 changed file
with
50 additions
and
33 deletions
Show diff stats
main.cpp
| @@ -33,6 +33,7 @@ void serviceREC2(); | @@ -33,6 +33,7 @@ void serviceREC2(); | ||
| 33 | void help(); | 33 | void help(); |
| 34 | void fail(string msg); | 34 | void fail(string msg); |
| 35 | void hasFailed(); | 35 | void hasFailed(); |
| 36 | +void hasInvalid(); | ||
| 36 | string createFileToResponse(char* id); | 37 | string createFileToResponse(char* id); |
| 37 | void updateRequestStatus(const char* filename, char* id, char* status); | 38 | void updateRequestStatus(const char* filename, char* id, char* status); |
| 38 | string createFileToRespWeb(char* id); | 39 | string createFileToRespWeb(char* id); |
| @@ -40,6 +41,7 @@ void updateRequestStatusWeb(const char* filename, char* id, char* status); | @@ -40,6 +41,7 @@ void updateRequestStatusWeb(const char* filename, char* id, char* status); | ||
| 40 | 41 | ||
| 41 | string filename; | 42 | string filename; |
| 42 | bool isFailed; | 43 | bool isFailed; |
| 44 | +bool isInvalid; | ||
| 43 | 45 | ||
| 44 | int main(int argc, char* argv[]) { | 46 | int main(int argc, char* argv[]) { |
| 45 | 47 | ||
| @@ -56,12 +58,14 @@ int main(int argc, char* argv[]) { | @@ -56,12 +58,14 @@ int main(int argc, char* argv[]) { | ||
| 56 | switch((int) atoi(argv[1])){ | 58 | switch((int) atoi(argv[1])){ |
| 57 | case 1: | 59 | case 1: |
| 58 | serviceCC(); | 60 | serviceCC(); |
| 59 | - return 1; | 61 | + hasInvalid(); |
| 62 | + break; | ||
| 60 | case 2: | 63 | case 2: |
| 61 | if(argc <= 8){ | 64 | if(argc <= 8){ |
| 62 | cout << "\nParametros inválidos. Tente novamente.\nService Type SRT: ./vlibras 2 INPUT_VIDEO INPUT_SRT LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; | 65 | cout << "\nParametros inválidos. Tente novamente.\nService Type SRT: ./vlibras 2 INPUT_VIDEO INPUT_SRT LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; |
| 63 | help(); | 66 | help(); |
| 64 | - return 1; | 67 | + hasInvalid(); |
| 68 | + break; | ||
| 65 | } | 69 | } |
| 66 | serviceSRT(argv[2], argv[3], argv[4], argv[5], | 70 | serviceSRT(argv[2], argv[3], argv[4], argv[5], |
| 67 | argv[6], argv[7], argv[8]); | 71 | argv[6], argv[7], argv[8]); |
| @@ -70,7 +74,8 @@ int main(int argc, char* argv[]) { | @@ -70,7 +74,8 @@ int main(int argc, char* argv[]) { | ||
| 70 | if(argc <= 7){ | 74 | if(argc <= 7){ |
| 71 | cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 3 INPUT_VIDEO LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; | 75 | cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 3 INPUT_VIDEO LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; |
| 72 | help(); | 76 | help(); |
| 73 | - return 1; | 77 | + hasInvalid(); |
| 78 | + break; | ||
| 74 | } | 79 | } |
| 75 | if (argc == 8) | 80 | if (argc == 8) |
| 76 | serviceREC(argv[2], argv[3], argv[4], argv[5], | 81 | serviceREC(argv[2], argv[3], argv[4], argv[5], |
| @@ -83,7 +88,8 @@ int main(int argc, char* argv[]) { | @@ -83,7 +88,8 @@ int main(int argc, char* argv[]) { | ||
| 83 | if(argc <= 5){ | 88 | if(argc <= 5){ |
| 84 | cout << "\nParametros inválidos. Tente novamente.\nService Type Text: ./vlibras 4 INPUT_TEXT_FILE TRANSPARENCY{0=Opaque, 1=Transparent} ID CLIENT_TYPE{Desktop, Web}" << endl; | 89 | cout << "\nParametros inválidos. Tente novamente.\nService Type Text: ./vlibras 4 INPUT_TEXT_FILE TRANSPARENCY{0=Opaque, 1=Transparent} ID CLIENT_TYPE{Desktop, Web}" << endl; |
| 85 | help(); | 90 | help(); |
| 86 | - return 1; | 91 | + hasInvalid(); |
| 92 | + break; | ||
| 87 | } | 93 | } |
| 88 | serviceText(argv[2], argv[3], argv[4], argv[5]); | 94 | serviceText(argv[2], argv[3], argv[4], argv[5]); |
| 89 | break; | 95 | break; |
| @@ -91,27 +97,34 @@ int main(int argc, char* argv[]) { | @@ -91,27 +97,34 @@ int main(int argc, char* argv[]) { | ||
| 91 | if(argc <= 4){ | 97 | if(argc <= 4){ |
| 92 | cout << "\nParametros inválidos. Tente novamente.\nService Type SRT Only: ./vlibras 5 INPUT_SRT TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; | 98 | cout << "\nParametros inválidos. Tente novamente.\nService Type SRT Only: ./vlibras 5 INPUT_SRT TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; |
| 93 | help(); | 99 | help(); |
| 94 | - return 1; | 100 | + hasInvalid(); |
| 101 | + break; | ||
| 95 | } | 102 | } |
| 96 | serviceOnlySRT(argv[2], argv[3], argv[4]); | 103 | serviceOnlySRT(argv[2], argv[3], argv[4]); |
| 97 | break; | 104 | break; |
| 98 | case 6: | 105 | case 6: |
| 99 | serviceREC2(); | 106 | serviceREC2(); |
| 100 | - return 1; | 107 | + hasInvalid(); |
| 108 | + break; | ||
| 101 | default: | 109 | default: |
| 102 | cout << "\nServiço inválido. Tente novamente." << endl; | 110 | cout << "\nServiço inválido. Tente novamente." << endl; |
| 103 | help(); | 111 | help(); |
| 104 | - return 1; | 112 | + hasInvalid(); |
| 113 | + break; | ||
| 105 | } | 114 | } |
| 106 | 115 | ||
| 107 | - if(!isFailed){ | ||
| 108 | - gettimeofday(&tv2, NULL); | ||
| 109 | - t2 = (double)(tv2.tv_sec) + (double)(tv2.tv_usec)/ 1000000.00; | ||
| 110 | - cout << endl; | ||
| 111 | - DDPRINTF("Time: %lf\n", (t2-t1)); | ||
| 112 | - DDPRINTF("VLibras concluído!\n\n"); | ||
| 113 | - } | ||
| 114 | - return 1; | 116 | + if(isFailed) |
| 117 | + return 1; | ||
| 118 | + else if(isInvalid) | ||
| 119 | + return 127; | ||
| 120 | + | ||
| 121 | + gettimeofday(&tv2, NULL); | ||
| 122 | + t2 = (double)(tv2.tv_sec) + (double)(tv2.tv_usec)/ 1000000.00; | ||
| 123 | + cout << endl; | ||
| 124 | + DDPRINTF("Time: %lf\n", (t2-t1)); | ||
| 125 | + DDPRINTF("VLibras concluído!\n\n"); | ||
| 126 | + return 0; | ||
| 127 | + | ||
| 115 | } | 128 | } |
| 116 | 129 | ||
| 117 | void serviceCC(){ | 130 | void serviceCC(){ |
| @@ -228,24 +241,25 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | @@ -228,24 +241,25 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | ||
| 228 | 241 | ||
| 229 | //filename = createFileToRespWeb(id); | 242 | //filename = createFileToRespWeb(id); |
| 230 | if (strcmp(client_type, (char*)"WEB") == 0) { | 243 | if (strcmp(client_type, (char*)"WEB") == 0) { |
| 231 | - ServiceWindowGenerationFromText *service_text; | ||
| 232 | - service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); | ||
| 233 | - try{ | ||
| 234 | - service_text->initialize(); | ||
| 235 | - }catch(ServiceException ex){ | ||
| 236 | - fail(ex.getMessage()); | ||
| 237 | - hasFailed(); | ||
| 238 | - return; | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - while (service_text->isAlive()) { | ||
| 242 | - usleep(100000); //100ms | ||
| 243 | - } | ||
| 244 | - //updateRequestStatusWeb(filename.c_str(), id, "true"); | ||
| 245 | - delete service_text; | 244 | + ServiceWindowGenerationFromText *service_text; |
| 245 | + service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); | ||
| 246 | + try{ | ||
| 247 | + service_text->initialize(); | ||
| 248 | + }catch(ServiceException ex){ | ||
| 249 | + fail(ex.getMessage()); | ||
| 250 | + hasFailed(); | ||
| 251 | + return; | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + while (service_text->isAlive()) { | ||
| 255 | + usleep(100000); //100ms | ||
| 256 | + } | ||
| 257 | + //updateRequestStatusWeb(filename.c_str(), id, "true"); | ||
| 258 | + delete service_text; | ||
| 259 | + | ||
| 246 | } else { | 260 | } else { |
| 247 | - printf("ServicoIOS\n"); | ||
| 248 | - ServiceWindowGenerationFromText *service_text; | 261 | + printf("ServicoIOS\n"); |
| 262 | + ServiceWindowGenerationFromText *service_text; | ||
| 249 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); | 263 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); |
| 250 | try{ | 264 | try{ |
| 251 | service_text->initialize(); | 265 | service_text->initialize(); |
| @@ -261,7 +275,6 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | @@ -261,7 +275,6 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | ||
| 261 | //updateRequestStatusWeb(filename.c_str(), id, "true"); | 275 | //updateRequestStatusWeb(filename.c_str(), id, "true"); |
| 262 | delete service_text; | 276 | delete service_text; |
| 263 | 277 | ||
| 264 | - | ||
| 265 | } | 278 | } |
| 266 | 279 | ||
| 267 | } | 280 | } |
| @@ -325,6 +338,10 @@ void hasFailed(){ | @@ -325,6 +338,10 @@ void hasFailed(){ | ||
| 325 | isFailed = true; | 338 | isFailed = true; |
| 326 | } | 339 | } |
| 327 | 340 | ||
| 341 | +void hasInvalid(){ | ||
| 342 | + isInvalid = true; | ||
| 343 | +} | ||
| 344 | + | ||
| 328 | 345 | ||
| 329 | //Help do programa, explicando todos os parâmetros existentes... | 346 | //Help do programa, explicando todos os parâmetros existentes... |
| 330 | void help() { | 347 | void help() { |