nfs-ganesha 1.4
|
00001 /* 00002 * Copyright IBM Corporation, 2010 00003 * Contributor: Aneesh Kumar K.v <aneesh.kumar@linux.vnet.ibm.com> 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 3 of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 * --------------------------------------- 00021 */ 00022 00023 #include <stdio.h> 00024 #include "nlm_list.h" 00025 00026 struct myteststruct 00027 { 00028 int value; 00029 struct glist_head glist; 00030 }; 00031 00032 struct glist_head mytestglist; 00033 struct glist_head mytestglist_new; 00034 00035 static void print_glist(struct glist_head *head) 00036 { 00037 struct myteststruct *entry; 00038 struct glist_head *glist; 00039 00040 glist_for_each(glist, head) 00041 { 00042 entry = glist_entry(glist, struct myteststruct, glist); 00043 printf("The value is %d\n", entry->value); 00044 } 00045 } 00046 00047 int main(int argc, char *argv[]) 00048 { 00049 struct myteststruct node1; 00050 struct myteststruct node2; 00051 struct myteststruct node3; 00052 struct myteststruct node4; 00053 struct myteststruct node1_new; 00054 struct myteststruct node2_new; 00055 init_glist(&mytestglist); 00056 init_glist(&mytestglist_new); 00057 node1.value = 10; 00058 node2.value = 11; 00059 node3.value = 12; 00060 glist_add(&mytestglist, &node1.glist); 00061 glist_add(&mytestglist, &node2.glist); 00062 glist_add(&mytestglist, &node3.glist); 00063 00064 print_glist(&mytestglist); 00065 printf("Now test tail add\n"); 00066 node4.value = 13; 00067 glist_add_tail(&mytestglist, &node4.glist); 00068 print_glist(&mytestglist); 00069 printf("Delete test\n"); 00070 glist_del(&node2.glist); 00071 print_glist(&mytestglist); 00072 node1_new.value = 15; 00073 node2_new.value = 16; 00074 glist_add(&mytestglist_new, &node1_new.glist); 00075 glist_add(&mytestglist_new, &node2_new.glist); 00076 printf("Add the below two list\n"); 00077 printf("list1\n"); 00078 print_glist(&mytestglist); 00079 printf("list2\n"); 00080 print_glist(&mytestglist_new); 00081 glist_add_list_tail(&mytestglist, &mytestglist_new); 00082 printf("combined list\n"); 00083 print_glist(&mytestglist); 00084 return 0; 00085 }