~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/serial/ts_snd_rcv.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2          ts_snd_rcv.c
  3 
  4          functions to send and receive TINA data structures
  5          via sockets
  6 */
  7 #include <tina/sys.h>
  8 #include <tina/sysfuncs.h>
  9 #include <time.h>
 10 #include <string.h>
 11 
 12 
 13 /* 
 14          Write the Tina data tree at 'data' to file descriptor fd
 15 */
 16 int ts_swrite(void *data, int fd)
 17 {
 18   List   *s = NULL;
 19         char    header[64];
 20   int     count;
 21   
 22   sprintf(header, "Tina Structure Data. Version %s\n", ts_version_get());
 23         write(fd, (void *)header, 64);
 24   s = ts_serialise_gen(s, data);
 25   count = ts_serialise_end();
 26   swrite_ts(fd, s, count);        
 27 
 28   return 1;
 29 }
 30 
 31 
 32 /* 
 33          Read the Tina data tree into pointer 'dp' from  file descriptor
 34  */
 35 int ts_sread(void **dp, int fd)
 36 {
 37   List *s=NULL;
 38   int   count;
 39         char  header[64];
 40   char  version[25];
 41 
 42   if (read(fd, header, 64) != 64)
 43         {
 44                 *(dp) = NULL;
 45                 return 0;
 46         }
 47 
 48         if (sscanf(header, "Tina Structure Data. Version %s\n", version) != 1)
 49         {
 50           *(dp)=NULL;
 51           return 0;
 52         }
 53 
 54   s = (List *)sread_ts(fd, &count);
 55 
 56   if(strcmp(version,ts_version_get()))
 57                 ts_upgrade_data(s, version);     
 58   s = ts_deserialise_gen(s, dp);
 59 
 60   return 1;
 61 }
 62 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.