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

Linux Cross Reference
Tina4/src/sys/gen/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   if (!fd)
 23                 return 0;
 24   sprintf(header, "Tina Structure Data. Version %s\n", ts_version_get());
 25         write(fd, (void *)header, 64);
 26   s = ts_serialise_gen(s, data);
 27   count = ts_serialise_end();
 28   swrite_ts(fd, s, count);        
 29 
 30   return 1;
 31 }
 32 
 33 
 34 /* 
 35          Read the Tina data tree into pointer 'dp' from  file descriptor
 36  */
 37 int ts_sread(void **dp, int fd)
 38 {
 39   List *s=NULL;
 40   int   count;
 41         char  header[64];
 42   char  version[25];
 43 
 44   if(!fd)
 45                 return 0;
 46 
 47   if (read(fd, header, 64) != 64)
 48         {
 49                 *(dp) = NULL;
 50                 return 0;
 51         }
 52 
 53         if (sscanf(header, "Tina Structure Data. Version %s\n", version) != 1)
 54         {
 55           *(dp)=NULL;
 56           return 0;
 57         }
 58 
 59   s = sread_ts(fd, &count);
 60 
 61   if(strcmp(version,ts_version_get()))
 62                 ts_upgrade_data(s, version);     
 63   s = ts_deserialise_gen(s, dp);
 64 
 65   return 1;
 66 }
 67 

~ [ 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.