2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: main.c,v 1.4.6.3 2007-05-28 12:55:48 zer0 Exp $
23 #include <aversive/list.h>
30 LIST_TYPEDEF(my_list_type, u08, 4);
31 LIST_TYPEDEF(my_another_list_type, u08, 10);
33 void dumplist(struct generic_list * l)
37 for(i=0 ; i < l->hdr.size ; i++)
38 printf( (i != l->hdr.size-1 ?
39 "|-------" : "|-------|"CR) );
41 for(i=0 ; i < l->hdr.size ; i++) {
42 if (( i < l->hdr.beg_indice ) && (l->hdr.cur_size > 0)) {
43 if (i < (l->hdr.beg_indice
46 printf(" %.3d ", l->elt[i]);
53 else if (l->hdr.cur_size > 0){
54 if (i < l->hdr.beg_indice + l->hdr.cur_size) {
55 printf(" %.3d ", l->elt[i]);
66 printf(" cur_size=%d"CR,l->hdr.cur_size);
68 for(i=0 ; i < l->hdr.size ; i++)
69 printf( (i != l->hdr.size-1 ?
70 "|-------" : "|-------|"CR) );
72 for(i=0 ; i < l->hdr.size ; i++)
74 if((i == l->hdr.beg_indice) && (l->hdr.cur_size <= 1))
76 else if(i == l->hdr.beg_indice)
78 else if((l->hdr.cur_size > 1) &&
79 (i == ((l->hdr.beg_indice + l->hdr.cur_size -1)
84 printf( (i != l->hdr.size-1 ?
88 for(i=0 ; i < l->hdr.size ; i++)
90 if(i == ((l->hdr.beg_indice + l->hdr.read_cursor)
95 printf( (i != l->hdr.size-1 ?
109 /* fdevopen((int (*)(char))uart0_send,(int (*)(void))uart0_recv,0); */
111 my_list_type my_list ;
112 my_another_list_type another_list ;
114 LIST_INIT(my_list, 0);
115 LIST_INIT(another_list, 8);
117 dumplist((struct generic_list *)&my_list);
120 LIST_PUSH_END(my_list, 2);
121 dumplist((struct generic_list *)&my_list);
124 LIST_PUSH_END(my_list, 3);
125 dumplist((struct generic_list *)&my_list);
128 LIST_PUSH_START(my_list, 1);
129 dumplist((struct generic_list *)&my_list);
132 LIST_PUSH_END(my_list, 4);
133 dumplist((struct generic_list *)&my_list);
136 LIST_PUSH_END(my_list, 5);
137 dumplist((struct generic_list *)&my_list);
141 LIST_PULL_END(my_list, &tmp);
142 dumplist((struct generic_list *)&my_list);
143 printf("tmp = %d"CR CR CR,tmp);
146 LIST_READ_START(my_list, &tmp);
147 dumplist((struct generic_list *)&my_list);
148 printf("tmp = %d"CR CR CR,tmp);
150 LIST_READ_END(my_list, &tmp);
151 dumplist((struct generic_list *)&my_list);
152 printf("tmp = %d"CR CR CR,tmp);
154 LIST_READ_GOTO(my_list, &tmp, 0);
155 dumplist((struct generic_list *)&my_list);
156 printf("tmp = %d"CR CR CR,tmp);
158 LIST_READ_GOTO(my_list, &tmp, 1);
159 dumplist((struct generic_list *)&my_list);
160 printf("tmp = %d"CR CR CR,tmp);
162 LIST_READ_GOTO(my_list, &tmp, 2);
163 dumplist((struct generic_list *)&my_list);
164 printf("tmp = %d"CR CR CR,tmp);
166 LIST_READ_GOTO(my_list, &tmp, 3);
167 dumplist((struct generic_list *)&my_list);
168 printf("tmp = %d"CR CR CR,tmp);
170 LIST_READ_MOVE(my_list, &tmp, 1);
171 dumplist((struct generic_list *)&my_list);
172 printf("tmp = %d"CR CR CR,tmp);
174 LIST_READ_MOVE(my_list, &tmp, 1);
175 dumplist((struct generic_list *)&my_list);
176 printf("tmp = %d"CR CR CR,tmp);
178 LIST_READ_MOVE(my_list, &tmp, 1);
179 dumplist((struct generic_list *)&my_list);
180 printf("tmp = %d"CR CR CR,tmp);
182 LIST_READ_MOVE(my_list, &tmp, 1);
183 dumplist((struct generic_list *)&my_list);
184 printf("tmp = %d"CR CR CR,tmp);
186 LIST_READ_MOVE(my_list, &tmp, 2);
187 dumplist((struct generic_list *)&my_list);
188 printf("tmp = %d"CR CR CR,tmp);
190 LIST_READ_MOVE(my_list, &tmp, 3);
191 dumplist((struct generic_list *)&my_list);
192 printf("tmp = %d"CR CR CR,tmp);
194 LIST_READ_MOVE(my_list, &tmp, 1);
195 dumplist((struct generic_list *)&my_list);
196 printf("tmp = %d"CR CR CR,tmp);
198 LIST_READ_MOVE(my_list, &tmp, 2);
199 dumplist((struct generic_list *)&my_list);
200 printf("tmp = %d"CR CR CR,tmp);
202 LIST_READ_MOVE(my_list, &tmp, 3);
203 dumplist((struct generic_list *)&my_list);
204 printf("tmp = %d"CR CR CR,tmp);
206 LIST_READ_MOVE(my_list, &tmp, -1);
207 dumplist((struct generic_list *)&my_list);
208 printf("tmp = %d"CR CR CR,tmp);
210 LIST_READ_MOVE(my_list, &tmp, -2);
211 dumplist((struct generic_list *)&my_list);
212 printf("tmp = %d"CR CR CR,tmp);
214 LIST_READ_MOVE(my_list, &tmp, -3);
215 dumplist((struct generic_list *)&my_list);
216 printf("tmp = %d"CR CR CR,tmp);
220 LIST_PULL_END(my_list, &tmp);
221 dumplist((struct generic_list *)&my_list);
222 printf("tmp = %d"CR CR CR,tmp);
224 LIST_PULL_START(my_list, &tmp);
225 dumplist((struct generic_list *)&my_list);
226 printf("tmp = %d"CR CR CR,tmp);
228 LIST_PULL_START(my_list, &tmp);
229 dumplist((struct generic_list *)&my_list);
230 printf("tmp = %d"CR CR CR,tmp);
232 LIST_PULL_START(my_list, &tmp);
233 dumplist((struct generic_list *)&my_list);
238 LIST_ARRAY_PUSH_START(another_list, tab1, 4);
239 dumplist((struct generic_list *)&another_list);
242 LIST_ARRAY_PUSH_END(another_list, "abcde", 5);
243 dumplist((struct generic_list *)&another_list);
246 LIST_ARRAY_PULL_START(another_list, tab2, 4);
247 dumplist((struct generic_list *)&another_list);
250 LIST_ARRAY_PULL_END(another_list, tab2, 2);
251 dumplist((struct generic_list *)&another_list);
254 LIST_ALIGN_LEFT(another_list);
255 dumplist((struct generic_list *)&another_list);
259 LIST_INIT(my_list,0);
260 dumplist((struct generic_list *)&my_list);
263 LIST_ARRAY_PUSH_START(my_list, tab1, 3);
264 dumplist((struct generic_list *)&my_list);
267 LIST_ALIGN_LEFT(my_list);
268 dumplist((struct generic_list *)&my_list);