ruby plugin fixes
[opsoft.git] / gclib2 / unit_tests / pack.cxx
bloba01318c674ce956e166284b76fb90c3a36a5854f
1 /*
2 * (c) Oleg Puchinin 2008
3 * graycardinalster@gmail.com
5 */
7 #include <gclib2.h>
9 List * __init_list ()
11 List * l;
13 l = new List;
14 *l << "GOP" << "SUP" << "VOBLA" << "KUKISH";
15 return l;
18 Hash * __init_hash ()
20 Hash * h;
22 h = new Hash;
23 h->set ("Date", "yesterday");
24 h->set ("From", "Oleg");
25 h->set ("To", "Papka");
26 h->set ("Nyu", "Fu");
28 return h;
31 int main (int argc, char ** argv)
33 Buf * m_buf;
34 List * m_list;
35 Hash * m_hash;
36 char * str;
38 int i = 0;
40 m_list = __init_list ();
41 m_hash = __init_hash ();
43 str = "HELLO";
44 m_buf = pack ("clhs", 2, m_list, m_hash, str);
46 m_list = NULL;
47 m_hash = NULL;
48 str = NULL;
50 unpack (m_buf, "clhs", &i, &m_list, &m_hash, &str);
51 printf ("i = %i\n", i);
52 printf ("string = %s\n", str);
53 printf ("LIST:\n");
54 m_list->dump ();
55 printf ("Hash:\n");
56 m_hash->dump ();