FACT++  1.0
void execute_command ( SERVICE servp,
DIC_PACKET packet 
)

Definition at line 1589 of file dis.c.

References buffer, DIC_PACKET::buffer, copy_swap_buffer_in(), DIC_HEADER, dis_set_timestamp(), FORMAT_STR::flags, DIC_PACKET::format, serv::format_data, Memory::free(), serv::id, IT_IS_FLOAT, Memory::malloc(), MAX_NAME, FORMAT_STR::par_bytes, size, DIC_PACKET::size, serv::tag, and serv::user_routine.

Referenced by dis_insert_request().

1590 {
1591  int size;
1592  int format;
1593  FORMAT_STR format_data_cp[MAX_NAME/4], *formatp;
1594  static int *buffer;
1595  static int buffer_size = 0;
1596  int add_size;
1597 
1598  size = vtohl(packet->size) - DIC_HEADER;
1599  add_size = size + (size/2);
1600  if(!buffer_size)
1601  {
1602  buffer = (int *)malloc((size_t)add_size);
1603  buffer_size = add_size;
1604  }
1605  else
1606  {
1607  if( add_size > buffer_size )
1608  {
1609  free(buffer);
1610  buffer = (int *)malloc((size_t)add_size);
1611  buffer_size = add_size;
1612  }
1613  }
1614 
1615  dis_set_timestamp(servp->id, 0, 0);
1616  if(servp->user_routine != 0)
1617  {
1618  format = vtohl(packet->format);
1619  memcpy(format_data_cp, servp->format_data, sizeof(format_data_cp));
1620  if((format & 0xF) == ((MY_FORMAT) & 0xF))
1621  {
1622  for(formatp = format_data_cp; formatp->par_bytes; formatp++)
1623  {
1624  if(formatp->flags & IT_IS_FLOAT)
1625  formatp->flags |= ((short)format & (short)0xf0);
1626  formatp->flags &= (short)0xFFF0; /* NOSWAP */
1627  }
1628  }
1629  else
1630  {
1631  for(formatp = format_data_cp; formatp->par_bytes; formatp++)
1632  {
1633  if(formatp->flags & IT_IS_FLOAT)
1634  formatp->flags |= ((short)format & (short)0xf0);
1635  }
1636  }
1637  size = copy_swap_buffer_in(format_data_cp,
1638  buffer,
1639  packet->buffer, size);
1640  (servp->user_routine)(&servp->tag, buffer, &size);
1641  }
1642 }
#define MAX_NAME
Definition: dim.h:182
int copy_swap_buffer_in(FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
Definition: copy_swap.c:270
short flags
Definition: dim.h:219
void * malloc()
Definition: EventBuilder.cc:99
#define DIC_HEADER
Definition: dim.h:240
dim_long tag
Definition: dis.c:80
short par_bytes
Definition: dim.h:218
FORMAT_STR format_data[MAX_NAME/4]
Definition: dis.c:76
#define IT_IS_FLOAT
Definition: dim.h:27
void(* user_routine)()
Definition: dis.c:79
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int size
Definition: dim.h:231
int size
Definition: db_dim_server.c:17
int buffer[1]
Definition: dim.h:237
int format
Definition: dim.h:236
void free(void *mem)
int dis_set_timestamp(unsigned serv_id, int secs, int millisecs)
Definition: dis.c:1956
int id
Definition: dis.c:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function: