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 |