22 GRAS_DEFINE_TYPE(struct_s_mixed,
40 struct list * cons(int v, struct list *l);
42 string_size_callback(void *vars,
43 struct s_gs_type *p_type,
48 cons(int v, struct list *l) {
49 struct list *nl = malloc(sizeof (struct list));
58 string_size_callback(void *vars,
59 struct s_gs_type *p_type,
61 return 1+(long int)strlen(data);
66 main(int argc, char **argv) {
67 struct list *l = NULL;
76 struct s_mixed mixed =
81 struct s_gs_type_driver *t_driver = NULL;
82 struct s_gs_net_driver *n_driver = NULL;
83 struct s_gs_type_bag *bag = NULL;
84 struct s_gs_connection *cnx = NULL;
86 struct s_gs_type_bag_ops *bag_ops = NULL;
88 struct s_gs_type *t_signed_int = NULL;
89 struct s_gs_type *t_list = NULL;
90 struct s_gs_type *t_ref_list = NULL;
92 struct s_gs_type *t_array = NULL;
94 struct s_gs_type *t_ref_sint = NULL;
95 struct s_gs_type *t_pair = NULL;
97 struct s_gs_type *t_char = NULL;
98 struct s_gs_type *t_string = NULL;
101 struct s_gs_type *t_u_char = NULL;
102 struct s_gs_type *t_u_long_int = NULL;
105 struct s_gs_type *t_mixed = NULL;
107 struct s_gs_message *m = NULL;
108 struct s_gs_message_instance *mi = NULL;
112 gs_purge_cmd_line(&argc, argv);
113 gras_log_control_set("NDR.thresh=debug");
115 t_driver = gs_type_driver_init("rl");
116 n_driver = gs_net_driver_init("fd");
118 bag = gs_type_bag_alloc(t_driver);
119 bag_ops = bag->bag_ops;
123 cnx = gs_net_connection_connect(n_driver, &fd);
126 bag_ops->register_outgoing_connection(bag, cnx);
129 t_signed_int = bag_ops->get_type_by_name(bag, NULL, "signed int");
130 t_list = gs_type_new_struct(bag, NULL, "list");
131 t_ref_list = gs_type_new_ref(bag, NULL, "p_list", t_list);
133 gs_type_struct_append_field(t_list, "v", t_signed_int);
134 gs_type_struct_append_field(t_list, "l", t_ref_list);
137 t_array = gs_type_new_array(bag, NULL, "array", 5, t_signed_int);
140 t_ref_sint = gs_type_new_ref(bag, NULL, "p_ref_sint", t_signed_int);
141 t_pair = gs_type_new_struct(bag, NULL, "pair");
143 gs_type_struct_append_field(t_pair, "pa", t_ref_sint);
144 gs_type_struct_append_field(t_pair, "pb", t_ref_sint);
147 t_char = bag_ops->get_type_by_name(bag, NULL, "signed char");
148 t_string = gs_type_new_array_with_callback(bag, NULL, "string", -1, t_char, string_size_callback, NULL);
152 t_mixed = gs_type_get_by_symbol(bag,struct_s_mixed);
154 t_u_char = bag_ops->get_type_by_name(bag, NULL, "unsigned char");
155 t_u_long_int = bag_ops->get_type_by_name(bag, NULL, "unsigned long int");
156 t_mixed = gs_type_new_struct(bag, NULL, "s_mixed");
158 gs_type_struct_append_field(t_mixed, "c1", t_u_char);
159 gs_type_struct_append_field(t_mixed, "l1", t_u_long_int);
160 gs_type_struct_append_field(t_mixed, "c2", t_u_char);
161 gs_type_struct_append_field(t_mixed, "l2", t_u_long_int);
164 /* message declaration */
165 m = gs_message_new(bag, NULL, "my msg");
166 gs_message_append_new_sequence(m, t_ref_list);
167 gs_message_append_new_sequence(m, t_array);
168 gs_message_append_new_sequence(m, t_pair);
169 gs_message_append_new_sequence(m, t_string);
170 gs_message_append_new_sequence(m, t_mixed);
177 pair.pa = malloc(sizeof(int));
182 mi = gs_message_init_send_by_name(bag, cnx, "my msg");
183 fprintf(stderr, "\nsending sequence 1\n----------------\n");
184 gs_message_send_next_sequence(mi, &l);
185 fprintf(stderr, "\nsending sequence 2\n----------------\n");
186 gs_message_send_next_sequence(mi, (void*)array);
187 fprintf(stderr, "\nsending sequence 3\n----------------\n");
188 gs_message_send_next_sequence(mi, &pair);
189 fprintf(stderr, "\nsending sequence 4\n----------------\n");
190 gs_message_send_next_sequence(mi, (void*)"Hello, World");
191 fprintf(stderr, "\nsending sequence 5\n----------------\n");
192 gs_message_send_next_sequence(mi, (void*)&mixed);