home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / test-pack1.c < prev    next >
C/C++ Source or Header  |  2005-11-09  |  929b  |  45 lines

  1. #include <stdlib.h>
  2. #ifdef HAVE_MALLOC_H
  3. #include <malloc.h>
  4. #endif
  5. #include <string.h>
  6. #include <pvfs2-request.h>
  7. #include <pint-request.h>
  8.  
  9. int main(int argc, char **argv)
  10. {
  11.     struct PINT_Request *r;
  12.     struct PINT_Request *r_packed;
  13.     int r_size;
  14.  
  15.     /* build a request */
  16.     PVFS_Request_vector(16, 4, 64, PVFS_DOUBLE, &r);
  17.     PINT_dump_request(r);
  18.  
  19.     /* pack the request */
  20.     r_size = PINT_REQUEST_PACK_SIZE(r);
  21.     r_packed = (struct PINT_Request *)malloc(r_size);
  22.     PINT_request_commit(r_packed, r);
  23.     PINT_dump_request(r_packed);
  24.  
  25.     /* now prepare for sending on wire */
  26.     PINT_request_encode(r_packed);
  27.  
  28.     {
  29.         struct PINT_Request *r2;
  30.         r2 = (struct PINT_Request *)malloc(r_size);
  31.         memcpy(r2, r_packed, r_size); /* simulates sending on wire */
  32.  
  33.         /* now we'll unencode and see what we have */
  34.         PINT_request_decode(r2);
  35.  
  36.         /* for now we'll just dump the request */
  37.         PINT_dump_request(r2);
  38.  
  39.         /* we're done */
  40.         free(r2);
  41.     }
  42.  
  43.     return 0;
  44. }
  45.