FACT++  1.0
static void execute_service ( DIS_PACKET packet,
DIC_SERVICE servp,
int  size 
)
static

Definition at line 376 of file dic.c.

References buffer, copy_swap_buffer_in(), DIS_HEADER, DIS_STAMPED_HEADER, FORMAT_STR::flags, dic_serv::format, dic_serv::format_data, Memory::free(), Memory::malloc(), MAX_NAME, FORMAT_STR::par_bytes, dic_serv::quality, dic_serv::serv_address, dic_serv::serv_size, dic_serv::stamped, dic_serv::tag, dic_serv::time_stamp, and dic_serv::user_routine.

Referenced by recv_rout().

377 {
378  int format;
379  FORMAT_STR format_data_cp[MAX_NAME/4], *formatp;
380  static int *buffer;
381  static int buffer_size = 0;
382  int add_size;
383  int *pkt_buffer, header_size;
384 
385  Current_server = servp;
386  format = servp->format;
387  memcpy(format_data_cp, servp->format_data, sizeof(format_data_cp));
388  if((format & 0xF) == ((MY_FORMAT) & 0xF))
389  {
390  for(formatp = format_data_cp; formatp->par_bytes; formatp++)
391  formatp->flags &= (short)0xFFF0; /* NOSWAP */
392  }
393  if( servp->stamped)
394  {
395  pkt_buffer = ((DIS_STAMPED_PACKET *)packet)->buffer;
396  header_size = DIS_STAMPED_HEADER;
397  servp->time_stamp[0] = vtohl(((DIS_STAMPED_PACKET *)packet)->time_stamp[0]);
398  if(((unsigned)servp->time_stamp[0] & 0xFFFF0000) == 0xc0de0000)
399  {
400 /*
401  servp->time_stamp[0] &= 0x0000FFFF;
402 */
403  servp->time_stamp[1] = vtohl(((DIS_STAMPED_PACKET *)packet)->time_stamp[1]);
404  servp->quality = vtohl(((DIS_STAMPED_PACKET *)packet)->quality);
405  }
406  else if((vtohl(((DIS_STAMPED_PACKET *)packet)->reserved[0])) == (int)0xc0dec0de)
407  {
408 /*
409  servp->time_stamp[0] &= 0x0000FFFF;
410 */
411  servp->time_stamp[1] = vtohl(((DIS_STAMPED_PACKET *)packet)->time_stamp[1]);
412  servp->quality = vtohl(((DIS_STAMPED_PACKET *)packet)->quality);
413  }
414  else
415  {
416  pkt_buffer = ((DIS_PACKET *)packet)->buffer;
417  header_size = DIS_HEADER;
418  }
419  }
420  else
421  {
422  pkt_buffer = ((DIS_PACKET *)packet)->buffer;
423  header_size = DIS_HEADER;
424  }
425  size -= header_size;
426  if( servp->serv_address )
427  {
428  if( size > servp->serv_size )
429  size = servp->serv_size;
430  add_size = copy_swap_buffer_in(format_data_cp,
431  servp->serv_address,
432  pkt_buffer, size);
433  if( servp->user_routine )
434  (servp->user_routine)(&servp->tag, servp->serv_address, &add_size );
435  }
436  else
437  {
438  if( servp->user_routine )
439  {
440  add_size = size + (size/2);
441  if(!buffer_size)
442  {
443  buffer = (int *)malloc((size_t)add_size);
444  buffer_size = add_size;
445  }
446  else
447  {
448  if( add_size > buffer_size )
449  {
450  free(buffer);
451  buffer = (int *)malloc((size_t)add_size);
452  buffer_size = add_size;
453  }
454  }
455  add_size = copy_swap_buffer_in(format_data_cp,
456  buffer,
457  pkt_buffer, size);
458  (servp->user_routine)( &servp->tag, buffer, &add_size );
459  }
460  }
461  Current_server = 0;
462 }
#define MAX_NAME
Definition: dim.h:182
int stamped
Definition: dim.h:478
int copy_swap_buffer_in(FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
Definition: copy_swap.c:270
int time_stamp[2]
Definition: dim.h:479
short flags
Definition: dim.h:219
void * malloc()
Definition: EventBuilder.cc:99
#define DIS_STAMPED_HEADER
Definition: dim.h:260
int quality
Definition: dim.h:480
short par_bytes
Definition: dim.h:218
void(* user_routine)()
Definition: dim.h:472
dim_long tag
Definition: dim.h:473
int * serv_address
Definition: dim.h:468
static DIC_SERVICE * Current_server
Definition: dic.c:43
FORMAT_STR format_data[MAX_NAME/4]
Definition: dim.h:462
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int size
Definition: db_dim_server.c:17
void free(void *mem)
int format
Definition: dim.h:464
#define DIS_HEADER
Definition: dim.h:249
int serv_size
Definition: dim.h:469

+ Here is the call graph for this function:

+ Here is the caller graph for this function: