Advertisement
wandrake

Untitled

Jul 12th, 2011
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.63 KB | None | 0 0
  1. int main (int argc, char* argv[]) {
  2.     FILE* cityfile;
  3.     FILE* edgefile;
  4.  
  5.     int ret = EXIT_FAILURE;
  6.  
  7.     if (argc != 3) return ret;
  8.  
  9.     ec_meno1( signal_block_all() );
  10.  
  11.     ec_null( cityfile = fopen(argv[1], "r") );
  12.     ec_null( edgefile = fopen(argv[2], "r") );
  13.     ec_null( map = load_graph(cityfile, edgefile) );
  14.     ec_null( logfile = fopen(LOGFILE, "w") );
  15.  
  16.     ec_meno1( server_sock = createServerChannel(SOCKNAME) );
  17.     /*ec_null( authlist = authlist_new() );*/
  18.     ec_null( offers = offerlist_new() );
  19.     ec_null( requests = requestlist_new() );
  20.     ec_null( sessions = sessionlist_new() );
  21.  
  22.     login_init();
  23.  
  24.     ec_nzero( pthread_create(&request_dispatcher, NULL, dispatcher, NULL) );
  25.     ec_nzero( pthread_create(&request_match, NULL, match, logfile) );
  26.     ec_nzero( pthread_join(request_match, NULL) );
  27.  
  28.     printf("Match terminated...\n");
  29.  
  30.     ec_nzero( pthread_join(request_dispatcher, NULL) );
  31.  
  32.     printf("Dispatcher terminated...\n");
  33.  
  34.     ret = EXIT_SUCCESS;
  35.  
  36.     sessionlist_print(sessions);
  37.     requestlist_print(requests);
  38.     offerlist_print(offers);
  39.  
  40.     /* Apertura del socket, inizio server */
  41. /*    return 0;*/
  42.  
  43. EC_CLEANUP_BGN
  44.         sessionlist_free(&sessions);
  45.         requestlist_free(&requests);
  46.         offerlist_free(&offers);
  47. /*        authlist_free(&authlist);*/
  48.  
  49.         closeSocket(server_sock);
  50.  
  51.         printf("Unlinking\n");
  52.         unlink(SOCKNAME);
  53.  
  54.         free_graph(&map);
  55.  
  56.         if (logfile != NULL) fclose(logfile);
  57.         if (cityfile != NULL) fclose(cityfile);
  58.         if (edgefile != NULL) fclose(edgefile);
  59.  
  60.         return ret;
  61. EC_CLEANUP_END
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement