Exemplo n.º 1
0
int main(int argc, char **argv) {

  int retval = 0;
    
  arguments_t a;
  unsigned long long session_size;
  
  if (pthread_mutex_init(&bufferLock, NULL) != 0)
  {
      fprintf(stderr,"\n bufferLock mutex init failed\n");
      exit(-1);
  }

  /*flute_receiver_report_t *report;*/

#if defined(_MSC_VER) && _DEBUG_MEMORY > 0
  _CrtSetDbgFlag(
        _CRTDBG_ALLOC_MEM_DF |
        _CRTDBG_CHECK_ALWAYS_DF |
        _CRTDBG_CHECK_CRT_DF |
        /*_CRTDBG_DELAY_FREE_MEM_DF |*/
        _CRTDBG_LEAK_CHECK_DF);
#endif
  
  if(start_up_flute() != 0) {
    return -1;
  }

  /* Set signal handler */
  
  signal(SIGINT, signal_handler);
#ifdef _MSC_VER
  signal(SIGBREAK, signal_handler);
#endif

  srand((unsigned)time(NULL));

  retval = parse_args(argc, argv, &a);
  
  if(retval == -1) {
    usage();
  }
  calling_main();

  //Malek El Khatib 15.05.2014
  //Start
  //Opening log file for writing
  printf("Opening Log File\n");
  logFilePtr=fopen(logFile, "w");
  fprintf(logFilePtr,"************************************************************************************************************************************************************\n");
  fprintf(logFilePtr,"Logger assumes that half word is not used, TOI field is 32 bits, FDT is NOT sent completely at beginning of session and that only one sender channel is used\n");
  fprintf(logFilePtr,"************************************************************************************************************************************************************\n");
  //End

  s_id = -1;
  
  if(a.alc_a.mode == SENDER) {
    
    if(a.alc_a.calculate_session_size == TRUE) {
      
      session_size = flute_session_size(&a, &s_id);

      if(a.alc_a.verbosity > 0) {
#ifdef _MSC_VER
	printf("Session size in bytes (including UDP/IP headers): %I64u\n", session_size);
#else
	printf("Session size in bytes (including UDP/IP headers): %llu\n", session_size);
#endif
      }
    }
    else {
      retval = flute_sender(&a, &s_id, &session_size);

      if(a.alc_a.verbosity > 0) {
#ifdef _MSC_VER
	printf("Total bytes sent: %I64u\n", session_size);
#else
	printf("Total bytes sent: %llu\n", session_size);
#endif
      }
    }
  }
  else if(a.alc_a.mode == RECEIVER) {
    
    retval = flute_receiver(&a, &s_id);
    
    /*
    retval = flute_receiver_report(&a, &s_id, &report);
    free_receiver_report(report);
    */
  }
  
	
  //Malek El Khatib 15.05.2014
  //Start
  //Closing log file
  printf("Closing Log File\n");
  fclose(logFilePtr);
  //End
  //START 13.1.2015
  char* CloseFile="Closed.html";
  FILE* CloseFilePtr;
  CloseFilePtr=fopen(CloseFile, "w");
  fprintf(CloseFilePtr,"Session Closed\n");
  chmod(CloseFile,S_IRWXU |S_IRWXG|S_IRWXO );
  fclose(CloseFilePtr);
  //END

  shut_down_flute(&a);

  return retval;
}
Exemplo n.º 2
0
int main(int argc, char **argv) {

  int retval = 0;
    
  arguments_t a;
  unsigned long long session_size;

  /*flute_receiver_report_t *report;*/

#if defined(_MSC_VER) && _DEBUG_MEMORY > 0
  _CrtSetDbgFlag(
        _CRTDBG_ALLOC_MEM_DF |
        _CRTDBG_CHECK_ALWAYS_DF |
        _CRTDBG_CHECK_CRT_DF |
        /*_CRTDBG_DELAY_FREE_MEM_DF |*/
        _CRTDBG_LEAK_CHECK_DF);
#endif
  
  if(start_up_flute() != 0) {
    return -1;
  }

  /* Set signal handler */
  
  signal(SIGINT, signal_handler);
#ifdef _MSC_VER
  signal(SIGBREAK, signal_handler);
#endif

  srand((unsigned)time(NULL));

  retval = parse_args(argc, argv, &a);
  
  if(retval == -1) {
    usage();
  }

  s_id = -1;
  
  if(a.alc_a.mode == SENDER) {
    
    if(a.alc_a.calculate_session_size == TRUE) {
      
      session_size = flute_session_size(&a, &s_id);

      if(a.alc_a.verbosity > 0) {
#ifdef _MSC_VER
	printf("Session size in bytes (including UDP/IP headers): %I64u\n", session_size);
#else
	printf("Session size in bytes (including UDP/IP headers): %llu\n", session_size);
#endif
      }
    }
    else {
      retval = flute_sender(&a, &s_id, &session_size);

      if(a.alc_a.verbosity > 0) {
#ifdef _MSC_VER
	printf("Total bytes sent: %I64u\n", session_size);
#else
	printf("Total bytes sent: %llu\n", session_size);
#endif
      }
    }
  }
  else if(a.alc_a.mode == RECEIVER) {
    
    retval = flute_receiver(&a, &s_id);
    
    /*
    retval = flute_receiver_report(&a, &s_id, &report);
    free_receiver_report(report);
    */
  }
  
  shut_down_flute(&a);

  return retval;
}