src/main.c

changeset 4
560e07f7a6a1
parent 3
3693fd2eb0e9
child 5
f7dfef88947d
equal deleted inserted replaced
3:3693fd2eb0e9 4:560e07f7a6a1
133 perror("Server shutdown failed"); 133 perror("Server shutdown failed");
134 } 134 }
135 } 135 }
136 136
137 return exitcode; 137 return exitcode;
138 }
139
140 static WINDOW* window;
141
142 void leavescr() {
143 mvprintw(getmaxy(window)-1, 0, "Leaving terminal-chess. Press any key...");
144 getch();
145 endwin();
138 } 146 }
139 147
140 int main(int argc, char **argv) { 148 int main(int argc, char **argv) {
141 srand(time(NULL)); 149 srand(time(NULL));
142 150
165 "Example: -t 150s\n" 173 "Example: -t 150s\n"
166 ); 174 );
167 return EXIT_SUCCESS; 175 return EXIT_SUCCESS;
168 } 176 }
169 177
170 initscr(); 178 window = initscr();
171 cbreak(); 179 cbreak();
172 atexit((void(*)(void)) endwin); 180 atexit(leavescr);
173 181
174 Server server; 182 Server server;
175 settings.server = &server; 183 settings.server = &server;
176 184
177 if (is_server(&settings)) { 185 if (is_server(&settings)) {
251 } else { 259 } else {
252 fprintf(stderr, "Server sent invalid gameinfo.\n"); 260 fprintf(stderr, "Server sent invalid gameinfo.\n");
253 } 261 }
254 } 262 }
255 263
256 getch(); /* TODO: remove */
257 return cleanup(&settings, EXIT_SUCCESS); 264 return cleanup(&settings, EXIT_SUCCESS);
258 } 265 }
259 266

mercurial