src/server.c

changeset 59
3fa1de896666
parent 55
54ea19938d57
child 60
0c50aac49e55
equal deleted inserted replaced
58:7ba8a97a8b6e 59:3fa1de896666
73 FILE *pgnfile = fopen(settings->continuepgn, "r"); 73 FILE *pgnfile = fopen(settings->continuepgn, "r");
74 if (pgnfile) { 74 if (pgnfile) {
75 int result = read_pgn(pgnfile, &continuegame, 75 int result = read_pgn(pgnfile, &continuegame,
76 &(settings->gameinfo)); 76 &(settings->gameinfo));
77 fclose(pgnfile); 77 fclose(pgnfile);
78 if (result != EXIT_SUCCESS) { 78 if (result) {
79 addstr("Invalid PGN file content.\n"); 79 addstr("Invalid PGN file content.\n");
80 return EXIT_FAILURE; 80 return 1;
81 } 81 }
82 if (!is_game_running(&continuegame)) { 82 if (!is_game_running(&continuegame)) {
83 addstr("Game has ended. Use -S to analyze it.\n"); 83 addstr("Game has ended. Use -S to analyze it.\n");
84 return EXIT_FAILURE; 84 return 1;
85 } 85 }
86 addch('\n'); 86 addch('\n');
87 dump_moveinfo(&continuegame); 87 dump_moveinfo(&continuegame);
88 addch('\n'); 88 addch('\n');
89 } else { 89 } else {
90 printw("Can't read PGN file (%s)\n", strerror(errno)); 90 printw("Can't read PGN file (%s)\n", strerror(errno));
91 return EXIT_FAILURE; 91 return 1;
92 } 92 }
93 } 93 }
94 94
95 if (server_open(&server, settings->port)) { 95 if (server_open(&server, settings->port)) {
96 net_destroy(&server); 96 net_destroy(&server);
97 return EXIT_FAILURE; 97 return 1;
98 } 98 }
99 99
100 if (server_handshake(server.client)) { 100 if (server_handshake(server.client)) {
101 net_destroy(&server); 101 net_destroy(&server);
102 return EXIT_FAILURE; 102 return 1;
103 } 103 }
104 104
105 int fd = server.client->fd; 105 int fd = server.client->fd;
106 if (settings->continuepgn) { 106 if (settings->continuepgn) {
107 // Continue game, send PGN data 107 // Continue game, send PGN data
155 } else { 155 } else {
156 addstr("\rInvalid client response"); 156 addstr("\rInvalid client response");
157 clrtoeol(); 157 clrtoeol();
158 158
159 net_destroy(&server); 159 net_destroy(&server);
160 return EXIT_FAILURE; 160 return 1;
161 } 161 }
162 162
163 net_destroy(&server); 163 net_destroy(&server);
164 return EXIT_SUCCESS; 164 return 0;
165 } 165 }

mercurial