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

Linux Cross Reference
Tina4/src/serialise/ddlist.c

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

  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <tina/sys.h>
  4 #include <tina/math.h>
  5 #include <tina/genfuncs.h>
  6 void    ts_free_gen(void *data);
  7 void    ts_print_gen(void *data);
  8 List   *ts_deserialise_gen (List * lg, void **data);
  9 List   *ts_serialise_gen(List * lg, void *d);
 10 int     deserialise_tagged_item (List ** lgp, void **data);
 11 int     serialise_tagged_item(List ** lgp, void *data, size_t s);
 12 
 13 void Ddlist_ts_print(Ddlist *l)
 14 {
 15   mprintf("ddlist start{");
 16   while(l)
 17   {
 18     mprintf("struct ddlist{ int <type>%d, POINTER *<next>0x%x, "
 19             "POINTER *<last>0x%x, POINTER *<to>",
 20             l->type,l->next,l->last);
 21     ts_print_gen(l->to);
 22     mprintf("}ddlist; ");
 23     l=l->next;
 24     if(l && !repeatp_checker(l))
 25     { mprintf("Repeated list element\n");
 26       l=NULL;
 27     }
 28   }
 29   mprintf("}ddlist end ;");
 30 }
 31 
 32 List *Ddlist_ts_serialise(List * lg, Ddlist *l)
 33 {
 34   while(l)
 35   {
 36     if(serialise_tagged_item(&lg, l, sizeof(List)))
 37     {
 38       lg=ts_serialise_gen(lg,l->to);
 39       lg=Ddlist_ts_serialise(lg,l->last);
 40       l=l->next;
 41     }
 42     else break;
 43   }
 44   return lg;
 45 }
 46 
 47 List *Ddlist_ts_deserialise(List * lg, Ddlist **l)
 48 {
 49   do
 50   {
 51     if(deserialise_tagged_item(&lg, (void**)l))
 52     {
 53       if((*l)->to)
 54         lg=ts_deserialise_gen(lg,&((*l)->to));
 55       if((*l)->last)
 56         lg=Ddlist_ts_deserialise(lg,&((*l)->last));
 57       l=&((*l)->next);
 58     }
 59     else break;
 60   }while(*l);
 61   return lg;
 62 }
 63   
 64 void Ddlist_ts_free(Ddlist *l)
 65 {
 66   Ddlist *l2=l;
 67 
 68   while(l)
 69   {
 70     l2=l->next;
 71     ts_free_gen(l->to);
 72     rfree(l);
 73     if(l2 && !repeatp_checker(l2))
 74       l=NULL;
 75     else
 76       l=l2;
 77   }
 78 }
 79 

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