FACT++  1.0
int copy_swap_buffer_out ( int  format,
FORMAT_STR format_data,
void *  buff_out,
void *  buff_in,
int  size 
)

Definition at line 170 of file copy_swap.c.

References check_padding(), Dis_padding, FORMAT_STR::flags, get_curr_bytes(), inc_pter, NOSWAP, FORMAT_STR::par_bytes, FORMAT_STR::par_num, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_LONG, SIZEOF_SHORT, SWAPD, SWAPL, and SWAPS.

Referenced by execute_service(), and send_command().

171 {
172  int num = 0, pad_num = 0, curr_size = 0, curr_out = 0;
173  int next_par_bytes, curr_par_num;
174 
175  if(format){}
176  if(!format_data->par_bytes) {
177  if(buff_in != buff_out)
178  memcpy( buff_out, buff_in, (size_t)size );
179  return(size);
180  }
181  next_par_bytes = format_data->par_bytes;
182  while(next_par_bytes)
183  {
184  curr_par_num = format_data->par_num;
185  if((curr_size+(curr_par_num * format_data->par_bytes))
186  > size)
187  {
188  curr_par_num = (size - curr_size)/format_data->par_bytes;
189  next_par_bytes = 0;
190  }
191  switch(format_data->flags & 0x3)
192  {
193  case NOSWAP :
194 
195  num = get_curr_bytes(curr_par_num,
196  size - curr_size, SIZEOF_CHAR);
197 
198  memcpy( buff_out, buff_in, (size_t)num);
199  inc_pter( buff_in, num);
200  inc_pter( buff_out, num);
201  curr_out += num;
202  break;
203  case SWAPS :
204  num = get_curr_bytes(curr_par_num,
205  size - curr_size, SIZEOF_SHORT);
206 
207  if(Dis_padding)
208  {
209  if( (pad_num = check_padding(curr_size, SIZEOF_SHORT)) )
210  {
211  inc_pter( buff_in, pad_num);
212  curr_size += pad_num;
213  }
214  }
215  memcpy( buff_out, buff_in, (size_t)num);
216  inc_pter( buff_in, num);
217  inc_pter( buff_out, num);
218  curr_out += num;
219  break;
220  case SWAPL :
221  num = get_curr_bytes(curr_par_num,
222  size - curr_size, SIZEOF_LONG);
223 
224  if(Dis_padding)
225  {
226  if( (pad_num = check_padding(curr_size, SIZEOF_LONG)) )
227  {
228  inc_pter( buff_in, pad_num);
229  curr_size += pad_num;
230  }
231  }
232  memcpy( buff_out, buff_in, (size_t)num);
233  inc_pter( buff_in, num);
234  inc_pter( buff_out, num);
235  curr_out += num;
236  break;
237  case SWAPD :
238  num = get_curr_bytes(curr_par_num,
239  size - curr_size, SIZEOF_DOUBLE);
240 
241  if(Dis_padding)
242  {
243 #ifdef PADD64
244  if( (pad_num = check_padding(curr_size, SIZEOF_DOUBLE)) )
245 #else
246  if( (pad_num = check_padding(curr_size, SIZEOF_LONG)) )
247 #endif
248  {
249  inc_pter( buff_in, pad_num);
250  curr_size += pad_num;
251  }
252  }
253  memcpy( buff_out, buff_in, (size_t)num);
254  inc_pter( buff_in, num);
255  inc_pter( buff_out, num);
256  curr_out += num;
257  break;
258  }
259 #ifdef vms
260  check_vms_out(format_data->flags, format, curr_par_num, buff_out);
261 #endif
262  curr_size += num;
263  format_data++;
264  if(next_par_bytes)
265  next_par_bytes = format_data->par_bytes;
266  }
267  return(curr_out);
268 }
Definition: dim.h:191
static int check_padding(int curr_bytes, int item_size)
Definition: copy_swap.c:159
static int Dis_padding
Definition: copy_swap.c:23
#define inc_pter(p, i)
Definition: dim.h:605
short flags
Definition: dim.h:219
Definition: dim.h:191
Definition: dim.h:191
#define SIZEOF_CHAR
Definition: dim.h:596
short par_bytes
Definition: dim.h:218
#define SIZEOF_DOUBLE
Definition: dim.h:600
int par_num
Definition: dim.h:217
#define SIZEOF_LONG
Definition: dim.h:598
int size
Definition: db_dim_server.c:17
static int get_curr_bytes(int items, int bytes_left, int item_size)
Definition: copy_swap.c:35
#define SIZEOF_SHORT
Definition: dim.h:597
Definition: dim.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function: