예제 #1
0
파일: acr_nema.c 프로젝트: BIC-MNI/xdisp
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_get_short
@INPUT      : nvals - number of values to convert to short
              input_value - pointer to array of input values
@OUTPUT     : mach_value - pointer to array of shorts
@RETURNS    : (nothing)
@DESCRIPTION: Converts input values to shorts.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : November 10, 1993 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
void acr_get_short(long nvals, void *input_value, 
                          unsigned short *mach_value)
{
   long i;
   char *ptr1, *ptr2, v0, v1;

   /* Check whether a flip is needed */
   if (acr_need_invert()) {
      ptr1 = (char *) input_value;
      ptr2 = (char *) mach_value;
      for (i=0; i<nvals; i++) {
         v0 = ptr1[1];
         v1 = ptr1[0];
         ptr2[0] = v0;
         ptr2[1] = v1;
         ptr1 += ACR_SIZEOF_SHORT;
         ptr2 += sizeof(mach_value[0]);
      }
   }
   else {
      (void) memcpy((void *) mach_value, input_value, 
                    (size_t) (nvals*sizeof(unsigned short)));
   }

   return ;
}
예제 #2
0
파일: acr_nema.c 프로젝트: BIC-MNI/xdisp
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_put_long
@INPUT      : nvals - number of values to convert from long
              mach_value - pointer to array of longs
@OUTPUT     : output_value - pointer to array of output values
@RETURNS    : (nothing)
@DESCRIPTION: Converts longs to output values.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : November 10, 1993 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
void acr_put_long(long nvals, long *mach_value, void *output_value)
{
   long i;
   char *ptr1, *ptr2, v0, v1;

   /* Check whether a flip is needed */
   if (acr_need_invert()) {
      ptr1 = (char *) mach_value;
      ptr2 = (char *) output_value;
      for (i=0; i<nvals; i++) {
         v0 = ptr1[3];
         v1 = ptr1[0];
         ptr2[0] = v0;
         ptr2[3] = v1;
         v0 = ptr1[2];
         v1 = ptr1[1];
         ptr2[1] = v0;
         ptr2[2] = v1;
         ptr1 += sizeof(mach_value[0]);
         ptr2 += ACR_SIZEOF_LONG;
      }
   }
   else {
      (void) memcpy(output_value, (void *) mach_value, 
                    (size_t) (nvals*sizeof(long)));
   }

   return ;
}
예제 #3
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : invert_values
@INPUT      : byte_order - byte ordering for input values
              nvals - number of values to invert
              value_size - length of each value
              input_value - pointer to array of input values
@OUTPUT     : mach_value - pointer to array of inverted values
@RETURNS    : (nothing)
@DESCRIPTION: Reverses byte-ordering of an array of values to match machine
              byte order if necessary, otherwise the values are just copied.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : January 31, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
static void invert_values(Acr_byte_order byte_order, 
                          long nvals, size_t value_size, 
                          void *input_value, void *mach_value)
{
   long i;
   char *ptr1, *ptr2;

   /* Check whether a flip is needed */
   if (acr_need_invert(byte_order)) {
      acr_reverse_byte_order(nvals, value_size, input_value, mach_value);
   }
   else {
      ptr1 = (char *) input_value;
      ptr2 = (char *) mach_value;
      for (i=0; i<nvals*value_size; i++) {
         ptr2[i] = ptr1[i];
      }
   }

}