#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/timeb.h>
#include <string.h>
#ifdef __linux__
#include <unistd.h>
#else
#include <windows.h>
#endif
unsigned int message_mask;
{
if (mess_struct_ptr->
category & message_mask)
{
}
}
void DeviceData(const char *device_key,
int packet_length,
unsigned char *packet_buffer_ptr)
{
unsigned int count;
for (count = 0; count*
sizeof(
cfdp_struct_type) < (
unsigned int)packet_length; count++)
{
{
printf(
"Message %s\n",cfdp_struct_ptr->
message);
}
{
printf("Progress Transaction_id %s -> %s\t file size=%lld\t bytes trans=%lld\t percent trans=%u%%\n",
}
}
}
int CreateDataFile(char *pathname,
unsigned int file_size)
{
FILE *file_ptr = NULL;
char fill_data[250];
unsigned int i;
if ((file_ptr = fopen(pathname,"wb")) == NULL)
{
printf("Error Failed to open example data file.\n");
}
else
{
memset(fill_data,0xfe,sizeof(fill_data));
for (i = 0; i < file_size; i+=sizeof(fill_data))
fwrite(fill_data,1,sizeof(fill_data),file_ptr);
fflush(file_ptr);
fclose(file_ptr);
}
}
int InitExampleDataFiles(char *pathname3MB,
char *destination_pathname3MB)
{
struct timeb timebuffer;
char home_path[256];
{
}
ftime(&timebuffer);
sprintf(pathname3MB, "%s/get_example_1_data_file_3MB",home_path);
if (CreateDataFile(pathname3MB,3000000) ==
FAIL)
{
}
sprintf(destination_pathname3MB,"%s_%u",pathname3MB,
(unsigned int)timebuffer.time);
}
int MonitorTransactions(unsigned int monitor_timeout,
unsigned int transaction_count)
{
int return_value;
unsigned int current_transaction_count = 0;
unsigned int final_transaction_count = transaction_count;
unsigned int number_of_cfdp_structs = 0;
struct timeb start_timebuffer;
struct timeb current_timebuffer;
unsigned int i;
ftime(&start_timebuffer);
while (current_transaction_count != final_transaction_count)
{
number_of_cfdp_structs = final_transaction_count;
{
free(cfdp_struct_array_ptr);
cfdp_struct_array_ptr =
final_transaction_count = number_of_cfdp_structs;
cfdp_struct_array_ptr);
}
{
for (i=0; i<number_of_cfdp_structs; i++)
{
if (cfdp_struct_array_ptr[i].cfdp_status ==
DS_CANCEL ||
cfdp_struct_array_ptr[i].cfdp_status ==
DS_SUCCESS ||
cfdp_struct_array_ptr[i].cfdp_status ==
DS_FAIL ||
cfdp_struct_array_ptr[i].cfdp_status ==
DS_ABANDON ||
cfdp_struct_array_ptr[i].cfdp_status ==
DS_UNKNOWN)
{
if (cfdp_struct_array_ptr[i].cfdp_status !=
DS_SUCCESS)
{
printf("Info Failed to execute put file for destination pathname: %s and eid: %d.\n",
cfdp_struct_array_ptr[i].destination_pathname,
(int)cfdp_struct_array_ptr[i].eid);
}
current_transaction_count += 1;
}
}
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
ftime(¤t_timebuffer);
if (current_timebuffer.time - start_timebuffer.time >
monitor_timeout)
{
printf("Error CFDP monitor transaction timeout.\n");
current_transaction_count= final_transaction_count;
}
}
else
{
printf("Error Failed to GetCFDPStructArray.\n");
current_transaction_count = final_transaction_count;
}
}
free(cfdp_struct_array_ptr);
return(return_value);
}
int main(int argc, char *argv[])
{
char pathname[256];
char pathname3MB[256];
char destination_pathname3MB[256];
long long eid;
unsigned int transaction_count;
unsigned int timeout_in_sec;
char log_path[256];
char log_filename[256];
strcpy (pathname, "./cfdp_get_example_1_config.txt");
if (argc == 2)
{
strcpy(pathname,argv[1]);
}
else if (argc > 2)
{
printf("Error Command line contains too many arguments.\n");
return 0;
}
strcpy(log_path,"");
strcpy(log_filename,"cfdp_get_example_1_log_file");
log_filename,
{
{
printf("Error Failed to GetDisplayMessageMask.\n");
}
{
printf("Error Failed to RegisterCFDPDeviceData.\n");
}
if (InitExampleDataFiles(pathname3MB,
destination_pathname3MB) !=
SUCCESS)
{
printf("Error Failed to InitExampleDataFiles.\n");
return 0;
}
printf("\nGet Example 1\n\n");
eid = 100;
destination_pathname3MB,
eid,
{
timeout_in_sec = 30;
transaction_count = 1;
if (MonitorTransactions(timeout_in_sec,
{
printf("Error Failed to MonitorTransactions.\n");
remove(pathname3MB);
return 0;
}
}
else
{
printf("Error Failed 3Mb GetComponentCFDP.\n");
remove(pathname3MB);
return 0;
}
remove(pathname3MB);
}
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
return 0;
}