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 | 33 | void help(); |
34 | 34 | void fail(string msg); |
35 | 35 | void hasFailed(); |
36 | +void hasInvalid(); | |
36 | 37 | string createFileToResponse(char* id); |
37 | 38 | void updateRequestStatus(const char* filename, char* id, char* status); |
38 | 39 | string createFileToRespWeb(char* id); |
... | ... | @@ -40,6 +41,7 @@ void updateRequestStatusWeb(const char* filename, char* id, char* status); |
40 | 41 | |
41 | 42 | string filename; |
42 | 43 | bool isFailed; |
44 | +bool isInvalid; | |
43 | 45 | |
44 | 46 | int main(int argc, char* argv[]) { |
45 | 47 | |
... | ... | @@ -56,12 +58,14 @@ int main(int argc, char* argv[]) { |
56 | 58 | switch((int) atoi(argv[1])){ |
57 | 59 | case 1: |
58 | 60 | serviceCC(); |
59 | - return 1; | |
61 | + hasInvalid(); | |
62 | + break; | |
60 | 63 | case 2: |
61 | 64 | if(argc <= 8){ |
62 | 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 | 66 | help(); |
64 | - return 1; | |
67 | + hasInvalid(); | |
68 | + break; | |
65 | 69 | } |
66 | 70 | serviceSRT(argv[2], argv[3], argv[4], argv[5], |
67 | 71 | argv[6], argv[7], argv[8]); |
... | ... | @@ -70,7 +74,8 @@ int main(int argc, char* argv[]) { |
70 | 74 | if(argc <= 7){ |
71 | 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 | 76 | help(); |
73 | - return 1; | |
77 | + hasInvalid(); | |
78 | + break; | |
74 | 79 | } |
75 | 80 | if (argc == 8) |
76 | 81 | serviceREC(argv[2], argv[3], argv[4], argv[5], |
... | ... | @@ -83,7 +88,8 @@ int main(int argc, char* argv[]) { |
83 | 88 | if(argc <= 5){ |
84 | 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 | 90 | help(); |
86 | - return 1; | |
91 | + hasInvalid(); | |
92 | + break; | |
87 | 93 | } |
88 | 94 | serviceText(argv[2], argv[3], argv[4], argv[5]); |
89 | 95 | break; |
... | ... | @@ -91,27 +97,34 @@ int main(int argc, char* argv[]) { |
91 | 97 | if(argc <= 4){ |
92 | 98 | cout << "\nParametros inválidos. Tente novamente.\nService Type SRT Only: ./vlibras 5 INPUT_SRT TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; |
93 | 99 | help(); |
94 | - return 1; | |
100 | + hasInvalid(); | |
101 | + break; | |
95 | 102 | } |
96 | 103 | serviceOnlySRT(argv[2], argv[3], argv[4]); |
97 | 104 | break; |
98 | 105 | case 6: |
99 | 106 | serviceREC2(); |
100 | - return 1; | |
107 | + hasInvalid(); | |
108 | + break; | |
101 | 109 | default: |
102 | 110 | cout << "\nServiço inválido. Tente novamente." << endl; |
103 | 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 | 130 | void serviceCC(){ |
... | ... | @@ -228,24 +241,25 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ |
228 | 241 | |
229 | 242 | //filename = createFileToRespWeb(id); |
230 | 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 | 260 | } else { |
247 | - printf("ServicoIOS\n"); | |
248 | - ServiceWindowGenerationFromText *service_text; | |
261 | + printf("ServicoIOS\n"); | |
262 | + ServiceWindowGenerationFromText *service_text; | |
249 | 263 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); |
250 | 264 | try{ |
251 | 265 | service_text->initialize(); |
... | ... | @@ -261,7 +275,6 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ |
261 | 275 | //updateRequestStatusWeb(filename.c_str(), id, "true"); |
262 | 276 | delete service_text; |
263 | 277 | |
264 | - | |
265 | 278 | } |
266 | 279 | |
267 | 280 | } |
... | ... | @@ -325,6 +338,10 @@ void hasFailed(){ |
325 | 338 | isFailed = true; |
326 | 339 | } |
327 | 340 | |
341 | +void hasInvalid(){ | |
342 | + isInvalid = true; | |
343 | +} | |
344 | + | |
328 | 345 | |
329 | 346 | //Help do programa, explicando todos os parâmetros existentes... |
330 | 347 | void help() { | ... | ... |